Beispiel #1
0
 public CardPanelControl(Pile p, Action<CardButton> f)
 {
     panel = new CardPanel(() =>
     {
         var b = new CardButton(new FML(clickedCallback, f));
         b.setHeight(150);
         return b;
     }, new LayoutArgs(false, false));
     panel.Size = new Size(300, 150);
     panel.BackColor = Color.Navy;
     p.addObserver(panel);
     window = GUI.showWindow(panel);
 }
Beispiel #2
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;
        }
Beispiel #3
0
        public FriendPanel()
        {
            friendList = new List<string>();
            Size = new Size(250, 80);
            BackColor = Color.Silver;

            friendCount = new Label();
            friendCount.Size = new Size(70, 70);
            friendCount.Location = new Point(5, 5);
            friendCount.Text = "0";
            friendCount.Font = new Font(new FontFamily("Comic Sans MS"), 40);

            friendListPanel = new Panel();
            friendListPanel.Size = new Size(150, 240);
            friendListPanel.BackColor = Color.DarkGreen;
            friendListButtons = new Button[6];
            friendListLabels = new Label[6];
            for (int i = 0; i < 6; i++)
            {
                Button b = new Button();
                Label l = new Label();
                //
                l.Size = new Size(120, 40);
                l.Location = new Point(0, i * 40);
                l.Text = i.ToString();
                friendListLabels[i] = l;
                l.Click += (_, __) =>
                {
                    getConversation(l.Text);
                };

                b.Size = new Size(30, 30);
                b.Location = new Point(115, 5 + i * 40);
                friendListButtons[i] = b;
                var i1 = i;
                b.Click += (_, __) =>
                {
                    removeFriend(l.Text);
                };

                friendListPanel.Controls.Add(b);
                friendListPanel.Controls.Add(l);

            }
            friendListPanel.Font = new Font(new FontFamily("Comic Sans MS"), 20);

            friendCount.Click += (sender, args) =>
            {
                if (friendListWindow == null || friendListWindow.isClosed()) { updateFriendList(); friendListWindow = GUI.showWindow(friendListPanel); }
            };

            var addFriendButton = new Button();
            addFriendButton.Size = new Size(70, 70);
            addFriendButton.Location = new Point(75, 5);
            addFriendButton.Font = new Font(new FontFamily("Comic Sans MS"), 40);
            addFriendButton.Text = "+";
            addFriendButton.Click += (sender, args) =>
            {
                Panel p = new Panel();

                TextBox x = new TextBox();
                x.Font = FontLoader.getFont(FontLoader.MPLATIN, 16);
                x.KeyDown += (xx, xd) =>
                {
                    if (xd.KeyCode != Keys.Enter) { return; }

                    addFriend(x.Text);
                };
                p.Size = x.Size;
                x.BackColor = Color.Red;

                p.Controls.Add(x);

                GUI.showWindow(p);
            };

            challengeName = new TextBox();
            challengeName.Location = new Point(150, 10);
            challengeName.Size = new Size(80, 40);
            challengeName.Visible = true;
            challengeName.KeyDown += (sender, e) =>
            {
                if (e.KeyCode == Keys.Enter)
                {
                    string s = challengeName.Text;
                    challengeName.Text = "";
                    Network.challenge(s);
                }
            };

            Controls.Add(challengeName);
            Controls.Add(friendCount);
            Controls.Add(addFriendButton);
        }