Пример #1
0
        private void remoteCtrlToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (subViewCtrl.IsCommunicationActive)
            {
                MessageBox.Show("Stop communication.",
                                "Caution",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);

                return;
            }

            var form = new RemoteSettingForm(subViewCtrl.Config, subViewCtrl.IsRemote);

            form.StartPosition = FormStartPosition.CenterParent;
            var result = form.ShowDialog();

            if (result == DialogResult.OK)
            {
                if ((subViewCtrl.ViewSettingList != null) &&
                    (subViewCtrl.ViewSettingList.Count > 0))
                {
                    DialogResult msgresult = MessageBox.Show("The DataGridView is already loaded.\nDo you want to clear in the DataGridView?",
                                                             "Question",
                                                             MessageBoxButtons.YesNo,
                                                             MessageBoxIcon.Exclamation,
                                                             MessageBoxDefaultButton.Button2);

                    if (msgresult == DialogResult.Yes)
                    {
                        subViewCtrl.SetTargetVersionName(string.Empty);
                        subViewCtrl.LoadViewSettingFile(new ViewSetting());
                    }
                }

                subViewCtrl.RunRemoteServerAsync();
            }
            else if (result == DialogResult.Abort)
            {
                subViewCtrl.CancelRemoteServer();
            }
        }
Пример #2
0
        public MainForm(string[] args)
        {
            InitializeComponent();

            this.Text = AssemblyProduct;

            subViewCtrl = new SubViewControl();

            mainPanel.Controls.Add(subViewCtrl);
            subViewCtrl.Dock = DockStyle.Fill;

            if (IsValidRequestCommandLine(args))
            {
                subViewCtrl.SetTargetVersionName(string.Empty);
                subViewCtrl.LoadViewSettingFile(new ViewSetting());
                subViewCtrl.RunRemoteServerAsync();
            }
            else
            {
                CommMainCtrl.CommunicationMode mode;
                if (Enum.TryParse <CommMainCtrl.CommunicationMode>(Properties.Settings.Default.CommMode, out mode))
                {
                    subViewCtrl.Config.CommMode = mode;
                }

                CommInstructions.RmAddr range;
                if (Enum.TryParse <CommInstructions.RmAddr>(Properties.Settings.Default.RmRange, out range))
                {
                    subViewCtrl.Config.RmRange = range;
                }

                subViewCtrl.Config.BaudRate = Properties.Settings.Default.BaudRate;

                subViewCtrl.Config.SerialPortName = Properties.Settings.Default.SerialPortName;

                System.Net.IPAddress clientAddress;
                if (System.Net.IPAddress.TryParse(Properties.Settings.Default.ClientAddress, out clientAddress))
                {
                    subViewCtrl.Config.ClientAddress = clientAddress;
                }

                subViewCtrl.Config.ClientPort = Properties.Settings.Default.ClientPort;

                System.Net.IPAddress serverAddress;
                if (System.Net.IPAddress.TryParse(Properties.Settings.Default.ServerAddress, out serverAddress))
                {
                    subViewCtrl.Config.ServerAddress = serverAddress;
                }

                subViewCtrl.Config.ServerPort = Properties.Settings.Default.ServerPort;

                if (Properties.Settings.Default.PassNumber <= UInt32.MaxValue)
                {
                    subViewCtrl.Config.PassNumber = Properties.Settings.Default.PassNumber;
                }

                if (!loadViewFile(Properties.Settings.Default.PathViewFileName))
                {
                    pathViewFileName = null;

                    DefaultViewSettings();
                }
                else
                {
                    pathViewFileName = Properties.Settings.Default.PathViewFileName;
                }
            }
        }