Пример #1
0
		static void Main(string [] args)
		{
			Thread.CurrentThread.Name = "Main Thread";
			Application.EnableVisualStyles();
			Application.SetCompatibleTextRenderingDefault(false);

			// Check for the .NET Framework 2.0 Service Pack 1
			RegistryKey regkey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v2.0.50727");
			if (regkey == null || regkey.GetValue("Increment") == null)
			{
				MessageBox.Show(
					"Tilde requires the .NET Framework 2.0 to be installed. Please install:\r\n\r\n"
					+ "\t" + "http://www.microsoft.com/downloads/details.aspx?FamilyID=0856eacb-4362-4b0d-8edd-aab15c5e04f5&displaylang=en" + "\r\n"
					+ "\t" + "http://www.microsoft.com/downloads/details.aspx?familyid=79BC3B77-E02C-4AD3-AACF-A7633F706BA5&displaylang=en",
					".NET Framework Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
				return;
			}
			else if(Int32.Parse(regkey.GetValue("Increment").ToString()) < 1433)
			{
				MessageBox.Show(
					"Tilde requires the .NET Framework 2.0 Service Pack 1 to be installed. Please install:\r\n\r\n"
					+ "\t" + "http://www.microsoft.com/downloads/details.aspx?familyid=79BC3B77-E02C-4AD3-AACF-A7633F706BA5&displaylang=en",
					".NET Framework Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
				return;
			}

			CommandLineArguments param = new CommandLineArguments(args);
			Manager manager = new Manager(param);
			MainWindow mainWindow = new MainWindow(manager);
			mainWindow.CreateToolWindows();

			Application.Run(mainWindow);
		}
Пример #2
0
		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;
		}