示例#1
0
        private void SelectControl(object sender, EventArgs e)
        {
            FGuiPath = sender.GetType().GetProperty("ImageLocation").GetValue(sender).ToString();
            //Main main = new Main();
            //GuiProperty guiProperty = new GuiProperty();
            //main.propertyGrid1.SelectedObject = guiProperty;
            if (m_control is Control)
            {
                m_control.Cursor = oldCursor;

                //Remove event any pre-existing event handlers appended by this class
                m_control.MouseDown -= new MouseEventHandler(this.ctl_MouseDown);
                m_control.MouseMove -= new MouseEventHandler(this.ctl_MouseMove);
                m_control.MouseUp   -= new MouseEventHandler(this.ctl_MouseUp);
                //m_control.MouseClick -= new MouseEventHandler(this.ctl_MouseClick);
                m_control = null;
            }

            m_control = (Control)sender;
            //Add event handlers for moving the selected control around
            m_control.MouseDown += new MouseEventHandler(this.ctl_MouseDown);
            m_control.MouseMove += new MouseEventHandler(this.ctl_MouseMove);
            m_control.MouseUp   += new MouseEventHandler(this.ctl_MouseUp);
            m_control.Resize    += new EventHandler(this.ctl_Resize);
            //m_control.MouseClick += new MouseEventHandler(this.ctl_MouseClick);

            //Add sizing handles to Control's container (Form or PictureBox)
            for (int i = 0; i < 8; i++)
            {
                m_control.Parent.Controls.Add(lbl[i]);
                lbl[i].BringToFront();
            }
            string Tag     = (string)m_control.Tag;
            string YmlName = Tag.Substring(Tag.LastIndexOf(":") + 1);

            try
            {
                if (Tag.StartsWith("gui:"))
                {
                    Main.Mainfrm.GuiComboBox.SelectedIndex = Main.Mainfrm.GuiComboBox.Items.IndexOf("GUI:" + YmlName + ".yml");
                    XmlMethods.ReadGui(Main.GuisPath + YmlName + ".xml");
                    Main.Mainfrm.GuiPropertyGrid.SelectedObject = gui;
                }
            }
            catch { }
            //Position sizing handles around Control
            MoveHandles();

            //Display sizing handles
            ShowHandles();

            oldCursor = m_control.Cursor;
            //m_control.Cursor = Cursors.SizeAll;
            Main.Mainfrm.LbX.Text = "X:0";
            Main.Mainfrm.LbY.Text = "Y:0";
        }
示例#2
0
 public static void ShowHandles()
 {
     try
     {
         if (CurrentControl != null)
         {
             for (int i = 0; i < 8; i++)
             {
                 Rectangle[i].Visible = true;
             }
         }
         string Tag     = (string)CurrentControl.Tag;
         string YmlName = Tag.Substring(Tag.LastIndexOf(":") + 1) + ".xml";
         if (Tag.StartsWith("image:"))
         {
             SGuiFrame.Im.XShow = ControlW.ToString();
             SGuiFrame.Im.YShow = ControlH.ToString();
             SGuiFrame.Im.X     = (CurrentControl.Location.X - Main.Mainfrm.Gui_X).ToString();
             SGuiFrame.Im.Y     = (CurrentControl.Location.Y - Main.Mainfrm.Gui_Y).ToString();
             XmlMethods.ModifyIm(Main.ImagesPath + YmlName);
             XmlMethods.ReadIm(Main.ImagesPath + YmlName);
             Main.Mainfrm.GuiPropertyGrid.SelectedObject = Im;
         }
         else if (Tag.StartsWith("button:"))
         {
             SGuiFrame.Bt.Width = ControlW.ToString();
             SGuiFrame.Bt.High  = ControlH.ToString();
             SGuiFrame.Bt.X     = (CurrentControl.Location.X - Main.Mainfrm.Gui_X).ToString();
             SGuiFrame.Bt.Y     = (CurrentControl.Location.Y - Main.Mainfrm.Gui_Y).ToString();
             XmlMethods.ModifyBt(Main.ButtonsPath + YmlName);
             XmlMethods.ReadBt(Main.ButtonsPath + YmlName);
             Main.Mainfrm.GuiPropertyGrid.SelectedObject = Bt;
         }
         else if (Tag.StartsWith("text:"))
         {
             SGuiFrame.Txt.X = (CurrentControl.Location.X - Main.Mainfrm.Gui_X).ToString();
             SGuiFrame.Txt.Y = (CurrentControl.Location.Y - Main.Mainfrm.Gui_Y).ToString();
             XmlMethods.ModifyTxt(Main.TextsPath + YmlName);
             XmlMethods.ReadTxt(Main.TextsPath + YmlName);
             Main.Mainfrm.GuiPropertyGrid.SelectedObject = Txt;
         }
     }
     catch
     {
         //MessageBox.Show("66");
     }
 }
