Exemplo n.º 1
0
 void ld_MouseMove(object sender, MouseEventArgs e)
 {
     if (mousedown)
     {
         if (tpf == null)
         {
             if (Math.Abs(mousedownpos.X - e.X) >= 5 || Math.Abs(mousedownpos.Y - e.Y) >= 5)
             {
                 tpf = new TransParentForm();
                 tpf.Show();
                 tpf.SetInfo(SelectedLayer, SelectedLayer.Size);
                 tpf.Location = this.PointToScreen(new Point(SelectedLayer.Location.X, SelectedLayer.Location.Y));
                 bb           = new BlackBar();
                 this.Controls.Add(bb);
                 this.Controls.SetChildIndex(bb, 0);
                 mousedownpos = new Point(Cursor.Position.X, Cursor.Position.Y);
                 movecount    = 0;
             }
         }
         else
         {
             Point p = Cursor.Position;
             tpf.Location = new Point(tpf.Location.X + p.X - mousedownpos.X, tpf.Location.Y + p.Y - mousedownpos.Y);
             mousedownpos = new Point(p.X, p.Y);
             int index = (SelectedLayer.Location.Y + e.Y + VerticalScroll.Value) / SelectedLayer.Height;
             if (index < 0)
             {
                 index = 0;
             }
             if (index > layers.Count)
             {
                 index = layers.Count;
             }
             bb.Location = new Point(0, SelectedLayer.Height * index - VerticalScroll.Value);
             if (movecount % 10 == 0)
             {
                 if (bb.Location.Y < 0)
                 {
                     GainVScroll(-SelectedLayer.Width);
                 }
                 else if (bb.Location.Y > this.ClientSize.Height)
                 {
                     GainVScroll(SelectedLayer.Width);
                 }
             }
             bb.Location = new Point(0, SelectedLayer.Height * index - VerticalScroll.Value);
             movecount++;
         }
     }
 }
Exemplo n.º 2
0
 void ld_MouseUp(object sender, MouseEventArgs e)
 {
     if (mousedown && tpf != null)
     {
         int index = (SelectedLayer.Location.Y + e.Y + VerticalScroll.Value) / SelectedLayer.Height;
         if (index < 0)
         {
             index = 0;
         }
         if (index > layers.Count)
         {
             index = layers.Count;
         }
         index = layers.Count - index;
         var selectedIndex = layers.IndexOf(SelectedLayer);
         var layer         = SelectedLayer;
         if (selectedIndex < index)
         {
             index--;
         }
         if (selectedIndex != index)
         {
             layers.RemoveAt(selectedIndex);
             layers.Insert(index, layer);
             Relocate();
         }
     }
     mousedown = false;
     if (tpf != null)
     {
         tpf.Close();
         tpf.Dispose();
         tpf = null;
     }
     if (bb != null)
     {
         this.Controls.Remove(bb);
         bb.Dispose();
         bb = null;
     }
 }