Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > .NET Frameworks (точка нет фреймворки) > C# (си шарп)
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 25.05.2018, 21:07   #1
Parohod
Новичок
Джуниор
 
Регистрация: 25.05.2018
Сообщений: 1
По умолчанию If else не устанавливает значение

Здравствуйте!
Не срабатывает установка размеров из списка в зависимости от пользовательского ввода через if else. В чем я неправ?
Код:
    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()
            {
     
            }
Parohod вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Найти значение на другом листе и подставить значение следующей ячейки ElenaNTro Microsoft Office Excel 12 11.02.2019 12:44
компьютер не устанавливает программы nublu Помощь студентам 4 11.01.2016 09:06
Вычислить значение функции(или функция не определена), значение х вводится с клавиатуры Safok Помощь студентам 2 16.12.2014 08:04
Скрипт комментариев от facebook устанавливает неприлично большую высоту. VladimirNew JavaScript, Ajax 1 19.04.2012 08:44
Не устанавливает windows 7 x64 stenl1 Windows 2 19.08.2010 16:54