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"; }
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; } }