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 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();
        }
Exemplo n.º 3
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;
            }
        }
        public void Init2(Control control1, Control container1, Control control2, Control container2, Direction direction, int param)
        {
            bool              Dragging  = false;
            Point             DragStart = Point.Empty;
            MouseEventHandler handler   = (sender, e) =>
            {
                Dragging         = true;
                DragStart        = new Point(e.X, e.Y);
                control1.Capture = true;
                control2.Capture = true;
            };

            control1.MouseDown += handler;
            control2.MouseDown += handler;

            MouseEventHandler handler2 = (sender, e) =>
            {
                Dragging         = false;
                control1.Capture = false;
                control2.Capture = false;
            };

            control1.MouseUp += handler2;
            control2.MouseUp += handler2;

            MouseEventHandler handler3 = (sender, e) =>
            {
                if (Dragging && this.lockCheckBox.Checked)
                {
                    if (direction != Direction.Vertical)
                    {
                        container1.Left = Math.Max(0, e.X + container1.Left - DragStart.X);
                    }
                    container2.Left = Math.Max(0, e.X + container2.Left - DragStart.X);
                    if (direction != Direction.Horizontal)
                    {
                        container1.Top = Math.Max(0, e.Y + container1.Top - DragStart.Y);
                    }
                    container2.Top = Math.Max(0, e.Y + container2.Top - DragStart.Y);

                    UpdatePoint up = new UpdatePoint();
                    if (up.Update_point(ListLabels[param].Id, container1.Location.X, container1.Location.Y))
                    {
                        Console.WriteLine("Update Success");
                    }
                    else
                    {
                        Console.WriteLine("Error");
                    }
                }
            };

            control1.MouseMove += handler3;
            control2.MouseMove += handler3;

            MouseEventHandler handler4 = (sender, e) =>
            {
                if (e.Button == MouseButtons.Right)
                {
                    if (this.lockCheckBox.Checked)
                    {
                        switch (ListLabels[param].Type)
                        {
                        case 0:
                            LinkLabel frmlink0 = new LinkLabel(ListLabels[param].Link, ListLabels[param].Lbl_name, ListLabels[param].Lbl_text, Progs.Rows[ListLabels[param].Link].Cells[3].Value.ToString(), Progs.Rows[ListLabels[param].Link].Cells[2].Value.ToString(), ListLabels[param].Type);
                            frmlink0.dgv    = Progs;
                            frmlink0.Prg    = Prg;
                            frmlink0.CodesP = CodesP;

                            frmlink0.PointsP = PointsP;
                            frmlink0.Show();
                            break;

                        case 1:
                            LinkLabel frmlink1 = new LinkLabel(ListLabels[param].Link, ListLabels[param].Lbl_name, ListLabels[param].Lbl_text, (ListLabels[param].Link + 1).ToString() + "GRP" + (ListLabels[param].Link + 1).ToString(), "AUTO", ListLabels[param].Type);
                            frmlink1.Show();
                            break;

                        case 2:
                            LinkLabel frmlink2 = new LinkLabel(ListLabels[param].Link, ListLabels[param].Lbl_name, ListLabels[param].Lbl_text, Vars.Rows[ListLabels[param].Link].Cells[2].Value.ToString(), Vars.Rows[ListLabels[param].Link].Cells[3].Value.ToString(), ListLabels[param].Type);
                            frmlink2.dgv     = Vars;
                            frmlink2.id      = ListLabels[param].Id;
                            frmlink2.Prg     = Prg;
                            frmlink2.PrgPath = PrgPath;

                            if (frmlink2.ShowDialog() == DialogResult.OK)
                            {
                                if (frmlink2.flag)
                                {
                                    for (int x = 0; x < counter; x++)
                                    {
                                        this.Controls.Remove(ListLabels[x].Thumb);
                                        this.Controls.Remove(ListLabels[x].Lbl);
                                    }
                                    counter    = 0;
                                    ListLabels = new List <AtributosLabel>();
                                    ShowPoint();
                                }
                            }
                            break;
                        }
                    }
                }
            };

            /************Right Click*******************/
            control1.MouseClick += handler4;
            control2.MouseClick += handler4;



            EventHandler handler5 = (sender, e) =>
            {
                if (!this.lockCheckBox.Checked && ListLabels[param].Type == 1)
                {
                    //EditScreenForm frmedit = new EditScreenForm(Prfileid,Screenid,"");
                    //frmedit.Show();
                    try
                    {
                        var name     = Dgv.Rows[ListLabels[param].Link].Cells[3].Value.ToString();
                        var building = "Default_Building";
                        var path     = GetFullPathForPicture(name, building);
                        index_ = ListLabels[param].Link;
                        if (path != null && File.Exists(path))
                        {
                            BackgroundImage = Image.FromFile(path);
                        }
                        else
                        {
                            BackgroundImage = null;
                        }
                    }
                    catch (Exception exception)
                    {
                        MessageBoxUtilities.ShowException(exception);
                    }
                    Screenid = ListLabels[param].Link;
                    for (int x = 0; x < counter; x++)
                    {
                        this.Controls.Remove(ListLabels[x].Thumb);
                        this.Controls.Remove(ListLabels[x].Lbl);
                    }
                    counter    = 0;
                    ListLabels = new List <AtributosLabel>();
                    ShowPoint();
                }
            };

            control1.Click += handler5;
            control2.Click += handler5;

            EventHandler handler6 = (sender, e) =>
            {
                if (this.lockCheckBox.Checked)
                {
                    ///
                }
            };

            control1.Click += handler6;
        }