[Monodevelop-patches-list] r573 - in trunk/MonoDevelop/src/Main/StartUp: . Dialogs

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Mon Jan 19 15:16:01 EST 2004


Author: tberman
Date: 2004-01-19 15:16:01 -0500 (Mon, 19 Jan 2004)
New Revision: 573

Modified:
   trunk/MonoDevelop/src/Main/StartUp/Dialogs/ExceptionBox.cs
   trunk/MonoDevelop/src/Main/StartUp/Makefile
   trunk/MonoDevelop/src/Main/StartUp/SharpDevelopMain.cs
Log:
Patch from Inigo Illan <kodeport at terra.es>


Modified: trunk/MonoDevelop/src/Main/StartUp/Dialogs/ExceptionBox.cs
===================================================================
--- trunk/MonoDevelop/src/Main/StartUp/Dialogs/ExceptionBox.cs	2004-01-19 18:26:00 UTC (rev 572)
+++ trunk/MonoDevelop/src/Main/StartUp/Dialogs/ExceptionBox.cs	2004-01-19 20:16:01 UTC (rev 573)
@@ -1,191 +1,218 @@
-// project created on 2/6/2003 at 11:10 AM
-using System;
-using System.Diagnostics;
-using System.Resources;
-using System.Reflection;
-using System.Drawing;
-
-namespace ICSharpCode.SharpDevelop 
-{
-	public class ExceptionBox //: System.Windows.Forms.Form
-	{
-		/*private System.Windows.Forms.TextBox exceptionTextBox;
-		private System.Windows.Forms.CheckBox copyErrorCheckBox;
-		private System.Windows.Forms.CheckBox includeSysInfoCheckBox;
-		private System.Windows.Forms.Label label3;
-		private System.Windows.Forms.Label label2;
-		private System.Windows.Forms.Label label;
-		private System.Windows.Forms.Button continueButton;
-		private System.Windows.Forms.Button reportButton;
-		private System.Windows.Forms.PictureBox pictureBox;
-		Exception exceptionThrown;
-		
-		public ExceptionBox(Exception e)
-		{
-			this.exceptionThrown = e;
-			InitializeComponent();
-			exceptionTextBox.Text = e.ToString();
-			
-			ResourceManager resources = new ResourceManager("BitmapResources", Assembly.GetEntryAssembly());
-			this.pictureBox.Image = (Bitmap)resources.GetObject("ErrorReport");
-		}
-		
-		string getClipboardString()
-		{
-			string str = "";
-			if (includeSysInfoCheckBox.Checked) {
-				str  = ".NET Version         : " + Environment.Version.ToString() + Environment.NewLine;
-				str += "OS Version           : " + Environment.OSVersion.ToString() + Environment.NewLine;
-				str += "Boot Mode            : " + SystemInformation.BootMode + Environment.NewLine;
-				str += "Working Set Memory   : " + (Environment.WorkingSet / 1024) + "kb" + Environment.NewLine + Environment.NewLine;
-				Version v = Assembly.GetEntryAssembly().GetName().Version;
-				str += "SharpDevelop Version : " + v.Major + "." + v.Minor + "." + v.Revision + "." + v.Build + Environment.NewLine;
-			}
-			
-			str += "Exception thrown: " + Environment.NewLine;
-			str += exceptionThrown.ToString();
-			return str;
-		}
-		
-		void CopyInfoToClipboard()
-		{
-			if (copyErrorCheckBox.Checked) {
-				Clipboard.SetDataObject(new DataObject(System.Windows.Forms.DataFormats.Text, getClipboardString()), true);
-			}
-		}
-		
-		// This method is used in the forms designer.
-		// Change this method on you own risk
-		void buttonClick(object sender, System.EventArgs e)
-		{
-			CopyInfoToClipboard();
-			// open IE via process.start to our bug reporting forum
-			Process.Start("http://www.icsharpcode.net/OpenSource/SD/Forum/forum.asp?FORUM_ID=5");
-		}
-		
-		void continueButtonClick(object sender, System.EventArgs e)
-		{
-//			CopyInfoToClipboard();
-			DialogResult = System.Windows.Forms.DialogResult.Ignore;
-		}
-		
-		void InitializeComponent() {
-			this.pictureBox = new System.Windows.Forms.PictureBox();
-			this.reportButton = new System.Windows.Forms.Button();
-			this.continueButton = new System.Windows.Forms.Button();
-			this.label = new System.Windows.Forms.Label();
-			this.label2 = new System.Windows.Forms.Label();
-			this.label3 = new System.Windows.Forms.Label();
-			this.includeSysInfoCheckBox = new System.Windows.Forms.CheckBox();
-			this.copyErrorCheckBox = new System.Windows.Forms.CheckBox();
-			this.exceptionTextBox = new System.Windows.Forms.TextBox();
-			this.SuspendLayout();
-			// 
-			// pictureBox
-			// 
-			this.pictureBox.Location = new System.Drawing.Point(0, 0);
-			this.pictureBox.Name = "pictureBox";
-			this.pictureBox.Size = new System.Drawing.Size(224, 464);
-			this.pictureBox.TabIndex = 0;
-			this.pictureBox.TabStop = false;
-			// 
-			// reportButton
-			// 
-			this.reportButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
-			this.reportButton.Location = new System.Drawing.Point(232, 424);
-			this.reportButton.Name = "reportButton";
-			this.reportButton.Size = new System.Drawing.Size(216, 23);
-			this.reportButton.TabIndex = 4;
-			this.reportButton.Text = "Report Error to SharpDevelop Team";
-			this.reportButton.Click += new System.EventHandler(this.buttonClick);
-			// 
-			// continueButton
-			// 
-			this.continueButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
-			this.continueButton.Location = new System.Drawing.Point(600, 424);
-			this.continueButton.Name = "continueButton";
-			this.continueButton.TabIndex = 5;
-			this.continueButton.Text = "Continue";
-			this.continueButton.Click += new System.EventHandler(this.continueButtonClick);
-			// 
-			// label
-			// 
-			this.label.Location = new System.Drawing.Point(232, 8);
-			this.label.Name = "label";
-			this.label.Size = new System.Drawing.Size(448, 48);
-			this.label.TabIndex = 6;
-			this.label.Text = "An unhandled exception has occurred in SharpDevelop. This is unexpected and we\'d " +
-"ask you to help us improve SharpDevelop by reporting this error to the SharpDeve" +
-"lop team. ";
-			// 
-			// label2
-			// 
-			this.label2.Location = new System.Drawing.Point(232, 64);
-			this.label2.Name = "label2";
-			this.label2.Size = new System.Drawing.Size(448, 80);
-			this.label2.TabIndex = 8;
-			this.label2.Text = @"How to report errors efficiently: We have set up a Web-based forum to report and track errors that are reported by users of SharpDevelop. To minimize necessary questions by the team members, in addition to providing the error message that is copied to the clipboard for easier pasting in the error report, we ask that you provide us with an as detailed as possible step-by-step procedure to reproduce this bug. ";
-			// 
-			// label3
-			// 
-			this.label3.Location = new System.Drawing.Point(232, 152);
-			this.label3.Name = "label3";
-			this.label3.Size = new System.Drawing.Size(448, 23);
-			this.label3.TabIndex = 9;
-			this.label3.Text = "Thank you for helping make SharpDevelop a better program for everyone!";
-			// 
-			// includeSysInfoCheckBox
-			// 
-			this.includeSysInfoCheckBox.Checked = true;
-			this.includeSysInfoCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
-			this.includeSysInfoCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
-			this.includeSysInfoCheckBox.Location = new System.Drawing.Point(232, 392);
-			this.includeSysInfoCheckBox.Name = "includeSysInfoCheckBox";
-			this.includeSysInfoCheckBox.Size = new System.Drawing.Size(440, 24);
-			this.includeSysInfoCheckBox.TabIndex = 3;
-			this.includeSysInfoCheckBox.Text = "Include system information (version of Windows, .NET framework)";
-			// 
-			// copyErrorCheckBox
-			// 
-			this.copyErrorCheckBox.Checked = true;
-			this.copyErrorCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
-			this.copyErrorCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
-			this.copyErrorCheckBox.Location = new System.Drawing.Point(232, 368);
-			this.copyErrorCheckBox.Name = "copyErrorCheckBox";
-			this.copyErrorCheckBox.Size = new System.Drawing.Size(440, 24);
-			this.copyErrorCheckBox.TabIndex = 2;
-			this.copyErrorCheckBox.Text = "Copy error message to clipboard";
-			// 
-			// exceptionTextBox
-			// 
-			this.exceptionTextBox.Location = new System.Drawing.Point(232, 176);
-			this.exceptionTextBox.Multiline = true;
-			this.exceptionTextBox.Name = "exceptionTextBox";
-			this.exceptionTextBox.ReadOnly = true;
-			this.exceptionTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
-			this.exceptionTextBox.Size = new System.Drawing.Size(448, 184);
-			this.exceptionTextBox.TabIndex = 1;
-			this.exceptionTextBox.Text = "textBoxExceptionText";
-			// 
-			// ExceptionBox
-			// 
-			this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
-			this.ClientSize = new System.Drawing.Size(688, 453);
-			this.Controls.Add(this.label3);
-			this.Controls.Add(this.label2);
-			this.Controls.Add(this.label);
-			this.Controls.Add(this.continueButton);
-			this.Controls.Add(this.reportButton);
-			this.Controls.Add(this.includeSysInfoCheckBox);
-			this.Controls.Add(this.copyErrorCheckBox);
-			this.Controls.Add(this.exceptionTextBox);
-			this.Controls.Add(this.pictureBox);
-			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
-			this.MaximizeBox = false;
-			this.MinimizeBox = false;
-			this.Name = "ExceptionBox";
-			this.Text = "Unhandled exception has occured";
-			this.ResumeLayout(false);
-		}*/
-	}
-}
+using System;
+using System.Reflection;
+using System.Resources;
+using System.Diagnostics;
+using System.Drawing;
+
+using Gtk;
+using Gdk;
+
+using ICSharpCode.SharpDevelop.Gui;
+using ICSharpCode.Core.Services;
+
+namespace ICSharpCode.SharpDevelop 
+{
+	public enum  DialogResult{
+		Abort,
+		Ignore,
+		Continue
+	}
+	public delegate void ButtonHandler(ExceptionDialog eb, DialogResult dr);
+	
+	public class ExceptionDialog:Gtk.Window {
+	
+		private Gtk.Fixed fixedcontainer;
+		private Gtk.Button continueButton;
+		private Gtk.Button ignoreButton;
+		private Gtk.Button abortButton;
+		private Gtk.CheckButton copyErrorCheckButton;
+		private Gtk.CheckButton includeSysInfoCheckButton;
+		private Gtk.Label label;
+		private Gtk.ScrolledWindow scrolledwindow;
+		private Gtk.TextView exceptionTextView;
+		private Gtk.Image image;
+		private Exception exceptionThrown;
+		private ButtonHandler buttonhandler;
+		static GLib.GType type;
+
+
+		static ExceptionDialog() {
+			type = RegisterGType(typeof(ExceptionDialog));
+		}
+
+		public ExceptionDialog(Exception e):base(type)
+		{
+				this.exceptionThrown = e;
+				InitializeComponent();
+				this.exceptionTextView.Buffer.Text = e.ToString(); 
+		}
+	
+		string getClipboardString()
+		{
+			Version v;
+			string str = "";
+			if (includeSysInfoCheckButton.Active) {
+				str  = ".NET Version         : " + Environment.Version.ToString() + Environment.NewLine;
+				str += "OS Version           : " + Environment.OSVersion.ToString() + Environment.NewLine;
+				// str += "Boot Mode            : " + Information.BootMode + Environment.NewLine;
+				str += "Working Set Memory   : " + (Environment.WorkingSet / 1024) + "kb" + Environment.NewLine + Environment.NewLine;
+				v = Assembly.GetEntryAssembly().GetName().Version;
+				str += "SharpDevelop Version : " + v.Major + "." + v.Minor + "." + v.Revision + "." + v.Build + Environment.NewLine;
+			}
+			
+			str += "Exception thrown: " + Environment.NewLine;
+			str += exceptionThrown.ToString();
+			return str;
+		}
+			
+		void CopyInfoToClipboard()
+		{
+			if (copyErrorCheckButton.Active) {
+				Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", true)).SetText(getClipboardString()); // How does clipboard work?
+			}
+		}
+	
+		void AbortButton_Clicked(object obj, EventArgs ea)
+		{
+			CallButtonHandlers(DialogResult.Abort);
+			Application.Quit();
+		}
+	
+		void ContinueButton_Clicked(object sender, System.EventArgs e)
+		{
+			CopyInfoToClipboard();
+			// open Mozilla via process.start to SharpDevelop bug reporting forum
+			this.ResumeLayout();
+			try {
+				Process.Start("mozilla http://www.icsharpcode.net/OpenSource/SD/Forum/forum.asp?FORUM_ID=5");
+			}
+			catch (Exception ex) {}
+			CallButtonHandlers(DialogResult.Continue);
+		}
+		
+		void IgnoreButton_Clicked(object sender, System.EventArgs e)
+		{
+			CopyInfoToClipboard();
+			this.ResumeLayout();
+	
+			CallButtonHandlers(DialogResult.Ignore);
+		}
+	
+		void CallButtonHandlers(DialogResult dr) {
+			if (this.buttonhandler != null)
+				buttonhandler(this, dr);
+		}
+	
+		public void InitializeComponent() {
+			ResourceService resourceService = (ResourceService)ServiceManager.Services.GetService(typeof(IResourceService));
+
+			this.fixedcontainer = new Gtk.Fixed();
+			this.continueButton = new Gtk.Button();
+			this.ignoreButton = new Gtk.Button();
+			this.abortButton = new Gtk.Button();
+			this.copyErrorCheckButton = new Gtk.CheckButton();
+			this.includeSysInfoCheckButton = new Gtk.CheckButton();
+			this.label = new Gtk.Label();
+			this.scrolledwindow = new Gtk.ScrolledWindow();
+			this.exceptionTextView = new Gtk.TextView();
+
+			try {
+				this.image = new Gtk.Image(resourceService.GetBitmap("ErrorReport"));
+			}
+			catch (NullReferenceException ex) {
+				this.image = new Gtk.Image();
+				this.image.SetFromStock("gtk-dialog-error", Gtk.IconSize.Dialog);
+			}
+	
+			this.SuspendLayout();
+	
+			//
+			// continueButton
+			//
+			this.continueButton.Label = "Continue";
+			this.continueButton.RequestSize = new System.Drawing.Size(112, 40);
+			this.continueButton.Clicked += new System.EventHandler(this.ContinueButton_Clicked);
+			//
+			// abortButton
+			//
+			this.abortButton.Label = "Abort";
+			this.abortButton.RequestSize = new System.Drawing.Size(112, 40);
+			this.abortButton.Clicked += new System.EventHandler(this.AbortButton_Clicked);
+			//
+			// ignoreButton
+			//
+			this.ignoreButton.Label = "Ignore";
+			this.ignoreButton.RequestSize = new System.Drawing.Size(112, 40);
+			this.ignoreButton.Clicked += new System.EventHandler(this.IgnoreButton_Clicked);
+			//
+			// copyErrorCheckButton
+			//
+			this.copyErrorCheckButton.Label = "Copy error to clipboard";
+			this.copyErrorCheckButton.RequestSize = new System.Drawing.Size(672, 24);
+			//
+			// includeSysInfoCheckButton
+			//
+			this.includeSysInfoCheckButton.Label = "Include system info (Mono version, O.S. version)";
+			this.copyErrorCheckButton.RequestSize = new System.Drawing.Size(672, 24);
+			//
+			// label
+			//
+			this.label.LineWrap = true;
+			this.label.Text = 	"An error has ocurred." + System.Environment.NewLine +
+										"This may be due to a programming error." + System.Environment.NewLine +
+										"Please, help us to make MonoDevelop a better program for everyone." + System.Environment.NewLine +
+										"Thanks in advance for your help.";
+			this.label.RequestSize = new System.Drawing.Size(480, 88);
+			//
+			// scrolledwindow
+			//
+			this.scrolledwindow.HscrollbarPolicy = Gtk.PolicyType.Automatic;
+			this.scrolledwindow.VscrollbarPolicy = Gtk.PolicyType.Automatic;
+			this.scrolledwindow.AddWithViewport(this.exceptionTextView);
+			this.scrolledwindow.RequestSize = new System.Drawing.Size(480, 256);
+			//
+			// exceptionTextView
+			//
+			this.exceptionTextView.Editable = false;
+			//
+			// image
+			//
+			this.image.RequestSize = new System.Drawing.Size(226, 466);
+			//
+			// fixedcontainer
+			//
+			this.fixedcontainer.RequestSize = new System.Drawing.Size(740, 483);
+			this.fixedcontainer.Put(continueButton, 624, 432);
+			this.fixedcontainer.Put(abortButton, 368, 432);
+			this.fixedcontainer.Put(ignoreButton, 496, 432);
+			this.fixedcontainer.Put(copyErrorCheckButton, 256, 360);
+			this.fixedcontainer.Put(includeSysInfoCheckButton, 256, 392);
+			this.fixedcontainer.Put(label, 256, 8);
+			this.fixedcontainer.Put(scrolledwindow, 256, 96);
+			this.fixedcontainer.Put(image, 8, 8);
+			//
+			// this
+			//
+			this.Title = "Exception raised error";
+			this.Resizable = false;
+			this.WindowPosition = Gtk.WindowPosition.Center;
+			this.Add(fixedcontainer);
+		}
+	
+		public void AddButtonHandler(ButtonHandler bh) {
+			this.buttonhandler += bh;
+		}
+	
+		void SuspendLayout() {
+			this.Modal = true;
+			if (ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.Workbench != null) {
+				this.TransientFor = (Gtk.Window) ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.Workbench;
+			}
+		}
+
+		void ResumeLayout() {
+			this.Modal = false;
+		}
+	
+	}
+}

