private void Toolbox_Move(object sender, EventArgs e) { if (this.snapToWorkspace) { this.Location = new System.Drawing.Point(Derma.GetWorkspace().Location.X - Derma.toolbox.ClientSize.Width - 20, Derma.GetWorkspace().Location.Y); } }
private void PropertiesWindow_Move(object sender, EventArgs e) { if (this.snapToWorkspace) { this.Location = new System.Drawing.Point(Derma.GetWorkspace().Location.X + Derma.GetWorkspace().ClientSize.Width + 24, Derma.GetWorkspace().Location.Y); } }
public bool IsCentered() { if (this.x == (Derma.GetWorkspace().Width / 2) - (this.width / 2) && this.y == (Derma.GetWorkspace().Width / 2) - (this.height / 2)) { return(true); } return(false); }
private void menuItem29_Click(object sender, EventArgs e) { MenuItem t = (MenuItem)sender; t.Checked = !t.Checked; Derma.toolbox.snapToWorkspace = t.Checked; if (t.Checked) { Derma.toolbox.Location = new System.Drawing.Point(Derma.GetWorkspace().Location.X - Derma.toolbox.ClientSize.Width - 20, Derma.GetWorkspace().Location.Y); } }
public void Center() { if (this.hasParent && this.parent) { this.SetPos(parent.x + (parent.width / 2) - (this.width / 2), parent.y + (parent.height / 2) - (this.height / 2)); } else { this.SetPos((Derma.GetWorkspace().Width / 2) - (this.width / 2), (Derma.GetWorkspace().Height / 2) - (this.height / 2)); } }
private void Form1_Move(object sender, EventArgs e) { if (Derma.toolbox != null && Derma.toolbox.snapToWorkspace) { Derma.toolbox.Location = new System.Drawing.Point(Derma.GetWorkspace().Location.X - Derma.toolbox.ClientSize.Width - 20, Derma.GetWorkspace().Location.Y); } if (Derma.prop != null && Derma.prop.snapToWorkspace) { Derma.prop.Location = new System.Drawing.Point(Derma.GetWorkspace().Location.X + Derma.GetWorkspace().ClientSize.Width + 24, Derma.GetWorkspace().Location.Y); } }
public static Image LoadImage(string filename, bool abspath) { Image img; if (!abspath) { filename = Application.StartupPath + "\\" + filename; } try { img = Image.FromFile(filename); return(img); } catch (Exception e) { MessageBox.Show("Error loading image from file \"" + filename + "\" : " + e.ToString() + ".\n\nExiting.", "Fatal error"); Derma.GetWorkspace().Close(); Application.Exit(); } return(null); }
private void menuItem12_Click(object sender, EventArgs e) { Derma.GetWorkspace().Close(); Application.Exit(); }
public static SaveFileDialog GetSaveDialog() { return(((Main)Derma.GetWorkspace()).SaveDialog); }
public static OpenFileDialog GetOpenDialog() { return(((Main)Derma.GetWorkspace()).OpenDialog); }
public static void SetEnvironment(string filename) { CurrentFilename = filename; Derma.GetWorkspace().Text = "DermaDesigner - " + Path.GetFileName(filename); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); string[] args = Environment.GetCommandLineArgs(); bool openFileOnStartup = false; if (args.Length > 1 && File.Exists(args[1]) && Path.GetExtension(args[1]) == ".ddproj") { openFileOnStartup = true; } // Set this before making any derma controls Derma.Init(new Main(), new PropertiesWindow(), new Toolbox()); Derma.GetWorkspace().Show(); Derma.toolbox.Location = new System.Drawing.Point(Derma.GetWorkspace().Location.X - Derma.toolbox.ClientSize.Width - 20, Derma.GetWorkspace().Location.Y); Derma.toolbox.Show(); Derma.prop.Location = new System.Drawing.Point(Derma.GetWorkspace().Location.X + Derma.GetWorkspace().ClientSize.Width + 24, Derma.GetWorkspace().Location.Y); Derma.prop.Show(); Derma.GetWorkspace().Focus(); /* here we will register all the classes derived from Panel */ Assembly DD = Assembly.GetExecutingAssembly(); foreach (Type type in DD.GetTypes()) { if (type.IsSubclassOf(typeof(Panel))) { MethodInfo r = type.GetMethod("Register"); if (r == null) { MessageBox.Show("Derma control \"" + type.ToString() + "\" failed to register: Register class method not found.", "Control registration error"); } else { r.Invoke(type, new object[] { }); } } } /* end panel registration */ /* here we will load all the extension modules and register the panels in them */ string[] files = Directory.GetFiles(Application.StartupPath + "\\" + "plugins", "*.dll"); foreach (string dll in files) { Assembly fe = LoadPlugin(Path.GetFullPath(dll), dll); if (fe != null) { foreach (Type type in fe.GetTypes()) { if (type.IsSubclassOf(typeof(Panel))) { MethodInfo r = type.GetMethod("Register"); if (r == null) { MessageBox.Show("Derma control \"" + type.ToString() + "\" from plugin " + dll + " failed register: Register class method not found.", "Control registration error"); } else { r.Invoke(type, new object[] { }); } } } } } /* end module registration */ Derma.GetWorkspace().GotFocus += new EventHandler(Program_GotFocus); Derma.GetWorkspace().SizeChanged += new EventHandler(Program_GotFocus); Derma.GetWorkspace().LostFocus += new EventHandler(Program_LostFocus); ShowWindowInterop.ShowInactiveTopmost((Form)Derma.prop); ShowWindowInterop.ShowInactiveTopmost((Form)Derma.toolbox); if (openFileOnStartup) { DSave.Load(args[1]); } Application.Run(Derma.GetWorkspace()); }
static void Program_LostFocus(object sender, EventArgs e) { IntPtr FocusedWindow = ShowWindowInterop.GetForegroundWindowPtr(); if (Derma.toolbox.Handle == FocusedWindow || Derma.prop.Handle == FocusedWindow || Derma.GetWorkspace().Handle == FocusedWindow) { return; } else { ShowWindowInterop.HideTarget(Derma.toolbox); ShowWindowInterop.HideTarget(Derma.prop); } }