protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); string loginData = @"oauth= username="******"fourtf"); //IrcManager.MessageReceived += (s, e) => //{ // lock (messages) // { // messages.Add(e.Message); // e.Message.CalculateBounds(null, 1000); // } //}; }
static void Main(string[] args) { Application.Init(); AppSettings.SavePath = Path.Combine(Util.GetUserDataPath(), "Settings.ini"); GuiEngine.Initialize(new GtkGuiEngine()); Cache.Load(); AppSettings.Load(); IrcManager.Connect(); var window = new MainWindow(); window.ShowAll(); window.Hidden += (s, e) => { Application.Quit(); }; Application.Run(); AppSettings.Save(); }
static void Main() { CurrentVersion = VersionNumber.Parse( AssemblyName.GetAssemblyName(Assembly.GetExecutingAssembly().Location).Version.ToString()); if (!File.Exists("./removeupdatenew") && Directory.Exists("./Updater.new")) { UpdaterPath = Path.Combine(new FileInfo(Assembly.GetEntryAssembly().Location).Directory.FullName, "Updater.new", "Chatterino.Updater.exe"); } else { if (File.Exists("./update2")) { UpdaterPath = Path.Combine(new FileInfo(Assembly.GetEntryAssembly().Location).Directory.FullName, "Updater2", "Chatterino.Updater.exe"); } } Directory.SetCurrentDirectory(new FileInfo(Assembly.GetEntryAssembly().Location).Directory.FullName); GuiEngine.Initialize(new WinformsGuiEngine()); ServicePointManager.ServerCertificateValidationCallback = (a, b, c, d) => true; ServicePointManager.DefaultConnectionLimit = int.MaxValue; //ServicePointManager.UseNagleAlgorithm = false; //ServicePointManager.MaxServicePoints = 10000; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //SetProcessDpiAwareness(_Process_DPI_Awareness.Process_Per_Monitor_DPI_Aware); Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location); // Fonts if (Environment.OSVersion.Version.Major >= 6 && Environment.OSVersion.Version.Minor >= 1) { UseDirectX = true; } // Exceptions Application.ThreadException += (s, e) => { e.Exception.Log("exception", "{0}\n"); }; AppDomain.CurrentDomain.UnhandledException += (s, e) => { (e.ExceptionObject as Exception).Log("exception", "{0}\n"); }; EmoteCache.init(); // Update gif emotes int offset = 0; new System.Windows.Forms.Timer { Interval = 30, Enabled = true }.Tick += (s, e) => { if (AppSettings.ChatEnableGifAnimations) { lock (GuiEngine.Current.GifEmotesLock) { offset += 3; if (offset < 0) { offset = 0; } try { if (EmoteList != null && EmoteList.GetGifEmotes() != null) { GuiEngine.Current.GifEmotesOnScreen.UnionWith(EmoteList.GetGifEmotes()); } foreach (LazyLoadedImage emote in GuiEngine.Current.GifEmotesOnScreen) { if (emote.HandleAnimation != null) { emote.HandleAnimation(offset); } } if (ToolTip != null && ToolTip.Visible && ToolTip.Image != null && ToolTip.Image.HandleAnimation != null) { ToolTip.Image.HandleAnimation(offset); lock (ToolTip) { ToolTip.redraw(); } } } catch (Exception err) { GuiEngine.Current.log("error updating gifs " + err.ToString()); } } GifEmoteFramesUpdated?.Invoke(null, EventArgs.Empty); } }; // Settings/Colors try { if (!Directory.Exists(Util.GetUserDataPath())) { Directory.CreateDirectory(Util.GetUserDataPath()); } if (!Directory.Exists(Path.Combine(Util.GetUserDataPath(), "Custom"))) { Directory.CreateDirectory(Path.Combine(Util.GetUserDataPath(), "Custom")); } } catch { } AppSettings.SavePath = Path.Combine(Util.GetUserDataPath(), "Settings.ini"); var showWelcomeForm = false; try { if (!File.Exists(AppSettings.SavePath)) { CanShowChangelogs = false; showWelcomeForm = true; if (File.Exists("./Settings.ini") && !File.Exists(AppSettings.SavePath)) { File.Move("./Settings.ini", AppSettings.SavePath); try { File.Delete("./Settings.ini"); } catch { } } if (File.Exists("./Custom/Commands.txt") && !File.Exists(Path.Combine(Util.GetUserDataPath(), "Custom", "Commands.txt"))) { File.Move("./Custom/Commands.txt", Path.Combine(Util.GetUserDataPath(), "Custom", "Commands.txt")); try { File.Delete("./Custom/Commands.txt"); } catch { } } if (File.Exists("./Custom/Ping.wav") && !File.Exists(Path.Combine(Util.GetUserDataPath(), "Custom", "Ping.wav"))) { File.Move("./Custom/Ping.wav", Path.Combine(Util.GetUserDataPath(), "Custom", "Ping.wav")); try { File.Delete("./Custom/Ping.wav"); } catch { } } if (File.Exists("./Layout.xml") && !File.Exists(Path.Combine(Util.GetUserDataPath(), "Layout.xml"))) { File.Move("./Layout.xml", Path.Combine(Util.GetUserDataPath(), "Layout.xml")); try { File.Delete("./Layout.xml"); } catch { } } } } catch { } AppSettings.Load(); AccountManager.LoadFromJson(Path.Combine(Util.GetUserDataPath(), "Login.json")); IrcManager.Account = AccountManager.FromUsername(AppSettings.SelectedUser) ?? Account.AnonAccount; IrcManager.Connect(); Commands.LoadOrDefault(Path.Combine(Util.GetUserDataPath(), "Custom", "Commands.txt")); Cache.Load(); _updateTheme(); AppSettings.ThemeChanged += (s, e) => _updateTheme(); // Check for updates //try //{ // string updaterPath = "./Updater"; // string newUpdaterPath = "./Updater.new"; // if (Directory.Exists(newUpdaterPath)) // { // if (Directory.Exists(updaterPath)) // Directory.Delete(updaterPath, true); // Directory.Move(newUpdaterPath, updaterPath); // } //} //catch { } Updates.UpdateFound += (s, e) => { try { using (var dialog = new UpdateDialog()) { if (File.Exists(UpdaterPath)) { var result = dialog.ShowDialog(); // OK -> install now // Yes -> install on exit if (result == DialogResult.OK || result == DialogResult.Yes) { using (var client = new WebClient()) { client.DownloadFile(e.Url, Path.Combine(Util.GetUserDataPath(), "update.zip")); } installUpdatesOnExit = true; if (result == DialogResult.OK) { restartAfterUpdates = true; MainForm?.Close(); } } } else { MessageBox.Show("An update is available but the update executable could not be found. If you want to update chatterino you will have to reinstall it."); } } } catch { } }; #if DEBUG Updates.CheckForUpdate("win-dev", CurrentVersion); #else Updates.CheckForUpdate("win-release", CurrentVersion); #endif // Start irc Emotes.LoadGlobalEmotes(); Badges.LoadGlobalBadges(); GuiEngine.Current.LoadBadges(); Net.StartHttpServer(); // Show form MainForm = new MainForm(); MainForm.Show(); if (showWelcomeForm) { new WelcomeForm().Show(); } MainForm.FormClosed += (s, e) => { Application.Exit(); // Save settings AppSettings.Save(); Cache.Save(); EmoteCache.SaveEmoteList(); Commands.Save(Path.Combine(Util.GetUserDataPath(), "Custom", "Commands.txt")); }; Application.Run(); Environment.Exit(0); }