예제 #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;
            }
        }
예제 #2
0
        private void SaveAsPrg(object sender, EventArgs e)
        {
            if (!IsOpened)
            {
                statusLabel.Text = Resources.FileIsNotOpen;
                return;
            }

            var dialog = new SaveFileDialog();

            dialog.Filter = $"{Resources.PrgFiles}|*.prg;*.prog|{Resources.AllFiles} (*.*)|*.*";
            dialog.Title  = Resources.SavePrgFile;
            if (dialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            var path = dialog.FileName;

            try
            {
                Prg.Save(path);
                statusLabel.Text = string.Format(Resources.Saved, path);
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
            }
        }
예제 #3
0
        private void Save(object sender, EventArgs e)
        {
            if (!view.Validate())
            {
                MessageBoxUtilities.ShowWarning(Resources.ViewNotValidated);
                DialogResult = DialogResult.None;
                return;
            }

            try
            {
                for (var i = 0; i < view.RowCount && i < Points.Count; ++i)
                {
                    var point = Points[i];
                    var row   = view.Rows[i];
                    point.Description = row.GetValue <string>(DescriptionColumn);
                    point.PictureFile = row.GetValue <string>(PictureColumn);
                    point.GraphicMode = row.GetValue <TextGraphic>(ModeColumn);
                    point.Label       = row.GetValue <string>(LabelColumn);
                    point.RefreshTime = row.GetValue <int>(RefreshColumn);

                    string      name     = row.GetValue <string>(PictureColumn);
                    var         building = "Default_Building";
                    string      path     = GetFullPathForPicture(name, building);
                    UpdatePoint up       = new UpdatePoint();
                    if (up.Update_point_image(Prfileid, path, i))
                    {
                        Console.WriteLine("Image Update Success");
                    }
                    else
                    {
                        Console.WriteLine("Error");
                    }
                }
                Prg.Save(PrgPath);
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
                DialogResult = DialogResult.None;
                return;
            }

            DialogResult = DialogResult.OK;
            Close();
        }
예제 #4
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;
            }
        }
예제 #5
0
        private void SavePrg(object sender, EventArgs e)
        {
            if (!IsOpened)
            {
                statusLabel.Text = Resources.FileIsNotOpen;
                return;
            }

            try
            {
                var path = PrgPath;

                Prg.Save(path);
                statusLabel.Text = string.Format(Resources.Saved, path);
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
            }
        }