public void UpdateUnits()
        {
            try
            {
                analogUnitsListBox.Items.Clear();
                AnalogDictionary = UnitsNamesUtilities.GetNames(CustomUnits, AnalogPredicate);
                foreach (var name in AnalogDictionary)
                {
                    analogUnitsListBox.Items.Add($"{ToNumber(name.Key)}. {name.Value.OffOnName}");
                }

                digitalUnitsListBox.Items.Clear();
                DigitalDictionary = UnitsNamesUtilities.GetNames(CustomUnits, unit => unit.IsDigital());
                foreach (var name in DigitalDictionary)
                {
                    digitalUnitsListBox.Items.Add($"{ToNumber(name.Key)}. {name.Value.OffOnName}");
                }

                ShowSelectedItem();
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
            }
        }
        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.Input.Number = row.GetValue <int>(NumberColumn);
                    point.AutoManual   = row.GetValue <AutoManual>(AutoManualColumn);
                    //point.Value = TViewUtilities.GetVariableValue(row, ValueColumn, UnitsColumn, RangeColumn, CustomUnits);
                }
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
                DialogResult = DialogResult.None;
                return;
            }

            DialogResult = DialogResult.OK;
            Close();
        }
예제 #3
0
        private void EditScreenColumn(object sender, EventArgs e)
        {
            try
            {
                var name     = view.CurrentRow.GetValue <string>(PictureColumn);
                var building = "Default_Building";
                var path     = GetFullPathForPicture(name, building);

                var form = new EditScreenForm(Prfileid, view.CurrentRow.Index, path);
                //form.Prfileid = Prfileid;
                form.Dgv = view;
                //form.Screenid = view.CurrentRow.Index;
                form.PrgPath = PrgPath;
                form.Vars    = Vars;
                form.Progs   = Progs;
                form.Prg     = Prg;
                form.PointsP = PointsP;
                form.CodesP  = CodesP;


                if (form.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
            }
        }
예제 #4
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);
            }
        }
예제 #5
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);
            }
        }
예제 #6
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.Control     = row.GetValue <OffOn>(StatusColumn);
                    point.NormalCom   = row.GetValue <NormalCom>(RunStatusColumn);
                    point.AutoManual  = row.GetValue <AutoManual>(AutoManualColumn);
                    point.Length      = row.GetValue <int>(SizeColumn);
                    point.Label       = row.GetValue <string>(LabelColumn);
                }
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
                DialogResult = DialogResult.None;
                return;
            }

            DialogResult = DialogResult.OK;
            Close();
        }
예제 #7
0
        private void EditPictureColumn(object sender, EventArgs e)
        {
            try
            {
                var dialog = new OpenFileDialog();
                dialog.Filter = $"{Resources.ImageFiles} (*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png|" +
                                $"{Resources.AllFiles} (*.*)|*.*";
                dialog.Title            = Resources.SelectImageFile;
                dialog.InitialDirectory = Assembly.GetExecutingAssembly().Location;
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                var building = "Default_Building";
                var name     = Path.GetFileName(dialog.FileName);
                var path     = GetFullPathForPicture(name, building);

                Directory.CreateDirectory(Path.GetDirectoryName(path));
                File.Copy(dialog.FileName, path, overwrite: true);

                var row  = view.CurrentRow;
                var cell = row.Cells[PictureColumn.Name];
                cell.Value = name;
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
            }
        }
예제 #8
0
        private void LoadPrg(object sender, EventArgs e)
        {
            var dialog = new OpenFileDialog();

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

            try
            {
                var path = dialog.FileName;


                PrgPath = path;
                Prg     = Prg.Load(path);



                statusLabel.Text = string.Format(Resources.CurrentFile, path);

                //File menu
                savePRGToolStripMenuItem.Enabled = true;
                saveAsToolStripMenuItem.Enabled  = true;
                upgradeMenuItem.Enabled          = true;

                //Control menu
                inputsMenuItem.Enabled      = true;
                outputsMenuItem.Enabled     = true;
                variablesMenuItem.Enabled   = true;
                programsMenuItem.Enabled    = true;
                controllersMenuItem.Enabled = true;
                screensMenuItem.Enabled     = true;
                schedulesMenuItem.Enabled   = true;
                holidaysMenuItem.Enabled    = true;

                //Buttons tool strip
                inputsButton.Enabled      = true;
                outputsButton.Enabled     = true;
                variablesButton.Enabled   = true;
                programsButton.Enabled    = true;
                controllersButton.Enabled = true;
                screensButton.Enabled     = true;
                schedulesButton.Enabled   = true;
                holidaysButton.Enabled    = true;

                if (Prg.FileVersion != FileVersion.Current)
                {
                    upgradeMenuItem.Visible = true;
                }
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
            }
        }
