예제 #1
0
        void HandleControls(GuiConfigDB conf)
        {
            if (conf.HideAllControls.IsExplicit() && conf.HideAllControls)
            {
                HideAllControls();
            }
            // apply default style if exists
            GuiControlStyle stl = conf.GetControlStyle("DefaultControl");

            if (stl != null)
            {
                DefaultControlStyle = stl;
                foreach (KeyValuePair <String, Control> pair in Controls)
                {
                    if (pair.Value is ctlUserPanel)
                    {
                        ctlUserPanel ctl = (ctlUserPanel)pair.Value;
                        ctl.ApplyStyle(stl);
                    }
                    else
                    {
                        // apply the style by recursing through the object
                        ApplyStyleRecurse(pair.Value, stl);
                    }
                }
            }

            foreach (KeyValuePair <string, GuiControl> pair in conf.GuiControlsDict)
            {
                HandleControl(conf, pair.Value);
            }
        }
        public CWParameter GetParameter(string name, object defaultVal)
        {
            if (paramDict.ContainsKey(name))
            {
                return(paramDict[name]);
            }
            CWParameter par = null;

            if (defaultVal is string)
            {
                par = CWParameter.CreateStringParam((string)defaultVal, null);
            }
            else if (defaultVal is int)
            {
                par = CWParameter.CreateIntParam(((int)defaultVal).ToString(), null);
            }
            else if (defaultVal is bool)
            {
                par = CWParameter.CreateBoolParam(((bool)defaultVal).ToString(), null);
            }
            else if (defaultVal is Color)
            {
                par = CWParameter.CreateColorParam(GuiConfigDB.ColorToString((Color)defaultVal), null);
            }
            if (par != null)
            {
                par.paramName   = name;
                paramDict[name] = par;
                ConfigChanged   = true;
            }
            return(par);
        }
예제 #3
0
        public void ApplyConfiguration(GuiConfigDB conf)
        {
            guiConf = conf;
            if (firstTime)
            {
                UVDLPApp.Instance().m_callbackhandler.RegisterCallback("GMActivateTab", ActivateTab, "GUI Tab Activation <ctlTabItem> <ctlTabContent>");
                firstTime = false;
            }
            try
            {
                // read and store all styles
                foreach (KeyValuePair <string, GuiControlStyle> pair in conf.GuiControlStylesDict)
                {
                    GuiControlStylesDict[pair.Key] = pair.Value;
                }

                HandleDecals(conf);
                HandleButtonCreation(conf);
                HandleLayouts(conf);
                HandleControls(conf);
                HandleButtons(conf);
                HandleSequences(conf);
            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogError(ex);
            }
        }
예제 #4
0
 private void loadGUIConfigToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         // load a new GUIConfig file from disk
         // this is a debug only function for now.
         openFileDialog1.Filter = "Gui Config Files (*.xml;*.txt)|*.xml;*.txt|All files (*.*)|*.*";
         if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             // test new gui config system
             GuiConfigDB gconfdb = new GuiConfigDB();
             gconfdb.LoadConfigFromFile(openFileDialog1.FileName);
             //gconfdb.PreviewMode = true;
             UVDLPApp.Instance().m_gui_config.ApplyConfiguration(gconfdb);
             Control winLayout = UVDLPApp.Instance().m_gui_config.GetLayout("MainLayout");
             if (winLayout != null)
             {
                 Form frm = new Form();
                 frm.Size = new Size(winLayout.Width, winLayout.Height);
                 frm.Controls.Add(winLayout);
                 frm.ShowDialog();
             }
             UVDLPApp.Instance().m_gui_config.DumpDatabase("GuiManagerDatabase.txt");
             //UVDLPApp.Instance().m_gui_config.LayoutGui(
         }
     }catch (Exception ex)
     {
         DebugLogger.Instance().LogError(ex);
     }
 }
예제 #5
0
        public frmMain2()
        {
            SceneFileExt = "cws";// default to creation workshop CWS files
            m_lsttabs    = new List <tabview>();
            m_logSB      = new StringBuilder();
            InitializeComponent();

            UVDLPApp.Instance().m_mainform = this;
            m_manctl = ManualControl.Instance(); // late intialization happens here after the UVDLP app Singleton is initiated.

            RegisterCallbacks();
            RegisterGUI();
            SetButtonStatuses();
            UVDLPApp.Instance().AppEvent += new AppEventDelegate(AppEventDel);
            DebugLogger.Instance().LoggerStatusEvent += new LoggerStatusHandler(LoggerStatusEvent);
            UVDLPApp.Instance().m_slicer.Slice_Event += new Slicer.SliceEvent(SliceEv);
            UVDLPApp.Instance().m_buildmgr.BuildStatus += new delBuildStatus(BuildStatus);
            UVDLPApp.Instance().m_deviceinterface.StatusEvent += new DeviceInterface.DeviceInterfaceStatus(DeviceStatusEvent);
            UVDLPApp.Instance().m_buildmgr.PrintLayer += new delPrinterLayer(PrintLayer);
            UVDLPApp.Instance().Engine3D.UpdateGrid();
            ctl3DView1.UpdateView(); // initial update
            // set up initial log data in form
            foreach (string lg in DebugLogger.Instance().GetLog())
            {
                //txtLog.Text = lg + "\r\n" + txtLog.Text;
                AddtoLog(lg);
            }
            //RearrangeGui
            AddButtons();
            AddControls();
            SetupTabs();
            //set the default tab
            m_viewtype = -1; // start with the first tab added
            ShowView(0);     // 3d tab


            ctl3DView1.RearrangeGui();
            ctl3DView1.Enable3dView(true);
            // test new gui config system
            GuiConfigDB gconfdb = new GuiConfigDB();

            gconfdb.LoadConfiguration(global::UV_DLP_3D_Printer.Properties.Resources.GuiConfig);
            UVDLPApp.Instance().m_gui_config.ApplyConfiguration(gconfdb);
            gconfdb.SaveConfiguration("GuiConfigTest");

            //ctlSliceGCodePanel1.ctlSliceViewctl.DlpForm = m_frmdlp; // set the dlp form for direct control
            SetMainMessage("");
            SetTimeMessage("");
            #if (DEBUG)
            ShowLogPanel(true);
            #else
            ShowLogPanel(false);
            pluginTesterToolStripMenuItem.Visible       = false;
            testToolStripMenuItem.Visible               = false;
            testMachineControlToolStripMenuItem.Visible = false;
            loadGUIConfigToolStripMenuItem.Visible      = false;
            #endif
            SetTitle();
            UVDLPApp.Instance().PerformPluginCommand("MainFormLoadedCommand", true);
        }
