public MainWindow(Manager manager) { mManager = manager; InitializeComponent(); mDocumentViews = new List<DocumentView>(); mToolWindows = new List<ToolWindow>(); mManager.MainWindow = this; mManager.PropertyChange += new PropertyChangeEventHandler(Manager_PropertyChange); mManager.ProjectOpened += new ProjectOpenedEventHandler(Manager_ProjectOpened); mManager.ProjectClosed += new ProjectClosedEventHandler(Manager_ProjectClosed); mDockContentHistory = new List<IDockContent>(); mPluginsWindow = new PluginsWindow(this); mOptionsWindow = new OptionsWindow(this); mFindFileInProjectWindow = new FindFileInProjectWindow(this); mDocumentSwitchWindow = new DocumentSwitchWindow(this); // Get recent projects list mRecentProjects = new List<string>(); string data; data = (string)mManager.RegistryRoot.GetValue("RecentProjects"); if (data != null) { foreach (string proj in data.Split(new char[] { ';' })) { if(String.Compare(System.IO.Path.GetExtension(proj), ".xml", true) == 0 || String.Compare(System.IO.Path.GetExtension(proj), ".vcproj", true) == 0) mRecentProjects.Add(proj); } } UpdateRecentProjects(); // Set up open document dialog StringBuilder filter = new StringBuilder(); foreach(Type docType in mManager.GetPluginImplementations(typeof(Document))) { DocumentClassAttribute attr = DocumentClassAttribute.ForType(docType); if (attr != null) { string extensions = String.Join(";", Array.ConvertAll<string, string>(attr.FileExtensions, delegate(string ext) { return "*" + ext; })); filter.Append(attr.Name + "(" + extensions + ")|" + extensions + "|"); } } filter.Append("All files (*.*)|*.*"); openDocumentDialog.Filter = filter.ToString(); // Set up new project menu foreach(Type projType in mManager.GetPluginImplementations(typeof(Project))) { ProjectClassAttribute attr = ProjectClassAttribute.ForType(projType); ConstructorInfo constructor = projType.GetConstructor(new Type [] { typeof(IManager) } ); if (constructor != null) { ToolStripMenuItem item = new ToolStripMenuItem(attr.Name, null, new EventHandler(NewProject_Click)); item.Tag = projType; tsiFileNewProject.DropDownItems.Add(item); } } tsiFileNewProject.Enabled = tsiFileNewProject.DropDownItems.Count != 0; sourceControlToolStripMenuItem.Enabled = false; }
public MainWindow(Manager manager) { mManager = manager; InitializeComponent(); mDocumentViews = new List <DocumentView>(); mToolWindows = new List <ToolWindow>(); mManager.MainWindow = this; mManager.PropertyChange += new PropertyChangeEventHandler(Manager_PropertyChange); mManager.ProjectOpened += new ProjectOpenedEventHandler(Manager_ProjectOpened); mManager.ProjectClosed += new ProjectClosedEventHandler(Manager_ProjectClosed); mDockContentHistory = new List <IDockContent>(); mPluginsWindow = new PluginsWindow(this); mOptionsWindow = new OptionsWindow(this); mFindFileInProjectWindow = new FindFileInProjectWindow(this); mDocumentSwitchWindow = new DocumentSwitchWindow(this); // Get recent projects list mRecentProjects = new List <string>(); string data; data = (string)mManager.RegistryRoot.GetValue("RecentProjects"); if (data != null) { foreach (string proj in data.Split(new char[] { ';' })) { if (String.Compare(System.IO.Path.GetExtension(proj), ".xml", true) == 0 || String.Compare(System.IO.Path.GetExtension(proj), ".vcproj", true) == 0) { mRecentProjects.Add(proj); } } } UpdateRecentProjects(); // Set up open document dialog StringBuilder filter = new StringBuilder(); foreach (Type docType in mManager.GetPluginImplementations(typeof(Document))) { DocumentClassAttribute attr = DocumentClassAttribute.ForType(docType); if (attr != null) { string extensions = String.Join(";", Array.ConvertAll <string, string>(attr.FileExtensions, delegate(string ext) { return("*" + ext); })); filter.Append(attr.Name + "(" + extensions + ")|" + extensions + "|"); } } filter.Append("All files (*.*)|*.*"); openDocumentDialog.Filter = filter.ToString(); // Set up new project menu foreach (Type projType in mManager.GetPluginImplementations(typeof(Project))) { ProjectClassAttribute attr = ProjectClassAttribute.ForType(projType); ConstructorInfo constructor = projType.GetConstructor(new Type [] { typeof(IManager) }); if (constructor != null) { ToolStripMenuItem item = new ToolStripMenuItem(attr.Name, null, new EventHandler(NewProject_Click)); item.Tag = projType; tsiFileNewProject.DropDownItems.Add(item); } } tsiFileNewProject.Enabled = tsiFileNewProject.DropDownItems.Count != 0; sourceControlToolStripMenuItem.Enabled = false; }