Beispiel #1
0
        public override void FinishedLaunching(NSObject notification)
        {
            ///////
            /// Glorified Event "Handler"
            ///  for Menu Items (like File, edit and so forth)
            ///////
            ///

            // *************************** //
            // TODO
            // - Reimplement SaveAs (command-S)

            mainWindowController = new MainWindowController ();
            mainWindowController.Window.MakeKeyAndOrderFront (this);

            MainWindow winMain = mainWindowController.Window;

            /////
            /// SaveAs File Menu Item
            /////
            miSaveAs.Activated += (object sender, EventArgs e) => {
                SharedWindowMethods.SaveCurrentSetFilePanel ();
            };

            /////
            /// Open File Menu Item
            /////
            miOpen.Activated += (object sender, EventArgs e) => {
                // Call for openPanel
                // Credit user: rjm
                // http://forums.xamarin.com/discussion/3876/regression-in-nsopenpanel
                NSOpenPanel openPanel = new NSOpenPanel ();
                openPanel.Begin (((int result) => {
                    try {
                        if (openPanel.Url != null) {
                            // get path
                            var file = openPanel.Url.Path;

                            // open file
                            m_at.OpenFile (System.IO.Path.GetFileName (file), System.IO.Path.GetDirectoryName (file));

                            // parse open file
                            m_at.InitSet ();

                            // init SetRunner
                            m_sr.Init (m_at.GetSetList ());

                            // update table
                            winMain.tbvSetList.DataSource = new TableViewHandler (m_at.GetSetListTable ());

                        }
                    } finally {
                        openPanel.Dispose ();
                    }
                }));

                // refresh window gui
                winMain.updateGUI ();
            };
        }
        public static string OpenFilePanel()
        {
            // Open file prompt
            // Credit user: rjm
            // http://forums.xamarin.com/discussion/3876/regression-in-nsopenpanel
            NSOpenPanel openPanel = new NSOpenPanel ();
            string s = "";
            openPanel.Begin (((int result) => {
                try {
                    if (openPanel.Url != null)
                        s = openPanel.Url.Path;

                } finally {
                    openPanel.Dispose ();
                }
            }));
            return s;
        }
Beispiel #3
0
		public static void SelectFile(NSWindow window, NSTextField field)
		{
			NSOpenPanel openPanel = new NSOpenPanel ();
			openPanel.BeginSheet (window, (i) => {

				try {
					if (openPanel.Url != null) {
						string path = openPanel.Url.Path;

						if (!string.IsNullOrEmpty (path))
							field.StringValue = path;
					}
				} finally {
					openPanel.Dispose ();
				}


			});

		}