public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType) { if (destinationType == typeof(System.String) && value is PCExeSysMetaData) { PCExeSysMetaData so = (PCExeSysMetaData)value; return("MetaData"); } return(base.ConvertTo(context, culture, value, destinationType)); }
/// <summary> /// The PCExeSys Constructor /// - Intended use: to be called by PCExeSysForm during its construction/instantiation /// - Establishes link between execution system and main PC form /// - Calls maininit function of the execution system /// </summary> /// <param name="MDSFormIn"></param> public PCExeSys(MechatronicDesignSuiteForm MDSFormIn) { if (MDSFormIn != null) { LinkedMDSForm = MDSFormIn; } pcExecutionSystemMetaData = PCExeSysMetaData.generateMetaData(); InitializeExecutionSystem(); ToolStripDropDownButton ExeSysMenuItems = null; foreach (Control ctr in LinkedMDSForm.Controls) { if (ctr.GetType() == typeof(MenuStrip)) { LinkedMDSForm.MainMenuStrip = (MenuStrip)ctr; ExeSysMenuItems = new ToolStripDropDownButton("PCExeSys"); LinkedMDSForm.MainMenuStrip.Items.Add(ExeSysMenuItems); ExeSysMenuItems.DropDownItems.Add("Project Explorer", null, viewProjectExplorerToolStripMenuItem_Click); ExeSysMenuItems.DropDownItems.Add("Exception Log", null, viewExceptionLogToolStripMenuItem_Click); ExeSysMenuItems.DropDownItems.Add("Open New Plot Pane", null, viewPlotPaneMenuItem_Click); LinkedMDSForm.MainMenuStrip.Parent = LinkedMDSForm; LinkedMDSForm.MainMenuStrip.Visible = true; LinkedMDSForm.MainMenuStrip.Show(); } else if (ctr.GetType() == typeof(ToolStrip)) { ExeSysMenuItems = new ToolStripDropDownButton("PCExeSys"); ((ToolStrip)ctr).Items.Add(ExeSysMenuItems); ExeSysMenuItems.DropDownItems.Add("Project Explorer", null, viewProjectExplorerToolStripMenuItem_Click); ExeSysMenuItems.DropDownItems.Add("Exception Log", null, viewExceptionLogToolStripMenuItem_Click); ExeSysMenuItems.DropDownItems.Add("Open New Plot Pane", null, viewPlotPaneMenuItem_Click); ((ToolStrip)ctr).Parent = LinkedMDSForm; ((ToolStrip)ctr).Visible = true; ((ToolStrip)ctr).Show(); } } if (ExeSysMenuItems == null) { LinkedMDSForm.MainMenuStrip = new MenuStrip(); LinkedMDSForm.MainMenuStrip.Dock = DockStyle.Top; ExeSysMenuItems = new ToolStripDropDownButton("PCExeSys"); LinkedMDSForm.MainMenuStrip.Items.Add(ExeSysMenuItems); ExeSysMenuItems.DropDownItems.Add("Project Explorer", null, viewProjectExplorerToolStripMenuItem_Click); ExeSysMenuItems.DropDownItems.Add("Exception Log", null, viewExceptionLogToolStripMenuItem_Click); ExeSysMenuItems.DropDownItems.Add("Open New Plot Pane", null, viewPlotPaneMenuItem_Click); LinkedMDSForm.MainMenuStrip.Parent = LinkedMDSForm; LinkedMDSForm.MainMenuStrip.Visible = true; LinkedMDSForm.MainMenuStrip.Show(); } }
//public static string MetaDataPathString = "";// public static void saveMetaData(PCExeSysMetaData toBeSaved) { if (toBeSaved != null) { FileStream MDFileStream = File.Open(MetaDataPathString, FileMode.Truncate); BinaryFormatter MDFileFormatter = new BinaryFormatter(); MDFileFormatter.Serialize(MDFileStream, toBeSaved); MDFileStream.Close(); //FileStream MDFileStream = File.OpenWrite(MetaDataPathString); //BinaryFormatter MDFileFormatter = new BinaryFormatter(); //MDFileFormatter.Serialize(MDFileStream, toBeSaved); //MDFileStream.Close(); } }
public static PCExeSysMetaData generateMetaData() { string executableDirectoryString = Path.GetFullPath(Directory.GetCurrentDirectory()); if (Directory.Exists(executableDirectoryString)) { MetaDataPathString = Path.Combine(executableDirectoryString, "MDSMetaData.md"); if (File.Exists(MetaDataPathString)) { FileStream MDFileStream = File.OpenRead(MetaDataPathString); BinaryFormatter MDFileFormatter = new BinaryFormatter(); PCExeSysMetaData TempDeserializationContainer = (PCExeSysMetaData)MDFileFormatter.Deserialize(MDFileStream); MDFileStream.Close(); return(TempDeserializationContainer); } else { return(new PCExeSysMetaData()); } } return(null); }