예제 #9
0
        private void EditCodeColumn(object sender, EventArgs e)
        {
            try
            {
                var row = view.CurrentRow;
                Index_EditProgramCode = row.GetValue <int>(NumberColumn) - 1;

                var form = new ProgramEditorForm();
                form.Caption = $"Edit Code: Panel 1 - Program {Index_EditProgramCode } - Label {Prg.Programs[Index_EditProgramCode].Description}";

                Console.WriteLine("--------------ORIGINAL CODE-------------------");
                ConsolePrintBytes(Codes[Index_EditProgramCode].Code, "Original");
                form.SetCode(Codes[Index_EditProgramCode].ToString());


                #region Create local copy of identifiers from control points
                foreach (var vars in Prg.Variables)
                {
                    form.Identifiers.Add(vars.Label);
                }
                foreach (var ins in Prg.Inputs)
                {
                    form.Identifiers.Add(ins.Label, IdentifierTypes.INS);
                }
                foreach (var outs in Prg.Outputs)
                {
                    form.Identifiers.Add(outs.Label, IdentifierTypes.OUTS);
                }
                foreach (var prgs in Prg.Programs)
                {
                    form.Identifiers.Add(prgs.Label, IdentifierTypes.PRGS);
                }
                foreach (var schs in Prg.Schedules)
                {
                    form.Identifiers.Add(schs.Label, IdentifierTypes.SCHS);
                }
                foreach (var hols in Prg.Holidays)
                {
                    form.Identifiers.Add(hols.Label, IdentifierTypes.HOLS);
                }

                #endregion


                //Override Send Event Handler and encode program into bytes.
                form.Send     += Form_Send;
                form.MdiParent = this.MdiParent;

                form.Show();
                //if (form.ShowDialog() != DialogResult.OK) return;
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
            }
        }
        private void Save(object sender, EventArgs e)
        {
            try
            {
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
                DialogResult = DialogResult.None;
                return;
            }

            DialogResult = DialogResult.OK;
            Close();
        }
 private void EditCodeColumn(object sender, EventArgs e)
 {
     try
     {
         var form = new EditSchedulesForm();
         if (form.ShowDialog() != DialogResult.OK)
         {
             return;
         }
     }
     catch (Exception exception)
     {
         MessageBoxUtilities.ShowException(exception);
     }
 }
예제 #12
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);
            }
        }
예제 #13
0
        private void ShowSchedules(object sender, EventArgs e)
        {
            try
            {
                if (!CheckIsOpened())
                {
                    return;
                }

                var form = new SchedulesForm(Prg.Schedules, Prg.ScheduleCodes);
                form.Show();
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
            }
        }
예제 #14
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();
        }
예제 #15
0
        private void ShowControllers(object sender, EventArgs e)
        {
            try
            {
                if (!CheckIsOpened())
                {
                    return;
                }

                var form = new ControllersForm(PRG.Controllers, PRG.CustomUnits);
                form.Show();
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
            }
        }
예제 #16
0
        private void ShowHolidays(object sender, EventArgs e)
        {
            try
            {
                if (!CheckIsOpened())
                {
                    return;
                }

                var form = new HolidaysForm(PRG.Holidays, PRG.HolidayCodes);
                form.Show();
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
            }
        }
예제 #17
0
 public void ExternalSaveValue(int pos, DataGridViewRow erow)
 {
     try
     {
         for (var i = 0; i < view.RowCount && i < Points.Count; ++i)
         {
             var point = Points[i];
             var row   = erow;
             if (i == pos)
             {
                 point.Control = ((OffOn)row.Cells[2].Value);
             }
         }
     }
     catch (Exception exception)
     {
         MessageBoxUtilities.ShowException(exception);
     }
 }
