示例#1
0
        public MenuBar(UserConfig config)
        {
            Algorithm         = new AlgorithmScreen(config.AlgorithmScreenConfig);
            LogIn.deviceToken = config.DeviceToken;

            MenuPanel           = new Panel();
            MenuPanel.BackColor = Color.White;
            MenuPanel.Size      = new Size(150, 400);

            ToggleButton          = new PictureBox();
            ToggleButton.Image    = Bitmap.FromFile("Content/GUI/Button_Menu.png");
            ToggleButton.Size     = ToggleButton.Image.Size;
            ToggleButton.MouseUp += (sender, e) =>
            {
                if (ToggleButton.Parent.Controls.Contains(MenuPanel))
                {
                    // Hide the menu
                    Hide();
                }
                else
                {
                    // Show the menu
                    Show();
                }
            };
            ToggleButton.LocationChanged += (sender, e) =>
            {
                MenuPanel.Location = new Point(ToggleButton.Location.X, ToggleButton.Location.Y + ToggleButton.Height + 5);
                if (ToggleButton.Parent != null)
                {
                    ToggleButton.Parent.Refresh();
                }
            };

            MenuPanel.Controls.Add(new LogInButton(this));
            MenuPanel.Controls.Add(new ScriptButton(this));
            MenuPanel.Controls.Add(new ScriptSessionButton(this));
            PackMenu();
        }
示例#2
0
            public ScriptTextBox(AlgorithmScreen screen, string script = "")
                : base()
            {
                this.Screen    = screen;
                this.Text      = script;
                this.BackColor = GuiStyle.DARK_GREY;
                this.ForeColor = GuiStyle.TEXT_COLOR;
                this.Font      = GuiStyle.Font;


                // Add a remove button for the script
                var CloseButton = new PictureBox();

                CloseButton.Image = Bitmap.FromFile("Content/GUI/Button_Close.png");
                CloseButton.Size  = new Size(CloseButton.Image.Width, CloseButton.Image.Height);
                CloseButton.BringToFront();
                CloseButton.MouseUp += (subSender, subE) =>
                {
                    Remove();
                };

                this.LocationChanged += (sScript, eScript) =>
                {
                    CloseButton.Location = new Point(this.Right - 5, this.Top - ((CloseButton.Height - this.Height) / 2));
                };
                Resize += (sender, e) =>
                {
                    CloseButton.Location = new Point(this.Right, this.Top);
                };
                ParentChanged += (sender, e) =>
                {
                    if (this.Parent != null)
                    {
                        this.Parent.Controls.Add(CloseButton);
                        this.PrevParent = Parent;
                        this.Screen.Scripts.Add(this);
                        Pack();
                    }
                    else
                    {
                        Remove();
                    }
                };
                KeyDown += (s, eventArgs) =>
                {
                    if (eventArgs.KeyCode == Keys.Enter)
                    {
                        try
                        {
                            if (!string.IsNullOrEmpty(this.Text))
                            {
                                // Save the script to the configuration
                                var idx = Screen.Scripts.IndexOf(this);
                                if (idx >= Screen.Cfg.ActionScripts.Count)
                                {
                                    Screen.Cfg.ActionScripts.Insert(idx, this.Text);
                                }
                                else
                                {
                                    Screen.Cfg.ActionScripts[idx] = this.Text;
                                }

                                // Run the script
                                Run();
                            }
                            else
                            {
                                Remove();
                            }
                        }
                        catch (Exception ex)
                        {
                            System.Windows.Forms.MessageBox.Show(ex.ToString());
                        }
                    }
                };
            }