Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MainView: load files given on command line

  • Loading branch information...
commit 23217c6e94e7edd7fde5b9c88c718f6df6444c1d 1 parent 1955b55
@himdel authored
Showing with 44 additions and 43 deletions.
  1. +1 −3 Makefile
  2. +26 −28 src/Program.cs
  3. +17 −12 src/UI/MainView.cs
View
4 Makefile
@@ -15,7 +15,7 @@ prepare:
run: prepare
cp ${DEPS_DIR}/*.dll ${BUILD_DIR}
- cp ${DEPS_DIR}/*.mdb ${BUILD_DIR}
+ cp ${DEPS_DIR}/*.mdb ${BUILD_DIR} || true
cd ${BUILD_DIR} && mono --debug mwf-designer.exe
mono-design: prepare
@@ -24,5 +24,3 @@ mono-design: prepare
mono-design-update:
cd ${DEPS_DIR}/Mono.Design && make update
-
-
View
54 src/Program.cs
@@ -4,35 +4,33 @@
namespace mwf_designer
{
- static class Program
- {
- /// <summary>
- /// The main entry point for the application.
- /// </summary>
- [STAThread]
- static void Main()
- {
- AppDomain.CurrentDomain.UnhandledException += delegate (object sender, UnhandledExceptionEventArgs args) {
- System.Windows.Forms.MessageBox.Show (args.ExceptionObject.GetType ().Name);
- if (args.ExceptionObject is Exception)
- OnException ((Exception)args.ExceptionObject);
- };
+ static class Program
+ {
+ /// <summary>
+ /// The main entry point for the application.
+ /// </summary>
+ [STAThread]
+ static void Main(string[] args)
+ {
+ AppDomain.CurrentDomain.UnhandledException += delegate (object sender, UnhandledExceptionEventArgs ueargs) {
+ System.Windows.Forms.MessageBox.Show (ueargs.ExceptionObject.GetType ().Name);
+ if (ueargs.ExceptionObject is Exception)
+ OnException ((Exception) ueargs.ExceptionObject);
+ };
- try {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new MainView());
- } catch (Exception e) {
- OnException (e);
- System.Windows.Forms.Application.Exit ();
+ try {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new MainView(args));
+ } catch (Exception e) {
+ OnException (e);
+ System.Windows.Forms.Application.Exit ();
+ }
}
- }
- private static void OnException (Exception e)
- {
- MessageBox.Show ("A fatal error occurred. Please file a bug report with the following details (Ctrl-C to copy to clipboard):" +
- System.Environment.NewLine + System.Environment.NewLine +
- e.ToString (), "Fatal Error");
+ private static void OnException (Exception e)
+ {
+ MessageBox.Show ("A fatal error occurred. Please file a bug report with the following details (Ctrl-C to copy to clipboard):" + System.Environment.NewLine + System.Environment.NewLine + e.ToString (), "Fatal Error");
+ }
}
- }
-}
+}
View
29 src/UI/MainView.cs
@@ -53,10 +53,23 @@ public partial class MainView : Form
private ToolboxFiller _toolboxFiller;
private readonly string MODIFIED_MARKER = " *";
- public MainView ()
+ public MainView (string[] args)
{
InitializeComponent ();
LoadWorkspace ();
+ foreach (string s in args)
+ LoadFile(s);
+ }
+
+ private void LoadFile(string f) {
+ if (surfaceTabs.TabPages.ContainsKey (f)) {// tab page for file already existing
+ surfaceTabs.SelectedTab = surfaceTabs.TabPages[f];
+ } else {
+ if (CodeProvider.IsValidFile (f))
+ LoadDocument (f, _workspace);
+ else
+ MessageBox.Show ("No corresponding .Designer file found for " + f);
+ }
}
private void openToolStripMenuItem_Click (object sender, EventArgs e)
@@ -65,16 +78,8 @@ private void openToolStripMenuItem_Click (object sender, EventArgs e)
dialog.CheckFileExists = true;
dialog.Multiselect = false;
dialog.Filter = "C# Source Code (*.cs)|*.cs|VB.NET Source Code (*.vb)|*.vb";
- if (dialog.ShowDialog () == DialogResult.OK) {
- if (surfaceTabs.TabPages.ContainsKey (dialog.FileName)) {// tab page for file already existing
- surfaceTabs.SelectedTab = surfaceTabs.TabPages[dialog.FileName];
- } else {
- if (CodeProvider.IsValidFile (dialog.FileName))
- LoadDocument (dialog.FileName, _workspace);
- else
- MessageBox.Show ("No corresponding .Designer file found for " + dialog.FileName);
- }
- }
+ if (dialog.ShowDialog () == DialogResult.OK)
+ LoadFile(dialog.FileName);
}
private void LoadWorkspace ()
@@ -241,4 +246,4 @@ private void OnDelete_Clicked (object sender, EventArgs args)
}
}
}
-}
+}
Please sign in to comment.
Something went wrong with that request. Please try again.