Beispiel #1
0
        private void AttachCommandToButton(Type commandType, Button button, ButtonMethod method)
        {
            switch (method)
            {
            case ButtonMethod.WhenPressed:
                button.WhenPressed(CreateCommand(commandType));
                break;

            case ButtonMethod.WhenReleased:
                button.WhenReleased(CreateCommand(commandType));
                break;

            case ButtonMethod.WhileHeld:
                button.WhileHeld(CreateCommand(commandType));
                break;

            case ButtonMethod.ToggleWhenPressed:
                button.ToggleWhenPressed(CreateCommand(commandType));
                break;

            case ButtonMethod.CancelWhenPressed:
                button.CancelWhenPressed(CreateCommand(commandType));
                break;

            default:
                throw new NotSupportedException("The button method specified is not supported.");
            }
        }
        ///
        /// Notification Methods
        ///
        /// AddButton(string, ButtonMethod) : void
        /// GetButtonCount() : int
        /// GetButtonMethod() : ButtonMethod
        /// GetButtonName() : string
        /// RemoveButton(int) : void
        /// SetButton(int, string, ButtonMethod) : void
        ///

        // Add New Button
        public void AddButton(string button_name, ButtonMethod button_method)
        {
            // Add new button name and method if less than the max
            if (button_names.Count < buttons_max)
            {
                button_names.Add(button_name);
                button_methods.Add(button_method);
            }
        }
    public ScrollViewHandler(GameObject button, ref GameObject _content, ButtonMethod methodadd_tobuttons)
    {
        if (buttonpool == null)
        {
            buttonpool = new SpawnerScript(button, 5);
        }

        _contentobject       = _content;
        buttonsused          = new List <GameObject>();
        _methodadd_tobuttons = methodadd_tobuttons;
    }
        // Overwrite Existing Button
        public void SetButton(int button_number, string button_name, ButtonMethod button_method)
        {
            // If button number is in range, overwrite it
            if (button_number >= 0 && button_number < buttons_max)
            {
                // Remove old button
                button_names.RemoveAt(button_number);
                button_methods.RemoveAt(button_number);

                // Insert new button
                button_names.Insert(button_number, button_name);
                button_methods.Insert(button_number, button_method);
            }
        }
        public static void NavigateTo(string page)
        {
            var userPage  = UserPages.ToList().Find(p => p.Title == page);
            var adminPage = AdminPages.ToList().Find(p => p.Title == page);


            var foundPage = userPage ?? adminPage;

            NavFrame.Navigate(foundPage);
            var controller = UserPageControllers.Find(c =>
                                                      Equals(c.Page, UserPages.ToList().Find(p => p.Title == foundPage.Title))) ??
                             AdminPageControllers.Find(c =>
                                                       Equals(c.Page, AdminPages.ToList().Find(p => p.Title == foundPage.Title)));

            ButtonMethod.Invoke(controller.NewButtonActive, controller.EditButtonActive, controller.SaveButtonActive, controller.DeleteButtonActive, false);

            CurrentNavStatus = foundPage;
            OnNavigationAlert(CurrentNavStatus.Title);
        }
Beispiel #6
0
 /// <summary>
 /// Creates a new <see cref="RunCommandOnNetworkKeyAttribute"/>.
 /// </summary>
 /// <param name="tableName">The network table to run on.</param>
 /// <param name="key">The network table key to run the command on.</param>
 /// <param name="method">The <see cref="ButtonMethod"/> to run the command on.</param>
 public RunCommandOnNetworkKeyAttribute(string tableName, string key, ButtonMethod method)
 {
     TableName    = tableName;
     Key          = key;
     ButtonMethod = method;
 }
 /// <summary>
 /// Creates a new <see cref="RunCommandOnJoystickAttribute"/>.
 /// </summary>
 /// <param name="controllerId">The controller to run the command on.</param>
 /// <param name="buttonId">The button to run the command on.</param>
 /// <param name="buttonMethod">The <see cref="ButtonMethod"/> to run the command on.</param>
 public RunCommandOnJoystickAttribute(int controllerId, int buttonId, ButtonMethod buttonMethod)
 {
     ControllerId = controllerId;
     ButtonId = buttonId;
     ButtonMethod = buttonMethod;
 }
 /// <summary>
 /// Creates a new <see cref="RunCommandOnNetworkKeyAttribute"/>.
 /// </summary>
 /// <param name="tableName">The network table to run on.</param>
 /// <param name="key">The network table key to run the command on.</param>
 /// <param name="method">The <see cref="ButtonMethod"/> to run the command on.</param>
 public RunCommandOnNetworkKeyAttribute(string tableName, string key, ButtonMethod method)
 {
     TableName = tableName;
     Key = key;
     ButtonMethod = method;
 }
