예제 #1
0
        private void EditLayout_Click(object sender, RoutedEventArgs e)
        {
            EditorOverlay mainEditor = EditorOverlay.Current;

            if (!(mainEditor.DataContext is LayoutModel model))
            {
                return;
            }

            model.IsSelected = false;
            _editing         = true;
            Close();

            bool isPredefinedLayout = Settings.IsPredefinedLayout(model);

            if (!_settings.CustomModels.Contains(model) || isPredefinedLayout)
            {
                if (isPredefinedLayout)
                {
                    // make a copy
                    model = model.Clone();
                    mainEditor.DataContext = model;
                }

                int maxCustomIndex = 0;
                foreach (LayoutModel customModel in _settings.CustomModels)
                {
                    string name = customModel.Name;
                    if (name.StartsWith(_defaultNamePrefix))
                    {
                        if (int.TryParse(name.Substring(_defaultNamePrefix.Length), out int i))
                        {
                            if (maxCustomIndex < i)
                            {
                                maxCustomIndex = i;
                            }
                        }
                    }
                }

                model.Name = _defaultNamePrefix + (++maxCustomIndex);
            }

            mainEditor.Edit();

            EditorWindow window;

            if (model is GridLayoutModel)
            {
                window = new GridEditorWindow();
            }
            else
            {
                window = new CanvasEditorWindow();
            }

            window.Owner       = EditorOverlay.Current;
            window.DataContext = model;
            window.Show();
        }
예제 #2
0
        public EditorOverlay()
        {
            InitializeComponent();
            Current = this;

            Left   = _settings.WorkArea.Left;
            Top    = _settings.WorkArea.Top;
            Width  = _settings.WorkArea.Width;
            Height = _settings.WorkArea.Height;
        }
예제 #3
0
        protected void OnSaveApplyTemplate(object sender, RoutedEventArgs e)
        {
            EditorOverlay mainEditor = EditorOverlay.Current;
            LayoutModel   model      = mainEditor.DataContext as LayoutModel;

            if (model != null)
            {
                model.Persist(mainEditor.GetZoneRects());
            }
            _choosing = true;
            this.Close();
            EditorOverlay.Current.Close();
        }
        public EditorOverlay()
        {
            InitializeComponent();
            Current = this;

            // TODO: multimon
            // Need to set Left and Top to the correct monitor based on the
            // foreground window passed in the command line arguments
            Rect workArea = System.Windows.SystemParameters.WorkArea;

            Left   = workArea.Left;
            Top    = workArea.Top;
            Width  = workArea.Width;
            Height = workArea.Height;
        }
예제 #5
0
        protected void OnSaveApplyTemplate(object sender, RoutedEventArgs e)
        {
            EditorOverlay mainEditor = EditorOverlay.Current;

            if (mainEditor.DataContext is LayoutModel model)
            {
                model.Persist();
            }

            LayoutModel.SerializeDeletedCustomZoneSets();

            _backToLayoutPicker = false;
            Close();
            EditorOverlay.Current.Close();
        }
예제 #6
0
        private void OnStartup(object sender, StartupEventArgs e)
        {
            if (e.Args.Length > 1)
            {
                UInt16.TryParse(e.Args[1], out _idInitial);
            }

            LayoutModel foundModel = null;

            if (_idInitial != 0)
            {
                foreach (LayoutModel model in _settings.DefaultModels)
                {
                    if (model.Id == _idInitial)
                    {
                        // found match
                        foundModel = model;
                        break;
                    }
                }

                if (foundModel == null)
                {
                    foreach (LayoutModel model in _settings.CustomModels)
                    {
                        if (model.Id == _idInitial)
                        {
                            // found match
                            foundModel = model;
                            break;
                        }
                    }
                }
            }
            if (foundModel == null)
            {
                foundModel = _settings.DefaultModels[0];
            }

            foundModel.IsSelected = true;
            // TODO: multimon
            // Pass in the correct args to show on the desired monitor
            EditorOverlay overlay = new EditorOverlay();

            overlay.Show();
            overlay.DataContext = foundModel;
        }
