Exemplo n.º 1
0
        /// <summary>
        /// Shows the manage layouts dialog</summary>
        /// <remarks>Programmatic method for showing the 'manage layouts' dialog</remarks>
        public override void ShowManageLayoutsDialog()
        {
            using (var dialog = new WindowLayoutManageDialog())
            {
                dialog.ScreenshotDirectory = LayoutScreenshotDirectory;
                dialog.LayoutNames         = WindowLayoutService.Layouts;

                TryUseMainFormIcon(MainForm, dialog);

                dialog.ShowDialog(MainForm);

                // Re-associate shortcuts for proper persisting
                foreach (var kv in dialog.RenamedLayouts)
                {
                    IEnumerable <Input.Keys> shortcuts;
                    if (!m_dictCommandKeys.TryGetValue(kv.Key, out shortcuts))
                    {
                        continue;
                    }

                    m_dictCommandKeys.Remove(kv.Key);
                    m_dictCommandKeys[kv.Value] = shortcuts;
                }

                foreach (var kv in dialog.RenamedLayouts)
                {
                    WindowLayoutService.RenameLayout(kv.Key, kv.Value);
                }

                foreach (var layoutName in dialog.DeletedLayouts)
                {
                    WindowLayoutService.RemoveLayout(layoutName);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Updates a command</summary>
        /// <param name="commandTag">Command</param>
        /// <param name="state">Command state</param>
        public override void UpdateCommand(object commandTag, CommandState state)
        {
            if (!(commandTag is WindowLayoutServiceCommand))
            {
                return;
            }

            var cmd = (WindowLayoutServiceCommand)commandTag;

            state.Check = WindowLayoutService.IsCurrent(cmd.LayoutName);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Saves the current layout as a name (and creates a screenshot)</summary>
        /// <param name="layoutName">Layout name to save as</param>
        /// <returns>True iff saved</returns>
        public virtual bool SaveLayoutAs(string layoutName)
        {
            if (string.IsNullOrEmpty(layoutName))
            {
                return(false);
            }

            // Allow overwriting. This is only possible if
            // the layout name isn't already in use.
            WindowLayoutService.RemoveLayout(layoutName);

            WindowLayoutService.CurrentLayout = layoutName;
            SaveLayoutScreenshot(layoutName, LayoutScreenshotDirectory, this);

            return(true);
        }