예제 #6
0
 void HandleLayouts(GuiConfigDB conf)
 {
     foreach (GuiLayout gl in conf.GuiLayouts)
     {
         Control ctl = CreateLayoutRecurse(gl);
         GuiLayouts[gl.name] = ctl;
     }
 }
예제 #7
0
        public frmMain2()
        {
            m_logSB = new StringBuilder();
            InitializeComponent();
            m_viewtype = eViewTypes.eNone;
            UVDLPApp.Instance().m_mainform = this;
            m_manctl = ManualControl.Instance(); // late intialization happens here after the UVDLP app Singleton is initiated.

            ctlTitle3dView.Checked = true; // set it as checked
            ctlTitle3dView_Click(null, null); // and click the button

            RegisterCallbacks();
            RegisterGUI();
            SetButtonStatuses();
            UVDLPApp.Instance().AppEvent += new AppEventDelegate(AppEventDel);
            DebugLogger.Instance().LoggerStatusEvent += new LoggerStatusHandler(LoggerStatusEvent);
            UVDLPApp.Instance().m_slicer.Slice_Event += new Slicer.SliceEvent(SliceEv);
            UVDLPApp.Instance().m_buildmgr.BuildStatus += new delBuildStatus(BuildStatus);
            UVDLPApp.Instance().m_deviceinterface.StatusEvent += new DeviceInterface.DeviceInterfaceStatus(DeviceStatusEvent);
            UVDLPApp.Instance().m_buildmgr.PrintLayer += new delPrinterLayer(PrintLayer);
            UVDLPApp.Instance().Engine3D.UpdateGrid();
            ctl3DView1.UpdateView(); // initial update
            // set up initial log data in form
            foreach (string lg in DebugLogger.Instance().GetLog())
            {
                //txtLog.Text = lg + "\r\n" + txtLog.Text;
                AddtoLog(lg);
            }
            //RearrangeGui
            AddButtons();
            AddControls();
            ctl3DView1.RearrangeGui();
            ctl3DView1.Enable3dView(true);
            #if (DEBUG) // DBG_GUICONF
            // test new gui config system
            GuiConfigDB gconfdb = new GuiConfigDB();
            gconfdb.LoadConfiguration(global::UV_DLP_3D_Printer.Properties.Resources.GuiConfig);
            UVDLPApp.Instance().m_gui_config.ApplyConfiguration(gconfdb);
            gconfdb.SaveConfiguration("GuiConfigTest");
            #else
            UVDLPApp.Instance().m_gui_config.LoadConfiguration(global::UV_DLP_3D_Printer.Properties.Resources.GuiConfig);
            #endif

            //ctlSliceGCodePanel1.ctlSliceViewctl.DlpForm = m_frmdlp; // set the dlp form for direct control
            SetMainMessage("");
            SetTimeMessage("");
            #if (DEBUG)
                ShowLogPanel(true);
            #else
                ShowLogPanel(false);
                pluginTesterToolStripMenuItem.Visible = false;
                testToolStripMenuItem.Visible = false;
                testMachineControlToolStripMenuItem.Visible = false;
                loadGUIConfigToolStripMenuItem.Visible = false;
            #endif
                SetTitle();
            UVDLPApp.Instance().PerformPluginCommand("MainFormLoadedCommand", true);
        }
예제 #8
0
 void HandleDecals(GuiConfigDB conf)
 {
     if (conf.HideAllDecals)
     {
         BgndDecorList = conf.BgndDecorList;
         FgndDecorList = conf.FgndDecorList;
     }
     BgndDecorList.AddRange(conf.BgndDecorList);
     FgndDecorList.AddRange(conf.FgndDecorList);
 }
예제 #9
0
 void HandleSequences(GuiConfigDB conf)
 {
     foreach (CommandSequence cmdseq in conf.CmdSequenceList)
     {
         if (cmdseq.m_seqtype == CommandSequence.COMMAND_TYPE_GCODE)
         {
             GCodeSequence gcseq = new GCodeSequence(cmdseq.m_name, cmdseq.m_seq);
             SequenceManager.Instance().Add(gcseq);
         }
     }
 }
