Beispiel #1
0
        public static void openFileWindow(Toplevel top, Toplevel ntop)
        {
            var o = new OpenDialog("Open", "Open a file");

            //o.MouseEvent mouseEvent;

            Application.Run(o);

            if (o.FilePath != "")
            {
                string filePath    = o.DirectoryPath.ToString() + "\\" + o.FilePath.ToString();
                string fileContent = FileOperation.openRead(filePath);

                var tframe = top.Frame;

                currentOpenedPath = filePath;

                var win = new Window(o.FilePath ?? "Untitled")
                {
                    X      = 0,
                    Y      = 1,
                    Width  = Dim.Fill(),
                    Height = Dim.Fill()
                };


                var text = new TextView(new Rect(0, 0, tframe.Width - 2, tframe.Height - 3));
                text.Text = fileContent;

                win.Add(text);
                ntop.Clear();

                //Menu***************************************************
                displayMenu(top, ntop, text);
                //end Menu*********************************************************

                ntop.Add(win);

                Application.Run(ntop);
            }
        }
Beispiel #2
0
        public static void displayMenu(Toplevel top, Toplevel ntop, TextView v)
        {
            var menu = new MenuBar(new MenuBarItem[] {
                new MenuBarItem("_File", new MenuItem [] {
                    new MenuItem("_New", "", () => NewFile(top, ntop)),
                    new MenuItem("_Open", "", () => openFileWindow(top, ntop)),
                    new MenuItem("_Save", "", () => saveFileWindow(v)),
                    new MenuItem("_Exit", "", () => { if (Quit())
                                                      {
                                                          Application.RequestStop();
                                                      }
                                 }),
                }),
                new MenuBarItem("About", new MenuItem [] {
                    new MenuItem("A_bout", "", About)
                }),
            });

            ntop.Clear();
            ntop.Add(menu);
        }
Beispiel #3
0
 private void run()
 {
     _top.Clear();
     createWindow();
     addMenu();
 }