Ejemplo n.º 1
0
        private void ConsoleItem_Click(object sender, EventArgs e)
        {
            ResetConsoleItems();

            Control SelectedItem;

            if (((Control)sender) is not TileConsoleItem)
            {
                SelectedItem = ((Control)sender).Parent;
            }
            else
            {
                SelectedItem = (Control)sender as TileConsoleItem;
            }

            SelectedConsole            = SelectedItem as TileConsoleItem;
            SelectedConsole.IsSelected = true;

            ConsoleProfile = SelectedConsole.ConsoleProfile;

            ButtonEdit.Enabled    = ConsoleProfile != null;
            ButtonDelete.Enabled  = ConsoleProfile != null;
            ButtonConnect.Enabled = ConsoleProfile != null;

            if (ConsoleProfile != null)
            {
                ButtonConnect.Focus();
            }
        }
 // Главное окно загружено
 private void MainForm_Load(object sender, EventArgs e)
 {
     // Перевод интерфейса
     ((TextAnnotation)RadiationChart.Annotations.FindByName("NoDataAnnotation")).Text = Translate.GetString("no_data", Culture);
     if (DATA.radiation.Count() == 0)
     {
         RadiationLabel.Text = Translate.GetString("not_available", Culture);
     }
     ButtonConnect.Text     = Translate.GetString((ComPort.IsOpen ? "disconnect" : "connect"), Culture);
     RadiationGroupBox.Text = Translate.GetString("radiation_level", Culture);
     AccuracyLabel.Text     = String.Format(Translate.GetString("accuracy", Culture), (DATA.radiation.Count() == 0 ? Translate.GetString("not_available", Culture) : DATA.radiation.Last().accuracy.ToString() + "%"));
     SettingsButton.Text    = Translate.GetString("settings", Culture);
     AboutButton.Text       = Translate.GetString("about", Culture);
     // Выполняется только при запуске
     if (e != null)
     {
         // Автоподключение
         if (RunArguments.Contains("/connect"))
         {
             ButtonConnect.PerformClick();
         }
         // Минимизировать
         if (RunArguments.Contains("/minimize"))
         {
             this.WindowState = FormWindowState.Minimized;
         }
         // Максимизировать
         if (RunArguments.Contains("/maximize"))
         {
             this.WindowState = FormWindowState.Maximized;
         }
     }
 }
