コード例 #1
0
        public LogoWindow()
        {
            InitializeComponent();

            ContentRendered += (_, __) => {
                AddLogLine("Activate Penguintter");
                AddLogLine("Registering global hotkey...");
                var hotkey = new GlobalHotkey(this);
                hotkey.Regist(ModifierKeys.Control | ModifierKeys.Alt, Key.T, new EventHandler(ShowUpdateView));
                hotkey.Regist(ModifierKeys.Control | ModifierKeys.Alt, Key.L, new EventHandler(ShowLogView));
                hotkey.Regist(ModifierKeys.Control | ModifierKeys.Alt, Key.C, new EventHandler(ShowConfigView));
                AddLogLine("-> done");

                AddLogLine("Initializing cache...");
                var app = (App)Application.Current;
                app.LoadCache();
                AddLogLine("-> done");

                AddLogLine("Checking " + Config.ConfigFileName + "...");
                if (app.LoadConfig())
                {
                    AddLogLine("-> Detected");
                }
                else
                {
                    AddLogLine("-> Not found or Deserialize Error: Apply default configuration");
                }

                AddLogLine("Checking " + Account.AccountFileName + "...");
                if (app.LoadAccount())
                {
                    AddLogLine("-> Detected: Loaded account data");
                }
                else
                {
                    AddLogLine("-> Not found or Deserialize Error: Creating and saving new account data...");
                    if (app.CreateAccount())
                    {
                        AddLogLine("-> Saved successfully");
                    }
                    else
                    {
                        AddLogLine("-> FAILED");
                        AddLogLine("アプリケーションを終了してください");
                        return;
                    }
                    app.LoadAccount();
                    AddLogLine("Loaded account data");
                }

                AddLogLine("Start streaming");
                Timer.Tick += (___, ____) => {
                    WindowState = WindowState.Minimized;
                    Timer.Stop();
                };
                Timer.Start();
                ((App)Application.Current).StartStream();
            };
        }