예제 #10
0
 public void Load(XmlNode xnode)
 {
     vendorID    = GuiConfigDB.GetIntParam(xnode, "vendorid", 0x1000);
     productID   = GuiConfigDB.GetIntParam(xnode, "productid", new GuiParam <int>());
     vendorName  = GuiConfigDB.GetStrParam(xnode, "vendorname", "Envision Labs");
     productName = GuiConfigDB.GetStrParam(xnode, "productname", "Envision Labs");
     description = GuiConfigDB.GetStrParam(xnode, "description", "Envision Labs Plugin");
     version     = GuiConfigDB.GetStrParam(xnode, "version", "1.0.0.1");
     guiConfig   = GuiConfigDB.GetStrParam(xnode, "guiconfig", "GuiConfig.xml");
     guiLayout   = GuiConfigDB.GetStrParam(xnode, "guilayout", new GuiParam <string>());
 }
예제 #11
0
 void HandleDecals(GuiConfigDB conf)
 {
     if (conf.HideAllDecals)
     {
         BgndDecorList.Clear();
         FgndDecorList.Clear();
     }
     BgndDecorList.AddRange(conf.BgndDecorList);
     FgndDecorList.AddRange(conf.FgndDecorList);
     UVDLPApp.Instance().Engine3D.UpdateRenderStyle(conf.RenderStyle);
 }
예제 #12
0
 void HandleButtonCreation(GuiConfigDB conf)
 {
     foreach (KeyValuePair <string, GuiButton> pair in conf.GuiButtonsDict)
     {
         GuiButton gbtn = pair.Value;
         if (!Buttons.ContainsKey(gbtn.name))
         {
             // create a new empty button
             ctlImageButton btn = new ctlImageButton();
             btn.Name = gbtn.name;
             AddButton(btn);
             btn.BringToFront();
         }
     }
 }
 void HandleSequences(GuiConfigDB conf)
 {
     foreach (CommandSequence cmdseq in conf.CmdSequenceList)
     {
         if (cmdseq.m_seqtype == CommandSequence.COMMAND_TYPE_GCODE)
         {
             GCodeSequence gcseq = new GCodeSequence(cmdseq.m_name, cmdseq.m_seq);
             SequenceManager.Instance().Add(gcseq);
         }
         if (cmdseq.m_seqtype == CommandSequence.COMMAND_TYPE_SPAWN_PROCESS)
         {
             ProcessSequence cast = (ProcessSequence)cmdseq;
             SequenceManager.Instance().Add(cast.Clone()); // insert a cloned copy into the sequencemanager
         }
     }
 }
예제 #14
0
        void HandleButtons(GuiConfigDB conf)
        {
            if (conf.HideAllButtons.IsExplicit() && conf.HideAllButtons)
            {
                HideAllButtons();
            }

            // apply default style if exists
            GuiControlStyle defbutstl = conf.GetControlStyle("DefaultButton");

            if (defbutstl != null)
            {
                DefaultButtonStyle = defbutstl;
            }
            GuiControlStyle deftitstl = conf.GetControlStyle("DefaultTitle");

            foreach (KeyValuePair <String, ctlImageButton> pair in Buttons)
            {
                ctlImageButton butt = pair.Value;
                if (butt is ctlTitle)
                {
                    if (deftitstl != null)
                    {
                        butt.ApplyStyle(deftitstl);
                    }
                }
                else
                {
                    if (defbutstl != null)
                    {
                        butt.ApplyStyle(defbutstl);
                    }
                }
            }
            foreach (KeyValuePair <string, GuiButton> pair in conf.GuiButtonsDict)
            {
                HandleButton(conf, pair.Value);
            }
        }
