Ejemplo n.º 1
0
        private Panel CreateControlPanel()
        {
            Panel    panel = new Panel(this);
            BoxSizer sizer = new BoxSizer(Orientation.Horizontal);

            _port = new ComboBox(panel, "", WxDefaultPosition, WxDefaultSize, new string[0],
                                 WindowStyles.ComboBoxDropDown | WindowStyles.ComboBoxReadonly);
            UpdatePorts();
            sizer.Add(_port, 0, SizerFlag.Expand | SizerFlag.All, 5);

            Bitmap refreshBitmap = GetType().Assembly.GetManifestResourceWxBitmap("DummyLoadController.Images.refresh.png");

            _refreshPorts = new BitmapButton(panel, ID_RefreshPorts, refreshBitmap);
            EvtButton(ID_RefreshPorts, (s, e) => UpdatePorts());
            sizer.Add(_refreshPorts, 0, SizerFlag.Expand | SizerFlag.All, 0);

            string[] baudRates = new[] { "300", "600", "1200", "2400", "4800", "9600", "14,400", "19,200", "28,800", "38,400", "57,600", "76,800", "115,200", "230,400" };
            _baudRate = new ComboBox(panel, "", WxDefaultPosition, WxDefaultSize, baudRates, WindowStyles.ComboBoxDropDown | WindowStyles.ComboBoxReadonly);
            _baudRate.Select(5);
            sizer.Add(_baudRate, 0, SizerFlag.Expand | SizerFlag.All, 5);

            _connect = new Button(panel, ID_Connect, "Connect");
            EvtButton(ID_Connect, (s, e) => Connect());
            sizer.Add(_connect, 0, SizerFlag.Expand | SizerFlag.All, 5);

            _disconnect = new Button(panel, ID_Disconnect, "Disconnect");
            EvtButton(ID_Disconnect, (s, e) => _comService.Disconnect());
            sizer.Add(_disconnect, 0, SizerFlag.Expand | SizerFlag.All, 5);

            panel.SetSizer(sizer);
            sizer.SetSizeHints(panel);

            return(panel);
        }
Ejemplo n.º 2
0
        private void OnClose()
        {
            SaveSettings();

            if (_comService != null)
            {
                _comService.Disconnect();
                _comService.Dispose();
            }
        }