HamBook – Diff between revs 52 and 53

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 52 Rev 53
Line 9... Line 9...
9 using System; 9 using System;
10 using System.Collections.Concurrent; 10 using System.Collections.Concurrent;
11 using System.Collections.Generic; 11 using System.Collections.Generic;
12 using System.ComponentModel; 12 using System.ComponentModel;
13 using System.Data; 13 using System.Data;
-   14 using System.Drawing;
14 using System.Linq; 15 using System.Linq;
15 using System.Media; 16 using System.Media;
16 using System.Reflection; 17 using System.Reflection;
17 using System.Runtime.Remoting.Channels; 18 using System.Runtime.Remoting.Channels;
18 using System.Threading; 19 using System.Threading;
Line 35... Line 36...
35 private List<DataGridViewRow> _clipboardRows; 36 private List<DataGridViewRow> _clipboardRows;
Line 36... Line 37...
36   37  
37 public MemoryOrganizerForm() 38 public MemoryOrganizerForm()
38 { 39 {
-   40 InitializeComponent();
Line 39... Line 41...
39 InitializeComponent(); 41 Utilities.WindowState.FormTracker.Track(this);
40   42  
41 _localCancellationTokenSource = new CancellationTokenSource(); 43 _localCancellationTokenSource = new CancellationTokenSource();
Line 84... Line 86...
84 try 86 try
85 { 87 {
86 switch (rowProgress) 88 switch (rowProgress)
87 { 89 {
88 case DataGridViewRowProgressSuccess<MemoryChannel> rowProgressSuccess: 90 case DataGridViewRowProgressSuccess<MemoryChannel> rowProgressSuccess:
-   91 dataGridView1.Rows[rowProgressSuccess.Row.Index].DefaultCellStyle.BackColor = DataGridView.DefaultBackColor;
Line 89... Line 92...
89   92  
90 switch(Configuration.Radio) 93 switch (Configuration.Radio)
91 { 94 {
92 case "Yaesu FT-891": 95 case "Yaesu FT-891":
Line 93... Line 96...
93 var result = (Radios.Yaesu.FT_891.MemoryChannel)rowProgressSuccess.Data; 96 var result = (Radios.Yaesu.FT_891.MemoryChannel)rowProgressSuccess.Data;
Line 107... Line 110...
107   110  
108 toolStripStatusLabel1.Text = $"{Resources.Read_memory_bank} {rowProgress.Index + 1}"; 111 toolStripStatusLabel1.Text = $"{Resources.Read_memory_bank} {rowProgress.Index + 1}";
109 break; 112 break;
110 case DataGridViewRowProgressFailure rowProgressFailure: 113 case DataGridViewRowProgressFailure rowProgressFailure:
-   114 Log.Error(rowProgressFailure.Exception, $"{Resources.Could_not_read_memory_bank}");
Line 111... Line 115...
111 Log.Error(rowProgressFailure.Exception, $"{Resources.Could_not_read_memory_bank}"); 115 dataGridView1.Rows[rowProgressFailure.Row.Index].DefaultCellStyle.BackColor = Color.Red;
112   116  
113 toolStripStatusLabel1.Text = $"{Resources.Could_not_read_memory_bank} {rowProgress.Index + 1}"; 117 toolStripStatusLabel1.Text = $"{Resources.Could_not_read_memory_bank} {rowProgress.Index + 1}";
Line 145... Line 149...
145 try 149 try
146 { 150 {
147 switch (rowProgress) 151 switch (rowProgress)
148 { 152 {
149 case DataGridViewRowProgressSuccess<bool> rowProgressSuccess: 153 case DataGridViewRowProgressSuccess<bool> rowProgressSuccess:
-   154 dataGridView1.Rows[rowProgressSuccess.Row.Index].DefaultCellStyle.BackColor = DataGridView.DefaultBackColor;
150 var success = rowProgressSuccess.Data; 155 var success = rowProgressSuccess.Data;
151   156
152 if (success) 157 if (success)
153 { 158 {
Line 154... Line 159...
154   159  
155 toolStripStatusLabel1.Text = 160 toolStripStatusLabel1.Text =
Line 160... Line 165...
160 } 165 }
Line 161... Line 166...
161   166  
162 Log.Error($"{Resources.Could_not_write_memory_bank}"); 167 Log.Error($"{Resources.Could_not_write_memory_bank}");
163 break; 168 break;
-   169 case DataGridViewRowProgressFailure rowProgressFailure:
164 case DataGridViewRowProgressFailure rowProgressFailure: 170 dataGridView1.Rows[rowProgressFailure.Row.Index].DefaultCellStyle.BackColor = Color.Red;
165 Log.Error(rowProgressFailure.Exception, $"{Resources.Could_not_write_memory_bank}"); 171 Log.Error(rowProgressFailure.Exception, $"{Resources.Could_not_write_memory_bank}");
166 break; 172 break;
Line 167... Line 173...
167 } 173 }
Line 225... Line 231...
225 "Plus Shift", 231 "Plus Shift",
226 "Minus Shift" 232 "Minus Shift"
227 ); 233 );
228 dataGridView1.Columns.Add(phaseComboBoxColumn); 234 dataGridView1.Columns.Add(phaseComboBoxColumn);
229 dataGridView1.Columns.Add(new DataGridViewCheckBoxColumn() { Name = "TagColumn", HeaderText = "Tag" }); 235 dataGridView1.Columns.Add(new DataGridViewCheckBoxColumn() { Name = "TagColumn", HeaderText = "Tag" });
230 dataGridView1.Columns.Add(new DataGridViewTextBoxColumn() { Name = "TextColumn", HeaderText = "Text" }); 236 dataGridView1.Columns.Add(new DataGridViewTextBoxColumn() { Name = "TextColumn", HeaderText = "Text", MaxInputLength = Radios.Yaesu.FT_891.Constants.MAX_TAG_CHARACTERS });
231 break; 237 break;
232 } 238 }
Line 233... Line 239...
233   239  
234 toolStripProgressBar1.Minimum = 0; 240 toolStripProgressBar1.Minimum = 0;
Line 608... Line 614...
608 try 614 try
609 { 615 {
610 switch (rowProgress) 616 switch (rowProgress)
611 { 617 {
612 case DataGridViewRowProgressSuccess<MemoryChannel> rowProgressSuccess: 618 case DataGridViewRowProgressSuccess<MemoryChannel> rowProgressSuccess:
-   619 dataGridView1.Rows[rowProgressSuccess.Row.Index].DefaultCellStyle.BackColor = DataGridView.DefaultBackColor;
-   620  
613 switch(rowProgressSuccess.Data) 621 switch (rowProgressSuccess.Data)
614 { 622 {
615 case Radios.Yaesu.FT_891.MemoryChannel memoryChannel: 623 case Radios.Yaesu.FT_891.MemoryChannel memoryChannel:
616 rowProgress.Row.Cells["FrequencyColumn"].Value = memoryChannel.Frequency; 624 rowProgress.Row.Cells["FrequencyColumn"].Value = memoryChannel.Frequency;
617 rowProgress.Row.Cells["ClarifierDirectionColumn"].Value = (char)memoryChannel.ClarifierDirection; 625 rowProgress.Row.Cells["ClarifierDirectionColumn"].Value = (char)memoryChannel.ClarifierDirection;
618 rowProgress.Row.Cells["ClarifierOffsetColumn"].Value = memoryChannel.ClarifierOffset; 626 rowProgress.Row.Cells["ClarifierOffsetColumn"].Value = memoryChannel.ClarifierOffset;
Line 628... Line 636...
628   636  
629 toolStripStatusLabel1.Text = $"{Resources.Read_memory_bank} {rowProgress.Index + 1}"; 637 toolStripStatusLabel1.Text = $"{Resources.Read_memory_bank} {rowProgress.Index + 1}";
630 break; 638 break;
631 case DataGridViewRowProgressFailure rowProgressFailure: 639 case DataGridViewRowProgressFailure rowProgressFailure:
-   640 Log.Error(rowProgressFailure.Exception, $"{Resources.Could_not_read_memory_bank}");
Line 632... Line 641...
632 Log.Error(rowProgressFailure.Exception, $"{Resources.Could_not_read_memory_bank}"); 641 dataGridView1.Rows[rowProgressFailure.Row.Index].DefaultCellStyle.BackColor = Color.Red;
633   642  
634 toolStripStatusLabel1.Text = $"{Resources.Could_not_read_memory_bank} {rowProgress.Index + 1}"; 643 toolStripStatusLabel1.Text = $"{Resources.Could_not_read_memory_bank} {rowProgress.Index + 1}";
Line 674... Line 683...
674 try 683 try
675 { 684 {
676 switch (rowProgress) 685 switch (rowProgress)
677 { 686 {
678 case DataGridViewRowProgressSuccess<bool> rowProgressSuccess: 687 case DataGridViewRowProgressSuccess<bool> rowProgressSuccess:
-   688 dataGridView1.Rows[rowProgressSuccess.Row.Index].DefaultCellStyle.BackColor = DataGridView.DefaultBackColor;
679 var success = rowProgressSuccess.Data; 689 var success = rowProgressSuccess.Data;
Line 680... Line 690...
680   690  
681 if (success) 691 if (success)
Line 682... Line 692...
682 { 692 {
683   693  
684 toolStripStatusLabel1.Text = 694 toolStripStatusLabel1.Text =
685 $"{Resources.Wrote_memory_bank} {rowProgress.Index + 1}"; 695 $"{Resources.Wrote_memory_bank} {rowProgress.Index + 1}";
-   696 toolStripProgressBar1.Increment(1);
686 toolStripProgressBar1.Increment(1); 697 statusStrip1.Update();
687 statusStrip1.Update(); 698
Line 688... Line 699...
688 return; 699 return;
689 } 700 }
690   701  
691 Log.Error($"{Resources.Could_not_write_memory_bank}"); 702 Log.Error($"{Resources.Could_not_write_memory_bank}");
-   703 break;
692 break; 704 case DataGridViewRowProgressFailure rowProgressFailure:
693 case DataGridViewRowProgressFailure rowProgressFailure: 705 Log.Error(rowProgressFailure.Exception, $"{Resources.Could_not_write_memory_bank}");
Line 694... Line 706...
694 Log.Error(rowProgressFailure.Exception, $"{Resources.Could_not_write_memory_bank}"); 706 dataGridView1.Rows[rowProgressFailure.Row.Index].DefaultCellStyle.BackColor = Color.Red;
695 break; 707 break;
Line 958... Line 970...
958   970  
959 private void deleteToolStripMenuItem_Click(object sender, EventArgs e) 971 private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
960 { 972 {
961 DeleteSelectedRows(dataGridView1); 973 DeleteSelectedRows(dataGridView1);
-   974 }
-   975  
-   976 private void dataGridView1_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
-   977 {
-   978 DataGridView dataGridView = sender as DataGridView;
-   979 foreach (DataGridViewCell cell in dataGridView.Rows[e.RowIndex].Cells)
-   980 {
-   981 if (cell.Selected == false) { continue; }
-   982 var bgColorCell = Color.White;
-   983 if (cell.Style.BackColor != Color.Empty) { bgColorCell = cell.Style.BackColor; }
-   984 else if (cell.InheritedStyle.BackColor != Color.Empty) { bgColorCell = cell.InheritedStyle.BackColor; }
-   985 cell.Style.SelectionBackColor = MixColor(bgColorCell, Color.FromArgb(0, 150, 255), 10, 4);
-   986 }
-   987 }
-   988  
-   989 //Mix two colors
-   990 //Example: Steps=10 & Position=4 makes Color2 mix 40% into Color1
-   991 /// <summary>
-   992 /// Mix two colors.
-   993 /// </summary>
-   994 /// <param name="Color1"></param>
-   995 /// <param name="Color2"></param>
-   996 /// <param name="Steps"></param>
-   997 /// <param name="Position"></param>
-   998 /// <example>Steps=10 & Positon=4 makes Color2 mix 40% into Color1</example>
-   999 /// <remarks>https://stackoverflow.com/questions/38337849/transparent-selectionbackcolor-for-datagridview-cell</remarks>
-   1000 /// <returns></returns>
-   1001 public static Color MixColor(Color Color1, Color Color2, int Steps, int Position)
-   1002 {
-   1003 if (Position <= 0 || Steps <= 1) { return Color1; }
-   1004 if (Position >= Steps) { return Color2; }
-   1005 return Color.FromArgb(
-   1006 Color1.R + ((Color2.R - Color1.R) / Steps * Position),
-   1007 Color1.G + ((Color2.G - Color1.G) / Steps * Position),
-   1008 Color1.B + ((Color2.B - Color1.B) / Steps * Position)
-   1009 );
962 } 1010 }
963 } 1011 }