Beispiel #9
0
 public object Button(ButtonMethod method, params object[] options)
 {
     return(null);
 }
Beispiel #10
0
 public object Button(ButtonMethod method, params object[] options) {
     return null;
 }
Beispiel #11
0
        public Form1()
        {
            #region Serilog initial
            Log.Logger = new LoggerConfiguration()
                         .WriteTo.Console()
                         .WriteTo.File($"{AppDomain.CurrentDomain.BaseDirectory}\\log\\log-.txt",
                                       rollingInterval: RollingInterval.Day,
                                       outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}")
                         .CreateLogger();       //宣告Serilog初始化
            #endregion

            #region Loading initial
            FluentSplashScreenOptions op = new FluentSplashScreenOptions();
            op.Title                = "太陽能資料蒐集系統";//太陽能資料蒐集系統  帆宣自動化抄表系統
            op.Subtitle             = "Automatic Meter Reading System";
            op.LeftFooter           = "Copyright © 2021 SIN MAO Energy CO., LTD." + Environment.NewLine + "All Rights reserved.";
            op.LoadingIndicatorType = FluentLoadingIndicatorType.Dots;
            op.OpacityColor         = Color.FromArgb(62, 91, 135);
            op.Opacity              = 130;
            SplashScreenManager.ShowFluentSplashScreen(
                op,
                parentForm: this,
                useFadeIn: true,
                useFadeOut: true
                );
            #endregion

            #region  入資料庫JSON
            op.RightFooter = $"載入資料庫資訊";
            SplashScreenManager.Default.SendCommand(FluentSplashScreenCommand.UpdateOptions, op);
            SystemSetting = InitialMethod.SystemLoad();
            Thread.Sleep(1000);
            #endregion

            #region  入按鈕JSON
            op.RightFooter = $"載入按鈕資訊";
            SplashScreenManager.Default.SendCommand(FluentSplashScreenCommand.UpdateOptions, op);
            ButtonSetting = InitialMethod.InitialButtonLoad();
            Thread.Sleep(1000);
            #endregion

            #region  入匯出報表JSON
            op.RightFooter = $"載入匯出報表資訊";
            SplashScreenManager.Default.SendCommand(FluentSplashScreenCommand.UpdateOptions, op);
            XtraReportSetting = InitialMethod.InitialXtraReportLoad();

            Thread.Sleep(1000);
            #endregion

            #region JSON錯誤資訊檢查
            if (SystemSetting == null && ButtonSetting == null && XtraReportSetting == null)
            {
                ErrorStr = "資料庫與按鈕Json錯誤";
            }
            else if (SystemSetting != null && ButtonSetting == null && XtraReportSetting != null)
            {
                ErrorStr = "按鈕Json錯誤";
            }
            else if (SystemSetting == null && ButtonSetting != null && XtraReportSetting != null)
            {
                ErrorStr = "資料庫Json錯誤";
            }
            else if (SystemSetting != null && ButtonSetting != null && XtraReportSetting == null)
            {
                ErrorStr = "匯出報表Json錯誤";
            }
            if (ErrorStr == "")
            {
                op.RightFooter = $"載入完成";
                SplashScreenManager.Default.SendCommand(FluentSplashScreenCommand.UpdateOptions, op);
                Thread.Sleep(1000);
                SplashScreenManager.CloseForm();
            }
            else
            {
                op.RightFooter = $"{ErrorStr}";
                SplashScreenManager.Default.SendCommand(FluentSplashScreenCommand.UpdateOptions, op);
                Thread.Sleep(5000);
                SplashScreenManager.CloseForm();
            }
            #endregion

            InitializeComponent();
            if (ErrorStr == "")
            {
                Change_Logo();                                                                   //載入Logo
                SettingbarButtonItem.ImageOptions.Image = imageCollection1.Images["technology"]; //設定按鈕圖
                #region 建立資料庫物件
                MysqlMethod = new MysqlMethod(SystemSetting);
                if (SystemSetting != null)
                {
                    GatewayConfigs = MysqlMethod.Search_GatewayConfig();
                }
                #endregion

                #region 建立通訊
                if (GatewayConfigs != null)
                {
                    foreach (var item in GatewayConfigs)
                    {
                        GatewayTypeEnum gatewayType = (GatewayTypeEnum)item.GatewayTypeEnum;
                        switch (gatewayType)
                        {
                        case GatewayTypeEnum.ModbusRTU:
                        {
                            SerialportMasterComponent serialport = new SerialportMasterComponent(item, MysqlMethod)
                            {
                                MysqlMethod = MysqlMethod
                            };
                            serialport.MyWorkState = true;
                            Field4Components.Add(serialport);
                        }
                        break;

                        case GatewayTypeEnum.ModbusTCP:
                        {
                            TCPMasterComponent TCP = new TCPMasterComponent(item, MysqlMethod)
                            {
                                MysqlMethod = MysqlMethod
                            };
                            TCP.MyWorkState = true;
                            Field4Components.Add(TCP);
                        }
                        break;
                        }
                    }
                }
                #endregion

                #region 建立按鈕物件
                NavigationFrame = new NavigationFrame()
                {
                    Dock = DockStyle.Fill
                };
                NavigationFrame.Parent = ViewpanelControl;
                ButtonMethod           = new ButtonMethod()
                {
                    Form1 = this, navigationFrame = NavigationFrame
                };
                ButtonMethod.AccordionLoad(accordionControl1, ButtonSetting);
                #endregion

                #region 建立畫面
                foreach (var Componentitem in Field4Components)
                {
                    foreach (var Absprotocolitem in Componentitem.ElectricAbsProtocols)
                    {
                        ElectricAbsProtocols.Add(Absprotocolitem);
                    }
                }
                #region 主畫面
                MainUserControl main = new MainUserControl(MysqlMethod, ElectricAbsProtocols)
                {
                    Dock = DockStyle.Fill
                };
                NavigationFrame.AddPage(main);
                Field4UserControls.Add(main);
                #endregion
                #region 報表畫面
                ChartUserControl chart = new ChartUserControl(MysqlMethod)
                {
                    Dock = DockStyle.Fill
                };
                NavigationFrame.AddPage(chart);
                Field4UserControls.Add(chart);
                #endregion
                #region 月報表畫面
                xtraReportUserControl = new XtraReportUserControl(MysqlMethod)
                {
                    Dock = DockStyle.Fill
                };
                NavigationFrame.AddPage(xtraReportUserControl);
                #endregion
                #endregion
            }
            timer1.Interval = 1000;
            timer1.Enabled  = true;
        }
 public extern object Button(ButtonMethod method, params object[] options);