Ejemplo n.º 3
0
        private void ButtonConnect_Click(object sender, EventArgs e)
        {
            try
            {
                //serialPort1.PortName = ComboBoxPort.SelectedItem.ToString();
                //serialPort1.BaudRate = int.Parse(ComboBoxBaudRate.SelectedItem.ToString());
                //COM PORT Parameters
                serialPort1.PortName = ComboBoxPort.Text;
                serialPort1.BaudRate = Convert.ToInt32(ComboBoxBaudRate.Text);
                serialPort1.DataBits = Convert.ToInt32(ComboBoxDataBits.Text);
                serialPort1.StopBits = (StopBits)Enum.Parse(typeof(StopBits), ComboBoxStopBits.Text);
                serialPort1.Parity   = (Parity)Enum.Parse(typeof(Parity), ComboBoxParityBits.Text);
                serialPort1.Open();
                progressBar1.Value = 100;

                LabelStatus.Text = "Status : Connected";
                ButtonConnect.SendToBack();
                ButtonDisconnect.BringToFront();
                PictureBoxConnectionStatus.BackColor = Color.Green;
            }
            //COM PORT Error Message
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 4
0
 private MainWidget(Builder builder) : base(builder.GetObject(typeof(MainWidget).Name).Handle)
 {
     builder.Autoconnect(this);
     //_mvButton1.Clicked += new EventHandler((o, e) => ButtonPlay?.Invoke(this, e));
     _mvButton2.Clicked += new EventHandler((o, e) => ButtonConnect?.Invoke(this, e));
     _mvButton3.Clicked += new EventHandler((o, e) => ButtonCreate?.Invoke(this, e));
     _mvButton4.Clicked += new EventHandler((o, e) => ButtonSettings?.Invoke(this, e));
     _mvButton5.Clicked += new EventHandler((o, e) => ButtonQuit?.Invoke(this, e));
 }
Ejemplo n.º 5
0
 private void ButtonDisconnect_Click(object sender, EventArgs e)
 {
     serialPort1.Close();
     progressBar1.Value = 0;
     LabelStatus.Text   = "Status : Disconnected";
     ButtonDisconnect.SendToBack();
     ButtonConnect.BringToFront();
     PictureBoxConnectionStatus.Visible   = true;
     PictureBoxConnectionStatus.BackColor = Color.Red;
 }
Ejemplo n.º 6
0
        private void ListViewConsoleProfiles_SelectedIndicesChanged(object sender, EventArgs e)
        {
            ButtonEdit.Enabled    = ListViewConsoleProfiles.SelectedIndices.Count > 0;
            ButtonDelete.Enabled  = ListViewConsoleProfiles.SelectedIndices.Count > 0;
            ButtonConnect.Enabled = ListViewConsoleProfiles.SelectedIndices.Count > 0;

            if (ListViewConsoleProfiles.SelectedIndices.Count > 0)
            {
                _ = ButtonConnect.Focus();
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Device disconnected
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void DeviceDisConnected()
 {
     statusLabel.Text = "Disconnected";
     ButtonConnect.Show();
     ButtonDisconnect.Hide();
     ButtonInit.Hide();
     ButtonWash.Hide();
     ButtonSend.Hide();
     TextBoxCmd.Hide();
     sendGroupBox.Hide();
 }
Ejemplo n.º 8
0
 private void ButtonDisconnect_Click(object sender, EventArgs e)
 {
     PanelConnection.Focus();
     TimerSerial.Stop();
     SerialPort1.Close();
     ButtonDisconnect.SendToBack();
     ButtonConnect.BringToFront();
     LabelStatus.Text = "Status : Disconnect";
     PictureBoxStatusConnection.Visible   = true;
     PictureBoxStatusConnection.BackColor = Color.Red;
 }
Ejemplo n.º 9
0
 private void ButtonConnect_Click(object sender, EventArgs e)
 {
     PanelConnection.Focus();
     try
     {
         SerialPort1.BaudRate = Convert.ToInt32(ComboBoxBaudRate.SelectedItem);
         SerialPort1.PortName = ComboBoxPort.SelectedItem.ToString();
         SerialPort1.Open();
         TimerSerial.Start();
         LabelStatus.Text = "Status : Connected";
         ButtonConnect.SendToBack();
         ButtonDisconnect.BringToFront();
         PictureBoxStatusConnection.BackColor = Color.Green;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Please check the Hardware, COM, Baud Rate and try again.", ex.Message);
     }
 }
Ejemplo n.º 10
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            await Users.Load();

            users            = new UserViewModel(Users.Items);
            this.DataContext = users;

            if (users.SelectedIndex == -1)
            {
                ButtonDelete.IsEnabled = false; ButtonNew.IsEnabled = false;
            }

            CheckBoxSaveUser.IsChecked           = AppSettings.Get("App", "SaveUserinfo", true);
            CheckBoxSaveUser.Click              += new RoutedEventHandler(CheckBoxSaveUser_Click);
            CheckBoxSavePass.Click              += new RoutedEventHandler(CheckBoxSavePass_Click);
            TextBoxHost.TextChanged             += new TextChangedEventHandler(TextBoxHost_TextChanged);
            ComboBoxEncryption.SelectionChanged += new SelectionChangedEventHandler(ComboBoxEncryption_SelectionChanged);

            this.IsEnabled = true;

            ButtonConnect.Focus();
        }
Ejemplo n.º 11
0
 private void ClientManager_OnNatTraversalSucceeded(object sender, NatTraversedEventArgs e)
 {
     ButtonConnect.Set(() => ButtonConnect.Text, "Connecting to " + TextBox_Id.Text + " ...");
 }
Ejemplo n.º 12
0
        void ClientManager_OnConnected(object sender, ConnectedEventArgs e)
        {
            ButtonConnect.Set(() => ButtonConnect.Text, "Connected.");

            this.Dispose();
        }
Ejemplo n.º 13
0
        private void TimerSerial_Tick(object sender, EventArgs e)
        {
            try
            {
                StrSerialIn = SerialPort1.ReadExisting();  // --> Read incoming serial data
                var TB = new TextBox();
                TB.Multiline = true;
                TB.Text      = StrSerialIn; // --> Enter serial data into the textbox
                if (TB.Lines.Count() > 0)
                {
                    if (TB.Lines[0] == "Failed to read from DHT sensor!") // --> Check Arduino if it fails to read the DHT sensor, if this happens the connection is disconnected
                    {
                        TimerSerial.Stop();
                        SerialPort1.Close();
                        LabelStatus.Text = "Status : Disconnect";
                        ButtonDisconnect.SendToBack();
                        ButtonConnect.BringToFront();
                        PictureBoxStatusConnection.Visible   = true;
                        PictureBoxStatusConnection.BackColor = Color.Red;
                        MessageBox.Show("Failed to read from DHT sensor !!!, Please check the Hardware and Please connect again.", MessageBoxButtons.OK.ToString());
                        return;
                    }



                    StrSerialInRam = TB.Lines[0].Substring(0, 1);
                    if ((StrSerialInRam ?? "") == "H")
                    {
                        Hum  = TB.Lines[0];
                        HumL = Hum.Length;
                    }
                    else
                    {
                        Hum = Hum;
                    }

                    StrSerialInRam = TB.Lines[1].Substring(0, 1);
                    if ((StrSerialInRam ?? "") == "T")
                    {
                        Temp  = TB.Lines[1];
                        TempL = Temp.Length;
                    }
                    else
                    {
                        Temp = Temp;
                    }

                    HumResult         = Strings.Mid(Hum, 2, HumL);
                    TempResult        = Strings.Mid(Temp, 2, TempL);
                    TempToProgressBar = Conversions.ToSingle(TempResult);
                    CircularProgressBarHumidity.Value = Convert.ToInt32(HumResult);
                    CircularProgressBarHumidity.Text  = CircularProgressBarHumidity.Value + " %";
                    LabelTemperature.Text             = TempResult + " °C";

                    // -----------The process for making a progress bar using a picturebox (Vertical progress bar)-----------
                    vpb_sy = this.Map(TempToProgressBar, -20.0f, 60.0f, (float)0, (float)120);
                    if (vpb_sy > 120)
                    {
                        vpb_sy = 120;
                    }

                    if (vpb_sy < 0)
                    {
                        vpb_sy = 0;
                    }

                    PictureBoxPBTemp.Height = PictureBoxPBTempBack.Height * vpb_sy / 120;
                    vpb_ly = PictureBoxPBTempBack.Height - vpb_sy + PictureBoxPBTempBack.Location.Y;
                    PictureBoxPBTemp.Location = new Point(PictureBoxPBTemp.Location.X, vpb_ly);
                    // ------------------------------------------------------------------------------------------------------

                    // -----------Enter the temperature and humidity values into the chart-----------------------------------
                    Chart1.Series["Humidity       "].Points.AddY(HumResult);
                    if (Chart1.Series[0].Points.Count == ChartLimit)
                    {
                        Chart1.Series[0].Points.RemoveAt(0);
                    }

                    Chart2.Series["Temperature"].Points.AddY(TempResult);
                    if (Chart2.Series[0].Points.Count == ChartLimit)
                    {
                        Chart2.Series[0].Points.RemoveAt(0);
                    }
                    // ------------------------------------------------------------------------------------------------------

                    // -----------If the Then connection Is successful And running, PictureBoxStatusConnection will blink----
                    if (PictureBoxStatusConnection.Visible == true)
                    {
                        PictureBoxStatusConnection.Visible = false;
                    }
                    else if (PictureBoxStatusConnection.Visible == false)
                    {
                        PictureBoxStatusConnection.Visible = true;
                    }
                    // ------------------------------------------------------------------------------------------------------
                }
            }
            catch (Exception ex)
            {
                TimerSerial.Stop();
                SerialPort1.Close();
                LabelStatus.Text = "Status : Disconnect";
                ButtonDisconnect.SendToBack();
                ButtonConnect.BringToFront();
                PictureBoxStatusConnection.BackColor = Color.Red;
                MessageBox.Show("Please check the Hardware and Please connect again." + ex.Message);
                return;
            }
        }