예제 #1
0
파일: Menu.cs 프로젝트: mchi2dy2/gui.cs
        internal void CheckSubMenu()
        {
            if (barItems.Children [current] == null)
            {
                return;
            }
            var subMenu = barItems.Children [current].SubMenu;

            if (subMenu != null)
            {
                int pos = -1;
                if (host.openSubMenu != null)
                {
                    pos = host.openSubMenu.FindIndex(o => o?.barItems == subMenu);
                }
                host.Activate(host.selected, pos, subMenu);
            }
            else if (host.openSubMenu != null && !barItems.Children [current].IsFromSubMenu)
            {
                host.CloseMenu(false, true);
            }
        }
예제 #2
0
        void SetupGUI()
        {
            var height = Application.Lines - 4;

            left   = Panel.Create(this, "left", 4);
            right  = Panel.Create(this, "right", 4);
            bar    = new ButtonBar(bar_labels);
            menu   = new MenuBar(mc_menu);
            prompt = new Label(0, Application.Lines - 2, "bash$ acción ")
            {
                Color = Application.ColorBasic
            };
            entry = new Entry(prompt.Text.Length, Application.Lines - 2, Application.Cols - prompt.Text.Length, "")
            {
                Color    = Application.ColorBasic,
                CanFocus = false,
            };

            bar.Action += delegate(int n){
                switch (n)
                {
                case 3:
                    var selected = CurrentPanel.SelectedNode;
                    if (selected is Listing.DirNode)
                    {
                        CurrentPanel.ChangeDir(selected as Listing.DirNode);
                    }
                    else
                    {
                        Stream stream;
                        try {
                            stream = File.OpenRead(CurrentPanel.SelectedPath);
                        } catch (IOException ioe) {
                            Message.Error(ioe, "Could not open file", CurrentPanel.SelectedPath);
                            return;
                        }
                        FullView.Show(stream);

                        stream.Dispose();
                    }
                    break;

                case 5:
                    CurrentPanel.Copy(OtherPanel.CurrentPath);
                    break;

                case 9:
                    menu.Activate(0);
                    break;

                case 10:
                    var r = MessageBox.Query(56, 7, "Midnight Commander NG", "Do you really want to quit?", "Yes", "No");
                    if (r == 0)
                    {
                        Running = false;
                    }
                    break;

                default:
                    break;
                }
            };

            Add(left);
            Add(right);
            Add(bar);
            Add(menu);
            Add(prompt);
            Add(entry);

            SetFocus(left);
        }