Ejemplo n.º 1
0
        private void SaveCurrentToConfig(string layoutName)
        {
            // TODO: better input of layout names
            // TODO: verify with user when re-using a layout name: it will overwrite the existing settings

            var processWindows = _desktopWindowUtil.ListWindows();
            var selector       = _dialogFactory.Create(
                processWindows,
                new[]
            {
                nameof(ProcessWindow.ProcessName),
                nameof(ProcessWindow.WindowTitle),
                nameof(ProcessWindow.Position)
            });
            var selectorResult = selector.Prompt();

            if (selectorResult.Result == DialogResult.Cancel)
            {
                return;
            }
            processWindows = selectorResult.SelectedItems;

            RemoveAllAppLayoutSectionsFor(layoutName);
            AddAppLayoutSectionsFor(layoutName, processWindows);
            _config.Persist();
        }
Ejemplo n.º 2
0
        private void RestoreWindowPositionsFor(string layout)
        {
            var appLayoutSections = _sectionNameHelper.ListAppLayoutSectionsFor(layout);

            _desktopWindowUtil.ListWindows()
            .ForEach(
                window =>
            {
                var section = FindBestMatchFor(window, appLayoutSections);
                if (section == null)
                {
                    return;
                }
                ApplyLayout(window, section);
            });
            _eventAggregator
            .GetEvent <LayoutRestoredEvent>()
            .Publish(layout);
            _trayIcon.ShowBalloonTipFor(
                5000,
                "Layout restored",
                $"Layout '{layout}' was restored",
                ToolTipIcon.Info
                );
        }