示例#3
0
 public void GuiCodeTxt_TextChanged(object sender, EventArgs e)
 {
     try
     {
         LineP.Invalidate();
         //比如 map_title    ok
         string currentTabName = Main.Mainfrm.tabControl1.TabPages[Main.Mainfrm.tabControl1.SelectedIndex].Text.Substring(Main.Mainfrm.tabControl1.TabPages[Main.Mainfrm.tabControl1.SelectedIndex].Text.IndexOf(":") + 1);  //map_title.yml [文档]
         string newName        = currentTabName.Substring(0, currentTabName.LastIndexOf("[") - 5);
         if (Main.Mainfrm.tabControl1.TabPages[Main.Mainfrm.tabControl1.SelectedIndex].Tag == "image")
         {
             Stream stream = File.Open(Main.ImagesPath + newName + ".xml", FileMode.Open, FileAccess.Write, FileShare.ReadWrite);
             stream.Seek(0, SeekOrigin.Begin);
             stream.SetLength(0);
             stream.Close();
             File.WriteAllText(Main.ImagesPath + newName + ".xml", Main.Mainfrm.tabControl1.TabPages[Main.Mainfrm.tabControl1.SelectedIndex].Controls[0].Controls[0].Text);
             XmlMethods.ReadIm(Main.ImagesPath + newName + ".xml");
             Main.Mainfrm.GuiPropertyGrid.SelectedObject = SGuiFrame.Im;
         }
         else if (Main.Mainfrm.tabControl1.TabPages[Main.Mainfrm.tabControl1.SelectedIndex].Tag == "button")
         {
             Stream stream = File.Open(Main.ButtonsPath + newName + ".xml", FileMode.Open, FileAccess.Write, FileShare.ReadWrite);
             stream.Seek(0, SeekOrigin.Begin);
             stream.SetLength(0);
             stream.Close();
             File.WriteAllText(Main.ButtonsPath + newName + ".xml", Main.Mainfrm.tabControl1.TabPages[Main.Mainfrm.tabControl1.SelectedIndex].Controls[0].Controls[0].Text);
             XmlMethods.ReadBt(Main.ButtonsPath + newName + ".xml");
             Main.Mainfrm.GuiPropertyGrid.SelectedObject = SGuiFrame.Bt;
         }
         else if (Main.Mainfrm.tabControl1.TabPages[Main.Mainfrm.tabControl1.SelectedIndex].Tag == "text")
         {
             Stream stream = File.Open(Main.TextsPath + newName + ".xml", FileMode.Open, FileAccess.Write, FileShare.ReadWrite);
             stream.Seek(0, SeekOrigin.Begin);
             stream.SetLength(0);
             stream.Close();
             File.WriteAllText(Main.TextsPath + newName + ".xml", Main.Mainfrm.tabControl1.TabPages[Main.Mainfrm.tabControl1.SelectedIndex].Controls[0].Controls[0].Text);
             XmlMethods.ReadTxt(Main.TextsPath + newName + ".xml");
             Main.Mainfrm.GuiPropertyGrid.SelectedObject = SGuiFrame.Txt;
         }
     }
     catch
     {
     }
 }
示例#4
0
        private void ShowHandles()
        {
            if (m_control != null)
            {
                for (int i = 0; i < 8; i++)
                {
                    lbl[i].Visible = true;
                }
            }
            string Tag     = (string)m_control.Tag;
            string YmlName = Tag.Substring(Tag.LastIndexOf(":") + 1) + ".xml";

            //MessageBox.Show(YmlName);
            if (Tag.StartsWith("gui:"))
            {
                FGuiFrame.gui.XShow = m_control.Width.ToString();
                FGuiFrame.gui.YShow = m_control.Height.ToString();
                FGuiFrame.gui.X     = (m_control.Location.X - Main.Mainfrm.Gui_X).ToString();
                FGuiFrame.gui.Y     = (m_control.Location.Y - Main.Mainfrm.Gui_Y).ToString();
                XmlMethods.ModifyGui(Main.GuisPath + YmlName);
                XmlMethods.ReadGui(Main.GuisPath + YmlName);
                Main.Mainfrm.GuiPropertyGrid.SelectedObject = gui;
            }
        }
