예제 #1
0
        public void QuickInit(Image backimage, string text, Font textfont, Color textfore, Color backgroundcol, Image decal, Size decalsize, Image[] buttons, Size buttonsize, Action <object, int> ButtonPressed)
        {
            BackgroundImage       = backimage;
            BackgroundImageLayout = ImageLayout.Stretch;
            Text              = text;
            TextBackColor     = backgroundcol;
            TextFont          = textfont;
            textlab.ForeColor = textfore;

            Decals         = new Panel[1];
            Decals[0]      = new Panel();
            Decals[0].Size = decalsize;
            Decals[0].BackgroundImageLayout = ImageLayout.Stretch;
            Decals[0].BackgroundImage       = decal;
            Decals[0].BackColor             = backgroundcol;

            Buttons = new ExtButton[buttons.Length];
            for (int i = 0; i < buttons.Length; i++)
            {
                Buttons[i]             = new ExtButton();
                Buttons[i].Size        = buttonsize;
                Buttons[i].Image       = buttons[i];
                Buttons[i].ImageLayout = ImageLayout.Stretch;
                Buttons[i].Tag         = i;
                Buttons[i].BackColor   = backgroundcol;
                Buttons[i].Click      += (o, e) => { ExtButton b = o as ExtButton; ButtonPressed?.Invoke(this.Tag, (int)b.Tag); };
            }

            EnsureControlsAdded();
        }
예제 #2
0
        // icon list box

        private void extButton1_Click(object sender, EventArgs e)
        {
            ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm();

            int width = 400;

            var butl = new ExtendedControls.ExtButton();

            butl.Image = Properties.Resources.LeftArrow;
            f.Add(new ExtendedControls.ConfigurableForm.Entry(butl, "left", "", new Point(20, 64), new Size(32, 32), null));
            var butr = new ExtendedControls.ExtButton();

            butr.Image = Properties.Resources.RightArrow;
            f.Add(new ExtendedControls.ConfigurableForm.Entry(butr, "right", "", new Point(width - 20 - 32, 64), new Size(32, 32), null));

            f.Add(new ExtendedControls.ConfigurableForm.Entry("olabel", typeof(Label), "Offer", new Point(20, 30), new Size(width - 40, 20), null, 1.5f, ContentAlignment.MiddleCenter));

            f.Add(new ExtendedControls.ConfigurableForm.Entry("offer", typeof(Label), "0/0", new Point(width / 2 - 12, 50), new Size(width / 2 - 20, 20), null, 1.2f, ContentAlignment.MiddleLeft));

            var bar = new PictureBox();

            bar.SizeMode = PictureBoxSizeMode.StretchImage;
            bar.Image    = Properties.Resources.TraderBar;
            f.Add(new ExtendedControls.ConfigurableForm.Entry(bar, "bar", "", new Point(width / 2 - 32, 70), new Size(64, 16), null));

            f.Add(new ExtendedControls.ConfigurableForm.Entry("receive", typeof(Label), "0", new Point(width / 2 - 12, 90), new Size(width / 2 - 20, 20), null, 1.2f, ContentAlignment.MiddleLeft));

            f.Add(new ExtendedControls.ConfigurableForm.Entry("rlabel", typeof(Label), "Receive", new Point(20, 110), new Size(width - 40, 20), null, 1.5f, ContentAlignment.MiddleCenter));

            var panelbox = new GroupBox()
            {
                ForeColor = Color.Red
            };

            f.Add(new ExtendedControls.ConfigurableForm.Entry(panelbox, "panel", "g1", new Point(10, 150), new Size(width - 10, 100), "")
            {
                anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Left
            });

            f.AddOK(new Point(width - 100, 270), anchor: AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom);
            f.AddCancel(new Point(20, 270), anchor: AnchorStyles.Right | AnchorStyles.Bottom);

            f.Trigger += (a, b, c) => { System.Diagnostics.Debug.WriteLine("Ret " + b); if (b == "OK" || b == "Close")
                                        {
                                            f.ReturnResult(DialogResult.OK);
                                        }
            };

            f.RightMargin = 20;
            f.AllowResize = true;

            Theme.Current.FontSize = 12;

            f.ShowDialogCentred(this, this.Icon, "Trader", closeicon: true, minsize: new Size(800, 500), maxsize: new Size(1000, 600));
        }
예제 #3
0
        // used to create a button dynamically

        public static CompositeButton QuickInit(Image backimage,
                                                string text, Font textfont, Color textfore, Color textbackgroundcol,
                                                Image decal, Size decalsize,
                                                Image[] buttons, Size buttonsize,
                                                int padtop,
                                                Action <object, int> ButtonPressed)
        {
            CompositeButton but = new CompositeButton();

            but.Name = text;
            but.SuspendLayout();
            but.BackgroundImage       = backimage;
            but.BackgroundImageLayout = ImageLayout.Stretch;

            Label l = new Label();

            l.Text         = text;
            l.Font         = textfont;
            l.ForeColor    = textfore;
            l.Margin       = new Padding(0);
            l.BackColor    = textbackgroundcol;
            l.AutoSize     = false;
            l.Dock         = DockStyle.Top;
            l.TextAlign    = ContentAlignment.TopCenter;
            l.AutoEllipsis = true;

            but.Controls.Add(l);

            Panel d = new Panel();

            d.BackgroundImage       = decal;
            d.BackgroundImageLayout = ImageLayout.Stretch;
            d.BackColor             = Color.Transparent;
            d.Size = decalsize;

            but.Controls.Add(d);

            int butno = 0;

            foreach (Image i in buttons)
            {
                ExtButton b = new ExtButton();
                b.Image       = i;
                b.ImageLayout = ImageLayout.Stretch;
                b.Size        = buttonsize;
                b.Tag         = butno++;
                b.Click      += (o, e) => { ExtButton bhit = o as ExtButton; ButtonPressed?.Invoke(but, (int)bhit.Tag); };
                but.Controls.Add(b);
            }

            but.Padding = new Padding(0, padtop, 0, 0);
            but.ResumeLayout();
            return(but);
        }
