Example #1
0
        private Click GetCurrentClickObj()
        {
            TabPageMeta tabPage = Tabs_Clicks.SelectedTab as TabPageMeta;

            if (tabPage == null || tabPage.ClickObj == null)
            {
                throw new Exception(ERROR);
            }

            return(tabPage.ClickObj);
        }
Example #2
0
        private void SyncUIParams(bool global = false)
        {
            BindingOff();

            CB_Template.Items.Clear();
            foreach (var item in service.Templates)
            {
                CB_Template.Items.Add(item.Name ?? "?");
            }

            if (selectedTemplate != null)
            {
                CB_Template.SelectedIndex = GetTemplateIndex(selectedTemplate);
                if (global || selectedTemplate.Clicks.Count != Tabs_Clicks.TabCount)
                {
                    Tabs_Clicks.TabPages.Clear();
                    for (int i = 0; i < selectedTemplate.Clicks.Count; ++i)
                    {
                        Click click = selectedTemplate.Clicks[i];

                        TabPageMeta page = new TabPageMeta(click, $"#{i + 1}");
                        Tabs_Clicks.TabPages.Add(page);

                        // X
                        Label x = new Label
                        {
                            Text     = "X",
                            Font     = new Font("Segoe UI", 10),
                            Size     = new Size(19, 17),
                            Location = new Point(27, 34),
                        };
                        NumericUpDown nud_x = new NumericUpDown
                        {
                            Minimum  = 0,
                            Maximum  = Screen.PrimaryScreen.Bounds.Width,
                            Font     = new Font("Segoe UI", 10),
                            Size     = new Size(85, 25),
                            Location = new Point(52, 32),
                            Name     = NUD_X,
                        };
                        nud_x.Value = click.Point.X >= nud_x.Minimum && click.Point.X <= nud_x.Maximum
                            ? click.Point.X
                            : 0;

                        // Y
                        Label y = new Label
                        {
                            Text     = "Y",
                            Font     = new Font("Segoe UI", 10),
                            Size     = new Size(19, 17),
                            Location = new Point(27, 65),
                        };
                        NumericUpDown nud_y = new NumericUpDown
                        {
                            Minimum  = 0,
                            Maximum  = Screen.PrimaryScreen.Bounds.Height,
                            Font     = new Font("Segoe UI", 10),
                            Size     = new Size(85, 25),
                            Location = new Point(52, 63),
                            Name     = NUD_Y,
                        };
                        nud_y.Value = click.Point.Y >= nud_y.Minimum && click.Point.Y <= nud_y.Maximum
                            ? click.Point.Y
                            : 0;

                        // Clicks count
                        Label count = new Label
                        {
                            Text     = "Clicks count",
                            Font     = new Font("Segoe UI", 9),
                            Size     = new Size(75, 17),
                            Location = new Point(150, 34),
                        };
                        NumericUpDown nud_count = new NumericUpDown
                        {
                            Minimum  = 1,
                            Maximum  = 10,
                            Value    = click.Count,
                            Font     = new Font("Segoe UI", 10),
                            Size     = new Size(85, 25),
                            Location = new Point(225, 32),
                            Name     = NUD_CLICKS_COUNT,
                        };

                        // Delay before
                        Label delay = new Label
                        {
                            Text     = "Delay before (ms)",
                            Font     = new Font("Segoe UI", 9),
                            Size     = new Size(75, 17),
                            Location = new Point(150, 65),
                        };
                        NumericUpDown nud_delay = new NumericUpDown
                        {
                            Minimum  = 0,
                            Maximum  = 10000, // 10 sec - max delay
                            Value    = click.DelayBefore,
                            Font     = new Font("Segoe UI", 10),
                            Size     = new Size(85, 25),
                            Location = new Point(225, 63),
                            Name     = NUD_DELAY_BEFORE,
                        };

                        // Enabled
                        CheckBox enabled = new CheckBox
                        {
                            Text     = "Enabled",
                            Name     = CB_Enabled,
                            Checked  = click.Enabled,
                            Font     = new Font("Segoe UI", 9),
                            AutoSize = true,
                            Location = new Point(3, 113),
                        };

                        // Right
                        CheckBox right = new CheckBox
                        {
                            Text     = "Right click",
                            Name     = CB_Right,
                            Checked  = click.Right,
                            Font     = new Font("Segoe UI", 9),
                            AutoSize = true,
                            Location = new Point(71, 113),
                        };

                        // Clone button
                        Button clone = new Button
                        {
                            Text      = "clone",
                            Font      = new Font("Segoe UI", 8),
                            Size      = new Size(50, 23),
                            FlatStyle = FlatStyle.Flat,
                            Location  = new Point(317, 107),
                        };
                        clone.FlatAppearance.BorderColor = Color.Silver;
                        clone.Click += Btn_Clone_Click;

                        // Test button
                        Button test = new Button
                        {
                            Text      = "test",
                            Font      = new Font("Segoe UI", 8),
                            Size      = new Size(40, 23),
                            FlatStyle = FlatStyle.Flat,
                            Location  = new Point(275, 107),
                        };
                        test.FlatAppearance.BorderColor = Color.Silver;
                        test.Click += Btn_Test_Click;

                        Tabs_Clicks.TabPages[i].Controls.Add(x);
                        Tabs_Clicks.TabPages[i].Controls.Add(nud_x);
                        Tabs_Clicks.TabPages[i].Controls.Add(y);
                        Tabs_Clicks.TabPages[i].Controls.Add(nud_y);
                        Tabs_Clicks.TabPages[i].Controls.Add(count);
                        Tabs_Clicks.TabPages[i].Controls.Add(nud_count);
                        Tabs_Clicks.TabPages[i].Controls.Add(delay);
                        Tabs_Clicks.TabPages[i].Controls.Add(nud_delay);
                        Tabs_Clicks.TabPages[i].Controls.Add(enabled);
                        Tabs_Clicks.TabPages[i].Controls.Add(right);
                        Tabs_Clicks.TabPages[i].Controls.Add(clone);
                        Tabs_Clicks.TabPages[i].Controls.Add(test);
                    }
                }
                else
                {
                    foreach (TabPage tabPage in Tabs_Clicks.TabPages)
                    {
                        Click click = GetCurrentClickObj();

                        (this[tabPage, ControlType.CoordinateX] as NumericUpDown).Value = click.Point.X;
                        (this[tabPage, ControlType.CoordinateY] as NumericUpDown).Value = click.Point.Y;
                        (this[tabPage, ControlType.ClicksCount] as NumericUpDown).Value = click.Count;
                        (this[tabPage, ControlType.Delay] as NumericUpDown).Value       = click.DelayBefore;
                        (this[tabPage, ControlType.Enabled] as CheckBox).Checked        = click.Enabled;
                        (this[tabPage, ControlType.RightClick] as CheckBox).Checked     = click.Right;
                    }
                }
            }

            SyncStartApp();
            SyncBGMode();

            Btn_RemoveTemplate.Enabled = service.Templates.Count > 1;
            Btn_RemoveClick.Enabled    = selectedTemplate.Clicks.Count > 1;

            BindingOn();
        }