Exemplo n.º 1
0
        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case (Keys.Enter):
                Regex Val = new Regex(@"^[+-]?\d+(\.\d+)?$");
                if (IsNumeric(textBox1.Text) || Val.IsMatch(textBox1.Text))
                {
                    dgv.Rows[Pos].Cells[3].Value = textBox1.Text;
                    var form = new VariablesForm(Prg.Variables, Prg.CustomUnits);

                    form.ExternalSaveValue(Pos, dgv.Rows[Pos]);

                    UpdatePoint up = new UpdatePoint();
                    if (up.Update_point(id, dgv.Rows[Pos].Cells[1].Value.ToString() + " " + textBox1.Text))
                    {
                        Console.WriteLine("Name Update Success");
                    }
                    else
                    {
                        Console.WriteLine("Error");
                    }
                    Prg.Save(PrgPath);
                    MessageBox.Show("Saved");
                    flag         = true;
                    DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Invalid parameter");
                }
                break;
            }
        }
Exemplo n.º 2
0
        private void ShowScreens(object sender, EventArgs e)
        {
            try
            {
                if (!CheckIsOpened())
                {
                    return;
                }
                var f    = new VariablesForm(PRG.Variables, PRG.CustomUnits);
                var f2   = new ProgramsForm(ref _prg, PrgPath);
                var form = new ScreensForm(PRG.Screens);
                form.Prg     = PRG;
                form.PointsP = PRG.Programs;
                form.CodesP  = PRG.ProgramCodes;
                form.PrgPath = PrgPath;

                form.Vars  = f.Vars;
                form.Progs = f2.Progs;

                form.Show();
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
            }
        }
Exemplo n.º 3
0
        //private void textBox1_DoubleClick(object sender, MouseEventArgs e)
        //{
        //    int x, y;
        //    x = e.Location.X;
        //    y = e.Location.Y;
        //    if ((x>=138 && x<=220) && (y>=34 && y<=54) )
        //    {
        //        textBox1.Enabled = true;
        //        MessageBox.Show("Text entro");
        //    }
        //    else if ((x >= 324 && x <= 406) && (y >= 34 && y <= 54))
        //    {
        //        textBox2.Enabled = true;
        //        MessageBox.Show(textBox1.Enabled.ToString());
        //    }

        //}

        private void textBox2_Click(object sender, MouseEventArgs e)
        {
            textBox2.Text = ((textBox2.Text.Equals("Automatic"))?"Manual":"Automatic");
            Boolean flag = ((textBox2.Text.Equals("Automatic")) ? false : true);


            if (Type == 0)
            {
                textBox1.Enabled = flag;
                var form = new ProgramsForm(ref _prg, PrgPath);
                dgv.Rows[Pos].Cells[3].Value = ((AutoManual)dgv.Rows[Pos].Cells[3].Value).NextValue();
                form.ExternalSaveAutomanual(Pos, dgv.Rows[Pos]);
            }
            else if (Type == 2)
            {
                Regex Val = new Regex(@"^[+-]?\d+(\.\d+)?$");
                if (IsNumeric(textBox1.Text) || Val.IsMatch(textBox1.Text))
                {
                    textBox1.Enabled  = flag;
                    textBox1.ReadOnly = false;
                }
                else
                {
                    textBox1.Enabled  = flag;
                    textBox1.ReadOnly = true;
                }
                var form = new VariablesForm(Prg.Variables, Prg.CustomUnits);
                dgv.Rows[Pos].Cells[2].Value = ((AutoManual)dgv.Rows[Pos].Cells[2].Value).NextValue();
                form.ExternalSaveAutomanual(Pos, dgv.Rows[Pos]);
            }
        }
Exemplo n.º 4
0
        private void ShowVariables(object sender, EventArgs e)
        {
            try
            {
                if (!CheckIsOpened())
                {
                    return;
                }

                var form = new VariablesForm(PRG.Variables, PRG.CustomUnits);
                form.Show();
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
            }
        }
Exemplo n.º 5
0
        private void textBox1_ClickVars(object sender, MouseEventArgs e)
        {
            Regex Val = new Regex(@"^[+-]?\d+(\.\d+)?$");

            if (IsNumeric(textBox1.Text) || Val.IsMatch(textBox1.Text))
            {
                textBox1.Enabled = true;
            }
            else
            {
                if (textBox1.Text.ToLower().Contains("on") || textBox1.Text.ToLower().Contains("off"))
                {
                    dgv.Rows[Pos].Cells[3].Value = ((textBox1.Text.Equals("On")) ? "Off" : "On");
                }
                else if (textBox1.Text.ToLower().Contains("yes") || textBox1.Text.ToLower().Contains("no"))
                {
                    dgv.Rows[Pos].Cells[3].Value = ((textBox1.Text.Equals("Yes")) ? "No" : "Yes");
                }



                textBox1.Text = dgv.Rows[Pos].Cells[3].Value.ToString();
                var form = new VariablesForm(Prg.Variables, Prg.CustomUnits);

                form.ExternalSaveValue(Pos, dgv.Rows[Pos]);


                UpdatePoint up = new UpdatePoint();
                if (up.Update_point(id, dgv.Rows[Pos].Cells[1].Value.ToString() + " " + textBox1.Text))
                {
                    Console.WriteLine("Name Update Success");
                }
                else
                {
                    Console.WriteLine("Error");
                }
                Prg.Save(PrgPath);
                MessageBox.Show("Saved");
                flag         = true;
                DialogResult = DialogResult.OK;
            }
        }