示例#5
0
        public void SelectControl(object sender, EventArgs e)
        {
            try
            {
                if (CurrentControl is Control)
                {
                    CurrentControl.Cursor = oldCursor;

                    //Remove event any pre-existing event handlers appended by this class
                    CurrentControl.MouseDown   -= new MouseEventHandler(this.SGuiFrame_MouseDown);
                    CurrentControl.MouseMove   -= new MouseEventHandler(this.SGuiFrame_MouseMove);
                    CurrentControl.MouseUp     -= new MouseEventHandler(this.SGuiFrame_MouseUp);
                    CurrentControl.DoubleClick -= new EventHandler(this.SGuiFrame_DoubleClick);
                    CurrentControl.Resize      -= new EventHandler(this.SGuiFrame_Resize);
                    //CurrentControl.LostFocus -= new EventHandler(this.SGuiFrame_LostFocus);
                    //
                    CurrentControl = null;
                }

                CurrentControl = (Control)sender;
                //Add event handlers for moving the selected control around
                CurrentControl.MouseDown   += new MouseEventHandler(this.SGuiFrame_MouseDown);
                CurrentControl.MouseMove   += new MouseEventHandler(this.SGuiFrame_MouseMove);
                CurrentControl.MouseUp     += new MouseEventHandler(this.SGuiFrame_MouseUp);
                CurrentControl.DoubleClick += new EventHandler(this.SGuiFrame_DoubleClick);
                CurrentControl.Resize      += new EventHandler(this.SGuiFrame_Resize);
                //CurrentControl.LostFocus += new EventHandler(this.SGuiFrame_LostFocus);
                //Add sizing handles to Control's container (Form or PictureBox)
                for (int i = 0; i < 8; i++)
                {
                    CurrentControl.Parent.Controls.Add(Rectangle[i]);
                    Rectangle[i].BringToFront();
                }
                string Tag     = (string)CurrentControl.Tag;
                string YmlName = Tag.Substring(Tag.LastIndexOf(":") + 1);

                if (Tag.StartsWith("image:"))
                {
                    //先改变GuiComboBox的值非常重要,如果等到propertygrid控件选择完对象以后再改变变量值会发生改变,触发guicomboBox IndexChanged的modify就会错误保存。
                    Main.Mainfrm.GuiComboBox.SelectedIndex = Main.Mainfrm.GuiComboBox.Items.IndexOf("图像:" + YmlName + ".yml");
                    XmlMethods.ReadIm(Main.ImagesPath + YmlName + ".xml");
                    ControlW = Convert.ToInt32(SGuiFrame.Im.XShow);
                    ControlH = Convert.ToInt32(SGuiFrame.Im.YShow);
                    Main.Mainfrm.GuiPropertyGrid.SelectedObject = Im;
                }
                else if (Tag.StartsWith("button:"))
                {
                    Main.Mainfrm.GuiComboBox.SelectedIndex = Main.Mainfrm.GuiComboBox.Items.IndexOf("按钮:" + YmlName + ".yml");
                    XmlMethods.ReadBt(Main.ButtonsPath + YmlName + ".xml");
                    ControlW = Convert.ToInt32(SGuiFrame.Bt.Width);
                    ControlH = Convert.ToInt32(SGuiFrame.Bt.High);
                    Main.Mainfrm.GuiPropertyGrid.SelectedObject = Bt;
                }
                else if (Tag.StartsWith("text:"))
                {
                    Main.Mainfrm.GuiComboBox.SelectedIndex = Main.Mainfrm.GuiComboBox.Items.IndexOf("文本:" + YmlName + ".yml");
                    XmlMethods.ReadTxt(Main.TextsPath + YmlName + ".xml");
                    Main.Mainfrm.GuiPropertyGrid.SelectedObject = Txt;
                }
                //Position sizing handles around Control
                MoveHandles();

                //Display sizing handles
                ShowHandles();

                oldCursor             = CurrentControl.Cursor;
                CurrentControl.Cursor = Cursors.SizeAll;
                //CurrentControl.BringToFront();
            }
            catch (Exception ex)
            {
                MessageBox.Show("请检查xml文本编辑框内容,缺少了尖括号和标签等请手动填补上去");
            }
        }