Ejemplo n.º 1
0
 internal int GetAmountOfCheckersAtPoint(int i)
 {
     if (i == CheckerColor.Black.GetBar())
     {
         return(BlackBar.GetAmount());
     }
     else if (i == White.GetBar())
     {
         return(WhiteBar.GetAmount());
     }
     else if (i == White.BearOffPositionID())
     {
         return(WhiteBearOff.GetAmount());
     }
     else if (i == Black.BearOffPositionID())
     {
         return(BlackBearOff.GetAmount());
     }
     else
     {
         int value = Points[i].GetAmount();
         if (value != 0 && Points[i].GetTopChecker().Color == Black)
         {
             return(-value);
         }
         return(value);
     }
 }
Ejemplo n.º 2
0
 internal void GlowPoints(List <int> list)
 {
     for (int i = 1; i < Points.Count; i++)
     {
         Points[i].Glow(list.Contains(i));
     }
     WhiteBar.Glow(list.Contains(BackgammonGame.WHITE_BAR_ID));
     BlackBar.Glow(list.Contains(BackgammonGame.BLACK_BAR_ID));
     WhiteBearOff.Glow(list.Contains(BackgammonGame.WHITE_BEAR_OFF_ID));
     BlackBearOff.Glow(list.Contains(BackgammonGame.BLACK_BEAR_OFF_ID));
 }
Ejemplo n.º 3
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++;
         }
     }
 }
Ejemplo n.º 4
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;
     }
 }