コード例 #1
0
 public DrawingSheet(PhasesBook ownerBook, string sheetName, Size size, int imageIndex = Constants.ImageIndex.SubSheet)
     : base(sheetName, size)
 {
     OwnerBook = ownerBook;
     sheetTree = new TreeNode(sheetName, imageIndex, imageIndex);
     Sketch    = new DrawableCollection(this);
 }
コード例 #2
0
        public bool DeserializeSelection(byte[] data, bool pointerLocation, Point location, Func <string, List <DrawableObject>, string> NextName)
        {
            Dictionary <int, DrawableObject> objects;
            int index = 0;

            if (!Serialization.DeserializeParameter(data, ref index, out DateTime date))
            {
                return(false);
            }
            if (!DrawableCollection.DeserializeList(draw, data, ref index, out objects))
            {
                return(false);
            }

            Point poffset;

            if (pointerLocation)
            {
                Point center = Util.Center(objects.Values.ToList().ConvertAll(dobj => dobj.Center).ToArray());
                poffset = Location;
                poffset.Offset(-center.X, -center.Y);
            }
            else
            {
                int offset = 10;
                if (date == pastedTimeStamp)
                {
                    pastedTimes++;
                }
                else
                {
                    pastedTimes     = 0;
                    pastedTimeStamp = date;
                }
                offset *= pastedTimes;
                poffset = new Point(offset, offset);
            }

            ClearSelection();
            // Changing objects names first to handle state size change separately
            foreach (DrawableObject obj in objects.Values)
            {
                if (draw.OwnerSheet.ExistsName(obj.Name))
                {
                    obj.Name = NextName(obj.GetFormName(), objects.Values.ToList());
                }
            }
            // Aplying paste offset and adding to selection
            foreach (DrawableObject obj in objects.Values)
            {
                obj.Move(poffset);
                AddToSelection(obj);
            }
            //Doing = MouseDoing.Pasting;
            return(true);
        }
コード例 #3
0
        public byte[] SerializeSelection()
        {
            var data = new List <byte>();

            pastedTimeStamp = DateTime.Now;
            pastedTimes     = 0;
            data.AddRange(Serialization.SerializeParameter(pastedTimeStamp));
            data.AddRange(DrawableCollection.SerializeList(SelectedObjects));
            return(data.ToArray());
        }
コード例 #4
0
 public MouseTool(DrawableCollection _draw, PictureBox pictureBox)
 {
     draw                       = _draw;
     pBox                       = pictureBox;
     Doing                      = MouseDoing.Nothing;
     DrawingObject              = null;
     SelectionRectangles        = new List <SelectionRectangle>();
     InclusiveSelection         = false;
     selectedObjects            = new List <DrawableObject>();
     selectedObjectFocusedIndex = -1;
     pastedTimeStamp            = DateTime.Now;
     pastedTimes                = 0;
 }
コード例 #5
0
 public Rectangle GetSelectionRectangle(int margin) => DrawableCollection.GetObjectsRectangle(selectedObjects, margin);