Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

Commit

Permalink
MainView: load files given on command line
Browse files Browse the repository at this point in the history
  • Loading branch information
himdel committed May 16, 2011
1 parent 1955b55 commit 23217c6
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 43 deletions.
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -24,5 +24,3 @@ mono-design: prepare

mono-design-update:
cd ${DEPS_DIR}/Mono.Design && make update


54 changes: 26 additions & 28 deletions src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}
}
}
29 changes: 17 additions & 12 deletions src/UI/MainView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 ()
Expand Down Expand Up @@ -241,4 +246,4 @@ private void OnDelete_Clicked (object sender, EventArgs args)
}
}
}
}
}

0 comments on commit 23217c6

Please sign in to comment.