Beispiel #1
0
        /// <summary>
        /// 关闭并卸载UI
        /// </summary>
        /// <param name="behaviourName"></param>
        public void CloseUI(string behaviourName)
        {
            IPanel behaviour = null;

            mAllUI.TryGetValue(behaviourName, out behaviour);

            if ((behaviour as UIPanel))
            {
                behaviour.Close();
                mAllUI.Remove(behaviourName);
            }
        }
Beispiel #2
0
        public void Push(IPanel view)
        {
            if (view != null)
            {
                mUIStack.Push(view.Info);
                view.Close();

                var panelSearchKeys = PanelSearchKeys.Allocate();

                panelSearchKeys.GameObjName = view.Transform.name;

                UIManager.Instance.RemoveUI(panelSearchKeys);

                panelSearchKeys.Recycle2Cache();
            }
        }
Beispiel #3
0
        public static void ShowPanelsMenu()
        {
            var menu = Far.Api.CreateMenu();

            menu.AutoAssignHotkeys = true;
            menu.HelpTopic         = "MenuPanels";
            menu.ShowAmpersands    = true;
            menu.Title             = "Panels";

            menu.AddKey(KeyCode.Delete);
            menu.AddKey(KeyCode.Spacebar);

            for (;; menu.Items.Clear())
            {
                IPanel panel  = Far.Api.Panel;
                Panel  module = null;

                // Push/Shelve
                if (panel.IsPlugin)
                {
                    module = panel as Panel;
                    if (module != null)
                    {
                        menu.Add(sPushShelveThePanel);
                        menu.Add(sResizeColum1);
                        menu.Add(sResizeColum2);
                        menu.Add(sSwitchFullScreen);
                    }

                    menu.Add(sClose);
                }
                else if (panel.Kind == PanelKind.File)
                {
                    menu.Add(sPushShelveThePanel);
                }

                // Pop/Unshelve
                if (ShelveInfo.Stack.Count > 0)
                {
                    menu.Add("Pop/Unshelve").IsSeparator = true;

                    foreach (var si in ShelveInfo.Stack)
                    {
                        menu.Add(si.Title).Data = si;
                    }
                }

                if (!menu.Show())
                {
                    return;
                }

                var mi = menu.Items[menu.Selected];

                // [Delete]:
                if (menu.Key.VirtualKeyCode == KeyCode.Delete)
                {
                    // remove the shelved panel; do not remove module panels because of their shutdown bypassed
                    var si = (ShelveInfo)mi.Data;
                    if (si.CanRemove)
                    {
                        ShelveInfo.Stack.Remove(si);
                    }

                    continue;
                }

                // Push/Shelve
                if (mi.Text == sPushShelveThePanel)
                {
                    panel.Push();
                    return;
                }

                bool repeat = menu.Key.VirtualKeyCode == KeyCode.Spacebar;

                // Decrease/Increase column
                if (mi.Text == sResizeColum1 || mi.Text == sResizeColum2)
                {
                    ResizeColumn(module, mi.Text == sResizeColum2);
                    if (repeat)
                    {
                        continue;
                    }
                    else
                    {
                        return;
                    }
                }

                // Full screen
                if (mi.Text == sSwitchFullScreen)
                {
                    SwitchFullScreen(module);
                    if (repeat)
                    {
                        continue;
                    }
                    else
                    {
                        return;
                    }
                }

                // Close panel
                if (mi.Text == sClose)
                {
                    // native plugin panel: go to the first item to work around "Far does not restore panel state",
                    // this does not restore either but is still better than unexpected current item after exit.
                    if (null == module)
                    {
                        panel.Redraw(0, 0);
                        panel.Close();
                    }
                    else
                    {
                        module.UIEscape(true);
                    }
                    return;
                }

                // Pop/Unshelve
                var shelve = (ShelveInfo)mi.Data;
                shelve.Pop();
                return;
            }
        }