Ejemplo n.º 1
0
        private void StatusBarInitialize()
        {
            // bar1.AddItem(NewBarStaticItem("Прием:"));
               //
               // for (int i = 0; i < _readPortsValuesStaticItems.Length; i++)
               // {
               //     bar1.AddItem(NewBarStaticItem("Порт " + (i + 1)));
               //     _readPortsValuesStaticItems[i] = NewBarStaticItem("Value" + (i + 1));
               //     bar1.AddItem(_readPortsValuesStaticItems[i]);
               // }

            bar1.AddItem(NewBarStaticItem("Передача:"));

            _writePortValueStaticitem.Caption = "Value";
            bar1.AddItem(_writePortValueStaticitem);

            bar1.AddItem(NewBarStaticItem("ID:"));
            _IdValueStaticitem.Caption = "Value";
            bar1.AddItem(_IdValueStaticitem);

            BarButtonItem settingsButton = new BarButtonItem();
            settingsButton.Caption = "Настройки";
            settingsButton.Alignment = BarItemLinkAlignment.Right;
            settingsButton.ItemClick += (ea, s) =>
                                            {
                                                Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                                                using (var settingsForm = new SettingsForm(new Setting
                                                    {
                                                        WindowEnabled1 = Convert.ToBoolean(config.AppSettings.Settings["EnabledVideoWindow1"].Value),
                                                        WindowEnabled2 = Convert.ToBoolean(config.AppSettings.Settings["EnabledVideoWindow2"].Value),
                                                        WindowEnabled3 = Convert.ToBoolean(config.AppSettings.Settings["EnabledVideoWindow3"].Value),
                                                        WindowEnabled4 = Convert.ToBoolean(config.AppSettings.Settings["EnabledVideoWindow4"].Value)
                                                    }))
                                                {
                                                    if (settingsForm.ShowDialog(this) == DialogResult.OK)
                                                    {
                                                        config.AppSettings.Settings["EnabledVideoWindow1"].Value = settingsForm.Setting.WindowEnabled1.ToString();
                                                        config.AppSettings.Settings["EnabledVideoWindow2"].Value = settingsForm.Setting.WindowEnabled2.ToString();
                                                        config.AppSettings.Settings["EnabledVideoWindow3"].Value = settingsForm.Setting.WindowEnabled3.ToString();
                                                        config.AppSettings.Settings["EnabledVideoWindow4"].Value = settingsForm.Setting.WindowEnabled4.ToString();
                                                        config.Save(ConfigurationSaveMode.Modified);
                                                        ConfigurationManager.RefreshSection("appSettings");
                                                        ShowVideoWindows();
                                                    }
                                                }
                                            };

            bar1.AddItem(settingsButton);

            BarButtonItem saveButton = new BarButtonItem();
            saveButton.Caption = "Сохранить";
            saveButton.Alignment = BarItemLinkAlignment.Right;
            saveButton.ItemClick += (ea, s) =>
                                        {
                                            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                                            foreach (var window in _videoWindows)
                                            {
                                                config.AppSettings.Settings[String.Format("VideoWindowTop{0}", window.Key + 1)].Value = window.Value.Top.ToString();
                                                config.AppSettings.Settings[String.Format("VideoWindowLeft{0}", window.Key + 1)].Value = window.Value.Left.ToString();
                                                config.AppSettings.Settings[String.Format("VideoWindowHeight{0}", window.Key + 1)].Value = window.Value.Height.ToString();
                                                config.AppSettings.Settings[String.Format("VideoWindowWidth{0}", window.Key + 1)].Value = window.Value.Width.ToString();
                                            }

                                            config.AppSettings.Settings["MainWindowTop"].Value = this.Top.ToString();
                                            config.AppSettings.Settings["MainWindowLeft"].Value = this.Left.ToString();
                                            config.AppSettings.Settings["MainWindowHeight"].Value = this.Height.ToString();
                                            config.AppSettings.Settings["MainWindowWidth"].Value = this.Width.ToString();

                                            config.Save(ConfigurationSaveMode.Modified);
                                            ConfigurationManager.RefreshSection("appSettings");
                                        };

               // bar1.AddItem(saveButton);

            BarButtonItem resetButton = new BarButtonItem();
            resetButton.Caption = "Сбросить";
            resetButton.Alignment = BarItemLinkAlignment.Right;
            resetButton.ItemClick += (ea, s) =>
            {
                Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

                config.AppSettings.Settings["MainWindowTop"].Value = Properties.Settings.Default.DefaultTop.ToString();
                config.AppSettings.Settings["MainWindowLeft"].Value = Properties.Settings.Default.DefaultLeft.ToString();
                config.AppSettings.Settings["MainWindowHeight"].Value = this.MinimumSize.Height.ToString();
                config.AppSettings.Settings["MainWindowWidth"].Value = this.MinimumSize.Width.ToString();

                int i = 10;

                foreach (var window in _videoWindows)
                {
                    config.AppSettings.Settings[String.Format("VideoWindowTop{0}", window.Key + 1)].Value = Properties.Settings.Default.DefaultTop+i.ToString();
                    config.AppSettings.Settings[String.Format("VideoWindowLeft{0}", window.Key + 1)].Value = Properties.Settings.Default.DefaultLeft+i.ToString();
                    config.AppSettings.Settings[String.Format("VideoWindowHeight{0}", window.Key + 1)].Value = Properties.Settings.Default.DefaultHeight.ToString();
                    config.AppSettings.Settings[String.Format("VideoWindowWidth{0}", window.Key + 1)].Value = Properties.Settings.Default.DefaultWidth.ToString();
                    i += 10;
                }

                config.Save(ConfigurationSaveMode.Modified);
                ConfigurationManager.RefreshSection("appSettings");

                this.Top = int.Parse(config.AppSettings.Settings["MainWindowTop"].Value);
                this.Left = int.Parse(config.AppSettings.Settings["MainWindowLeft"].Value);
                this.Width = int.Parse(config.AppSettings.Settings["MainWindowWidth"].Value);
                this.Height = int.Parse(config.AppSettings.Settings["MainWindowHeight"].Value);

                ShowVideoWindows();
            };

               // bar1.AddItem(resetButton);

            var windowMenu = new BarSubItem();
            windowMenu.Caption = "Окна";
            windowMenu.Alignment = BarItemLinkAlignment.Right;

            bar1.AddItem(windowMenu);

            windowMenu.AddItem(saveButton);
            windowMenu.AddItem(resetButton);

            if (_cu != null && _cu.ClietnId != null)

            _IdValueStaticitem.Caption = _cu.ClietnId.ToString();
        }
Ejemplo n.º 2
0
 private void settingsMenuItem_Click(object sender, EventArgs e)
 {
     var SettingsWindow = new SettingsForm();
     SettingsWindow.Show();
 }