0

Я не понимаю, как тут исправить данную ошибку:

case "-editor":
                    {
                        Application.Run(new Editor());
                        Editor.InitializeComponent();
                        break;
                    }

Куда обращаюсь:

public void InitializeComponent()
    {
        this.components = new System.ComponentModel.Container();
        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Editor));
        this.mainMenu = new System.Windows.Forms.MainMenu(this.components);
        this.City_Item = new System.Windows.Forms.MenuItem();
        this.New_Item = new System.Windows.Forms.MenuItem();
        this.Open_Item = new System.Windows.Forms.MenuItem();
        this.Save_Item = new System.Windows.Forms.MenuItem();
        this.SaveAs_Item = new System.Windows.Forms.MenuItem();
        this.SeparatorItem1 = new System.Windows.Forms.MenuItem();
        this.Refresh_All_TripStop_Lists_Item = new System.Windows.Forms.MenuItem();
        this.Check_Joints_Item = new System.Windows.Forms.MenuItem();
        this.Find_MinRadius_Item = new System.Windows.Forms.MenuItem();
        this.ComputeAllTime_Item = new System.Windows.Forms.MenuItem();
        this.Run_Item = new System.Windows.Forms.MenuItem();
        this.SeparatorItem2 = new System.Windows.Forms.MenuItem();
        this.Exit_Item = new System.Windows.Forms.MenuItem();
        this.statusBar = new System.Windows.Forms.StatusBar();
        this.Cursor_x_Status = new System.Windows.Forms.StatusBarPanel();
        this.Cursor_y_Status = new System.Windows.Forms.StatusBarPanel();
        this.SeparatorPanel1 = new System.Windows.Forms.StatusBarPanel();
        this.Coord_x1_Status = new System.Windows.Forms.StatusBarPanel();
        this.Coord_y1_Status = new System.Windows.Forms.StatusBarPanel();
        this.Angle1_Status = new System.Windows.Forms.StatusBarPanel();
        this.SeparatorPanel2 = new System.Windows.Forms.StatusBarPanel();
        this.Coord_x2_Status = new System.Windows.Forms.StatusBarPanel();
        this.Coord_y2_Status = new System.Windows.Forms.StatusBarPanel();
        this.Angle2_Status = new System.Windows.Forms.StatusBarPanel();
        this.SeparatorPanel3 = new System.Windows.Forms.StatusBarPanel();
        this.Length_Status = new System.Windows.Forms.StatusBarPanel();
        this.Radius_Status = new System.Windows.Forms.StatusBarPanel();
        this.Angle_Status = new System.Windows.Forms.StatusBarPanel();
        this.Wide0_Status = new System.Windows.Forms.StatusBarPanel();
        this.Wide1_Status = new System.Windows.Forms.StatusBarPanel();
        this.Height0_Status = new System.Windows.Forms.StatusBarPanel();
        this.Height1_Status = new System.Windows.Forms.StatusBarPanel();
        this.SeparatorPanel4 = new System.Windows.Forms.StatusBarPanel();
        this.Maschtab = new System.Windows.Forms.StatusBarPanel();
        this.SeparatorPanel5 = new System.Windows.Forms.StatusBarPanel();
        this.Ugol = new System.Windows.Forms.StatusBarPanel();
        this.toolBar = new System.Windows.Forms.ToolBar();
        this.New_Button = new System.Windows.Forms.ToolBarButton();
        this.Open_Button = new System.Windows.Forms.ToolBarButton();
        this.Save_Button = new System.Windows.Forms.ToolBarButton();
        this.SeparatorButton1 = new System.Windows.Forms.ToolBarButton();
        this.SeparatorButton2 = new System.Windows.Forms.ToolBarButton();
        this.Run_Button = new System.Windows.Forms.ToolBarButton();
        this.Play_Button = new System.Windows.Forms.ToolBarButton();
        this.SeparatorButton3 = new System.Windows.Forms.ToolBarButton();
        this.SeparatorButton4 = new System.Windows.Forms.ToolBarButton();
        this.ButtonUndo = new System.Windows.Forms.ToolBarButton();
        this.Edit_Button = new System.Windows.Forms.ToolBarButton();
        this.Rail_Button = new System.Windows.Forms.ToolBarButton();
        this.Troll_lines_Button = new System.Windows.Forms.ToolBarButton();
        this.SeparatorButton5 = new System.Windows.Forms.ToolBarButton();
        this.SeparatorButton6 = new System.Windows.Forms.ToolBarButton();
        this.Stops_Button = new System.Windows.Forms.ToolBarButton();
        this.Park_Button = new System.Windows.Forms.ToolBarButton();
        this.Route_Button = new System.Windows.Forms.ToolBarButton();
        this.Signals_Button = new System.Windows.Forms.ToolBarButton();
        this.Svetofor_Button = new System.Windows.Forms.ToolBarButton();
        this.Object_Button = new System.Windows.Forms.ToolBarButton();
        this.toolBarButton3 = new System.Windows.Forms.ToolBarButton();
        this.SeparatorButton8 = new System.Windows.Forms.ToolBarButton();
        this.Rail_Edit_Button = new System.Windows.Forms.ToolBarButton();
        this.Rail_Build_Direct_Button = new System.Windows.Forms.ToolBarButton();
        this.Rail_Build_Curve_Button = new System.Windows.Forms.ToolBarButton();
        this.Road_Button = new System.Windows.Forms.ToolBarButton();
        this.Rail_Build_попутки_Button = new System.Windows.Forms.ToolBarButton();
        this.Rail_Build_попутки1_Button = new System.Windows.Forms.ToolBarButton();
        this.Rail_Build_попутки2_Button = new System.Windows.Forms.ToolBarButton();
        this.Rail_Build_попутки3_Button = new System.Windows.Forms.ToolBarButton();
        this.Rail_Build_встречки_Button = new System.Windows.Forms.ToolBarButton();
        this.Rail_Build_встречки1_Button = new System.Windows.Forms.ToolBarButton();
        this.Rail_Build_встречки2_Button = new System.Windows.Forms.ToolBarButton();
        this.Rail_Build_встречки3_Button = new System.Windows.Forms.ToolBarButton();
        this.Park_Edit_Button = new System.Windows.Forms.ToolBarButton();
        this.Park_In_Button = new System.Windows.Forms.ToolBarButton();
        this.Park_Out_Button = new System.Windows.Forms.ToolBarButton();
        this.Park_Rails_Button = new System.Windows.Forms.ToolBarButton();
        this.Troll_lines_Edit_Button = new System.Windows.Forms.ToolBarButton();
        this.Troll_lines_Draw_Button = new System.Windows.Forms.ToolBarButton();
        this.Troll_lines_Flag_Button = new System.Windows.Forms.ToolBarButton();
        this.imageList = new System.Windows.Forms.ImageList(this.components);
        this.renderPanel = new Engine.Controls.RenderPanel();
        this.object_panel = new System.Windows.Forms.Panel();
        this.Objects_Instance_Box = new System.Windows.Forms.ComboBox();
        this.Objects_Instance_label = new System.Windows.Forms.Label();
        this.Objects_EditLocation_Button = new System.Windows.Forms.Button();
        this.Objects_ShowLocation_Button = new System.Windows.Forms.Button();
        this.Objects_Location_label = new System.Windows.Forms.Label();
        this.Objects_Remove_Button = new System.Windows.Forms.Button();
        this.Objects_Add_Button = new System.Windows.Forms.Button();
        this.Objects_Box = new System.Windows.Forms.ComboBox();
        this.Objects_label = new System.Windows.Forms.Label();
        this.route_panel = new System.Windows.Forms.Panel();
        this.StopsButton = new System.Windows.Forms.Button();
        this.Route_TransportType_Box = new System.Windows.Forms.ComboBox();
        this.Route_TransportType_label = new System.Windows.Forms.Label();
        this.Route_ShowNarads_Box = new System.Windows.Forms.CheckBox();
        this.Route_Runs_ComputeTime_Button = new System.Windows.Forms.Button();
        this.Route_Runs_Time_Box = new Trancity.TimeBox();
        this.Route_Runs_ToParkIndex_UpDown = new System.Windows.Forms.NumericUpDown();
        this.Route_Runs_ToPark_Box = new System.Windows.Forms.CheckBox();
        this.Route_Runs_Park_Box = new System.Windows.Forms.CheckBox();
        this.Route_Runs_Time_label = new System.Windows.Forms.Label();
        this.Route_Runs_ToParkIndex_label = new System.Windows.Forms.Label();
        this.Route_Runs_label = new System.Windows.Forms.Label();
        this.Route_Name_label = new System.Windows.Forms.Label();
        this.Route_Name_Box = new System.Windows.Forms.TextBox();
        this.Route_Runs_Remove_Button = new System.Windows.Forms.Button();
        this.Route_Remove_Button = new System.Windows.Forms.Button();
        this.Route_Runs_Add_Button = new System.Windows.Forms.Button();
        this.Route_Add_Button = new System.Windows.Forms.Button();
        this.Route_ChangeName_Button = new System.Windows.Forms.Button();
        this.Route_label = new System.Windows.Forms.Label();
        this.Route_Runs_Box = new System.Windows.Forms.ComboBox();
        this.Route_Box = new System.Windows.Forms.ComboBox();
        this.svetofor_panel = new System.Windows.Forms.Panel();
        this.Svetofor_Model_Box = new System.Windows.Forms.ComboBox();
        this.Svetofor_Model_label = new System.Windows.Forms.Label();
        this.Svetofor_Svetofor_ArrowRed_Box = new System.Windows.Forms.ComboBox();
        this.Svetofor_Svetofor_ArrowYellow_Box = new System.Windows.Forms.ComboBox();
        this.Svetofor_Svetofor_ArrowGreen_Box = new System.Windows.Forms.ComboBox();
        this.Svetofor_Cycle_Box = new Trancity.TimeBox();
        this.Svetofor_OfGreen_Box = new Trancity.TimeBox();
        this.Svetofor_End_Box = new Trancity.TimeBox();
        this.Svetofor_ToGreen_Box = new Trancity.TimeBox();
        this.Svetofor_Begin_Box = new Trancity.TimeBox();
        this.Svetofor_Element_Location_label = new System.Windows.Forms.Label();
        this.Svetofor_Cycle_label = new System.Windows.Forms.Label();
        this.Svetofor_Green_label = new System.Windows.Forms.Label();
        this.Svetofor_Work_label = new System.Windows.Forms.Label();
        this.Svetofor_Remove_Button = new System.Windows.Forms.Button();
        this.Svetofor_Svetofor_ArrowRed_label = new System.Windows.Forms.Label();
        this.Svetofor_Svetofor_ArrowYellow_label = new System.Windows.Forms.Label();
        this.Svetofor_Svetofor_ArrowGreen_label = new System.Windows.Forms.Label();
        this.Svetofor_Element_label = new System.Windows.Forms.Label();
        this.Svetofor_Add_Button = new System.Windows.Forms.Button();
        this.Svetofor_Element_EditLocation_Button = new System.Windows.Forms.Button();
        this.Svetofor_Element_ShowLocation_Button = new System.Windows.Forms.Button();
        this.Svetofor_label = new System.Windows.Forms.Label();
        this.Svetofor_Element_Remove_Button = new System.Windows.Forms.Button();
        this.Svetofor_Box = new System.Windows.Forms.ComboBox();
        this.Svetofor_Element_Box = new System.Windows.Forms.ComboBox();
        this.Svetofor_Signal_Add_Button = new System.Windows.Forms.Button();
        this.Svetofor_Svetofor_Add_Button = new System.Windows.Forms.Button();
        this.splines_panel = new System.Windows.Forms.Panel();
        this.Rail_Box_NumericBox = new Common.NumericBox();
        this.Spline_Select_mode_Box = new System.Windows.Forms.CheckBox();
        this.Splines_Instance_Box = new System.Windows.Forms.ComboBox();
        this.Splines_Instance_label = new System.Windows.Forms.Label();
        this.Splines_ShowLocation_Button = new System.Windows.Forms.Button();
        this.Rail_Box_dist_Label = new System.Windows.Forms.Label();
        this.Splines_Location_label = new System.Windows.Forms.Label();
        this.Splines_ChangeModel_Button = new System.Windows.Forms.Button();
        this.Splines_Remove_Button = new System.Windows.Forms.Button();
        this.Splines_Models_Box = new System.Windows.Forms.ComboBox();
        this.Splines_label = new System.Windows.Forms.Label();
        this.signals_panel = new System.Windows.Forms.Panel();
        this.Signals_Model_Box = new System.Windows.Forms.ComboBox();
        this.Signals_Model_label = new System.Windows.Forms.Label();
        this.Signals_Element_Minus_Box = new System.Windows.Forms.CheckBox();
        this.Signals_Bound_UpDown = new System.Windows.Forms.NumericUpDown();
        this.Signals_Element_Location_label = new System.Windows.Forms.Label();
        this.Signals_Bound_label = new System.Windows.Forms.Label();
        this.Signals_Remove_Button = new System.Windows.Forms.Button();
        this.Signals_Element_label = new System.Windows.Forms.Label();
        this.Signals_Add_Button = new System.Windows.Forms.Button();
        this.Signals_Element_EditLocation_Button = new System.Windows.Forms.Button();
        this.Signals_Element_ShowLocation_Button = new System.Windows.Forms.Button();
        this.Signals_label = new System.Windows.Forms.Label();
        this.Signals_Element_Remove_Button = new System.Windows.Forms.Button();
        this.Signals_Box = new System.Windows.Forms.ComboBox();
        this.Signals_Element_Box = new System.Windows.Forms.ComboBox();
        this.Signals_Element_AddSignal_Button = new System.Windows.Forms.Button();
        this.Signals_Element_AddContact_Button = new System.Windows.Forms.Button();
        this.stops_panel = new System.Windows.Forms.Panel();
        this.Stops_Model_Box = new System.Windows.Forms.ComboBox();
        this.Stops_Model_label = new System.Windows.Forms.Label();
        this.TypeOfTransportBox = new System.Windows.Forms.GroupBox();
        this.BusBox = new System.Windows.Forms.CheckBox();
        this.TrolleybusBox = new System.Windows.Forms.CheckBox();
        this.TramwayBox = new System.Windows.Forms.CheckBox();
        this.Stops_Location_label = new System.Windows.Forms.Label();
        this.Stops_Name_label = new System.Windows.Forms.Label();
        this.Stops_Name_Box = new System.Windows.Forms.TextBox();
        this.Stops_Remove_Button = new System.Windows.Forms.Button();
        this.Stops_Add_Button = new System.Windows.Forms.Button();
        this.Stops_EditLocation_Button = new System.Windows.Forms.Button();
        this.Stops_ShowLocation_Button = new System.Windows.Forms.Button();
        this.Stops_ChangeName_Button = new System.Windows.Forms.Button();
        this.Stops_label = new System.Windows.Forms.Label();
        this.Stops_Box = new System.Windows.Forms.ComboBox();
        this.park_panel = new System.Windows.Forms.Panel();
        this.Park_Name_label = new System.Windows.Forms.Label();
        this.Park_Name_Box = new System.Windows.Forms.TextBox();
        this.Park_Remove_Button = new System.Windows.Forms.Button();
        this.Park_ChangeName_Button = new System.Windows.Forms.Button();
        this.Park_Add_Button = new System.Windows.Forms.Button();
        this.Park_label = new System.Windows.Forms.Label();
        this.Park_Box = new System.Windows.Forms.ComboBox();
        this.Refresh_Timer = new System.Windows.Forms.Timer(this.components);
        this.Sizable_Panel = new System.Windows.Forms.Panel();
        this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
        this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
        this.edit_panel = new System.Windows.Forms.Panel();
        this.narad_panel = new System.Windows.Forms.Panel();
        this.RollingStockBox = new System.Windows.Forms.ComboBox();
        this.Transport_label = new System.Windows.Forms.Label();
        this.Narad_Runs_Time2_Box = new Trancity.TimeBox();
        this.Narad_Runs_Time1_Box = new Trancity.TimeBox();
        this.Narad_Runs_Time2_label = new System.Windows.Forms.Label();
        this.Narad_Runs_Time1_label = new System.Windows.Forms.Label();
        this.Narad_Runs_label = new System.Windows.Forms.Label();
        this.Narad_Park_label = new System.Windows.Forms.Label();
        this.Narad_Runs_Run_label = new System.Windows.Forms.Label();
        this.Narad_Name_label = new System.Windows.Forms.Label();
        this.Narad_Name_Box = new System.Windows.Forms.TextBox();
        this.Narad_Runs_Remove_Button = new System.Windows.Forms.Button();
        this.Narad_Remove_Button = new System.Windows.Forms.Button();
        this.Narad_Runs_Add_Button = new System.Windows.Forms.Button();
        this.Narad_Add_Button = new System.Windows.Forms.Button();
        this.Narad_ChangeName_Button = new System.Windows.Forms.Button();
        this.Narad_label = new System.Windows.Forms.Label();
        this.Narad_Park_Box = new System.Windows.Forms.ComboBox();
        this.Narad_Runs_Run_Box = new System.Windows.Forms.ComboBox();
        this.Narad_Runs_Box = new System.Windows.Forms.ComboBox();
        this.Narad_Box = new System.Windows.Forms.ComboBox();
        ((System.ComponentModel.ISupportInitialize)(this.Cursor_x_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Cursor_y_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.SeparatorPanel1)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Coord_x1_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Coord_y1_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Angle1_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.SeparatorPanel2)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Coord_x2_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Coord_y2_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Angle2_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.SeparatorPanel3)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Length_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Radius_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Angle_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Wide0_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Wide1_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Height0_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Height1_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.SeparatorPanel4)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Maschtab)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.SeparatorPanel5)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Ugol)).BeginInit();
        this.object_panel.SuspendLayout();
        this.route_panel.SuspendLayout();
        ((System.ComponentModel.ISupportInitialize)(this.Route_Runs_ToParkIndex_UpDown)).BeginInit();
        this.svetofor_panel.SuspendLayout();
        this.splines_panel.SuspendLayout();
        this.signals_panel.SuspendLayout();
        ((System.ComponentModel.ISupportInitialize)(this.Signals_Bound_UpDown)).BeginInit();
        this.stops_panel.SuspendLayout();
        this.TypeOfTransportBox.SuspendLayout();
        this.park_panel.SuspendLayout();
        this.Sizable_Panel.SuspendLayout();
        this.narad_panel.SuspendLayout();
        this.SuspendLayout();

