public Form1() { Process[] processcollection = Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName); if (processcollection.Length > 1) { MessageBox.Show("当登录成功后,会留下后台进程检查并维持登录,如果出现问题您可以尝试使用任务管理器终止", "程序已经在运行"); System.Environment.Exit(0); } if (File.Exists(Application.StartupPath + "\\IP.txt")) { try { using (StreamReader IPconf = new StreamReader(Application.StartupPath + "\\IP.txt")) { String IPset = IPconf.ReadToEnd(); loginer = new Loginer(IPset); } } catch { MessageBox.Show("您的 \"IP.txt\" 文件存在问题,请删除或修正"); } } else { loginer = new Loginer(""); } setVisible = Hide; Control.CheckForIllegalCrossThreadCalls = false; InitializeComponent(); }
private void SetButtomVisibled(bool visibled, Button button) { if (button.InvokeRequired) { var call = new SetVisible(SetButtomVisibled); Invoke(call, visibled, button); } else { button.Visible = visibled; } }
private void SetVisibleControl(bool state) { if (this.ServerDisconnected.InvokeRequired) { var d = new SetVisible(this.SetVisibleControl); ServerDisconnected.Invoke(d, state); } else { this.ServerDisconnected.Visible = state; } }
private void Import() { if (File.Exists(localeo_path.Text) && File.Exists(ipo_path.Text) && Directory.Exists(Path.GetDirectoryName(olocale_path.Text))) { if (import_msg.InvokeRequired) { SetTextCallback d = new SetTextCallback(SetText); this.Invoke(d, new object[] { "" }); } using (Stream stream = new FileStream(localeo_path.Text, FileMode.Open, FileAccess.Read)) { Locale m_Locale = DataSerializer.Deserialize <Locale>(stream, DataSerializer.Mode.File); Dictionary <Locale.Key, string> m_LocalizedStrings = Utils.GetPrivateField <Dictionary <Locale.Key, string> >(m_Locale, "m_LocalizedStrings"); Dictionary <Locale.Key, string> l_LocalizedStrings = new Dictionary <Locale.Key, string>(m_LocalizedStrings); List <string> lines = new List <string>(); using (StreamReader file = new StreamReader(ipo_path.Text)) { string line; while ((line = file.ReadLine()) != null) { lines.Add(line); } } if (progress.InvokeRequired) { SetMaximum d = new SetMaximum(SetMaximum); this.Invoke(d, new object[] { lines.Count }); } if (progress.InvokeRequired) { SetVisible d = new SetVisible(SetVisible); this.Invoke(d, new object[] { true }); } Regex regex = new Regex(@"#. ""(.+)\[(.+)\]:(\d+)""|#. ""(.+):(\d+)"""); Regex regex_msgid = new Regex(@"msgid ""(.+)"""); Regex regex_msgstr = new Regex(@"msgstr ""(.+)"""); for (int i = 0; i < lines.Count; i++) { if (progress.InvokeRequired) { SetValue d = new SetValue(SetValue); this.Invoke(d, new object[] { i + 1 }); } if (i + 2 < lines.Count && regex.IsMatch(lines[i])) { string m_Identifier = regex.Match(lines[i]).Groups[1].Value.Length != 0 ? regex.Match(lines[i]).Groups[1].Value : regex.Match(lines[i]).Groups[4].Value; string m_Index = regex.Match(lines[i]).Groups[3].Value.Length != 0 ? regex.Match(lines[i]).Groups[3].Value : regex.Match(lines[i]).Groups[5].Value; string m_Key = regex.Match(lines[i]).Groups[2].Value.Length != 0 ? regex.Match(lines[i]).Groups[2].Value : null; string msgid = regex_msgid.Match(lines[i + 1]).Groups[1].Value; string msgstr = regex_msgstr.Match(lines[i + 2]).Groups[1].Value; if (msgid.Length != 0) { Locale.Key key = new Locale.Key(); key.m_Identifier = m_Identifier; key.m_Index = int.Parse(m_Index); key.m_Key = m_Key; if (l_LocalizedStrings.ContainsKey(key)) { l_LocalizedStrings.Remove(key); l_LocalizedStrings.Add(key, msgid.Replace(@"\r", "\r").Replace(@"\n", "\n")); } else { l_LocalizedStrings.Add(key, msgid.Replace(@"\r", "\r").Replace(@"\n", "\n")); } } } } string m_EnglishName = language_e.Text; string m_NativeName = language.Text; if (m_EnglishName.Length != 0) { Utils.SetPrivateField <string>(m_Locale, "m_EnglishName", m_EnglishName); } if (m_NativeName.Length != 0) { Utils.SetPrivateField <string>(m_Locale, "m_NativeName", m_NativeName); } Utils.SetPrivateField <Dictionary <Locale.Key, string> >(m_Locale, "m_LocalizedStrings", l_LocalizedStrings); Utils.ExportFile(olocale_path.Text, m_Locale); if (import_msg.InvokeRequired) { SetTextCallback d = new SetTextCallback(SetText); this.Invoke(d, new object[] { "import success !" }); } if (progress.InvokeRequired) { SetVisible d = new SetVisible(SetVisible); this.Invoke(d, new object[] { false }); } } } else { if (import_msg.InvokeRequired) { SetTextCallback d = new SetTextCallback(SetText); this.Invoke(d, new object[] { "file or directory not exist !" }); } } }
override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { SetVisible.SetVisibleObject(); }