Beispiel #1
0
        public ManagerForm(LogCache logCache, ApiData apiData)
        {
            LogCache = logCache ?? throw new ArgumentNullException(nameof(logCache));
            ApiData  = apiData ?? throw new ArgumentNullException(nameof(apiData));

            // Background processors
            var dpsReportUploader = new DpsReportUploader();

            UploadProcessor   = new UploadProcessor(dpsReportUploader, LogCache);
            ApiProcessor      = new ApiProcessor(ApiData, new Gw2Client());
            LogDataProcessor  = new LogDataProcessor(LogCache, ApiProcessor, LogAnalytics);
            LogNameProvider   = new TranslatedLogNameProvider(GameLanguage.English);
            LogCacheAutoSaver = LogCacheAutoSaver.StartNew(logCache, LogCacheAutoSavePeriod);

            LogDataProcessor.StoppingWithError += (sender, args) =>
            {
                Application.Instance.InvokeAsync(() => MessageBox.Show(this,
                                                                       $"The background processor for logs has failed critically. " +
                                                                       $"Please report the following error:\n\nException: {args.Exception}", "Error", MessageBoxType.Error));
            };

            ApiProcessor.StoppingWithError += (sender, args) =>
            {
                Application.Instance.InvokeAsync(() => MessageBox.Show(this,
                                                                       $"The background processor for API requests has failed critically. " +
                                                                       $"Please report the following error:\n\nException: {args.Exception}", "Error", MessageBoxType.Error));
            };

            UploadProcessor.StoppingWithError += (sender, args) =>
            {
                Application.Instance.InvokeAsync(() => MessageBox.Show(this,
                                                                       $"The background processor for log uploads has failed critically. " +
                                                                       $"Please report the following error:\n\nException: {args.Exception}", "Error", MessageBoxType.Error));
            };

            Filters = new LogFilters(new SettingsFilters());
            Filters.PropertyChanged += (sender, args) => logsFiltered.Refresh();

            if (Settings.UseGW2Api)
            {
                ApiProcessor.StartBackgroundTask();
            }

            Settings.UseGW2ApiChanged += (sender, args) =>
            {
                if (Settings.UseGW2Api)
                {
                    ApiProcessor.StartBackgroundTask();
                }
                else
                {
                    ApiProcessor.StopBackgroundTask();
                }
            };

            Settings.DpsReportDomainChanged += (sender, args) => { dpsReportUploader.Domain = Settings.DpsReportDomain; };

            // Form layout
            Icon       = Resources.GetProgramIcon();
            Title      = "arcdps Log Manager";
            ClientSize = new Size(1300, 768);
            var formLayout = new DynamicLayout();

            Content = formLayout;

            Menu = ConstructMenuBar();

            formLayout.BeginVertical(new Padding(5), yscale: false);
            {
                formLayout.Add(ConstructMainSplitter(), yscale: true);
                formLayout.Add(ConstructStatusPanel());
            }
            formLayout.EndVertical();

            // Event handlers
            ApiProcessor.Processed += (sender, args) =>
            {
                bool last = args.CurrentScheduledItems == 0;

                if (last)
                {
                    ApiData.SaveDataToFile();
                }
            };

            Settings.LogRootPathChanged += (sender, args) => Application.Instance.Invoke(ReloadLogs);

            Closing += (sender, args) =>
            {
                if (LogCache?.ChangedSinceLastSave ?? false)
                {
                    LogCache?.SaveToFile();
                }

                ApiData?.SaveDataToFile();
            };
            LogSearchFinished += (sender, args) =>
            {
                var updates = LogDataUpdater.GetUpdates(logs).ToList();
                if (updates.Count > 0)
                {
                    new ProcessingUpdateDialog(LogDataProcessor, updates).ShowModal(this);
                }
            };

            // Collection initialization
            logsFiltered = new FilterCollection <LogData>(logs);
            logsFiltered.CollectionChanged += (sender, args) => FilteredLogsUpdated?.Invoke(this, EventArgs.Empty);
            logsFiltered.Filter             = Filters.FilterLog;
            LogCollectionsInitialized?.Invoke(this, EventArgs.Empty);
            LogDataProcessor.Processed += (sender, args) =>
            {
                bool last = args.CurrentScheduledItems == 0;
                if (last)
                {
                    Application.Instance.AsyncInvoke(logsFiltered.Refresh);
                }
            };

            Shown += (sender, args) => ReloadLogs();
            Shown += (sender, args) => CheckUpdates();
        }
Beispiel #2
0
        public ManagerForm(LogCache logCache, ApiData apiData)
        {
            LogCache = logCache ?? throw new ArgumentNullException(nameof(logCache));
            ApiData  = apiData ?? throw new ArgumentNullException(nameof(apiData));

            // Background processors
            var dpsReportUploader = new DpsReportUploader();

            UploadProcessor  = new UploadProcessor(dpsReportUploader, LogCache);
            ApiProcessor     = new ApiProcessor(ApiData, new Gw2Client());
            LogDataProcessor = new LogDataProcessor(LogCache, ApiProcessor, LogAnalytics);
            LogNameProvider  = new TranslatedLogNameProvider(GameLanguage.English);

            Filters = new LogFilters(new SettingsFilters());
            Filters.PropertyChanged += (sender, args) => logsFiltered.Refresh();

            if (Settings.UseGW2Api)
            {
                ApiProcessor.StartBackgroundTask();
            }

            Settings.UseGW2ApiChanged += (sender, args) =>
            {
                if (Settings.UseGW2Api)
                {
                    ApiProcessor.StartBackgroundTask();
                }
                else
                {
                    ApiProcessor.StopBackgroundTask();
                }
            };

            Settings.DpsReportDomainChanged += (sender, args) => { dpsReportUploader.Domain = Settings.DpsReportDomain; };

            // Form layout
            Icon       = Resources.GetProgramIcon();
            Title      = "arcdps Log Manager";
            ClientSize = new Size(1024, 768);
            var formLayout = new DynamicLayout();

            Content = formLayout;

            Menu = ConstructMenuBar();

            formLayout.BeginVertical(new Padding(5), yscale: false);
            {
                formLayout.Add(ConstructMainSplitter(), yscale: true);
                formLayout.Add(ConstructStatusPanel());
            }
            formLayout.EndVertical();

            // Event handlers
            ApiProcessor.Processed += (sender, args) =>
            {
                bool last = args.CurrentScheduledItems == 0;

                if (last)
                {
                    ApiData.SaveDataToFile();
                }
            };

            Settings.LogRootPathChanged += (sender, args) => Application.Instance.Invoke(ReloadLogs);

            Shown   += (sender, args) => ReloadLogs();
            Closing += (sender, args) =>
            {
                if (LogCache?.ChangedSinceLastSave ?? false)
                {
                    LogCache?.SaveToFile();
                }

                ApiData?.SaveDataToFile();
            };
            LogCollectionsRecreated += (sender, args) =>
            {
                logsFiltered.Filter = Filters.FilterLog;
                logsFiltered.Refresh();
            };
            LogSearchFinished += (sender, args) =>
            {
                var updates = LogDataUpdater.GetUpdates(logs).ToList();
                if (updates.Count > 0)
                {
                    new UpdateDialog(LogDataProcessor, updates).ShowModal(this);
                }
            };

            // Collection initialization
            RecreateLogCollections(new ObservableCollection <LogData>(logs));
        }
Beispiel #3
0
        private MenuBar ConstructMenuBar()
        {
            var updateMenuItem = new ButtonMenuItem {
                Text = "&Update logs with outdated data…"
            };

            updateMenuItem.Click += (sender, args) =>
            {
                new ProcessingUpdateDialog(LogDataProcessor, LogDataUpdater.GetUpdates(logs).ToList()).ShowModal(this);
            };
            LogSearchFinished          += (sender, args) => { updateMenuItem.Enabled = LogDataUpdater.GetUpdates(logs).Any(); };
            LogDataProcessor.Processed += (sender, args) =>
            {
                if (args.CurrentScheduledItems == 0)
                {
                    bool updatesFound = LogDataUpdater.GetUpdates(logs).Any();
                    Application.Instance.AsyncInvoke(() => updateMenuItem.Enabled = updatesFound);
                }
            };

            var logCacheMenuItem = new ButtonMenuItem {
                Text = "&Log cache"
            };

            logCacheMenuItem.Click += (sender, args) => { new CacheDialog(this).ShowModal(this); };

            var apiDataMenuItem = new ButtonMenuItem {
                Text = "&API cache"
            };

            apiDataMenuItem.Click += (sender, args) => { new ApiDialog(ApiProcessor).ShowModal(this); };

            var settingsFormMenuItem = new ButtonMenuItem {
                Text = "&Settings"
            };

            settingsFormMenuItem.Click += (sender, args) => { new SettingsForm().Show(); };

            var debugDataMenuItem = new CheckMenuItem {
                Text = "Show &debug data"
            };

            debugDataMenuItem.Checked         = Settings.ShowDebugData;
            debugDataMenuItem.CheckedChanged += (sender, args) => { Settings.ShowDebugData = debugDataMenuItem.Checked; };

            var showGuildTagsMenuItem = new CheckMenuItem {
                Text = "Show &guild tags in log details"
            };

            showGuildTagsMenuItem.Checked         = Settings.ShowGuildTagsInLogDetail;
            showGuildTagsMenuItem.CheckedChanged += (sender, args) => { Settings.ShowGuildTagsInLogDetail = showGuildTagsMenuItem.Checked; };

            var showFailurePercentagesMenuItem = new CheckMenuItem {
                Text = "Show failure health &percentages in log list"
            };

            showFailurePercentagesMenuItem.Checked         = Settings.ShowFailurePercentagesInLogList;
            showFailurePercentagesMenuItem.CheckedChanged += (sender, args) =>
            {
                Settings.ShowFailurePercentagesInLogList = showFailurePercentagesMenuItem.Checked;
            };

            var showSidebarMenuItem = new CheckMenuItem {
                Text = "Show &filters in a sidebar"
            };

            showSidebarMenuItem.Checked         = Settings.ShowFilterSidebar;
            Settings.ShowFilterSidebarChanged  += (sender, args) => showSidebarMenuItem.Checked = Settings.ShowFilterSidebar;
            showSidebarMenuItem.CheckedChanged += (sender, args) => { Settings.ShowFilterSidebar = showSidebarMenuItem.Checked; };

            // TODO: Implement

            /*
             * var arcdpsSettingsMenuItem = new ButtonMenuItem {Text = "&arcdps settings", Enabled = false};
             *
             * var arcdpsMenuItem = new ButtonMenuItem {Text = "&arcdps", Enabled = false};
             * arcdpsMenuItem.Items.Add(arcdpsSettingsMenuItem);
             */

            var dataMenuItem = new ButtonMenuItem {
                Text = "&Data"
            };

            dataMenuItem.Items.Add(updateMenuItem);
            dataMenuItem.Items.Add(new SeparatorMenuItem());
            dataMenuItem.Items.Add(logCacheMenuItem);
            dataMenuItem.Items.Add(apiDataMenuItem);

            var viewMenuItem = new ButtonMenuItem {
                Text = "&View"
            };

            viewMenuItem.Items.Add(showSidebarMenuItem);
            viewMenuItem.Items.Add(showGuildTagsMenuItem);
            viewMenuItem.Items.Add(showFailurePercentagesMenuItem);
            viewMenuItem.Items.Add(new SeparatorMenuItem());
            viewMenuItem.Items.Add(debugDataMenuItem);

            var settingsMenuItem = new ButtonMenuItem {
                Text = "&Settings"
            };

            settingsMenuItem.Items.Add(settingsFormMenuItem);

            var helpMenuItem = new ButtonMenuItem {
                Text = "Help"
            };

            helpMenuItem.Items.Add(new About());

            return(new MenuBar(dataMenuItem, viewMenuItem, settingsMenuItem, helpMenuItem));
        }
Beispiel #4
0
        private MenuBar ConstructMenuBar()
        {
            var updateMenuItem = new ButtonMenuItem {
                Text = "&Update"
            };

            updateMenuItem.Click += (sender, args) => { new UpdateDialog(LogDataProcessor, LogDataUpdater.GetUpdates(logs).ToList()).ShowModal(this); };

            var logCacheMenuItem = new ButtonMenuItem {
                Text = "Log &cache"
            };

            logCacheMenuItem.Click += (sender, args) => { new CacheDialog(this).ShowModal(this); };

            var apiDataMenuItem = new ButtonMenuItem {
                Text = "&API data"
            };

            apiDataMenuItem.Click += (sender, args) => { new ApiDialog(ApiProcessor).ShowModal(this); };

            var settingsFormMenuItem = new ButtonMenuItem {
                Text = "&Settings"
            };

            settingsFormMenuItem.Click += (sender, args) => { new SettingsForm().Show(); };

            var debugDataMenuItem = new CheckMenuItem {
                Text = "Show &debug data"
            };

            debugDataMenuItem.Checked         = Settings.ShowDebugData;
            debugDataMenuItem.CheckedChanged += (sender, args) => { Settings.ShowDebugData = debugDataMenuItem.Checked; };

            var showGuildTagsMenuItem = new CheckMenuItem {
                Text = "Show &guild tags in log details"
            };

            showGuildTagsMenuItem.Checked         = Settings.ShowGuildTagsInLogDetail;
            showGuildTagsMenuItem.CheckedChanged += (sender, args) => { Settings.ShowGuildTagsInLogDetail = showGuildTagsMenuItem.Checked; };

            // TODO: Implement

            /*
             * var arcdpsSettingsMenuItem = new ButtonMenuItem {Text = "&arcdps settings", Enabled = false};
             *
             * var arcdpsMenuItem = new ButtonMenuItem {Text = "&arcdps", Enabled = false};
             * arcdpsMenuItem.Items.Add(arcdpsSettingsMenuItem);
             */

            var dataMenuItem = new ButtonMenuItem {
                Text = "&Data"
            };

            dataMenuItem.Items.Add(updateMenuItem);
            dataMenuItem.Items.Add(logCacheMenuItem);
            dataMenuItem.Items.Add(apiDataMenuItem);

            var settingsMenuItem = new ButtonMenuItem {
                Text = "&Settings"
            };

            settingsMenuItem.Items.Add(settingsFormMenuItem);
            settingsMenuItem.Items.Add(showGuildTagsMenuItem);
            settingsMenuItem.Items.Add(new SeparatorMenuItem());
            settingsMenuItem.Items.Add(debugDataMenuItem);

            var helpMenuItem = new ButtonMenuItem {
                Text = "Help"
            };

            helpMenuItem.Items.Add(new About());

            return(new MenuBar(dataMenuItem, settingsMenuItem, helpMenuItem));
        }