Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ShellWindow"/> class.
        /// </summary>
        public ShellWindow()
        {
            var serviceLocator = ServiceLocator.Default;

            var themeService = serviceLocator.ResolveType <IThemeService>();

            ThemeHelper.EnsureApplicationThemes(GetType().Assembly, themeService.ShouldCreateStyleForwarders());

            InitializeComponent();

            serviceLocator.RegisterInstance(pleaseWaitProgressBar, "pleaseWaitService");

            var statusService = serviceLocator.ResolveType <IStatusService>();

            statusService.Initialize(statusTextBlock);

            var dependencyResolver = this.GetDependencyResolver();
            var ribbonService      = dependencyResolver.Resolve <IRibbonService>();

            var ribbonContent = ribbonService.GetRibbon();

            if (ribbonContent != null)
            {
                ribbonContentControl.Content = ribbonContent;
            }

            var statusBarContent = ribbonService.GetStatusBar();

            if (statusBarContent != null)
            {
                customStatusBarItem.Content = statusBarContent;
            }

            contentControl.Content = ribbonService.GetMainView();
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ShellWindow"/> class.
        /// </summary>
        public ShellWindow()
        {
            ThemeHelper.EnsureApplicationThemes(GetType().Assembly, true);

            InitializeComponent();

            var serviceLocator = ServiceLocator.Default;
            var statusService  = serviceLocator.ResolveType <IStatusService>();

            statusService.Initialize(statusTextBlock);

            var dependencyResolver = this.GetDependencyResolver();
            var ribbonService      = dependencyResolver.Resolve <IRibbonService>();

            var ribbonContent = ribbonService.GetRibbon();

            if (ribbonContent != null)
            {
                ribbonContentControl.Content = ribbonContent;
            }

            var statusBarContent = ribbonService.GetStatusBar();

            if (statusBarContent != null)
            {
                customStatusBarItem.Content = statusBarContent;
            }

            contentControl.Content = ribbonService.GetMainView();
        }
Esempio n. 3
0
        public virtual async Task InitializeBeforeShowingSplashScreenAsync()
        {
            var serviceLocator = this.GetServiceLocator();
            var themeService   = serviceLocator.ResolveType <IThemeService>();

            ThemeHelper.EnsureApplicationThemes(GetType().Assembly, themeService.ShouldCreateStyleForwarders());
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ShellWindow"/> class.
        /// </summary>
        public ShellWindow()
        {
            ThemeHelper.EnsureApplicationThemes(GetType().Assembly, true);

            MahAppsHelper.ApplyTheme();

            InitializeComponent();

            var accentColorBrush = ThemeHelper.GetAccentColorBrush();

            border.BorderBrush = accentColorBrush;

            var serviceLocator = ServiceLocator.Default;
            var statusService  = serviceLocator.ResolveType <IStatusService>();

            statusService.Initialize(statusTextBlock);

            var commandManager = serviceLocator.ResolveType <ICommandManager>();
            var flyoutService  = serviceLocator.ResolveType <IFlyoutService>();
            var mahAppsService = serviceLocator.ResolveType <IMahAppsService>();

            serviceLocator.RegisterInstance <IAboutInfoService>(mahAppsService);

            var flyouts = new FlyoutsControl();

            foreach (var flyout in flyoutService.GetFlyouts())
            {
                flyouts.Items.Add(flyout);
            }

            Flyouts = flyouts;

            var windowCommands = mahAppsService.GetRightWindowCommands();

            if (mahAppsService.GetAboutInfo() != null)
            {
                var aboutWindowCommand = WindowCommandHelper.CreateWindowCommandButton("appbar_information", "about");

                var aboutService = serviceLocator.ResolveType <IAboutService>();
                commandManager.RegisterAction("Help.About", aboutService.ShowAbout);
                aboutWindowCommand.Command = commandManager.GetCommand("Help.About");

                windowCommands.Items.Add(aboutWindowCommand);
            }

            RightWindowCommands = windowCommands;

            var mainView = mahAppsService.GetMainView();

            contentControl.Content = mainView;

            SetBinding(TitleProperty, new Binding("ViewModel.Title")
            {
                Source = mainView
            });
        }
Esempio n. 5
0
        public virtual async Task InitializeBeforeShowingSplashScreenAsync()
        {
            var serviceLocator = this.GetServiceLocator();
            var themeService   = serviceLocator.ResolveType <IThemeService>();

            // Note: we only have to create style forwarders once
            ThemeHelper.EnsureApplicationThemes(typeof(ApplicationInitializationServiceBase).Assembly, false);
            ThemeHelper.EnsureApplicationThemes(GetType().Assembly, false);

            if (themeService.ShouldCreateStyleForwarders())
            {
                StyleHelper.CreateStyleForwardersForDefaultStyles();
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ShellWindow"/> class.
        /// </summary>
        public ShellWindow()
        {
            var serviceLocator = ServiceLocator.Default;

            var themeService = serviceLocator.ResolveType <IThemeService>();

            ThemeHelper.EnsureApplicationThemes(GetType().Assembly, themeService.ShouldCreateStyleForwarders());

            InitializeComponent();

            serviceLocator.RegisterInstance(pleaseWaitProgressBar, "pleaseWaitService");

            var statusService = serviceLocator.ResolveType <IStatusService>();

            statusService.Initialize(statusTextBlock);

            var dependencyResolver = this.GetDependencyResolver();
            var ribbonService      = dependencyResolver.Resolve <IRibbonService>();

            var ribbonContent = ribbonService.GetRibbon();

            if (ribbonContent != null)
            {
                ribbonContentControl.SetCurrentValue(ContentProperty, ribbonContent);

                var ribbon = ribbonContent.FindVisualDescendantByType <Fluent.Ribbon>();
                if (ribbon != null)
                {
                    serviceLocator.RegisterInstance <Fluent.Ribbon>(ribbon);
                }
            }

            var statusBarContent = ribbonService.GetStatusBar();

            if (statusBarContent != null)
            {
                customStatusBarItem.SetCurrentValue(ContentProperty, statusBarContent);
            }

            var mainView = ribbonService.GetMainView();

            contentControl.Content = mainView;

            ShellDimensionsHelper.ApplyDimensions(this, mainView);
        }
Esempio n. 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ShellWindow"/> class.
        /// </summary>
        public ShellWindow()
        {
            var serviceLocator = ServiceLocator.Default;

            var themeService = serviceLocator.ResolveType <IThemeService>();

            ThemeHelper.EnsureApplicationThemes(GetType().Assembly, themeService.ShouldCreateStyleForwarders());

            // Required for Fluent accent color
            var accentColor          = ThemeHelper.GetAccentColor();
            var applicationResources = Application.Current.Resources;

            applicationResources.Add(MetroColors.ThemeColorKey, accentColor);

            InitializeComponent();

            serviceLocator.RegisterInstance(pleaseWaitProgressBar, "pleaseWaitService");

            var statusService = serviceLocator.ResolveType <IStatusService>();

            statusService.Initialize(statusTextBlock);

            var dependencyResolver = this.GetDependencyResolver();
            var ribbonService      = dependencyResolver.Resolve <IRibbonService>();

            var ribbonContent = ribbonService.GetRibbon();

            if (ribbonContent != null)
            {
                ribbonContentControl.SetCurrentValue(ContentProperty, ribbonContent);
            }

            var statusBarContent = ribbonService.GetStatusBar();

            if (statusBarContent != null)
            {
                customStatusBarItem.SetCurrentValue(ContentProperty, statusBarContent);
            }

            contentControl.Content = ribbonService.GetMainView();
        }
Esempio n. 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ShellWindow"/> class.
        /// </summary>
        public ShellWindow()
        {
            ThemeHelper.EnsureApplicationThemes(GetType().Assembly, true);

            // Required for Fluent accent color
            var accentColor          = ThemeHelper.GetAccentColor();
            var applicationResources = Application.Current.Resources;

            applicationResources.Add(MetroColors.ThemeColorKey, accentColor);

            InitializeComponent();

            var serviceLocator = ServiceLocator.Default;
            var statusService  = serviceLocator.ResolveType <IStatusService>();

            statusService.Initialize(statusTextBlock);

            var dependencyResolver = this.GetDependencyResolver();
            var ribbonService      = dependencyResolver.Resolve <IRibbonService>();

            var ribbonContent = ribbonService.GetRibbon();

            if (ribbonContent != null)
            {
                ribbonContentControl.Content = ribbonContent;
            }

            var statusBarContent = ribbonService.GetStatusBar();

            if (statusBarContent != null)
            {
                customStatusBarItem.Content = statusBarContent;
            }

            contentControl.Content = ribbonService.GetMainView();
        }
Esempio n. 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ShellWindow"/> class.
        /// </summary>
        /// <remarks>This method is required for design time support.</remarks>
        public ShellWindow()
            : base(DataWindowMode.Custom, setOwnerAndFocus: false)
        {
            var currentLogFileName = TaskRunnerEnvironment.CurrentLogFileName;

            if (File.Exists(currentLogFileName))
            {
                File.Delete(currentLogFileName);
            }

            var fileLogListener = new FileLogListener(currentLogFileName, 25 * 1000)
            {
                IgnoreCatelLogging = true,
                IsDebugEnabled     = false
            };

            LogManager.AddListener(fileLogListener);

            var serviceLocator      = this.GetServiceLocator();
            var processService      = serviceLocator.ResolveType <IProcessService>();
            var taskRunnerService   = serviceLocator.ResolveType <ITaskRunnerService>();
            var commandManager      = serviceLocator.ResolveType <ICommandManager>();
            var uiVisualizerService = serviceLocator.ResolveType <IUIVisualizerService>();

            AddCustomButton(new DataWindowButton("Open log...", () =>
            {
                LogManager.FlushAll();

                processService.StartProcess(currentLogFileName);
            }));

            if (taskRunnerService.ShowCustomizeShortcutsButton)
            {
                AddCustomButton(new DataWindowButton("Keyboard shortcuts", () => uiVisualizerService.ShowDialog <KeyboardMappingsOverviewViewModel>()));
            }

            serviceLocator.RegisterInstance <IAboutInfoService>(taskRunnerService);

            if (taskRunnerService.GetAboutInfo() != null)
            {
                var aboutService = serviceLocator.ResolveType <IAboutService>();
                commandManager.RegisterAction("Help.About", aboutService.ShowAbout);

                AddCustomButton(new DataWindowButton("About", commandManager.GetCommand("Help.About")));
            }

            ThemeHelper.EnsureApplicationThemes(GetType().Assembly, true);

            InitializeComponent();

            serviceLocator.RegisterInstance <ILogControlService>(new LogControlService(traceOutputControl));

            var task = taskRunnerService.GetViewDataContext();

            task.Wait();
            ConfigurationContext = task.Result;

            var startupSize = taskRunnerService.GetInitialWindowSize();

            if (startupSize != null && !startupSize.IsEmpty)
            {
                bool setWidth  = startupSize.Width > 0d;
                bool setHeight = startupSize.Height > 0d;

                if (setHeight && setWidth)
                {
                    SizeToContent = SizeToContent.Manual;
                }
                else if (setHeight)
                {
                    SizeToContent = SizeToContent.Width;
                }
                else if (setWidth)
                {
                    SizeToContent = SizeToContent.Height;
                }
                else
                {
                    SizeToContent = SizeToContent.WidthAndHeight;
                }

                if (setWidth)
                {
                    MinWidth = startupSize.Width;
                    Width    = startupSize.Width;
                }

                if (setHeight)
                {
                    MinHeight = startupSize.Height;
                    Height    = startupSize.Height;
                }
            }

            var view = taskRunnerService.GetView();

            contentControl.Content = view;
        }
Esempio n. 10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ShellWindow"/> class.
        /// </summary>
        /// <remarks>This method is required for design time support.</remarks>
        public ShellWindow()
            : base(DataWindowMode.Custom, setOwnerAndFocus: false)
        {
            var currentLogFileName = TaskRunnerEnvironment.CurrentLogFileName;

            if (File.Exists(currentLogFileName))
            {
                File.Delete(currentLogFileName);
            }

            var fileLogListener = new FileLogListener(currentLogFileName, 25 * 1000)
            {
                IgnoreCatelLogging = true,
                IsDebugEnabled     = false
            };

            LogManager.AddListener(fileLogListener);

            var serviceLocator      = this.GetServiceLocator();
            var taskRunnerService   = serviceLocator.ResolveType <ITaskRunnerService>();
            var commandManager      = serviceLocator.ResolveType <ICommandManager>();
            var uiVisualizerService = serviceLocator.ResolveType <IUIVisualizerService>();

            if (taskRunnerService.ShowCustomizeShortcutsButton)
            {
                AddCustomButton(DataWindowButton.FromAsync("Keyboard shortcuts", () => uiVisualizerService.ShowDialogAsync <KeyboardMappingsOverviewViewModel>(), null));
            }

            serviceLocator.RegisterInstance <IAboutInfoService>(taskRunnerService);

            if (taskRunnerService.GetAboutInfo() != null)
            {
                var aboutService = serviceLocator.ResolveType <IAboutService>();
#pragma warning disable AvoidAsyncVoid // Avoid async void
                commandManager.RegisterAction("Help.About", async() => await aboutService.ShowAboutAsync());
#pragma warning restore AvoidAsyncVoid // Avoid async void

                AddCustomButton(new DataWindowButton("About", commandManager.GetCommand("Help.About")));
            }

            ThemeHelper.EnsureApplicationThemes(GetType().Assembly, true);

            InitializeComponent();
            serviceLocator.RegisterInstance <ILogControlService>(new LogControlService(traceOutputControl));

            ConfigurationContext = taskRunnerService.GetViewDataContext();

            var startupSize = taskRunnerService.GetInitialWindowSize();
            if (startupSize != null && !startupSize.IsEmpty)
            {
                var setWidth  = startupSize.Width > 0d;
                var setHeight = startupSize.Height > 0d;

                if (setHeight && setWidth)
                {
                    SetCurrentValue(SizeToContentProperty, SizeToContent.Manual);
                }
                else if (setHeight)
                {
                    SetCurrentValue(SizeToContentProperty, SizeToContent.Width);
                }
                else if (setWidth)
                {
                    SetCurrentValue(SizeToContentProperty, SizeToContent.Height);
                }
                else
                {
                    SetCurrentValue(SizeToContentProperty, SizeToContent.WidthAndHeight);
                }

                if (setWidth)
                {
                    SetCurrentValue(MinWidthProperty, startupSize.Width);
                    SetCurrentValue(WidthProperty, startupSize.Width);
                }

                if (setHeight)
                {
                    SetCurrentValue(MinHeightProperty, startupSize.Height);
                    SetCurrentValue(HeightProperty, startupSize.Height);
                }
            }

            var view = taskRunnerService.GetView();

            contentControl.Content = view;
        }