예제 #4
0
        public Action <ExtTextBox> EndButtonClick = null;                              // if the button is pressed

        public ExtTextBox() : base()
        {
            this.GotFocus      += TextBoxBorder_GotFocus;
            textbox             = new TextBox();
            textbox.BorderStyle = BorderStyle.FixedSingle;
            backerrorcolor      = Color.Red;
            backnormalcolor     = textbox.BackColor;
            inerrorcondition    = false;

            SuspendLayout();

            endbutton             = new ExtButton();                   // we only add it to controls list if shown.. to limit the load on the GUI
            endbutton.Name        = "EB";
            endbutton.Image       = Properties.Resources.ArrowDown;
            endbutton.Click      += Dropdownbutton_Click;
            endbutton.MouseMove  += Textbox_MouseMove;
            endbutton.MouseEnter += Textbox_MouseEnter;
            endbutton.MouseLeave += Textbox_MouseLeave;
            endbutton.Visible     = false;
            Controls.Add(endbutton);

            // Enter and Leave is handled by this wrapper control itself, since when we leave the textbox, we leave this
            textbox.Click            += Textbox_Click;
            textbox.Name              = "TB";
            textbox.DoubleClick      += Textbox_DoubleClick;
            textbox.KeyUp            += Textbox_KeyUp;
            textbox.KeyDown          += Textbox_KeyDown;
            textbox.KeyPress         += Textbox_KeyPress;
            textbox.MouseClick       += Textbox_MouseClick;
            textbox.MouseDoubleClick += Textbox_MouseDoubleClick;
            textbox.MouseUp          += Textbox_MouseUp;
            textbox.MouseDown        += Textbox_MouseDown;
            textbox.MouseMove        += Textbox_MouseMove;
            textbox.MouseEnter       += Textbox_MouseEnter;
            textbox.MouseLeave       += Textbox_MouseLeave;
            textbox.TextChanged      += Textbox_TextChanged;
            textbox.Validating       += Textbox_Validating;
            textbox.Validated        += Textbox_Validated;
            Controls.Add(textbox);

            ResumeLayout();
        }
예제 #5
0
        // icon list box

        private void extButton1_Click(object sender, EventArgs e)
        {
            ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm();

            int width = 400;

            var butl = new ExtendedControls.ExtButton();

            butl.Image = Properties.Resources.LeftArrow;
            f.Add(new ExtendedControls.ConfigurableForm.Entry(butl, "left", "", new Point(20, 64), new Size(32, 32), null));
            var butr = new ExtendedControls.ExtButton();

            butr.Image = Properties.Resources.RightArrow;
            f.Add(new ExtendedControls.ConfigurableForm.Entry(butr, "right", "", new Point(width - 20 - 32, 64), new Size(32, 32), null));

            f.Add(new ExtendedControls.ConfigurableForm.Entry("olabel", typeof(Label), "Offer", new Point(20, 30), new Size(width - 40, 20), null, 1.5f, ContentAlignment.MiddleCenter));

            f.Add(new ExtendedControls.ConfigurableForm.Entry("offer", typeof(Label), "0/0", new Point(width / 2 - 12, 50), new Size(width / 2 - 20, 20), null, 1.2f, ContentAlignment.MiddleLeft));

            var bar = new PictureBox();

            bar.SizeMode = PictureBoxSizeMode.StretchImage;
            bar.Image    = Properties.Resources.TraderBar;
            f.Add(new ExtendedControls.ConfigurableForm.Entry(bar, "bar", "", new Point(width / 2 - 32, 70), new Size(64, 16), null));

            f.Add(new ExtendedControls.ConfigurableForm.Entry("receive", typeof(Label), "0", new Point(width / 2 - 12, 90), new Size(width / 2 - 20, 20), null, 1.2f, ContentAlignment.MiddleLeft));

            f.Add(new ExtendedControls.ConfigurableForm.Entry("rlabel", typeof(Label), "Receive", new Point(20, 110), new Size(width - 40, 20), null, 1.5f, ContentAlignment.MiddleCenter));

            f.AddOK(new Point(width - 100, 150));
            f.AddCancel(new Point(20, 150));

            f.Trigger += (a, b, c) => { System.Diagnostics.Debug.WriteLine("Ret " + b); f.ReturnResult(DialogResult.OK); };

            f.RightMargin = 20;

            f.ShowDialogCentred(this, this.Icon, "Trader", closeicon: true);
        }