Exemplo n.º 1
0
        public ButtonPanel(Config.PanelConfigElement cfg)
        {
            InitializeComponent();

            try
            {
                this.TitleLabel.Text = cfg.TitleName;
                this.PanelBasePath   = cfg.FolderName;

                // サイズの定数化
                ButtonArea.Width  = CommonLibrary.DesignConst.PanelAreaXSize;
                ButtonArea.Height = CommonLibrary.DesignConst.PanelAreaYSize;

                // 横の分割
                AreaWidth = ButtonArea.Width;
                CellWidth = AreaWidth / cfg.DividedXSize;

                // 縦の拡張
                CellHeight = ButtonArea.Height;
                AreaHeight = ButtonArea.Height * cfg.ExpansionYSize;

                // 拡張した分パネルを高くする
                if (cfg.ExpansionYSize > 1)
                {
                    Height += (CellHeight * (cfg.ExpansionYSize - 1));
                }

                // アセンブラとインスタンス生成
                Assembly        assembly    = Assembly.LoadFrom($"{cfg.AssemblyName}.dll");
                Type            myType      = assembly.GetType(cfg.ClassName);
                ConstructorInfo constructor = myType.GetConstructor(new Type[] { typeof(string) });
                MainInstance = constructor.Invoke(new object[] { cfg.FolderName });

                // コントロール生成
                foreach (Config.ControlConfigElement cfgCtrl in cfg.Controls)
                {
                    object ctrl = CreateContorl(cfgCtrl);
                    if (ctrl is Control)
                    {
                        this.Controls.Add((Control)ctrl);
                    }
                    else if (ctrl is Timer)
                    {
                        MainTimer = (Timer)ctrl;
                    }
                }
                // サイズ・位置を決めるエリアのコントロールを削除する
                this.Controls.Remove(ButtonArea);
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 2
0
 public SamplePanel(Config.PanelConfigElement cfg)
 {
     InitializeComponent();
 }