Exemplo n.º 1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            // Create aero and controller.
            this.aero       = new Aero();
            this.controller = new AeroController(this.aero);
            this.controller.Load();

            // Create background update task.
            this.updateTask = this.Dispatcher.InvokeAsync(() => this.updateLoop(this.cancellationTokenSource.Token), DispatcherPriority.Background).Task;

            // Get app icon.
            Icon ico;

            using (Stream stream = typeof(App).Assembly.GetManifestResourceStream("AeroCtl.UI.Main.ico"))
            {
                ico = new Icon(stream);
            }

            // Create tray icon.
            this.trayIcon = new NotifyIcon
            {
                Icon    = ico,
                Text    = this.title,
                Visible = true,
            };

            this.trayIcon.DoubleClick += (s, e2) => { this.showWindow(); };

            // Handle Fn key events.
            this.aero.Keyboard.FnKeyPressed   += (s, e2) => { this.Dispatcher.InvokeAsync(() => this.handleFnKey(e2)); };
            this.aero.Touchpad.EnabledChanged += (s, e2) => { this.Dispatcher.InvokeAsync(() => this.onTouchpadEnabledChanged().AsTask()); };

            // To re-apply fan profile after wake up:
            SystemEvents.SessionSwitch    += this.onSessionSwitch;
            SystemEvents.PowerModeChanged += this.onPowerModeChanged;

            if (!this.controller.StartMinimized || Debugger.IsAttached)
            {
                // Show window if 'start minimized' isn't active.
                this.showWindow();
            }
        }
Exemplo n.º 2
0
 public MainWindow(AeroController controller)
 {
     this.Controller = controller;
     this.InitializeComponent();
 }