- Timestamp:
- Feb 14, 2019, 5:29:40 PM (6 years ago)
- Location:
- Common
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
Common/Database.cs
r1 r2 94 94 } 95 95 96 p rivatestatic DbConnection GetConnection()96 public static DbConnection GetConnection() 97 97 { 98 98 DbConnection connection = GetFactory().CreateConnection(); … … 529 529 public void ExecuteQueries() 530 530 { 531 #if SSS531 #if NO_TRANSACTION 532 532 foreach (Query item in queries) 533 533 { 534 534 Database.ExecuteNonQuery(item.query, item.parameters); 535 535 } 536 #e ndif536 #else 537 537 lock (threadQueries) 538 538 { … … 540 540 Monitor.Pulse(threadQueries); 541 541 } 542 #endif 542 543 queries.Clear(); 543 544 } -
Common/FormFind.Designer.cs
r1 r2 31 31 this.buttonFindNext = new System.Windows.Forms.Button(); 32 32 this.buttonCancel = new System.Windows.Forms.Button(); 33 this.textBoxWhat = new System.Windows.Forms.TextBox();34 33 this.label1 = new System.Windows.Forms.Label(); 35 34 this.checkBoxMatchWholeWordOnly = new System.Windows.Forms.CheckBox(); 36 35 this.checkBoxMatchCase = new System.Windows.Forms.CheckBox(); 37 36 this.buttonFindPrevious = new System.Windows.Forms.Button(); 37 this.comboBoxWhat = new System.Windows.Forms.ComboBox(); 38 38 this.SuspendLayout(); 39 39 // … … 41 41 // 42 42 this.buttonFindNext.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 43 this.buttonFindNext.Location = new System.Drawing.Point(304, 12); 43 this.buttonFindNext.Location = new System.Drawing.Point(405, 15); 44 this.buttonFindNext.Margin = new System.Windows.Forms.Padding(4); 44 45 this.buttonFindNext.Name = "buttonFindNext"; 45 this.buttonFindNext.Size = new System.Drawing.Size( 88, 23);46 this.buttonFindNext.Size = new System.Drawing.Size(117, 28); 46 47 this.buttonFindNext.TabIndex = 4; 47 48 this.buttonFindNext.Text = "Find next"; … … 53 54 this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 54 55 this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; 55 this.buttonCancel.Location = new System.Drawing.Point(304, 70); 56 this.buttonCancel.Location = new System.Drawing.Point(405, 86); 57 this.buttonCancel.Margin = new System.Windows.Forms.Padding(4); 56 58 this.buttonCancel.Name = "buttonCancel"; 57 this.buttonCancel.Size = new System.Drawing.Size( 87, 23);59 this.buttonCancel.Size = new System.Drawing.Size(116, 28); 58 60 this.buttonCancel.TabIndex = 6; 59 61 this.buttonCancel.Text = "Cancel"; … … 61 63 this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); 62 64 // 63 // textBoxWhat64 //65 this.textBoxWhat.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)66 | System.Windows.Forms.AnchorStyles.Right)));67 this.textBoxWhat.Location = new System.Drawing.Point(74, 14);68 this.textBoxWhat.Name = "textBoxWhat";69 this.textBoxWhat.Size = new System.Drawing.Size(224, 20);70 this.textBoxWhat.TabIndex = 1;71 this.textBoxWhat.TextChanged += new System.EventHandler(this.textBoxWhat_TextChanged);72 this.textBoxWhat.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBoxWhat_KeyPress);73 //74 65 // label1 75 66 // 76 67 this.label1.AutoSize = true; 77 this.label1.Location = new System.Drawing.Point(12, 17); 68 this.label1.Location = new System.Drawing.Point(16, 21); 69 this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); 78 70 this.label1.Name = "label1"; 79 this.label1.Size = new System.Drawing.Size( 56, 13);71 this.label1.Size = new System.Drawing.Size(72, 17); 80 72 this.label1.TabIndex = 0; 81 73 this.label1.Text = "Find what:"; … … 84 76 // 85 77 this.checkBoxMatchWholeWordOnly.AutoSize = true; 86 this.checkBoxMatchWholeWordOnly.Location = new System.Drawing.Point(15, 47); 78 this.checkBoxMatchWholeWordOnly.Location = new System.Drawing.Point(20, 58); 79 this.checkBoxMatchWholeWordOnly.Margin = new System.Windows.Forms.Padding(4); 87 80 this.checkBoxMatchWholeWordOnly.Name = "checkBoxMatchWholeWordOnly"; 88 this.checkBoxMatchWholeWordOnly.Size = new System.Drawing.Size(1 35, 17);81 this.checkBoxMatchWholeWordOnly.Size = new System.Drawing.Size(172, 21); 89 82 this.checkBoxMatchWholeWordOnly.TabIndex = 2; 90 83 this.checkBoxMatchWholeWordOnly.Text = "Match whole word only"; … … 94 87 // 95 88 this.checkBoxMatchCase.AutoSize = true; 96 this.checkBoxMatchCase.Location = new System.Drawing.Point(15, 70); 89 this.checkBoxMatchCase.Location = new System.Drawing.Point(20, 86); 90 this.checkBoxMatchCase.Margin = new System.Windows.Forms.Padding(4); 97 91 this.checkBoxMatchCase.Name = "checkBoxMatchCase"; 98 this.checkBoxMatchCase.Size = new System.Drawing.Size( 82, 17);92 this.checkBoxMatchCase.Size = new System.Drawing.Size(102, 21); 99 93 this.checkBoxMatchCase.TabIndex = 3; 100 94 this.checkBoxMatchCase.Text = "Match case"; … … 104 98 // 105 99 this.buttonFindPrevious.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 106 this.buttonFindPrevious.Location = new System.Drawing.Point(304, 41); 100 this.buttonFindPrevious.Location = new System.Drawing.Point(405, 50); 101 this.buttonFindPrevious.Margin = new System.Windows.Forms.Padding(4); 107 102 this.buttonFindPrevious.Name = "buttonFindPrevious"; 108 this.buttonFindPrevious.Size = new System.Drawing.Size( 87, 23);103 this.buttonFindPrevious.Size = new System.Drawing.Size(116, 28); 109 104 this.buttonFindPrevious.TabIndex = 5; 110 105 this.buttonFindPrevious.Text = "Find previous"; … … 112 107 this.buttonFindPrevious.Click += new System.EventHandler(this.buttonFindPrevious_Click); 113 108 // 109 // comboBoxWhat 110 // 111 this.comboBoxWhat.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 112 | System.Windows.Forms.AnchorStyles.Right))); 113 this.comboBoxWhat.FormattingEnabled = true; 114 this.comboBoxWhat.Location = new System.Drawing.Point(95, 18); 115 this.comboBoxWhat.Name = "comboBoxWhat"; 116 this.comboBoxWhat.Size = new System.Drawing.Size(297, 24); 117 this.comboBoxWhat.TabIndex = 7; 118 this.comboBoxWhat.TextChanged += new System.EventHandler(this.textBoxWhat_TextChanged); 119 this.comboBoxWhat.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBoxWhat_KeyPress); 120 // 114 121 // FormFind 115 122 // 116 this.AutoScaleDimensions = new System.Drawing.SizeF( 6F, 13F);123 this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); 117 124 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 118 this.ClientSize = new System.Drawing.Size(403, 102); 125 this.ClientSize = new System.Drawing.Size(537, 126); 126 this.Controls.Add(this.comboBoxWhat); 119 127 this.Controls.Add(this.buttonFindPrevious); 120 128 this.Controls.Add(this.checkBoxMatchCase); 121 129 this.Controls.Add(this.checkBoxMatchWholeWordOnly); 122 130 this.Controls.Add(this.label1); 123 this.Controls.Add(this.textBoxWhat);124 131 this.Controls.Add(this.buttonCancel); 125 132 this.Controls.Add(this.buttonFindNext); 133 this.Margin = new System.Windows.Forms.Padding(4); 126 134 this.MaximizeBox = false; 127 135 this.MinimizeBox = false; 128 this.MinimumSize = new System.Drawing.Size(3 00, 140);136 this.MinimumSize = new System.Drawing.Size(394, 162); 129 137 this.Name = "FormFind"; 130 138 this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; … … 142 150 private System.Windows.Forms.Button buttonFindNext; 143 151 private System.Windows.Forms.Button buttonCancel; 144 private System.Windows.Forms.TextBox textBoxWhat;145 152 private System.Windows.Forms.Label label1; 146 153 private System.Windows.Forms.CheckBox checkBoxMatchWholeWordOnly; 147 154 private System.Windows.Forms.CheckBox checkBoxMatchCase; 148 155 private System.Windows.Forms.Button buttonFindPrevious; 156 private System.Windows.Forms.ComboBox comboBoxWhat; 149 157 } 150 158 } -
Common/FormFind.cs
r1 r2 8 8 using System.Threading.Tasks; 9 9 using System.Windows.Forms; 10 using Microsoft.Win32; 10 11 11 12 namespace Common … … 14 15 { 15 16 public RichTextBoxEx richTextBox; 16 FormDimensions formDimensions; 17 public string regSubKey; 18 public int maxHistoryCount; 17 19 18 20 public FormFind() 19 21 { 20 22 InitializeComponent(); 21 formDimensions = new FormDimensions(); 23 regSubKey = "Find"; 24 maxHistoryCount = 20; 22 25 } 23 26 … … 57 60 private void SearchText(bool reverse = false) 58 61 { 62 if (comboBoxWhat.Text.Trim() != "") 63 { 64 string previousText = comboBoxWhat.Text; 65 int index = comboBoxWhat.Items.IndexOf(comboBoxWhat.Text); 66 if (index >= 0) comboBoxWhat.Items.RemoveAt(index); 67 comboBoxWhat.Text = previousText; 68 comboBoxWhat.Items.Insert(0, comboBoxWhat.Text); 69 70 while (comboBoxWhat.Items.Count > maxHistoryCount) 71 comboBoxWhat.Items.RemoveAt(comboBoxWhat.Items.Count - 1); 72 } 73 59 74 while (true) 60 75 { 61 int newPos = FindText( textBoxWhat.Text.Trim(), richTextBox.SelectionStart, richTextBox.SelectionLength, reverse);76 int newPos = FindText(comboBoxWhat.Text.Trim(), richTextBox.SelectionStart, richTextBox.SelectionLength, reverse); 62 77 if (newPos >= 0) 63 78 { 64 79 richTextBox.SelectionColor = Color.Red; 65 richTextBox.Select(newPos, textBoxWhat.Text.Length);80 richTextBox.Select(newPos, comboBoxWhat.Text.Length); 66 81 richTextBox.ScrollToCaret(); 67 82 } … … 94 109 DpiScaling.Apply(this); 95 110 this.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath); 96 formDimensions.Load(this, Owner); 97 textBoxWhat.Focus(); 111 new FormDimensions().Load(this, Owner); 112 comboBoxWhat.Focus(); 113 LoadFromRegistry(); 98 114 UpdateInterface(); 99 115 } … … 106 122 private void FormFind_FormClosing(object sender, FormClosingEventArgs e) 107 123 { 124 SaveToRegistry(); 108 125 richTextBox.formFind = null; 109 formDimensions.Save(this, Owner);126 new FormDimensions().Save(this, Owner); 110 127 } 111 128 … … 115 132 { 116 133 buttonFindNext.PerformClick(); 134 } else 135 if (e.KeyChar == 27) 136 { 137 Close(); 117 138 } 118 139 } … … 120 141 private void UpdateInterface() 121 142 { 122 buttonFindNext.Enabled = textBoxWhat.Text.Length > 0; 123 buttonFindPrevious.Enabled = textBoxWhat.Text.Length > 0; 143 buttonFindNext.Enabled = comboBoxWhat.Text.Length > 0; 144 buttonFindPrevious.Enabled = comboBoxWhat.Text.Length > 0; 145 } 146 147 public void LoadFromRegistry() 148 { 149 RegistryKey regKey = Application.UserAppDataRegistry.OpenSubKey(regSubKey); 150 if (regKey == null) regKey = Application.UserAppDataRegistry.CreateSubKey(regSubKey); 151 152 checkBoxMatchWholeWordOnly.Checked = regKey.GetValueBool("MatchWholeWordOnly", false); 153 checkBoxMatchCase.Checked = regKey.GetValueBool("MatchCase", false); 154 155 regKey = Application.UserAppDataRegistry.OpenSubKey(regSubKey + "\\History"); 156 if (regKey == null) regKey = Application.UserAppDataRegistry.CreateSubKey(regSubKey + "\\History"); 157 int count = regKey.GetValueInt("Count", 0); 158 comboBoxWhat.BeginUpdate(); 159 while (comboBoxWhat.Items.Count > count) comboBoxWhat.Items.RemoveAt(comboBoxWhat.Items.Count - 1); 160 while (comboBoxWhat.Items.Count < count) comboBoxWhat.Items.Add(""); 161 for (int i = 0; i < count; i++) 162 { 163 comboBoxWhat.Items[i] = (string)regKey.GetValue(i.ToString(), ""); 164 } 165 comboBoxWhat.EndUpdate(); 166 } 167 168 public void SaveToRegistry() 169 { 170 RegistryKey regKey = Application.UserAppDataRegistry.OpenSubKey(regSubKey, true); 171 if (regKey == null) regKey = Application.UserAppDataRegistry.CreateSubKey(regSubKey); 172 173 regKey.SetValue("MatchWholeWordOnly", checkBoxMatchWholeWordOnly.Checked); 174 regKey.SetValue("MatchCase", checkBoxMatchCase.Checked); 175 176 regKey = Application.UserAppDataRegistry.OpenSubKey(regSubKey + "\\History", true); 177 if (regKey == null) regKey = Application.UserAppDataRegistry.CreateSubKey(regSubKey + "\\History"); 178 179 int i = 0; 180 regKey.SetValue("Count", comboBoxWhat.Items.Count); 181 foreach (var item in comboBoxWhat.Items) 182 { 183 regKey.SetValue(i.ToString(), item); 184 i++; 185 } 186 187 while (true) 188 { 189 List<string> names = regKey.GetValueNames().ToList(); 190 if (names.IndexOf(i.ToString()) != -1) 191 { 192 regKey.DeleteValue(i.ToString()); 193 } 194 else break; 195 i++; 196 } 124 197 } 125 198 } -
Common/FormProgress.cs
r1 r2 77 77 private void bg_DoWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) 78 78 { 79 if (e.Error != null) 80 { 81 currentTask.terminated = true; 82 MessageBox.Show(e.Error.Message, "Error in background task", MessageBoxButtons.OK, MessageBoxIcon.Error); 83 } 79 84 if (!currentTask.terminated) 80 85 { … … 91 96 } 92 97 else Close(); 93 if (e.Error != null)94 {95 MessageBox.Show(e.Error.Message, "Error in background task", MessageBoxButtons.OK, MessageBoxIcon.Error);96 }97 98 } 98 99 … … 134 135 foreach (var task in tasks) 135 136 { 136 if (task.completed) completed += 1; 137 if (task.completed) completed += 1; 137 138 } 138 139 return completed == tasks.Count; … … 154 155 public int current; 155 156 public bool terminated; 156 public bool completed; // If task was not terminated dur ring execution.157 public bool completed; // If task was not terminated during execution. 157 158 public string operation; 158 159 public delegate void CallbackEventHandler(Progress progress);
Note:
See TracChangeset
for help on using the changeset viewer.