private void DestroyAll()
        {
            U.LogInfo("We are going to Save and close!");
            try
            {
                if (_smMain.IsRunning)
                {
                    _smMain.Stop();
                    _smMain.Abort();
                }

                CompRoot.AppStatus("Pre-Destroy");
                U.RootComp.PreDestroy();
                U.RootComp.SaveSettings();
                CompRoot.AppStatus("Destroying Root");
                U.RootComp.Destroy();
            }
            catch (MCoreException ex)
            {
                U.Log(ex);
            }
            catch (Exception ex)
            {
                U.LogPopup(ex, "Destroy Problem");
            }
        }
        private void btnExportRecipe_Click(object sender, EventArgs e)
        {
            if (cbDelRecipe.SelectedItem != null &&
                _allRecipe.ChildExists(cbDelRecipe.SelectedItem.ToString()))
            {
                string recipeDumpPath = AppUtility.AppFullPath + "\\Dump Recipes\\";
                U.EnsureDirectory(recipeDumpPath);
                AppProductRecipe exportRecipe   = cbDelRecipe.SelectedItem as AppProductRecipe;
                string           exportFilePath = String.Format("{0}DumpRecipe[ {1} ]_{2}.xml", recipeDumpPath, exportRecipe.Name, DateTime.Now.ToString("yyyy-MM-dd-HHmmss"));
                CompRoot.ExportSettings(exportFilePath, exportRecipe);

                AppUtility.ShowKryptonMessageBox("Export Recipe Completed", String.Format("Export Recipe \"{0}\" Completed", exportRecipe.Name), String.Format("Export Recipe {0} to {1}", exportRecipe.Name, exportFilePath),
                                                 ComponentFactory.Krypton.Toolkit.TaskDialogButtons.OK, MessageBoxIcon.Information, this);
            }
        }
Beispiel #3
0
 private void OnChangedCompName(CompBase comp, string oldID)
 {
     try
     {
         if (string.IsNullOrEmpty(oldID))
         {
             cbClassChooser.Items.Clear();
             Type[] types = CompRoot.GetSiblingTypes(comp.GetType());
             if (types != null)
             {
                 cbClassChooser.Items.AddRange(types);
                 cbClassChooser.SelectedItem = comp.GetType();
                 cbClassChooser.Show();
                 cbClassChooser.DroppedDown = true;
             }
         }
     }
     catch (Exception ex)
     {
         ex.ToString();
     }
 }
        private void RunningStatusOnChange(AppMachine.Comp.AppMachine.eRunStatus status)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new _delParamRunStatus(RunningStatusOnChange), new object[] { status });
                return;
            }

            switch (status)
            {
            case AppMachine.Comp.AppMachine.eRunStatus.Running:
                panelGreenLight.BackColor = Color.Lime;
                panelRedLight.BackColor   = Color.Maroon;
                panelAmberLight.BackColor = Color.Olive;
                CompRoot.AppStatus("Running");
                break;

            case AppMachine.Comp.AppMachine.eRunStatus.Pause:
                panelGreenLight.BackColor = Color.DarkGreen;
                panelRedLight.BackColor   = Color.Red;
                panelAmberLight.BackColor = Color.Olive;
                CompRoot.AppStatus("Pause");
                break;

            case AppMachine.Comp.AppMachine.eRunStatus.Stopping:
                panelGreenLight.BackColor = Color.Lime;
                panelRedLight.BackColor   = Color.Maroon;
                panelAmberLight.BackColor = Color.Olive;
                CompRoot.AppStatus("Stopping");
                break;

            case AppMachine.Comp.AppMachine.eRunStatus.Stopped:
                panelGreenLight.BackColor = Color.DarkGreen;
                panelRedLight.BackColor   = Color.Red;
                panelAmberLight.BackColor = Color.Olive;
                CompRoot.AppStatus("Stopped");
                break;
            }
        }
        private void btnImportRecipe_Click(object sender, EventArgs e)
        {
            string recipeDumpPath = AppUtility.AppFullPath + "\\Dump Recipes\\";

            U.EnsureDirectory(recipeDumpPath);
            OpenFileDialog od = new OpenFileDialog();

            od.DefaultExt       = ".xml";
            od.Filter           = "Product File|*.xml";
            od.InitialDirectory = recipeDumpPath;
            od.CheckFileExists  = true;
            od.Multiselect      = false;
            od.ShowDialog();
            if (String.IsNullOrEmpty(od.FileName))
            {
                return;
            }

            string           importFilePath = od.FileName;
            AppProductRecipe importRecipe   = null;

            try
            {
                importRecipe = CompRoot.ImportFile(typeof(AppProductRecipe), importFilePath) as AppProductRecipe;
            }
            catch (Exception ex)
            {
                AppUtility.ShowKryptonMessageBox("Import Recipe Error", String.Format("Import Recipe Error"), ex.ToString(), ComponentFactory.Krypton.Toolkit.TaskDialogButtons.OK, MessageBoxIcon.Error, this);
                return;
            }


            if (_allRecipe.ChildExists(importRecipe.Name))
            {
                DialogResult result = AppUtility.ShowKryptonMessageBox("Recipe Name Exist", String.Format("Recipe name \"{0}\" already exist.", importRecipe.Name),
                                                                       "Do you want to auto generate unique name?", ComponentFactory.Krypton.Toolkit.TaskDialogButtons.Yes | ComponentFactory.Krypton.Toolkit.TaskDialogButtons.No, MessageBoxIcon.Question, this);
                if (result != DialogResult.Yes)
                {
                    return;
                }

                int    count             = 1;
                string autoGenRecipeName = "";
                do
                {
                    autoGenRecipeName = importRecipe.Name + count.ToString("_00#");
                } while (_allRecipe.ChildExists(autoGenRecipeName));
                importRecipe.Name = autoGenRecipeName;
            }

            try
            {
                importRecipe.PropertyValChanged += new PropertyChangedEventHandler(AppMachine.Comp.AppMachine.This.RecipePropValue_OnChange);
                _allRecipe.Add(importRecipe);
                componentBrowser.Rebuild(_allRecipe);
                AppUtility.ShowKryptonMessageBox("Import Recipe Completed", String.Format("Import Recipe \"{0}\" Completed", importRecipe.Name), "", ComponentFactory.Krypton.Toolkit.TaskDialogButtons.OK, MessageBoxIcon.Information, this);
                tbNewRecipe.Clear();
            }
            finally
            {
            }
        }
 private void btnApply_Click(object sender, EventArgs e)
 {
     U.RootComp.SaveSettings();
     CompRoot.AppStatus("All Setting Saved");
 }
