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

            //var io = Icon.ExtractAssociatedIcon(Riot.GetRiotClientPath());
            //using (FileStream fs = new FileStream("riot.ico", FileMode.Create))
            //    io.Save(fs);
            try
            {
                Assembly executingAssembly     = Assembly.GetExecutingAssembly();
                string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
                string   str = "server.pfx";

                using (var sourceStream = executingAssembly.GetManifestResourceStream(manifestResourceNames.Single(m => m.Contains(str))))
                    using (var memoryStream = new MemoryStream())
                    {
                        sourceStream.CopyTo(memoryStream);
                        CertificateBytes = memoryStream.ToArray();
                    }

                NotifyIcon      = new TaskbarIcon();
                NotifyIcon.Icon = Icon.ExtractAssociatedIcon(Riot.GetRiotClientPath());

                this.ShutdownMode = ShutdownMode.OnExplicitShutdown;
                EnsureRiotNotRunning();
                SetupConfigProxy();

                SetupTrayIcon();

                DispatcherTimer timer = new DispatcherTimer();
                timer.Tick += (s, ev) =>
                {
                    SetupTrayIcon();
                    RightAlignGame();
                };
                timer.Interval = TimeSpan.FromSeconds(5);
                timer.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                Shutdown();
            }
        }