и

public Editor()
        {
            
            InitializeComponent();
        }
5
  • 1
    Мой бог, сколько всего запихнули в конструктор. Почитайте о том, чем плох god object и попробуйте разбить этот класс на отдельные классы.
    – A K
    22 ноя 2020 в 9:20
  • @AK это .Designer.cs винформ, автогенерат. :) Так что ваш коммент не валиден.
    – aepot
    22 ноя 2020 в 11:03
  • @aepot И? Это нормально, да?
    – A K
    22 ноя 2020 в 11:05
  • 2
    @AK для винформ это нормально, да.
    – aepot
    22 ноя 2020 в 11:06
  • 1
    @AK если быть точнее, то в WPF аналогичная проблема - большая xaml портянка, здесь вопрос проектирования View, и вам известно, как он решается. Но явной ошибки в том, что в одном классе много контролов - нет.
    – aepot
    22 ноя 2020 в 11:11

1 ответ 1

2
Editor.InitializeComponent();

Вам эта строка кода не нужна, она будет вызвана в конструкторе и второй раз вызывать не нужно. А ошибка возникает из-за того, что вы пытаетесь вызвать не статический метод, как статический, нужно передавать не название класса, общект у которого будет вызван этот метод. Например:

var editor = new Editor();
Application.Run(editor);
editor.InitializeComponent(); // тут уже компилятор ругаться не будет
2
  • 1
    Ошибка CS0163: Управление не может передаваться вниз от одной метки case ("case "-editor":") к другой (break; добавил и заработало, хоть пока и не так, как надо)
    – Trollebas
    22 ноя 2020 в 10:49
  • 1
    @Trollebas - вы зачем это пишете в комментариях? Вы задали вопрос - вы получили ответ. Примите его и на этом тема закрыта. Если у вас возник другой вопрос - создайте новую тему с ним. 22 ноя 2020 в 11:08

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.