public bool Initialize() { _projectManager = CoreSystem.Managers.Find(m => m.Name.Contains("ProjectManager")) as ProjectManager; _name = new StringProperty("Name", "Unnamed Project"); _operations = new List<Operation>(); _devices = new List<Device>(); if (_logConfiguration == null) { _logConfiguration = new LogConfiguration(); #if DEBUG _logConfiguration.Categories.Add(LogCategory.Debug.GetDescription()); #endif _logConfiguration.Categories.Add(LogCategory.Info.GetDescription()); _logConfiguration.Categories.Add(LogCategory.Warning.GetDescription()); _logConfiguration.Categories.Add(LogCategory.Error.GetDescription()); } if (_projectManager.CreateEmptyProject() == false) { _name = new StringProperty("Name", "Unnamed Project"); _operations = new List<Operation>(); _devices = new List<Device>(); if (_operations.Count == 0) { Operation operation = new Operation("Unnamed Operation"); _projectManager.Add(operation); } } return true; }
/// <summary> /// Initializes a new instance of the <see cref="Processor"/> class. /// </summary> public Processor() { _projectManager = CoreSystem.Managers.Find(m => m.Name.Contains("ProjectManager")) as ProjectManager; _dataStorageManager = CoreSystem.Managers.Find(m => m.Name.Contains("DataStorageManager")) as DataStorageManager; _propertyManager = CoreSystem.Managers.Find(m => m.Name.Contains("PropertyManager")) as PropertyManager; _extensionManager = CoreSystem.Managers.Find(m => m.Name.Contains("ExtensionManager")) as ExtensionManager; _nexuses = new List<AsyncNanoProcessor>(); }
private void HandleLoaded(object sender, RoutedEventArgs e) { if (DesignerProperties.GetIsInDesignMode(this) == false) { _projectManager = CoreSystem.Managers.Find(m => m.Name.Contains("ProjectManager")) as ProjectManager; _guiManager = CoreSystem.Managers.Find(m => m.Name.Contains("GuiManager")) as GuiManager; if (_projectManager == null) throw new Exception("ProjectManager is NULL!"); _projectManager.OperationAddedEvent += HandleOperationCollectionChanged; _projectManager.OperationRemovedEvent += HandleOperationCollectionChanged; _projectManager.Loaded += HandleProjectLoaded; GenerateTree(); } }
private void GenerateTree() { if (_projectManager != null) { _projectManager = CoreSystem.Managers.Find(m => m.Name.Contains("ProjectManager")) as ProjectManager; _projectManager.Loading += ProjectManagerLoading; } if (_projectManager != null) { this.ProjectTree.Items.Clear(); NodeTreeItem projectItem = new NodeTreeItem(_projectManager.Configuration.Name, "Project '{0}'"); this.ProjectTree.Items.Add(projectItem); foreach (Operation operation in _projectManager.Configuration.Operations) { OperationTreeItem operationItem = new OperationTreeItem(operation); operationItem.IsExpanded = true; this.ProjectTree.Items.Add(operationItem); } } }
/// <summary> /// Handles the loaded. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private void HandleLoaded(object sender, RoutedEventArgs e) { ToolManager manager = CoreSystem.Managers.Find(m => m.Name.Contains("ToolManager")) as ToolManager; _guiManager = CoreSystem.Managers.Find(m => m.Name.Contains("GuiManager")) as GuiManager; _projectManager = CoreSystem.Managers.Find(m => m.Name.Contains("ProjectManager")) as ProjectManager; if (manager == null) { Trace.WriteLine("Could not find ToolManager instance in CoreSystem!", LogCategory.Error); return; } if (_guiManager == null) { Trace.WriteLine("Could not find NodeSelectionManager instance in CoreSystem!", LogCategory.Error); return; } foreach (Node node in manager.Plugins) { if (node is Tool) { Tool tool = node as Tool; this.ListViewAll.Items.Add(node); bool contains = false; foreach (KeyValuePair<string, ListBox> pair in _listBoxes) { if (pair.Key == tool.Category) { pair.Value.Items.Add(tool); contains = true; break; } } if (!contains) { TabItem item = null; string tabName = "Tool" + tool.Category.Replace(' ', '_'); foreach (TabItem it in this.ToolTabs.Items) { if (it.Name == tabName) { item = it; break; } } if (item == null) { item = new TabItem(); item.Name = tabName; item.Header = tool.Category; this.ToolTabs.Items.Add(item); } ListBox box = new ListBox(); item.Content = box; _listBoxes.Add(new KeyValuePair<string, ListBox>(tool.Category, box)); box.Items.Add(tool); } } else if (node is Operation) this.ListViewAllOperations.Items.Add(node); } }
/// <summary> /// Initializes the specified is webservice. /// </summary> /// <param name="isWebservice">if set to <c>true</c> [is webservice].</param> /// <returns></returns> /// <exception cref="System.Exception"> /// Could not initialize ConfigurationManager! /// or /// Could not initialize PropertyManager! /// or /// Could not initialize PluginManager! /// or /// Could not initialize DisplayManager! /// or /// Could not initialize DataStorageManager! /// </exception> public static bool Initialize(bool isWebservice) { bool result = false; try { BaseManager.IsWebservice = isWebservice; //Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";" + BaseManager.AssemblyPath + Path.DirectorySeparatorChar + "Libs"); AppDomain.CurrentDomain.AssemblyResolve += delegate(object sender, ResolveEventArgs args) { // Find name (first argument) string assemblyName = args.Name.Substring(0, args.Name.IndexOf(',')); try { // Build the path to DLL and load it // WARNING: The path has to be absolute otherwise it will raise an ArgumentException (security) string libsPath = BaseManager.AssemblyPath + Path.DirectorySeparatorChar + "Libs" + Path.DirectorySeparatorChar + assemblyName + ".dll"; string basePath = BaseManager.AssemblyPath + Path.DirectorySeparatorChar + assemblyName + ".dll"; if (File.Exists(libsPath)) return Assembly.LoadFile(libsPath); else if (File.Exists(basePath)) return Assembly.LoadFile(basePath); else return null; } catch (Exception ex) { Trace.WriteLine(ex.Message, ex.StackTrace, LogCategory.Error); throw ex; } }; _traceListener = new TraceListener(BaseManager.LogPath, BaseManager.DaysToKeepLogFiles); _traceListener.SetLoggingCategoties(new List<string> { #if DEBUG LogCategory.Debug.GetDescription(), #endif LogCategory.Info.GetDescription(), LogCategory.Warning.GetDescription(), LogCategory.Error.GetDescription() }); System.Diagnostics.Trace.Listeners.Add(_traceListener); Trace.WriteLine("Initialize CoreSystem ...", LogCategory.Info); _managers.Clear(); // Default managers must be added to the CoreSystem. ProjectManager projectManager = new ProjectManager(); PropertyManager propertyManager = new PropertyManager(); PluginManager pluginManager = new PluginManager(); DisplayManager displayManager = new DisplayManager(); DataStorageManager dataStorageManager = new DataStorageManager(); _managers.Add(projectManager); _managers.Add(propertyManager); _managers.Add(pluginManager); _managers.Add(displayManager); _managers.Add(dataStorageManager); AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); if (pluginManager.Initialize() == false) throw new Exception("Could not initialize PluginManager!"); if (propertyManager.Initialize() == false) throw new Exception("Could not initialize PropertyManager!"); if (projectManager.Initialize() == false) throw new Exception("Could not initialize ConfigurationManager!"); _traceListener.SetLoggingCategoties(projectManager.Configuration.LogConfiguration.Categories); if (displayManager.Initialize() == false) throw new Exception("Could not initialize DisplayManager!"); if (dataStorageManager.Initialize() == false) throw new Exception("Could not initialize DataStorageManager!"); ExtensionManager extensionManager = CoreSystem.Managers.Find(m => m.Name.Contains("ExtensionManager")) as ExtensionManager; if (extensionManager.Initialize() == false) throw new Exception("Could not initialize ExtensionManager!"); _processor = new Core.Processor(); _shell = new Core.Shell(); _shell.Initialize(); result = true; } catch (Exception ex) { Trace.WriteLine(ex.Message, ex.StackTrace, LogCategory.Error); throw ex; } return result; }
private void LoadedHandle(object sender, RoutedEventArgs e) { if (DesignerProperties.GetIsInDesignMode(this)) return; _displayManager = CoreSystem.Managers.Find(m => m.Name.Contains("DisplayManager")) as DisplayManager; _guiManager = CoreSystem.Managers.Find(m => m.Name.Contains("GuiManager")) as GuiManager; _projectManager = CoreSystem.Managers.Find(m => m.Name.Contains("ProjectManager")) as ProjectManager; _projectManager.Loading += ProjectManagerLoading; foreach (Operation operation in _displayManager.Nodes.Where(o => o is Operation)) { AddTabParent(operation); } foreach(ImageProperty imageProperty in _displayManager.Nodes.Where(i => i is ImageProperty)) { AddTabItem(imageProperty); } if (this.DisplayTabControl.Items.Count > 0) this.DisplayTabControl.SelectedIndex = 0; _displayManager.NodeAddedEvent += NodeAddedEvent; _displayManager.ImageChangedEvent += ImageChangedEvent; _displayManager.NodeRemovedEvent += DisplayManagerNodeRemovedEvent; _displayManager.ClearEvent += ClearEvent; _guiManager.SelectedItemChanged += GuiManagerSelectedItemChanged; }
/// <summary> /// Initialize the instance of the manager. /// </summary> /// <returns></returns> public override bool Initialize() { _projectManager = CoreSystem.Managers.Find(m => m.Name.Contains("ProjectManager")) as ProjectManager; _projectManager.OperationRemovedEvent += ProjectManagerOperationRemoved; return true; }