예제 #15
0
        public void ApplyConfiguration(GuiConfigDB conf)
        {
            guiConf = conf;
            if (firstTime)
            {
                UVDLPApp.Instance()
                .m_callbackhandler.RegisterCallback("GMActivateTab", ActivateTab,
                                                    UVDLPApp.Instance()
                                                    .resman.GetString("GUITabActivationCtlTabItemCtlTabContent", UVDLPApp.Instance().cul));
                firstTime = false;
            }
            try
            {
                // read and store all styles
                foreach (KeyValuePair <string, GuiControlStyle> pair in conf.GuiControlStylesDict)
                {
                    GuiControlStylesDict[pair.Key] = pair.Value;
                }

                HandleDecals(conf);
                HandleLayouts(conf);
                HandleButtonCreation(conf);
                HandleControls(conf);
                HandleButtons(conf);
                HandleSequences(conf);

                if (GuiLayouts.ContainsKey("MainLayout"))
                {
                    UVDLPApp.Instance().m_mainform.ReplaceGui(GuiLayouts["MainLayout"]);
                }
            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogError(ex);
            }
        }
 void HandleSequences(GuiConfigDB conf)
 {
     foreach (CommandSequence cmdseq in conf.CmdSequenceList)
     {
         if (cmdseq.type == CommandSequence.CSType.gcode)
         {
             GCodeSequence gcseq = new GCodeSequence(cmdseq.name, cmdseq.sequence);
             SequenceManager.Instance().Add(gcseq);
         }
     }
 }
        void HandleControls(GuiConfigDB conf)
        {
            if (conf.HideAllControls.IsExplicit() && conf.HideAllControls)
                HideAllControls();
            // apply default style if exists
            GuiControlStyle stl = conf.GetControlStyle("DefaultControl");

            if (stl != null)
            {
                DefaultControlStyle = stl;
                foreach (KeyValuePair<String, Control> pair in Controls)
                {
                    if (pair.Value is ctlUserPanel)
                    {
                        ctlUserPanel ctl = (ctlUserPanel)pair.Value;
                        ctl.ApplyStyle(stl);
                    }
                    else
                    {
                        // apply the style by recursing through the object
                        ApplyStyleRecurse(pair.Value, stl);
                    }
                }
            }

            foreach (KeyValuePair<string, GuiControl> pair in conf.GuiControlsDict)
                HandleControl(conf, pair.Value);
        }
 void HandleDecals(GuiConfigDB conf)
 {
     if (conf.HideAllDecals)
     {
         BgndDecorList = conf.BgndDecorList;
         FgndDecorList = conf.FgndDecorList;
     }
     BgndDecorList.AddRange(conf.BgndDecorList);
     FgndDecorList.AddRange(conf.FgndDecorList);
 }
        void HandleButtons(GuiConfigDB conf)
        {
            if (conf.HideAllButtons.IsExplicit() && conf.HideAllButtons)
                HideAllButtons();

            // apply default style if exists
            GuiControlStyle defstl = conf.GetControlStyle("DefaultButton");
            if (defstl != null)
            {
                DefaultButtonStyle = defstl;
                foreach (KeyValuePair<String, ctlImageButton> pair in Buttons)
                {
                    ctlImageButton butt = pair.Value;
                    butt.ApplyStyle(defstl);
                }
            }
            foreach (KeyValuePair<string, GuiButton> pair in conf.GuiButtonsDict)
                HandleButton(conf, pair.Value);
        }
        void HandleControl(GuiConfigDB conf, GuiControl gctl)
        {
            if (!Controls.ContainsKey(gctl.name))
                return;

            Control ct = Controls[gctl.name]; // find the existing control
            if (gctl.visible.IsExplicit())
                ct.Visible = gctl.visible.GetVal();
            ct.Width = gctl.w.GetIfExplicit(ct.Width);
            ct.Height = gctl.h.GetIfExplicit(ct.Height);
            //load some control locations as well,

            if (gctl.px.IsExplicit() || gctl.py.IsExplicit())
            {
                int px, py;
                px = gctl.px.GetIfExplicit(ct.Location.X);
                py = gctl.py.GetIfExplicit(ct.Location.Y);
                Point pt = new Point(px, py);
                ct.Location = pt;
            }

            // load docking style
            if (gctl.action.IsExplicit())
            {
                string action = gctl.action;  // telling something to happen to this control
                if (action.Contains("remove")) // this handles removing a control from it's parent
                {
                    // remove this control from it's parent
                    if (ct.Parent != null)
                    {
                        ct.Parent.Controls.Remove(ct);
                        ct.Parent = null;
                    }
                }
                else if (action.Contains("hide")) // this handles hiding
                {
                    // hide this control, do not remove it from the parent
                    ct.Hide();
                }
                else if (action.Contains("show")) // this handles showing
                {
                    // show this control
                    ct.Show();
                }
                else if (action.Contains("addto")) // this handles adding a new/existing control to a parent control
                {
                    // Get the name of the parent
                    // Get the name of the parent
                    string parentname = gctl.parent;
                    if (gctl.parent.IsExplicit() && (parentname != null) && (parentname.Length != 0))
                    {
                        //find the parent
                        //find the parent
                        if (Controls.ContainsKey(parentname))
                        {
                            Control ctlParent = Controls[parentname];
                            ctlParent.Controls.Add(ct);
                        }
                        else
                        {
                            DebugLogger.Instance().LogWarning("Control parent not found: " + parentname);
                        }
                    }
                }
            }

            String styleName = gctl.style.GetIfValid(null);
            GuiControlStyle style = conf.GetControlStyle(styleName);
            if (ct is ctlUserPanel)
            {
                ctlUserPanel ctl = (ctlUserPanel)ct;
                ctl.GuiAnchor = gctl.dock.GetIfExplicit(ctl.GuiAnchor);
                ctl.Gapx = gctl.x.GetIfExplicit(ctl.Gapx);
                ctl.Gapy = gctl.y.GetIfExplicit(ctl.Gapy);
                if (styleName != null)
                {
                    ctl.StyleName = styleName;
                    if (style != null)
                    {
                        ctl.GLVisible = style.glMode;
                        ctl.ApplyStyle(style);
                    }
                }
                //ctl.GLVisible = GetBoolParam(ctlnode, "gl", false);
                if (ctl.GLVisible)
                    ctl.GLBackgroundImage = gctl.BorderShape.GetIfExplicit(ctl.GLBackgroundImage);
                else
                    ctl.bgndPanel.imageName = gctl.BorderShape.GetIfExplicit(ctl.bgndPanel.imageName);
            }
            else
            {
                if (style != null)
                {
                    ApplyStyleRecurse(ct, style);
                }
            }
        }
        public void ApplyConfiguration(GuiConfigDB conf)
        {
            try
            {
                // read and store all styles
                foreach (KeyValuePair<string, GuiControlStyle> pair in conf.GuiControlStylesDict)
                    GuiControlStylesDict[pair.Key] = pair.Value;

                HandleDecals(conf);
                HandleButtons(conf);
                HandleControls(conf);
                HandleSequences(conf);
            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogError(ex);
            }
        }
        void HandleButton(GuiConfigDB conf, GuiButton gbtn)
        {
            if (!Buttons.ContainsKey(gbtn.name))
            {
                // create a new empty button
                AddButton(gbtn.name, new ctlImageButton());
                Buttons[gbtn.name].BringToFront();
            }
            ctlImageButton butt = Buttons[gbtn.name];
            //            butt.Visible = true;
            butt.Visible = gbtn.visible.GetIfExplicit(true);
            butt.GuiAnchor = gbtn.dock.GetIfExplicit(butt.GuiAnchor);
            butt.Gapx = gbtn.x.GetIfExplicit(butt.Gapx);
            butt.Gapy = gbtn.y.GetIfExplicit(butt.Gapy);
            butt.Width = gbtn.w.GetIfExplicit(butt.Width);
            butt.Height = gbtn.h.GetIfExplicit(butt.Height);
            butt.StyleName = gbtn.style.GetIfExplicit(butt.StyleName);
            butt.OnClickCallback = gbtn.onClickCmd.GetIfExplicit(butt.OnClickCallback);
            GuiControlStyle bstl = conf.GetControlStyle(butt.StyleName);
            if (bstl != null)
            {
                butt.GLVisible = bstl.glMode;
            }
            if (gbtn.image.IsExplicit())
            {
                butt.GLImage = gbtn.image;
                butt.Image = conf.GetImage(gbtn.image, null);
            }
            butt.CheckImage = conf.GetImage(gbtn.checkImage, butt.CheckImage);

            // add the ability to add buttons in various named parents
            // this will allow adding buttons to toolbar from plugins
            if (gbtn.action.IsExplicit())
            {
                string action = gbtn.action;
                if (action.Contains("remove")) // this handles removing a control from it's parent
                {
                    // remove this control from it's parent
                    if (butt.Parent != null)
                    {
                        butt.Parent.Controls.Remove(butt);
                        butt.Parent = null;
                    }
                }
                else if (action.Contains("addto")) // this handles adding a new control to a parent control
                {
                    // Get the name of the parent
                    string parentname = gbtn.parent;
                    if (gbtn.parent.IsExplicit() && (parentname != null) && (parentname.Length != 0))
                    {
                        //find the parent
                        if (Controls.ContainsKey(parentname))
                        {
                            Control ctlParent = Controls[parentname];
                            ctlParent.Controls.Add(butt);
                        }
                        else
                        {
                            DebugLogger.Instance().LogWarning("Button parent not found: " + parentname);
                        }
                    }
                }
            }
        }