Modified: trunk/MonoDevelop/src/Main/StartUp/Makefile
===================================================================
--- trunk/MonoDevelop/src/Main/StartUp/Makefile	2004-01-19 18:26:00 UTC (rev 572)
+++ trunk/MonoDevelop/src/Main/StartUp/Makefile	2004-01-19 20:16:01 UTC (rev 573)
@@ -38,6 +38,7 @@
 	@ mcs /debug /out:$(DLL) /r:System.Drawing.dll \
 		/r:../../../build/bin/ICSharpCode.Core.dll \
 		/r:../../../build/bin/SharpDevelop.Base.dll \
-		/define:GTK /r:gtk-sharp.dll /r:gdk-sharp.dll\
+		/r:glib-sharp.dll \
+		/define:GTK /r:gtk-sharp.dll /r:gdk-sharp.dll \
 		$(RESOURCES) $(SOURCES)
 

Modified: trunk/MonoDevelop/src/Main/StartUp/SharpDevelopMain.cs
===================================================================
--- trunk/MonoDevelop/src/Main/StartUp/SharpDevelopMain.cs	2004-01-19 18:26:00 UTC (rev 572)
+++ trunk/MonoDevelop/src/Main/StartUp/SharpDevelopMain.cs	2004-01-19 20:16:01 UTC (rev 573)
@@ -1,131 +1,123 @@
-// <file>
-//	 <copyright see="prj:///doc/copyright.txt"/>
-//	 <license see="prj:///doc/license.txt"/>
-//	 <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-//	 <version value="$version"/>
-// </file>
-
-using System;
-using System.IO;
-using System.Diagnostics;
-using System.Reflection;
-using System.Drawing;
-using System.Collections;
-using System.Resources;
-using System.Xml;
-using System.Threading;
-using System.Runtime.Remoting;
-using System.Security.Policy;
-
-using ICSharpCode.Core.Properties;
-using ICSharpCode.Core.AddIns.Codons;
-using ICSharpCode.Core.AddIns;
-using ICSharpCode.Core.Services;
-using ICSharpCode.SharpDevelop.Gui.Dialogs;
-
-namespace ICSharpCode.SharpDevelop
-{
-	/// <summary>
-	/// This Class is the Core main class, it starts the program.
-	/// </summary>
-	public class SharpDevelopMain
-	{
-		static string[] commandLineArgs = null;
-		
-		public static string[] CommandLineArgs {
-			get {
-				return commandLineArgs;
-			}
-		}
-		
-		static void ShowErrorBox(object sender, ThreadExceptionEventArgs eargs)
-		{
-#if GTK
-			// FIXME: GTKize
-#else
-			DialogResult result = new ExceptionBox(eargs.Exception).ShowDialog();
-
-			DataObject dataObject = new DataObject();
-			dataObject.SetData(DataFormats.Text, eargs.Exception.ToString());
-			Clipboard.SetDataObject(dataObject, true);
-			
-			switch (result) {
-				case DialogResult.Ignore:
-					break;
-				case DialogResult.Abort:
-					Application.Exit();
-					break;
-				case DialogResult.Yes:
-					Process.Start("http://www.icsharpcode.net/OpenSource/SD/Forum/post.asp?method=Topic&FORUM_ID=5");
-					break;
-			}
-#endif
-		}
-		
-		/// <summary>
-		/// Starts the core of SharpDevelop.
-		/// </summary>
-		[STAThread()]
-		public static void Main(string[] args)
-		{
-			Gtk.Application.Init ();
-			Gdk.Threads.Init();
-			commandLineArgs = args;
-			bool noLogo = false;
-		
-			SplashScreenForm.SetCommandLineArgs(args);
-			
-			foreach (string parameter in SplashScreenForm.GetParameterList()) {
-				switch (parameter.ToUpper()) {
-					case "NOLOGO":
-						noLogo = true;
-						break;
-				}
-			}
-	
-			if (!noLogo) {
-				SplashScreenForm.SplashScreen.ShowAll ();
-				while (Gtk.Application.EventsPending()) {
-					Gtk.Application.RunIteration (false);
-				}
-			}
-			
-			bool ignoreDefaultPath = false;
-			string [] addInDirs = ICSharpCode.SharpDevelop.AddInSettingsHandler.GetAddInDirectories(out ignoreDefaultPath);
-			AddInTreeSingleton.SetAddInDirectories(addInDirs, ignoreDefaultPath);
-
-			//Application.ThreadException += new ThreadExceptionEventHandler(ShowErrorBox);
-			
-			ArrayList commands = null;
-			try {
-				ServiceManager.Services.AddService(new IconService());
-				ServiceManager.Services.AddService(new MessageService());
-				ServiceManager.Services.AddService(new ResourceService());
-				ServiceManager.Services.InitializeServicesSubsystem("/Workspace/Services");
-			
-				commands = AddInTreeSingleton.AddInTree.GetTreeNode("/Workspace/Autostart").BuildChildItems(null);
-				for (int i = 0; i < commands.Count - 1; ++i) {
-					((ICommand)commands[i]).Run();
-				}
-			} catch (XmlException e) {
-				Console.WriteLine("Could not load XML :\n" + e.Message);
-				return;
-			} catch (Exception e) {
-				Console.WriteLine("Loading error, please reinstall :\n" + e.ToString());
-				return;
-			} finally {
-				if (SplashScreenForm.SplashScreen != null) {
-					SplashScreenForm.SplashScreen.Hide();
-				}
-			}
-			
-			// run the last autostart command, this must be the workbench starting command
-			if (commands.Count > 0) {
-				((ICommand)commands[commands.Count - 1]).Run();
-			}
-			
-			// unloading services
-			ServiceManager.Services.UnloadAllServices();
-		}
-	}
-}
+// <file>
+//	 <copyright see="prj:///doc/copyright.txt"/>
+//	 <license see="prj:///doc/license.txt"/>
+//	 <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+//	 <version value="$version"/>
+// </file>
+
+using System;
+using System.IO;
+using System.Diagnostics;
+using System.Reflection;
+using System.Drawing;
+using System.Collections;
+using System.Resources;
+using System.Xml;
+using System.Threading;
+using System.Runtime.Remoting;
+using System.Security.Policy;
+
+using ICSharpCode.Core.Properties;
+using ICSharpCode.Core.AddIns.Codons;
+using ICSharpCode.Core.AddIns;
+using ICSharpCode.Core.Services;
+using ICSharpCode.SharpDevelop.Gui.Dialogs;
+
+namespace ICSharpCode.SharpDevelop
+{
+	/// <summary>
+	/// This Class is the Core main class, it starts the program.
+	/// </summary>
+	public class SharpDevelopMain
+	{
+		static string[] commandLineArgs = null;
+		
+		public static string[] CommandLineArgs {
+			get {
+				return commandLineArgs;
+			}
+		}
+
+		static void ShowErrorBox(object sender, ThreadExceptionEventArgs eargs)
+		{
+			ExceptionDialog ed;
+
+			ed = new ExceptionDialog(eargs.Exception);
+			ed.AddButtonHandler(new ButtonHandler(DialogResultHandler));
+			ed.ShowAll();
+		}
+
+		static void DialogResultHandler(ExceptionDialog ed, DialogResult dr) {
+			ed.Destroy();			
+		}
+
+		/// <summary>
+		/// Starts the core of SharpDevelop.
+		/// </summary>
+		[STAThread()]
+		public static void Main(string[] args)
+		{
+			Gtk.Application.Init ();
+			Gdk.Threads.Init();
+			commandLineArgs = args;
+			bool noLogo = false;
+		
+			SplashScreenForm.SetCommandLineArgs(args);
+			
+			foreach (string parameter in SplashScreenForm.GetParameterList()) {
+				switch (parameter.ToUpper()) {
+					case "NOLOGO":
+						noLogo = true;
+						break;
+				}
+			}
+
+			if (!noLogo) {
+				SplashScreenForm.SplashScreen.ShowAll ();
+				while (Gtk.Application.EventsPending()) {
+					Gtk.Application.RunIteration (false);
+				}
+			}
+
+			bool ignoreDefaultPath = false;
+			string [] addInDirs = ICSharpCode.SharpDevelop.AddInSettingsHandler.GetAddInDirectories(out ignoreDefaultPath);
+			AddInTreeSingleton.SetAddInDirectories(addInDirs, ignoreDefaultPath);
+
+			ArrayList commands = null;
+			try {
+				ServiceManager.Services.AddService(new IconService());
+				ServiceManager.Services.AddService(new MessageService());
+				ServiceManager.Services.AddService(new ResourceService());
+				ServiceManager.Services.InitializeServicesSubsystem("/Workspace/Services");
+
+				commands = AddInTreeSingleton.AddInTree.GetTreeNode("/Workspace/Autostart").BuildChildItems(null);
+				for (int i = 0; i < commands.Count - 1; ++i) {
+					((ICommand)commands[i]).Run();
+				}
+
+				// We don't have yet an alternative for Application.ThreadException
+				// How can we handle this?
+				// Application.ThreadException += new ThreadExceptionEventHandler(ShowErrorBox);
+
+			} catch (XmlException e) {
+				Console.WriteLine("Could not load XML :\n" + e.Message);
+				return;
+			} catch (Exception e) {
+				Console.WriteLine("Loading error, please reinstall :\n" + e.ToString());
+				return;
+			} finally {
+				if (SplashScreenForm.SplashScreen != null) {
+					SplashScreenForm.SplashScreen.Hide();
+				}
+			}
+
+			// run the last autostart command, this must be the workbench starting command
+			if (commands.Count > 0) {
+				((ICommand)commands[commands.Count - 1]).Run();
+			}
+
+			// unloading services
+			ServiceManager.Services.UnloadAllServices();
+		}
+	}
+}




More information about the Monodevelop-patches-list mailing list