public MainForm() { try { Hide(); SplashScreen.BackgroundImage = Resources.splash; SplashScreen.FontForeColor = Color.White; var splashthread = new Thread(SplashScreen.ShowSplashScreen) { IsBackground = true }; splashthread.Start(); Config.LanguageFileName = Config.LocalSetting.LanguageFileName; if (System.IO.File.Exists(Config.LanguageFileName)) { var language = XmlHelper.XmlDeserialize( Config.LanguageFileName, typeof(Language)) as Language; Config.LocalLanguage = language; } SplashScreen.UpdateStatusText(Config.LocalLanguage.Messages.InitializeComponent); InitializeComponent(); } catch (Exception ex) { SplashScreen.CloseSplashScreen(); MsgBox.ShowExceptionMessage(ex); } }
public Game() : base(640, 480, new GraphicsMode(32, 16, 8, 0)) { try { Title = "SnowFlake Engine"; VSync = VSyncMode.Off; DebugWindow.Log("VSync: " + VSync); _sEngine = new Engine(this); var splashthread = new Thread(SplashScreen.ShowSplashScreen) { IsBackground = true }; splashthread.Start(); SplashScreen.UpdatePercentage(10); SplashScreen.UdpateStatusTextWithStatus("Loading BSP map: level.bsp", TypeOfMessage.Success); DebugWindow.Log("Loading level outpost.bsp"); SplashScreen.UpdatePercentage(20); _sEngine.LoadMap(Engine.Quake3FilesPath + Utility.AdaptRelativePathToPlatform("maps/"), "outpost.bsp"); DebugWindow.Log("Loaded map outpost.bsp"); SplashScreen.UpdatePercentage(60); SplashScreen.UpdatePercentage(90); SplashScreen.CloseSplashScreen(); } catch (Exception ex) { if (ex.InnerException != null) { MessageBox.Show(ex.InnerException.Message, ex.Message); } } }
/// <summary> /// 检查并更新 /// </summary> private void CheckVersionAndDownLoad() { #region update if (!string.IsNullOrEmpty(Config.NeedUpdate)) { SplashScreen.CloseSplashScreen(); if (DialogResult.Yes == MsgBox.ShowQuestionMessage(Config.NeedUpdate)) { OpenIE(Config.ProxyHeroCloudSetting.UpdateUrl); } } if (!Config.ProxyHeroCloudSetting.UpdatedEnableUse.Equals("1") && !string.IsNullOrEmpty(Config.NeedUpdate)) { SplashScreen.CloseSplashScreen(); if (DialogResult.OK == MsgBox.ShowMessage("此版本已无法使用,请立即更新!")) { OpenIE(Config.ProxyHeroCloudSetting.UpdateUrl); Application.Exit(); } } #endregion }
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); SplashScreen.ShowSplashScreen(Strings.S.WAIT_MSG); if (!KCASoftCL.ValidateLicense()) { SplashScreen.CloseSplashScreen(); KCASoftCL.Activate(); MessageBox.Show(Strings.S.BARCODE_NOT_ENABLED, Strings.S.FREE_EDITION_TITLE); return; } else { SplashScreen.CloseSplashScreen(); } // Initialize Analytics if (KCASoftCL.InitializeAnalytics() == -1) { return; // something wrong with the initializer } Application.Run(new MainForm()); }
/// <summary> /// Closes the SplashScreen /// </summary> public static void CloseSplashScreen() { if (sf != null) { sf.CloseSplashScreen(); sf = null; } }
private void HandleException(Exception ex) { ErrorBox.Show(CommonResourceManager.Instance.GetResourceString("Common_FatalError"), ex, "Unexpected error occurred. Please contact support."); if (SplashScreen != null) { SplashScreen.CloseSplashScreen(); } }
private void CloseSplashScreen(bool show = true) { if (show) { this.Show(); } SplashScreen.CloseSplashScreen(); this.Activate(); }
/// <summary> /// The close splash screen. /// </summary> /// <param name="show"> /// The show. /// </param> private void CloseSplashScreen(bool show = true) { if (show) { this.Show(); } SplashScreen.CloseSplashScreen(); (this.Parent as Form).Activate(); }
private void LoadViewSetting() { if (System.IO.File.Exists(Config.ViewSettingFileName)) { var setting = XmlHelper.XmlDeserialize( Config.ViewSettingFileName, typeof(ViewSetting)) as ViewSetting; if (setting != null) { Config.LocalSetting.NeedDebug = Debug.Checked = setting.EnableDebug; InfomationWindow.Checked = setting.InformationWindow; if (InfomationWindow.Checked) { InfoPage.Show(); } else { InfoPage.Hide(); } ProxyWindow.Checked = setting.ProxyWindow; if (ProxyWindow.Checked) { ProxyPage.Show(); } else { ProxyPage.Hide(); } MainStatusBar.Visible = RightStatusBar.Checked = StatusBar.Checked = setting.StatusBar; MainToolbar.Visible = RightToolBar.Checked = ToolBar.Checked = setting.ToolBar; MainMenu.Visible = RightMenuBar.Checked = MenuBar.Checked = setting.MenuBar; } else { System.IO.File.Delete(Config.ViewSettingFileName); SplashScreen.CloseSplashScreen(); _hasViewSettingException = true; MsgBox.ShowErrorMessage("ViewSetting.xml not found!"); Close(); } } }
private void OnFirstRun() { Properties.Settings.Default.MinecraftPath = Environment.CurrentDirectory + "/Minecraft"; while (SplashScreen.GetScreen() == null) { ; } while (SplashScreen.GetScreen().Opacity != 1.0) { ; } SplashScreen.UpdateStatusText("Welcome to " + MinecraftModUpdater.ShortAppName + " Version " + MinecraftModUpdater.Version + "."); OptionsForm of = new OptionsForm(); Thread.Sleep(2000); of.ShowDialog(); SplashScreen.CloseSplashScreen(); }
public MainForm() { try { Hide(); SplashScreen.BackgroundImage = Resources.splash; SplashScreen.FontForeColor = Color.White; var splashthread = new Thread(SplashScreen.ShowSplashScreen) { IsBackground = true }; splashthread.Start(); SplashScreen.UpdateStatusText(Config.LocalLanguage.Messages.InitializeComponent); InitializeComponent(); } catch (Exception ex) { SplashScreen.CloseSplashScreen(); MsgBox.ShowExceptionMessage(ex); } }
private void Form1_Load(object sender, EventArgs e) { #region Splash Screen Load lblCountdown.Text = ""; //toolStrip1.Renderer = new ToolStripRenderPro(); //toolStrip2.Renderer = new ToolStripRenderPro(); //toolStrip3.Renderer = new ToolStripRenderPro(); //toolStrip4.Renderer = new ToolStripRenderPro(); var sf = new SplashScreenForm(); // Splash Screen SplashScreen.UdpateStatusText("Loading Items..."); SplashScreen.UdpateStatusTextWithStatus("Loading Defaults", TypeOfMessage.Success); SplashScreen.UdpateStatusText("Complete"); txtVersion.Text = @"v " + "3.4.2.0"; SetBindings(); //lblTime.DataBindings.Add(new Binding("Text", AppSettings.Instance.CurrentAuction, "EndDate", false, DataSourceUpdateMode.OnPropertyChanged)); Show(); SplashScreen.CloseSplashScreen(); Activate(); #endregion }
void ph_ModList(Packet pa) { ModListPacket p = pa as ModListPacket; identifiers.AddRange(p.Mods); if (p.Mods.Length == 0) { Program.RunOnUIThread(delegate { SplashScreen.CloseSplashScreen(); Show(); }); return; } Program.RunOnUIThread(delegate { if (Visible) { Hide(); } }); foreach (string s in p.Mods) { Packet.Send(new RequestModPacket { Identifier = s, Type = RequestModPacket.RequestType.Info }, ph.Stream); } bool exists = Directory.Exists(Properties.Settings.Default.MinecraftPath + @"\mods"); if (!exists) { Directory.CreateDirectory(Properties.Settings.Default.MinecraftPath + @"\mods"); } SplashScreen.AdvanceProgressBar(); }
private void btnConfirm_Click(object sender, EventArgs e) { if (lsModsToUpdate.Items.Count == 0) { if (Properties.Settings.Default.LaunchAfterUpdate) { if (Properties.Settings.Default.FirstRun || !File.Exists(Properties.Settings.Default.MinecraftPath + "/bin/version")) { Program.UpdateMinecraft(); } SplashScreen.CloseSplashScreen(); Hide(); Program.StartMinecraft(); } Program.RunOnUIThread(delegate { Close(); }); return; } Program.AppStatus = AppStatus.Updating; if (!Properties.Settings.Default.AutoUpdate) { if (MessageBox.Show("Are you sure you want to update " + lsModsToUpdate.Items.Count + " mods and delete " + lsModsToDelete.Items.Count + " more?", "Confirm Update Action", MessageBoxButtons.YesNo) != System.Windows.Forms.DialogResult.Yes) { return; } } foreach (object m in lsModsToUpdate.Items) { progress[3] += (int)((Mod)m).Size; } if (!Properties.Settings.Default.AutoUpdate) { TaskManager.AddAsyncTask(delegate { SplashScreen.ShowSplashScreen(); }); } while (SplashScreen.GetScreen() == null) { ; } while (SplashScreen.GetScreen().Opacity != 1) { ; } if (Properties.Settings.Default.FirstRun || !File.Exists(Properties.Settings.Default.MinecraftPath + "/bin/version")) { Program.UpdateMinecraft(); } SplashScreen.UpdateStatusText("Downloading Updates..."); SplashScreen.GetScreen().Invoke(new ModUpdaterDelegate(delegate { SplashScreen.GetScreen().lblTitle.Font.Dispose(); SplashScreen.GetScreen().lblTitle.Font = new Font(FontFamily.GenericSansSerif, Server.FontSize); SplashScreen.GetScreen().lblTitle.Text = Server.Name; SplashScreen.GetScreen().lblProgress.Visible = true; SplashScreen.GetScreen().lblProgress.Text = "0%"; })); foreach (object o in lsModsToDelete.Items) { string m = (string)o; string path = Properties.Settings.Default.MinecraftPath + "\\" + Path.GetDirectoryName(m) + Path.GetFileName(m).TrimEnd('\\').Replace("clientmods", "mods"); File.Delete(Properties.Settings.Default.MinecraftPath + @"\mods\" + Path.GetFileName(m)); } Mod mod = (Mod)lsModsToUpdate.Items[progress[0]]; if (lsModsToUpdate.Items.Contains(mod)) { Packet.Send(new RequestModPacket { Type = RequestModPacket.RequestType.Download, Identifier = mod.Identifier }, ph.Stream); } TaskManager.AddAsyncTask(delegate { while (CurrentDownload == null) { ; } int i = 5; int kbps = 0; while (warnDisconnect == true) { SplashScreen.GetScreen().Invoke(new ModUpdaterDelegate(delegate { SplashScreen.GetScreen().lblProgress.Text = string.Format(string.Format("{0:0%}", percentage) + " at {0} KB/s", kbps); SplashScreen.GetScreen().Progress.Value = Convert.ToInt32(percentage.ToString("0%").Replace("%", "")); if (i == 10) { kbps = (dlThisSecond) / 1000; dlThisSecond = 0; i = 0; } })); i++; Thread.Sleep(100); } }); Hide(); }
void ph_AllDone(Packet pa) { AllDonePacket p = pa as AllDonePacket; int i = 0; while (progress[1] != progress[2]) { if (i > 10) { SplashScreen.UpdateStatusText("There was an error while downloading. Retrying..."); Thread.Sleep(5000); Packet.Send(new RequestModPacket { Type = RequestModPacket.RequestType.Download, Identifier = p.Identifier }, ph.Stream); return; } i++; Thread.Sleep(1000); } Mod m = Mods.Find(p.Identifier); string path = Path.GetDirectoryName(Properties.Settings.Default.MinecraftPath + "\\" + m.File); File.WriteAllBytes(path + "\\" + Path.GetFileName(m.File), CurrentDownload.Contents); MinecraftModUpdater.Logger.Log(Logger.Level.Info, "Downloaded " + path + "\\" + Path.GetFileName(m.File)); ProcessStartInfo pr = new ProcessStartInfo("cmd"); pr.CreateNoWindow = true; pr.UseShellExecute = false; pr.RedirectStandardOutput = true; pr.RedirectStandardInput = true; Process proc = new Process(); proc.StartInfo = pr; proc.Start(); foreach (string s in m.PostDownload) { try { proc.StandardInput.WriteLine(s); } catch (Exception e) { ExceptionHandler.HandleException(e, this); } } proc.Kill(); MinecraftModUpdater.Logger.Log(Logger.Level.Info, "[Post Download] " + proc.StandardOutput.ReadToEnd()); if (GetLastModToUpdate().File == m.File) { SplashScreen.UpdateStatusText("All files downloaded!"); Thread.Sleep(1000); warnDisconnect = false; Packet.Send(new LogPacket { LogMessages = MinecraftModUpdater.Logger.GetMessages() }, ph.Stream); Packet.Send(new DisconnectPacket(), ph.Stream); ph.RemovePacketHandler(PacketId.Metadata); ph.RemovePacketHandler(PacketId.ModInfo); ph.RemovePacketHandler(PacketId.ModList); ph.RemovePacketHandler(PacketId.NextDownload); ph.RemovePacketHandler(PacketId.FilePart); ph.RemovePacketHandler(PacketId.AllDone); TaskManager.AddAsyncTask(delegate { ph.Stop(); }, ThreadRole.Delayed, 5000); if (Properties.Settings.Default.LaunchAfterUpdate) { Program.RunOnUIThread(delegate { Program.StartMinecraft(); }); } else { SplashScreen.CloseSplashScreen(); } Program.RunOnUIThread(delegate { Close(); }); return; } progress[0]++; m = (Mod)lsModsToUpdate.Items[progress[0]]; Packet.Send(new RequestModPacket { Type = RequestModPacket.RequestType.Download, Identifier = m.Identifier }, ph.Stream); }
public static void CloseWaitForm() { m_splashScreen.CloseSplashScreen(); }
void ph_ModInfo(Packet pa) { ModInfoPacket p = pa as ModInfoPacket; Mod m = new Mod { Author = p.Author, File = p.File, Name = p.ModName, Hash = p.Hash, Size = p.FileSize, Description = p.Description, Identifier = p.Identifier, Optional = p.Optional, Requires = p.Requires.ToList() }; if (m.Optional) { OptionalMods.Add(m); } else { Mods.Add(m); } string path = Path.GetDirectoryName(Properties.Settings.Default.MinecraftPath + "\\" + p.File); string s = ""; bool exists = File.Exists(path + "\\" + Path.GetFileName(m.File)); if (exists) { try { s = Extras.GenerateHash(path + "\\" + Path.GetFileName(m.File)); } catch (Exception e) { MinecraftModUpdater.Logger.Log(e); } } if ((!exists && !m.Optional) || (s != m.Hash && !m.Optional)) { Program.RunOnUIThread(delegate { lsModsToUpdate.Items.Add(m); }); } else if (!m.Optional) { Program.RunOnUIThread(delegate { lsMods.Items.Add(m); }); } if (exists && m.Optional && s == m.Hash) { Mods.Add(m); Program.RunOnUIThread(delegate { lsMods.Items.Add(m); }); } else if (exists && m.Optional && s != m.Hash) { Mods.Add(m); Program.RunOnUIThread(delegate { lsModsToUpdate.Items.Add(m); }); } MinecraftModUpdater.Logger.Log(Logger.Level.Debug, "Info: " + m.Name); string str = GetLastModId(); if (str == m.Identifier) { foreach (string str1 in Directory.GetFiles(Properties.Settings.Default.MinecraftPath + @"\mods")) { string str2 = @"mods\" + Path.GetFileName(str1); Mod mod = Mods.FindFromFile(str2); bool file = mod != null; if (!file) { Program.RunOnUIThread(delegate { lsModsToDelete.Items.Add(Path.GetFileName(str1)); }); } } } if (str == m.Identifier && Properties.Settings.Default.AutoUpdate) { Program.RunOnUIThread(delegate { btnConfirm_Click(null, null); }); } else if (str == m.Identifier) { List <Mod> allMods = new List <Mod>(); allMods.AddRange(Mods); allMods.AddRange(OptionalMods); foreach (Mod mod in Mods) { mod.BuildRequiredByList(allMods.ToArray().ToList()); //Just so that we don't modify the mod list. } foreach (Mod mod in OptionalMods) { mod.BuildRequiredByList(allMods.ToArray().ToList()); //Just so that we don't modify the mod list. } Program.RunOnUIThread(delegate { SplashScreen.CloseSplashScreen(); Show(); }); } else if (str != m.Identifier && !Properties.Settings.Default.AutoUpdate) { Program.RunOnUIThread(delegate { if (Visible) { Hide(); } }); } }
void ph_Metadata(Packet pa) { MetadataPacket p = pa as MetadataPacket; StringBuilder sb = new StringBuilder(); for (int i = 0; i < p.SData.Length; i++) { sb.AppendFormat("StringData {0}: {1}\r\n", i, p.SData[i]); } for (int i = 0; i < p.IData.Length; i++) { sb.AppendFormat("IntData {0}: {1}\r\n", i, p.IData[i]); } for (int i = 0; i < p.FData.Length; i++) { sb.AppendFormat("FloatData {0}: {1}\r\n", i, p.FData[i]); } Debug.Assert(sb.ToString()); if (p.SData[0] == "shutdown") { Server.Shutdown = true; if (SplashScreen.GetScreen() != null) { SplashScreen.UpdateStatusTextWithStatus(p.SData[1], TypeOfMessage.Error); SplashScreen.GetScreen().Progress.StartColor = Color.FromArgb(210, 202, 0); SplashScreen.GetScreen().Progress.EndColor = Color.FromArgb(210, 202, 0); } else { MessageBox.Show(p.SData[1], "Server Shutdown"); } MinecraftModUpdater.Logger.Log(Logger.Level.Error, "Server Shutdown. Reason: " + p.SData[1]); } else if (p.SData[0] == "server_name") { Server.Name = p.SData[1]; Server.FontSize = p.FData[0]; Properties.Settings.Default.MinecraftPath = Environment.CurrentDirectory + "/Minecraft/" + ServerFolder; MinecraftModUpdater.Logger.Log(Logger.Level.Info, string.Format("Minecraft path set to: {0}", Properties.Settings.Default.MinecraftPath)); } else if (p.SData[0] == "splash_display") { SplashScreen.UpdateStatusText(p.SData[1]); } else if (p.SData[0] == "require_version") { warnDisconnect = false; SplashScreen.UpdateStatusTextWithStatus("This server requires API version " + p.SData[1] + " for you to connect.", TypeOfMessage.Error); Thread.Sleep(3000); SplashScreen.CloseSplashScreen(); Thread.Sleep(1000); Program.RunOnUIThread(delegate { Close(); }); } else if (p.SData[0] == "version_downgrade") { ClientVersion = p.SData[1]; } }
private void MainForm_Load(object sender, EventArgs e) { try { #region 测试版 #if DEBUG try { var apiHelper = new ApiHelper(); DateTime now = apiHelper.GetDate(DateType.SysDate); if (now > AboutBox.PublishDate.AddMonths(1)) //发布一个月失效 { SplashScreen.CloseSplashScreen(); MsgBox.ShowErrorMessage("该测试版已失效,请下在最新版!"); OpenIE(Config.ProxyHeroCloudSetting.UpdateUrl); Exit_Click(Exit, new EventArgs()); } } catch (WebException) { Config.InitErrorInfo = Config.LocalLanguage.Messages.InitializeFailed + "," + Config.LocalLanguage.Messages.PleaseCheckNetworkSettingsAreCorrect; } #endif #endregion #region _languageLoader = new LanguageLoader(); TimerAutoSwitchingProxy = new Timer(); TimerAutoChangeIcon = new Timer(); //SplashScreen.UpdateStatusText(Config.LocalLanguage.Messages.InitializeDatabase); //Config.InitDatabase(); _deserializeDockContent = GetContentFromPersistString; SplashScreen.UpdateStatusText(Config.LocalLanguage.Messages.LoadingLanguages); Config.LanguageFileName = Config.LocalSetting.LanguageFileName; if (System.IO.File.Exists(Config.LanguageFileName)) { Config.LocalLanguage = XmlHelper.XmlDeserialize( Config.LanguageFileName, typeof(Language)) as Language; } LoadLanguage(); #endregion #region 初始化配置 GetNetConfigAndCheckVersion(); #endregion #region 连接云引擎 try { DelegateVoid dv = ConnectCloud; var thred = new Thread(new ThreadStart(dv)); thred.Start(); } catch { if (Config.LocalLanguage != null) { CloudStatus.Text = Config.LocalLanguage.Messages.ConnectCloudEngineFailed; } CloudStatus.Image = Resources.cloudno; } #endregion #region Hotkey //Hotkey hotkey = new Hotkey(this.Handle); //Hotkey1 = hotkey.RegisterHotkey(System.Windows.Forms.Keys.T, Hotkey.KeyFlags.MOD_CONTROL); //hotkey.OnHotkey += new HotkeyEventHandler(OnHotkey); #endregion #region UI MainToolbar.Visible = false; MainStatusBar.Items.Insert(2, new ToolStripSeparator()); MainStatusBar.Items.Insert(4, new ToolStripSeparator()); MainStatusBar.Items.Insert(6, new ToolStripSeparator()); MainStatusBar.Items.Insert(8, new ToolStripSeparator()); MainStatusBar.Items.Insert(10, new ToolStripSeparator()); tsslVersion.Text = @"Version:" + Assembly.GetExecutingAssembly().GetName().Version; if (Config.LocalLanguage != null) { CloudStatus.Text = Config.LocalLanguage.Messages.ConnectingCloudEngine; } _httpHelper.HttpOption.Timeout = 60 * 1000; SetProxyStatusLabel(); if (Config.LocalLanguage != null) { AutoSwitchProxyStatus.Text = Config.LocalLanguage.Messages.AutomaticSwitchingOff; } Status.Text = Config.InitErrorInfo; Status.Spring = true; #endregion #region timer TimerAutoSwitchingProxy.Enabled = false; TimerAutoSwitchingProxy.Interval = 1000; TimerAutoSwitchingProxy.Elapsed += timerAutoSwitchingProxy_Elapsed; TimerAutoChangeIcon.Enabled = false; TimerAutoChangeIcon.Interval = 1000; TimerAutoChangeIcon.Elapsed += timerAutoChangeIcon_Elapsed; #endregion #region DockPanel if (Config.LocalLanguage != null) { SplashScreen.UpdateStatusText(Config.LocalLanguage.Messages.InitializeDockPanel); if (System.IO.File.Exists(Config.DockSettingFileName)) { try { MainDockPanel.LoadFromXml(Config.DockSettingFileName, _deserializeDockContent); } catch { _hasDockSettingExceptioin = true; if (System.IO.File.Exists(Config.DockSettingFileName)) { SplashScreen.CloseSplashScreen(); System.IO.File.Delete(Config.DockSettingFileName); MsgBox.ShowErrorMessage(Config.LocalLanguage.Messages.InitializeFailed); Application.Exit(); } } } else { #region dock StartPage.Show(MainDockPanel, DockState.Document); InfoPage.Show(MainDockPanel, DockState.DockBottomAutoHide); InfoPage.Hide(); ProxyPage.Show(MainDockPanel, DockState.Document); #endregion } } #endregion #region LoadViewSetting(); if (Config.LocalLanguage != null) { SplashScreen.UpdateStatusText(Config.LocalLanguage.Messages.CheckUpdate); } CheckVersionAndDownLoad(); #region 读取上次代理 if (System.IO.File.Exists(Config.LastProxyFileName)) { ProxyData.ProxyList = (List <ProxyServer>) XmlHelper.XmlDeserialize(Config.LastProxyFileName, typeof(List <ProxyServer>)); ProxyPage.BindData(); } #endregion if (Config.LocalLanguage != null) { SplashScreen.UpdateStatusText(Config.LocalLanguage.Messages.LoadingPlugins); } PluginManager.LoadAllPlugins(); //如果没有获取代理网页列表,则禁止使用 #if !DEBUG if (Config.ProxySiteUrlList.Count == 0) { this.ProxyPage.Enabled = false; } #endif SplashScreen.CloseSplashScreen(); StartPage.Activate(); Activate(); if (Config.ProxyHeroCloudSetting.EnableCommercialPage == "1") //如果显示弹出广告 { #if !DEBUG if (Config.IsChineseOs) { this.OpenNewTab(Config.ProxyHeroCloudSetting.CommercialUrl); } else { this.OpenNewTab(Config.ProxyHeroCloudSetting.EnglishCommercialUrl); } #else OpenNewTab(Config.IsChineseLanguage ? Config.ProxyHeroCloudSetting.CommercialUrl : Config.ProxyHeroCloudSetting.EnglishCommercialUrl); #endif } #endregion } catch (Exception ex) { SplashScreen.CloseSplashScreen(); MsgBox.ShowExceptionMessage(ex); } }
static void Main(string[] args) { try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Registration registration = new Registration(); string filename = Path.Combine(Application.StartupPath, "License.dat"); bool AuthResult = false; if (!(File.Exists(filename) && registration.AuthSerial(filename))) { if (DialogResult.OK == registration.ShowDialog()) { AuthResult = true; } } else { AuthResult = true; } if (AuthResult) { //JZUpgrade.Logger log = new JZUpgrade.Logger(); //log.Logfolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log"); //log.IsUseLog = true; //log.QueueBufferSize = 5; //JZUpgrade.UpdateHelperClient uhc = new JZUpgrade.UpdateHelperClient(log, "8"); //if (!ProcessHelper.IsRuningProcess("JZUpgradeAgent")) //{ // ProcessStartInfo Info = new ProcessStartInfo(); // Info.CreateNoWindow = false; // Info.UseShellExecute = true; // Info.FileName = Path.Combine(Application.StartupPath, "JZUpgrade.exe"); // Info.Arguments = "\"8\""; // //1 管理系统文件+不执行,2 采集系统文件+不执行,3 管理系统数据+不执行, // //4 管理系统文件+数据+执行; // //5 采集系统文件+执行 // //6 管理系统执行 // //7 采集系统执行 // //8 管理系统文件+执行 // Process.Start(Info); //} Again: Boolean isRemote = Internet.IsWanAlive(); LoginDialog loginDialog = new LoginDialog(); //如果有sys.xml且NetTcpDomainAddress做了配置,强制更改Endpoint设置 string EndPointAddress0 = BizCommon.ConfigHelper.GetEndpointAddress("TransferServiceEndPoint").ToString(); string NetTcpDomainAddress0 = BizCommon.ConfigHelper.GetSysXmlValue("NetTcpDomainAddress"); string strAddressM0 = EndPointAddress0.Replace("net.tcp://", ""); strAddressM0 = strAddressM0.Substring(0, strAddressM0.IndexOf('/')); string strAddressE0 = EndPointAddress0.Replace("net.tcp://", "").Replace(strAddressM0, ""); if (!string.IsNullOrEmpty(NetTcpDomainAddress0))//配置了域名地址,开始判断域名地址 { EndPointAddress0 = "net.tcp://" + NetTcpDomainAddress0 + strAddressE0; BizCommon.ConfigHelper.SetEndpointAddress("TransferServiceEndPoint", EndPointAddress0); } if (DialogResult.OK == loginDialog.ShowDialog()) { if (loginDialog.IsUpdate == false) { #region 登录 const String resourceName = "Splash.jpg"; // 嵌入的资源图片的名字 splash = SplashScreen.Current; splash.SetTransparentKey = Color.Fuchsia; splash.SetBackgroundImage = GetResource(resourceName); splash.SetFade = true;//设置淡入淡出效果 splash.ShowSplashScreen(); AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.AssemblyLoad += asmLoadHandler; splash.SetStatus = "验证用户并登录..."; if (loginDialog.com_User.Text.Trim() == "") { splash.CloseSplashScreen(); MessageBox.Show("请输入用户名。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); goto Again; } try { isRemote = true; Boolean logined = loginDialog.Login(isRemote); if (!logined) { //Modifyed By TanLiPing In 2014-03-16 //添加智能识别DNS和域名代码 if (Yqun.Services.Agent.TestNetwork() == true)//net.tcp配置可以正常访问网络 { splash.CloseSplashScreen(); MessageBox.Show("用户名或密码错误,请重新输入。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); goto Again; } else//使用备用地址 { bool bNetWorkIsConnected = false; string EndPointAddress = BizCommon.ConfigHelper.GetEndpointAddress("TransferServiceEndPoint").ToString(); string NetTcpDomainAddress = BizCommon.ConfigHelper.GetSysXmlValue("NetTcpDomainAddress"); string strAddressM = EndPointAddress.Replace("net.tcp://", ""); strAddressM = strAddressM.Substring(0, strAddressM.IndexOf('/')); string strAddressE = EndPointAddress.Replace("net.tcp://", "").Replace(strAddressM, ""); if (!string.IsNullOrEmpty(NetTcpDomainAddress))//配置了域名地址,开始判断域名地址 { EndPointAddress = "net.tcp://" + NetTcpDomainAddress + strAddressE; BizCommon.ConfigHelper.SetEndpointAddress("TransferServiceEndPoint", EndPointAddress); if (Yqun.Services.Agent.TestNetwork() == true)//域名可以连接上 { bNetWorkIsConnected = true; } else { string NetTcpIPAddress = BizCommon.ConfigHelper.GetSysXmlValue("NetTcpIPAddress"); if (!string.IsNullOrEmpty(NetTcpIPAddress)) { EndPointAddress = "net.tcp://" + NetTcpIPAddress + strAddressE; BizCommon.ConfigHelper.SetEndpointAddress("TransferServiceEndPoint", EndPointAddress); if (Yqun.Services.Agent.TestNetwork() == true) { bNetWorkIsConnected = true; } } else { bNetWorkIsConnected = false; EndPointAddress = "net.tcp://" + strAddressM + strAddressE; BizCommon.ConfigHelper.SetEndpointAddress("TransferServiceEndPoint", EndPointAddress); } } } else { string NetTcpIPAddress = BizCommon.ConfigHelper.GetSysXmlValue("NetTcpIPAddress"); if (!string.IsNullOrEmpty(NetTcpIPAddress)) { EndPointAddress = "net.tcp://" + NetTcpIPAddress + strAddressE; BizCommon.ConfigHelper.SetEndpointAddress("TransferServiceEndPoint", EndPointAddress); if (Yqun.Services.Agent.TestNetwork() == true) { bNetWorkIsConnected = true; } } else { bNetWorkIsConnected = false; EndPointAddress = "net.tcp://" + strAddressM + strAddressE; BizCommon.ConfigHelper.SetEndpointAddress("TransferServiceEndPoint", EndPointAddress); } } if (bNetWorkIsConnected) { logined = loginDialog.Login(isRemote); if (!logined) { splash.CloseSplashScreen(); MessageBox.Show("用户名或密码错误,请重新输入。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); goto Again; } } else { splash.CloseSplashScreen(); MessageBox.Show("连接不上服务器端,请检查网络配置。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); goto Again; } } } } catch (Exception ex) { splash.CloseSplashScreen(); MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); goto Again; } splash.SetStatus = "登录成功并注册用户信息..."; loginDialog.MemberUser(); splash.SetStatus = "启动主程序..."; splash.CloseSplashScreen(); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); //验证初始密码,用户取消退出程序 if (!loginDialog.ChangDefaultPwd()) { Application.Exit(); } else { Application.Run(new MainForm()); } #endregion } else { #region 更新 JZUpgrade.UpdateAlert ua = new JZUpgrade.UpdateAlert(1); if (ua.ShowDialog() == DialogResult.OK) { if (!ProcessHelper.IsRuningProcess("JZUpgradeAgent")) { ProcessStartInfo Info = new ProcessStartInfo(); Info.CreateNoWindow = false; Info.UseShellExecute = true; Info.FileName = Path.Combine(Application.StartupPath, "JZUpgrade.exe"); Info.Arguments = "\"8\""; //1 管理系统文件+不执行,2 采集系统文件+不执行,3 管理系统数据+不执行, //4 管理系统文件+数据+执行; //5 采集系统文件+执行 //6 管理系统执行 //7 采集系统执行 //8 管理系统文件+执行 Process.Start(Info); //Process currentProcess = Process.GetCurrentProcess(); //currentProcess.Kill(); } } #endregion } } } //} //else //{ // MessageBox.Show("一个实例正在运行...", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // Application.Exit(); //} } catch (Exception ex) { String Error = string.Format("应用程序出错,出错原因:{0}", ex.Message); logger.Error(Error); MessageBox.Show(Error, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } }
/// <summary> /// The main entry point for the MP2 client application. /// </summary> private static void Main(params string[] args) { Thread.CurrentThread.Name = "Main"; // Parse command line options var mpOptions = new CommandLineOptions(); var parser = new CommandLine.Parser(with => with.HelpWriter = Console.Out); parser.ParseArgumentsStrict(args, mpOptions, () => Environment.Exit(1)); // Check if another instance is already running if (SingleInstanceHelper.IsAlreadyRunning(MUTEX_ID, out _mutex)) { _mutex = null; // Set focus on previously running app SingleInstanceHelper.SwitchToCurrentInstance(SingleInstanceHelper.SHOW_MP2_CLIENT_MESSAGE); // Stop current instance Console.Out.WriteLine("Application already running."); Environment.Exit(2); } #if !DEBUG string logPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), @"Team MediaPortal\MP2-Client\Log"); #endif Application.ThreadException += LauncherExceptionHandling.Application_ThreadException; AppDomain.CurrentDomain.UnhandledException += LauncherExceptionHandling.CurrentDomain_UnhandledException; TaskScheduler.UnobservedTaskException += LauncherExceptionHandling.TaskScheduler_UnobservedTaskException; SystemStateService systemStateService = new SystemStateService(); ServiceRegistration.Set <ISystemStateService>(systemStateService); systemStateService.SwitchSystemState(SystemState.Initializing, false); try { #if !DEBUG SplashScreen splashScreen = null; #endif ILogger logger = null; try { // Check if user wants to override the default Application Data location. ApplicationCore.RegisterVitalCoreServices(true, mpOptions.DataDirectory); #if !DEBUG splashScreen = CreateSplashScreen(); splashScreen.ShowSplashScreen(); #endif ApplicationCore.RegisterCoreServices(); logger = ServiceRegistration.Get <ILogger>(); #if !DEBUG IPathManager pathManager = ServiceRegistration.Get <IPathManager>(); logPath = pathManager.GetPath("<LOG>"); #endif UiExtension.RegisterUiServices(); } catch (Exception e) { if (logger != null) { logger.Critical("Error starting application", e); } systemStateService.SwitchSystemState(SystemState.ShuttingDown, true); ServiceRegistration.IsShuttingDown = true; UiExtension.DisposeUiServices(); ApplicationCore.DisposeCoreServices(); throw; } // Start the core logger.Debug("ApplicationLauncher: Starting application"); try { IPluginManager pluginManager = ServiceRegistration.Get <IPluginManager>(); pluginManager.Initialize(); pluginManager.Startup(false); ApplicationCore.StartCoreServices(); ISkinEngine skinEngine = ServiceRegistration.Get <ISkinEngine>(); IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); IMediaAccessor mediaAccessor = ServiceRegistration.Get <IMediaAccessor>(); ILocalSharesManagement localSharesManagement = ServiceRegistration.Get <ILocalSharesManagement>(); // We have to handle some dependencies here in the start order: // 1) After all plugins are loaded, the SkinEngine can initialize (=load all skin resources) // 2) After the skin resources are loaded, the workflow manager can initialize (=load its states and actions) // 3) Before the main window is shown, the splash screen should be hidden // 4) After the workflow states and actions are loaded, the main window can be shown // 5) After the skinengine triggers the first workflow state/startup screen, the default shortcuts can be registered mediaAccessor.Initialize(); // Independent from other services localSharesManagement.Initialize(); // After media accessor was initialized skinEngine.Initialize(); // 1) workflowManager.Initialize(); // 2) #if !DEBUG splashScreen.CloseSplashScreen(); // 3) #endif skinEngine.Startup(); // 4) UiExtension.Startup(); // 5) ApplicationCore.RegisterDefaultMediaItemAspectTypes().Wait(); // To be done after UI services are running _ipcServer = new IpcServer("Client"); _ipcServer.CustomShutdownCallback = () => { ServiceRegistration.Get <IScreenControl>().Shutdown(); return(true); }; try { _ipcServer.Open(); } catch (Exception ipcEx) { logger.Error(ipcEx); } systemStateService.SwitchSystemState(SystemState.Running, true); if (mpOptions.AutoStart) { StartFocusKeeper(); } Application.Run(); systemStateService.SwitchSystemState(SystemState.ShuttingDown, true); ServiceRegistration.IsShuttingDown = true; // Block ServiceRegistration from trying to load new services in shutdown phase // 1) Stop UI extensions (Releases all active players, must be done before shutting down SE) // 2) Shutdown SkinEngine (Closes all screens, uninstalls background manager, stops render thread) // 3) Shutdown WorkflowManager (Disposes all models) // 4) Shutdown ImporterWorker // 5) Shutdown PluginManager (Shuts down all plugins) // 6) Remove all services UiExtension.StopUiServices(); skinEngine.Shutdown(); workflowManager.Shutdown(); ServiceRegistration.Get <IImporterWorker>().Shutdown(); pluginManager.Shutdown(); mediaAccessor.Shutdown(); localSharesManagement.Shutdown(); ApplicationCore.StopCoreServices(); } catch (Exception e) { logger.Critical("Error executing application", e); systemStateService.SwitchSystemState(SystemState.ShuttingDown, true); ServiceRegistration.IsShuttingDown = true; } finally { if (_ipcServer != null) { _ipcServer.Close(); } UiExtension.DisposeUiServices(); ApplicationCore.DisposeCoreServices(); systemStateService.SwitchSystemState(SystemState.Ending, false); } } catch (Exception ex) { #if DEBUG ConsoleLogger log = new ConsoleLogger(LogLevel.All, false); log.Error(ex); #else UiCrashLogger crash = new UiCrashLogger(logPath); crash.CreateLog(ex); #endif systemStateService.SwitchSystemState(SystemState.Ending, false); // Release mutex for single instance if (_mutex != null) { _mutex.ReleaseMutex(); } Application.Exit(); } }
/// <summary> /// The main entry point for the MP 2 client application. /// </summary> private static void Main(params string[] args) { Thread.CurrentThread.Name = "Main"; #if !DEBUG SplashScreen splashScreen = CreateSplashScreen(); splashScreen.ShowSplashScreen(); #endif // Parse Command Line options CommandLineOptions mpArgs = new CommandLineOptions(); ICommandLineParser parser = new CommandLineParser(new CommandLineParserSettings(Console.Error)); if (!parser.ParseArguments(args, mpArgs, Console.Out)) { Environment.Exit(1); } #if !DEBUG string logPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), @"Team MediaPortal\MP2-Client\Log"); #endif SystemStateService systemStateService = new SystemStateService(); ServiceRegistration.Set <ISystemStateService>(systemStateService); systemStateService.SwitchSystemState(SystemState.Initializing, false); try { ILogger logger = null; try { // Check if user wants to override the default Application Data location. ApplicationCore.RegisterCoreServices(mpArgs.DataDirectory); logger = ServiceRegistration.Get <ILogger>(); #if !DEBUG IPathManager pathManager = ServiceRegistration.Get <IPathManager>(); logPath = pathManager.GetPath("<LOG>"); #endif UiExtension.RegisterUiServices(); } catch (Exception e) { if (logger != null) { logger.Critical("Error starting application", e); } systemStateService.SwitchSystemState(SystemState.ShuttingDown, true); ServiceRegistration.IsShuttingDown = true; UiExtension.DisposeUiServices(); ApplicationCore.DisposeCoreServices(); throw; } // Start the core logger.Debug("ApplicationLauncher: Starting application"); try { IPluginManager pluginManager = ServiceRegistration.Get <IPluginManager>(); pluginManager.Initialize(); pluginManager.Startup(false); ApplicationCore.StartCoreServices(); ISkinEngine skinEngine = ServiceRegistration.Get <ISkinEngine>(); IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); IMediaAccessor mediaAccessor = ServiceRegistration.Get <IMediaAccessor>(); ILocalSharesManagement localSharesManagement = ServiceRegistration.Get <ILocalSharesManagement>(); // We have to handle some dependencies here in the start order: // 1) After all plugins are loaded, the SkinEngine can initialize (=load all skin resources) // 2) After the skin resources are loaded, the workflow manager can initialize (=load its states and actions) // 3) Before the main window is shown, the splash screen should be hidden // 4) After the workflow states and actions are loaded, the main window can be shown // 5) After the skinengine triggers the first workflow state/startup screen, the default shortcuts can be registered mediaAccessor.Initialize(); // Independent from other services localSharesManagement.Initialize(); // After media accessor was initialized skinEngine.Initialize(); // 1) workflowManager.Initialize(); // 2) #if !DEBUG splashScreen.CloseSplashScreen(); // 3) #endif skinEngine.Startup(); // 4) UiExtension.Startup(); // 5) ApplicationCore.RegisterDefaultMediaItemAspectTypes(); // To be done after UI services are running systemStateService.SwitchSystemState(SystemState.Running, true); Application.Run(); systemStateService.SwitchSystemState(SystemState.ShuttingDown, true); ServiceRegistration.IsShuttingDown = true; // Block ServiceRegistration from trying to load new services in shutdown phase // 1) Stop UI extensions (Releases all active players, must be done before shutting down SE) // 2) Shutdown SkinEngine (Closes all screens, uninstalls background manager, stops render thread) // 3) Shutdown WorkflowManager (Disposes all models) // 4) Shutdown PluginManager (Shuts down all plugins) // 5) Remove all services UiExtension.StopUiServices(); skinEngine.Shutdown(); workflowManager.Shutdown(); pluginManager.Shutdown(); mediaAccessor.Shutdown(); localSharesManagement.Shutdown(); ApplicationCore.StopCoreServices(); } catch (Exception e) { logger.Critical("Error executing application", e); systemStateService.SwitchSystemState(SystemState.ShuttingDown, true); ServiceRegistration.IsShuttingDown = true; } finally { UiExtension.DisposeUiServices(); ApplicationCore.DisposeCoreServices(); systemStateService.SwitchSystemState(SystemState.Ending, false); } } catch (Exception ex) { #if DEBUG ConsoleLogger log = new ConsoleLogger(LogLevel.All, false); log.Error(ex); #else UiCrashLogger crash = new UiCrashLogger(logPath); crash.CreateLog(ex); #endif systemStateService.SwitchSystemState(SystemState.Ending, false); Application.Exit(); } }
public void HandleStartSplash() { isStartSplash = false; Game.S.detective.inMenu = false; splashScreen.CloseSplashScreen(); }
private void Connect() { Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket = s; Debug.Assert("Creating Objects."); try { string srv = Server.Address; int port = Server.Port; if (srv == LocalAddress.ToString()) { srv = "127.0.0.1"; } ConnectionHandler.ConnectTo(s, srv, port); SplashScreen.GetScreen().Progress.PerformStep(); } catch (SocketException ex) { Debug.Assert(ex); MessageBox.Show("There was an error while connecting to the update server. I will now self destruct."); Thread.Sleep(1000); SplashScreen.UpdateStatusTextWithStatus("Boom!!!", TypeOfMessage.Error); Thread.Sleep(5000); SplashScreen.UpdateStatusTextWithStatus("That was a joke, by the way.", TypeOfMessage.Warning); Thread.Sleep(1000); SplashScreen.CloseSplashScreen(); Thread.Sleep(3000); Close(); return; } catch (Exception ex) { ExceptionHandler.HandleException(ex, this); } modImages = new ImageList(); modImages.ImageSize = new Size(230, 180); modImages.ColorDepth = ColorDepth.Depth32Bit; SplashScreen.GetScreen().Progress.PerformStep(); TaskManager.AddAsyncTask(delegate { while (s.Connected) { ; } if (!warnDisconnect) { return; } if (SplashScreen.GetScreen() != null) { SplashScreen.UpdateStatusTextWithStatus("Lost connection to server.", TypeOfMessage.Error); Thread.Sleep(5000); } else { MessageBox.Show("Lost connection to server."); } Program.RunOnUIThread(delegate { Close(); }); }); MinecraftModUpdater.Logger.Log(Logger.Level.Info, "Logging started."); ph = new PacketHandler(s); ph.Start(); for (int i = 0; i < 10; i++) { TaskManager.SpawnTaskThread(ThreadRole.Standard); } TaskManager.AddAsyncTask(delegate { ph.RegisterPacketHandler(PacketId.Metadata, ph_Metadata); ph.RegisterPacketHandler(PacketId.ModInfo, ph_ModInfo); ph.RegisterPacketHandler(PacketId.ModList, ph_ModList); ph.RegisterPacketHandler(PacketId.AllDone, ph_AllDone); ph.RegisterPacketHandler(PacketId.NextDownload, ph_NextDownload); ph.RegisterPacketHandler(PacketId.FilePart, ph_FilePart); ph.RegisterPacketHandler(PacketId.Image, ph_Image); Debug.Assert("Packet Handlers registered."); SplashScreen.GetScreen().Progress.PerformStep(); }); if ((new LoginForm()).ShowDialog() != DialogResult.OK) { MinecraftModUpdater.Logger.Log(Logger.Level.Error, "Login failed"); SplashScreen.UpdateStatusTextWithStatus("Your login failed.", TypeOfMessage.Error); Thread.Sleep(2000); SplashScreen.CloseSplashScreen(); Thread.Sleep(400); Close(); return; } Thread.Sleep(1000); SplashScreen.UpdateStatusText("Connected to server. Retreving Mod List."); Packet.Send(new HandshakePacket { Username = ProgramOptions.Username }, ph.Stream); Debug.Assert("Sent Handshake Packet."); Thread.Sleep(100); for (int i = 0; i < 5; i++) { SplashScreen.GetScreen().Progress.Value += 1; Thread.Sleep(20); } }