public void ExecuteAfterStartupSteps()
        {
            try
            {
                var vm = newsViewModelFactory.CreateNewsViewModel();
                vm.ShowIfAnyUnshownNews();
            }
            catch (Exception exception)
            {
                logger.Error(exception, "Error at showing news");
                userNotifier.NotifyWithMessageBox("Error at showing news, see logs for details.", NotifyKind.Warning);
            }

            try
            {
                wurmUnlimitedLogsDirChecker.HandleOldLogsDirContents();
            }
            catch (Exception exception)
            {
                logger.Error(exception, "Error at HandleOldLogsDirContents");
                userNotifier.NotifyWithMessageBox("Error at HandleOldLogsDirContents, see logs for details.", NotifyKind.Warning);
            }

            var version = waVersionInfoProvider.Get();

            telemetry.TrackEvent($"Started: " + version);
        }
Esempio n. 2
0
        public MainViewModel(
            [NotNull] MainDataContext dataContext,
            [NotNull] ISystemTrayContextMenu trayMenu,
            [NotNull] IConsoleArgs consoleArgs,
            [NotNull] IWaVersionInfoProvider waVersionInfoProvider,
            [NotNull] MainForm mainForm)
        {
            if (dataContext == null)
            {
                throw new ArgumentNullException(nameof(dataContext));
            }
            if (trayMenu == null)
            {
                throw new ArgumentNullException(nameof(trayMenu));
            }
            if (consoleArgs == null)
            {
                throw new ArgumentNullException(nameof(consoleArgs));
            }
            if (waVersionInfoProvider == null)
            {
                throw new ArgumentNullException(nameof(waVersionInfoProvider));
            }
            if (mainForm == null)
            {
                throw new ArgumentNullException(nameof(mainForm));
            }
            this.DataContext           = dataContext;
            this.trayMenu              = trayMenu;
            this.consoleArgs           = consoleArgs;
            this.waVersionInfoProvider = waVersionInfoProvider;
            this.mainForm              = mainForm;

            trayMenu.ShowMainWindowClicked    += ShowRestore;
            trayMenu.ExitWurmAssistantClicked += (sender, eventArgs) => this.TryClose();

            savedNonMinimizedWindowState = WindowState.Normal;

            if (consoleArgs.WurmUnlimitedMode)
            {
                WindowTitle = "Aldur's Wurm Assistant Unlimited";
                Icon        = Resources.WurmAssistantUnlimitedIcon.ToImageSource();
            }
            else
            {
                WindowTitle = "Aldur's Wurm Assistant";
                Icon        = Resources.WurmAssistantIcon.ToImageSource();
            }

            WindowTitle += string.Format(" ({0})", waVersionInfoProvider.Get());

            mainForm.Dock   = DockStyle.Fill;
            WinFormsContent = new WindowsFormsHost()
            {
                Child = mainForm,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch
            };
        }