예제 #23
0
 void HandleLayouts(GuiConfigDB conf)
 {
     foreach (GuiLayout gl in conf.GuiLayouts)
     {
         Control ctl = CreateLayoutRecurse(gl);
         GuiLayouts[gl.name] = ctl;
     }
 }
예제 #24
0
 void HandleSequences(GuiConfigDB conf)
 {
     foreach (CommandSequence cmdseq in conf.CmdSequenceList)
     {
         if (cmdseq.m_seqtype  == CommandSequence.COMMAND_TYPE_GCODE)
         {
             GCodeSequence gcseq = new GCodeSequence(cmdseq.m_name, cmdseq.m_seq);
             SequenceManager.Instance().Add(gcseq);
         }
         if (cmdseq.m_seqtype == CommandSequence.COMMAND_TYPE_SPAWN_PROCESS)
         {
             ProcessSequence cast = (ProcessSequence)cmdseq;
             SequenceManager.Instance().Add(cast.Clone()); // insert a cloned copy into the sequencemanager
         }
     }
 }
예제 #25
0
        public void ApplyConfiguration(GuiConfigDB conf)
        {
            guiConf = conf;
            if (firstTime)
            {
                UVDLPApp.Instance().m_callbackhandler.RegisterCallback("GMActivateTab", ActivateTab, "GUI Tab Activation <ctlTabItem> <ctlTabContent>");
                firstTime = false;
            }
            try
            {
                // read and store all styles
                foreach (KeyValuePair<string, GuiControlStyle> pair in conf.GuiControlStylesDict)
                    GuiControlStylesDict[pair.Key] = pair.Value;

                HandleDecals(conf);
                HandleButtonCreation(conf);
                HandleLayouts(conf);
                HandleControls(conf);
                HandleButtons(conf);
                HandleSequences(conf);

            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogError(ex);
            }
        }
예제 #26
0
 void HandleButtonCreation(GuiConfigDB conf)
 {
     foreach (KeyValuePair<string, GuiButton> pair in conf.GuiButtonsDict)
     {
         GuiButton gbtn = pair.Value;
         if (!Buttons.ContainsKey(gbtn.name))
         {
             // create a new empty button
             ctlImageButton btn = new ctlImageButton();
             btn.Name = gbtn.name;
             AddButton(btn);
             btn.BringToFront();
         }
     }
 }
