mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
[WIP] First working drag and drop
Drag and drop finally works! But there is no feedback, and no animation and no cursor control. And the page still doesn't actually save the information, and it can't have new start programs added to it yet. It's fair to say there is still a lot to do :/
This commit is contained in:
parent
dccd13c019
commit
a278f183d7
@ -128,7 +128,6 @@
|
||||
</Compile>
|
||||
<Compile Include="ShortcutItem.cs" />
|
||||
<Compile Include="ShortcutRepository.cs" />
|
||||
<Compile Include="TableLayoutHelper.cs" />
|
||||
<Compile Include="UIForms\ApplyingProfileForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
@ -1,48 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DisplayMagician
|
||||
{
|
||||
|
||||
public static class TableLayoutHelper
|
||||
{
|
||||
public static void RemoveArbitraryRow(TableLayoutPanel panel, int rowIndex)
|
||||
{
|
||||
if (rowIndex >= panel.RowCount)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// delete all controls of row that we want to delete
|
||||
for (int i = 0; i < panel.ColumnCount; i++)
|
||||
{
|
||||
var control = panel.GetControlFromPosition(i, rowIndex);
|
||||
panel.Controls.Remove(control);
|
||||
}
|
||||
|
||||
// move up row controls that comes after row we want to remove
|
||||
for (int i = rowIndex + 1; i < panel.RowCount; i++)
|
||||
{
|
||||
for (int j = 0; j < panel.ColumnCount; j++)
|
||||
{
|
||||
var control = panel.GetControlFromPosition(j, i);
|
||||
if (control != null)
|
||||
{
|
||||
panel.SetRow(control, i - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var removeStyle = panel.RowCount - 1;
|
||||
|
||||
if (panel.RowStyles.Count > removeStyle)
|
||||
panel.RowStyles.RemoveAt(removeStyle);
|
||||
|
||||
panel.RowCount--;
|
||||
}
|
||||
}
|
||||
}
|
27
DisplayMagician/UIForms/ShortcutForm.Designer.cs
generated
27
DisplayMagician/UIForms/ShortcutForm.Designer.cs
generated
@ -68,6 +68,7 @@ namespace DisplayMagician.UIForms
|
||||
this.rb_change_audio = new System.Windows.Forms.RadioButton();
|
||||
this.rb_no_change_audio = new System.Windows.Forms.RadioButton();
|
||||
this.tabp_before = new System.Windows.Forms.TabPage();
|
||||
this.flp_start_programs = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.tabp_game = new System.Windows.Forms.TabPage();
|
||||
this.lbl_no_game_libraries = new System.Windows.Forms.Label();
|
||||
this.p_standalone = new System.Windows.Forms.Panel();
|
||||
@ -118,7 +119,6 @@ namespace DisplayMagician.UIForms
|
||||
this.cb_autosuggest = new System.Windows.Forms.CheckBox();
|
||||
this.btn_hotkey = new System.Windows.Forms.Button();
|
||||
this.lbl_hotkey_assigned = new System.Windows.Forms.Label();
|
||||
this.flp_start_programs = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.tabc_shortcut.SuspendLayout();
|
||||
this.tabp_display.SuspendLayout();
|
||||
this.tabp_audio.SuspendLayout();
|
||||
@ -626,6 +626,19 @@ namespace DisplayMagician.UIForms
|
||||
this.tabp_before.TabIndex = 1;
|
||||
this.tabp_before.Text = "3. Choose what happens before";
|
||||
//
|
||||
// flp_start_programs
|
||||
//
|
||||
this.flp_start_programs.AllowDrop = true;
|
||||
this.flp_start_programs.AutoScroll = true;
|
||||
this.flp_start_programs.AutoScrollMargin = new System.Drawing.Size(5, 0);
|
||||
this.flp_start_programs.AutoScrollMinSize = new System.Drawing.Size(5, 0);
|
||||
this.flp_start_programs.BackColor = System.Drawing.Color.White;
|
||||
this.flp_start_programs.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.flp_start_programs.Location = new System.Drawing.Point(3, 107);
|
||||
this.flp_start_programs.Name = "flp_start_programs";
|
||||
this.flp_start_programs.Size = new System.Drawing.Size(1076, 508);
|
||||
this.flp_start_programs.TabIndex = 0;
|
||||
//
|
||||
// tabp_game
|
||||
//
|
||||
this.tabp_game.BackColor = System.Drawing.Color.Black;
|
||||
@ -1248,18 +1261,6 @@ namespace DisplayMagician.UIForms
|
||||
this.lbl_hotkey_assigned.Visible = false;
|
||||
this.lbl_hotkey_assigned.Click += new System.EventHandler(this.lbl_hotkey_assigned_Click);
|
||||
//
|
||||
// flp_start_programs
|
||||
//
|
||||
this.flp_start_programs.AutoScroll = true;
|
||||
this.flp_start_programs.AutoScrollMargin = new System.Drawing.Size(5, 0);
|
||||
this.flp_start_programs.AutoScrollMinSize = new System.Drawing.Size(5, 0);
|
||||
this.flp_start_programs.BackColor = System.Drawing.Color.White;
|
||||
this.flp_start_programs.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.flp_start_programs.Location = new System.Drawing.Point(3, 107);
|
||||
this.flp_start_programs.Name = "flp_start_programs";
|
||||
this.flp_start_programs.Size = new System.Drawing.Size(1076, 508);
|
||||
this.flp_start_programs.TabIndex = 0;
|
||||
//
|
||||
// ShortcutForm
|
||||
//
|
||||
this.AcceptButton = this.btn_save;
|
||||
|
@ -56,6 +56,12 @@ namespace DisplayMagician.UIForms
|
||||
private Keys _hotkey = Keys.None;
|
||||
private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
|
||||
private StartProgramControl startProgramControlToMove;
|
||||
private int indexOfItemUnderMouseToDrag;
|
||||
private int indexOfItemUnderMouseToDrop;
|
||||
private Rectangle dragBoxFromMouseDown;
|
||||
private Point screenOffset;
|
||||
|
||||
public ShortcutForm(ShortcutItem shortcutToEdit)
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -1185,6 +1191,9 @@ namespace DisplayMagician.UIForms
|
||||
startProgramControl.Dock = DockStyle.None;
|
||||
startProgramControl.Margin = startProgramMargin;
|
||||
startProgramControl.Width = flp_start_programs.Width - 40;
|
||||
startProgramControl.MouseDown += new MouseEventHandler(StartProgramControl_MouseDown);
|
||||
startProgramControl.DragOver += new DragEventHandler(StartProgramControl_DragOver);
|
||||
startProgramControl.AllowDrop = true;
|
||||
//startProgramControl.Height = 170;
|
||||
|
||||
//startProgramControl.Height = pnl_start_programs.Height;
|
||||
@ -2123,5 +2132,44 @@ namespace DisplayMagician.UIForms
|
||||
ShortcutRepository.RunShortcut(chosenShortcut);
|
||||
}
|
||||
}
|
||||
|
||||
/*private void flp_start_programs_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
e.Effect = DragDropEffects.All;
|
||||
}*/
|
||||
|
||||
/* private void flp_start_programs_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
StartProgramControl startProgramControlBeingMoved = (StartProgramControl)e.Data.GetData(typeof(StartProgramControl));
|
||||
|
||||
Point p = flp_start_programs.PointToClient(new Point(e.X, e.Y));
|
||||
var startProgramControl = flp_start_programs.GetChildAtPoint(p);
|
||||
int index = flp_start_programs.Controls.GetChildIndex(startProgramControl, false);
|
||||
flp_start_programs.Controls.SetChildIndex(startProgramControlBeingMoved, index);
|
||||
flp_start_programs.Invalidate();
|
||||
}*/
|
||||
|
||||
private void StartProgramControl_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
//base.OnMouseDown(e);
|
||||
DoDragDrop(sender, DragDropEffects.All);
|
||||
}
|
||||
|
||||
private void StartProgramControl_DragOver(object sender, DragEventArgs e)
|
||||
{
|
||||
//base.OnDragOver(e);
|
||||
// is another dragable
|
||||
if (e.Data.GetData(typeof(StartProgramControl)) != null)
|
||||
{
|
||||
FlowLayoutPanel p = (FlowLayoutPanel)(sender as StartProgramControl).Parent;
|
||||
//Current Position
|
||||
int myIndex = p.Controls.GetChildIndex((sender as StartProgramControl));
|
||||
|
||||
//Dragged to control to location of next picturebox
|
||||
StartProgramControl q = (StartProgramControl)e.Data.GetData(typeof(StartProgramControl));
|
||||
p.Controls.SetChildIndex(q, myIndex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -128,13 +128,13 @@ namespace DisplayMagician.UIForms
|
||||
this.btn_delete.UseVisualStyleBackColor = true;
|
||||
this.btn_delete.Click += new System.EventHandler(this.btn_delete_Click);
|
||||
//
|
||||
// cb_start_program
|
||||
// cb_disable_start_program
|
||||
//
|
||||
this.cb_disable_start_program.AutoSize = true;
|
||||
this.cb_disable_start_program.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.cb_disable_start_program.ForeColor = System.Drawing.Color.White;
|
||||
this.cb_disable_start_program.Location = new System.Drawing.Point(78, 121);
|
||||
this.cb_disable_start_program.Name = "cb_start_program";
|
||||
this.cb_disable_start_program.Name = "cb_disable_start_program";
|
||||
this.cb_disable_start_program.Size = new System.Drawing.Size(312, 24);
|
||||
this.cb_disable_start_program.TabIndex = 28;
|
||||
this.cb_disable_start_program.Text = "Temporarily disable starting this program";
|
||||
@ -154,6 +154,7 @@ namespace DisplayMagician.UIForms
|
||||
//
|
||||
// StartProgramControl
|
||||
//
|
||||
this.AllowDrop = true;
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
|
||||
this.AutoSize = true;
|
||||
this.BackColor = System.Drawing.Color.Black;
|
||||
|
@ -120,4 +120,4 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
Thanks for the work and the time that all of our contributors put into making this a better project. Following is a short list, containing the name of some of these people:
|
||||
|
||||
* Original HelioDisplayManagement project created by the amazing Soroush Falahati
|
||||
* Readme file created by @timegrinder
|
||||
* Various icons made by Freepik from www.flaticon.com
|
Loading…
Reference in New Issue
Block a user