Esempio n. 1
0
 public static WindowedPanel showWindow(Panel p)
 {
     WindowedPanelArgs a = new WindowedPanelArgs("", false, false, false);
     return showWindow(p, a);
 }
Esempio n. 2
0
        public WindowedPanel(Control c, WindowedPanelArgs args)
        {
            content = c;

            Size = c.Size + new Size(0, 20);
            c.Location = new Point(0, 20);

            Label bar = new Label();
            bar.Size = new Size(Size.Width, 20);
            bar.Location = new Point(0, 0);
            bar.BackColor = Color.DarkOrchid;
            bar.Text = args.title ?? "";

            List<Button> buttons = new List<Button>();

            if (args.closeable)
            {
                Button x = new Button();
                x.BackColor = Color.Red;
                buttons.Add(x);
                x.Click += (a, b) =>
                {
                    close();
                };
            }

            if (args.minimizable)
            {
                Button t = new Button();
                t.BackColor = Color.Orange;
                buttons.Add(t);
                t.Click += (a, b) =>
                {
                    drawContent = !drawContent;

                    if (drawContent)
                    {
                        Size = c.Size + new Size(0, 20);
                    }
                    else
                    {
                        Size = new Size(Size.Width, 20);
                    }
                };
            }

            bar.MouseDown += (sender, ags) =>
            {
                dragging = true;
                xd = new Size(ags.X, ags.Y);
            };

            bar.MouseUp += (asd, sdf) =>
            {
                dragging = false;
            };

            bar.MouseMove += (sender, ags) =>
            {
                if (!dragging) { return; }
                Location = Location - xd + new Size(ags.X, ags.Y);
            };

            int i = 1;
            foreach (Button b in buttons)
            {
                b.Location = new Point(Size.Width - i++*20, 0);
                b.Size = new Size(20, 20);
                Controls.Add(b);
            }

            Controls.Add(bar);
            Controls.Add(c);
        }
Esempio n. 3
0
        /*
        public static WindowedPanel showWindow(Control p, string barTitle, bool closeable, Action closeCallback)
        {
            WindowedPanel v = null;

            Action a = () =>
            {
                v = new WindowedPanel(p, barTitle);
                frame.Controls.Add(v);
                v.BringToFront();
            };

            if (frame.InvokeRequired)
            {
                frame.Invoke(new Action(() =>
                {
                    try
                    {

                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.ToString());
                    }
                }));
            }
            else
            {
                v = new WindowedPanel(p, barTitle);
                frame.Controls.Add(v);
                v.BringToFront();
            }

            return v;
        }

        public static WindowedPanel showWindow(Panel p)
        {
            return showWindow(p, "", false, null);
        }
        */
        public static WindowedPanel showWindow(Panel p, WindowedPanelArgs args)
        {
            return frame.Invoke(new Func<WindowedPanel>(() =>
            {
                WindowedPanel w = new WindowedPanel(p, args);
                frame.Controls.Add(w);
                w.BringToFront();
                return w;
            })) as WindowedPanel;
        }