예제 #18
0
 public void ExternalSaveValue(int pos, DataGridViewRow erow)
 {
     try
     {
         for (var i = 0; i < view.RowCount && i < Points.Count; ++i)
         {
             var point = Points[i];
             var row   = erow;
             if (i == pos)
             {
                 point.Value = TViewUtilities.GetVariableValue(row, ValueColumn, UnitColumn, RangeColumn, CustomUnits);
             }
         }
     }
     catch (Exception exception)
     {
         MessageBoxUtilities.ShowException(exception);
     }
 }
예제 #19
0
        private void EditCodeColumn(object sender, EventArgs e)
        {
            try
            {
                var row   = view.CurrentRow;
                var index = ((int)row.Cells[NumberColumn.Name].Value) - 1;
                var form  = new SelectHolidaysForm(Codes[index]);
                if (form.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                Codes[index] = form.Code;
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
            }
        }
예제 #20
0
        private void ShowPrograms()
        {
            try
            {
                if (!CheckIsOpened())
                {
                    return;
                }

                var form = new ProgramsForm(ref _prg, PrgPath);

                form.MdiParent = this;
                form.Show();
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
            }
        }
        private void EditCodeColumn(object sender, EventArgs e)
        {
            try
            {
                var row = view.CurrentRow;
                Index_EditProgramCode = row.GetValue <int>(NumberColumn) - 1;

                var form = new ProgramEditorForm();
                form.Caption = $"Edit Code: Panel 1 - Program {Index_EditProgramCode } - Label {SelectedPrg.Programs[Index_EditProgramCode].Description}";

                Debug.WriteLine("--------------ORIGINAL CODE-------------------");
                CoderHelper.ConsolePrintBytes(Codes[Index_EditProgramCode].Code, "Original");

                Decoder DECODER = new Decoder();

                DECODER.SetControlPoints(SelectedPrg);
                string ProgramText = DECODER.DecodeBytes(Codes[Index_EditProgramCode].Code);

                Debug.WriteLine("--------------NEW PROGRAM TEXT-------------------");
                Debug.WriteLine(ProgramText);

                //STEP 1: create a local copy of all identifiers
                form.Identifiers = DECODER.Identifiers;

                //STEP 2: Create a local copy for Control Basic program text
                form.SetCode(ProgramText);

                //STEP 3: Override Send Event Handler and encode program into bytes.
                form.Send += Form_Send;

                //STEP 4: Who's your daddy?!!
                form.MdiParent = this.MdiParent;


                form.Show();
                //if (form.ShowDialog() != DialogResult.OK) return;
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
            }
        }
예제 #22
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);
            }
        }
예제 #23
0
        private void Upgrade(object sender, EventArgs e)
        {
            if (!IsOpened)
            {
                statusLabel.Text = Resources.FileIsNotOpen;
                return;
            }

            try
            {
                var path = PrgPath;

                PRG.Upgrade(FileVersion.Current);
                statusLabel.Text = string.Format(Resources.Upgraded, path);

                upgradeMenuItem.Visible = false;
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
            }
        }
        private void Save(object sender, EventArgs e)
        {
            if (!view.Validate())
            {
                MessageBoxUtilities.ShowWarning(Resources.ViewNotValidated);
                DialogResult = DialogResult.None;
                return;
            }

            try
            {
                var i = 0;
                foreach (DataGridViewRow row in view.Rows)
                {
                    if (i >= Points.Count)
                    {
                        break;
                    }

                    var point = Points[i];
                    point.Description      = (string)row.Cells[DescriptionColumn.Name].Value;
                    point.AutoManual       = (AutoManual)row.Cells[AutoManualColumn.Name].Value;
                    point.Control          = (OffOn)row.Cells[OutputColumn.Name].Value;
                    point.Override1Control = (OffOn)row.Cells[State1Column.Name].Value;
                    point.Override2Control = (OffOn)row.Cells[State2Column.Name].Value;
                    point.Label            = (string)row.Cells[LabelColumn.Name].Value;
                    ++i;
                }
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
                DialogResult = DialogResult.None;
                return;
            }

            DialogResult = DialogResult.OK;
            Close();
        }
        private void analogUnitsListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (analogUnitsListBox.SelectedIndex == -1 ||
                analogUnitsListBox.SelectedIndex == (int)SelectedUnit)
            {
                return;
            }

            try
            {
                if (digitalUnitsListBox.SelectedIndex != -1)
                {
                    digitalUnitsListBox.SelectedIndex = -1;
                }

                var selectedIndex = analogUnitsListBox.SelectedIndex;
                SelectedUnit = ToUnits(selectedIndex + 1);
                ShowSelectedItem();
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
            }
        }
