public class FormatsHandler
{
static double height;
static double width;
static List<Format> listOfFormats = new List<Format>()
{
new Format(){ formatID="A4", height=297, width=210},// все в портретной ориентации
new Format(){ formatID="A3", height=420, width=297},
new Format(){ formatID="A2", height=594, width=420},
new Format(){ formatID="A1", height=841, width=594},
new Format(){ formatID="A0", height=1189, width=841}
};
//Points of inner frame
Point2d keyPoint1 = new Point2d(-width + 25, height - 10);
Point2d keyPoint2 = new Point2d(0, height - 10);
Point2d keyPoint3 = new Point2d(0, 0);
Point2d keyPoint4 = new Point2d(-width + 25, 0);
//Points of outer frame
Point2d frPoint1 = new Point2d(-width + 5, height - 5);
Point2d frPoint2 = new Point2d(5, height - 5);
Point2d frPoint3 = new Point2d(5, -5);
Point2d frPoint4 = new Point2d(-width + 5, -5);
[CommandMethod("2Insert title")]
public static void DrawTitles()
{
Format curFormat = GetDataFromUser();
if (curFormat.formatID == "A3" && curFormat.orientation == "Portrait" && curFormat.type == "Title")
{
height = listOfFormats[1].height;
width = listOfFormats[1].width;
}
else if(curFormat.formatID == "A3" && curFormat.orientation == "Landscape" && curFormat.type == "Title")
{
height = listOfFormats[1].width;
width = listOfFormats[1].height;
}
// else if (curFormat.formatID == "A2" && curFormat.orientation == "Portrait" && curFormat.type == "Title")
// {
// height = listOfFormats[2].height;
// width = listOfFormats[2].width;
// }
//else
// {
// height = listOfFormats[2].width;
// width = listOfFormats[2].height;
// }
FormatsHandler fh = new FormatsHandler();
fh.DrawMainTitle();
}
public static Format GetDataFromUser()
{
Document acDoc = Application.DocumentManager.MdiActiveDocument;
//Выбрать формат
PromptKeywordOptions chFormat = new PromptKeywordOptions("\nChoose format: ");
chFormat.Keywords.Add("A4");
chFormat.Keywords.Add("A3");
chFormat.Keywords.Add("A2");
chFormat.Keywords.Add("A1");
chFormat.Keywords.Add("A0");
chFormat.AllowNone = false;
PromptResult formatID = acDoc.Editor.GetKeywords(chFormat);
//Application.ShowAlertDialog("The name entered was: "+formatID.StringResult);
//Установить кратность
PromptStringOptions chMultiplier = new PromptStringOptions("\nSet multiplier: ");
chMultiplier.AllowSpaces = false;
PromptResult multiplier = acDoc.Editor.GetString(chMultiplier);
// Установить ориентацию
PromptKeywordOptions chOrient = new PromptKeywordOptions("\nSet orientation: ");
chOrient.Keywords.Add("Portrait");
chOrient.Keywords.Add("Landscape");
chOrient.Keywords.Default = "Landscape";
chOrient.AllowNone = false;
PromptResult orientation = acDoc.Editor.GetKeywords(chOrient);
// Установить тип
PromptKeywordOptions chType = new PromptKeywordOptions("\nSet type: ");
chType.Keywords.Add("Title");
chType.Keywords.Add("Regular");
chType.Keywords.Default = "Regular";
chType.AllowNone = false;
PromptResult type = acDoc.Editor.GetKeywords(chType);
Format curFormat = new Format()
{
formatID = formatID.ToString(),
multiplier = int.Parse(multiplier.StringResult),
orientation = orientation.ToString(),
type = type.ToString()
};
return curFormat;
}
public void DrawMainTitle()
{
}