예제 #27
0
        /// <summary>
        /// This function iterates through all the plugins
        /// and loads the configuration GUIConfig from each
        /// there is no reason why this needs to be in the ctl3DView
        /// this should go in the main UVDLPApp class
        /// </summary>
        public void LoadPluginGui()
        {
            IPlugin plugin = null;

            foreach (PluginEntry ip in UVDLPApp.Instance().m_plugins)
            {
                try
                {
                    if (ip.m_licensed != true || ip.m_enabled == false)
                    {
                        continue;
                    }

                    plugin = ip.m_plugin;
                    if (plugin == null)
                    {
                        continue;
                    }

                    if (!plugin.SupportFunctionality(PluginFuctionality.CustomGUI))
                    {
                        continue;
                    }

                    string guiconfname = null;
                    foreach (PluginItem pi in plugin.GetPluginItems)
                    {
                        try
                        {
                            switch (pi.m_type)
                            {
                            case ePlItemType.eTexture:
                                gr2d.LoadTexture(plugin.GetString(pi.m_name + "_index"), plugin);
                                break;

                            case ePlItemType.eGuiConfig:
                                guiconfname = plugin.GetString(pi.m_name);
                                break;

                            case ePlItemType.eControl:
                                UserControl ctl = plugin.GetControl(pi.m_name);
                                if ((ctl.GetType() == typeof(ctlImageButton)) || ctl.GetType().IsSubclassOf(typeof(ctlImageButton)))
                                {
                                    guiconf.AddButton(pi.m_name, (ctlImageButton)ctl);
                                }
                                else      //(ctl.GetType().IsSubclassOf(typeof(ctlUserPanel)))
                                {
                                    guiconf.AddControl(pi.m_name, ctl);
                                }
                                break;
                            }
                        }
                        catch (Exception ex)
                        {
                            DebugLogger.Instance().LogError(ex);
                        }
                    }
                    //after all the resource have been loaded from the GUI
                    // the 'script' xml layout portion of the GUI is loaded to do something with those resources
                    if ((guiconf != null) && (guiconfname != null))
                    {
                        //gc.ClearLayout();
                        // test new gui config system
                        GuiConfigDB gconfdb = new GuiConfigDB();
                        gconfdb.LoadConfiguration(guiconfname, plugin);
                        guiconf.ApplyConfiguration(gconfdb);
                        gconfdb.SaveConfiguration("GuiConfigPlugin");
                        RearrangeGui();
                    }
                }
                catch (Exception ex)
                {
                    DebugLogger.Instance().LogError(ex);
                }
            }
        }
예제 #28
0
        public frmMain2()
        {
            SceneFileExt = "cws";// default to creation workshop CWS files
            m_lsttabs = new List<tabview>();
            m_logSB = new StringBuilder();
            InitializeComponent();

            UVDLPApp.Instance().m_mainform = this;
            m_manctl = ManualControl.Instance(); // late intialization happens here after the UVDLP app Singleton is initiated.

            RegisterCallbacks();
            RegisterGUI();
            SetButtonStatuses();
            UVDLPApp.Instance().AppEvent += new AppEventDelegate(AppEventDel);
            DebugLogger.Instance().LoggerStatusEvent += new LoggerStatusHandler(LoggerStatusEvent);
            UVDLPApp.Instance().m_slicer.Slice_Event += new Slicer.SliceEvent(SliceEv);
            UVDLPApp.Instance().m_buildmgr.BuildStatus += new delBuildStatus(BuildStatus);
            UVDLPApp.Instance().m_deviceinterface.StatusEvent += new DeviceInterface.DeviceInterfaceStatus(DeviceStatusEvent);
            UVDLPApp.Instance().m_buildmgr.PrintLayer += new delPrinterLayer(PrintLayer);
            UVDLPApp.Instance().Engine3D.UpdateGrid();
            ctl3DView1.UpdateView(); // initial update
            // set up initial log data in form
            foreach (string lg in DebugLogger.Instance().GetLog())
            {
                //txtLog.Text = lg + "\r\n" + txtLog.Text;
                AddtoLog(lg);
            }
            //RearrangeGui
            AddButtons();
            AddControls();
            SetupTabs();
            //set the default tab
            m_viewtype = -1;// start with the first tab added
            ShowView(0);// 3d tab

            ctl3DView1.RearrangeGui();
            ctl3DView1.Enable3dView(true);
            // test new gui config system
            GuiConfigDB gconfdb = new GuiConfigDB();
            //try to load the GUI
            gconfdb.LoadConfiguration(global::UV_DLP_3D_Printer.Properties.Resources.GuiConfig);
            UVDLPApp.Instance().m_gui_config.ApplyConfiguration(gconfdb);

            //ctlSliceGCodePanel1.ctlSliceViewctl.DlpForm = m_frmdlp; // set the dlp form for direct control
            SetMainMessage("");
            SetTimeMessage("");
            #if (DEBUG)
                ShowLogPanel(true);
            #else
                ShowLogPanel(false);
                pluginTesterToolStripMenuItem.Visible = false;
                testToolStripMenuItem.Visible = false;
                testMachineControlToolStripMenuItem.Visible = false;
                loadGUIConfigToolStripMenuItem.Visible = false;
                checkForUpdatesToolStripMenuItem.Visible = false;
                //miiManualControlToolStripMenuItem.Visible = false;
                //miiManualControlToolStripMenuItem.Visible = false;
            #endif
                SetTitle();
            UVDLPApp.Instance().PerformPluginCommand("MainFormLoadedCommand", true);
            AddGlobalMouseHandler();
        }
