private void AddIcoBox_CheckedChanged(object sender, EventArgs e) { if (AddIcoBox.Checked == true) { using var ofd = new OpenFileDialog { Title = "Выберите иконку для билд файла", Filter = "Icon|*.ico", AutoUpgradeEnabled = true, CheckFileExists = true, RestoreDirectory = true }; if (ofd.ShowDialog() == DialogResult.OK) { if (File.Exists(ofd.FileName)) { this.IconTextBox.Text = ofd.FileName; this.IcoViewer.ImageLocation = this.IconTextBox.Text; this.IcoViewer.BorderStyle = BorderStyle.None; this.LsizeIco.Visible = true; this.LsizeIco.Text = $"Размер иконки: {GetFileSize.Inizialize(new FileInfo(this.IconTextBox.Text).Length)}"; } else { this.IcoViewer.BorderStyle = BorderStyle.FixedSingle; this.IconTextBox.Clear(); AddIcoBox.Checked = false; this.LsizeIco.Visible = false; this.StatusCompile.Location = new Point(497, 392); ControlActive.CheckMessage(this.StatusCompile, "Иконка повреждена, выберите другую", Color.YellowGreen, 5000); } } else { this.IcoViewer.BorderStyle = BorderStyle.FixedSingle; this.IconTextBox.Clear(); AddIcoBox.Checked = false; this.LsizeIco.Visible = false; } } else { this.IcoViewer.BorderStyle = BorderStyle.FixedSingle; this.IconTextBox.Clear(); this.IcoViewer.Image = null; this.LsizeIco.Visible = false; } }
/// <summary> /// Выбор иконки для билд файла /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SelectIcon_Click(object sender, EventArgs e) { string result = string.Empty; using (var Open = new OpenFileDialog()) { Open.Title = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName.Equals("en", StringComparison.InvariantCultureIgnoreCase) ? Language.GlobalMessageStrings_en_US.IconChoice : Language.GlobalMessageStrings_ru_RU.IconChoice; Open.Filter = "Icon (*.ico)|*.ico"; Open.Multiselect = false; Open.AutoUpgradeEnabled = true; Open.CheckFileExists = true; Open.RestoreDirectory = true; if (Open.ShowDialog() == DialogResult.OK) { this.IcoPath.Text = Open.FileName; if (File.Exists(this.IcoPath.Text)) { this.IcoViewer.ImageLocation = this.IcoPath.Text; try { this.SizeIcon.Text = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName.Equals("en", StringComparison.InvariantCultureIgnoreCase) ? $"{Language.GlobalMessageStrings_en_US.SizeIcon} {GetFileSize.Inizialize(new FileInfo(this.IcoPath.Text).Length)}" : $"{Language.GlobalMessageStrings_en_US.SizeIcon} {GetFileSize.Inizialize(new FileInfo(this.IcoPath.Text).Length)}"; } catch { this.SizeIcon.Text = result; } } } else { if (Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName.Equals("en", StringComparison.InvariantCultureIgnoreCase)) { ControlActive.CheckMessage(this.ShowMessage, Language.GlobalMessageStrings_en_US.NoIconChoice); } else { ControlActive.CheckMessage(this.ShowMessage, Language.GlobalMessageStrings_ru_RU.NoIconChoice); } this.IcoPath.Clear(); this.SizeIcon.Text = result; this.IcoViewer.Image = null; } }; }
private void SelectIcon_Click(object sender, EventArgs e) { NativeMethods.SetFocus(IntPtr.Zero); this.LogoText.Focus(); try { using var Open = new OpenFileDialog { Title = "Выберите иконку для загрузчика", Filter = "Icon (*.ico)|*.ico", Multiselect = false, AutoUpgradeEnabled = true, CheckFileExists = true, RestoreDirectory = true }; if (Open.ShowDialog() == DialogResult.OK) { this.IcoPath.Text = Open.FileName; if (FileManager.ExistsFile(this.IcoPath.Text)) { this.StatusMessage.Location = new Point(524, 371); this.IcoViewer.ImageLocation = this.IcoPath.Text; this.IcoViewer.BorderStyle = BorderStyle.None; this.LsizeIco.Text = $"Размер иконки: {GetFileSize.Inizialize(new FileInfo(this.IcoPath.Text).Length)}"; } else { this.IcoViewer.BorderStyle = BorderStyle.FixedSingle; this.StatusMessage.Location = new Point(524, 371); this.LsizeIco.Text = $"Размер иконки: 0"; ControlActive.CheckMessage(this.StatusMessage, "Иконка повреждена!", Color.FromKnownColor(KnownColor.MenuHighlight), 5000); } } else { this.IcoPath.Clear(); this.IcoViewer.Image = null; this.IcoViewer.BorderStyle = BorderStyle.FixedSingle; this.StatusMessage.Location = new Point(524, 371); this.LsizeIco.Text = $"Размер иконки: 0"; ControlActive.CheckMessage(this.StatusMessage, "Иконка не выбрана", Color.FromKnownColor(KnownColor.MenuHighlight), 5000); } } catch (Exception ex) { throw new Exception("Error OpenFile", ex); } }
private void IcoViewer_DragDrop(object sender, DragEventArgs e) { foreach (string text in (string[])e.Data.GetData(DataFormats.FileDrop)) { this.IcoPath.Text = text; this.IcoViewer.Image = Image.FromFile(text); if (FileManager.ExistsFile(this.IcoPath.Text)) { this.StatusMessage.Location = new Point(12, 418); this.LsizeIco.Text = $"Размер иконки: {GetFileSize.Inizialize(new FileInfo(this.IcoPath.Text).Length)}"; } else { this.StatusMessage.Location = new Point(12, 418); this.LsizeIco.Text = $"Размер иконки: 0"; ControlActive.CheckMessage(this.StatusMessage, "Иконка повреждена!", Color.FromKnownColor(KnownColor.MenuHighlight), 5000); } } }
private void AddIcoBox_CheckedChanged(object sender, EventArgs e) { if (AddIcoBox.Checked == true) { using var ofd = new OpenFileDialog { Title = "Выберите иконку для билд файла", Filter = "Icon|*.ico", AutoUpgradeEnabled = true, CheckFileExists = true, RestoreDirectory = true }; if (ofd.ShowDialog() == DialogResult.OK) { this.IconTextBox.Text = ofd.FileName; this.IcoViewer.ImageLocation = this.IconTextBox.Text; this.IcoViewer.BorderStyle = BorderStyle.None; this.LsizeIco.Visible = true; this.LsizeIco.Text = $"Размер иконки: {GetFileSize.Inizialize(new FileInfo(this.IconTextBox.Text).Length)}"; } else { this.IcoViewer.BorderStyle = BorderStyle.FixedSingle; this.IconTextBox.Clear(); AddIcoBox.Checked = false; this.LsizeIco.Visible = false; } } else { this.IcoViewer.BorderStyle = BorderStyle.FixedSingle; this.IconTextBox.Clear(); this.IcoViewer.Image = null; this.LsizeIco.Visible = false; } }