Example #1
0
 private void menuItem7_Click(object sender, EventArgs e)
 {
     if (DSave.GetEnvironment() == "Untitled.ddproj")
     {
         SaveDialog.ShowDialog();
     }
     else
     {
         DSave.Save();
     }
 }
Example #2
0
        public static void Init(Form mainform, PropertiesWindow prp, Toolbox tb)
        {
            workspace = mainform;
            prop      = prp;
            toolbox   = tb;

            toolbox.controlPanel.LargeImageList           = new ImageList();
            toolbox.controlPanel.LargeImageList.ImageSize = new Size(32, 32);

            Tick.Interval = 20;
            Tick.Tick    += TickEvent;
            Tick.Tick    += new EventHandler(RepaintTick);
            Tick.Start();

            // for big logo
            colMatrix.Matrix33 = .2F;
            imAttr.SetColorMatrix(colMatrix);

            // For panel dragging
            workspace.MouseMove += PanelDrag;

            // Draw all the panels
            workspace.Paint += Paint;

            // Draw the resizer thing on the active panel
            workspace.Paint += ResizeGrip.Paint;

            // Resizer mouse events
            workspace.MouseUp   += ResizeGrip.Resize_MouseUp;
            workspace.MouseMove += ResizeGrip.Resize_MouseMove;

            // Create our mouse event handlers for derma controls
            workspace.MouseClick       += MouseClick;
            workspace.MouseDoubleClick += MouseDoubleClick;
            workspace.MouseDown        += MouseDown;
            workspace.MouseMove        += MouseMove;
            workspace.MouseUp          += MouseUp;
            workspace.MouseWheel       += MouseWheel;

            // Set up the "Default" font
            fontCollection.AddFontFile("Marlett.ttf");
            fontCollection.AddFontFile(Application.StartupPath + "\\" + "resources/defaultFont.ttf");

            DefaultFontFamily = fontCollection.Families[1];
            DefaultFont       = new Font(DefaultFontFamily, 6);

            MarlettFontFamily = fontCollection.Families[0];
            MarlettFont       = new Font(MarlettFontFamily, 10);

            DSave.SetEnvironment("Untitled.ddproj");
        }
Example #3
0
 private void menuItem5_Click(object sender, EventArgs e)
 {
     if (Derma.GetPanels().Count > 0)
     {
         DialogResult reply = MessageBox.Show("Are you sure you want to open a saved project?\nAny unsaved data in the current project will be lost.",
                                              "Open project", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
         if (reply != DialogResult.Yes)
         {
             return;
         }
     }
     DSave.SetDialogDefaults();
     Derma.prop.propertyGrid.SelectedObject = null;
     OpenDialog.ShowDialog();
 }
Example #4
0
 private void menuItem4_Click(object sender, EventArgs e)
 {
     if (Derma.GetPanels().Count > 0)
     {
         DialogResult reply = MessageBox.Show("Are you sure you want to start a new project?\nAny unsaved data will be lost.",
                                              "Really create a new project?", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
         if (reply == DialogResult.Yes)
         {
             DSave.ClearAll();
             Derma.prop.propertyGrid.SelectedObject = null;
             Derma.Repaint();
         }
     }
     else
     {
         DSave.ClearAll();
         Derma.prop.propertyGrid.SelectedObject = null;
         Derma.Repaint();
     }
 }
Example #5
0
 private void Main_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (Derma.GetPanels().Count > 0)
     {
         DialogResult reply = MessageBox.Show("Do you want to save your current project?",
                                              "Save project", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
         if (reply == DialogResult.Yes)
         {
             if (DSave.GetEnvironment() == "Untitled.ddproj")
             {
                 SaveDialog.ShowDialog();
             }
             else
             {
                 DSave.Save();
             }
         }
         else if (reply == DialogResult.Cancel)
         {
             e.Cancel = true;
         }
     }
 }
Example #6
0
 private void menuItem8_Click(object sender, EventArgs e)
 {
     DSave.SetDialogDefaults();
     SaveDialog.ShowDialog();
 }
Example #7
0
 private void OpenDialog_FileOk(object sender, CancelEventArgs e)
 {
     DSave.ClearAll();
     DSave.Load(OpenDialog.FileName);
 }
Example #8
0
 private void SaveDialog_FileOk(object sender, CancelEventArgs e)
 {
     DSave.SaveAs(SaveDialog.FileName);
 }
Example #9
0
        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());
        }