public static void SetLanguage(this TextEx text, int id) { if (text != null) { text.SetText(Language.Get(id)); } }
public static GameObject CreateButton(Resources resources) { GameObject buttonRoot = CreateUIElementRoot("Button", s_ThickElementSize); GameObject childText = new GameObject("Text"); childText.AddComponent <RectTransform>(); SetParentAndAlign(childText, buttonRoot); ImageEx image = buttonRoot.AddComponent <ImageEx>(); image.sprite = resources.standard; image.type = ImageEx.Type.Sliced; image.color = s_DefaultSelectableColor; ButtonEx bt = buttonRoot.AddComponent <ButtonEx>(); SetDefaultColorTransitionValues(bt); TextEx text = childText.AddComponent <TextEx>(); text.text = "Button"; text.alignment = TextAnchor.MiddleCenter; SetDefaultTextValues(text); RectTransform textRectTransform = childText.GetComponent <RectTransform>(); textRectTransform.anchorMin = Vector2.zero; textRectTransform.anchorMax = Vector2.one; textRectTransform.sizeDelta = Vector2.zero; return(buttonRoot); }
public static void SetText(this TextEx text, object @object) { if (text != null) { text.SetText(@object.ToString()); } }
private static void SaveTextFile(Control control, IWin32Window owner = null) { if (!(control is Control c)) { return; } if (string.IsNullOrEmpty(c.Text)) { MessageBoxEx.Show(owner, UIStrings.TextCanNotBeEmpty, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } using (var dialog = new SaveFileDialog()) { dialog.Filter = $@"{UIStrings.TextFiles}|*.txt"; dialog.FileName = $"{Path.GetFileNameWithoutExtension(PathEx.LocalPath)} {DateTime.Now:yyyy-MM-dd HH.mm.ss}.txt"; if (dialog.ShowDialog() == DialogResult.OK) { try { File.WriteAllText(dialog.FileName, TextEx.FormatNewLine(c.Text)); MessageBoxEx.Show(owner, UIStrings.FileSuccessfullySaved, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } catch (Exception ex) when(ex.IsCaught()) { MessageBoxEx.Show(owner, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Warning); } return; } MessageBoxEx.Show(owner, UIStrings.OperationCanceled, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }
public static void SetColor(this TextEx text, Color color) { if (text != null) { text.color = color; } }
public static GameObject CreateToggle(Resources resources) { // Set up hierarchy GameObject toggleRoot = CreateUIElementRoot("Toggle", s_ThinElementSize); GameObject background = CreateUIObject("Background", toggleRoot); GameObject checkmark = CreateUIObject("Checkmark", background); GameObject childLabel = CreateUIObject("Label", toggleRoot); // Set up components Toggle toggle = toggleRoot.AddComponent <Toggle>(); toggle.isOn = true; ImageEx bgImage = background.AddComponent <ImageEx>(); bgImage.sprite = resources.standard; bgImage.type = ImageEx.Type.Sliced; bgImage.color = s_DefaultSelectableColor; ImageEx checkmarkImage = checkmark.AddComponent <ImageEx>(); checkmarkImage.sprite = resources.checkmark; TextEx label = childLabel.AddComponent <TextEx>(); label.text = "Toggle"; SetDefaultTextValues(label); toggle.graphic = checkmarkImage; toggle.targetGraphic = bgImage; SetDefaultColorTransitionValues(toggle); RectTransform bgRect = background.GetComponent <RectTransform>(); bgRect.anchorMin = new Vector2(0f, 1f); bgRect.anchorMax = new Vector2(0f, 1f); bgRect.anchoredPosition = new Vector2(10f, -10f); bgRect.sizeDelta = new Vector2(kThinHeight, kThinHeight); RectTransform checkmarkRect = checkmark.GetComponent <RectTransform>(); checkmarkRect.anchorMin = new Vector2(0.5f, 0.5f); checkmarkRect.anchorMax = new Vector2(0.5f, 0.5f); checkmarkRect.anchoredPosition = Vector2.zero; checkmarkRect.sizeDelta = new Vector2(20f, 20f); RectTransform labelRect = childLabel.GetComponent <RectTransform>(); labelRect.anchorMin = new Vector2(0f, 0f); labelRect.anchorMax = new Vector2(1f, 1f); labelRect.offsetMin = new Vector2(23f, 1f); labelRect.offsetMax = new Vector2(-5f, -2f); return(toggleRoot); }
private static void SetDefaultTextValues(TextEx lbl) { // Set text values we want across UI elements in default controls. // Don't set values which are the same as the default values for the TextEx component, // since there's no point in that, and it's good to keep them as consistent as possible. lbl.color = s_TextColor; // Reset() is not called when playing. We still want the default font to be assigned //lbl.AssignDefaultFont(); }
public static GameObject CreateInputField(Resources resources) { GameObject root = CreateUIElementRoot("InputField", s_ThickElementSize); GameObject childPlaceholder = CreateUIObject("Placeholder", root); GameObject childText = CreateUIObject("Text", root); ImageEx image = root.AddComponent <ImageEx>(); image.sprite = resources.inputField; image.type = ImageEx.Type.Sliced; image.color = s_DefaultSelectableColor; InputField inputField = root.AddComponent <InputField>(); SetDefaultColorTransitionValues(inputField); TextEx text = childText.AddComponent <TextEx>(); text.text = ""; text.supportRichText = false; SetDefaultTextValues(text); TextEx placeholder = childPlaceholder.AddComponent <TextEx>(); placeholder.text = "Enter text..."; placeholder.fontStyle = FontStyle.Italic; // Make placeholder color half as opaque as normal text color. Color placeholderColor = text.color; placeholderColor.a *= 0.5f; placeholder.color = placeholderColor; RectTransform textRectTransform = childText.GetComponent <RectTransform>(); textRectTransform.anchorMin = Vector2.zero; textRectTransform.anchorMax = Vector2.one; textRectTransform.sizeDelta = Vector2.zero; textRectTransform.offsetMin = new Vector2(10, 6); textRectTransform.offsetMax = new Vector2(-10, -7); RectTransform placeholderRectTransform = childPlaceholder.GetComponent <RectTransform>(); placeholderRectTransform.anchorMin = Vector2.zero; placeholderRectTransform.anchorMax = Vector2.one; placeholderRectTransform.sizeDelta = Vector2.zero; placeholderRectTransform.offsetMin = new Vector2(10, 6); placeholderRectTransform.offsetMax = new Vector2(-10, -7); inputField.textComponent = text; inputField.placeholder = placeholder; return(root); }
public static GameObject CreateText(Resources resources) { GameObject go = CreateUIElementRoot("Text", s_ThickElementSize); TextEx lbl = go.AddComponent <TextEx>(); lbl.text = "New Text"; SetDefaultTextValues(lbl); return(go); }
static int Copy(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); TextEx obj = (TextEx)ToLua.CheckObject <TextEx>(L, 1); UnityEngine.UI.Text arg0 = (UnityEngine.UI.Text)ToLua.CheckObject <UnityEngine.UI.Text>(L, 2); obj.Copy(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int SetFontName(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); TextEx obj = (TextEx)ToLua.CheckObject <TextEx>(L, 1); string arg0 = ToLua.CheckString(L, 2); obj.SetFontName(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetFontName(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); TextEx obj = (TextEx)ToLua.CheckObject <TextEx>(L, 1); string o = obj.GetFontName(); LuaDLL.lua_pushstring(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static TextEx AddTextEx(GameObject go2, string txt) { RectTransform rt = go2.GetComponent <RectTransform>(); rt.sizeDelta = new Vector2(200, 24); TextEx t = go2.AddComponentIfNoExist <TextEx>(); t.raycastTarget = false; t.font = AssetDatabase.LoadAssetAtPath <Font>("Assets/UI/Font/hkhw5.TTF"); t.fontSize = 22; t.color = Color.white; t.text = txt; return(t); }
static int SetFont(IntPtr L) { try { ToLua.CheckArgsCount(L, 3); TextEx obj = (TextEx)ToLua.CheckObject <TextEx>(L, 1); UnityEngine.Font arg0 = (UnityEngine.Font)ToLua.CheckObject(L, 2, typeof(UnityEngine.Font)); string arg1 = ToLua.CheckString(L, 3); obj.SetFont(arg0, arg1); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public override void OnInspectorGUI() { TextEx textEx = target as TextEx; EditorGUI.BeginChangeCheck(); textEx.m_minPreferredWidth = EditorGUILayout.FloatField("minPreferredWidth", textEx.m_minPreferredWidth); textEx.m_maxPreferredWidth = EditorGUILayout.FloatField("maxPreferredWidth", textEx.m_maxPreferredWidth); if (EditorGUI.EndChangeCheck()) { EditorUtil.SetDirty(textEx); LayoutRebuilder.MarkLayoutForRebuild(textEx.transform as RectTransform); } base.OnInspectorGUI(); }
static int get_preferredWidth(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); TextEx obj = (TextEx)o; float ret = obj.preferredWidth; LuaDLL.lua_pushnumber(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index preferredWidth on a nil value")); } }
private static void WriteInnerLine(string message = default, string caption = default, ConsoleColor captionFgColor = DefaultFgColor, ConsoleColor captionBgColor = DefaultBgColor) { if (string.IsNullOrWhiteSpace(message)) { Console.WriteLine(); return; } if (!_active) { _active = true; } message = message.Trim(); if (!string.IsNullOrWhiteSpace(caption)) { caption = " " + caption.Trim(); if (!caption.EndsWith(":")) { caption = $"{caption}:"; } SetColors(captionFgColor, captionBgColor); Console.Write(caption); SetColors(); for (var i = caption.Length; i < 10; i++) { Console.Write(@" "); } if (message.ContainsEx("\r", "\n")) { var lines = TextEx.FormatNewLine(message).SplitNewLine(); for (var i = 1; i < lines.Length; i++) { lines[i] = lines[i].PadLeft(lines[i].Length + 11); } message = lines.Join(Environment.NewLine); } } Console.WriteLine(@" " + message); }
public void InitEmoji() { string strPath = "Assets/Emoji/emoji/emoji_c.png"; Object[] sprites = UnityEditor.AssetDatabase.LoadAllAssetsAtPath(strPath); for (int i = 0; i < sprites.Length; i++) { Sprite sp = sprites[i] as Sprite; if (sp != null) { TextEx.AddEmoji(sp.name); if (!m_dicEmojiSprite.ContainsKey(sp.name)) { m_dicEmojiSprite.Add(sp.name, sp); } continue; } } strPath = "Assets/Emoji/emoji/emoji_mat.mat"; Object mat = UnityEditor.AssetDatabase.LoadAssetAtPath(strPath, typeof(Material)); m_emojiMaterial = mat as Material; }
/* * Eventhandler is invoked e. g. in case of generating a new password * in PwEntryForm with password being visible */ private void ColoredSecureTextBoxChanged(object sender, EventArgs e) { if (UseSystemPasswordChar) { return; } if (m_text == null) { return; } //password is shown in plaintext already => no need to protect anything string pw = TextEx.ReadString(); if (pw != m_text.Text) { PluginDebug.AddInfo(Name + " ColoredSecureTextBoxChanged - Text changed"); m_text.Text = pw; } else { PluginDebug.AddInfo(Name + " ColoredSecureTextBoxChanged - Text not changed"); } }
static private void RewriteUIPrefab(Transform node) { ImageEx _uisprite = node.GetComponent <ImageEx>(); if (_uisprite != null) { if (_uisprite.sprite != null) { string path = AssetDatabase.GetAssetPath(_uisprite.sprite); TextureImporter texImp = AssetImporter.GetAtPath(path) as TextureImporter; if (texImp != null) { _uisprite.SetInfo(texImp.spritePackingTag, _uisprite.sprite.name); } else { _uisprite.SetInfo(null, null); } _uisprite.sprite = null; } else { _uisprite.SetInfo(null, null); } } RawImageEx _uitexture = node.GetComponent <RawImageEx>(); if (_uitexture != null) { if (_uitexture.texture != null) { _uitexture.SetInfo(_uitexture.texture.name); _uitexture.texture = null; } else { _uitexture.SetInfo(null); } } ButtonEx _uibutton = node.GetComponent <ButtonEx>(); if (_uibutton != null) { if (_uibutton.spriteState.highlightedSprite != null) { string path = AssetDatabase.GetAssetPath(_uibutton.spriteState.highlightedSprite); TextureImporter texImp = AssetImporter.GetAtPath(path) as TextureImporter; if (texImp != null) { _uibutton.SetButtonInfo(1, texImp.spritePackingTag, _uibutton.spriteState.highlightedSprite.name); } else { _uibutton.SetButtonInfo(1, null, null); } } else { _uibutton.SetButtonInfo(1, null, null); } if (_uibutton.spriteState.pressedSprite != null) { string path = AssetDatabase.GetAssetPath(_uibutton.spriteState.pressedSprite); TextureImporter texImp = AssetImporter.GetAtPath(path) as TextureImporter; if (texImp != null) { _uibutton.SetButtonInfo(2, texImp.spritePackingTag, _uibutton.spriteState.pressedSprite.name); } else { _uibutton.SetButtonInfo(2, null, null); } } else { _uibutton.SetButtonInfo(2, null, null); } if (_uibutton.spriteState.disabledSprite != null) { string path = AssetDatabase.GetAssetPath(_uibutton.spriteState.disabledSprite); TextureImporter texImp = AssetImporter.GetAtPath(path) as TextureImporter; if (texImp != null) { _uibutton.SetButtonInfo(3, texImp.spritePackingTag, _uibutton.spriteState.disabledSprite.name); } else { _uibutton.SetButtonInfo(3, null, null); } } else { _uibutton.SetButtonInfo(3, null, null); } _uibutton.spriteState = new SpriteState(); } TextEx _uitext = node.GetComponent <TextEx>(); if (_uitext != null) { if (_uitext.font != null) { if (_uitext.font.name.Equals("Arial")) { //_uitext.SetInfo("DFYuanW7"); } else { _uitext.SetInfo(_uitext.font.name); _uitext.font = null; } } else { _uitext.SetInfo(null); } } for (int i = 0; i < node.childCount; ++i) { RewriteUIPrefab(node.GetChild(i)); } }
private void MainForm_Load(object sender, EventArgs e) { Text = Resources.WindowTitle; TaskBar.Progress.SetState(Handle, TaskBar.Progress.Flags.Indeterminate); if (!NetEx.InternetIsAvailable()) { if (!_silent || !File.Exists(_appPath)) { MessageBoxEx.Show(Resources.Msg_Err_00, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } Application.Exit(); return; } var source = NetEx.Transfer.DownloadString(Resources.RegexUrl); string updUrl = null; try { var pattern = string.Format(Resources.RegexUrlPattern, #if x86 "32" #else "64" #endif ); source = TextEx.FormatNewLine(source).SplitNewLine().SkipWhile(x => !x.ContainsEx("p95") && !x.ContainsEx(".zip")).Take(1).Join(); foreach (Match match in Regex.Matches(source, pattern, RegexOptions.Singleline | RegexOptions.IgnoreCase)) { var mUrl = match.Groups[1].ToString(); if (string.IsNullOrWhiteSpace(mUrl)) { continue; } updUrl = string.Format(Resources.UpdateUrl, mUrl, #if x86 "32" #else "64" #endif ); break; } if (!NetEx.FileIsAvailable(updUrl, 60000, Resources.UserAgent)) { throw new PathNotFoundException(updUrl); } } catch (Exception ex) { Log.Write(ex); if (!_silent || !File.Exists(_appPath)) { MessageBoxEx.Show(Resources.Msg_Warn_01, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } Application.Exit(); return; } var localDate = File.GetLastWriteTime(_appPath); var onlineDate = NetEx.GetFileDate(updUrl, Resources.UserAgent); if ((onlineDate - localDate).Days > 0) { if (_silent || MessageBoxEx.Show(Resources.Msg_Hint_00, Resources.WindowTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { var archivePath = PathEx.Combine(PathEx.LocalDir, $"..\\{PathEx.GetTempFileName()}"); if (!File.Exists(archivePath)) { _transfer.DownloadFile(updUrl, archivePath); Opacity = 1f; CheckDownload.Enabled = true; return; } ExtractDownload.RunWorkerAsync(); } Application.Exit(); return; } if (!_silent) { MessageBoxEx.Show(Resources.Msg_Hint_01, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } Application.Exit(); }
private void MainForm_Load(object sender, EventArgs e) { Text = Resources.WindowTitle; TaskBar.Progress.SetState(Handle, TaskBar.Progress.Flags.Indeterminate); if (!NetEx.InternetIsAvailable()) { if (!_silent || !File.Exists(_appPath)) { MessageBoxEx.Show(Resources.Msg_Err_00, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } Application.Exit(); return; } string updUrl = null; try { var source = NetEx.Transfer.DownloadString(Resources.RegexFirstUrl); if (string.IsNullOrWhiteSpace(source)) { throw new ArgumentNullException(nameof(source)); } source = TextEx.FormatNewLine(source).SplitNewLine().SkipWhile(x => !x.ContainsEx(Resources.RegexSecBtnMatch)).Take(1).Join(); foreach (Match match in Regex.Matches(source, Resources.RegexSecUrlPattern, RegexOptions.Singleline)) { var mUrl = match.Groups[1].ToString(); if (string.IsNullOrWhiteSpace(mUrl)) { continue; } source = NetEx.Transfer.DownloadString(mUrl); if (string.IsNullOrWhiteSpace(source)) { throw new ArgumentNullException(nameof(source)); } source = TextEx.FormatNewLine(source).SplitNewLine().SkipWhile(x => !x.ContainsEx(Resources.RegexThirdBtnMatch) || !Resources.RegexThirdExtMatch.SplitNewLine().Any(y => x.ContainsEx(y))).Take(1).Join(); foreach (Match match2 in Regex.Matches(source, Resources.RegexThirdUrlPattern, RegexOptions.Singleline)) { mUrl = match2.Groups[1].ToString(); if (string.IsNullOrWhiteSpace(mUrl)) { continue; } if (mUrl.ContainsEx("/show/")) { mUrl = mUrl.Replace("/show/", "/get/"); } updUrl = mUrl; break; } break; } if (!NetEx.FileIsAvailable(updUrl, 60000, Resources.UserAgent)) { throw new PathNotFoundException(updUrl); } } catch (Exception ex) { Log.Write(ex); if (!_silent || !File.Exists(_appPath)) { MessageBoxEx.Show(Resources.Msg_Warn_01, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } Application.Exit(); return; } var localDate = File.GetLastWriteTime(_appPath); var onlineDate = NetEx.GetFileDate(updUrl, Resources.UserAgent); if ((onlineDate - localDate).Days > 0) { if (_silent || MessageBoxEx.Show(Resources.Msg_Hint_00, Resources.WindowTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { var archivePath = PathEx.Combine(PathEx.LocalDir, $"..\\{PathEx.GetTempFileName()}"); if (!File.Exists(archivePath)) { _tmpDir = PathEx.Combine(Path.GetTempPath(), PathEx.GetTempDirName(Resources.AppName)); var hlpPath = Path.Combine(_tmpDir, "iu.zip"); ResourcesEx.Extract(Resources.iu, hlpPath, true); Compaction.Unzip(hlpPath, _tmpDir); _transfer.DownloadFile(updUrl, archivePath); Opacity = 1f; CheckDownload.Enabled = true; return; } ExtractDownload.RunWorkerAsync(); } Application.Exit(); return; } if (!_silent) { MessageBoxEx.Show(Resources.Msg_Hint_01, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } Application.Exit(); }
/// <summary> /// Sets registry values from an INI config or from a REG file. /// </summary> /// <param name="fileOrContent"> /// The path or content of an INI or REG file. /// </param> public static void SetConfig(string fileOrContent) { if (string.IsNullOrWhiteSpace(fileOrContent)) { return; } var sections = Ini.GetSections(fileOrContent, false); try { if (sections.All(x => x.StartsWith("HKEY_")) && sections.All(x => Ini.GetKeys(x, fileOrContent, false).All(y => y.Equals("@") || y.StartsWith("\"") && y.EndsWith("\"")))) { try { var regex = new Regex("%(.+?)%"); var content = File.Exists(fileOrContent) ? File.ReadAllText(fileOrContent) : fileOrContent; foreach (var variable in regex.Matches(content).Cast <Match>().Select(x => x.Value).Distinct()) { var value = EnvironmentEx.GetVariableValue(variable); if (!content.ContainsEx(variable)) { continue; } content = content.Replace(variable, value); } var cArray = TextEx.FormatNewLine(content).SplitNewLine(); Reg.ImportFile(cArray); } catch (Exception ex) { Log.Write(ex); } return; } } catch (Exception ex) { Log.Write(ex); } foreach (var section in Ini.GetSections(fileOrContent, false)) { var key = Ini.Read(section, "Key", default(string), fileOrContent); if (string.IsNullOrEmpty(key)) { continue; } var entry = Ini.Read(section, "Entry", default(string), fileOrContent); var value = Ini.Read(section, "Value", default(string), fileOrContent); if (string.IsNullOrEmpty(value)) { continue; } if (!string.IsNullOrEmpty(entry)) { entry = PathEx.Combine(entry); } value = PathEx.Combine(value); var kind = Ini.Read(section, "Kind", default(string), fileOrContent); if (string.IsNullOrEmpty(kind)) { continue; } try { Reg.Write(key, !string.IsNullOrWhiteSpace(entry) ? entry : null, value, (RegistryValueKind)Enum.Parse(typeof(RegistryValueKind), kind)); } catch (Exception ex) { Log.Write(ex); continue; } var temp = Ini.Read(section, "Temp", default(string), fileOrContent); if (!temp.EqualsEx("True", "Entry")) { continue; } AppDomain.CurrentDomain.ProcessExit += (s, e) => { switch (temp.ToLower()) { case "true": Reg.RemoveSubKey(key); break; case "entry": Reg.RemoveEntry(key, entry); break; } }; } }
private void MainForm_Load(object sender, EventArgs e) { FormEx.Dockable(this); Lang.SetControlLang(this); // Check internet connection if (!(_ipv4 = NetEx.InternetIsAvailable()) && !(_ipv6 = NetEx.InternetIsAvailable(true))) { Environment.ExitCode = 1; Application.Exit(); return; } // Get update infos from GitHub if enabled if (Ini.Read("Settings", "UpdateChannel", 0) > 0) { if (!_ipv4 && _ipv6) { Environment.ExitCode = 1; Application.Exit(); return; } try { var path = PathEx.AltCombine(Resources.GitRawProfileUri, Resources.GitSnapshotsPath, "Last.ini"); if (!NetEx.FileIsAvailable(path, 60000)) { throw new PathNotFoundException(path); } var data = NetEx.Transfer.DownloadString(path); if (string.IsNullOrWhiteSpace(data)) { throw new ArgumentNullException(nameof(data)); } _lastStamp = Ini.ReadOnly("Info", "LastStamp", data); if (string.IsNullOrWhiteSpace(_lastStamp)) { throw new ArgumentNullException(_lastStamp); } path = PathEx.AltCombine(Resources.GitRawProfileUri, Resources.GitSnapshotsPath, $"{_lastStamp}.ini"); if (!NetEx.FileIsAvailable(path, 60000)) { throw new PathNotFoundException(path); } data = NetEx.Transfer.DownloadString(path); if (string.IsNullOrWhiteSpace(data)) { throw new ArgumentNullException(nameof(data)); } _hashInfo = data; } catch (Exception ex) { Log.Write(ex); } } // Get update infos if not already set if (string.IsNullOrWhiteSpace(_hashInfo)) { // Get available download mirrors var dnsInfo = string.Empty; for (var i = 0; i < 3; i++) { if (!_ipv4 && _ipv6) { dnsInfo = Resources.IPv6DNS; break; } try { var path = PathEx.AltCombine(Resources.GitRawProfileUri, Resources.GitDnsPath); if (!NetEx.FileIsAvailable(path, 60000)) { throw new PathNotFoundException(path); } var data = NetEx.Transfer.DownloadString(path); if (string.IsNullOrWhiteSpace(data)) { throw new ArgumentNullException(nameof(data)); } dnsInfo = data; } catch (Exception ex) { Log.Write(ex); } if (string.IsNullOrWhiteSpace(dnsInfo) && i < 2) { Thread.Sleep(1000); continue; } break; } if (!string.IsNullOrWhiteSpace(dnsInfo)) { foreach (var section in Ini.GetSections(dnsInfo)) { var addr = Ini.Read(section, _ipv4 ? "addr" : "ipv6", dnsInfo); if (string.IsNullOrEmpty(addr)) { continue; } var domain = Ini.Read(section, "domain", dnsInfo); if (string.IsNullOrEmpty(domain)) { continue; } var ssl = Ini.ReadOnly(section, "ssl", false, dnsInfo); domain = PathEx.AltCombine(ssl ? "https:" : "http:", domain); if (!DownloadMirrors.ContainsEx(domain)) { DownloadMirrors.Add(domain); } } } if (DownloadMirrors.Count == 0) { Environment.ExitCode = 1; Application.Exit(); return; } // Get file hashes foreach (var mirror in DownloadMirrors) { try { var path = PathEx.AltCombine(mirror, Resources.ReleasePath, "Last.ini"); if (!NetEx.FileIsAvailable(path, 60000)) { throw new PathNotFoundException(path); } var data = NetEx.Transfer.DownloadString(path); if (string.IsNullOrWhiteSpace(data)) { throw new ArgumentNullException(nameof(data)); } _lastFinalStamp = Ini.ReadOnly("Info", "LastStamp", data); if (string.IsNullOrWhiteSpace(_lastFinalStamp)) { throw new ArgumentNullException(nameof(_lastFinalStamp)); } path = PathEx.AltCombine(mirror, Resources.ReleasePath, $"{_lastFinalStamp}.ini"); if (!NetEx.FileIsAvailable(path, 60000)) { throw new PathNotFoundException(path); } data = NetEx.Transfer.DownloadString(path); if (string.IsNullOrWhiteSpace(data)) { throw new ArgumentNullException(nameof(data)); } _hashInfo = data; } catch (Exception ex) { Log.Write(ex); } if (!string.IsNullOrWhiteSpace(_hashInfo)) { break; } } } if (string.IsNullOrWhiteSpace(_hashInfo)) { Environment.ExitCode = 1; Application.Exit(); return; } // Compare hashes var updateAvailable = false; try { foreach (var key in Ini.GetKeys("SHA256", _hashInfo)) { var file = Path.Combine(HomeDir, $"{key}.exe"); if (!File.Exists(file)) { file = PathEx.Combine(PathEx.LocalDir, $"{key}.exe"); } if (Ini.Read("SHA256", key, _hashInfo).EqualsEx(Crypto.EncryptFileToSha256(file))) { continue; } updateAvailable = true; break; } } catch (Exception ex) { Log.Write(ex); Environment.ExitCode = 1; Application.Exit(); return; } // Install updates if (updateAvailable) { if (MessageBox.Show(Lang.GetText(nameof(en_US.UpdateAvailableMsg)), Text, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { // Update changelog if (DownloadMirrors.Count > 0) { var changes = string.Empty; foreach (var mirror in DownloadMirrors) { var path = PathEx.AltCombine(mirror, Resources.ReleasePath, "ChangeLog.txt"); if (string.IsNullOrWhiteSpace(path)) { continue; } if (!NetEx.FileIsAvailable(path, 60000)) { continue; } changes = NetEx.Transfer.DownloadString(path); if (!string.IsNullOrWhiteSpace(changes)) { break; } } if (!string.IsNullOrWhiteSpace(changes)) { changeLog.Font = new Font("Consolas", 8.25f); changeLog.Text = TextEx.FormatNewLine(changes); var colorMap = new Dictionary <Color, string[]> { { Color.PaleGreen, new[] { " PORTABLE APPS SUITE", " UPDATED:", " CHANGES:" } }, { Color.SkyBlue, new[] { " Global:", " Apps Launcher:", " Apps Downloader:", " Apps Suite Updater:" } }, { Color.Khaki, new[] { "Version History:" } }, { Color.Plum, new[] { "{", "}", "(", ")", "|", ".", "-" } }, { Color.Tomato, new[] { " * " } }, { Color.Black, new[] { new string('_', 84) } } }; foreach (var line in changeLog.Text.Split('\n')) { if (line.Length < 1 || !DateTime.TryParseExact(line.Trim(' ', ':'), "d MMMM yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime _)) { continue; } changeLog.MarkText(line, Color.Khaki); } foreach (var color in colorMap) { foreach (var s in color.Value) { changeLog.MarkText(s, color.Key); } } } } else { changeLog.Dock = DockStyle.None; changeLog.Size = new Size(changeLogPanel.Width, TextRenderer.MeasureText(changeLog.Text, changeLog.Font).Height); changeLog.Location = new Point(0, changeLogPanel.Height / 2 - changeLog.Height - 16); changeLog.SelectAll(); changeLog.SelectionAlignment = HorizontalAlignment.Center; changeLog.DeselectAll(); } ShowInTaskbar = true; return; } } // Exit the application if no updates were found Environment.ExitCode = 2; Application.Exit(); }
private void MainForm_Load(object sender, EventArgs e) { Text = Resources.WindowTitle; TaskBar.Progress.SetState(Handle, TaskBar.Progress.Flags.Indeterminate); if (!NetEx.InternetIsAvailable()) { if (!_silent || !File.Exists(_appPath)) { MessageBoxEx.Show(Resources.Msg_Err_00, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } Application.Exit(); return; } Version localVersion; try { var version = FileVersionInfo.GetVersionInfo(_appPath).FileVersion; if (version.Contains(',')) { version = version.Split(',').Select(c => c.Trim()).Join('.'); } localVersion = Version.Parse(version); } catch { localVersion = new Version("0.0.0.0"); } Version onlineVersion; try { var source = NetEx.Transfer.DownloadString(Resources.VersionUrl); if (string.IsNullOrEmpty(source)) { throw new ArgumentNullException(nameof(source)); } source = TextEx.FormatNewLine(source).SplitNewLine().SkipWhile(x => !x.ContainsEx(Resources.VersionHeader)).Take(1).Join(); var inner = Regex.Match(source, Resources.VersionRegex).Groups[1].ToString(); if (string.IsNullOrEmpty(inner)) { throw new ArgumentNullException(nameof(inner)); } var index = inner.IndexOf('('); if (index < 0) { throw new ArgumentOutOfRangeException(nameof(index)); } var ver = inner.Substring(0, index).Trim(' ', 'v').Split('.'); if (!Version.TryParse($"{ver.Take(2).Join('.')}.0.{ver.Last()}", out onlineVersion)) { throw new ArgumentNullException(nameof(onlineVersion)); } } catch (Exception ex) { Log.Write(ex); if (!_silent || !File.Exists(_appPath)) { MessageBoxEx.Show(Resources.Msg_Warn_01, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } Application.Exit(); return; } if (localVersion < onlineVersion) { if (_silent || MessageBoxEx.Show(Resources.Msg_Hint_00, Resources.WindowTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { var archivePath = PathEx.Combine(PathEx.LocalDir, $"..\\{PathEx.GetTempFileName()}"); if (!File.Exists(archivePath)) { _transfer.DownloadFile(Resources.UpdateUrl, archivePath); Opacity = 1f; CheckDownload.Enabled = true; return; } ExtractDownload.RunWorkerAsync(); } Application.Exit(); return; } if (!_silent) { MessageBoxEx.Show(Resources.Msg_Hint_01, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } Application.Exit(); }
private void MainForm_Load(object sender, EventArgs e) { Text = Resources.WindowTitle; TaskBar.Progress.SetState(Handle, TaskBar.Progress.Flags.Indeterminate); if (!NetEx.InternetIsAvailable()) { if (!_silent || !File.Exists(_appPath)) { MessageBoxEx.Show(Resources.Msg_Err_00, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } Application.Exit(); return; } string updUrl = null; try { var regexUrl = Resources.RegexUrl; if (!Ini.ReadDirect("Settings", "BetaUpdates").EqualsEx("1", "True")) { regexUrl += "/latest"; } var source = NetEx.Transfer.DownloadString(regexUrl); if (string.IsNullOrWhiteSpace(source)) { throw new ArgumentNullException(nameof(source)); } source = TextEx.FormatNewLine(source); #if x86 const string arch = "32"; #else const string arch = "64"; #endif source = source.SplitNewLine().Where(x => x.ContainsEx(Resources.SearchPrefix) && x.ContainsEx(string.Format(Resources.SearchSuffix, arch))).Take(1).Join(); foreach (Match match in Regex.Matches(source, Resources.RegexPattern, RegexOptions.Singleline)) { var mPath = match.Groups[1].ToString(); if (string.IsNullOrWhiteSpace(mPath) || mPath.Count(c => c == '/') != 1) { continue; } updUrl = string.Format(Resources.UpdateUrl, mPath); break; } if (!NetEx.FileIsAvailable(updUrl, 60000, Resources.UserAgent)) { throw new PathNotFoundException(updUrl); } } catch (Exception ex) { Log.Write(ex); if (!_silent || !File.Exists(_appPath)) { MessageBoxEx.Show(Resources.Msg_Warn_01, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } Application.Exit(); } var localDate = File.GetLastWriteTime(_appPath); var onlineDate = NetEx.GetFileDate(updUrl, Resources.UserAgent); if ((onlineDate - localDate).Days > 0) { if (_silent || MessageBoxEx.Show(Resources.Msg_Hint_00, Resources.WindowTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { var archivePath = PathEx.Combine(PathEx.LocalDir, $"..\\{PathEx.GetTempFileName()}"); if (!File.Exists(archivePath)) { _tmpDir = PathEx.Combine(Path.GetTempPath(), PathEx.GetTempDirName(Resources.AppName)); var hlpPath = Path.Combine(_tmpDir, "7z.zip"); ResourcesEx.Extract(Resources._7z, hlpPath, true); Compaction.Unzip(hlpPath, _tmpDir); _transfer.DownloadFile(updUrl, archivePath); Opacity = 1f; CheckDownload.Enabled = true; return; } ExtractDownload.RunWorkerAsync(); } Application.Exit(); return; } if (!_silent) { MessageBoxEx.Show(Resources.Msg_Hint_01, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } Application.Exit(); }
public static GameObject CreateDropdown(Resources resources) { GameObject root = CreateUIElementRoot("Dropdown", s_ThickElementSize); GameObject label = CreateUIObject("Label", root); GameObject arrow = CreateUIObject("Arrow", root); GameObject template = CreateUIObject("Template", root); GameObject viewport = CreateUIObject("Viewport", template); GameObject content = CreateUIObject("Content", viewport); GameObject item = CreateUIObject("Item", content); GameObject itemBackground = CreateUIObject("Item Background", item); GameObject itemCheckmark = CreateUIObject("Item Checkmark", item); GameObject itemLabel = CreateUIObject("Item Label", item); // Sub controls. GameObject scrollbar = CreateScrollbar(resources); scrollbar.name = "Scrollbar"; SetParentAndAlign(scrollbar, template); Scrollbar scrollbarScrollbar = scrollbar.GetComponent <Scrollbar>(); scrollbarScrollbar.SetDirection(Scrollbar.Direction.BottomToTop, true); RectTransform vScrollbarRT = scrollbar.GetComponent <RectTransform>(); vScrollbarRT.anchorMin = Vector2.right; vScrollbarRT.anchorMax = Vector2.one; vScrollbarRT.pivot = Vector2.one; vScrollbarRT.sizeDelta = new Vector2(vScrollbarRT.sizeDelta.x, 0); // Setup item UI components. TextEx itemLabelText = itemLabel.AddComponent <TextEx>(); SetDefaultTextValues(itemLabelText); itemLabelText.alignment = TextAnchor.MiddleLeft; ImageEx itemBackgroundImage = itemBackground.AddComponent <ImageEx>(); itemBackgroundImage.color = new Color32(245, 245, 245, 255); ImageEx itemCheckmarkImage = itemCheckmark.AddComponent <ImageEx>(); itemCheckmarkImage.sprite = resources.checkmark; Toggle itemToggle = item.AddComponent <Toggle>(); itemToggle.targetGraphic = itemBackgroundImage; itemToggle.graphic = itemCheckmarkImage; itemToggle.isOn = true; // Setup template UI components. ImageEx templateImage = template.AddComponent <ImageEx>(); templateImage.sprite = resources.standard; templateImage.type = ImageEx.Type.Sliced; ScrollRect templateScrollRect = template.AddComponent <ScrollRect>(); templateScrollRect.content = (RectTransform)content.transform; templateScrollRect.viewport = (RectTransform)viewport.transform; templateScrollRect.horizontal = false; templateScrollRect.movementType = ScrollRect.MovementType.Clamped; templateScrollRect.verticalScrollbar = scrollbarScrollbar; templateScrollRect.verticalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport; templateScrollRect.verticalScrollbarSpacing = -3; Mask scrollRectMask = viewport.AddComponent <Mask>(); scrollRectMask.showMaskGraphic = false; ImageEx viewportImage = viewport.AddComponent <ImageEx>(); viewportImage.sprite = resources.mask; viewportImage.type = ImageEx.Type.Sliced; // Setup dropdown UI components. TextEx labelText = label.AddComponent <TextEx>(); SetDefaultTextValues(labelText); labelText.alignment = TextAnchor.MiddleLeft; ImageEx arrowImage = arrow.AddComponent <ImageEx>(); arrowImage.sprite = resources.dropdown; ImageEx backgroundImage = root.AddComponent <ImageEx>(); backgroundImage.sprite = resources.standard; backgroundImage.color = s_DefaultSelectableColor; backgroundImage.type = ImageEx.Type.Sliced; Dropdown dropdown = root.AddComponent <Dropdown>(); dropdown.targetGraphic = backgroundImage; SetDefaultColorTransitionValues(dropdown); dropdown.template = template.GetComponent <RectTransform>(); dropdown.captionText = labelText; dropdown.itemText = itemLabelText; // Setting default Item list. itemLabelText.text = "Option A"; dropdown.options.Add(new Dropdown.OptionData { text = "Option A" }); dropdown.options.Add(new Dropdown.OptionData { text = "Option B" }); dropdown.options.Add(new Dropdown.OptionData { text = "Option C" }); dropdown.RefreshShownValue(); // Set up RectTransforms. RectTransform labelRT = label.GetComponent <RectTransform>(); labelRT.anchorMin = Vector2.zero; labelRT.anchorMax = Vector2.one; labelRT.offsetMin = new Vector2(10, 6); labelRT.offsetMax = new Vector2(-25, -7); RectTransform arrowRT = arrow.GetComponent <RectTransform>(); arrowRT.anchorMin = new Vector2(1, 0.5f); arrowRT.anchorMax = new Vector2(1, 0.5f); arrowRT.sizeDelta = new Vector2(20, 20); arrowRT.anchoredPosition = new Vector2(-15, 0); RectTransform templateRT = template.GetComponent <RectTransform>(); templateRT.anchorMin = new Vector2(0, 0); templateRT.anchorMax = new Vector2(1, 0); templateRT.pivot = new Vector2(0.5f, 1); templateRT.anchoredPosition = new Vector2(0, 2); templateRT.sizeDelta = new Vector2(0, 150); RectTransform viewportRT = viewport.GetComponent <RectTransform>(); viewportRT.anchorMin = new Vector2(0, 0); viewportRT.anchorMax = new Vector2(1, 1); viewportRT.sizeDelta = new Vector2(-18, 0); viewportRT.pivot = new Vector2(0, 1); RectTransform contentRT = content.GetComponent <RectTransform>(); contentRT.anchorMin = new Vector2(0f, 1); contentRT.anchorMax = new Vector2(1f, 1); contentRT.pivot = new Vector2(0.5f, 1); contentRT.anchoredPosition = new Vector2(0, 0); contentRT.sizeDelta = new Vector2(0, 28); RectTransform itemRT = item.GetComponent <RectTransform>(); itemRT.anchorMin = new Vector2(0, 0.5f); itemRT.anchorMax = new Vector2(1, 0.5f); itemRT.sizeDelta = new Vector2(0, 20); RectTransform itemBackgroundRT = itemBackground.GetComponent <RectTransform>(); itemBackgroundRT.anchorMin = Vector2.zero; itemBackgroundRT.anchorMax = Vector2.one; itemBackgroundRT.sizeDelta = Vector2.zero; RectTransform itemCheckmarkRT = itemCheckmark.GetComponent <RectTransform>(); itemCheckmarkRT.anchorMin = new Vector2(0, 0.5f); itemCheckmarkRT.anchorMax = new Vector2(0, 0.5f); itemCheckmarkRT.sizeDelta = new Vector2(20, 20); itemCheckmarkRT.anchoredPosition = new Vector2(10, 0); RectTransform itemLabelRT = itemLabel.GetComponent <RectTransform>(); itemLabelRT.anchorMin = Vector2.zero; itemLabelRT.anchorMax = Vector2.one; itemLabelRT.offsetMin = new Vector2(20, 1); itemLabelRT.offsetMax = new Vector2(-10, -2); template.SetActive(false); return(root); }
private void MainForm_Load(object sender, EventArgs e) { Text = Resources.WindowTitle; TaskBar.Progress.SetState(Handle, TaskBar.Progress.Flags.Indeterminate); if (!NetEx.InternetIsAvailable()) { if (!_silent || !File.Exists(_appPath)) { MessageBoxEx.Show(Resources.Msg_Err_00, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } Application.Exit(); return; } var source = NetEx.Transfer.DownloadString(Resources.UpdateUrl); string updUrl; try { source = TextEx.FormatNewLine(source).SplitNewLine().SkipWhile(x => !x.ContainsEx(Resources.AppName) && !x.ContainsEx(".zip")).FirstOrDefault(); source = source.Split("\"").SkipWhile(x => !x.ContainsEx(Resources.AppName) && !x.ContainsEx(".zip")).FirstOrDefault(); if (string.IsNullOrEmpty(source)) { throw new ArgumentNullException(nameof(source)); } updUrl = source; if (!NetEx.FileIsAvailable(updUrl, 60000, Resources.UserAgent)) { throw new PathNotFoundException(updUrl); } } catch (Exception ex) { Log.Write(ex); if (!_silent || !File.Exists(_appPath)) { MessageBoxEx.Show(Resources.Msg_Warn_01, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } Application.Exit(); return; } var localDate = File.GetLastWriteTime(_appPath); var onlineDate = NetEx.GetFileDate(updUrl, Resources.UserAgent); if ((onlineDate - localDate).Days > 0) { if (_silent || MessageBoxEx.Show(Resources.Msg_Hint_00, Resources.WindowTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { var archivePath = PathEx.Combine(PathEx.LocalDir, $"..\\{PathEx.GetTempFileName()}"); if (!File.Exists(archivePath)) { _transfer.DownloadFile(updUrl, archivePath); Opacity = 1f; CheckDownload.Enabled = true; return; } ExtractDownload.RunWorkerAsync(); } Application.Exit(); return; } if (!_silent) { MessageBoxEx.Show(Resources.Msg_Hint_01, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } Application.Exit(); }
private bool SetChangeLogText(string text) { if (string.IsNullOrWhiteSpace(text)) { return(false); } changeLog.Font = new Font("Consolas", 8.25f); changeLog.Text = TextEx.FormatNewLine(text); var colorMap = new Dictionary <Color, string[]> { { Color.PaleGreen, new[] { " PORTABLE APPS SUITE", " UPDATED:", " CHANGES:" } }, { Color.SkyBlue, new[] { " Global:", " Apps Launcher:", " Apps Downloader:", " Apps Suite Updater:" } }, { Color.Khaki, new[] { "Version History:" } }, { Color.Plum, new[] { "{", "}", "(", ")", "|", ".", "-" } }, { Color.Tomato, new[] { " * " } }, { Color.Black, new[] { new string('_', 84) } } }; foreach (var line in changeLog.Text.Split('\n')) { if (line.Length < 1 || !DateTime.TryParseExact(line.Trim(' ', ':'), "d MMMM yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out var _)) { continue; } changeLog.MarkText(line, Color.Khaki); } foreach (var color in colorMap) { foreach (var s in color.Value) { changeLog.MarkText(s, color.Key); } } return(true); }
private void MainForm_Load(object sender, EventArgs e) { Text = Resources.WindowTitle; TaskBar.Progress.SetState(Handle, TaskBar.Progress.Flags.Indeterminate); if (!NetEx.InternetIsAvailable()) { if (!_silent || !File.Exists(_appPath)) { MessageBoxEx.Show(Resources.Msg_Err_00, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } Application.Exit(); return; } string updUrl = null; try { _tmpDir = PathEx.Combine(Path.GetTempPath(), PathEx.GetTempDirName(Resources.AppDisplayName)); var hlpPath = Path.Combine(_tmpDir, "js.zip"); ResourcesEx.Extract(Resources.js, hlpPath, true); Compaction.Unzip(hlpPath, _tmpDir); Thread.Sleep(200); var helperPath = Path.Combine(_tmpDir, "read.js"); var source = Path.Combine(_tmpDir, "source.txt"); File.WriteAllText(helperPath, Resources.JsScript); using (var p = ProcessEx.Send(string.Format(Resources.RunScript, _tmpDir), Elevation.IsAdministrator, ProcessWindowStyle.Hidden, false)) if (p?.HasExited == false) { p.WaitForExit(); } source = File.ReadAllText(source); if (string.IsNullOrWhiteSpace(source)) { throw new ArgumentNullException(nameof(source)); } source = TextEx.FormatNewLine(source).SplitNewLine().SkipWhile(x => !x.ContainsEx(".exe")).Take(1).Join(); foreach (Match match in Regex.Matches(source, Resources.RegexUrlPattern, RegexOptions.Singleline)) { var mUrl = match.Groups[1].ToString(); if (string.IsNullOrWhiteSpace(mUrl)) { continue; } updUrl = mUrl.Trim('"'); break; } if (!NetEx.FileIsAvailable(updUrl, 60000, Resources.UserAgent)) { throw new PathNotFoundException(updUrl); } } catch (Exception ex) { Log.Write(ex); if (!_silent || !File.Exists(_appPath)) { MessageBoxEx.Show(Resources.Msg_Warn_01, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } Application.Exit(); return; } var localDate = File.GetLastWriteTime(_appPath); var onlineDate = NetEx.GetFileDate(updUrl, Resources.UserAgent); if ((onlineDate - localDate).Days > 0) { if (_silent || MessageBoxEx.Show(Resources.Msg_Hint_00, Resources.WindowTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { var archivePath = PathEx.Combine(PathEx.LocalDir, $"..\\{PathEx.GetTempFileName()}"); if (!File.Exists(archivePath)) { var hlpPath = Path.Combine(_tmpDir, "iu.zip"); ResourcesEx.Extract(Resources.iu, hlpPath, true); Compaction.Unzip(hlpPath, _tmpDir); _transfer.DownloadFile(updUrl, archivePath); Opacity = 1f; CheckDownload.Enabled = true; return; } ExtractDownload.RunWorkerAsync(); } Application.Exit(); return; } if (!_silent) { MessageBoxEx.Show(Resources.Msg_Hint_01, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } Application.Exit(); }