Beispiel #7
0
        private void OnNewSelection(object sender, TreeViewEventArgs e)
        {
            if (tabPages.Controls.Count > 0)
            {
                foreach (TabPage page in tabPages.Controls)
                {
                    foreach (Control control in page.Controls)
                    {
                        control.Dispose();
                    }
                    //page.Dispose();
                }
                tabPages.Controls.Clear();
            }
            CompBase comp   = null;
            Type     tyComp = null;

            try
            {
                comp   = e.Node.Tag as CompBase;
                tyComp = comp.GetType();
            }
            catch (Exception ex)
            {
                U.LogPopup(ex, "Problem with selection");
                return;
            }
            List <Control> controls = new List <Control>();

            try
            {
                do
                {
                    Type[] controlTypes = CompRoot.GetControlPages(tyComp);
                    if (controlTypes != null)
                    {
                        for (int i = 0; i < controlTypes.Length; i++)
                        {
                            Type controlType = controlTypes[i];
                            if (comp.IgnorePageList.Contains(controlType))
                            {
                                continue;
                            }
                            Control      control = Activator.CreateInstance(controlType) as Control;
                            PropertyInfo pi      = controlType.GetProperty("Bind");
                            pi.SetValue(control, comp, null);
                            controls.Insert(0, control);
                        }
                    }

                    tyComp = tyComp.BaseType;
                }while (tyComp != null && !Type.Equals(tyComp, typeof(Object)));
            }
            catch (Exception ex)
            {
                U.LogPopup(ex, "Problem with selection");
            }


            try
            {
                for (int i = 0; i < controls.Count; i++)
                {
                    Control control = controls[i];
                    TabPage tabPage = new TabPage(control.ToString());
                    tabPage.Location = new System.Drawing.Point(4, 22);
                    tabPage.Name     = string.Format("tabPage{0}", i);
                    tabPage.Padding  = new System.Windows.Forms.Padding(3);
                    tabPage.TabIndex = i;
                    tabPage.UseVisualStyleBackColor = true;
                    tabPage.Controls.Add(control);
                    tabPages.Controls.Add(tabPage);
                }
            }
            catch (Exception ex)
            {
                U.LogPopup(ex, "Problem with selection");
            }
            OnSizedChanged(null, null);
        }