예제 #7
0
        private void OnStartup(object sender, StartupEventArgs e)
        {
            if (e.Args.Length > 1)
            {
                ushort.TryParse(e.Args[1], out _idInitial);
            }

            LayoutModel foundModel = null;

            if (_idInitial != 0)
            {
                foreach (LayoutModel model in ZoneSettings.DefaultModels)
                {
                    if (model.Id == _idInitial)
                    {
                        // found match
                        foundModel = model;
                        break;
                    }
                }

                if (foundModel == null)
                {
                    foreach (LayoutModel model in ZoneSettings.CustomModels)
                    {
                        if (model.Id == _idInitial)
                        {
                            // found match
                            foundModel = model;
                            break;
                        }
                    }
                }
            }

            if (foundModel == null)
            {
                foundModel = ZoneSettings.DefaultModels[0];
            }

            foundModel.IsSelected = true;

            EditorOverlay overlay = new EditorOverlay();

            overlay.Show();
            overlay.DataContext = foundModel;
        }
예제 #8
0
        private void OnStartup(object sender, StartupEventArgs e)
        {
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            RunnerHelper.WaitForPowerToysRunner(Settings.PowerToysPID, () =>
            {
                Environment.Exit(0);
            });

            LayoutModel foundModel = null;

            foreach (LayoutModel model in ZoneSettings.DefaultModels)
            {
                if (model.Type == Settings.ActiveZoneSetLayoutType)
                {
                    // found match
                    foundModel = model;
                    break;
                }
            }

            if (foundModel == null)
            {
                foreach (LayoutModel model in Settings.CustomModels)
                {
                    if ("{" + model.Guid.ToString().ToUpper() + "}" == Settings.ActiveZoneSetUUid.ToUpper())
                    {
                        // found match
                        foundModel = model;
                        break;
                    }
                }
            }

            if (foundModel == null)
            {
                foundModel = ZoneSettings.DefaultModels[0];
            }

            foundModel.IsSelected = true;

            EditorOverlay overlay = new EditorOverlay();

            overlay.Show();
            overlay.DataContext = foundModel;
        }
예제 #9
0
        private void Apply_Click(object sender, RoutedEventArgs e)
        {
            EditorOverlay mainEditor = EditorOverlay.Current;

            if (mainEditor.DataContext is LayoutModel model)
            {
                if (model is GridLayoutModel)
                {
                    model.Apply(mainEditor.GetZoneRects());
                }
                else
                {
                    model.Apply((model as CanvasLayoutModel).Zones.ToArray());
                }

                Close();
            }
        }
        private void Apply_Click(object sender, RoutedEventArgs e)
        {
            EditorOverlay mainEditor = EditorOverlay.Current;

            if (mainEditor.DataContext is LayoutModel model)
            {
                if (model is GridLayoutModel)
                {
                    model.Apply();
                }
                else
                {
                    model.Persist();
                }

                Close();
            }
        }
예제 #11
0
        private void Apply()
        {
            EditorOverlay mainEditor = EditorOverlay.Current;

            if (mainEditor.DataContext is LayoutModel model)
            {
                // If custom canvas layout has been scaled, persisting is needed
                if (model is CanvasLayoutModel && (model as CanvasLayoutModel).IsScaled)
                {
                    model.Persist();
                }
                else
                {
                    model.Apply();
                }

                Close();
            }
        }
예제 #12
0
        private void OnStartup(object sender, StartupEventArgs e)
        {
            WaitForPowerToysRunner();

            LayoutModel foundModel = null;

            foreach (LayoutModel model in ZoneSettings.DefaultModels)
            {
                if (model.Type == Settings.ActiveZoneSetLayoutType)
                {
                    // found match
                    foundModel = model;
                    break;
                }
            }

            if (foundModel == null)
            {
                foreach (LayoutModel model in Settings.CustomModels)
                {
                    if ("{" + model.Guid.ToString().ToUpper() + "}" == Settings.ActiveZoneSetUUid.ToUpper())
                    {
                        // found match
                        foundModel = model;
                        break;
                    }
                }
            }

            if (foundModel == null)
            {
                foundModel = ZoneSettings.DefaultModels[0];
            }

            foundModel.IsSelected = true;

            EditorOverlay overlay = new EditorOverlay();

            overlay.Show();
            overlay.DataContext = foundModel;
        }
예제 #13
0
        protected void OnSaveApplyTemplate(object sender, RoutedEventArgs e)
        {
            EditorOverlay mainEditor = EditorOverlay.Current;

            if (mainEditor.DataContext is LayoutModel model)
            {
                // If new custom Canvas layout is created (i.e. edited Blank layout),
                // it's type needs to be updated
                if (model.Type == LayoutType.Blank)
                {
                    model.Type = LayoutType.Custom;
                }

                model.Persist();
            }

            LayoutModel.SerializeDeletedCustomZoneSets();

            _backToLayoutPicker = false;
            Close();
            EditorOverlay.Current.Close();
        }