public void AddSlice(Slice slice) { if (slice is HorizontalSlice) _horizontalSlices.Add(slice); else _verticalSlices.Add(slice); _rectangles.Slice(slice); }
public void Remove(Slice slice) { _rectangles.Remove(slice); _horizontalSlices.Remove(slice); _verticalSlices.Remove(slice); }
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); } }
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); }
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; } } } }
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; }
public void Remove(Slice slice) { _set.Remove(slice); }
bool IsEndPoint(Slice s) { return _set.Exists(slice => slice.Begin == s || slice.End == s); }
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; }
public bool SliceIsSelectable(Slice slice) { return(!(slice == null || slice.Locked)); }
public VerticalSlice(Slice top, Slice bottom, int x) : base(top, bottom, x) { }
MoveSliceFunc(SliceData sliceData, Preview preview, Slice slice) : base(sliceData, preview) { _slice = slice; Preview.Renderer.Function = Gdk.Function.Equiv; }
public void Slice(Slice slice) { var query = _set.Where(rectangle => rectangle.IntersectsWith(slice)); query.ToList().ForEach(rectangle => Add(rectangle.Slice(slice))); }
public bool IntersectsWith(Slice slice) { return slice.IntersectsWith(this); }
public void Cleanup(Slice slice) { _rectangles.Cleanup(slice); }
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; }
public void Add(Slice slice) { Changed = true; _set.Add(slice); }
public Rectangle Slice(Slice slice) { return slice.SliceRectangle(this); }
public bool SliceIsSelectable(Slice slice) { return !(slice == null || slice.Locked); }
public HorizontalSlice(Slice left, Slice right, int y) : base(left, right, y) { }
protected Slice(Slice begin, Slice end, int position) { Begin = begin; End = end; _position = position; }
public void Cleanup(Slice slice) { var query = _set.Where(rectangle => rectangle.Normalize(slice)); _set.RemoveAll(rectangle => query.Contains(rectangle)); Changed = query.Count() > 0; }