예제 #26
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.AutoManual      = row.GetValue <AutoManual>(AutoManualColumn);
                    point.Value           = TViewUtilities.GetVariableValue(row, ValueColumn, UnitColumn, RangeColumn, CustomUnits);
                    point.CalibrationL    = row.GetValue <double>(CalibrationColumn);
                    point.CalibrationSign = row.GetValue <Sign>(SignColumn);
                    point.Filter          = row.GetValue <int>(FilterColumn);
                    point.Status          = row.GetValue <InputStatus>(StatusColumn);
                    point.Jumper          = row.GetValue <Jumper>(JumperColumn);
                    point.Label           = row.GetValue <string>(LabelColumn);
                }
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
                DialogResult = DialogResult.None;
                return;
            }

            DialogResult = DialogResult.OK;
            Close();
        }
        private void digitalUnitsListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (digitalUnitsListBox.SelectedIndex == -1 ||
                digitalUnitsListBox.SelectedIndex == (SelectedUnit - Unit.DigitalUnused))
            {
                return;
            }

            try
            {
                if (analogUnitsListBox.SelectedIndex != -1)
                {
                    analogUnitsListBox.SelectedIndex = -1;
                }

                var selectedIndex = digitalUnitsListBox.SelectedIndex;
                SelectedUnit = (Unit.DigitalUnused + selectedIndex);
                ShowSelectedItem();
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
            }
        }
        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.AutoManual     = row.GetValue <AutoManual>(AutoManualColumn);
                    point.HwSwitchStatus = row.GetValue <SwitchStatus>(HOASwitchColumn);
                    point.LowVoltage     = row.GetValue <int>(LowVColumn);
                    point.HighVoltage    = row.GetValue <int>(HighVColumn);
                    point.PwmPeriod      = row.GetValue <int>(PWMPeriodColumn);
                    point.Control        = row.GetValue <OffOn>(StatusColumn);
                    point.Value          = TViewUtilities.GetVariableValue(row, ValueColumn, UnitColumn, RangeColumn, CustomUnits);
                    point.Label          = row.GetValue <string>(LabelColumn);
                }
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
                DialogResult = DialogResult.None;
                return;
            }

            DialogResult = DialogResult.OK;
            Close();
        }
        private void Save(object sender, EventArgs e)
        {
            if (!analogView.Validate() || !digitalView.Validate())
            {
                MessageBoxUtilities.ShowWarning(Resources.EditCustomUnitsFormNotValid);
                DialogResult = DialogResult.None;
                return;
            }

            try
            {
                for (var i = 0; i < analogView.RowCount && i < CustomUnits.Analog.Count; ++i)
                {
                    var point = CustomUnits.Analog[i];
                    var row   = analogView.Rows[i];
                    point.Name = row.GetValue <string>(NameColumn);
                }
                for (var i = 0; i < digitalView.RowCount && i < CustomUnits.Digital.Count; ++i)
                {
                    var point = CustomUnits.Digital[i];
                    var row   = digitalView.Rows[i];
                    point.DigitalUnitsOff = row.GetValue <string>(OffNameColumn);
                    point.DigitalUnitsOn  = row.GetValue <string>(OnNameColumn);
                    point.Direct          = row.GetValue <bool>(DirectColumn);
                }
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
                DialogResult = DialogResult.None;
                return;
            }

            DialogResult = DialogResult.OK;
            Close();
        }
        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;
        }