Beispiel #13
0
 private void AttachCommandToButton(Type commandType, Button button, ButtonMethod method)
 {
     switch (method)
     {
         case ButtonMethod.WhenPressed:
             button.WhenPressed(CreateCommand(commandType));
             break;
         case ButtonMethod.WhenReleased:
             button.WhenReleased(CreateCommand(commandType));
             break;
         case ButtonMethod.WhileHeld:
             button.WhileHeld(CreateCommand(commandType));
             break;
         case ButtonMethod.ToggleWhenPressed:
             button.ToggleWhenPressed(CreateCommand(commandType));
             break;
         case ButtonMethod.CancelWhenPressed:
             button.CancelWhenPressed(CreateCommand(commandType));
             break;
         default:
             throw new NotSupportedException("The button method specified is not supported.");
     }
 }
 public MMF_Button(string buttonText, ButtonMethod method)
 {
     ButtonText   = buttonText;
     TargetMethod = method;
 }
Beispiel #15
0
 /// <summary>
 /// Creates a new <see cref="RunCommandOnJoystickAttribute"/>.
 /// </summary>
 /// <param name="controllerId">The controller to run the command on.</param>
 /// <param name="buttonId">The button to run the command on.</param>
 /// <param name="buttonMethod">The <see cref="ButtonMethod"/> to run the command on.</param>
 public RunCommandOnJoystickAttribute(int controllerId, int buttonId, ButtonMethod buttonMethod)
 {
     ControllerId = controllerId;
     ButtonId     = buttonId;
     ButtonMethod = buttonMethod;
 }
        public Form1()
        {
            Log.Logger = new LoggerConfiguration()
                         .WriteTo.Console()
                         .WriteTo.File($"{AppDomain.CurrentDomain.BaseDirectory}\\log\\log-.txt",
                                       rollingInterval: RollingInterval.Day,
                                       outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}")
                         .CreateLogger(); //宣告Serilog初始化

            MySqlSetting  = InitialMethod.MySqlLoad();
            ButtonSetting = InitialMethod.InitialButtonLoad();
            InitializeComponent();
            NavigationFrame = new NavigationFrame()
            {
                Dock = DockStyle.Fill
            };
            NavigationFrame.Parent = DisPlaypanelControl;

            ButtonMethod = new ButtonMethod()
            {
                Form1 = this, navigationFrame = NavigationFrame
            };
            ButtonMethod.AccordionLoad(accordionControl1, ButtonSetting);

            #region Ewatch平台
            Ewatch_MySqlMethod                = new Ewatch_MySqlMethod(MySqlSetting);
            Ewatch_MySqlComponent             = new Ewatch_MySqlComponent(Ewatch_MySqlMethod);
            Ewatch_MySqlComponent.MyWorkState = true;
            Ewatch_Field4Component.Add(Ewatch_MySqlComponent);
            Ewatch_AlarmComponent             = new Ewatch_AlarmComponent(Ewatch_MySqlMethod);
            Ewatch_AlarmComponent.MyWorkState = true;
            Ewatch_Field4Component.Add(Ewatch_AlarmComponent);

            EwatchConnectionUserControl ewatchConnectionUserControl = new EwatchConnectionUserControl(Ewatch_MySqlComponent)
            {
                Dock = DockStyle.Fill
            };
            NavigationFrame.AddPage(ewatchConnectionUserControl);
            Ewatch_Field4UserControl.Add(ewatchConnectionUserControl);

            CaseUserControl caseUserControl = new CaseUserControl(Ewatch_MySqlMethod)
            {
                Form1 = this, Dock = DockStyle.Fill
            };
            NavigationFrame.AddPage(caseUserControl);
            Ewatch_Field4UserControl.Add(caseUserControl);

            AiSettingUserControl aiSettingUserControl = new AiSettingUserControl(Ewatch_MySqlMethod)
            {
                Form1 = this, Dock = DockStyle.Fill
            };
            NavigationFrame.AddPage(aiSettingUserControl);
            Ewatch_Field4UserControl.Add(aiSettingUserControl);

            AiConfigUserControl aiConfigUserControl = new AiConfigUserControl(Ewatch_MySqlMethod)
            {
                Form1 = this, Dock = DockStyle.Fill
            };
            NavigationFrame.AddPage(aiConfigUserControl);
            Ewatch_Field4UserControl.Add(aiConfigUserControl);

            ElectricSettingUserControl electricSettingUserControl = new ElectricSettingUserControl(Ewatch_MySqlMethod)
            {
                Form1 = this, Dock = DockStyle.Fill
            };
            NavigationFrame.AddPage(electricSettingUserControl);
            Ewatch_Field4UserControl.Add(electricSettingUserControl);

            StateSettingUserControl stateSettingUserControl = new StateSettingUserControl(Ewatch_MySqlMethod)
            {
                Form1 = this, Dock = DockStyle.Fill
            };
            NavigationFrame.AddPage(stateSettingUserControl);
            Ewatch_Field4UserControl.Add(stateSettingUserControl);
            #endregion

            #region ChungHsin平台
            ChungHsin_MySqlMethod                = new ChungHsin_MySqlMethod(MySqlSetting);
            ChungHsin_MySqlComponent             = new ChungHsin_MySqlComponent(ChungHsin_MySqlMethod);
            ChungHsin_MySqlComponent.MyWorkState = true;
            ChungHsin_Field4Component.Add(ChungHsin_MySqlComponent);

            ChumgHsinConnectionUserControl chumgHsinConnectionUserControl = new ChumgHsinConnectionUserControl(ChungHsin_MySqlComponent)
            {
                Dock = DockStyle.Fill
            };
            NavigationFrame.AddPage(chumgHsinConnectionUserControl);
            ChungHsin_Field4UserControl.Add(chumgHsinConnectionUserControl);

            DeviceConfigUserControl deviceConfigUserControl = new DeviceConfigUserControl(ChungHsin_MySqlMethod)
            {
                Dock = DockStyle.Fill
            };
            NavigationFrame.AddPage(deviceConfigUserControl);
            ChungHsin_Field4UserControl.Add(deviceConfigUserControl);

            CH_CaseSettingUserControl cH_CaseSettingUserControl = new CH_CaseSettingUserControl(ChungHsin_MySqlMethod)
            {
                Dock = DockStyle.Fill
            };
            NavigationFrame.AddPage(cH_CaseSettingUserControl);
            ChungHsin_Field4UserControl.Add(cH_CaseSettingUserControl);

            ReceiveSettingUserControl receiveSettingUserControl = new ReceiveSettingUserControl(ChungHsin_MySqlMethod)
            {
                Dock = DockStyle.Fill
            };
            NavigationFrame.AddPage(receiveSettingUserControl);
            ChungHsin_Field4UserControl.Add(receiveSettingUserControl);
            #endregion

            timer1.Interval = 1000;
            timer1.Enabled  = true;
        }