示例#1
0
 public void AddSlice(Slice slice)
 {
     if (slice is HorizontalSlice)
     _horizontalSlices.Add(slice);
       else
     _verticalSlices.Add(slice);
       _rectangles.Slice(slice);
 }
示例#2
0
 public void Remove(Slice slice)
 {
     _rectangles.Remove(slice);
       _horizontalSlices.Remove(slice);
       _verticalSlices.Remove(slice);
 }
示例#3
0
        protected override void OnMove(IntCoordinate c)
        {
            var coordinate = (_horizontal) ? new IntCoordinate(c.X, _y)
            : new IntCoordinate(_x, c.Y);
              var rectangle = SliceData.FindRectangle(coordinate);

              bool rectangleChanged = rectangle != _endRectangle;
              _endRectangle = rectangle;

              bool horizontal = Math.Abs(c.X - _x) > Math.Abs(c.Y - _y);
              bool orientationChanged = horizontal != _horizontal;
              _horizontal = horizontal;

              if (orientationChanged || rectangleChanged)
            {
              _slice.Draw(Preview.Renderer);
              if (_horizontal)
            {
              if (rectangle.X1 <= _rectangle.X1)
            {
              _slice = new HorizontalSlice(rectangle.Left,
                           _rectangle.Right, _y);
            }
              else
            {
              _slice = new HorizontalSlice(_rectangle.Left,
                           rectangle.Right, _y);
            }
            }
              else
            {
              if (rectangle.Y1 <= _rectangle.Y1)
            {
              _slice = new VerticalSlice(rectangle.Top,
                         _rectangle.Bottom, _x);
            }
              else
            {
              _slice = new VerticalSlice(_rectangle.Top,
                         rectangle.Bottom, _x);
            }
            }
              _slice.Draw(Preview.Renderer);
            }
        }
示例#4
0
 protected override void OnPress(IntCoordinate c)
 {
     _x = c.X;
       _y = c.Y;
       _rectangle = SliceData.FindRectangle(c);
       _slice = _rectangle.CreateHorizontalSlice(_y);
       _horizontal = true;
       Preview.Renderer.Function = Gdk.Function.Equiv;
       _slice.Draw(Preview.Renderer);
 }
示例#5
0
    public void Remove(Slice slice)
    {
      var set1 = _set.Where(rectangle => slice == rectangle.Bottom || 
			    slice == rectangle.Right).ToList();
      var set2 = _set.Where(rectangle => slice == rectangle.Top || 
			    slice == rectangle.Left).ToList();

      foreach (var r1 in set1)
        {
	  foreach (var r2 in set2)
	    {
	      if (r1.Left == r2.Left && r1.Right == r2.Right)
		{
		  r1.Bottom = r2.Bottom;
		  Remove(r2);
		  break;
		}
	      else if (r1.Top == r2.Top && r1.Bottom == r2.Bottom)
		{
		  r1.Right = r2.Right;
		  Remove(r2);
		  break;
		}
	    }
        }
    }
示例#6
0
        protected static Slice LoadFromNode(XmlNode node, Slice slice)
        {
            slice.Position = node.GetValue("position");
              slice.Index = node.GetValue("index");
              slice.Begin = new HorizontalSlice(node.GetValue("begin"));
              slice.End = new HorizontalSlice(node.GetValue("end"));
              slice.Changed = false;

              return slice;
        }
示例#7
0
 public void Remove(Slice slice)
 {
     _set.Remove(slice);
 }
示例#8
0
 bool IsEndPoint(Slice s)
 {
     return _set.Exists(slice => slice.Begin == s || slice.End == s);
 }
示例#9
0
 public Slice Contains(int x, int y, Slice slice)
 {
     if (slice == Left && y >= Y1 && y <= Y2)
     {
       return CreateVerticalSlice(X1);
     }
       else if (slice == Right && y >= Y1 && y <= Y2)
     {
       return CreateVerticalSlice(X2);
     }
       else if (slice == Top && x >= X1 && x <= X2)
     {
       return CreateHorizontalSlice(Y1);
     }
       else if (slice == Bottom && x >= X1 && x <= X2)
     {
       return CreateHorizontalSlice(Y2);
     }
       return null;
 }
示例#10
0
 public bool SliceIsSelectable(Slice slice)
 {
     return(!(slice == null || slice.Locked));
 }
示例#11
0
 public VerticalSlice(Slice top, Slice bottom, int x) : base(top, bottom, x)
 {
 }
示例#12
0
 MoveSliceFunc(SliceData sliceData, Preview preview, Slice slice)
     : base(sliceData, preview)
 {
     _slice = slice;
       Preview.Renderer.Function = Gdk.Function.Equiv;
 }
示例#13
0
 public VerticalSlice(Slice top, Slice bottom, int x)
     : base(top, bottom, x)
 {
 }
示例#14
0
 public void Slice(Slice slice)
 {
   var query = _set.Where(rectangle => rectangle.IntersectsWith(slice));
   query.ToList().ForEach(rectangle => Add(rectangle.Slice(slice)));
 }
示例#15
0
 public bool IntersectsWith(Slice slice)
 {
     return slice.IntersectsWith(this);
 }
示例#16
0
 public void Cleanup(Slice slice)
 {
     _rectangles.Cleanup(slice);
 }
示例#17
0
        public bool Normalize(Slice slice)
        {
            if (slice == Left && X1 >= X2)
            {
              Left.X = Right.X;
              return true;
            }
              else if (slice == Right && X2 <= X1)
            {
              Right.X = Left.X;
              return true;
            }

              if (slice == Top && Y1 >= Y2)
            {
              Top.Y = Bottom.Y;
              return true;
            }
              else if (slice == Bottom && Y2 <= Y1)
            {
              Bottom.Y = Top.Y;
              return true;
              // Fix me: shouldn't this have 'return true'?????
            }
              return false;
        }
示例#18
0
 public void Add(Slice slice)
 {
     Changed = true;
       _set.Add(slice);
 }
示例#19
0
 public Rectangle Slice(Slice slice)
 {
     return slice.SliceRectangle(this);
 }
示例#20
0
 public bool SliceIsSelectable(Slice slice)
 {
     return !(slice == null || slice.Locked);
 }
示例#21
0
 public HorizontalSlice(Slice left, Slice right, int y)
     : base(left, right, y)
 {
 }
示例#22
0
 protected Slice(Slice begin, Slice end, int position)
 {
     Begin = begin;
       End = end;
       _position = position;
 }
示例#23
0
 public void Cleanup(Slice slice)
 {
   var query = _set.Where(rectangle => rectangle.Normalize(slice));
   _set.RemoveAll(rectangle => query.Contains(rectangle));
   Changed = query.Count() > 0;
 }