Beispiel #1
0
 private void buttonSetTime_Click(object sender, EventArgs e)
 {
     if (DeviceControlClass.SetDeviceTime(1, 2, "192.168.1.201", 4370))
     {
         MessageBox.Show(@"Device time sync with the PC");
     }
 }
        private void buttonExecute_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                int iYear  = Convert.ToInt16(comboBoxYear.Text);
                int iMonth = comboBoxMonth.SelectedIndex + 1;
                int iDay   = Convert.ToInt16(comboBoxDay.Text);
                int iHour  = Convert.ToInt16(comboBoxHour.Text);
                int iMin   = Convert.ToInt16(comboBoxMin.Text);
                int iSec   = Convert.ToInt16(comboBoxSec.Text);

                if (DeviceControlClass.SetDeviceTime(1, 2, iYear, iMonth, iDay, iHour, iMin, iSec, sIP, iPort))
                {
                    string sCurrntTime = string.Empty;
                    if (DeviceControlClass.GetDeviceTime(1, 2, out sCurrntTime, sIP, iPort))
                    {
                        textBoxNew.Text = sCurrntTime;
                        MessageBox.Show(@"Device time sync successfull.", @"Time Sychronization", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        textBoxNew.Text = @"No Time Set.";
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(@"Error - " + ex.Message);
                //throw;
            }
            Cursor.Current = Cursors.Default;
        }
        private void buttonSetTime02_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            try
            {
                groupBox2.Enabled        = true;
                comboBoxYear.DataSource  = UtilityClass.FillYear();
                comboBoxMonth.DataSource = UtilityClass.FillMonth();
                comboBoxDay.DataSource   = UtilityClass.FillDays();
                comboBoxHour.DataSource  = UtilityClass.FillHours();
                comboBoxMin.DataSource   = UtilityClass.FillMins();
                comboBoxSec.DataSource   = UtilityClass.FillSecs();

                comboBoxYear.SelectedIndex  = 0;
                comboBoxMonth.SelectedIndex = 0;
                comboBoxDay.SelectedIndex   = 0;
                comboBoxHour.SelectedIndex  = 0;
                comboBoxMin.SelectedIndex   = 0;
                comboBoxSec.SelectedIndex   = 0;

                string sCurrentTime;
                if (DeviceControlClass.GetDeviceTime(1, 2, out sCurrentTime, sIP, iPort))
                {
                    textBoxCurrent.Text = sCurrentTime;
                }
            }
            catch (Exception)
            {
                MessageBox.Show(@"Please make sure the device is connected.", @"Device", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                //throw;
            }

            Cursor = Cursors.Default;
        }
Beispiel #4
0
        private void buttonRestart_Click(object sender, EventArgs e)
        {
            dataGridView1.DataSource = null;
            string sError = string.Empty;

            if (DeviceControlClass.RestartDevice(1, ref sError, 2, "192.168.1.201", 4370) == true)
            {
                MessageBox.Show(@"Restarting Device...", @"Device Shutdown.", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show(sError.ToString(), @"Error.", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void buttonSetTime_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            try
            {
                if (DeviceControlClass.SetDeviceTime(1, 2, sIP, iPort))
                {
                    MessageBox.Show(@"Device time sync with PC's.", @"Time Sychronization", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                groupBox2.Enabled = false;
            }
            catch (Exception)
            {
                MessageBox.Show(@"Please make sure the device is connected.", @"Device", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                //throw;
            }

            Cursor = Cursors.Default;
        }
 private void buttonOff_Click(object sender, EventArgs e)
 {
     Cursor = Cursors.WaitCursor;
     try
     {
         string sError = string.Empty;
         if (DeviceControlClass.TurnOffDevice(1, ref sError, 2, sIP, iPort))
         {
             MessageBox.Show(@"Power Off Device...", @"Device Shutdown.", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             MessageBox.Show(@"Cannot connect to the device. " + sError, @"Device Connection Error.", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         groupBox2.Enabled = false;
     }
     catch (Exception)
     {
         MessageBox.Show(@"Please make sure the device is connected.", @"Device Connection", MessageBoxButtons.OK,
                         MessageBoxIcon.Information);
         //throw;
     }
     Cursor = Cursors.Default;
 }