Exemple #1
0
        public static void Init(Graphics g,TextBox t,ShowOK CallBack)
        {
            NameInput = t;
            CallShowOK = CallBack;
            DrawMap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
            gp = Graphics.FromImage(DrawMap);
            Sgp = g;
            rect = new Rectangle(Screen.PrimaryScreen.Bounds.Width/2-300, 0, 600, 400);
            startpoint = new Point(rect.X, rect.Y);

            DrawDelay.Interval = 10;
            DrawDelay.Tick += (new EventHandler((object sender, EventArgs e) => {
                DrawUI();
                ((Timer)sender).Stop();
            }));

            NameInput.Visible = false;
            NameInput.Location = new Point(startpoint.X + 130, 329);
            //NameInput.Parent.Focus();
            //NameInput.KeyDown += new KeyEventHandler((object sender, KeyEventArgs e) => {
            //    if (isEditName)
            //    {
            //        if (e.KeyCode == Keys.Enter)
            //        {
            //            ((Control.Button)SaveItem).SetName(NameInput.Text);
            //            NameInput.Parent.Focus();
            //            NameInput.Visible = false;
            //            isEditName = false;
            //            DrawDelay.Start();
            //        }
            //    }
            //    else
            //    {
            //        ((TextBox)sender).Visible = false;
            //    }
            //});
            //--------按钮属性
            ButtonInfo.Add(new Control.Button(startpoint.X + 10, 310, 100, 80, "", 4, new Control.Button.ButtonCallBack((Control.Button b) => {
                isEditKey = true;
                SelectButtonIndex = 0;
                if (ButtonUI.ScreenKeyboard)
                    ButtonUI.ShowScreenKeyboard();
            })));

            ButtonInfo.Add(new Control.Button(startpoint.X + 120, 310, 100, 80, "", 4, new Control.Button.ButtonCallBack((Control.Button b) => {
                isEditName = true;
                NameInput.Visible = true;
                NameInput.Focus();
                if (ButtonUI.ScreenKeyboard)
                    ButtonUI.ShowScreenKeyboard();
            })));

            ButtonInfo.Add(new Control.Button(startpoint.X + 380, 310, 100, 80, "X方向缩放", 4, new Control.Button.ButtonCallBack((Control.Button b) => {
                if ((((Control.Button)SaveItem).mode & Control.Button.Button_IsRect) == 0)
                {
                    if (ButtonXSize)
                    {
                        ButtonXSize = ButtonYSize = false;
                        ButtonInfo[0].mode &= ~Control.Button.Button_IsUse;
                        ButtonInfo[1].mode &= ~Control.Button.Button_IsUse;
                    }
                    else
                    {
                        ButtonXSize = ButtonYSize = true;
                        ButtonInfo[0].mode |= Control.Button.Button_IsUse;
                        ButtonInfo[1].mode |= Control.Button.Button_IsUse;
                    }
                }
                else
                {
                    if (ButtonXSize)
                    {
                        ButtonXSize = false;
                        b.mode &= ~Control.Button.Button_IsUse;
                    }
                    else
                    {
                        ButtonXSize = true;
                        b.mode |= Control.Button.Button_IsUse;
                    }
                }
                DrawUI();
            })));

            ButtonInfo.Add(new Control.Button(startpoint.X + 490, 310, 100, 80, "Y方向缩放", 4, new Control.Button.ButtonCallBack((Control.Button b) =>
            {
                if ((((Control.Button)SaveItem).mode & Control.Button.Button_IsRect)==0)
                {
                    if (ButtonYSize)
                    {
                        ButtonXSize = ButtonYSize = false;
                        ButtonInfo[0].mode &= ~Control.Button.Button_IsUse;
                        ButtonInfo[1].mode &= ~Control.Button.Button_IsUse;
                    }
                    else
                    {
                        ButtonXSize = ButtonYSize = true;
                        ButtonInfo[0].mode |= Control.Button.Button_IsUse;
                        ButtonInfo[1].mode |= Control.Button.Button_IsUse;
                    }
                }
                else
                {
                    if (ButtonYSize)
                    {
                        ButtonYSize = false;
                        b.mode &= ~Control.Button.Button_IsUse;
                    }
                    else
                    {
                        ButtonYSize = true;
                        b.mode |= Control.Button.Button_IsUse;
                    }
                }
                DrawUI();
            })));
            //---------

            //------摇杆属性
            StickInfo.Add(new Control.Button(startpoint.X + 10, 310, 100, 80, "",  4, new Control.Button.ButtonCallBack((Control.Button b) =>
            {
                SelectButtonIndex = 0;
                isEditKey = true;
                if (ButtonUI.ScreenKeyboard)
                    ButtonUI.ShowScreenKeyboard();
            })));
            StickInfo.Add(new Control.Button(startpoint.X + 160, 310, 100, 80, "", 4, new Control.Button.ButtonCallBack((Control.Button b) =>
            {
                SelectButtonIndex = 1;
                isEditKey = true;
                if (ButtonUI.ScreenKeyboard)
                    ButtonUI.ShowScreenKeyboard();
            })));
            StickInfo.Add(new Control.Button(startpoint.X + 310, 310, 100, 80, "", 4, new Control.Button.ButtonCallBack((Control.Button b) =>
            {
                SelectButtonIndex = 2;
                isEditKey = true;
                if (ButtonUI.ScreenKeyboard)
                    ButtonUI.ShowScreenKeyboard();
            })));
            StickInfo.Add(new Control.Button(startpoint.X + 490, 310, 100, 80, "", 4, new Control.Button.ButtonCallBack((Control.Button b) =>
            {
                SelectButtonIndex = 3;
                isEditKey = true;
                if (ButtonUI.ScreenKeyboard)
                    ButtonUI.ShowScreenKeyboard();
            })));
            //-------

            NewList.Add(new Control.Button(startpoint.X + 100 - 50, 200 - 50, 100, 100, "圆形按钮", 0, null, new Control.Button.ButtonCallBack((Control.Button b) => {

                Point p = new Point(Screen.PrimaryScreen.Bounds.Width / 2 - 50, 160);
                ControlBase item = new Control.Button(p.X,p.Y,100,100, "圆形按钮",(short)'A',0);
                item.g = gp;
                Touch.MobList.Add(item);
                SaveItem = item;
                DrawUI();
            })));

            NewList.Add(new Control.Button(startpoint.X + 300 - 50, 200 - 40, 100, 80, "方形按钮", 4, null, new Control.Button.ButtonCallBack((Control.Button b) => {
                Point p = new Point(Screen.PrimaryScreen.Bounds.Width / 2 - 50, 160);
                ControlBase item = new Control.Button(p.X, p.Y, 100, 80, "方形按钮", (short)'A', 4);
                item.g = gp;
                Touch.MobList.Add(item);
                SaveItem = item;
                DrawUI();
            })));

            NewList.Add(new Control.Stick(startpoint.X + 500 - 50, 200 - 50, 50, DefKeyList, 0, 110, 0.3F, 0.5F, new Stick.StickCallBack((Stick s) =>
            {
                Point p = new Point(Screen.PrimaryScreen.Bounds.Width / 2 - 50, 160);
                ControlBase item = new Stick(p.X, p.Y, 50, DefKeyList);
                item.g = gp;
                Touch.MobList.Add(item);
                SaveItem = item;
                DrawUI();
            })));

            ContList.Add(new Control.Button(startpoint.X + 10, 0, 80, 50, "添加", 4, new Control.Button.ButtonCallBack((Control.Button b) =>
            {
                isNewList = true;
                DrawNewList();
            })));

            ContList.Add(new Control.Button(startpoint.X + 110, 0, 80, 50, "删除", 4, new Control.Button.ButtonCallBack((Control.Button b) =>
            {
                if (SaveItem != null)
                {
                    Touch.MobList.Remove(SaveItem);
                    SaveItem = null;
                    DrawUI();
                    GC.Collect();
                }
            })));

            ContList.Add(new Control.Button(startpoint.X + 210, 0, 80, 50, "复制", 4, new Control.Button.ButtonCallBack((Control.Button b) =>
            {
                if (SaveItem != null)
                {
                    Point p = new Point(Screen.PrimaryScreen.Bounds.Width / 2-SaveItem.rect.Width/2,200-SaveItem.rect.Height/2);
                    ControlBase item = SaveItem.clone();
                    item.setpos(p);
                    Touch.MobList.Add(item);
                    DrawUI();
                }
            })));

            ContList.Add(new Control.Button(startpoint.X + 310, 0, 80, 50, "放大", 4, new Control.Button.ButtonCallBack((Control.Button b) =>
            {
                if (SaveItem != null)
                {
                    if (SaveItem is Control.Button)
                    {
                        SaveItem.setsize(new Size((ButtonXSize) ? SaveItem.rect.Width + 10 : SaveItem.rect.Width, (ButtonYSize) ? SaveItem.rect.Height + 10 : SaveItem.rect.Height));
                    }
                    else
                    {
                        SaveItem.setsize(new Size(SaveItem.rect.Width + 10, SaveItem.rect.Height + 10));
                    }
                    SaveItem.setpos(SaveItem.rect.Location);
                    DrawUI();
                }
            })));

            ContList.Add(new Control.Button(startpoint.X + 410, 0, 80, 50, "缩小", 4, new Control.Button.ButtonCallBack((Control.Button b) =>
            {

                if (SaveItem != null)
                {
                    if (SaveItem.rect.Width > 10 && SaveItem.rect.Height > 10)
                    {
                        if(SaveItem is Control.Button)
                            SaveItem.setsize(new Size((ButtonXSize) ? SaveItem.rect.Width - 10 : SaveItem.rect.Width, (ButtonYSize) ? SaveItem.rect.Height - 10 : SaveItem.rect.Height));
                        else
                            SaveItem.setsize(new Size(SaveItem.rect.Width - 10, SaveItem.rect.Height - 10));
                        SaveItem.setpos(SaveItem.rect.Location);
                        DrawUI();
                    }
                }
            })));
            ContList.Add(new Control.Button(startpoint.X + 510, 0, 80, 50, "关闭", 4,null, new Control.Button.ButtonCallBack((Control.Button b) => { Hide(); if (CallShowOK != null)CallShowOK(); })));

            foreach (Control.Button b in ContList)
                b.g = gp;
            foreach (Control.ControlBase b in NewList)
                b.g = gp;
            foreach (Control.ControlBase b in ButtonInfo)
                b.g = gp;
            foreach (Control.ControlBase b in StickInfo)
                b.g = gp;
        }
Exemple #2
0
 public override ControlBase clone()
 {
     Button b = new Button(this.rect.X, this.rect.Y, this.rect.Width, this.rect.Height, this.name, this.key,this.mode);
     b.g = g;
     b.redraw = redraw;
     b.id = -1;
     return b;
 }