예제 #29
0
        /// <summary>
        /// This function iterates through all the plugins
        /// and loads the configuration GUIConfig from each
        /// there is no reason why this needs to be in the ctl3DView
        /// this should go in the main UVDLPApp class
        /// </summary>
        public void LoadPluginGui()
        {
            IPlugin plugin = null;
            foreach (PluginEntry ip in UVDLPApp.Instance().m_plugins)
            {
                try
                {
                    if (ip.m_licensed != true || ip.m_enabled == false)
                        continue;

                    plugin = ip.m_plugin;
                    if (plugin == null)
                        continue;

                    if (!plugin.SupportFunctionality(PluginFuctionality.CustomGUI))
                        continue;

                    string guiconfname = null;
                    foreach (PluginItem pi in plugin.GetPluginItems)
                    {
                        try
                        {
                            switch (pi.m_type)
                            {
                                case ePlItemType.eTexture:
                                    gr2d.LoadTexture(plugin.GetString(pi.m_name + "_index"), plugin);
                                    break;

                                case ePlItemType.eGuiConfig:
                                    guiconfname = plugin.GetString(pi.m_name);
                                    break;

                                case ePlItemType.eControl:
                                    UserControl ctl = plugin.GetControl(pi.m_name);
                                    if ((ctl.GetType() == typeof(ctlImageButton)) || ctl.GetType().IsSubclassOf(typeof(ctlImageButton)))
                                    {
                                        guiconf.AddButton(pi.m_name, (ctlImageButton)ctl);
                                    }
                                    else  //(ctl.GetType().IsSubclassOf(typeof(ctlUserPanel)))
                                    {
                                        guiconf.AddControl(pi.m_name, ctl);
                                    }
                                    break;

                            }
                        }
                        catch (Exception ex)
                        {
                            DebugLogger.Instance().LogError(ex);
                        }
                    }
                    //after all the resource have been loaded from the GUI
                    // the 'script' xml layout portion of the GUI is loaded to do something with those resources
                    if ((guiconf != null) && (guiconfname != null))
                    {
                        //gc.ClearLayout();
                        // test new gui config system
                        GuiConfigDB gconfdb = new GuiConfigDB();
                        gconfdb.LoadConfiguration(guiconfname, plugin);
                        guiconf.ApplyConfiguration(gconfdb);
                        gconfdb.SaveConfiguration("GuiConfigPlugin");
                        RearrangeGui();
                    }
                }
                catch (Exception ex)
                {
                    DebugLogger.Instance().LogError(ex);
                }
            }
        }
예제 #30
0
파일: frmMain2.cs 프로젝트: tojoevan/BGC-CW
 private void loadGUIConfigToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         // load a new GUIConfig file from disk
         // this is a debug only function for now.
         openFileDialog1.Filter = "Gui Config Files (*.xml;*.txt)|*.xml;*.txt|All files (*.*)|*.*";
         if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             // test new gui config system
             GuiConfigDB gconfdb = new GuiConfigDB();
             gconfdb.LoadConfigFromFile(openFileDialog1.FileName);
             //gconfdb.PreviewMode = true;
             UVDLPApp.Instance().m_gui_config.ApplyConfiguration(gconfdb);
             Control winLayout = UVDLPApp.Instance().m_gui_config.GetLayout("MainLayout");
             if (winLayout != null)
             {
                 Form frm = new Form();
                 frm.Size = new Size(winLayout.Width, winLayout.Height);
                 frm.Controls.Add(winLayout);
                 frm.ShowDialog();
             }
             gconfdb.SaveConfiguration("GuiConfigMenuTest");
             UVDLPApp.Instance().m_gui_config.DumpDatabase("GuiManagerDatabase.txt");
             //UVDLPApp.Instance().m_gui_config.LayoutGui(
         }
     }catch(Exception ex)
     {
         DebugLogger.Instance().LogError(ex);
     }
 }
예제 #31
0
        void HandleButton(GuiConfigDB conf, GuiButton gbtn)
        {
            if (!Buttons.ContainsKey(gbtn.name))
            {
                return; // should not happen!
            }
            ctlImageButton butt = Buttons[gbtn.name];

//            butt.Visible = true;
            butt.Visible         = gbtn.visible.GetIfExplicit(true);
            butt.GuiAnchor       = gbtn.dock.GetIfExplicit(butt.GuiAnchor);
            butt.Gapx            = gbtn.x.GetIfExplicit(butt.Gapx);
            butt.Gapy            = gbtn.y.GetIfExplicit(butt.Gapy);
            butt.Width           = gbtn.w.GetIfExplicit(butt.Width);
            butt.Height          = gbtn.h.GetIfExplicit(butt.Height);
            butt.StyleName       = gbtn.style.GetIfExplicit(butt.StyleName);
            butt.OnClickCallback = gbtn.onClickCmd.GetIfExplicit(butt.OnClickCallback);
            GuiControlStyle bstl = conf.GetControlStyle(butt.StyleName);

            if (bstl != null)
            {
                butt.GLVisible = bstl.glMode;
            }
            if (gbtn.image.IsExplicit())
            {
                butt.GLImage = gbtn.image;
                butt.Image   = conf.GetImage(gbtn.image, null);
            }
            butt.CheckImage = conf.GetImage(gbtn.checkImage, butt.CheckImage);


            // add the ability to add buttons in various named parents
            // this will allow adding buttons to toolbar from plugins
            if (gbtn.action.IsExplicit())
            {
                string action = gbtn.action;
                if (action.Contains("remove")) // this handles removing a control from it's parent
                {
                    // remove this control from it's parent
                    if (butt.Parent != null)
                    {
                        butt.Parent.Controls.Remove(butt);
                        butt.Parent = null;
                    }
                }
                else if (action.Contains("addto")) // this handles adding a new control to a parent control
                {
                    // Get the name of the parent
                    string parentname = gbtn.parent;
                    if (gbtn.parent.IsExplicit() && (parentname != null) && (parentname.Length != 0))
                    {
                        //find the parent
                        if (Controls.ContainsKey(parentname))
                        {
                            Control ctlParent = Controls[parentname];
                            AddControlToParent(butt, ctlParent);
                        }
                        else
                        {
                            DebugLogger.Instance().LogWarning("Button parent not found: " + parentname);
                        }
                    }
                }
            }
        }
