diff --git a/InputBox.cs b/InputBox.cs new file mode 100644 index 0000000..4c61674 --- /dev/null +++ b/InputBox.cs @@ -0,0 +1,2987 @@ +////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////// +// +// Milok Zbrozek InputBox Class +// milokz@gmail.com +// Last Modified: 30.09.2021 +// +QueryPass +// +QueryDateTime +// +////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////// + +using System; +using System.IO; +using System.Collections.Generic; +using System.Drawing; +using System.Text; +using System.Text.RegularExpressions; +using System.Windows; +using System.Windows.Forms; + +namespace System.Windows.Forms +{ + public class InputBox + { + public static string pOk_Text = "OK"; + public static string pCancel_Text = "Cancel"; + public static string pOk_Yes = "Yes"; + public static string pOk_No = "No"; + public static string pOk_Abort = ""; + public static string pOk_Retry = ""; + public static string pOk_Ignore = ""; + public static bool pShowInTaskBar = false; + public static int defWidth = 300; + + private string _title; + private string _promptText; + private string[] _values; + private int _valueIndex = 0; + private string _prevValue; + private bool _readOnly; + private string _inputMaskOrRegex; + private System.Drawing.Image _icon; + private ImageList _imlist; + private DialogResult _result = DialogResult.None; + private object[] _additData = new object[6]; + + public string Title + { + get + { + return _title; + } + set + { + _title = value; + } + } + public string PromptText + { + get + { + return this._promptText; + } + set + { + this._promptText = value; + } + } + public string Value + { + get + { + return _values[this._valueIndex]; + } + set + { + if (_values.Length == 1) + this._values[0] = value; + else + { + for (int i = 0; i < this._values.Length; i++) + if (this._values[i] == value) + this._valueIndex = i; + }; + } + } + public string[] Values + { + get + { + return this._values; + } + set + { + if (value == null) throw new Exception("Invalid length"); + if (value.Length == 0) throw new Exception("Invalid length"); + this._values = value; + this._valueIndex = 0; + } + } + public int SelectedIndex + { + get + { + return this._valueIndex; + } + set + { + if ((this._values.Length > 1) && (value >= 0) && (value < this._values.Length)) + this._valueIndex = value; + } + } + public bool ReadOnly + { + get + { + return _readOnly; + } + set + { + this._readOnly = value; + } + } + public string InputMaskOrRegex + { + get + { + return this._inputMaskOrRegex; + } + set + { + this._inputMaskOrRegex = value; + } + } + public string InputMask + { + get + { + if (String.IsNullOrEmpty(this._inputMaskOrRegex)) + return this._inputMaskOrRegex; + + string[] mr = this._inputMaskOrRegex.Split(new char[] { '\0' }, 2); + for (int i = 0; i < mr.Length; i++) + if (mr[i].StartsWith("M")) + return mr[i].Substring(1); + return ""; + } + set + { + this._inputMaskOrRegex = "M" + value; + } + } + public string InputRegex + { + get + { + if (String.IsNullOrEmpty(this._inputMaskOrRegex)) + return this._inputMaskOrRegex; + + string[] mr = this._inputMaskOrRegex.Split(new char[] { '\0' }, 2); + for (int i = 0; i < mr.Length; i++) + if (mr[i].StartsWith("R")) + return mr[i].Substring(1); + return ""; + } + set + { + this._inputMaskOrRegex = "R" + value; + } + } + public ImageList IconList + { + get + { + return this._imlist; + } + set + { + this._imlist = value; + } + } + public System.Drawing.Image Icon + { + get + { + return this._icon; + } + set + { + this._icon = value; + } + } + public DialogResult Result + { + get + { + return _result; + } + } + + private InputBox(string Title, string PromptText) + { + this._title = Title; + this._promptText = PromptText; + } + + private InputBox(string Title, string PromptText, string Value) + { + this._title = Title; + this._promptText = PromptText; + this._values = new string[] { Value }; + } + + private InputBox(string Title, string PromptText, string[] Values) + { + this._title = Title; + this._promptText = PromptText; + this.Values = Values; + } + + private InputBox(string Title, string PromptText, string[] Values, int SelectedIndex) + { + this._title = Title; + this._promptText = PromptText; + this.Values = Values; + this.SelectedIndex = SelectedIndex; + } + + private DialogResult Show() + { + if (this._values.Length == 1) + return ShowMaskedTextBoxed(); + else + return ShowComboBoxed(); + } + + private DialogResult ShowNumericBoxed(ref int val, int min, int max) + { + Form form = new InputBoxForm(); + form.ShowInTaskbar = pShowInTaskBar; + Label label = new Label(); + NumericUpDown digitBox = new NumericUpDown(); + Button buttonOk = new Button(); + Button buttonCancel = new Button(); + PictureBox picture = new PictureBox(); + + form.Text = _title; + label.Text = _promptText; + digitBox.BorderStyle = BorderStyle.FixedSingle; + digitBox.Minimum = min; + digitBox.Maximum = max; + digitBox.Value = val; + digitBox.Select(0, digitBox.Value.ToString().Length); + if (_icon != null) picture.Image = _icon; + picture.SizeMode = PictureBoxSizeMode.StretchImage; + + buttonOk.Text = pOk_Text; + buttonCancel.Text = pCancel_Text; + buttonOk.DialogResult = DialogResult.OK; + buttonCancel.DialogResult = DialogResult.Cancel; + + label.SetBounds(9, 20, defWidth - 24, 13); + digitBox.SetBounds(12, 36, defWidth - 24, 20); + buttonOk.SetBounds(defWidth - 168, 72, 75, 23); + buttonCancel.SetBounds(defWidth - 87, 72, 75, 23); + picture.SetBounds(12, 72, 22, 22); + + label.AutoSize = true; + digitBox.Anchor = digitBox.Anchor | AnchorStyles.Right; + buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + + form.ClientSize = new Size(defWidth, 107); + form.Controls.AddRange(new Control[] { label, digitBox, buttonOk, buttonCancel, picture }); + form.ClientSize = new Size(Math.Max(defWidth, label.Right + 10), form.ClientSize.Height); + form.FormBorderStyle = FormBorderStyle.FixedDialog; + form.StartPosition = FormStartPosition.CenterScreen; + form.MinimizeBox = false; + form.MaximizeBox = false; + form.AcceptButton = buttonOk; + form.CancelButton = buttonCancel; + + _result = form.ShowDialog(); + if (picture.Image != null) picture.Image.Dispose(); + form.Dispose(); + _values[0] = ((val = (int)digitBox.Value)).ToString(); + return _result; + } + + private DialogResult ShowMaskedTextBoxed() + { + Form form = new InputBoxForm(); + form.ShowInTaskbar = pShowInTaskBar; + Label label = new Label(); + MaskedTextBox textBox = new MaskedTextBox(); + Button buttonOk = new Button(); + Button buttonCancel = new Button(); + PictureBox picture = new PictureBox(); + + form.Text = _title; + label.Text = _promptText; + textBox.Text = _prevValue = _values[0]; + if (!String.IsNullOrEmpty(this.InputMask)) + textBox.Mask = this.InputMask; + textBox.SelectionStart = 0; + textBox.SelectionLength = textBox.Text.Length; + textBox.BorderStyle = BorderStyle.FixedSingle; + Color bc = textBox.BackColor; + if (_readOnly) textBox.ReadOnly = true; + textBox.BackColor = bc; + textBox.TextChanged += new EventHandler(MaskOrComboTextChanged); + if (_icon != null) picture.Image = _icon; + picture.SizeMode = PictureBoxSizeMode.StretchImage; + + buttonOk.Text = pOk_Text; + buttonCancel.Text = pCancel_Text; + buttonOk.DialogResult = DialogResult.OK; + buttonCancel.DialogResult = DialogResult.Cancel; + + label.SetBounds(9, 20, defWidth - 24, 13); + textBox.SetBounds(12, 36, defWidth - 24, 20); + buttonOk.SetBounds(defWidth - 168, 72, 75, 23); + buttonCancel.SetBounds(defWidth - 87, 72, 75, 23); + picture.SetBounds(12, 72, 22, 22); + + label.AutoSize = true; + textBox.Anchor = textBox.Anchor | AnchorStyles.Right; + buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + + form.ClientSize = new Size(defWidth, 107); + form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel, picture }); + form.ClientSize = new Size(Math.Max(defWidth, label.Right + 10), form.ClientSize.Height); + form.FormBorderStyle = FormBorderStyle.FixedDialog; + form.StartPosition = FormStartPosition.CenterScreen; + form.MinimizeBox = false; + form.MaximizeBox = false; + form.AcceptButton = buttonOk; + form.CancelButton = buttonCancel; + + _result = form.ShowDialog(); + if (picture.Image != null) picture.Image.Dispose(); + form.Dispose(); + _values[0] = textBox.Text; + return _result; + } + + private DialogResult ShowMultiline() + { + Form form = new InputBoxForm(); + form.ShowInTaskbar = pShowInTaskBar; + Label label = new Label(); + TextBox textBox = new TextBox(); + Button buttonOk = new Button(); + Button buttonCancel = new Button(); + PictureBox picture = new PictureBox(); + + form.Text = _title; + label.Text = _promptText; + textBox.Text = _prevValue = _values[0]; + textBox.SelectionStart = 0; + textBox.SelectionLength = textBox.Text.Length; + textBox.BorderStyle = BorderStyle.FixedSingle; + textBox.Multiline = true; + textBox.ScrollBars = ScrollBars.Both; + Color bc = textBox.BackColor; + if (_readOnly) textBox.ReadOnly = true; + textBox.BackColor = bc; + textBox.TextChanged += new EventHandler(MaskOrComboTextChanged); + if (_icon != null) picture.Image = _icon; + picture.SizeMode = PictureBoxSizeMode.StretchImage; + + buttonOk.Text = pOk_Text; + buttonCancel.Text = pCancel_Text; + buttonOk.DialogResult = DialogResult.OK; + buttonCancel.DialogResult = DialogResult.Cancel; + + label.SetBounds(9, 20, defWidth - 24, 13); + textBox.SetBounds(12, 36, defWidth - 24, 200); + buttonOk.SetBounds(defWidth - 168, 252, 75, 23); + buttonCancel.SetBounds(defWidth - 87, 252, 75, 23); + picture.SetBounds(12, 252, 22, 22); + + label.AutoSize = true; + textBox.Anchor = textBox.Anchor | AnchorStyles.Right; + buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + + form.ClientSize = new Size(defWidth, 287); + form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel, picture }); + form.ClientSize = new Size(Math.Max(defWidth, label.Right + 10), form.ClientSize.Height); + form.FormBorderStyle = FormBorderStyle.FixedDialog; + form.StartPosition = FormStartPosition.CenterScreen; + form.MinimizeBox = false; + form.MaximizeBox = false; + form.AcceptButton = buttonOk; + form.CancelButton = buttonCancel; + + _result = form.ShowDialog(); + if (picture.Image != null) picture.Image.Dispose(); + form.Dispose(); + _values[0] = textBox.Text; + return _result; + } + + private DialogResult ShowRegex(string testerText, bool allow_new, string test) + { + Form form = new InputBoxForm(); + form.ShowInTaskbar = pShowInTaskBar; + Label label = new Label(); + Label labed = new Label(); + TextBox textBox = new TextBox(); + ComboBox comboBox = new ComboBox(); + TextBox testBox = new TextBox(); + Button buttonOk = new Button(); + Button buttonCancel = new Button(); + PictureBox picture = new PictureBox(); + + if (this._values.Length == 1) + { + textBox.Text = _prevValue = _values[0]; + textBox.SelectionStart = 0; + textBox.SelectionLength = textBox.Text.Length; + textBox.BorderStyle = BorderStyle.FixedSingle; + textBox.TextChanged += new EventHandler(testBox_TextChanged); + _additData[0] = textBox; + textBox.SetBounds(12, 36, defWidth - 24, 20); + textBox.Anchor = textBox.Anchor | AnchorStyles.Right; + } + else + { + comboBox.FlatStyle = FlatStyle.Flat; + comboBox.DropDownHeight = 200; + if (this._readOnly) + comboBox.DropDownStyle = ComboBoxStyle.DropDownList; + else + comboBox.DropDownStyle = ComboBoxStyle.DropDown; + foreach (string str in this._values) + comboBox.Items.Add(str); + comboBox.SelectedIndex = this._valueIndex; + this._prevValue = comboBox.Text; + comboBox.TextChanged += new EventHandler(testBox_TextChanged); + _additData[0] = comboBox; + comboBox.SetBounds(12, 36, defWidth - 24, 20); + comboBox.Anchor = textBox.Anchor | AnchorStyles.Right; + } + + form.Text = _title; + label.Text = _promptText; + labed.Text = testerText; + testBox.Text = test; + testBox.BorderStyle = BorderStyle.FixedSingle; + testBox.TextChanged += new EventHandler(testBox_TextChanged); + if (_icon != null) picture.Image = _icon; + picture.SizeMode = PictureBoxSizeMode.StretchImage; + + buttonOk.Text = pOk_Text; + buttonCancel.Text = pCancel_Text; + buttonOk.DialogResult = DialogResult.OK; + buttonCancel.DialogResult = DialogResult.Cancel; + + label.SetBounds(9, 20, defWidth - 24, 13); + labed.SetBounds(9, 60, defWidth - 24, 13); + testBox.SetBounds(12, 76, defWidth - 24, 20); + buttonOk.SetBounds(defWidth - 168, 112, 75, 23); + buttonCancel.SetBounds(defWidth - 87, 112, 75, 23); + picture.SetBounds(12, 112, 22, 22); + + label.AutoSize = true; + labed.AutoSize = true; + buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + + form.ClientSize = new Size(defWidth, 147); + form.Controls.AddRange(new Control[] { label, this._values.Length == 1 ? (Control)textBox : (Control)comboBox, labed, testBox, buttonOk, buttonCancel, picture }); + form.ClientSize = new Size(Math.Max(defWidth, label.Right + 10), form.ClientSize.Height); + form.FormBorderStyle = FormBorderStyle.FixedDialog; + form.StartPosition = FormStartPosition.CenterScreen; + form.MinimizeBox = false; + form.MaximizeBox = false; + form.AcceptButton = buttonOk; + form.CancelButton = buttonCancel; + + _additData[1] = testBox; + + _result = form.ShowDialog(); + if (picture.Image != null) picture.Image.Dispose(); + form.Dispose(); + if (this._values.Length == 1) + _values[0] = textBox.Text; + else + { + if (comboBox.SelectedIndex == -1) + { + List tmp = new List(this._values); + tmp.Add(comboBox.Text); + this._values = tmp.ToArray(); + this._valueIndex = this._values.Length - 1; + } + else + this._valueIndex = comboBox.SelectedIndex; + }; + if (!String.IsNullOrEmpty(test)) + { + _values[0] += (char)164; + _values[0] += testBox.Text; + }; + return _result; + } + + private void testBox_TextChanged(object sender, EventArgs e) + { + if ((sender is TextBox) || (sender is ComboBox)) + { + Control ctrlBox = (Control)_additData[0]; + TextBox testBox = (TextBox)_additData[1]; + + try + { + Regex rx = new Regex(ctrlBox.Text.Trim()); + testBox.BackColor = rx.IsMatch(testBox.Text.Trim()) ? Color.LightGreen : Color.LightPink; + } + catch + { + testBox.BackColor = Color.LightPink; + }; + }; + } + + private DialogResult ShowComboBoxed() + { + Form form = new InputBoxForm(); + form.ShowInTaskbar = pShowInTaskBar; + Label label = new Label(); + ComboBox comboBox = new ComboBox(); + Button buttonOk = new Button(); + Button buttonCancel = new Button(); + PictureBox picture = new PictureBox(); + + if (this.IconList != null) + comboBox = new ComboIcons(); + + form.Text = _title; + label.Text = _promptText; + comboBox.FlatStyle = FlatStyle.Flat; + comboBox.DropDownHeight = 200; + if (this._readOnly) + comboBox.DropDownStyle = ComboBoxStyle.DropDownList; + else + comboBox.DropDownStyle = ComboBoxStyle.DropDown; + for (int i = 0; i < this._values.Length; i++) + { + string str = this._values[i]; + comboBox.Items.Add(new DropDownItem(str, (this._imlist == null) || (i >= this._imlist.Images.Count) ? null : this._imlist.Images[i])); + }; + comboBox.SelectedIndex = this._valueIndex; + this._prevValue = comboBox.Text; + comboBox.TextChanged += new EventHandler(MaskOrComboTextChanged); + if (_icon != null) picture.Image = _icon; + picture.SizeMode = PictureBoxSizeMode.StretchImage; + + buttonOk.Text = pOk_Text; + buttonCancel.Text = pCancel_Text; + buttonOk.DialogResult = DialogResult.OK; + buttonCancel.DialogResult = DialogResult.Cancel; + + label.SetBounds(9, 20, defWidth - 24, 13); + comboBox.SetBounds(12, 36, defWidth - 24, 20); + buttonOk.SetBounds(defWidth - 168, 72, 75, 23); + buttonCancel.SetBounds(defWidth - 87, 72, 75, 23); + picture.SetBounds(12, 72, 22, 22); + + label.AutoSize = true; + comboBox.Anchor = comboBox.Anchor | AnchorStyles.Right; + buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + + form.ClientSize = new Size(defWidth, 107); + form.Controls.AddRange(new Control[] { label, comboBox, buttonOk, buttonCancel, picture }); + form.ClientSize = new Size(Math.Max(defWidth, label.Right + 10), form.ClientSize.Height); + form.FormBorderStyle = FormBorderStyle.FixedDialog; + form.StartPosition = FormStartPosition.CenterScreen; + form.MinimizeBox = false; + form.MaximizeBox = false; + form.AcceptButton = buttonOk; + form.CancelButton = buttonCancel; + + _result = form.ShowDialog(); + if (picture.Image != null) picture.Image.Dispose(); + form.Dispose(); + if (comboBox.SelectedIndex == -1) + { + List tmp = new List(this._values); + tmp.Add(comboBox.Text); + this._values = tmp.ToArray(); + this._valueIndex = this._values.Length - 1; + } + else + this._valueIndex = comboBox.SelectedIndex; + return _result; + } + + private DialogResult ShowSelectDir() + { + Form form = new InputBoxForm(); + form.ShowInTaskbar = pShowInTaskBar; + Label label = new Label(); + MaskedTextBox textBox = new MaskedTextBox(); + Button buttonOk = new Button(); + Button buttonCancel = new Button(); + Button buttonAddit = new Button(); + PictureBox picture = new PictureBox(); + + form.Text = _title; + label.Text = _promptText; + textBox.Text = _values[0]; + textBox.SelectionStart = 0; + textBox.SelectionLength = textBox.Text.Length; + textBox.BorderStyle = BorderStyle.FixedSingle; + Color bc = textBox.BackColor; + if (_readOnly) textBox.ReadOnly = true; + textBox.BackColor = bc; + if (_icon != null) picture.Image = _icon; + picture.SizeMode = PictureBoxSizeMode.StretchImage; + buttonAddit.Click += new EventHandler(buttonAdditD_Click); + _additData[0] = textBox; + + buttonOk.Text = pOk_Text; + buttonCancel.Text = pCancel_Text; + buttonAddit.Text = ".."; + buttonOk.DialogResult = DialogResult.OK; + buttonCancel.DialogResult = DialogResult.Cancel; + + label.SetBounds(9, 20, defWidth - 24, 13); + textBox.SetBounds(12, 36, defWidth - 52, 20); + buttonOk.SetBounds(defWidth - 168, 72, 75, 23); + buttonCancel.SetBounds(defWidth - 87, 72, 75, 23); + buttonAddit.SetBounds(defWidth - 36, 36, 24, 20); + picture.SetBounds(12, 72, 22, 22); + + label.AutoSize = true; + textBox.Anchor = textBox.Anchor | AnchorStyles.Right; + buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonAddit.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + + form.ClientSize = new Size(defWidth, 107); + form.Controls.AddRange(new Control[] { label, textBox, buttonAddit, buttonOk, buttonCancel, picture }); + form.ClientSize = new Size(Math.Max(defWidth, label.Right + 10), form.ClientSize.Height); + form.FormBorderStyle = FormBorderStyle.FixedDialog; + form.StartPosition = FormStartPosition.CenterScreen; + form.MinimizeBox = false; + form.MaximizeBox = false; + form.AcceptButton = buttonOk; + form.CancelButton = buttonCancel; + + _result = form.ShowDialog(); + if (picture.Image != null) picture.Image.Dispose(); + form.Dispose(); + _values[0] = textBox.Text; + return _result; + } + + private DialogResult ShowSelectFile(string filter) + { + Form form = new InputBoxForm(); + form.ShowInTaskbar = pShowInTaskBar; + Label label = new Label(); + MaskedTextBox textBox = new MaskedTextBox(); + Button buttonOk = new Button(); + Button buttonCancel = new Button(); + Button buttonAddit = new Button(); + PictureBox picture = new PictureBox(); + + form.Text = _title; + label.Text = _promptText; + textBox.Text = _values[0]; + textBox.SelectionStart = 0; + textBox.SelectionLength = textBox.Text.Length; + textBox.BorderStyle = BorderStyle.FixedSingle; + Color bc = textBox.BackColor; + if (_readOnly) textBox.ReadOnly = true; + textBox.BackColor = bc; + if (_icon != null) picture.Image = _icon; + picture.SizeMode = PictureBoxSizeMode.StretchImage; + buttonAddit.Click += new EventHandler(buttonAdditF_Click); + _additData[0] = textBox; + if (String.IsNullOrEmpty(filter)) + _additData[1] = "All Types|*.*"; + else + _additData[1] = filter; + _additData[2] = _title; + + buttonOk.Text = pOk_Text; + buttonCancel.Text = pCancel_Text; + buttonAddit.Text = ".."; + buttonOk.DialogResult = DialogResult.OK; + buttonCancel.DialogResult = DialogResult.Cancel; + + label.SetBounds(9, 20, defWidth - 24, 13); + textBox.SetBounds(12, 36, defWidth - 52, 20); + buttonOk.SetBounds(defWidth - 168, 72, 75, 23); + buttonCancel.SetBounds(defWidth - 87, 72, 75, 23); + buttonAddit.SetBounds(defWidth - 36, 36, 24, 20); + picture.SetBounds(12, 72, 22, 22); + + label.AutoSize = true; + textBox.Anchor = textBox.Anchor | AnchorStyles.Right; + buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonAddit.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + + form.ClientSize = new Size(defWidth, 107); + form.Controls.AddRange(new Control[] { label, textBox, buttonAddit, buttonOk, buttonCancel, picture }); + form.ClientSize = new Size(Math.Max(defWidth, label.Right + 10), form.ClientSize.Height); + form.FormBorderStyle = FormBorderStyle.FixedDialog; + form.StartPosition = FormStartPosition.CenterScreen; + form.MinimizeBox = false; + form.MaximizeBox = false; + form.AcceptButton = buttonOk; + form.CancelButton = buttonCancel; + + _result = form.ShowDialog(); + if (picture.Image != null) picture.Image.Dispose(); + form.Dispose(); + _values[0] = textBox.Text; + return _result; + } + + private DialogResult ShowSelectColor(ref Color color) + { + Form form = new InputBoxForm(); + form.ShowInTaskbar = pShowInTaskBar; + Label label = new Label(); + MaskedTextBox textBox = new MaskedTextBox(); + Button buttonOk = new Button(); + Button buttonCancel = new Button(); + Button buttonAddit = new Button(); + PictureBox picture = new PictureBox(); + + form.Text = _title; + label.Text = _promptText; + textBox.Text = HexConverter(color); + textBox.SelectionStart = 0; + textBox.SelectionLength = textBox.Text.Length; + textBox.BorderStyle = BorderStyle.FixedSingle; + textBox.Mask = @"\#AAAAAA"; + this.InputRegex = @"^(#[\dA-Fa-f]{0,6})$"; + textBox.TextChanged += new EventHandler(colorBox_TextChanged); + if (_icon != null) picture.Image = _icon; + picture.SizeMode = PictureBoxSizeMode.StretchImage; + buttonAddit.Text = ".."; + buttonAddit.FlatStyle = FlatStyle.Flat; + buttonAddit.BackColor = color; + buttonAddit.Click += new EventHandler(buttonAdditC_Click); + _additData[0] = textBox; + _additData[1] = buttonAddit; + + buttonOk.Text = pOk_Text; + buttonCancel.Text = pCancel_Text; + buttonAddit.Text = ".."; + buttonOk.DialogResult = DialogResult.OK; + buttonCancel.DialogResult = DialogResult.Cancel; + + label.SetBounds(9, 20, defWidth - 24, 13); + textBox.SetBounds(12, 36, defWidth - 52, 20); + buttonOk.SetBounds(defWidth - 168, 72, 75, 23); + buttonCancel.SetBounds(defWidth - 87, 72, 75, 23); + buttonAddit.SetBounds(defWidth - 36, 36, 24, 20); + picture.SetBounds(12, 72, 22, 22); + + label.AutoSize = true; + textBox.Anchor = textBox.Anchor | AnchorStyles.Right; + buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonAddit.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + + form.ClientSize = new Size(defWidth, 107); + form.Controls.AddRange(new Control[] { label, textBox, buttonAddit, buttonOk, buttonCancel, picture }); + form.ClientSize = new Size(Math.Max(defWidth, label.Right + 10), form.ClientSize.Height); + form.FormBorderStyle = FormBorderStyle.FixedDialog; + form.StartPosition = FormStartPosition.CenterScreen; + form.MinimizeBox = false; + form.MaximizeBox = false; + form.AcceptButton = buttonOk; + form.CancelButton = buttonCancel; + + _result = form.ShowDialog(); + if (picture.Image != null) picture.Image.Dispose(); + form.Dispose(); + color = RGBConverter(textBox.Text); + return _result; + } + + private void colorBox_TextChanged(object sender, EventArgs e) + { + ((Button)_additData[1]).BackColor = RGBConverter((string)((MaskedTextBox)_additData[0]).Text); + } + + private void buttonAdditC_Click(object sender, EventArgs e) + { + System.Windows.Forms.ColorDialog cd = new System.Windows.Forms.ColorDialog(); + cd.FullOpen = true; + cd.Color = RGBConverter((string)((MaskedTextBox)_additData[0]).Text); + if (cd.ShowDialog() == DialogResult.OK) + { + ((MaskedTextBox)_additData[0]).Text = HexConverter(cd.Color); + ((Button)_additData[1]).BackColor = cd.Color; + }; + cd.Dispose(); + } + + private void buttonAdditF_Click(object sender, EventArgs e) + { + OpenFileDialog ofd = new OpenFileDialog(); + ofd.FileName = ((MaskedTextBox)_additData[0]).Text; + ofd.Title = (string)_additData[2]; + ofd.Filter = (string)_additData[1]; + ofd.FileName = (string)((MaskedTextBox)_additData[0]).Text; + try + { + if (ofd.ShowDialog() == DialogResult.OK) + ((MaskedTextBox)_additData[0]).Text = ofd.FileName; + } + catch + { + ofd.FileName = ""; + if (ofd.ShowDialog() == DialogResult.OK) + ((MaskedTextBox)_additData[0]).Text = ofd.FileName; + }; + ofd.Dispose(); + } + + private void buttonAdditD_Click(object sender, EventArgs e) + { + FolderBrowserDialog fbd = new FolderBrowserDialog(); + fbd.SelectedPath = (string)((MaskedTextBox)_additData[0]).Text; + if (fbd.ShowDialog() == DialogResult.OK) + ((MaskedTextBox)_additData[0]).Text = fbd.SelectedPath; + fbd.Dispose(); + } + + private void MaskOrComboTextChanged(object sender, EventArgs e) + { + if (String.IsNullOrEmpty(InputRegex)) return; + + if (sender is MaskedTextBox) + { + MaskedTextBox tb = (MaskedTextBox)sender; + int index = tb.SelectionStart > 0 ? tb.SelectionStart - 1 : 0; + if (String.IsNullOrEmpty(tb.Text)) return; + if (Regex.IsMatch(tb.Text, InputRegex)) + { + _prevValue = tb.Text; + return; + } + else + { + tb.Text = _prevValue; + tb.SelectionStart = index; + }; + }; + if (sender is ComboBox) + { + ComboBox cb = (ComboBox)sender; + int index = cb.SelectionStart > 0 ? cb.SelectionStart - 1 : 0; + if (String.IsNullOrEmpty(cb.Text)) return; + if (Regex.IsMatch(cb.Text, InputRegex)) + { + _prevValue = cb.Text; + return; + } + else + { + cb.Text = _prevValue; + cb.SelectionStart = index; + }; + }; + } + + /// + /// Show ReadOnly Box Dialog + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// DialogResult6 + public static DialogResult Show(string title, string promptText, string value) + { + InputBox ib = new InputBox(title, promptText, value); + ib.ReadOnly = true; + DialogResult dr = ib.Show(); + value = ib.Value; + return dr; + } + /// + /// Show ReadOnly Box Dialog with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// Icon Image + /// DialogResult + public static DialogResult Show(string title, string promptText, string value, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, value); + ib.ReadOnly = true; + ib.Icon = icon; + DialogResult dr = ib.Show(); + value = ib.Value; + return dr; + } + /// + /// Show Editable Input Box Dialog + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// DialogResult + public static DialogResult Show(string title, string promptText, ref string value) + { + InputBox ib = new InputBox(title, promptText, value); + DialogResult dr = ib.Show(); + value = ib.Value; + return dr; + + } + /// + /// Show Editable Input Box Dialog with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// Icon Image + /// DialogResult + public static DialogResult Show(string title, string promptText, ref string value, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, value); + ib.Icon = icon; + DialogResult dr = ib.Show(); + value = ib.Value; + return dr; + + } + /// + /// Show Editable Masked Input Box Dialog + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// Input Mask or Regex for Value + /// If text is Input Mask it starts from M. If text is Regex it starts from R. + /// Input Mask symbols: 0 - digits; 9 - digits and spaces; # - digits, spaces, +, - + /// L - letter; ? - letters if need; A - letter or digit; . - decimal separator; + /// , - space for digits; / - date separator; $ - currency symbol + /// Regex: http://regexstorm.net/reference + /// + /// DialogResult + public static DialogResult Show(string title, string promptText, ref string value, string InputMaskOrRegex) + { + InputBox ib = new InputBox(title, promptText, value); + ib.InputMaskOrRegex = InputMaskOrRegex; + DialogResult dr = ib.Show(); + value = ib.Value; + return dr; + } + /// + /// Show Editable Masked Input Box Dialog with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// Input Mask or Regex for Value + /// If text is Input Mask it starts from M. If text is Regex it starts from R. + /// Input Mask symbols: 0 - digits; 9 - digits and spaces; # - digits, spaces, +, - + /// L - letter; ? - letters if need; A - letter or digit; . - decimal separator; + /// , - space for digits; / - date separator; $ - currency symbol + /// Regex: http://regexstorm.net/reference + /// + /// Image Icon + /// DialogResult + public static DialogResult Show(string title, string promptText, ref string value, string InputMaskOrRegex, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, value); + ib.Icon = icon; + DialogResult dr = ib.Show(); + value = ib.Value.ToString(); + return dr; + } + + public static DialogResult QueryText(string title, string promptText, ref string value) + { + InputBox ib = new InputBox(title, promptText, value); + DialogResult dr = ib.ShowMultiline(); + value = ib.Value; + return dr; + } + + public static DialogResult QueryText(string title, string promptText, string value) + { + InputBox ib = new InputBox(title, promptText, value); + ib.ReadOnly = true; + DialogResult dr = ib.ShowMultiline(); + return dr; + } + + public static DialogResult QueryText(string title, string promptText, string value, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, value); + ib.ReadOnly = true; + ib.Icon = icon; + DialogResult dr = ib.ShowMultiline(); + return dr; + } + + public static DialogResult QueryText(string title, string promptText, ref string value, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, value); + ib.Icon = icon; + DialogResult dr = ib.ShowMultiline(); + value = ib.Value; + return dr; + } + + public static DialogResult QueryPass(string title, string promptText, ref string value) + { + InputBox ib = new InputBox(title, promptText, value); + DialogResult dr = ib.ShowPass(); + value = ib.Value; + return dr; + } + + + private DialogResult ShowPass() + { + Form form = new InputBoxForm(); + form.ShowInTaskbar = pShowInTaskBar; + Label label = new Label(); + MaskedTextBox textBox = new MaskedTextBox(); + Button buttonOk = new Button(); + Button buttonCancel = new Button(); + PictureBox picture = new PictureBox(); + + form.Text = _title; + label.Text = _promptText; + textBox.Text = _prevValue = _values[0]; + if (!String.IsNullOrEmpty(this.InputMask)) + textBox.Mask = this.InputMask; + textBox.SelectionStart = 0; + textBox.SelectionLength = textBox.Text.Length; + textBox.BorderStyle = BorderStyle.FixedSingle; + textBox.PasswordChar = '*'; + Color bc = textBox.BackColor; + if (_readOnly) textBox.ReadOnly = true; + textBox.BackColor = bc; + textBox.TextChanged += new EventHandler(MaskOrComboTextChanged); + if (_icon != null) picture.Image = _icon; + picture.SizeMode = PictureBoxSizeMode.StretchImage; + + buttonOk.Text = pOk_Text; + buttonCancel.Text = pCancel_Text; + buttonOk.DialogResult = DialogResult.OK; + buttonCancel.DialogResult = DialogResult.Cancel; + + label.SetBounds(9, 20, defWidth - 24, 13); + textBox.SetBounds(12, 36, defWidth - 24, 20); + buttonOk.SetBounds(defWidth - 168, 72, 75, 23); + buttonCancel.SetBounds(defWidth - 87, 72, 75, 23); + picture.SetBounds(12, 72, 22, 22); + + label.AutoSize = true; + textBox.Anchor = textBox.Anchor | AnchorStyles.Right; + buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + + form.ClientSize = new Size(defWidth, 107); + form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel, picture }); + form.ClientSize = new Size(Math.Max(defWidth, label.Right + 10), form.ClientSize.Height); + form.FormBorderStyle = FormBorderStyle.FixedDialog; + form.StartPosition = FormStartPosition.CenterScreen; + form.MinimizeBox = false; + form.MaximizeBox = false; + form.AcceptButton = buttonOk; + form.CancelButton = buttonCancel; + + _result = form.ShowDialog(); + if (picture.Image != null) picture.Image.Dispose(); + form.Dispose(); + _values[0] = textBox.Text; + return _result; + } + + public static DialogResult QueryDateTime(string title, string promptText, ref DateTime value) + { + return QueryDateTime(title, promptText, null, ref value); + } + + public static DialogResult QueryDate(string title, string promptText, ref DateTime value) + { + return QueryDateTime(title, promptText, "dd.MM.yyyy", ref value); + } + + public static DialogResult QueryTime(string title, string promptText, ref DateTime value) + { + return QueryDateTime(title, promptText, "HH:mm", ref value); + } + + public static DialogResult QueryDateTime(string title, string promptText, string format, ref DateTime value) + { + Form form = new InputBoxForm(); + form.ShowInTaskbar = pShowInTaskBar; + Label label = new Label(); + DateTimePicker dtBox = new DateTimePicker(); + Button buttonOk = new Button(); + Button buttonCancel = new Button(); + PictureBox picture = new PictureBox(); + + form.Text = String.IsNullOrEmpty(title) ? "Select Date/Time" : title; + label.Text = String.IsNullOrEmpty(promptText) ? "Select Date/Time" : promptText; + if (value == null) + dtBox.Value = DateTime.Today; + else + dtBox.Value = value; + if (!String.IsNullOrEmpty(format)) + { + dtBox.Format = DateTimePickerFormat.Custom; + dtBox.CustomFormat = format; + }; + + buttonOk.Text = pOk_Text; + buttonCancel.Text = pCancel_Text; + buttonOk.DialogResult = DialogResult.OK; + buttonCancel.DialogResult = DialogResult.Cancel; + + label.SetBounds(9, 20, defWidth - 24, 13); + dtBox.SetBounds(12, 36, defWidth - 24, 20); + buttonOk.SetBounds(defWidth - 168, 72, 75, 23); + buttonCancel.SetBounds(defWidth - 87, 72, 75, 23); + picture.SetBounds(12, 72, 22, 22); + + label.AutoSize = true; + dtBox.Anchor = dtBox.Anchor | AnchorStyles.Right; + buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + + form.ClientSize = new Size(defWidth, 107); + form.Controls.AddRange(new Control[] { label, dtBox, buttonOk, buttonCancel, picture }); + form.ClientSize = new Size(Math.Max(defWidth, label.Right + 10), form.ClientSize.Height); + form.FormBorderStyle = FormBorderStyle.FixedDialog; + form.StartPosition = FormStartPosition.CenterScreen; + form.MinimizeBox = false; + form.MaximizeBox = false; + form.AcceptButton = buttonOk; + form.CancelButton = buttonCancel; + + DialogResult _result = form.ShowDialog(); + form.Dispose(); + value = dtBox.Value; + return _result; + } + + public static DialogResult QueryRegexBox(string title, string promptText, string testerText, ref string value) + { + InputBox ib = new InputBox(title, promptText, value); + DialogResult dr = ib.ShowRegex(testerText, false, ""); + value = ib.Value; + return dr; + } + + public static DialogResult QueryReplaceBox(string title, string promptText, string testerText, ref string value, ref string test) + { + InputBox ib = new InputBox(title, promptText, value); + DialogResult dr = ib.ShowRegex(testerText, false, test); + string[] vt = ib.Value.Split(new char[] { (char)164 }); + value = vt[0]; + if (vt.Length > 1) + test = vt[1]; + else + test = ""; + return dr; + } + + public static DialogResult QueryRegexBox(string title, string promptText, string testerText, ref string value, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, value); + ib.Icon = icon; + DialogResult dr = ib.ShowRegex(testerText, false, ""); + value = ib.Value; + return dr; + } + + public static DialogResult QueryRegexBox(string title, string promptText, string testerText, string[] options, ref int selectedValue) + { + InputBox ib = new InputBox(title, promptText, options, selectedValue); + ib.ReadOnly = true; + DialogResult dr = ib.ShowRegex(testerText, false, ""); + selectedValue = ib.SelectedIndex; + return dr; + } + + public static DialogResult QueryRegexBox(string title, string promptText, string testerText, string[] options, ref int selectedValue, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, options, selectedValue); + ib.ReadOnly = true; + ib.Icon = icon; + DialogResult dr = ib.ShowRegex(testerText, false, ""); + selectedValue = ib.SelectedIndex; + return dr; + } + + public static DialogResult QueryRegexBox(string title, string promptText, string testerText, string[] options, ref string selectedValue) + { + InputBox ib = new InputBox(title, promptText, options); + ib.ReadOnly = true; + ib.Value = selectedValue; + DialogResult dr = ib.ShowRegex(testerText, false, ""); + selectedValue = ib.Value; + return dr; + } + + public static DialogResult QueryRegexBox(string title, string promptText, string testerText, string[] options, ref string selectedValue, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, options); + ib.ReadOnly = true; + ib.Value = selectedValue; + ib.Icon = icon; + DialogResult dr = ib.ShowRegex(testerText, false, ""); + selectedValue = ib.Value; + return dr; + } + + public static DialogResult QueryRegexBox(string title, string promptText, string testerText, string[] options, ref string selectedValue, bool allowNewValue) + { + InputBox ib = new InputBox(title, promptText, options); + ib.ReadOnly = !allowNewValue; + ib.Value = selectedValue; + DialogResult dr = ib.ShowRegex(testerText, true, ""); + selectedValue = ib.Value; + return dr; + } + + public static DialogResult QueryRegexBox(string title, string promptText, string testerText, string[] options, ref string selectedValue, bool allowNewValue, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, options); + ib.ReadOnly = !allowNewValue; + ib.Value = selectedValue; + ib.Icon = icon; + DialogResult dr = ib.ShowRegex(testerText, true, ""); + selectedValue = ib.Value; + return dr; + } + + public static DialogResult QueryMultiple(string title, string[] prompts, string[] values, string inputMask, bool readOnly, Bitmap icon) + { + if ((prompts == null) || (values == null) || (prompts.Length == 0) || (values.Length == 0) || (values.Length != prompts.Length)) + return DialogResult.None; + + Form form = new InputBoxForm(); + form.ShowInTaskbar = pShowInTaskBar; + Label[] labels = new Label[prompts.Length]; + MaskedTextBox[] textBoxes = new MaskedTextBox[values.Length]; + Button buttonOk = new Button(); + Button buttonCancel = new Button(); + PictureBox picture = new PictureBox(); + + form.Text = title; + int lRight = 0; + for (int i = 0; i < prompts.Length; i++) + { + labels[i] = new Label(); + labels[i].Text = prompts[i]; + + textBoxes[i] = new MaskedTextBox(); + textBoxes[i].Text = values[i]; + textBoxes[i].SelectionStart = 0; + textBoxes[i].SelectionLength = textBoxes[i].Text.Length; + textBoxes[i].BorderStyle = BorderStyle.FixedSingle; + if (!String.IsNullOrEmpty(inputMask)) + textBoxes[i].Mask = inputMask; + Color bc = textBoxes[i].BackColor; + if (readOnly) textBoxes[i].ReadOnly = true; + textBoxes[i].BackColor = bc; + // textBoxes[i].TextChanged += new EventHandler(MaskOrComboTextChanged); + + labels[i].SetBounds(9, 20 + 40 * i, defWidth - 24, 13); + labels[i].AutoSize = true; + textBoxes[i].SetBounds(12, 36 + 40 * i, defWidth - 24, 20); + textBoxes[i].Anchor = textBoxes[i].Anchor | AnchorStyles.Right; + + if (labels[i].Right > lRight) lRight = labels[i].Right; + }; + + if (icon != null) picture.Image = icon; + picture.SizeMode = PictureBoxSizeMode.StretchImage; + + buttonOk.Text = pOk_Text; + buttonCancel.Text = pCancel_Text; + buttonOk.DialogResult = DialogResult.OK; + buttonCancel.DialogResult = DialogResult.Cancel; + + + buttonOk.SetBounds(defWidth - 168, 32 + 40 * prompts.Length, 75, 23); + buttonCancel.SetBounds(defWidth - 87, 32 + 40 * prompts.Length, 75, 23); + picture.SetBounds(12, 32 + 40 * prompts.Length, 22, 22); + + buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + + form.ClientSize = new Size(defWidth, 67 + 40 * prompts.Length); + form.Controls.AddRange(labels); + form.Controls.AddRange(textBoxes); + form.Controls.AddRange(new Control[] { buttonOk, buttonCancel, picture }); + form.ClientSize = new Size(Math.Max(defWidth, lRight + 10), form.ClientSize.Height); + form.FormBorderStyle = FormBorderStyle.FixedDialog; + form.StartPosition = FormStartPosition.CenterScreen; + form.MinimizeBox = false; + form.MaximizeBox = false; + form.AcceptButton = buttonOk; + form.CancelButton = buttonCancel; + + DialogResult _result = form.ShowDialog(); + for (int i = 0; i < prompts.Length; i++) + values[i] = textBoxes[i].Text; + if (picture.Image != null) picture.Image.Dispose(); + form.Dispose(); + return _result; + } + + public static DialogResult QueryMultiple(string title, string[] prompts, string[] values, string inputMask, bool readOnly, Bitmap icon, MessageBoxButtons buttons, string[] buttonsText) + { + if ((prompts == null) || (values == null) || (prompts.Length == 0) || (values.Length == 0) || (values.Length != prompts.Length)) + return DialogResult.None; + + Form form = new InputBoxForm(); + form.ShowInTaskbar = pShowInTaskBar; + Label[] labels = new Label[prompts.Length]; + MaskedTextBox[] textBoxes = new MaskedTextBox[values.Length]; + int btnCount = 1; + if ((buttons == MessageBoxButtons.OKCancel) || (buttons == MessageBoxButtons.YesNo) || (buttons == MessageBoxButtons.RetryCancel)) btnCount = 2; + if ((buttons == MessageBoxButtons.AbortRetryIgnore) || (buttons == MessageBoxButtons.YesNoCancel)) btnCount = 3; + Button[] Buttons = new Button[btnCount]; + Button buttonCancel = new Button(); + PictureBox picture = new PictureBox(); + + form.Text = title; + int lRight = 0; + for (int i = 0; i < prompts.Length; i++) + { + labels[i] = new Label(); + labels[i].Text = prompts[i]; + + textBoxes[i] = new MaskedTextBox(); + textBoxes[i].Text = values[i]; + textBoxes[i].SelectionStart = 0; + textBoxes[i].SelectionLength = textBoxes[i].Text.Length; + textBoxes[i].BorderStyle = BorderStyle.FixedSingle; + if (!String.IsNullOrEmpty(inputMask)) + textBoxes[i].Mask = inputMask; + Color bc = textBoxes[i].BackColor; + if (readOnly) textBoxes[i].ReadOnly = true; + textBoxes[i].BackColor = bc; + // textBoxes[i].TextChanged += new EventHandler(MaskOrComboTextChanged); + + labels[i].SetBounds(9, 20 + 40 * i, defWidth - 24, 13); + labels[i].AutoSize = true; + textBoxes[i].SetBounds(12, 36 + 40 * i, defWidth - 24, 20); + textBoxes[i].Anchor = textBoxes[i].Anchor | AnchorStyles.Right; + + if (labels[i].Right > lRight) lRight = labels[i].Right; + }; + + if (icon != null) picture.Image = icon; + picture.SizeMode = PictureBoxSizeMode.StretchImage; + + for (int i = 0; i < btnCount; i++) + { + Buttons[i] = new Button(); + Buttons[i].Text = pOk_Text; + if (i == 0) + { + if (buttons == MessageBoxButtons.OK) { Buttons[i].Text = pOk_Text; Buttons[i].DialogResult = DialogResult.OK; }; + if (buttons == MessageBoxButtons.OKCancel) { Buttons[i].Text = pOk_Text; Buttons[i].DialogResult = DialogResult.OK; }; + if (buttons == MessageBoxButtons.AbortRetryIgnore) { Buttons[i].Text = "Abort"; Buttons[i].DialogResult = DialogResult.Abort; }; + if (buttons == MessageBoxButtons.YesNoCancel) { Buttons[i].Text = "Yes"; Buttons[i].DialogResult = DialogResult.Yes; }; + if (buttons == MessageBoxButtons.YesNo) { Buttons[i].Text = "Yes"; Buttons[i].DialogResult = DialogResult.Yes; }; + if (buttons == MessageBoxButtons.RetryCancel) { Buttons[i].Text = "Retry"; Buttons[i].DialogResult = DialogResult.Retry; }; + if ((buttonsText != null) && (buttonsText.Length > 0)) Buttons[i].Text = buttonsText[i]; + }; + if (i == 1) + { + if (buttons == MessageBoxButtons.OKCancel) { Buttons[i].Text = pCancel_Text; Buttons[i].DialogResult = DialogResult.Cancel; }; + if (buttons == MessageBoxButtons.AbortRetryIgnore) { Buttons[i].Text = "Retry"; Buttons[i].DialogResult = DialogResult.Retry; }; + if (buttons == MessageBoxButtons.YesNoCancel) { Buttons[i].Text = "No"; Buttons[i].DialogResult = DialogResult.No; }; + if (buttons == MessageBoxButtons.YesNo) { Buttons[i].Text = "No"; Buttons[i].DialogResult = DialogResult.No; }; + if (buttons == MessageBoxButtons.RetryCancel) { Buttons[i].Text = pCancel_Text; Buttons[i].DialogResult = DialogResult.Cancel; }; + if ((buttonsText != null) && (buttonsText.Length > 1)) Buttons[i].Text = buttonsText[i]; + }; + if (i == 2) + { + if (buttons == MessageBoxButtons.AbortRetryIgnore) { Buttons[i].Text = "Ignore"; Buttons[i].DialogResult = DialogResult.Ignore; }; + if (buttons == MessageBoxButtons.YesNoCancel) { Buttons[i].Text = pCancel_Text; Buttons[i].DialogResult = DialogResult.Cancel; }; + if ((buttonsText != null) && (buttonsText.Length > 2)) Buttons[i].Text = buttonsText[i]; + }; + Buttons[i].SetBounds(defWidth - 87 - 81 * (btnCount - i - 1), 32 + 40 * prompts.Length, 75, 23); + Buttons[i].Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + }; + + buttonCancel.SetBounds(defWidth - 87, 32 + 40 * prompts.Length, 75, 23); + picture.SetBounds(12, 32 + 40 * prompts.Length, 22, 22); + + + form.ClientSize = new Size(defWidth, 67 + 40 * prompts.Length); + form.Controls.AddRange(labels); + form.Controls.AddRange(textBoxes); + form.Controls.AddRange(Buttons); + form.Controls.AddRange(new Control[] { picture }); + form.ClientSize = new Size(Math.Max(defWidth, lRight + 10), form.ClientSize.Height); + form.FormBorderStyle = FormBorderStyle.FixedDialog; + form.StartPosition = FormStartPosition.CenterScreen; + form.MinimizeBox = false; + form.MaximizeBox = false; + form.AcceptButton = Buttons[0]; + form.CancelButton = Buttons[btnCount - 1]; + + DialogResult _result = form.ShowDialog(); + for (int i = 0; i < prompts.Length; i++) + values[i] = textBoxes[i].Text; + if (picture.Image != null) picture.Image.Dispose(); + form.Dispose(); + return _result; + } + + public static DialogResult QueryMultiple(string title, string[] prompts, int[] values, bool readOnly, Bitmap icon) + { + return QueryMultiple(title, prompts, values, int.MinValue, int.MaxValue, readOnly, icon); + } + + public static DialogResult QueryMultiple(string title, string[] prompts, int[] values, int minValue, int maxValue, bool readOnly, Bitmap icon) + { + if ((prompts == null) || (values == null) || (prompts.Length == 0) || (values.Length == 0) || (values.Length != prompts.Length)) + return DialogResult.None; + + Form form = new InputBoxForm(); + form.ShowInTaskbar = pShowInTaskBar; + Label[] labels = new Label[prompts.Length]; + NumericUpDown[] textBoxes = new NumericUpDown[values.Length]; + Button buttonOk = new Button(); + Button buttonCancel = new Button(); + PictureBox picture = new PictureBox(); + + form.Text = title; + int lRight = 0; + for (int i = 0; i < prompts.Length; i++) + { + labels[i] = new Label(); + labels[i].Text = prompts[i]; + + textBoxes[i] = new NumericUpDown(); + textBoxes[i].Minimum = minValue; + textBoxes[i].Maximum = maxValue; + textBoxes[i].Value = values[i]; + textBoxes[i].BorderStyle = BorderStyle.FixedSingle; + Color bc = textBoxes[i].BackColor; + if (readOnly) textBoxes[i].ReadOnly = true; + textBoxes[i].BackColor = bc; + + labels[i].SetBounds(9, 20 + 40 * i, defWidth - 24, 13); + labels[i].AutoSize = true; + textBoxes[i].SetBounds(12, 36 + 40 * i, defWidth - 24, 20); + textBoxes[i].Anchor = textBoxes[i].Anchor | AnchorStyles.Right; + + if (labels[i].Right > lRight) lRight = labels[i].Right; + }; + + if (icon != null) picture.Image = icon; + picture.SizeMode = PictureBoxSizeMode.StretchImage; + + buttonOk.Text = pOk_Text; + buttonCancel.Text = pCancel_Text; + buttonOk.DialogResult = DialogResult.OK; + buttonCancel.DialogResult = DialogResult.Cancel; + + + buttonOk.SetBounds(defWidth - 168, 32 + 40 * prompts.Length, 75, 23); + buttonCancel.SetBounds(defWidth - 87, 32 + 40 * prompts.Length, 75, 23); + picture.SetBounds(12, 32 + 40 * prompts.Length, 22, 22); + + buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + + form.ClientSize = new Size(defWidth, 67 + 40 * prompts.Length); + form.Controls.AddRange(labels); + form.Controls.AddRange(textBoxes); + form.Controls.AddRange(new Control[] { buttonOk, buttonCancel, picture }); + form.ClientSize = new Size(Math.Max(defWidth, lRight + 10), form.ClientSize.Height); + form.FormBorderStyle = FormBorderStyle.FixedDialog; + form.StartPosition = FormStartPosition.CenterScreen; + form.MinimizeBox = false; + form.MaximizeBox = false; + form.AcceptButton = buttonOk; + form.CancelButton = buttonCancel; + + DialogResult _result = form.ShowDialog(); + for (int i = 0; i < prompts.Length; i++) + values[i] = (int)textBoxes[i].Value; + if (picture.Image != null) picture.Image.Dispose(); + form.Dispose(); + return _result; + } + + public static DialogResult QueryMultiple(string title, string[] prompts, double[] values, bool readOnly, Bitmap icon) + { + return QueryMultiple(title, prompts, values, double.MinValue, double.MinValue, readOnly, icon); + } + + private static double[] qm_d_mima = new double[] { double.MinValue, double.MaxValue }; + public static DialogResult QueryMultiple(string title, string[] prompts, double[] values, double minValue, double maxValue, bool readOnly, Bitmap icon) + { + if ((prompts == null) || (values == null) || (prompts.Length == 0) || (values.Length == 0) || (values.Length != prompts.Length)) + return DialogResult.None; + + qm_d_mima[0] = minValue; + qm_d_mima[1] = maxValue; + + Form form = new InputBoxForm(); + form.ShowInTaskbar = pShowInTaskBar; + Label[] labels = new Label[prompts.Length]; + MaskedTextBox[] textBoxes = new MaskedTextBox[values.Length]; + Button buttonOk = new Button(); + Button buttonCancel = new Button(); + PictureBox picture = new PictureBox(); + + form.Text = title; + int lRight = 0; + for (int i = 0; i < prompts.Length; i++) + { + labels[i] = new Label(); + labels[i].Text = prompts[i]; + + textBoxes[i] = new MaskedTextBox(); + textBoxes[i].Text = values[i].ToString(System.Globalization.CultureInfo.InvariantCulture); + textBoxes[i].SelectionStart = 0; + textBoxes[i].SelectionLength = textBoxes[i].Text.Length; + textBoxes[i].BorderStyle = BorderStyle.FixedSingle; + Color bc = textBoxes[i].BackColor; + if (readOnly) textBoxes[i].ReadOnly = true; + textBoxes[i].BackColor = bc; + textBoxes[i].Validating += new System.ComponentModel.CancelEventHandler(InputBox_Validating); + + labels[i].SetBounds(9, 20 + 40 * i, defWidth - 24, 13); + labels[i].AutoSize = true; + textBoxes[i].SetBounds(12, 36 + 40 * i, defWidth - 24, 20); + textBoxes[i].Anchor = textBoxes[i].Anchor | AnchorStyles.Right; + + if (labels[i].Right > lRight) lRight = labels[i].Right; + }; + + if (icon != null) picture.Image = icon; + picture.SizeMode = PictureBoxSizeMode.StretchImage; + + buttonOk.Text = pOk_Text; + buttonCancel.Text = pCancel_Text; + buttonOk.DialogResult = DialogResult.OK; + buttonCancel.DialogResult = DialogResult.Cancel; + + + buttonOk.SetBounds(defWidth - 168, 32 + 40 * prompts.Length, 75, 23); + buttonCancel.SetBounds(defWidth - 87, 32 + 40 * prompts.Length, 75, 23); + picture.SetBounds(12, 32 + 40 * prompts.Length, 22, 22); + + buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + + form.ClientSize = new Size(defWidth, 67 + 40 * prompts.Length); + form.Controls.AddRange(labels); + form.Controls.AddRange(textBoxes); + form.Controls.AddRange(new Control[] { buttonOk, buttonCancel, picture }); + form.ClientSize = new Size(Math.Max(defWidth, lRight + 10), form.ClientSize.Height); + form.FormBorderStyle = FormBorderStyle.FixedDialog; + form.StartPosition = FormStartPosition.CenterScreen; + form.MinimizeBox = false; + form.MaximizeBox = false; + form.AcceptButton = buttonOk; + form.CancelButton = buttonCancel; + + DialogResult _result = form.ShowDialog(); + for (int i = 0; i < prompts.Length; i++) + values[i] = double.Parse(textBoxes[i].Text, System.Globalization.CultureInfo.InvariantCulture); + if (picture.Image != null) picture.Image.Dispose(); + form.Dispose(); + return _result; + } + + private static void InputBox_Validating(object sender, System.ComponentModel.CancelEventArgs e) + { + if (sender is MaskedTextBox) + { + double d = 0; + if (double.TryParse((sender as MaskedTextBox).Text, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out d)) ; + if (d < qm_d_mima[0]) d = qm_d_mima[0]; + if (d > qm_d_mima[1]) d = qm_d_mima[1]; + (sender as MaskedTextBox).Text = d.ToString(System.Globalization.CultureInfo.InvariantCulture); + }; + } + + /// + /// Show Editable Input Box Dialog + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// DialogResult + public static DialogResult QueryStringBox(string title, string promptText, ref string value) + { + InputBox ib = new InputBox(title, promptText, value); + DialogResult dr = ib.Show(); + value = ib.Value; + return dr; + } + /// + /// Show Editable Input Box Dialog with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// Icon Image + /// DialogResult + public static DialogResult QueryStringBox(string title, string promptText, ref string value, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, value); + ib.Icon = icon; + DialogResult dr = ib.Show(); + value = ib.Value; + return dr; + + } + /// + /// Show Editable Masked Input Box Dialog + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// Input Mask or Regex for Value + /// If text is Input Mask it starts from M. If text is Regex it starts from R. + /// Input Mask symbols: 0 - digits; 9 - digits and spaces; # - digits, spaces, +, - + /// L - letter; ? - letters if need; A - letter or digit; . - decimal separator; + /// , - space for digits; / - date separator; $ - currency symbol + /// Regex: http://regexstorm.net/reference + /// + /// DialogResult + public static DialogResult QueryStringBox(string title, string promptText, ref string value, string InputMaskOrRegex) + { + InputBox ib = new InputBox(title, promptText, value); + ib.InputMaskOrRegex = InputMaskOrRegex; + DialogResult dr = ib.Show(); + value = ib.Value; + return dr; + } + /// + /// Show Editable Masked Input Box Dialog with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// Input Mask or Regex for Value + /// If text is Input Mask it starts from M. If text is Regex it starts from R. + /// Input Mask symbols: 0 - digits; 9 - digits and spaces; # - digits, spaces, +, - + /// L - letter; ? - letters if need; A - letter or digit; . - decimal separator; + /// , - space for digits; / - date separator; $ - currency symbol + /// Regex: http://regexstorm.net/reference + /// + /// Image Icon + /// DialogResult + public static DialogResult QueryStringBox(string title, string promptText, ref string value, string InputMaskOrRegex, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, value); + ib.ReadOnly = true; + DialogResult dr = ib.Show(); + value = ib.Value.ToString(); + return dr; + } + + /// + /// Show ReadOnly Box Dialog + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// DialogResult + public static DialogResult Show(string title, string promptText, int value) + { + InputBox ib = new InputBox(title, promptText, value.ToString()); + ib.ReadOnly = true; + DialogResult dr = ib.Show(); + return dr; + + } + /// + /// Show ReadOnly Box Dialog with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// Image Icon + /// DialogResult + public static DialogResult Show(string title, string promptText, int value, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, value.ToString()); + ib.Icon = icon; + ib.ReadOnly = true; + DialogResult dr = ib.Show(); + return dr; + + } + /// + /// Show Editable Input Box Dialog + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// DialogResult + public static DialogResult Show(string title, string promptText, ref int value) + { + InputBox ib = new InputBox(title, promptText, value.ToString()); + DialogResult dr = ib.ShowNumericBoxed(ref value, int.MinValue, int.MaxValue); + value = int.Parse(ib.Value); + return dr; + + } + /// + /// Show Editable Input Box Dialog with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// Image Icon + /// DialogResult + public static DialogResult Show(string title, string promptText, ref int value, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, value.ToString()); + ib.Icon = icon; + DialogResult dr = ib.ShowNumericBoxed(ref value, int.MinValue, int.MaxValue); + value = int.Parse(ib.Value); + return dr; + + } + /// + /// Show Editable Input Box Dialog + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// Minimum Allowed Value + /// Maximum Allowed Value + /// DialogResult + public static DialogResult Show(string title, string promptText, ref int value, int min, int max) + { + InputBox ib = new InputBox(title, promptText, value.ToString()); + DialogResult dr = ib.ShowNumericBoxed(ref value, min, max); + value = int.Parse(ib.Value); + return dr; + + } + /// + /// Show Editable Input Box Dialog with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// Minimum Allowed Value + /// Maximum Allowed Value + /// Image Icon + /// DialogResult + public static DialogResult Show(string title, string promptText, ref int value, int min, int max, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, value.ToString()); + ib.Icon = icon; + DialogResult dr = ib.ShowNumericBoxed(ref value, min, max); + value = int.Parse(ib.Value); + return dr; + + } + + /// + /// Show Editable Input Box Dialog + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// DialogResult + public static DialogResult QueryNumberBox(string title, string promptText, ref int value) + { + InputBox ib = new InputBox(title, promptText, value.ToString()); + DialogResult dr = ib.ShowNumericBoxed(ref value, int.MinValue, int.MaxValue); + value = int.Parse(ib.Value); + return dr; + + } + /// + /// Show Editable Input Box Dialog with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// Image Icon + /// DialogResult + public static DialogResult QueryNumberBox(string title, string promptText, ref int value, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, value.ToString()); + ib.Icon = icon; + DialogResult dr = ib.ShowNumericBoxed(ref value, int.MinValue, int.MaxValue); + value = int.Parse(ib.Value); + return dr; + + } + /// + /// Show Editable Input Box Dialog + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// Minimum Allowed Value + /// Maximum Allowed Value + /// DialogResult + public static DialogResult QueryNumberBox(string title, string promptText, ref int value, int min, int max) + { + InputBox ib = new InputBox(title, promptText, value.ToString()); + DialogResult dr = ib.ShowNumericBoxed(ref value, min, max); + value = int.Parse(ib.Value); + return dr; + + } + /// + /// Show Editable Input Box Dialog with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// Minimum Allowed Value + /// Maximum Allowed Value + /// Image Icon + /// DialogResult + public static DialogResult QueryNumberBox(string title, string promptText, ref int value, int min, int max, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, value.ToString()); + ib.Icon = icon; + DialogResult dr = ib.ShowNumericBoxed(ref value, min, max); + value = int.Parse(ib.Value); + return dr; + + } + + + /// + /// Show Selectable List Box + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// List Values + /// Selected Value Index + /// DialogResult + public static DialogResult Show(string title, string promptText, string[] values, ref int selectedValue) + { + InputBox ib = new InputBox(title, promptText, values, selectedValue); + ib.ReadOnly = true; + DialogResult dr = ib.Show(); + selectedValue = ib.SelectedIndex; + return dr; + + } + /// + /// Show Selectable List Box with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// List Values + /// Selected Value Index + /// Image Icon + /// DialogResult + public static DialogResult Show(string title, string promptText, string[] values, ref int selectedValue, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, values, selectedValue); + ib.ReadOnly = true; + ib.Icon = icon; + DialogResult dr = ib.Show(); + selectedValue = ib.SelectedIndex; + return dr; + + } + /// + /// Show Selectable List Box with Icons + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// List Values + /// Selected Value Index + /// ImageList + /// DialogResult + public static DialogResult Show(string title, string promptText, string[] values, ref int selectedValue, ImageList icons) + { + InputBox ib = new InputBox(title, promptText, values, selectedValue); + ib.ReadOnly = true; + ib.IconList = icons; + DialogResult dr = ib.Show(); + selectedValue = ib.SelectedIndex; + return dr; + + } + /// + /// Show Selectable List Box + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// List Values + /// Selected Value Text + /// DialogResult + public static DialogResult Show(string title, string promptText, string[] values, ref string selectedValue) + { + InputBox ib = new InputBox(title, promptText, values); + ib.ReadOnly = true; + ib.Value = selectedValue; + DialogResult dr = ib.Show(); + selectedValue = ib.Value; + return dr; + + } + /// + /// Show Selectable List Box with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// List Values + /// Selected Value Text + /// Image Icon + /// DialogResult + public static DialogResult Show(string title, string promptText, string[] values, ref string selectedValue, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, values); + ib.ReadOnly = true; + ib.Icon = icon; + ib.Value = selectedValue; + DialogResult dr = ib.Show(); + selectedValue = ib.Value; + return dr; + + } + /// + /// Show Selectable List Box with Icons + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// List Values + /// Selected Value Text + /// ImageList + /// DialogResult + public static DialogResult Show(string title, string promptText, string[] values, ref string selectedValue, ImageList icons) + { + InputBox ib = new InputBox(title, promptText, values); + ib.ReadOnly = true; + ib.IconList = icons; + ib.Value = selectedValue; + DialogResult dr = ib.Show(); + selectedValue = ib.Value; + return dr; + } + + /// + /// Show Changable List Box + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// List Values + /// Selected Value Text + /// Input Mask or Regex for Value + /// If text is Input Mask it starts from M. If text is Regex it starts from R. + /// Input Mask symbols: 0 - digits; 9 - digits and spaces; # - digits, spaces, +, - + /// L - letter; ? - letters if need; A - letter or digit; . - decimal separator; + /// , - space for digits; / - date separator; $ - currency symbol + /// Regex: http://regexstorm.net/reference + /// + /// DialogResult + public static DialogResult Show(string title, string promptText, string[] values, ref string selectedValue, string InputMaskOrRegex) + { + InputBox ib = new InputBox(title, promptText, values); + ib.InputMaskOrRegex = InputMaskOrRegex; + ib.ReadOnly = false; + ib.Value = selectedValue; + DialogResult dr = ib.Show(); + selectedValue = ib.Value; + return dr; + } + /// + /// Show Changable List Box with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// List Values + /// Selected Value Text + /// Input Mask or Regex for Value + /// If text is Input Mask it starts from M. If text is Regex it starts from R. + /// Input Mask symbols: 0 - digits; 9 - digits and spaces; # - digits, spaces, +, - + /// L - letter; ? - letters if need; A - letter or digit; . - decimal separator; + /// , - space for digits; / - date separator; $ - currency symbol + /// Regex: http://regexstorm.net/reference + /// + /// Image Icon + /// DialogResult + public static DialogResult Show(string title, string promptText, string[] values, ref string selectedValue, string InputMaskOrRegex, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, values); + ib.InputMaskOrRegex = InputMaskOrRegex; + ib.ReadOnly = false; + ib.Icon = icon; + ib.Value = selectedValue; + DialogResult dr = ib.Show(); + selectedValue = ib.Value; + return dr; + } + /// + /// Show Listable or Changable List + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// List Values + /// Selected Value Text + /// Changable or Editable + /// DialogResult + public static DialogResult Show(string title, string promptText, string[] values, ref string selectedValue, bool allowNewValue) + { + InputBox ib = new InputBox(title, promptText, values); + ib.ReadOnly = !allowNewValue; + ib.Value = selectedValue; + DialogResult dr = ib.Show(); + selectedValue = ib.Value; + return dr; + } + /// + /// Show Listable or Changable List with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// List Values + /// Selected Value Text + /// Changable or Editable + /// Image Icon + /// DialogResult + public static DialogResult Show(string title, string promptText, string[] values, ref string selectedValue, bool allowNewValue, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, values); + ib.ReadOnly = !allowNewValue; + ib.Icon = icon; + ib.Value = selectedValue; + DialogResult dr = ib.Show(); + selectedValue = ib.Value; + return dr; + } + + /// + /// Show Selectable List Box + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// List Values + /// Selected Value Index + /// DialogResult + public static DialogResult QueryListBox(string title, string promptText, string[] values, ref int selectedValue) + { + InputBox ib = new InputBox(title, promptText, values, selectedValue); + ib.ReadOnly = true; + DialogResult dr = ib.Show(); + selectedValue = ib.SelectedIndex; + return dr; + + } + /// + /// Show Selectable List Box with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// List Values + /// Selected Value Index + /// Image Icon + /// DialogResult + public static DialogResult QueryListBox(string title, string promptText, string[] values, ref int selectedValue, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, values, selectedValue); + ib.ReadOnly = true; + ib.Icon = icon; + DialogResult dr = ib.Show(); + selectedValue = ib.SelectedIndex; + return dr; + + } + /// + /// Show Selectable List Box + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// List Values + /// Selected Value Text + /// DialogResult + public static DialogResult QueryListBox(string title, string promptText, string[] values, ref string selectedValue) + { + InputBox ib = new InputBox(title, promptText, values); + ib.ReadOnly = true; + ib.Value = selectedValue; + DialogResult dr = ib.Show(); + selectedValue = ib.Value; + return dr; + + } + /// + /// Show Selectable List Box with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// List Values + /// Selected Value Text + /// Image Icon + /// DialogResult + public static DialogResult QueryListBox(string title, string promptText, string[] values, ref string selectedValue, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, values); + ib.ReadOnly = true; + ib.Icon = icon; + ib.Value = selectedValue; + DialogResult dr = ib.Show(); + selectedValue = ib.Value; + return dr; + + } + /// + /// Show Changable List Box + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// List Values + /// Selected Value Text + /// Input Mask or Regex for Value + /// If text is Input Mask it starts from M. If text is Regex it starts from R. + /// Input Mask symbols: 0 - digits; 9 - digits and spaces; # - digits, spaces, +, - + /// L - letter; ? - letters if need; A - letter or digit; . - decimal separator; + /// , - space for digits; / - date separator; $ - currency symbol + /// Regex: http://regexstorm.net/reference + /// + /// DialogResult + public static DialogResult QueryListBox(string title, string promptText, string[] values, ref string selectedValue, string InputMaskOrRegex) + { + InputBox ib = new InputBox(title, promptText, values); + ib.InputMaskOrRegex = InputMaskOrRegex; + ib.ReadOnly = false; + ib.Value = selectedValue; + DialogResult dr = ib.Show(); + selectedValue = ib.Value; + return dr; + } + /// + /// Show Changable List Box with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// List Values + /// Selected Value Text + /// Input Mask or Regex for Value + /// If text is Input Mask it starts from M. If text is Regex it starts from R. + /// Input Mask symbols: 0 - digits; 9 - digits and spaces; # - digits, spaces, +, - + /// L - letter; ? - letters if need; A - letter or digit; . - decimal separator; + /// , - space for digits; / - date separator; $ - currency symbol + /// Regex: http://regexstorm.net/reference + /// + /// Image Icon + /// DialogResult + public static DialogResult QueryListBox(string title, string promptText, string[] values, ref string selectedValue, string InputMaskOrRegex, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, values); + ib.InputMaskOrRegex = InputMaskOrRegex; + ib.ReadOnly = false; + ib.Icon = icon; + ib.Value = selectedValue; + DialogResult dr = ib.Show(); + selectedValue = ib.Value; + return dr; + } + /// + /// Show Listable or Changable List + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// List Values + /// Selected Value Text + /// Changable or Editable + /// DialogResult + public static DialogResult QueryListBox(string title, string promptText, string[] values, ref string selectedValue, bool allowNewValue) + { + InputBox ib = new InputBox(title, promptText, values); + ib.ReadOnly = !allowNewValue; + ib.Value = selectedValue; + DialogResult dr = ib.Show(); + selectedValue = ib.Value; + return dr; + } + /// + /// Show Listable or Changable List with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// List Values + /// Selected Value Text + /// Changable or Editable + /// Image Icon + /// DialogResult + public static DialogResult QueryListBox(string title, string promptText, string[] values, ref string selectedValue, bool allowNewValue, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, values); + ib.ReadOnly = !allowNewValue; + ib.Icon = icon; + ib.Value = selectedValue; + DialogResult dr = ib.Show(); + selectedValue = ib.Value; + return dr; + } + + /// + /// Show Two-List DropBox + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// boolean value + /// Text for False Value + /// Text for True Value + /// DialogResult + public static DialogResult Show(string title, string promptText, ref bool value, string textFalse, string textTrue) + { + InputBox ib = new InputBox(title, promptText, new string[] { textFalse, textTrue }, value ? 1 : 0); + ib.ReadOnly = true; + DialogResult dr = ib.Show(); + value = ib.SelectedIndex == 1; + return dr; + } + /// + /// Show Two-List DropBox with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// boolean value + /// Text for False Value + /// Text for True Value + /// Image Icon + /// DialogResult + public static DialogResult Show(string title, string promptText, ref bool value, string textFalse, string textTrue, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, new string[] { textFalse, textTrue }, value ? 1 : 0); + ib.Icon = icon; + ib.ReadOnly = true; + DialogResult dr = ib.Show(); + value = ib.SelectedIndex == 1; + return dr; + } + + /// + /// Show ReadOnly Box Dialog + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// DialogResult + public static DialogResult Show(string title, string promptText, float value) + { + InputBox ib = new InputBox(title, promptText, value.ToString(System.Globalization.CultureInfo.InvariantCulture)); + ib.ReadOnly = true; + DialogResult dr = ib.Show(); + return dr; + + } + /// + /// Show ReadOnly Box Dialog with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// Image Icon + /// DialogResult + public static DialogResult Show(string title, string promptText, float value, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, value.ToString(System.Globalization.CultureInfo.InvariantCulture)); + ib.Icon = icon; + ib.ReadOnly = true; + DialogResult dr = ib.Show(); + return dr; + + } + /// + /// Show Editable Input Box Dialog + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// DialogResult + public static DialogResult Show(string title, string promptText, ref float value) + { + InputBox ib = new InputBox(title, promptText, value.ToString(System.Globalization.CultureInfo.InvariantCulture)); + ib.InputMaskOrRegex = "^(([+-]?)|([+-]?[0-9]{1,}[.]?[0-9]{0,})|([+-]?[.][0-9]{0,}))$"; + DialogResult dr = ib.Show(); + if ((ib.Value == "-") || (ib.Value == ".")) + value = 0; + else + value = float.Parse(ib.Value, System.Globalization.CultureInfo.InvariantCulture); + return dr; + + } + /// + /// Show Editable Input Box Dialog with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// Image Icon + /// DialogResult + public static DialogResult Show(string title, string promptText, ref float value, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, value.ToString(System.Globalization.CultureInfo.InvariantCulture)); + ib.InputMaskOrRegex = "^(([+-]?)|([+-]?[0-9]{1,}[.]?[0-9]{0,})|([+-]?[.][0-9]{0,}))$"; + ib.Icon = icon; + DialogResult dr = ib.Show(); + if ((ib.Value == "-") || (ib.Value == ".")) + value = 0; + else + value = float.Parse(ib.Value, System.Globalization.CultureInfo.InvariantCulture); + return dr; + } + + /// + /// Show ReadOnly Box Dialog + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// DialogResult + public static DialogResult QueryNumberBox(string title, string promptText, float value) + { + InputBox ib = new InputBox(title, promptText, value.ToString(System.Globalization.CultureInfo.InvariantCulture)); + ib.ReadOnly = true; + DialogResult dr = ib.Show(); + return dr; + + } + /// + /// Show ReadOnly Box Dialog with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// Image Icon + /// DialogResult + public static DialogResult QueryNumberBox(string title, string promptText, float value, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, value.ToString(System.Globalization.CultureInfo.InvariantCulture)); + ib.Icon = icon; + ib.ReadOnly = true; + DialogResult dr = ib.Show(); + return dr; + + } + /// + /// Show Editable Input Box Dialog + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// DialogResult + public static DialogResult QueryNumberBox(string title, string promptText, ref float value) + { + InputBox ib = new InputBox(title, promptText, value.ToString(System.Globalization.CultureInfo.InvariantCulture)); + ib.InputMaskOrRegex = "^(([+-]?)|([+-]?[0-9]{1,}[.]?[0-9]{0,})|([+-]?[.][0-9]{0,}))$"; + DialogResult dr = ib.Show(); + if ((ib.Value == "-") || (ib.Value == ".")) + value = 0; + else + value = float.Parse(ib.Value, System.Globalization.CultureInfo.InvariantCulture); + return dr; + + } + /// + /// Show Editable Input Box Dialog with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// Image Icon + /// DialogResult + public static DialogResult QueryNumberBox(string title, string promptText, ref float value, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, value.ToString(System.Globalization.CultureInfo.InvariantCulture)); + ib.InputMaskOrRegex = "^(([+-]?)|([+-]?[0-9]{1,}[.]?[0-9]{0,})|([+-]?[.][0-9]{0,}))$"; + ib.Icon = icon; + DialogResult dr = ib.Show(); + if ((ib.Value == "-") || (ib.Value == ".")) + value = 0; + else + value = float.Parse(ib.Value, System.Globalization.CultureInfo.InvariantCulture); + return dr; + } + + /// + /// Show ReadOnly Box Dialog + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// DialogResult + public static DialogResult Show(string title, string promptText, double value) + { + InputBox ib = new InputBox(title, promptText, value.ToString(System.Globalization.CultureInfo.InvariantCulture)); + ib.ReadOnly = true; + DialogResult dr = ib.Show(); + return dr; + + } + /// + /// Show ReadOnly Box Dialog with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// Image Icon + /// DialogResult + public static DialogResult Show(string title, string promptText, double value, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, value.ToString(System.Globalization.CultureInfo.InvariantCulture)); + ib.Icon = icon; + ib.ReadOnly = true; + DialogResult dr = ib.Show(); + return dr; + + } + /// + /// Show Editable Input Box Dialog + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// DialogResult + public static DialogResult Show(string title, string promptText, ref double value) + { + InputBox ib = new InputBox(title, promptText, value.ToString(System.Globalization.CultureInfo.InvariantCulture)); + ib.InputMaskOrRegex = "^(([+-]?)|([+-]?[0-9]{1,}[.]?[0-9]{0,})|([+-]?[.][0-9]{0,}))$"; + DialogResult dr = ib.Show(); + if ((ib.Value == "-") || (ib.Value == ".")) + value = 0; + else + value = double.Parse(ib.Value, System.Globalization.CultureInfo.InvariantCulture); + return dr; + + } + /// + /// Show Editable Input Box Dialog with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// Image Icon + /// DialogResult + public static DialogResult Show(string title, string promptText, ref double value, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, value.ToString(System.Globalization.CultureInfo.InvariantCulture)); + ib.InputMaskOrRegex = "^(([+-]?)|([+-]?[0-9]{1,}[.]?[0-9]{0,})|([+-]?[.][0-9]{0,}))$"; + ib.Icon = icon; + DialogResult dr = ib.Show(); + if ((ib.Value == "-") || (ib.Value == ".")) + value = 0; + else + value = double.Parse(ib.Value, System.Globalization.CultureInfo.InvariantCulture); + return dr; + } + + /// + /// Show ReadOnly Box Dialog + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// DialogResult + public static DialogResult QueryNumberBox(string title, string promptText, double value) + { + InputBox ib = new InputBox(title, promptText, value.ToString(System.Globalization.CultureInfo.InvariantCulture)); + ib.ReadOnly = true; + DialogResult dr = ib.Show(); + return dr; + + } + /// + /// Show ReadOnly Box Dialog with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// Image Icon + /// DialogResult + public static DialogResult QueryNumberBox(string title, string promptText, double value, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, value.ToString(System.Globalization.CultureInfo.InvariantCulture)); + ib.Icon = icon; + ib.ReadOnly = true; + DialogResult dr = ib.Show(); + return dr; + + } + /// + /// Show Editable Input Box Dialog + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// DialogResult + public static DialogResult QueryNumberBox(string title, string promptText, ref double value) + { + InputBox ib = new InputBox(title, promptText, value.ToString(System.Globalization.CultureInfo.InvariantCulture)); + ib.InputMaskOrRegex = "^(([+-]?)|([+-]?[0-9]{1,}[.]?[0-9]{0,})|([+-]?[.][0-9]{0,}))$"; + DialogResult dr = ib.Show(); + if ((ib.Value == "-") || (ib.Value == ".")) + value = 0; + else + value = double.Parse(ib.Value, System.Globalization.CultureInfo.InvariantCulture); + return dr; + + } + /// + /// Show Editable Input Box Dialog with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Parameter Value + /// Image Icon + /// DialogResult + public static DialogResult QueryNumberBox(string title, string promptText, ref double value, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, value.ToString(System.Globalization.CultureInfo.InvariantCulture)); + ib.InputMaskOrRegex = "^(([+-]?)|([+-]?[0-9]{1,}[.]?[0-9]{0,})|([+-]?[.][0-9]{0,}))$"; + ib.Icon = icon; + DialogResult dr = ib.Show(); + if ((ib.Value == "-") || (ib.Value == ".")) + value = 0; + else + value = double.Parse(ib.Value, System.Globalization.CultureInfo.InvariantCulture); + return dr; + } + + /// + /// Show Listable Input Box Dialog for typeof(Enum) + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Type of Enum + /// Selected Value + /// DialogResult + public static DialogResult Show(string title, string promptText, Type enumType, ref object selectedValue) + { + Array vls = Enum.GetValues((enumType)); + + List vals = new List(); + foreach (string element in Enum.GetNames(enumType)) + vals.Add(element); + + InputBox ib = new InputBox(title, promptText, vals.ToArray()); + ib.Value = selectedValue.ToString(); + ib.ReadOnly = true; + DialogResult dr = ib.Show(); + selectedValue = vls.GetValue(ib.SelectedIndex); + return dr; + } + /// + /// Show Listable Input Box Dialog for typeof(Enum) + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Type of Enum + /// Selected Value + /// /// Image Icon + /// DialogResult + public static DialogResult Show(string title, string promptText, Type enumType, ref object selectedValue, Bitmap icon) + { + Array vls = Enum.GetValues((enumType)); + + List vals = new List(); + foreach (string element in Enum.GetNames(enumType)) + vals.Add(element); + + InputBox ib = new InputBox(title, promptText, vals.ToArray()); + ib.Icon = icon; + ib.Value = selectedValue.ToString(); + ib.ReadOnly = true; + DialogResult dr = ib.Show(); + selectedValue = vls.GetValue(ib.SelectedIndex); + return dr; + } + + /// + /// Show Editable Directory Input Box With Browse Button + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// DIrectory + /// DialogResult + public static DialogResult QueryDirectoryBox(string title, string promptText, ref string path) + { + InputBox ib = new InputBox(title, promptText, path); + DialogResult dr = ib.ShowSelectDir(); + path = ib.Value; + return dr; + } + /// + /// Show Editable Directory Input Box With Browse Button + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// DIrectory + /// Image Icon + /// DialogResult + public static DialogResult QueryDirectoryBox(string title, string promptText, ref string path, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, path); + ib.Icon = icon; + DialogResult dr = ib.ShowSelectDir(); + path = ib.Value; + return dr; + } + + /// + /// Show Editable File Input Box + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// File Path + /// OpenFileDialog Filter + /// DialogResult + public static DialogResult QueryFileBox(string title, string promptText, ref string file, string filter) + { + InputBox ib = new InputBox(title, promptText, file); + DialogResult dr = ib.ShowSelectFile(filter); + file = ib.Value; + return dr; + } + + /// + /// Show Editable File Input Box with Icon + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// File Path + /// OpenFileDialog Filter + /// Image Icon + /// DialogResult + public static DialogResult QueryFileBox(string title, string promptText, ref string file, string filter, Bitmap icon) + { + InputBox ib = new InputBox(title, promptText, file); + DialogResult dr = ib.ShowSelectFile(filter); + file = ib.Value; + return dr; + } + + /// + /// Show Editable Color Box + /// + /// Dialog Window Title + /// Parameter Prompt Text + /// Color + /// DialogResult + public static DialogResult QueryColorBox(string title, string promptText, ref Color color) + { + InputBox ib = new InputBox(title, promptText); + DialogResult dr = ib.ShowSelectColor(ref color); + return dr; + } + + private static String HexConverter(Color c) + { + return "#" + c.R.ToString("X2") + c.G.ToString("X2") + c.B.ToString("X2"); + } + + private static Color RGBConverter(string hex) + { + Color rtn = Color.Black; + try + { + return Color.FromArgb( + int.Parse(hex.Substring(1, 2), System.Globalization.NumberStyles.HexNumber), + int.Parse(hex.Substring(3, 2), System.Globalization.NumberStyles.HexNumber), + int.Parse(hex.Substring(5, 2), System.Globalization.NumberStyles.HexNumber)); + } + catch { }; + + return rtn; + } + + private static TextBox query_info_box = null; + public static DialogResult QueryInfoBox(string title, string topText, string bottomText, string mainText) + { + return QueryInfoBox(title, topText, bottomText, mainText, true, false, MessageBoxButtons.OK, true); + } + public static DialogResult QueryInfoBox(string title, string topText, string bottomText, string mainText, bool readOnly, bool allowNewLoadSave, MessageBoxButtons buttons, bool closeButton) + { + Form form = closeButton ? new Form() : new InputBoxForm(); + form.DialogResult = DialogResult.Cancel; + form.ShowInTaskbar = pShowInTaskBar; + form.Text = title; + form.ClientSize = new Size(defWidth, 107); + form.FormBorderStyle = FormBorderStyle.FixedDialog; + form.StartPosition = FormStartPosition.CenterScreen; + form.MinimizeBox = false; + form.MaximizeBox = false; + form.ClientSize = new Size(500, 400); + + Panel panel1 = new Panel(); + Label label1 = new Label(); + Panel panel2 = new Panel(); + Label label2 = new Label(); + Panel panel3 = new Panel(); + Panel panel4 = new Panel(); + TextBox textBox1 = new TextBox(); + Panel panel5 = new Panel(); + Panel panel6 = new Panel(); + Button button4 = new Button(); + Button button3 = new Button(); + Button button5 = new Button(); + + int btnCount = 1; + if ((buttons == MessageBoxButtons.OKCancel) || (buttons == MessageBoxButtons.YesNo) || (buttons == MessageBoxButtons.RetryCancel)) btnCount = 2; + if ((buttons == MessageBoxButtons.AbortRetryIgnore) || (buttons == MessageBoxButtons.YesNoCancel)) btnCount = 3; + Button[] Buttons = new Button[btnCount]; + for (int i = 0; i < btnCount; i++) + { + Buttons[i] = new Button(); + Buttons[i].Text = pOk_Text; + if (i == 0) + { + if (buttons == MessageBoxButtons.OK) { Buttons[i].Text = pOk_Text; Buttons[i].DialogResult = DialogResult.OK; }; + if (buttons == MessageBoxButtons.OKCancel) { Buttons[i].Text = pOk_Text; Buttons[i].DialogResult = DialogResult.OK; }; + if (buttons == MessageBoxButtons.AbortRetryIgnore) { Buttons[i].Text = pOk_Abort; Buttons[i].DialogResult = DialogResult.Abort; }; + if (buttons == MessageBoxButtons.YesNoCancel) { Buttons[i].Text = pOk_Yes; Buttons[i].DialogResult = DialogResult.Yes; }; + if (buttons == MessageBoxButtons.YesNo) { Buttons[i].Text = pOk_Yes; Buttons[i].DialogResult = DialogResult.Yes; }; + if (buttons == MessageBoxButtons.RetryCancel) { Buttons[i].Text = pOk_Retry; Buttons[i].DialogResult = DialogResult.Retry; }; + }; + if (i == 1) + { + if (buttons == MessageBoxButtons.OKCancel) { Buttons[i].Text = pCancel_Text; Buttons[i].DialogResult = DialogResult.Cancel; }; + if (buttons == MessageBoxButtons.AbortRetryIgnore) { Buttons[i].Text = pOk_Retry; Buttons[i].DialogResult = DialogResult.Retry; }; + if (buttons == MessageBoxButtons.YesNoCancel) { Buttons[i].Text = pOk_No; Buttons[i].DialogResult = DialogResult.No; }; + if (buttons == MessageBoxButtons.YesNo) { Buttons[i].Text = pOk_No; Buttons[i].DialogResult = DialogResult.No; }; + if (buttons == MessageBoxButtons.RetryCancel) { Buttons[i].Text = pCancel_Text; Buttons[i].DialogResult = DialogResult.Cancel; }; + }; + if (i == 2) + { + if (buttons == MessageBoxButtons.AbortRetryIgnore) { Buttons[i].Text = pOk_Ignore; Buttons[i].DialogResult = DialogResult.Ignore; }; + if (buttons == MessageBoxButtons.YesNoCancel) { Buttons[i].Text = pCancel_Text; Buttons[i].DialogResult = DialogResult.Cancel; }; + }; + Buttons[i].BackColor = System.Drawing.SystemColors.Control; + Buttons[i].Location = new System.Drawing.Point(9 + 81 * i, 10); + Buttons[i].Size = new System.Drawing.Size(75, 23); + }; + panel3.Controls.AddRange(Buttons); + + panel1.BackColor = System.Drawing.SystemColors.Window; + panel1.Controls.Add(label1); + panel1.Dock = System.Windows.Forms.DockStyle.Top; + panel1.Location = new System.Drawing.Point(0, 0); + panel1.Size = new System.Drawing.Size(578, 45); + label1.AutoSize = true; + label1.Location = new System.Drawing.Point(12, 14); + label1.Size = new System.Drawing.Size(174, 26); + label1.Text = topText; + panel2.BackColor = System.Drawing.SystemColors.Window; + panel2.Controls.Add(label2); + panel2.Controls.Add(panel3); + panel2.Dock = System.Windows.Forms.DockStyle.Bottom; + panel2.Location = new System.Drawing.Point(0, 432); + panel2.Size = new System.Drawing.Size(578, 45); + panel3.Dock = System.Windows.Forms.DockStyle.Right; + panel3.Location = new System.Drawing.Point(400, 0); + panel3.Size = new System.Drawing.Size(34 + 81 * btnCount, 45); + label2.AutoSize = true; + label2.Location = new System.Drawing.Point(12, 16); + label2.Size = new System.Drawing.Size(12, 13); + label2.Text = bottomText; + panel4.Controls.Add(textBox1); + panel4.Controls.Add(panel6); + panel4.Controls.Add(panel5); + panel4.Dock = System.Windows.Forms.DockStyle.Fill; + panel4.Location = new System.Drawing.Point(0, 135); + panel4.Size = new System.Drawing.Size(578, 297); + panel5.BackColor = System.Drawing.SystemColors.Window; + panel5.Dock = System.Windows.Forms.DockStyle.Left; + panel5.Location = new System.Drawing.Point(0, 0); + panel5.Size = new System.Drawing.Size(34, 297); + textBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + textBox1.Dock = System.Windows.Forms.DockStyle.Fill; + textBox1.Location = new System.Drawing.Point(34, 0); + textBox1.Multiline = true; + textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both; + textBox1.Size = new System.Drawing.Size(510, 297); + textBox1.Text = mainText; + textBox1.SelectionStart = 0; + Color bc = textBox1.BackColor; + textBox1.ReadOnly = readOnly; + textBox1.BackColor = bc; + panel6.BackColor = System.Drawing.SystemColors.Window; + panel6.Controls.Add(button5); + panel6.Controls.Add(button4); + panel6.Controls.Add(button3); + panel6.Dock = System.Windows.Forms.DockStyle.Right; + panel6.Location = new System.Drawing.Point(544, 0); + panel6.Size = new System.Drawing.Size(34, 297); + button4.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + button4.Location = new System.Drawing.Point(6, 54); + button4.Size = new System.Drawing.Size(22, 23); + button4.Text = "S"; + button3.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + button3.Location = new System.Drawing.Point(6, 30); + button3.Size = new System.Drawing.Size(22, 23); + button3.Text = readOnly ? "" : "L"; + button5.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + button5.Location = new System.Drawing.Point(6, 6); + button5.Size = new System.Drawing.Size(22, 23); + button5.TabIndex = 3; + button5.Text = readOnly ? "" : "N"; + if (!readOnly) + { + button3.Click += new EventHandler(buttonLNS_Click); + button4.Click += new EventHandler(buttonLNS_Click); + button5.Click += new EventHandler(buttonLNS_Click); + }; + form.Controls.Add(panel4); + form.Controls.Add(panel1); + form.Controls.Add(panel2); + form.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + + { + //button1.Text = fullview ? pCancel_Text : pOk_Text; + //button2.Visible = fullview; + button3.Visible = allowNewLoadSave; + button4.Visible = allowNewLoadSave; + button5.Visible = allowNewLoadSave; + + button3.Enabled = !readOnly; + button4.Enabled = !String.IsNullOrEmpty(mainText); + button5.Enabled = !readOnly; + }; + + query_info_box = textBox1; + DialogResult dr = form.ShowDialog(); + query_info_box = null; + form.Dispose(); + return dr; + } + + private static void buttonLNS_Click(object sender, EventArgs e) + { + if (sender is Button) + { + if (query_info_box == null) return; + Button btn = (Button)sender; + if (btn.Text == "N") + query_info_box.Text = ""; + if (btn.Text == "L") + { + OpenFileDialog ofd = new OpenFileDialog(); + ofd.Filter = "Text Files (*.txt)|*.txt|All Types (*.*)|*.*"; + ofd.DefaultExt = ".txt"; + if (ofd.ShowDialog() == DialogResult.OK) + { + try + { + FileStream fs = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read); + StreamReader sr = new StreamReader(fs, System.Text.Encoding.GetEncoding(1251)); + query_info_box.Text = sr.ReadToEnd(); + sr.Close(); + fs.Close(); + } + catch { }; + }; + ofd.Dispose(); + }; + if (btn.Text == "S") + { + SaveFileDialog sfd = new SaveFileDialog(); + sfd.Filter = "Text Files (*.txt)|*.txt|All Types (*.*)|*.*"; + sfd.DefaultExt = ".txt"; + if (sfd.ShowDialog() == DialogResult.OK) + { + try + { + FileStream fs = new FileStream(sfd.FileName, FileMode.Create, FileAccess.Write); + StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.GetEncoding(1251)); + sw.Write(query_info_box.Text); + sw.Close(); + fs.Close(); + } + catch { }; + }; + sfd.Dispose(); + }; + }; + } + } + + public class InputBoxForm : Form + { + private const int CP_NOCLOSE_BUTTON = 0x200; + protected override CreateParams CreateParams + { + get + { + CreateParams myCp = base.CreateParams; + myCp.ClassStyle = myCp.ClassStyle | CP_NOCLOSE_BUTTON; + return myCp; + } + } + } + + public class ComboIcons : ComboBox + { + public ComboIcons() + { + DrawMode = DrawMode.OwnerDrawFixed; + DropDownStyle = ComboBoxStyle.DropDownList; + } + + protected override void OnDrawItem(DrawItemEventArgs e) + { + e.DrawBackground(); + e.DrawFocusRectangle(); + if (e.Index >= 0 && e.Index < Items.Count) + { + DropDownItem item = (DropDownItem)Items[e.Index]; + e.Graphics.DrawImage(item.Image, e.Bounds.Left, e.Bounds.Top); + e.Graphics.DrawString(item.Value, e.Font, new SolidBrush(e.ForeColor), e.Bounds.Left + item.Image.Width + 1, e.Bounds.Top + 2); + }; + base.OnDrawItem(e); + } + } + + public class DropDownItem + { + private string value; + public string Value + { + get { return this.value; } + set { this.value = value; } + } + + private Image img; + public Image Image + { + get { return this.img; } + set { this.img = value; } + } + + public DropDownItem() : this("", Color.Black) { } + + public DropDownItem(string val) : this(val, Color.Black) { } + + public DropDownItem(string val, Color color) + { + this.value = val; + this.img = new Bitmap(16, 16); + using (Graphics g = Graphics.FromImage(this.img)) + { + using (Brush b = new SolidBrush(color)) + { + g.DrawRectangle(Pens.White, 0, 0, Image.Width, Image.Height); + g.FillRectangle(b, 1, 1, Image.Width - 1, Image.Height - 1); + }; + }; + } + + public DropDownItem(string val, Image im) + { + this.value = val; + this.img = im; + } + + public override string ToString() + { + return value; + } + } +} diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..5fe6a5b --- /dev/null +++ b/Program.cs @@ -0,0 +1,679 @@ +using System; +using System.Collections.Generic; +using System.Web; +using System.Net; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Xml; +using System.Xml.Serialization; +using System.Windows; +using System.Windows.Forms; + +using Newtonsoft.Json; +using ICSharpCode.SharpZipLib; +using ICSharpCode.SharpZipLib.Zip; +using ICSharpCode.SharpZipLib.Core; + +namespace TvilGrabber +{ + public static class Program + { + public static string version = "13.01.2022"; + + // All is very simple + // Plugin Must return fileName in last line (or in single line) + // if last line (or single) is empty - file is not exists + public static void Main() + { + Console.OutputEncoding = Encoding.UTF8; + + Console.WriteLine("Tvil Grabber by milokz@gmail.com"); + Console.WriteLine("** version " + version + " **"); + + string outFile = null; + TvilGrabber tg = TvilGrabber.Load(); + tg.Init(); + if ((tg.regions != null) && (tg.regions.Count > 0)) + { + List regions = new List(); + for (int i = 0; i < tg.regions.Count; i++) + regions.Add(tg.regions[i].name); + InputBox.defWidth = 450; + int sel = 0; + if (InputBox.Show("Tvil Grabber", " :", regions.ToArray(), ref sel) == DialogResult.OK) + { + int reg = tg.regions[sel].id; + Response.Data[] objs = tg.GrabRegion(reg); + if ((objs != null) && (objs.Length > 0)) + { + DialogResult dr = MessageBox.Show(" " + objs.Length.ToString() + " !\r\n ?\r\n\r\nP.S: !", "Tvil Grabber", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); + if (dr != DialogResult.Cancel) + { + for (int j = 0; j < objs.Length; j++) + { + objs[j].name = objs[j].i.ToString(); + objs[j].comm = String.Format(tg.name_url, objs[j].i); + objs[j].url = String.Format(tg.name_url, objs[j].i); + }; + if (dr == DialogResult.Yes) + { + outFile = Response.Data.SaveKML(objs, tg.regions[sel].name); + try + { + tg.GrabNames(ref objs); + } + catch (Exception ex) + { + Console.WriteLine("Error: " + ex.Message); + }; + }; + outFile = Response.Data.SaveKML(objs, tg.regions[sel].name); + if (outFile != null) outFile = Response.Data.SaveKMZ(outFile); + }; + }; + }; + }; + tg.DeInit(); + Console.WriteLine("Done"); + if (outFile != null) + { + Console.WriteLine("Data saved to file: "); + Console.WriteLine(outFile); + }; + System.Threading.Thread.Sleep(500); + } + } + + public class TvilGrabber + { + public string reg_url = "https://api.tvil.ru/mapEntities?page[limit]=1&filter[geo]={0}&format[minify]=1"; + public int reg_min = 2; + public int reg_max = 400; + public int reg_sleep = 20; + + public string objs_url = "https://api.tvil.ru/mapEntities?page[limit]={0}&filter[geo]={1}&format[minify]=1"; + public int objs_limit = 15000; + + public string name_url = "https://tvil.ru/city/all/hotels/{0}/"; + public int name_threads = 1; + public int name_sleep = 2000; + + + [XmlArray(ElementName = "regions")] + [XmlArrayItem(ElementName = "r")] + public List regions = new List(); + + public void Init() + { + if ((regions == null) || (regions.Count == 0)) GrabRegions(); + } + + public void DeInit() + { + this.Save(); + } + + public void GrabRegions() + { + regions = new List(); + Console.WriteLine("Grabbing {0}..{1} Regions with wGet ...", reg_min, reg_max); + for (int i = reg_min; i <= reg_max; i++) + { + string url = String.Format(reg_url, i); + Console.Write("Region {0} is ... ", i); + + HttpWGetRequest wGet = new HttpWGetRequest(url); + wGet.RemoteEncoding = Encoding.UTF8; + wGet.LocalEncoding = Encoding.UTF8; + string body = wGet.GetResponseBody(); + if (String.IsNullOrEmpty(body)) + { + Console.Write("NOTHING RETURNED"); + } + else + { + Response obj = null; + try + { + obj = JsonConvert.DeserializeObject(body); + regions.Add(new RegionInfo(i, obj.meta.geo)); + Console.Write(obj.meta.geo); + } + catch (Exception ex) + { + RespError err = null; + try + { + err = JsonConvert.DeserializeObject(body); + Console.Write(err.errors[0].title); + } + catch (Exception ex2) + { + Console.Write(ex2.Message); + }; + if (err == null) + Console.Write(ex.Message); + }; + }; + Console.WriteLine(); + System.Threading.Thread.Sleep(reg_sleep); + }; + if (regions.Count > 1) + regions.Sort(new RegionInfo.Comparer()); + } + + public Response.Data[] GrabRegion(int region) + { + string rName = "?"; + if (((regions != null) && (regions.Count > 0))) + foreach (RegionInfo r in regions) + if (r.id == region) + rName = r.name; + + Console.WriteLine("Grabbing {0} - {1} with wGet ... ", region, rName); + string url = String.Format(objs_url, objs_limit, region); + + HttpWGetRequest wGet = new HttpWGetRequest(url); + wGet.RemoteEncoding = Encoding.UTF8; + wGet.LocalEncoding = Encoding.UTF8; + string body = wGet.GetResponseBody(); + if (String.IsNullOrEmpty(body)) + { + Console.WriteLine("NOTHING RETURNED"); + } + else + { + Response obj = null; + try + { + obj = JsonConvert.DeserializeObject(body); + Console.WriteLine("{0} objects returned", obj.data.Length); + return obj.data; + } + catch (Exception ex) + { + RespError err = null; + try + { + err = JsonConvert.DeserializeObject(body); + Console.Write(err.errors[0].title); + } + catch (Exception ex2) + { + Console.Write(ex2.Message); + }; + if (err == null) + Console.Write(ex.Message); + }; + }; + Console.WriteLine(); + return null; + } + + private bool GrabName(long objId, out string objName, out string comment, out int cat, bool stdout) + { + objName = null; + comment = null; + cat = 0; + + if(stdout) + Console.Write("Name of {0} is ", objId); + string url = String.Format(name_url, objId); + + HttpWGetRequest wGet = new HttpWGetRequest(url); + wGet.UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36 - " + DateTime.Now.ToString("mmssfff"); + wGet.RemoteEncoding = Encoding.UTF8; + wGet.LocalEncoding = Encoding.UTF8; + string body = wGet.GetResponseBody(); + if (String.IsNullOrEmpty(body)) + { + if (stdout) + Console.Write("NOTHING RETURNED"); + return false; + } + else + { + int start_tag = body.IndexOf(""); + if (start_tag < 0) + { + if (stdout) + Console.Write("BAD RESULT"); + return false; + }; + start_tag += 7; + int end_tag = body.IndexOf(""); + if (end_tag < 0) + { + if (stdout) + Console.Write("BAD RESULT"); + return false; + }; + string tag_data = body.Substring(start_tag, end_tag - start_tag); + if (String.IsNullOrEmpty(tag_data)) + { + if (stdout) + Console.Write("BAD RESULT"); + return false; + }; + if (tag_data == "429 Too Many Requests") + { + if (stdout) + Console.Write(tag_data); + return false; + }; + objName = TrimAddress(objId, tag_data, out comment); + // get cat + { + string cn = objName.ToLower(); + + if (cn.IndexOf("") >= 0) cat = 6; + + if (cn.IndexOf("") >= 0) cat = 14; + if (cn.IndexOf("") >= 0) cat = 8; + if (cn.IndexOf("") >= 0) cat = 13; + + if (cn.IndexOf("") >= 0) cat = 12; + if (cn.IndexOf("") >= 0) cat = 10; + if (cn.IndexOf("") >= 0) cat = 1; + if (cn.IndexOf("") >= 0) cat = 11; + + if (cn.IndexOf("") >= 0) cat = 9; + if (cn.IndexOf("") >= 0) cat = 7; + if (cn.IndexOf("") >= 0) cat = 5; + + if (cn.IndexOf("") >= 0) cat = 4; + if (cn.IndexOf("") >= 0) cat = 3; + if (cn.IndexOf("") >= 0) cat = 2; + }; + comment += "\r\nCat: " + cat.ToString(); + comment += "\r\nUrl: " + url; + comment += "\r\nGrabbed: " + DateTime.Now.ToString("dd.MM.yyyy") + " by Tvil Grabber"; + if (stdout) + Console.Write(objName); + return true; + }; + } + + [XmlIgnore] + System.Threading.Mutex mtx = new System.Threading.Mutex(); + [XmlIgnore] + System.Threading.Thread[] thx = null; + public void GrabNames(ref Response.Data[] data) + { + if (data == null) return; + if (data.Length == 0) return; + + Console.WriteLine("Started at {0}", DateTime.Now.ToString("HH:mm:ss dd.MM.yyyy") ); + Console.WriteLine("Grabbing names of {0} objects in {1} threads with wGet ... ", data.Length, name_threads); + if (name_threads > 1) + GrabNamesThreaded(ref data); + else + GrabNamesSingled(ref data); + Console.WriteLine("Finished at {0}", DateTime.Now.ToString("HH:mm:ss dd.MM.yyyy")); + } + + private void GrabNamesSingled(ref Response.Data[] data) + { + thx = new System.Threading.Thread[name_threads]; + + for (int i = 0; i < data.Length; i++) + { + string name, comm; int cat; + bool ok = GrabName(data[i].i, out name, out comm, out cat, true); + if (ok) + { + data[i].name = name; + data[i].comm = comm; + data[i].cat = cat; + data[i].url = String.Format(this.name_url, data[i].i); + } + else + { + data[i].name = data[i].i.ToString(); + data[i].comm = data[i].url = String.Format(this.name_url, data[i].i); + }; + Console.WriteLine(" - {0}/{1}", i + 1, data.Length); + System.Threading.Thread.Sleep(name_sleep); + }; + Console.WriteLine("Grabbed done"); + } + + private void GrabNamesThreaded(ref Response.Data[] data) + { + thx = new System.Threading.Thread[name_threads]; + + ThreadData thrd = new ThreadData(); + thrd.data = data; + for (int i = 0; i < data.Length; i++) thrd.todo.Add(data[i].i); + + for (int i = 0; i < thx.Length; i++) + { + thx[i] = new System.Threading.Thread(GrabNameThread); + thx[i].Start(thrd); + }; + + bool cont = true; + int prcd = 0; + int prct = data.Length; + Console.Write("Already grabbed {0}/{1} ... ", prcd, prct); + while (cont) + { + mtx.WaitOne(); + { + cont = thrd.threadsFinished < thx.Length; + prcd = thrd.objectsFinished; + }; + mtx.ReleaseMutex(); + Console.SetCursorPosition(0, Console.CursorTop); + Console.Write("Already grabbed {0}/{1} ... ", prcd, prct); + System.Threading.Thread.Sleep(1000); + }; + cont = thrd.threadsFinished < thx.Length; + prcd = thrd.objectsFinished; + Console.SetCursorPosition(0, Console.CursorTop); + Console.WriteLine("Grabbed {0}/{1} names already done", prcd, prct); + } + + private void GrabNameThread(object thrxo) + { + while(true) + { + long id = -1; + mtx.WaitOne(); + { + ThreadData thrd = (ThreadData)thrxo; + if (thrd.todo.Count > 0) { id = thrd.todo[0]; thrd.todo.RemoveAt(0); }; + }; + mtx.ReleaseMutex(); + if (id == -1) + { + mtx.WaitOne(); + { + ThreadData thrd = (ThreadData)thrxo; + thrd.threadsFinished++; + }; + mtx.ReleaseMutex(); + break; + } + else + { + string name, comm; int cat; + bool ok = GrabName(id, out name, out comm, out cat, false); + mtx.WaitOne(); + { + ThreadData thrd = (ThreadData)thrxo; + for (int i = 0; i < thrd.data.Length; i++) + if (thrd.data[i].i == id) + { + if (ok) + { + thrd.data[i].name = name; + thrd.data[i].comm = comm; + thrd.data[i].cat = cat; + thrd.data[i].url = String.Format(this.name_url, thrd.data[i].i); + } + else + { + thrd.data[i].name = thrd.data[i].i.ToString(); + thrd.data[i].comm = thrd.data[i].url = String.Format(this.name_url, thrd.data[i].i); + }; + break; + }; + thrd.objectsFinished++; + }; + mtx.ReleaseMutex(); + System.Threading.Thread.Sleep(name_sleep); + }; + }; + } + + public static TvilGrabber Load() + { + try + { + return XMLSaved.Load(); + } + catch + { + return new TvilGrabber(); + }; + } + + private void Save() + { + XMLSaved.Save(this); + } + + private string TrimAddress(long id, string line, out string comment) + { + string ln = line; + comment = ln; + if(!String.IsNullOrEmpty(ln)) + { + ln = ln.Replace(" Tvil.ru, ", ""); + ln = ln.Replace(" Tvil.ru, ", ""); + ln = ln.Replace(" Tvil.ru", ""); + + ln = ln.Replace(""","\""); + ln = ln.Replace("'","\""); + int qsi = ln.IndexOf("\""); + if (qsi > -1) + { + int qse = ln.IndexOf("\"",qsi + 1); + if (qse > qsi) + { + string tmp = ln.Substring(qsi,qse-qsi + 1); + ln = tmp.Trim() + " " + (ln.Replace(tmp,"")).Trim(); + }; + }; + try + { + int s_i = ln.IndexOf(","); + int s_e = ln.LastIndexOf("-") + 1; + if (s_i > 0) + { + string tmp = ln.Substring(0,s_i).Trim()+" ["+(ln.Substring(s_e)).Trim()+"]"; + comment = tmp + "\r\nID: " + id.ToString() + "\r\nAddress: " + (ln.Substring(s_i + 1, s_e - 2 - s_i + 1)).Trim().Trim('-').Trim(); + comment = comment.Replace(" ", "\r\nNote: "); + ln = tmp; + }; + } + catch (Exception ex) + { + + }; + }; + return ln; + } + + private class ThreadData + { + public List todo = new List(); + public Response.Data[] data = null; + public int threadsFinished = 0; + public int objectsFinished = 0; + } + } + + public class RegionInfo + { + [XmlAttribute] + public int id; + [XmlText] + public string name; + public RegionInfo() { } + public RegionInfo(int id, string name) { this.id = id; this.name = name; } + + public class Comparer : IComparer + { + public int Compare(RegionInfo a, RegionInfo b) + { + return a.name.CompareTo(b.name); + } + } + } + + public class Response + { + public class Meta + { + public string geo; + } + + public class Data + { + public long i; + public int p; + public int v; + public double lt; + public double lg; + public int ne; + public int r; + + /* non-json */ + public string name; + public string comm; + public string url; + public int cat; + + public static string SaveKML(Data[] data, string layerName) + { + if ((data == null) || (data.Length == 0)) return ""; + string fileName = System.AppDomain.CurrentDomain.BaseDirectory + @"\TvilGrabber.kml"; + FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write); + StreamWriter sb = new StreamWriter(fs, Encoding.UTF8); + + sb.WriteLine(""); + sb.WriteLine(""); + sb.WriteLine(""); + sb.WriteLine("TvilGrabber"); + sb.WriteLine("TvilGrabber"); + sb.WriteLine(String.Format("", layerName, data.Length)); + foreach (Data d in data) + { + sb.WriteLine(""); + sb.WriteLine(String.Format("#cat{0}", d.cat)); + sb.WriteLine(String.Format("", d.name)); + sb.WriteLine(String.Format("", d.comm)); + sb.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, "{1},{0},0", d.lt, d.lg)); + sb.WriteLine(""); + }; + sb.WriteLine(""); + for (int k = 0; k <= 14; k++) + sb.WriteLine(String.Format("", k)); + sb.WriteLine(""); + sb.WriteLine(""); + sb.Close(); + return fileName; + } + + public static string SaveKMZ(string file) + { + string fileName = System.AppDomain.CurrentDomain.BaseDirectory + @"\TvilGrabber.kmz"; + FileStream fsOut = File.Create(fileName); + ZipOutputStream zipStream = new ZipOutputStream(fsOut); + zipStream.SetComment("Created by TvilGrabber"); + zipStream.SetLevel(3); + // doc.kml + { + FileInfo fi = new FileInfo(file); + ZipEntry newEntry = new ZipEntry("doc.kml"); + newEntry.DateTime = fi.LastWriteTime; // Note the zip format stores 2 second granularity + newEntry.Size = fi.Length; + zipStream.PutNextEntry(newEntry); + + byte[] buffer = new byte[4096]; + using (FileStream streamReader = File.OpenRead(fi.FullName)) + StreamUtils.Copy(streamReader, zipStream, buffer); + zipStream.CloseEntry(); + }; + // images + { + string[] files = Directory.GetFiles(System.AppDomain.CurrentDomain.BaseDirectory + @"\images"); + foreach (string filename in files) + { + + FileInfo fi = new FileInfo(filename); + + ZipEntry newEntry = new ZipEntry(@"images\" + fi.Name); + newEntry.DateTime = fi.LastWriteTime; // Note the zip format stores 2 second granularity + newEntry.Size = fi.Length; + zipStream.PutNextEntry(newEntry); + + byte[] buffer = new byte[4096]; + using (FileStream streamReader = File.OpenRead(filename)) + StreamUtils.Copy(streamReader, zipStream, buffer); + zipStream.CloseEntry(); + } + }; + zipStream.IsStreamOwner = true; // Makes the Close also Close the underlying stream + zipStream.Close(); + return fileName; + } + } + + public Data[] data; + public Meta meta; + } + + public class RespError + { + public class Error + { + public int status; + public string title; + } + + public Error[] errors; + } + +} +namespace System.Xml +{ + [Serializable] + public class XMLSaved + { + /// + /// + /// + /// + /// + public static void Save(T obj) + { + string fname = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase.ToString(); + fname = fname.Replace("file:///", ""); + fname = fname.Replace("/", @"\"); + fname = fname.Substring(0, fname.LastIndexOf(@"\") + 1); + fname += @"configuration.xml"; + + System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(T)); + System.IO.StreamWriter writer = System.IO.File.CreateText(fname); + xs.Serialize(writer, obj); + writer.Flush(); + writer.Close(); + } + + /// + /// + /// + /// + /// + public static T Load() + { + string fname = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase.ToString(); + fname = fname.Replace("file:///", ""); + fname = fname.Replace("/", @"\"); + fname = fname.Substring(0, fname.LastIndexOf(@"\") + 1); + fname += @"configuration.xml"; + + // if couldn't create file in temp - add credintals + // http://support.microsoft.com/kb/908158/ru + System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(T)); + System.IO.StreamReader reader = System.IO.File.OpenText(fname); + T c = (T)xs.Deserialize(reader); + reader.Close(); + return c; + } + } +} diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..8b6a404 --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("TvilGrabber")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("TvilGrabber")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("2fdab367-f374-48b3-90e7-4f2dbf107199")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.2")] +[assembly: AssemblyFileVersion("1.0.0.2")] diff --git a/TvilGrabber.csproj b/TvilGrabber.csproj new file mode 100644 index 0000000..01a809b --- /dev/null +++ b/TvilGrabber.csproj @@ -0,0 +1,59 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {46AB5D4B-979B-422B-9116-44CEB2062323} + Exe + Properties + TvilGrabber + TvilGrabber + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + true + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + true + + + + + + + + + + + + + + + Form + + + + + + + + \ No newline at end of file diff --git a/TvilGrabber.sln b/TvilGrabber.sln new file mode 100644 index 0000000..05be19f --- /dev/null +++ b/TvilGrabber.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TvilGrabber", "TvilGrabber.csproj", "{46AB5D4B-979B-422B-9116-44CEB2062323}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {46AB5D4B-979B-422B-9116-44CEB2062323}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {46AB5D4B-979B-422B-9116-44CEB2062323}.Debug|Any CPU.Build.0 = Debug|Any CPU + {46AB5D4B-979B-422B-9116-44CEB2062323}.Release|Any CPU.ActiveCfg = Release|Any CPU + {46AB5D4B-979B-422B-9116-44CEB2062323}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/bin/Debug/ICSharpCode.SharpZipLib.dll b/bin/Debug/ICSharpCode.SharpZipLib.dll new file mode 100644 index 0000000..1500f17 Binary files /dev/null and b/bin/Debug/ICSharpCode.SharpZipLib.dll differ diff --git a/bin/Debug/Newtonsoft.Json.dll b/bin/Debug/Newtonsoft.Json.dll new file mode 100644 index 0000000..adabab6 Binary files /dev/null and b/bin/Debug/Newtonsoft.Json.dll differ diff --git a/bin/Debug/TvilGrabber.exe b/bin/Debug/TvilGrabber.exe new file mode 100644 index 0000000..ed3496a Binary files /dev/null and b/bin/Debug/TvilGrabber.exe differ diff --git a/bin/Debug/TvilGrabber.kml b/bin/Debug/TvilGrabber.kml new file mode 100644 index 0000000..27ce5e4 --- /dev/null +++ b/bin/Debug/TvilGrabber.kml @@ -0,0 +1,152 @@ + + + +TvilGrabber +TvilGrabber + + +#cat9 + + +40.204483,44.244183,0 + + +#cat5 + + +40.205992,44.235385,0 + + +#cat5 + + +40.207721,44.231449,0 + + +#cat2 + + +40.103999,44.605516,0 + + +#cat12 + + +38.943801,45.02075,0 + + +#cat13 + + +40.134177,43.995542,0 + + +#cat10 + + +38.922583,45.016971,0 + + +#cat1 + + +38.942929,45.020514,0 + + +#cat1 + + +38.921364,45.019318,0 + + +#cat12 + + +38.935312,45.019316,0 + + +#cat1 + + +38.941699,44.997885,0 + + + + + + + + + + + + + + + + + + + diff --git a/bin/Debug/TvilGrabber.kmz b/bin/Debug/TvilGrabber.kmz new file mode 100644 index 0000000..068f9c8 Binary files /dev/null and b/bin/Debug/TvilGrabber.kmz differ diff --git a/bin/Debug/configuration.xml b/bin/Debug/configuration.xml new file mode 100644 index 0000000..526871c --- /dev/null +++ b/bin/Debug/configuration.xml @@ -0,0 +1,91 @@ + + + https://api.tvil.ru/mapEntities?page[limit]=1&filter[geo]={0}&format[minify]=1 + 2 + 400 + 20 + https://api.tvil.ru/mapEntities?page[limit]={0}&filter[geo]={1}&format[minify]=1 + 15000 + https://tvil.ru/city/all/hotels/{0}/ + 1 + 2000 + + Абхазия + Адыгея + Алтай + Алтайский край + Амурская область + Армения + Архангельская область + Астраханская область + Башкирия (Башкортостан) + Беларусь + Белгородская область + Болгария + Брянская область + Бурятия + Витебская область + Владимирская область + Волгоградская область + Вологодская область + Воронежская область + Гродненская область + Грузия + Ивановская область + Иркутская область + Кабардино-Балкария + Казахстан + Калининградская область + Калужская область + Карачаево-Черкесия + Карелия + Кемеровская область + Кировская область + Коми + Костромская область + Краснодарский край + Красноярский край + Крым + Курская область + Ленинградская область + Липецкая область + Марий Эл + Минская область + Могилевская область + Московская область + Мурманская область + Нижегородская область + Новгородская область + Новосибирская область + Одесская область + Омская область + Оренбургская область + Орловская область + Пензенская область + Пермский край + Приморский край + Псковская область + Ростовская область + Рязанская область + Самарская область + Саратовская область + Саха (Якутия) + Свердловская область + Северная Осетия + Ставропольский край + Тамбовская область + Татарстан + Тверская область + Томская область + Тульская область + Тюменская область + Украина + Ульяновская область + Хабаровский край + Ханты-Мансийский АО + Челябинская область + Черногория + Чувашия + Ярославская область + + \ No newline at end of file diff --git a/bin/Debug/images/cat0.png b/bin/Debug/images/cat0.png new file mode 100644 index 0000000..a3d539f Binary files /dev/null and b/bin/Debug/images/cat0.png differ diff --git a/bin/Debug/images/cat1.png b/bin/Debug/images/cat1.png new file mode 100644 index 0000000..f2d5f3b Binary files /dev/null and b/bin/Debug/images/cat1.png differ diff --git a/bin/Debug/images/cat10.png b/bin/Debug/images/cat10.png new file mode 100644 index 0000000..50b85fa Binary files /dev/null and b/bin/Debug/images/cat10.png differ diff --git a/bin/Debug/images/cat11.png b/bin/Debug/images/cat11.png new file mode 100644 index 0000000..b1f0c15 Binary files /dev/null and b/bin/Debug/images/cat11.png differ diff --git a/bin/Debug/images/cat12.png b/bin/Debug/images/cat12.png new file mode 100644 index 0000000..50b85fa Binary files /dev/null and b/bin/Debug/images/cat12.png differ diff --git a/bin/Debug/images/cat13.png b/bin/Debug/images/cat13.png new file mode 100644 index 0000000..3af1915 Binary files /dev/null and b/bin/Debug/images/cat13.png differ diff --git a/bin/Debug/images/cat14.png b/bin/Debug/images/cat14.png new file mode 100644 index 0000000..f5581a0 Binary files /dev/null and b/bin/Debug/images/cat14.png differ diff --git a/bin/Debug/images/cat2.png b/bin/Debug/images/cat2.png new file mode 100644 index 0000000..8d2bd72 Binary files /dev/null and b/bin/Debug/images/cat2.png differ diff --git a/bin/Debug/images/cat3.png b/bin/Debug/images/cat3.png new file mode 100644 index 0000000..93504fb Binary files /dev/null and b/bin/Debug/images/cat3.png differ diff --git a/bin/Debug/images/cat4.png b/bin/Debug/images/cat4.png new file mode 100644 index 0000000..13f420d Binary files /dev/null and b/bin/Debug/images/cat4.png differ diff --git a/bin/Debug/images/cat5.png b/bin/Debug/images/cat5.png new file mode 100644 index 0000000..dee18eb Binary files /dev/null and b/bin/Debug/images/cat5.png differ diff --git a/bin/Debug/images/cat6.png b/bin/Debug/images/cat6.png new file mode 100644 index 0000000..0a641de Binary files /dev/null and b/bin/Debug/images/cat6.png differ diff --git a/bin/Debug/images/cat7.png b/bin/Debug/images/cat7.png new file mode 100644 index 0000000..27905e9 Binary files /dev/null and b/bin/Debug/images/cat7.png differ diff --git a/bin/Debug/images/cat8.png b/bin/Debug/images/cat8.png new file mode 100644 index 0000000..5056c15 Binary files /dev/null and b/bin/Debug/images/cat8.png differ diff --git a/bin/Debug/images/cat9.png b/bin/Debug/images/cat9.png new file mode 100644 index 0000000..6456953 Binary files /dev/null and b/bin/Debug/images/cat9.png differ diff --git a/bin/Debug/name.txt b/bin/Debug/name.txt new file mode 100644 index 0000000..a20f1b0 --- /dev/null +++ b/bin/Debug/name.txt @@ -0,0 +1 @@ +Импорт объектов Tvil.ru \ No newline at end of file diff --git a/bin/Debug/readme.txt b/bin/Debug/readme.txt new file mode 100644 index 0000000..e102709 --- /dev/null +++ b/bin/Debug/readme.txt @@ -0,0 +1,3 @@ +All is very simple +Plugin Must return fileName in last STDOUT line (or in single line) +if last STDOUT line (or single) is empty - file is not exists \ No newline at end of file diff --git a/bin/Debug/wget.exe b/bin/Debug/wget.exe new file mode 100644 index 0000000..108a316 Binary files /dev/null and b/bin/Debug/wget.exe differ diff --git a/bin/Debug/zlib.dll b/bin/Debug/zlib.dll new file mode 100644 index 0000000..9ea38d5 Binary files /dev/null and b/bin/Debug/zlib.dll differ diff --git a/obj/Debug/ResolveAssemblyReference.cache b/obj/Debug/ResolveAssemblyReference.cache new file mode 100644 index 0000000..2b703c0 Binary files /dev/null and b/obj/Debug/ResolveAssemblyReference.cache differ diff --git a/obj/Debug/TvilGrabber.exe b/obj/Debug/TvilGrabber.exe new file mode 100644 index 0000000..ed3496a Binary files /dev/null and b/obj/Debug/TvilGrabber.exe differ diff --git a/obj/Debug/TvilGrabber.pdb b/obj/Debug/TvilGrabber.pdb new file mode 100644 index 0000000..a6df04e Binary files /dev/null and b/obj/Debug/TvilGrabber.pdb differ diff --git a/obj/Debug/avtodor_tr_m4.exe b/obj/Debug/avtodor_tr_m4.exe new file mode 100644 index 0000000..95bb043 Binary files /dev/null and b/obj/Debug/avtodor_tr_m4.exe differ diff --git a/obj/Debug/avtodor_tr_m4.pdb b/obj/Debug/avtodor_tr_m4.pdb new file mode 100644 index 0000000..f255b23 Binary files /dev/null and b/obj/Debug/avtodor_tr_m4.pdb differ diff --git a/obj/Release/avtodor_tr_m4.exe b/obj/Release/avtodor_tr_m4.exe new file mode 100644 index 0000000..c05eceb Binary files /dev/null and b/obj/Release/avtodor_tr_m4.exe differ diff --git a/obj/Release/avtodor_tr_m4.pdb b/obj/Release/avtodor_tr_m4.pdb new file mode 100644 index 0000000..a11d5e6 Binary files /dev/null and b/obj/Release/avtodor_tr_m4.pdb differ diff --git a/obj/TvilGrabber.csproj.FileListAbsolute.txt b/obj/TvilGrabber.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..718397d --- /dev/null +++ b/obj/TvilGrabber.csproj.FileListAbsolute.txt @@ -0,0 +1,5 @@ +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20220113H\PLUGIN_TvilGrabber_[Sources]_20220113H\bin\Debug\TvilGrabber.exe +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20220113H\PLUGIN_TvilGrabber_[Sources]_20220113H\bin\Debug\TvilGrabber.pdb +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20220113H\PLUGIN_TvilGrabber_[Sources]_20220113H\obj\Debug\ResolveAssemblyReference.cache +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20220113H\PLUGIN_TvilGrabber_[Sources]_20220113H\obj\Debug\TvilGrabber.exe +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20220113H\PLUGIN_TvilGrabber_[Sources]_20220113H\obj\Debug\TvilGrabber.pdb diff --git a/obj/avtodor_tr_m4.csproj.FileListAbsolute.txt b/obj/avtodor_tr_m4.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..98824d8 --- /dev/null +++ b/obj/avtodor_tr_m4.csproj.FileListAbsolute.txt @@ -0,0 +1,39 @@ +C:\Downloads\CD-REC\TEST\avtodor_tr_m4\avtodor_tr_m4\obj\Debug\ResolveAssemblyReference.cache +C:\Downloads\CD-REC\TEST\avtodor_tr_m4\avtodor_tr_m4\bin\Debug\avtodor_tr_m4.exe +C:\Downloads\CD-REC\TEST\avtodor_tr_m4\avtodor_tr_m4\bin\Debug\avtodor_tr_m4.pdb +C:\Downloads\CD-REC\TEST\avtodor_tr_m4\avtodor_tr_m4\obj\Debug\avtodor_tr_m4.exe +C:\Downloads\CD-REC\TEST\avtodor_tr_m4\avtodor_tr_m4\obj\Debug\avtodor_tr_m4.pdb +D:\PROJECTS\Планирование\2020 М4+A-147\GrabData\Avtodor-TR\AVTODOR_TR_[Sources]\obj\Debug\avtodor_tr_m4.exe +D:\PROJECTS\Планирование\2020 М4+A-147\GrabData\Avtodor-TR\AVTODOR_TR_[Sources]\obj\Debug\avtodor_tr_m4.pdb +D:\PROJECTS\Планирование\2020 М4+A-147\GrabData\Avtodor-TR\AVTODOR_TR_[Sources]\bin\Debug\avtodor_tr_m4.exe +D:\PROJECTS\Планирование\2020 М4+A-147\GrabData\Avtodor-TR\AVTODOR_TR_[Sources]\bin\Debug\avtodor_tr_m4.pdb +D:\PROJECTS\Планирование\2020 М4+A-147\GrabData\Avtodor-TR\AVTODOR_TR_[Sources]\obj\Debug\ResolveAssemblyReference.cache +D:\PROJECTS\Планирование\2020 М4+A-147\GrabData\Avtodor-TR\AVTODOR_TR_[Sources]\bin\Release\avtodor_tr_m4.exe +D:\PROJECTS\Планирование\2020 М4+A-147\GrabData\Avtodor-TR\AVTODOR_TR_[Sources]\bin\Release\avtodor_tr_m4.pdb +D:\PROJECTS\Планирование\2020 М4+A-147\GrabData\Avtodor-TR\AVTODOR_TR_[Sources]\obj\Release\ResolveAssemblyReference.cache +D:\PROJECTS\Планирование\2020 М4+A-147\GrabData\Avtodor-TR\AVTODOR_TR_[Sources]\obj\Release\avtodor_tr_m4.exe +D:\PROJECTS\Планирование\2020 М4+A-147\GrabData\Avtodor-TR\AVTODOR_TR_[Sources]\obj\Release\avtodor_tr_m4.pdb +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20200806H\PLUGIN_Avtodor_TR_M4_[Sources]_20200806H\obj\Debug\avtodor_tr_m4.exe +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20200806H\PLUGIN_Avtodor_TR_M4_[Sources]_20200806H\obj\Debug\avtodor_tr_m4.pdb +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20200806H\PLUGIN_Avtodor_TR_M4_[Sources]_20200806H\bin\Debug\avtodor_tr_m4.exe +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20200806H\PLUGIN_Avtodor_TR_M4_[Sources]_20200806H\bin\Debug\avtodor_tr_m4.pdb +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20200806H\PLUGIN_Avtodor_TR_M4_[Sources]_20200806H\obj\Debug\ResolveAssemblyReference.cache +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20200806H\PLUGIN_Avtodor_TR_M4_[Sources]_20210408H\obj\Debug\avtodor_tr_m4.exe +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20200806H\PLUGIN_Avtodor_TR_M4_[Sources]_20210408H\obj\Debug\avtodor_tr_m4.pdb +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20200806H\PLUGIN_Avtodor_TR_M4_[Sources]_20210408H\obj\Debug\ResolveAssemblyReference.cache +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20200806H\PLUGIN_Avtodor_TR_M4_[Sources]_20210408H\bin\Debug\avtodor_tr_m4.exe +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20200806H\PLUGIN_Avtodor_TR_M4_[Sources]_20210408H\bin\Debug\avtodor_tr_m4.pdb +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20200806H\PLUGIN_Avtodor_TR_M4_[Sources]_20210421H\obj\Debug\avtodor_tr_m4.exe +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20200806H\PLUGIN_Avtodor_TR_M4_[Sources]_20210421H\obj\Debug\avtodor_tr_m4.pdb +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20200806H\PLUGIN_Avtodor_TR_M4_[Sources]_20210421H\bin\Debug\avtodor_tr_m4.exe +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20200806H\PLUGIN_Avtodor_TR_M4_[Sources]_20210421H\bin\Debug\avtodor_tr_m4.pdb +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20200806H\PLUGIN_Avtodor_TR_M4_[Sources]_20210421H\obj\Debug\ResolveAssemblyReference.cache +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20200806H\PLUGIN_Avtodor_TR_M4_[Sources]_20210426H\obj\Debug\avtodor_tr_m4.exe +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20200806H\PLUGIN_Avtodor_TR_M4_[Sources]_20210426H\obj\Debug\avtodor_tr_m4.pdb +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20220110H\PLUGIN_Avtodor_TR_M4_[Sources]_20210426H\obj\Debug\avtodor_tr_m4.exe +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20220110H\PLUGIN_Avtodor_TR_M4_[Sources]_20210426H\obj\Debug\avtodor_tr_m4.pdb +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20220110H\PLUGIN_Avtodor_TR_M4_[Sources]_20210426H\bin\Debug\avtodor_tr_m4.exe +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20220110H\PLUGIN_Avtodor_TR_M4_[Sources]_20210426H\bin\Debug\avtodor_tr_m4.pdb +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20220110H\PLUGIN_Avtodor_TR_M4_[Sources]_20210426H\obj\Debug\ResolveAssemblyReference.cache +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20220113H\PLUGIN_TvilGrabber_[Sources]_20220113H\obj\Debug\avtodor_tr_m4.exe +D:\PROJECTS\Планирование\20XX Template\Soft (Win+Android)\MY KMZ KML TOOLS\KMZRebuilder+Viewer\_SOURCES\KMZTools_[Sources]_20220113H\PLUGIN_TvilGrabber_[Sources]_20220113H\obj\Debug\avtodor_tr_m4.pdb diff --git a/wGet.cs b/wGet.cs new file mode 100644 index 0000000..0f4ac4d Binary files /dev/null and b/wGet.cs differ