Esempio n. 1
0
        public UiMainWindow()
        {
            #region Construct

            Assembly        assembly = Assembly.GetEntryAssembly();
            FileVersionInfo fvi      = FileVersionInfo.GetVersionInfo(assembly.Location);
            Title = $"{fvi.ProductName} {fvi.FileVersion} {fvi.LegalCopyright}";

            Width  = 640;
            Height = 480;
            WindowStartupLocation = WindowStartupLocation.CenterScreen;
            WindowState           = WindowState.Maximized;

            UiGrid root = UiGridFactory.Create(2, 1);
            root.RowDefinitions[0].Height = GridLength.Auto;

            DockingManager dockingManager = new DockingManager();
            {
                root.AddUiElement(dockingManager, 1, 0);
                _layoutSerializer = new XmlLayoutSerializer(dockingManager);
                _layoutSerializer.LayoutSerializationCallback += OnLayoutDeserialized;
            }

            _mainMenu = UiMenuFactory.Create();
            {
                _mainMenuView = _mainMenu.AddChild(UiMenuItemFactory.Create("Вид"));
                {
                    foreach (UiMainDockableControl dockable in UiMainDockableControl.CreateKnownDockables(dockingManager))
                    {
                        _mainMenuView.AddChild(dockable.CreateMenuItem());
                    }
                }

                root.AddUiElement(_mainMenu, 0, 0);
            }

            Content = root;

            #endregion

            Loaded  += OnLoaded;
            Closing += OnClosing;
        }
Esempio n. 2
0
        public static UiMainDockableControl[] CreateKnownDockables(DockingManager dockingManager)
        {
            Type     currentType     = typeof(UiMainDockableControl);
            Assembly currentAssymbly = Assembly.GetExecutingAssembly();

            Type[] types = currentAssymbly.GetTypes();
            SortedList <int, UiMainDockableControl> list = new SortedList <int, UiMainDockableControl>();

            foreach (Type type in types)
            {
                if (!type.IsSubclassOf(currentType))
                {
                    continue;
                }

                UiMainDockableControl dockableControl = (UiMainDockableControl)Activator.CreateInstance(type);
                dockableControl.DockingManager = dockingManager;
                list.Add(dockableControl.Index, dockableControl);
            }
            return(list.Values.ToArray());
        }
Esempio n. 3
0
            public void Execute(object parameter)
            {
                UiMainDockableControl window = (UiMainDockableControl)parameter;

                window.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                window.VerticalAlignment   = System.Windows.VerticalAlignment.Stretch;
                lock (window._lock)
                {
                    LayoutAnchorable layout = window.LayoutAnchorable ?? (window.LayoutAnchorable = window.DockingManager.Layout.Descendents().OfType <LayoutAnchorable>().FirstOrDefault(l => l.Title == window.Header));
                    if (layout == null)
                    {
                        layout = new LayoutAnchorable
                        {
                            ContentId      = window.Header,
                            Title          = window.Header,
                            FloatingWidth  = window.Width,
                            FloatingHeight = window.Height,
                            FloatingLeft   = 200,
                            FloatingTop    = 200,
                            Content        = window
                        };

                        window.LayoutAnchorable = layout;
                        layout.AddToLayout(window.DockingManager, AnchorableShowStrategy.Most);
                        layout.Float();
                    }
                    else
                    {
                        if (layout.IsHidden)
                        {
                            layout.Show();
                        }
                        else
                        {
                            layout.Hide();
                        }
                    }
                }
            }