Ejemplo n.º 1
0
        public Layouts ReadConfig(LayoutsConfig config)
        {
            var layouts = new Layouts();

            foreach (var layoutConfig in config)
            {
                var layout = new Layout
                {
                    LayoutId = layoutConfig.LayoutId,
                    Title    = layoutConfig.Title
                };

                foreach (var itemConfig in layoutConfig.Items)
                {
                    var layoutItem = new LayoutItem
                    {
                        Icon        = itemConfig.Icon,
                        IconRunning = itemConfig.IconRunning,
                        Text        = itemConfig.Text
                    };

                    var actionType = Assembly.GetExecutingAssembly().GetType(itemConfig.Action);
                    var action     = (InterfaceAction)Activator.CreateInstance(actionType, itemConfig.Arguments);
                    layoutItem.Action = action;

                    layout.Items.Add(layoutItem);
                }

                layouts.Add(layout);
            }
            return(layouts);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initialize a new instance of the MetaDockPanel class.
        /// </summary>
        public MetaDockPanel()
        {
            DockLayout layout = new DockLayout();

            layout.SetBinding(DockLayout.LastChildFillProperty, ThisBinding("LastChildFill"));
            Layouts.Add(layout);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initialize a new instance of the MetaUniformGridPanel class.
        /// </summary>
        public MetaUniformGridPanel()
        {
            UniformGridLayout layout = new UniformGridLayout();

            layout.SetBinding(UniformGridLayout.RowsProperty, ThisBinding("Rows"));
            layout.SetBinding(UniformGridLayout.ColumnsProperty, ThisBinding("Columns"));
            layout.SetBinding(UniformGridLayout.FirstColumnProperty, ThisBinding("FirstColumn"));
            Layouts.Add(layout);
        }
        private void OnAdd()
        {
            Layout newLayout = new Layout(
                $"Layout {Layouts.Count + 1}", 0, 0, 70.0, 29.7, 2.0, 2.0);

            Layouts.Add(newLayout);
            SelectedLayout = newLayout;
            TempLayout.Set(newLayout);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initialize a new instance of the MetaRadialPanel class.
        /// </summary>
        public MetaRadialPanel()
        {
            RadialLayout layout = new RadialLayout();

            layout.SetBinding(RadialLayout.StartAngleProperty, ThisBinding("StartAngle"));
            layout.SetBinding(RadialLayout.EndAngleProperty, ThisBinding("EndAngle"));
            layout.SetBinding(RadialLayout.CircleProperty, ThisBinding("Circle"));
            Layouts.Add(layout);
        }
Ejemplo n.º 6
0
        public void Add(ILayout layout)
        {
            // Do this first, in case this throws an error
            if (!layout.Shortcut.IsEmpty())
            {
                keyboard_hook.RegisterHotKey(layout.Shortcut);
            }

            Layouts.Add(layout);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Initialize a new instance of the MetaWrapPanel class.
        /// </summary>
        public MetaWrapPanel()
        {
            WrapLayout layout = new WrapLayout();

            layout.SetBinding(WrapLayout.ItemWidthProperty, ThisBinding("ItemWidth"));
            layout.SetBinding(WrapLayout.ItemHeightProperty, ThisBinding("ItemHeight"));
            layout.SetBinding(WrapLayout.OrientationProperty, ThisBinding("Orientation"));
            layout.SetBinding(WrapLayout.BreakAfterProperty, ThisBinding("BreakAfter"));
            Layouts.Add(layout);
        }
Ejemplo n.º 8
0
 public void UpdateLayouts()
 {
     foreach (Pair <VirtualDesktop, HMONITOR> desktopMonitor in Windows.Keys)
     {
         if (!Layouts.ContainsKey(desktopMonitor))
         {
             Layouts.Add(desktopMonitor, Layout.Tall);
         }
     }
 }
        /// <summary> Add a new item layout configuration </summary>
        /// <param name="Layout"> Object with all the layout details </param>
        public void Add_Layout(ItemWriterLayoutConfig Layout)
        {
            // Ensure the dictionary is built
            if (layoutsLookup == null)
            {
                layoutsLookup = new Dictionary <string, ItemWriterLayoutConfig>(StringComparer.OrdinalIgnoreCase);
            }

            // Ensure all items in the list are in the dictionary
            if (layoutsLookup.Count != Layouts.Count)
            {
                layoutsLookup.Clear();
                foreach (ItemWriterLayoutConfig exstingConfig in Layouts)
                {
                    layoutsLookup[exstingConfig.ID] = exstingConfig;

                    if (exstingConfig.Default)
                    {
                        defaultLayout = exstingConfig;
                    }
                }
            }

            // Did this already exist?
            if (layoutsLookup.ContainsKey(Layout.ID))
            {
                ItemWriterLayoutConfig existing = null;
                foreach (ItemWriterLayoutConfig thisOne in Layouts)
                {
                    if (String.Compare(thisOne.ID, Layout.ID, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        existing = thisOne;
                        break;
                    }
                }
                if (existing != null)
                {
                    Layouts.Remove(existing);
                }
                layoutsLookup.Remove(Layout.ID);
            }

            // Add this
            layoutsLookup[Layout.ID] = Layout;
            Layouts.Add(Layout);

            // Was this the new default?
            if (Layout.Default)
            {
                defaultLayout = Layout;
            }
        }
Ejemplo n.º 10
0
        public Layout CreateLayout(string name, int gridSizeX, int gridSizeY)
        {
            var id_ = (from y in Layouts
                       select(int?) y.Id).Max();

            var id = id_ ?? 0;

            var l = new Layout(id, name, gridSizeX, gridSizeY);

            Layouts.Add(l);

            return(l);
        }
        private void OnFileNameChanged(object sender, EventArgs e)
        {
            ExcelSelected = false;
            if (excelPathVM.FileNameIsValid)
            {
                string path = excelPathVM.FileName;

                if (File.Exists(path))
                {
                    FileStream fs = null;
                    try
                    {
                        fs = File.Open(path, FileMode.Open, FileAccess.Read);
                    }
                    catch (System.IO.IOException ex)
                    {
                        AccessException(ex);
                    }
                    if (fs != null)
                    {
                        IExcelDataReader reader = null;
                        switch (Path.GetExtension(path))
                        {
                        case ".xls":
                            reader = ExcelReaderFactory.CreateBinaryReader(fs);
                            break;

                        case ".xlsx":
                            reader = ExcelReaderFactory.CreateOpenXmlReader(fs);
                            break;
                        }
                        if (reader != null)
                        {
                            DataSet result = reader.AsDataSet();
                            reader.Close();

                            Layouts.Clear();
                            foreach (DataTable table in result.Tables)
                            {
                                Layouts.Add(table);
                            }
                            ExcelSelected = true;
                        }
                    }
                }
            }

            OnPropertyChanged("ExcelSelected");
        }
Ejemplo n.º 12
0
        public void Apply(InputElement[] elements)
        {
            if (!Layouts.TryGetValue(elements, out var layout))
            {
                layout = new InputLayout(Device.NativeDevice, Signature, elements);
                Layouts.Add(elements, layout);
            }

            Device.NativeDeviceContext.InputAssembler.InputLayout = layout;
            Device.NativeDeviceContext.VertexShader.Set(VertexShader);
            Device.NativeDeviceContext.PixelShader.Set(PixelShader);
            Device.NativeDeviceContext.GeometryShader.Set(GeometryShader);
            Device.NativeDeviceContext.DomainShader.Set(null);
            Device.NativeDeviceContext.HullShader.Set(null);
        }
Ejemplo n.º 13
0
        internal void InitBaseData()
        {
            if (!Maps.Any())
            {
                var lines = File.ReadAllLines("SquadMaps.csv").Skip(1);
                foreach (var line in lines)
                {
                    var items = line.Split(';');
                    Maps.Add(new GameMap()
                    {
                        Name   = items[0],
                        Region = Enum.Parse <GameMapRegion>(items[1]),
                    });
                }
                SaveChanges();
            }
            if (!Layouts.Any())
            {
                var lines = File.ReadAllLines("SquadLayouts.csv").Skip(1);
                foreach (var line in lines)
                {
                    var items = line.Split(';');
                    var name  = items[0];
                    Layouts.Add(new GameLayout()
                    {
                        Name      = name,
                        Left      = !string.IsNullOrEmpty(items[1]) ? (Faction?)Enum.Parse <Faction>(items[1]) : null,
                        Right     = !string.IsNullOrEmpty(items[2]) ? (Faction?)Enum.Parse <Faction>(items[2]) : null,
                        Thumbnail = items[3],
                        MapFull   = items[4],
                        GameMap   = Maps.FirstOrDefault(m => name.Contains(m.Name)) ?? Maps.FirstOrDefault(m => m.Region == GameMapRegion.Training)
                    });
                }
                SaveChanges();
            }

            if (!Users.Any())
            {
                for (int i = 1; i <= 80; ++i)
                {
                    Users.Add(new User()
                    {
                        Name = $"User {i}", SteamId = "XXXXXXXXX"
                    });
                    SaveChanges();
                }
            }
        }
Ejemplo n.º 14
0
        public ManageWindowLayoutsDialogViewModel(IEnumerable <Pair <string, Keys> > layouts)
        {
            Title = "Select a layout";

            RenameCommand = new DelegateCommand <LayoutSlot>(Rename, CanRename, false);
            DeleteCommand = new DelegateCommand <LayoutSlot>(Delete, CanDelete, false);

            foreach (var layout in layouts)
            {
                var slot = new LayoutSlot(this, layout.First, layout.Second);
                slot.Renamed += SlotRenamed;
                Layouts.Add(slot);
            }

            LayoutView = CollectionViewSource.GetDefaultView(Layouts);
        }
        public Linclon2020March()
        {
            Name         = "Newark - Lincoln Model Rail Club General Exhibition";
            Location     = new NewarkShowground();
            EventDates   = "Saturday 29th February & Sunday 1st March 2020";
            Descrption   = "Lincoln Model Rail Club General Exhibition";
            ImagesPath   = Constants.RawDataPath + @"ModelEvents\2020-02-29 NewarkLincolnModelRailClub";
            TripDate     = new DateTime(2020, 02, 29);
            YouTubeLink  = "https://www.youtube.com/embed/gHkPSd4i8_0";
            ImageFolder  = "20200229-Newark";
            Title        = "Lincoln Model Rail Club General Exhibition 2020";
            ImagePreview = "P2298149-Dorehill-sT-Lincoln-model-rail-club.Stephens-Lincoln-model-rail-club-thumb.JPG";

            Layouts.Add(new LayoutDetails("Ambleton Vale", Gauges.N_Gauge, "Ambleton Vale"));
            Layouts.Add(new LayoutDetails("Arnold Lane", Gauges.OO_Gauge, "Arnold Lane"));
            Layouts.Add(new LayoutDetails("Barden", Gauges.O_Gauge, "Barden"));
            Layouts.Add(new LayoutDetails("Bedford Road", Gauges.O_Gauge, "Bedford Road"));
            Layouts.Add(new LayoutDetails("Blackgang", Gauges.NONE, "Blackgang"));
            Layouts.Add(new LayoutDetails("Breydon", Gauges.OO_Gauge, "Breydon"));
            Layouts.Add(new LayoutDetails("Caroline Concrete Works", Gauges.NONE, "Caroline Concrete Works"));
            Layouts.Add(new LayoutDetails("Croft Mill Wharf", Gauges.O_Gauge, "Croft Mill Wharf"));
            Layouts.Add(new LayoutDetails("Croft SPA", Gauges.N_Gauge, "Croft SPA"));
            Layouts.Add(new LayoutDetails("Cumanavago", Gauges.OO_Gauge));
            Layouts.Add(new LayoutDetails("Dorehill ST. Stephens", Gauges.OO_Gauge, "Dorehill ST. Stephens"));
            Layouts.Add(new LayoutDetails("Emsworth", Gauges.OO_Gauge, "Emsworth"));
            Layouts.Add(new LayoutDetails("Glenellen Castle", Gauges.N_Gauge, "Glenellen Castle"));
            Layouts.Add(new LayoutDetails("Hartley Poole", Gauges.N_Gauge, "Hartley Poole"));
            Layouts.Add(new LayoutDetails("Hollington Quarry", Gauges.OO9_Gauge));
            Layouts.Add(new LayoutDetails("Kleine Rundfahrt", Gauges.N_Gauge_Continental, "Kleine Rundfahrt"));
            Layouts.Add(new LayoutDetails("Kozel Cement", Gauges.HO_Gauge));
            Layouts.Add(new LayoutDetails("Norman Colliery", Gauges.O_Gauge, "Norman Colliery"));
            Layouts.Add(new LayoutDetails("Northallerton", Gauges.N_Gauge, "Northallerton"));
            Layouts.Add(new LayoutDetails("Obervaz", Gauges.H0mNarrowGauge, "Obervaz"));
            Layouts.Add(new LayoutDetails("Roberts Road", Gauges.N_Gauge, "Roberts Road"));
            Layouts.Add(new LayoutDetails("Salthaven Quay", Gauges.O_Gauge, "Salthaven Quay"));
            Layouts.Add(new LayoutDetails("Shaken & Not Stirred", Gauges.NONE));
            Layouts.Add(new LayoutDetails("Spilsby", Gauges.NONE, "Spilsby"));
            Layouts.Add(new LayoutDetails("Stamford East", Gauges.N_Gauge, "Stamford East"));
            Layouts.Add(new LayoutDetails("The Power Station", Gauges.N_Gauge, "The Power Station"));
            Layouts.Add(new LayoutDetails("Thorncliffe", Gauges.OO_Gauge, "Thorncliffe"));
            Layouts.Add(new LayoutDetails("Welby Lane", Gauges.NONE, "Welby Lane"));
            Layouts.Add(new LayoutDetails("Worlds Way", Gauges.OO_Gauge, "Worlds Way"));
            Layouts.Add(new LayoutDetails(LayoutNames.Myton, Gauges.OO_Gauge, "Myton"));

            Keywords.AddRange(ModelEventKeywords());
            Keywords.AddRange(new string[] { "Linclon", "L&DMRC", "Lincoln Model Rail Club", "Newark Showground", "General Exhibition" });
        }
        private void DrawMonitor(KeyValuePair <Pair <VirtualDesktop, HMONITOR>, ObservableCollection <DesktopWindow> > desktopMonitor, out float ScreenScalingFactorVert, out int mX, out int mY, out IEnumerable <Rectangle> gridGenerator)
        {
            HMONITOR m            = desktopMonitor.Key.Item2;
            int      windowsCount = desktopMonitor.Value.Count();

            User32.MONITORINFOEX info = new User32.MONITORINFOEX();
            info.cbSize = (uint)Marshal.SizeOf(info);
            User32.GetMonitorInfo(m, ref info);

            Gdi32.SafeHDC hdc = Gdi32.CreateDC(info.szDevice);
            int           LogicalScreenHeight  = Gdi32.GetDeviceCaps(hdc, Gdi32.DeviceCap.VERTRES);
            int           PhysicalScreenHeight = Gdi32.GetDeviceCaps(hdc, Gdi32.DeviceCap.DESKTOPVERTRES);
            int           LogicalScreenWidth   = Gdi32.GetDeviceCaps(hdc, Gdi32.DeviceCap.HORZRES);
            int           PhysicalScreenWidth  = Gdi32.GetDeviceCaps(hdc, Gdi32.DeviceCap.DESKTOPHORZRES);

            hdc.Close();

            float ScreenScalingFactorHoriz = (float)PhysicalScreenWidth / (float)LogicalScreenWidth;

            ScreenScalingFactorVert = (float)PhysicalScreenHeight / (float)LogicalScreenHeight;
            mX = info.rcWork.X + MarginLeft;
            mY = info.rcWork.Y + MarginTop;
            int mWidth  = info.rcWork.Width - MarginLeft - MarginRight;
            int mHeight = info.rcWork.Height - MarginTop - MarginBottom;

            Layout mCurrentLayout;

            try
            {
                mCurrentLayout = Layouts[desktopMonitor.Key];
            }
            catch
            {
                Layouts.Add(desktopMonitor.Key, Layout.Tall);
                mCurrentLayout = Layouts[desktopMonitor.Key];
            }

            if (!Factors.ContainsKey(desktopMonitor.Key))
            {
                Factors[desktopMonitor.Key] = 0;
            }

            gridGenerator = GridGenerator(mWidth, mHeight, windowsCount, Factors[desktopMonitor.Key], mCurrentLayout, LayoutPadding);
        }
        internal void InitializeLayouts()
        {
            Logger.Info("Loading window layouts.");

            Layouts.Clear();

            try
            {
                // Load factory presets.
                string applicationFolder = EditorHelper.GetUserSettingsFolder(ConfigurationUserLevel.None);
                string layoutsFolder     = Path.Combine(applicationFolder, LayoutsFolder, PresetsFolder);
                Layouts.AddRange(Directory.EnumerateFiles(layoutsFolder, LayoutPattern)
                                 .Select(Path.GetFileNameWithoutExtension)
                                 .Select(name => new WindowLayout(name, true)));
            }
            catch (Exception exception)
            {
                Logger.Warn(exception, "Failed to load factory presets.");
            }

            try
            {
                // Load user presets.
                string applicationFolder = EditorHelper.GetUserSettingsFolder(ConfigurationUserLevel.PerUserRoamingAndLocal);
                string layoutsFolder     = Path.Combine(applicationFolder, LayoutsFolder, PresetsFolder);
                Layouts.AddRange(Directory.EnumerateFiles(layoutsFolder, LayoutPattern)
                                 .Select(Path.GetFileNameWithoutExtension)
                                 .Select(name => new WindowLayout(name, false)));
            }
            catch (Exception exception)
            {
                Logger.Warn(exception, "Failed to load user presets.");
            }

            // Add a dummy entry, if no presets are available.
            if (Layouts.Count == 0)
            {
                Layouts.Add(new WindowLayout(DefaultLayout, true));
            }

            // The window layout will be loaded in OnEditorActivated().
            ActiveLayout = null;
        }
        public Linclon2019()
        {
            Name         = "Newark - Lincoln Model Rail Club Post Modernisation Exhibition";
            Location     = new NewarkShowground();
            EventDates   = "19th and 20th October 2019";
            Descrption   = "Lincoln Model Rail Club Post Modernisation Exhibition";
            ImagesPath   = Constants.RawDataPath + @"ModelEvents\2019-10-19 Newark Model LincolnModelRailClub";
            TripDate     = new DateTime(2019, 10, 19);
            YouTubeLink  = "https://www.youtube.com/embed/sfhv8iYXiYU";
            ImageFolder  = "20191019-Lincoln";
            Title        = "Lincoln Model Rail Club 2019";
            ImagePreview = "PA196601-Newark-Model-Lincoln-model-rail-club-Crimson-road-thumb.JPG";

            Keywords.AddRange(ModelEventKeywords());
            Keywords.AddRange(new string[] { "Linclon", "Lincoln Model Rail Club", "Newark Showground", "Post Modernisation Exhibition" });

            Layouts.Add(new LayoutDetails("Crimson Road", Gauges.NONE, "CrimsonRoad"));
            Layouts.Add(new LayoutDetails("Cumanavago", Gauges.NONE, "Cumanavago"));
            Layouts.Add(new LayoutDetails("Dovington Camp", Gauges.NONE, "DovingtonCamp"));
            Layouts.Add(new LayoutDetails("Eight Dollar Canyon", Gauges.NONE, "EightDollarCanyon"));
            Layouts.Add(new LayoutDetails("Euxton Junction", Gauges.NONE, "EuxtonJunction"));
            Layouts.Add(new LayoutDetails("Gillingbourne", Gauges.NONE, "Gillingbourne"));
            Layouts.Add(new LayoutDetails("Holland Beck", Gauges.NONE, "HollandBeck"));
            Layouts.Add(new LayoutDetails("Illie Town", Gauges.NONE, "IllieTown"));
            Layouts.Add(new LayoutDetails("K Street Yard", Gauges.NONE, "KStreetYard"));
            Layouts.Add(new LayoutDetails("Lea Green Yard", Gauges.NONE, "LeaGreenYard"));
            Layouts.Add(new LayoutDetails("Loch Tat", Gauges.NONE, "LochTat"));
            Layouts.Add(new LayoutDetails("Low Moor", Gauges.NONE, "LowMoor"));
            Layouts.Add(new LayoutDetails("Lynchwood Sidings", Gauges.NONE, "LynchwoodSidings"));
            Layouts.Add(new LayoutDetails("Norton Folgate", Gauges.NONE, "NortonFolgate"));
            Layouts.Add(new LayoutDetails("Oil DrumLane", Gauges.NONE, "OilDrumLane"));
            Layouts.Add(new LayoutDetails("Penna Lane", Gauges.NONE, "PennaLane"));
            Layouts.Add(new LayoutDetails("Sutherland Street", Gauges.NONE, "SutherlandStreet"));
            Layouts.Add(new LayoutDetails("Titheridge Junction", Gauges.NONE, "TitheridgeJunction"));
            Layouts.Add(new LayoutDetails("Weaver Hill", Gauges.NONE, "WeaverHill"));
            Layouts.Add(new LayoutDetails("West Street Station", Gauges.NONE, "WestStreetStation"));
            Layouts.Add(new LayoutDetails("Zlata Vychod", Gauges.NONE, "ZlataVychod"));
        }
Ejemplo n.º 19
0
        public DomainObject1PivotGridSetup()
        {
            Layouts.Add(new PivotGridLayout(Default1LayoutName, LayoutFields));
            Layouts.Add(new PivotGridLayout(Default2LayoutName, LayoutFields));

            TranYearField               = new PivotGridFieldBase("TranDate", PivotArea.FilterArea);
            TranYearField.Name          = "fieldTranYear";
            TranYearField.Caption       = "Tran Year";
            TranYearField.GroupInterval = PivotGroupInterval.DateYear;
            Fields.Add(TranYearField);

            TranDateField         = new PivotGridFieldBase("TranDate", PivotArea.FilterArea);
            TranDateField.Name    = "fieldTranDate";
            TranDateField.Caption = "Tran Date";
            TranDateField.ValueFormat.FormatType   = DevExpress.Utils.FormatType.Custom;
            TranDateField.ValueFormat.FormatString = "{0:dd-MMM-yy}";
            Fields.Add(TranDateField);

            NameField         = new PivotGridFieldBase("Name", PivotArea.ColumnArea);
            NameField.Name    = "fieldName";
            NameField.Caption = "My Name";
            Fields.Add(NameField);

            Category1Field         = new PivotGridFieldBase("Category1", PivotArea.ColumnArea);
            Category1Field.Name    = "fieldCategory1";
            Category1Field.Caption = "My Category1";
            Fields.Add(Category1Field);

            Category2Field         = new PivotGridFieldBase("Category2", PivotArea.ColumnArea);
            Category2Field.Name    = "fieldCategory2";
            Category2Field.Caption = "My Category2";
            Fields.Add(Category2Field);

            AmountField = new PivotGridFieldBase("Amount", PivotArea.ColumnArea);
            //AmountField.Name = "fieldAmount";
            AmountField.Caption = "My Amount";
            Fields.Add(AmountField);
        }
Ejemplo n.º 20
0
 /// <summary>
 /// Initialize a new instance of the MetaCanvasPanel class.
 /// </summary>
 public MetaCanvasPanel()
 {
     Layouts.Add(new CanvasLayout());
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Initialize a new instance of the MetaGridPanel class.
 /// </summary>
 public MetaGridPanel()
 {
     _layout = new GridLayout();
     Layouts.Add(_layout);
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Initialize a new instance of the MetaStretchPanel class.
 /// </summary>
 public MetaStretchPanel()
 {
     Layouts.Add(new StretchLayout());
 }
Ejemplo n.º 23
0
 public void AddLayout(RenderLayout layout)
 {
     layout.Parent = this;
     Layouts.Add(layout);
 }
Ejemplo n.º 24
0
 private CodeFrame(Op op) : this()
 {
     Ops.Add(op);
     OpData.Add(0);
     Layouts.Add(new MemoryLayout(0, 0, 0));
 }
        private void SavePresetAs()
        {
            Logger.Info("Saving window layout as new preset.");

ShowSaveLayoutDialog:
            var saveLayoutDialog = new SaveLayoutViewModel
            {
                DisplayName = "Save Window Layout",
                LayoutName  = "New layout"
            };

            string       layoutName     = null;
            WindowLayout existingLayout = null;
            var          result         = _windowService.ShowDialog(saveLayoutDialog);

            if (result.HasValue && result.Value)
            {
                Debug.Assert(!string.IsNullOrEmpty(saveLayoutDialog.LayoutName), "The layout name must not be null or empty.");
                Debug.Assert(saveLayoutDialog.LayoutName.IndexOfAny(Path.GetInvalidFileNameChars()) == -1, "The layout name must not contain invalid characters.");

                layoutName = saveLayoutDialog.LayoutName;

                // Overwrite existing window layout?
                existingLayout = Layouts.FirstOrDefault(l => string.Compare(l.Name, layoutName, StringComparison.OrdinalIgnoreCase) == 0);
                if (existingLayout != null)
                {
                    if (existingLayout.IsFactoryPreset)
                    {
                        MessageBox.Show(
                            $"\"{layoutName}\" is a factory preset. Factory presets cannot be overwritten.",
                            Editor.ApplicationName, MessageBoxButton.OK, MessageBoxImage.Exclamation);

                        // Try again.
                        goto ShowSaveLayoutDialog;
                    }
                    else
                    {
                        var messageBoxResult = MessageBox.Show(
                            $"The layout \"{layoutName}\" already exists. Overwrite existing?",
                            Editor.ApplicationName, MessageBoxButton.YesNoCancel, MessageBoxImage.Exclamation);

                        if (messageBoxResult == MessageBoxResult.No)
                        {
                            // Try again.
                            goto ShowSaveLayoutDialog;
                        }

                        if (messageBoxResult == MessageBoxResult.Cancel)
                        {
                            // Abort.
                            layoutName = null;
                        }
                    }
                }
            }

            if (!string.IsNullOrEmpty(layoutName))
            {
                try
                {
                    // Save window layout as new preset.
                    var serializedLayout = Editor.SaveLayout(true);
                    var layout           = new WindowLayout(layoutName, false)
                    {
                        SerializedLayout = serializedLayout
                    };
                    SaveUserPreset(layout);

                    if (existingLayout != null)
                    {
                        Layouts.Remove(existingLayout);
                    }

                    Layouts.Add(layout);
                    ActiveLayout = layout;
                    UpdateWindowLayoutItem();
                }
                catch (Exception exception)
                {
                    Logger.Error(exception, "Could not save window layout as new preset \"{0}\".", layoutName);

                    string message = $"Could not save window layout as new preset \"{layoutName}\".\n\n{exception.Message}";
                    MessageBox.Show(message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }