Ejemplo n.º 1
0
        /// <summary>
        /// On initial load, the desired collection durations are load from configuration.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainForm_Load(object sender, EventArgs e)
        {
            // for handling UI events
            m_dispatcher = Dispatcher.CurrentDispatcher;

            // Initialize the settings manager
            ZAMsettings.Initialize(m_loggerFactory);

            // Determine window position
            if (ZAMsettings.Settings.WindowPositionX > 0 && ZAMsettings.Settings.WindowPositionY > 0)
            {
                this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
                this.Location      = new System.Drawing.Point(ZAMsettings.Settings.WindowPositionX, ZAMsettings.Settings.WindowPositionY);
            }

            this.lvOverall.Items.Clear();
            this.lvOverall.Items.Add(m_summaryHelper.SummaryListViewItem);

            //m_labelHelpers.Add(new LabelHelper(lblMA1, lblAvgPower1, lblMaxPower1, lblFtpPower1, lblAvgHR1));
            //m_labelHelpers.Add(new LabelHelper(lblMA2, lblAvgPower2, lblMaxPower2, lblFtpPower2, lblAvgHR2));
            //m_labelHelpers.Add(new LabelHelper(lblMA3, lblAvgPower3, lblMaxPower3, lblFtpPower3, lblAvgHR3));


            // Set the environment based on the current user
            SetupCurrentUser();

            m_logger.LogInformation("MainForm Loaded");
        }
Ejemplo n.º 2
0
        public static Task Main(string[] args)
        {
            var executableLocation = Path.GetDirectoryName(typeof(Program).Assembly.Location);

            var host = new HostBuilder()
                       .ConfigureWinForms <MainForm>()
                       //.ConfigureWinForms<MonitorStatistics>()
                       .ConfigureConfiguration(args)
                       .ConfigureLogging()
                       .ConfigureSingleInstance(builder =>
            {
                builder.MutexId = "{80B16FA8-ECAE-4DD8-9F8A-FE7E6780A825}";
                builder.WhenNotFirstInstance = (hostingEnvironment, logger) =>
                {
                    // This is called when an instance was already started, this is in the second instance
                    logger.LogWarning("Application {0} already running.", hostingEnvironment.ApplicationName);
                };
            })
                       //.ConfigurePlugins(pluginBuilder =>
                       //{
                       //    if (executableLocation == null)
                       //    {
                       //        return;
                       //    }

                       //    var runtime = Path.GetFileName(executableLocation);
                       //    var parentDirectory = Directory.GetParent(executableLocation).FullName;
                       //    var configuration = Path.GetFileName(parentDirectory);
                       //    var basePath = Path.Combine(executableLocation, @"..\..\..\..\");
                       //    // Specify the location from where the Dll's are "globbed"
                       //    pluginBuilder.AddScanDirectories(basePath);
                       //    // Add the framework libraries which can be found with the specified globs
                       //    pluginBuilder.IncludeFrameworks(@$"**\bin\{configuration}\netstandard2.0\*.FrameworkLib.dll");
                       //    // Add the plugins which can be found with the specified globs
                       //    pluginBuilder.IncludePlugins(@$"**\bin\{configuration}\{runtime}\*.Sample.Plugin*.dll");
                       //})
                       .ConfigureServices(serviceCollection =>
            {
                // Add the ZwiftPacketMonitor extensions
                ZwiftPacketMonitor.RegistrationExtensions.AddZwiftPacketMonitoring(serviceCollection);

                // add our ZwiftPacketMonitor wrapper service
                serviceCollection.AddSingleton <ZPMonitorService>();

                serviceCollection.AddTransient <AdvancedOptions>();
                serviceCollection.AddTransient <ConfigurationOptions>();
                serviceCollection.AddSingleton <MonitorTimer>();
            })
                       .UseWinFormsLifetime()
                       .Build();

            ILoggerFactory   lf = host.Services.GetRequiredService <ILoggerFactory>();
            ZPMonitorService zp = host.Services.GetRequiredService <ZPMonitorService>();

            ZAMsettings.Initialize(lf, zp);


            return(host.RunAsync());
        }