예제 #1
0
 public FileHandler(SonarrApi sonarrApi_, MediaServer mServer_)
 {
     sonarrApi = sonarrApi_;
     mServer   = mServer_;
 }
        protected override void OnStartup(StartupEventArgs e)
        {
            foreach (string arg in e.Args)
            {
                if (arg == "/debug")
                {
                    Config.Debug = true;
                }
                if (arg == "/trace")
                {
                    Config.Trace = true;
                }
            }

            if (Config.Debug)
            {
                Log.EnableDebugLevel();
            }
            if (Config.Trace)
            {
                Log.EnableTraceLevel();
            }

            logger.Info("The application is running.");
            logger.Debug("The application is running in debug mode.");

            mServer   = new MediaServer();
            sonarrApi = new SonarrApi();

            notifyIcon = new NotifyIcon();
            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MediaCleaner.Resource." + "icon_stopped.ico"))
            {
                notifyIcon.Icon = new Icon(stream);
            }
            notifyIcon.Visible = true;

            notifyIcon.Text    = "Starting...";
            notifyIcon.Visible = true;

            contextMenu     = new ContextMenuStrip();
            runCleaningNow  = new ToolStripMenuItem();
            openSettings    = new ToolStripMenuItem();
            exitApplication = new ToolStripMenuItem();

            notifyIcon.ContextMenuStrip = contextMenu;

            runCleaningNow.Text   = "Run a cleaning phase now";
            runCleaningNow.Click += new EventHandler(RunCleaningNow);
            contextMenu.Items.Add(runCleaningNow);

            openSettings.Text   = "Settings";
            openSettings.Click += new EventHandler(OpenSettings);
            contextMenu.Items.Add(openSettings);

            exitApplication.Text   = "Exit";
            exitApplication.Click += new EventHandler(ShutdownApp);
            contextMenu.Items.Add(exitApplication);

            if (checkSettings())
            {
                start();
            }
            else
            {
                wrongSettings();
            }
        }