diff --git a/DisplayMagician/UIForms/ShortcutForm.cs b/DisplayMagician/UIForms/ShortcutForm.cs index c8b2b38..8335385 100644 --- a/DisplayMagician/UIForms/ShortcutForm.cs +++ b/DisplayMagician/UIForms/ShortcutForm.cs @@ -61,6 +61,7 @@ namespace DisplayMagician.UIForms private int indexOfItemUnderMouseToDrop; private Rectangle dragBoxFromMouseDown; private Point screenOffset; + private Cursor _bitMapCursor; public ShortcutForm(ShortcutItem shortcutToEdit) { @@ -1193,6 +1194,7 @@ namespace DisplayMagician.UIForms startProgramControl.Width = flp_start_programs.Width - 40; startProgramControl.MouseDown += new MouseEventHandler(StartProgramControl_MouseDown); startProgramControl.DragOver += new DragEventHandler(StartProgramControl_DragOver); + startProgramControl.DragDrop += new DragEventHandler(StartProgramControl_DragDrop); startProgramControl.AllowDrop = true; //startProgramControl.Height = 170; @@ -2152,23 +2154,85 @@ namespace DisplayMagician.UIForms private void StartProgramControl_MouseDown(object sender, MouseEventArgs e) { //base.OnMouseDown(e); - DoDragDrop(sender, DragDropEffects.All); + DoDragDrop(sender, DragDropEffects.Move); + /*Bitmap bmp = new Bitmap(btntarget.Width, btntarget.Height); + btntarget.DrawToBitmap(bmp, new Rectangle(Point.Empty, bmp.Size)); + //optionally define a transparent color + bmp.MakeTransparent(Color.White); + + Cursor cur = new Cursor(bmp.GetHicon()); + Cursor.Current = cur;*/ + + /*//Cast the sender to control type youre using + StartProgramControl send = (StartProgramControl)sender; + //Copy the control in a bitmap + Bitmap bmp = new Bitmap(send.Width, send.Height); + send.DrawToBitmap(bmp, new Rectangle(Point.Empty, bmp.Size)); + //In a variable save the cursor with the image of your controler + _bitMapCursor = new Cursor(bmp.GetHicon()); + send.DoDragDrop(send.Text, DragDropEffects.Move);*/ } private void StartProgramControl_DragOver(object sender, DragEventArgs e) { //base.OnDragOver(e); // is another dragable - if (e.Data.GetData(typeof(StartProgramControl)) != null) + if (e.Data.GetData(typeof(StartProgramControl)) is StartProgramControl) { + + e.Effect = DragDropEffects.Move; 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); + StartProgramControl spc = (StartProgramControl)e.Data.GetData(typeof(StartProgramControl)); + p.Controls.SetChildIndex(spc, myIndex); + } + + } + + private void StartProgramControl_DragDrop(object sender, DragEventArgs e) + { + //base.OnDragOver(e); + // is another dragable + if (e.Data.GetData(typeof(StartProgramControl)) is StartProgramControl) + { + + 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 spc = (StartProgramControl)e.Data.GetData(typeof(StartProgramControl)); + p.Controls.SetChildIndex(spc, myIndex); + StartProgram startProgram = spc.StartProgram; + startProgram.Priority = myIndex + 1; + spc.StartProgram = startProgram; + + flp_start_programs.SuspendLayout(); + + // And now we update all the UI for the items in the list + foreach (StartProgramControl startProgramControl in p.Controls) + { + int priority = p.Controls.GetChildIndex(startProgramControl) + 1; + startProgramControl.ChangePriority(priority); + } + + flp_start_programs.ResumeLayout(); + flp_start_programs.Invalidate(); + } + + } + + private void StartProgramControl_GiveFeedback(object sender, GiveFeedbackEventArgs e) + { + //Deactivate the default cursor + //e.UseDefaultCursors = false; + //Use the cursor created from the bitmap + //Cursor.Current = _bitMapCursor; + } } diff --git a/DisplayMagician/UIForms/StartProgramControl.Designer.cs b/DisplayMagician/UIForms/StartProgramControl.Designer.cs index 478dce2..8e9509f 100644 --- a/DisplayMagician/UIForms/StartProgramControl.Designer.cs +++ b/DisplayMagician/UIForms/StartProgramControl.Designer.cs @@ -38,6 +38,7 @@ namespace DisplayMagician.UIForms this.btn_delete = new System.Windows.Forms.Button(); this.cb_disable_start_program = new System.Windows.Forms.CheckBox(); this.lbl_start_program = new System.Windows.Forms.Label(); + this.lbl_priority = new System.Windows.Forms.Label(); this.SuspendLayout(); // // cb_dont_start_if_running @@ -58,7 +59,7 @@ namespace DisplayMagician.UIForms this.txt_start_program.BackColor = System.Drawing.Color.White; this.txt_start_program.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.txt_start_program.ForeColor = System.Drawing.Color.Black; - this.txt_start_program.Location = new System.Drawing.Point(221, 17); + this.txt_start_program.Location = new System.Drawing.Point(221, 16); this.txt_start_program.Name = "txt_start_program"; this.txt_start_program.Size = new System.Drawing.Size(503, 26); this.txt_start_program.TabIndex = 25; @@ -82,7 +83,7 @@ namespace DisplayMagician.UIForms this.btn_start_program.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btn_start_program.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.btn_start_program.ForeColor = System.Drawing.Color.White; - this.btn_start_program.Location = new System.Drawing.Point(730, 17); + this.btn_start_program.Location = new System.Drawing.Point(730, 16); this.btn_start_program.Name = "btn_start_program"; this.btn_start_program.Size = new System.Drawing.Size(85, 27); this.btn_start_program.TabIndex = 23; @@ -152,12 +153,23 @@ namespace DisplayMagician.UIForms this.lbl_start_program.TabIndex = 29; this.lbl_start_program.Text = "Start this program:"; // + // lbl_priority + // + this.lbl_priority.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbl_priority.Location = new System.Drawing.Point(10, 16); + this.lbl_priority.Name = "lbl_priority"; + this.lbl_priority.Size = new System.Drawing.Size(55, 23); + this.lbl_priority.TabIndex = 30; + this.lbl_priority.Text = "1"; + this.lbl_priority.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // // StartProgramControl // this.AllowDrop = true; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; this.AutoSize = true; this.BackColor = System.Drawing.Color.Black; + this.Controls.Add(this.lbl_priority); this.Controls.Add(this.lbl_start_program); this.Controls.Add(this.cb_disable_start_program); this.Controls.Add(this.btn_delete); @@ -187,5 +199,6 @@ namespace DisplayMagician.UIForms private System.Windows.Forms.Button btn_delete; private System.Windows.Forms.CheckBox cb_disable_start_program; private System.Windows.Forms.Label lbl_start_program; + private System.Windows.Forms.Label lbl_priority; } } diff --git a/DisplayMagician/UIForms/StartProgramControl.cs b/DisplayMagician/UIForms/StartProgramControl.cs index 86184b8..8ad0c19 100644 --- a/DisplayMagician/UIForms/StartProgramControl.cs +++ b/DisplayMagician/UIForms/StartProgramControl.cs @@ -26,7 +26,7 @@ namespace DisplayMagician.UIForms set { myStartProgram = value; - populateUI(); + UpdateUI(); } } public StartProgramControl() @@ -40,13 +40,14 @@ namespace DisplayMagician.UIForms // Update the text with the start program info myStartProgram = startProgram; - populateUI(); + UpdateUI(); } - private void populateUI() + public void UpdateUI() { // Now populate the controls with the start program data + lbl_priority.Text = myStartProgram.Priority.ToString(); txt_start_program.Text = myStartProgram.Executable; cb_disable_start_program.Checked = myStartProgram.Disabled; cb_start_program_pass_args.Checked = myStartProgram.ExecutableArgumentsRequired; @@ -56,6 +57,13 @@ namespace DisplayMagician.UIForms } + public void ChangePriority(int priority) + { + // Now update the priority field + myStartProgram.Priority = priority; + lbl_priority.Text = priority.ToString(); + } + private void btn_start_program_Click(object sender, EventArgs e) {