예제 #32
0
 private void loadGUIConfigToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         // load a new GUIConfig file from disk
         // this is a debug only function for now.
         if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             StreamReader streamReader = new StreamReader(openFileDialog1.FileName);
             string text = streamReader.ReadToEnd();
             streamReader.Close();
     #if (DEBUG) // DBG_GUICONF
                 // test new gui config system
             GuiConfigDB gconfdb = new GuiConfigDB();
             gconfdb.LoadConfiguration(text);
             UVDLPApp.Instance().m_gui_config.ApplyConfiguration(gconfdb);
             gconfdb.SaveConfiguration("GuiConfigMenuTest");
     #else
             UVDLPApp.Instance().m_gui_config.LoadConfiguration(text);
     #endif
             //UVDLPApp.Instance().m_gui_config.LayoutGui(
         }
     }catch(Exception ex)
     {
         DebugLogger.Instance().LogError(ex);
     }
 }
예제 #33
0
        void HandleControl(GuiConfigDB conf, GuiControl gctl)
        {
            if (!Controls.ContainsKey(gctl.name))
            {
                return;
            }

            Control ct = Controls[gctl.name]; // find the existing control

            if (gctl.visible.IsExplicit())
            {
                ct.Visible = gctl.visible.GetVal();
            }
            ct.Width  = gctl.w.GetIfExplicit(ct.Width);
            ct.Height = gctl.h.GetIfExplicit(ct.Height);
            //load some control locations as well,

            if (gctl.px.IsExplicit() || gctl.py.IsExplicit())
            {
                int px, py;
                px = gctl.px.GetIfExplicit(ct.Location.X);
                py = gctl.py.GetIfExplicit(ct.Location.Y);
                Point pt = new Point(px, py);
                ct.Location = pt;
            }

            // load docking style
            if (gctl.action.IsExplicit())
            {
                string action = gctl.action;   // telling something to happen to this control
                if (action.Contains("remove")) // this handles removing a control from it's parent
                {
                    // remove this control from it's parent
                    if (ct.Parent != null)
                    {
                        ct.Parent.Controls.Remove(ct);
                        ct.Parent = null;
                    }
                }
                else if (action.Contains("hide")) // this handles hiding
                {
                    // hide this control, do not remove it from the parent
                    ct.Hide();
                }
                else if (action.Contains("show")) // this handles showing
                {
                    // show this control
                    ct.Show();
                }
                else if (action.Contains("addto")) // this handles adding a new/existing control to a parent control
                {
                    // Get the name of the parent
                    // Get the name of the parent
                    string parentname = gctl.parent;
                    if (gctl.parent.IsExplicit() && (parentname != null) && (parentname.Length != 0))
                    {
                        //find the parent
                        //find the parent
                        if (Controls.ContainsKey(parentname))
                        {
                            Control ctlParent = Controls[parentname];
                            AddControlToParent(ct, ctlParent);
                        }
                        else
                        {
                            DebugLogger.Instance().LogWarning("Control parent not found: " + parentname);
                        }
                    }
                }
            }

            String          styleName = gctl.style.GetIfValid(null);
            GuiControlStyle style     = conf.GetControlStyle(styleName);

            if (ct is ctlUserPanel)
            {
                ctlUserPanel ctl = (ctlUserPanel)ct;
                ctl.GuiAnchor = gctl.dock.GetIfExplicit(ctl.GuiAnchor);
                ctl.Gapx      = gctl.x.GetIfExplicit(ctl.Gapx);
                ctl.Gapy      = gctl.y.GetIfExplicit(ctl.Gapy);
                if (styleName != null)
                {
                    ctl.StyleName = styleName;
                    if (style != null)
                    {
                        ctl.GLVisible = style.glMode;
                        ctl.ApplyStyle(style);
                    }
                }
                //ctl.GLVisible = GetBoolParam(ctlnode, "gl", false);
                if (ctl.GLVisible)
                {
                    ctl.GLBackgroundImage = gctl.BorderShape.GetIfExplicit(ctl.GLBackgroundImage);
                }
                else
                {
                    ctl.bgndPanel.imageName = gctl.BorderShape.GetIfExplicit(ctl.bgndPanel.imageName);
                }
            }
            else
            {
                if (style != null)
                {
                    ApplyStyleRecurse(ct, style);
                }
            }
        }