From 75023a90007e78e109ee2fcb0bd2cb0b74c523ff Mon Sep 17 00:00:00 2001 From: bogiton <34060135+bogiton@users.noreply.github.com> Date: Wed, 13 Mar 2019 11:31:23 +0000 Subject: [PATCH 1/3] Added drag-drop support to each panel --- ChameleonMiniGUI/FrmMain.Designer.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/ChameleonMiniGUI/FrmMain.Designer.cs b/ChameleonMiniGUI/FrmMain.Designer.cs index 56dd2bb..06ffe57 100644 --- a/ChameleonMiniGUI/FrmMain.Designer.cs +++ b/ChameleonMiniGUI/FrmMain.Designer.cs @@ -938,6 +938,7 @@ private void InitializeComponent() // // tableLayoutPanel6 // + this.tableLayoutPanel6.AllowDrop = true; this.tableLayoutPanel6.ColumnCount = 3; this.tableLayoutPanel6.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F)); this.tableLayoutPanel6.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 35F)); @@ -970,6 +971,8 @@ private void InitializeComponent() this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F)); this.tableLayoutPanel6.Size = new System.Drawing.Size(254, 213); this.tableLayoutPanel6.TabIndex = 26; + this.tableLayoutPanel6.DragDrop += new System.Windows.Forms.DragEventHandler(this.tableLayoutPanel_DragDrop); + this.tableLayoutPanel6.DragEnter += new System.Windows.Forms.DragEventHandler(this.tableLayoutPanel_DragEnter); // // lbl_mode6 // @@ -1228,6 +1231,7 @@ private void InitializeComponent() // // tableLayoutPanel1 // + this.tableLayoutPanel1.AllowDrop = true; this.tableLayoutPanel1.ColumnCount = 3; this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 35F)); @@ -1260,6 +1264,8 @@ private void InitializeComponent() this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F)); this.tableLayoutPanel1.Size = new System.Drawing.Size(254, 213); this.tableLayoutPanel1.TabIndex = 37; + this.tableLayoutPanel1.DragDrop += new System.Windows.Forms.DragEventHandler(this.tableLayoutPanel_DragDrop); + this.tableLayoutPanel1.DragEnter += new System.Windows.Forms.DragEventHandler(this.tableLayoutPanel_DragEnter); // // lbl_uid1 // @@ -1517,6 +1523,7 @@ private void InitializeComponent() // // tableLayoutPanel2 // + this.tableLayoutPanel2.AllowDrop = true; this.tableLayoutPanel2.ColumnCount = 3; this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F)); this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 35F)); @@ -1549,6 +1556,8 @@ private void InitializeComponent() this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F)); this.tableLayoutPanel2.Size = new System.Drawing.Size(254, 213); this.tableLayoutPanel2.TabIndex = 22; + this.tableLayoutPanel2.DragDrop += new System.Windows.Forms.DragEventHandler(this.tableLayoutPanel_DragDrop); + this.tableLayoutPanel2.DragEnter += new System.Windows.Forms.DragEventHandler(this.tableLayoutPanel_DragEnter); // // lbl_mode2 // @@ -1790,6 +1799,7 @@ private void InitializeComponent() // // tableLayoutPanel4 // + this.tableLayoutPanel4.AllowDrop = true; this.tableLayoutPanel4.ColumnCount = 3; this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F)); this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 35F)); @@ -1822,6 +1832,8 @@ private void InitializeComponent() this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F)); this.tableLayoutPanel4.Size = new System.Drawing.Size(254, 213); this.tableLayoutPanel4.TabIndex = 22; + this.tableLayoutPanel4.DragDrop += new System.Windows.Forms.DragEventHandler(this.tableLayoutPanel_DragDrop); + this.tableLayoutPanel4.DragEnter += new System.Windows.Forms.DragEventHandler(this.tableLayoutPanel_DragEnter); // // lbl_mode4 // @@ -2063,6 +2075,7 @@ private void InitializeComponent() // // tableLayoutPanel3 // + this.tableLayoutPanel3.AllowDrop = true; this.tableLayoutPanel3.ColumnCount = 3; this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F)); this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 35F)); @@ -2095,6 +2108,8 @@ private void InitializeComponent() this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F)); this.tableLayoutPanel3.Size = new System.Drawing.Size(254, 213); this.tableLayoutPanel3.TabIndex = 22; + this.tableLayoutPanel3.DragDrop += new System.Windows.Forms.DragEventHandler(this.tableLayoutPanel_DragDrop); + this.tableLayoutPanel3.DragEnter += new System.Windows.Forms.DragEventHandler(this.tableLayoutPanel_DragEnter); // // lbl_mode3 // @@ -2336,6 +2351,7 @@ private void InitializeComponent() // // tableLayoutPanel5 // + this.tableLayoutPanel5.AllowDrop = true; this.tableLayoutPanel5.ColumnCount = 3; this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F)); this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 35F)); @@ -2368,6 +2384,8 @@ private void InitializeComponent() this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F)); this.tableLayoutPanel5.Size = new System.Drawing.Size(254, 213); this.tableLayoutPanel5.TabIndex = 24; + this.tableLayoutPanel5.DragDrop += new System.Windows.Forms.DragEventHandler(this.tableLayoutPanel_DragDrop); + this.tableLayoutPanel5.DragEnter += new System.Windows.Forms.DragEventHandler(this.tableLayoutPanel_DragEnter); // // lbl_mode5 // @@ -2609,6 +2627,7 @@ private void InitializeComponent() // // tableLayoutPanel7 // + this.tableLayoutPanel7.AllowDrop = true; this.tableLayoutPanel7.ColumnCount = 3; this.tableLayoutPanel7.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F)); this.tableLayoutPanel7.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 35F)); @@ -2641,6 +2660,8 @@ private void InitializeComponent() this.tableLayoutPanel7.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F)); this.tableLayoutPanel7.Size = new System.Drawing.Size(254, 213); this.tableLayoutPanel7.TabIndex = 26; + this.tableLayoutPanel7.DragDrop += new System.Windows.Forms.DragEventHandler(this.tableLayoutPanel_DragDrop); + this.tableLayoutPanel7.DragEnter += new System.Windows.Forms.DragEventHandler(this.tableLayoutPanel_DragEnter); // // lbl_mode7 // @@ -2882,6 +2903,7 @@ private void InitializeComponent() // // tableLayoutPanel8 // + this.tableLayoutPanel8.AllowDrop = true; this.tableLayoutPanel8.ColumnCount = 3; this.tableLayoutPanel8.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F)); this.tableLayoutPanel8.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 35F)); @@ -2914,6 +2936,8 @@ private void InitializeComponent() this.tableLayoutPanel8.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F)); this.tableLayoutPanel8.Size = new System.Drawing.Size(254, 213); this.tableLayoutPanel8.TabIndex = 26; + this.tableLayoutPanel8.DragDrop += new System.Windows.Forms.DragEventHandler(this.tableLayoutPanel_DragDrop); + this.tableLayoutPanel8.DragEnter += new System.Windows.Forms.DragEventHandler(this.tableLayoutPanel_DragEnter); // // lbl_mode8 // From 00126695dad7f3443e67ccd520c495e79defab13 Mon Sep 17 00:00:00 2001 From: bogiton <34060135+bogiton@users.noreply.github.com> Date: Wed, 13 Mar 2019 11:33:51 +0000 Subject: [PATCH 2/3] Added handlers for the drag-drop event on panels --- ChameleonMiniGUI/FrmMain.cs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/ChameleonMiniGUI/FrmMain.cs b/ChameleonMiniGUI/FrmMain.cs index 24cba77..1565c43 100644 --- a/ChameleonMiniGUI/FrmMain.cs +++ b/ChameleonMiniGUI/FrmMain.cs @@ -1037,6 +1037,37 @@ private void tfSerialHelp_TextClick(object sender, EventArgs e) this.ActiveControl = tbSerialCmd; } + private void tableLayoutPanel_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(DataFormats.FileDrop)) + e.Effect = DragDropEffects.Copy; + else + e.Effect = DragDropEffects.None; + } + + private void tableLayoutPanel_DragDrop(object sender, DragEventArgs e) + { + string[] s = (string[])e.Data.GetData(DataFormats.FileDrop, false); + if (s.Length > 0) + { + var dumpFileName = s[0]; + if (File.Exists(dumpFileName)) + { + // Get the tagslot index + var tagslotIndex = int.Parse(((TableLayoutPanel)sender).Name.Substring(((TableLayoutPanel)sender).Name.Length - 1)); + if (tagslotIndex <= 0) return; + + // Select the corresponding slot + SendCommandWithoutResult($"SETTING{_cmdExtension}={tagslotIndex - _tagslotIndexOffset}"); + + // Load the dump + UploadDump(dumpFileName); + + // Refresh slot + RefreshSlot(tagslotIndex); + } + } + } #endregion #region Helper methods @@ -2624,5 +2655,6 @@ private void DisconnectDevice() } #endregion + } } From f00c162bc12c2919484ef135fe8598948f029f00 Mon Sep 17 00:00:00 2001 From: bogiton <34060135+bogiton@users.noreply.github.com> Date: Wed, 13 Mar 2019 12:46:08 +0000 Subject: [PATCH 3/3] Added simple type identification when upload dump --- ChameleonMiniGUI/FrmMain.cs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/ChameleonMiniGUI/FrmMain.cs b/ChameleonMiniGUI/FrmMain.cs index 1565c43..146845b 100644 --- a/ChameleonMiniGUI/FrmMain.cs +++ b/ChameleonMiniGUI/FrmMain.cs @@ -2078,6 +2078,9 @@ internal void UploadDump(string filename) { var bytes = ReadFileIntoByteArray(filename); + // Try to identify the dump type + IndentifyDumpTypeBySize(bytes.Length); + var xmodem = new XMODEM(_comport, XMODEM.Variants.XModemChecksum); SendCommandWithoutResult($"UPLOAD{_cmdExtension}"); @@ -2101,6 +2104,28 @@ internal void UploadDump(string filename) } } + private void IndentifyDumpTypeBySize(int byteLength) + { + switch (byteLength) + { + case 4096: + SendCommandWithoutResult($"CONFIG{_cmdExtension}=MF_CLASSIC_4K"); + break; + case 64: + SendCommandWithoutResult($"CONFIG{_cmdExtension}=MF_ULTRALIGHT"); + break; + case 80: + SendCommandWithoutResult($"CONFIG{_cmdExtension}=MF_ULTRALIGHT_EV1_80B"); + break; + case 164: + SendCommandWithoutResult($"CONFIG{_cmdExtension}=MF_ULTRALIGHT_EV1_164B"); + break; + default: + SendCommandWithoutResult($"CONFIG{_cmdExtension}=MF_CLASSIC_1K"); + break; + } + } + internal void DownloadAndSaveDump(string filename) { // First get the current memory size of the slot @@ -2655,6 +2680,5 @@ private void DisconnectDevice() } #endregion - } }