Пример #1
0
        public void ShowStartView <TStartWindow, TStartView>(
            UiShowStartWindowOptions options = null)
            where TStartWindow : class
            where TStartView : class, IView
        {
            if (options != null)
            {
                ToolPaneWidth = options.ToolPaneWidth;
            }

            var startObject = Container.Resolve <TStartWindow>();

            if (startObject == null)
            {
                throw new InvalidOperationException($"You shuld configurate {typeof(TStartWindow)}");
            }

            var window = startObject as Window;

            if (window == null)
            {
                throw new InvalidCastException($"{startObject.GetType()} is not a window");
            }

            ShowView <TStartView>();

            window.Show();
        }
Пример #2
0
 public void ShowStartView <TStartWindow>(
     UiShowStartWindowOptions options = null)
     where TStartWindow : class
 {
     InitOnStart <TStartWindow>(options);
     Window.Show();
 }
Пример #3
0
        public static IShell Start <TStartWindow>(IBootstraper bootstraper, UiShowStartWindowOptions options = null)
            where TStartWindow : class
        {
            var shell = bootstraper.Init();

            shell.ShowStartView <TStartWindow>(options);

            return(shell);
        }
Пример #4
0
        private void InitOnStart <TStartWindow>(UiShowStartWindowOptions options)
            where TStartWindow : class
        {
            if (options != null)
            {
                Title = options.Title;
            }

            DockingManager = options?.DockingManager ?? new DefaultDockingManager();
            IDisposable dockingManagerSubscription = null;
            Dictionary <ILayoutPane, LayoutContent> placeholders = null;

            this.WhenAnyValue(x => x.DockingManager)
            .Subscribe(dm =>
            {
                if (placeholders != null)
                {
                    foreach (var placeholder in placeholders.Values)
                    {
                        placeholder.Close();
                    }
                }

                dockingManagerSubscription?.Dispose();
                if (dm == null)
                {
                    return;
                }
                dockingManagerSubscription = Observable
                                             .FromEventPattern(
                    x => dm.ActiveContentChanged += x,
                    x => dm.ActiveContentChanged -= x)
                                             .Select(x => ((DockingManager)x.Sender).ActiveContent as IView)
                                             .Subscribe(x => SelectedView = x);

                var dmDescendents = dm.Layout.Descendents().ToList();
                placeholders      = dmDescendents
                                    .OfType <DependencyObject>()
                                    .Where(x => !string.IsNullOrEmpty(DockContainer.GetName(x)))
                                    .OfType <ILayoutPane>()
                                    .ToDictionary(
                    x => x,
                    x =>
                {
                    var content = new LayoutAnchorable();
                    switch (x)
                    {
                    case LayoutGroup <LayoutAnchorable> la:
                        la.Children.Add(content);
                        break;

                    case LayoutGroup <LayoutContent> ld:
                        ld.Children.Add(content);
                        break;
                    }

                    content.IsVisible = false;

                    return((LayoutContent)content);
                });
            });

            var startObject = Container.Resolve <TStartWindow>() ??
                              throw new InvalidOperationException(
                                        $"You should register {typeof(TStartWindow)} in container");

            Window = startObject as Window ??
                     throw new InvalidCastException($"{startObject.GetType()} is not a window");
        }