コード例 #1
0
        public void Execute()
        {
            StageView stage = MainForm.CurrentStage;

            prevLocation = stage.Selection.StrokeBounds.Point;
            stage.ScaleSelectionAt(scaleX, scaleY, scaleCenter);
        }
コード例 #2
0
        public Matrix GetRotatedMatrix(float angle, Vex.Point center)
        {
            Matrix m = transformMatrix.Clone();

            m.RotateAt(angle, center.SysPointF(), MatrixOrder.Append);
            return(m);
        }
コード例 #3
0
        public void ScaleAt(float scaleX, float scaleY, Vex.Point center)
        {
            scaleX = (Math.Abs(scaleX) < .01) ? .01f : scaleX;
            scaleY = (Math.Abs(scaleY) < .01) ? .01f : scaleY;

            Matrix tm = TransformMatrix.Clone();

            tm.Translate(-TransformMatrix.OffsetX, -TransformMatrix.OffsetY, MatrixOrder.Append);
            Matrix itm = tm.Clone();

            itm.Invert();

            foreach (uint id in list)
            {
                DesignInstance inst = instanceManager[id];

                using (Matrix ms = inst.GetMatrix().SysMatrix())
                {
                    ms.Translate(-center.X, -center.Y, MatrixOrder.Append);
                    ms.Multiply(itm, MatrixOrder.Append);
                    ms.Scale(scaleX, scaleY, MatrixOrder.Append);
                    ms.Multiply(tm, MatrixOrder.Append);
                    ms.Translate(center.X, center.Y, MatrixOrder.Append);

                    inst.SetMatrix(ms.VexMatrix());
                }
            }
            tm.Dispose();
            itm.Dispose();

            transformMatrix.ScaleAt(scaleX, scaleY, center.SysPointF());
            isDirty = true;
            MainForm.CurrentStage.InvalidateTransformedSelection();
        }
コード例 #4
0
        public Matrix GetScaledMatrix(float scaleX, float scaleY, Vex.Point center)
        {
            Matrix m = transformMatrix.Clone();

            m.ScaleAt(scaleX, scaleY, center.SysPointF());
            return(m);
        }
コード例 #5
0
ファイル: ColorMask.cs プロジェクト: lardratboy/it3rate
        public static Vex.Point GetScalingOrigin(this ColorMask colorMask, Vex.Rectangle r)
        {
            Vex.Point result = r.Point;
            switch (colorMask)
            {
            case ColorMask.ScaleTopLeft:
            case ColorMask.ScaleLeftCenter:
            case ColorMask.ScaleTopCenter:
            case ColorMask.RulerSelLeft:
            case ColorMask.RulerSelTop:
                result = new Vex.Point(r.Right, r.Bottom);
                break;

            case ColorMask.ScaleTopRight:
                result = new Vex.Point(r.Left, r.Bottom);
                break;

            case ColorMask.ScaleBottomRight:
            case ColorMask.ScaleBottomCenter:
            case ColorMask.ScaleRightCenter:
            case ColorMask.RulerSelRight:
            case ColorMask.RulerSelBottom:
                result = r.Point;
                break;

            case ColorMask.ScaleBottomLeft:
                result = new Vex.Point(r.Right, r.Top);
                break;
            }
            return(result);
        }
コード例 #6
0
 public ImportFileCommand(string filename, Vex.Point location)
 {
     this.filename       = filename;
     this.location       = location;
     addToStage          = true;
     addInstanceCommands = new List <AddInstancesCommand>();
 }
コード例 #7
0
        public void Execute()
        {
            StageView stage = MainForm.CurrentStage;

            this.rotateCenter = stage.Selection.GlobalRotationCenter;
            stage.RotateSelectionAt(angle, rotateCenter);
        }
コード例 #8
0
        public void ResetTransform()
        {
            if (transformMatrix != null)
            {
                transformMatrix.Dispose();
            }

            if (list.Count == 1)
            {
                DesignInstance di = instanceManager[list[0]];
                transformMatrix     = di.GetMatrix().SysMatrix();
                center              = di.RotationCenter;
                untransformedBounds = di.Definition.StrokeBounds;//.TranslatedRectangle(-di.Location.X, -di.Location.Y);
            }
            else
            {
                transformMatrix = new Matrix();
                transformMatrix.Translate(StrokeBounds.Left, StrokeBounds.Top, MatrixOrder.Append);
                center = StrokeBounds.LocalCenter;
                //center = StrokeBounds.LocalCenter.Translate(StrokeBounds.Point);
                untransformedBounds = StrokeBounds.TranslatedRectangle(-StrokeBounds.Left, -StrokeBounds.Top);
            }

            isTransformDirty = false;
        }
コード例 #9
0
        public void AppendNudge(int xAmount, int yAmount)
        {
            StageView stage = MainForm.CurrentStage;

            stage.TranslateSelection(new Vex.Point(xAmount, yAmount), false, addedBonds, previousBonds);

            offset = new Vex.Point(offset.X + xAmount, offset.Y + yAmount);
        }
コード例 #10
0
        public void TranslateSelection(Vex.Point offset)
        {
            Dictionary <uint, Vex.Rectangle> alreadyDiscovered = new Dictionary <uint, Vex.Rectangle>();

            MainForm.CurrentStage.CurrentEditItem.BondStore.GetRelatedObjectTransforms(list, alreadyDiscovered, offset);
            relatedIds = alreadyDiscovered.Keys.ToArray();
            foreach (uint id in alreadyDiscovered.Keys)
            {
                TranslateElement(id, alreadyDiscovered[id].Left, alreadyDiscovered[id].Top);
            }

            ResetTransform();
            MainForm.CurrentStage.InvalidateTransformedSelection();
        }
コード例 #11
0
        public void RotateAt(float angle, Vex.Point center)
        {
            foreach (uint id in list)
            {
                DesignInstance inst = instanceManager[id];
                using (Matrix mr = inst.GetMatrix().SysMatrix())
                {
                    mr.RotateAt(angle, center.SysPointF(), MatrixOrder.Append);
                    inst.SetMatrix(mr.VexMatrix());
                }
            }

            transformMatrix.RotateAt(angle, center.SysPointF(), MatrixOrder.Append);
            isDirty = true;
            MainForm.CurrentStage.InvalidateTransformedSelection();
        }
コード例 #12
0
        public void DrawRotated(Graphics g, float angle, Vex.Point center)
        {
            Matrix m = g.Transform;

            foreach (uint id in list)
            {
                DesignInstance inst = instanceManager[id];
                using (Matrix mr = inst.GetMatrix().SysMatrix())
                {
                    mr.RotateAt(angle, center.SysPointF(), MatrixOrder.Append);
                    mr.Multiply(m, MatrixOrder.Append);
                    g.Transform = mr;
                    inst.DrawOutlineIntoRaw(g, 0, 0);
                }
            }
            g.Transform = m;
        }
コード例 #13
0
        public void Execute()
        {
            StageView   stage = MainForm.CurrentStage;
            LibraryView currentLibraryView = MainForm.CurrentLibraryView;

            string ext = Path.GetExtension(filename).ToUpperInvariant();

            if (ext == ".SWF")
            {
                libraryItems = currentLibraryView.AddSwf(filename);
            }
            else if (ext == ".BMP" || ext == ".JPG" || ext == ".GIF" || ext == ".PNG")
            {
                libraryItems = new LibraryItem[] { currentLibraryView.AddImage(filename) };
            }

            if (currentLibraryView.GetSelectedNode() == null && libraryItems.Length > 0)
            {
                currentLibraryView.SelectNode(libraryItems[0].DefinitionId);
            }
            else
            {
                currentLibraryView.RefreshCurrentNode();
            }

            if (addToStage)
            {
                uint[]      itemIds = new uint[libraryItems.Length];
                Vex.Point[] locs    = new Vex.Point[libraryItems.Length];

                for (int i = 0; i < libraryItems.Length; i++)
                {
                    itemIds[i] = libraryItems[i].Definition.Id;
                    Vex.Point centerOffset = libraryItems[i].Definition.StrokeBounds.Center.Negate();
                    locs[i] = location.Translate(centerOffset);
                }
                AddInstancesCommand aic = new AddInstancesCommand(itemIds, locs);
                aic.Execute();
                addInstanceCommands.Add(aic);
                stage.InvalidateAll();
            }

            stage.HasSaveableChanges = true;
            currentLibraryView.Invalidate();
        }
コード例 #14
0
        public void Execute()
        {
            StageView stage = MainForm.CurrentStage;

            // store old selection
            prevSelected = stage.Selection.IdsByDepth;// SelectedIds;
            prevOffset   = stage.Selection.StrokeBounds.Point;


            // create symbol from selected
            Vex.Timeline tl = new Vex.Timeline(stage.Library.NextLibraryId());

            tl.Name         = stage.Library.GetNextDefaultName();
            tl.StrokeBounds = stage.Selection.StrokeBounds.TranslatedRectangle(-prevOffset.X, -prevOffset.Y);

            // delete old symbols
            DesignInstance[] oldInstances = stage.RemoveInstancesById(prevSelected);

            for (int i = 0; i < prevSelected.Length; i++)
            {
                DesignInstance inst = oldInstances[i];// instMgr[prevSelected[i]];
                Vex.Matrix     m    = inst.GetMatrix();
                m.TranslateX -= prevOffset.X;
                m.TranslateY -= prevOffset.Y;
                inst.SetMatrix(m);
                tl.AddInstance(inst.Instance);
                stage.InstanceManager.AddInstance(inst); // reusing, so must readd (todo: don't  reuse ids?)
            }

            LibraryItem li = stage.CreateLibraryItem(tl, true);

            newLibraryItemId = li.DefinitionId;
            stage.Library.AddLibraryItem(li);
            LibraryView.CurrentLibraryView.AddItemToLibrary(li);

            // add new symbol to stage
            DesignInstance di = stage.AddInstance(tl.Id, prevOffset);

            newInstanceId = di.InstanceHash;

            // select new symbol
            stage.Selection.Set(new uint[] { di.InstanceHash });
            stage.ResetTransformHandles();
            stage.InvalidateSelection();
        }
コード例 #15
0
ファイル: ColorMask.cs プロジェクト: lardratboy/it3rate
        public static Vex.Point GetHandleOffset(this ColorMask colorMask, Vex.Rectangle r, Vex.Point mouseDownLocation)
        {
            Vex.Point result = Vex.Point.Zero;
            switch (colorMask)
            {
            case ColorMask.ScaleTopLeft:
            case ColorMask.RotateTopLeft:
                result = mouseDownLocation.Translate(new Vex.Point(-r.Left, -r.Top));
                break;

            case ColorMask.ScaleTopRight:
            case ColorMask.RotateTopRight:
                result = mouseDownLocation.Translate(new Vex.Point(-r.Right, -r.Top));
                break;

            case ColorMask.ScaleBottomRight:
            case ColorMask.RotateBottomRight:
                result = mouseDownLocation.Translate(new Vex.Point(-r.Right, -r.Bottom));
                break;

            case ColorMask.ScaleBottomLeft:
            case ColorMask.RotateBottomLeft:
                result = mouseDownLocation.Translate(new Vex.Point(-r.Left, -r.Bottom));
                break;

            case ColorMask.RulerSelLeft:
                result = mouseDownLocation.Translate(new Vex.Point(-r.Left, 0));
                break;

            case ColorMask.RulerSelTop:
                result = mouseDownLocation.Translate(new Vex.Point(0, -r.Top));
                break;

            case ColorMask.RulerSelRight:
                result = mouseDownLocation.Translate(new Vex.Point(-r.Right, 0));
                break;

            case ColorMask.RulerSelBottom:
                result = mouseDownLocation.Translate(new Vex.Point(0, -r.Bottom));
                break;
            }
            return(result);
        }
コード例 #16
0
        public void Execute()
        {
            StageView stage = MainForm.CurrentStage;

            InstanceGroup sel = stage.Selection;

            this.prevSelected = sel.SelectedIds;

            Vex.Point selRotCent = sel.GlobalRotationCenter.Translate(sel.Location.Negate());

            uint[]      libraryIds = new uint[prevSelected.Length];
            Vex.Point[] locations  = new Vex.Point[prevSelected.Length];
            for (int i = 0; i < prevSelected.Length; i++)
            {
                DesignInstance di = MainForm.CurrentInstanceManager[prevSelected[i]];
                libraryIds[i] = di.LibraryItem.DefinitionId;
                locations[i]  = new Vex.Point(di.Location.X + offset.X, di.Location.Y + offset.Y);
            }

            if (newInstanceIds == null)
            {
                newInstanceIds = stage.AddInstances(libraryIds, locations);
                for (int i = 0; i < newInstanceIds.Length; i++)
                {
                    DesignInstance oldDi = MainForm.CurrentInstanceManager[prevSelected[i]];
                    DesignInstance newDi = MainForm.CurrentInstanceManager[newInstanceIds[i]];
                    Vex.Matrix     m     = oldDi.GetMatrix();
                    stage.SetDesignInstanceMatrix(newDi, new Vex.Matrix(m.ScaleX, m.Rotate0, m.Rotate1, m.ScaleY, newDi.Location.X, newDi.Location.Y));

                    newDi.RotationCenter = oldDi.RotationCenter;
                }
            }
            else
            {
                stage.AddInstancesById(newInstanceIds);
            }

            sel.Set(newInstanceIds);
            sel.GlobalRotationCenter = selRotCent.Translate(sel.Location);
            stage.ResetTransformHandles();
            stage.InvalidateTransformedSelection();
        }
コード例 #17
0
        public void DrawScaled(Graphics g, float scaleX, float scaleY, Vex.Point center)
        {
            Matrix m = g.Transform;

            scaleX = (Math.Abs(scaleX) < .01) ? .01f : scaleX;
            scaleY = (Math.Abs(scaleY) < .01) ? .01f : scaleY;

            Matrix tm = TransformMatrix.Clone();

            tm.Translate(-TransformMatrix.OffsetX, -TransformMatrix.OffsetY, MatrixOrder.Append);
            Matrix itm = tm.Clone();

            itm.Invert();

            foreach (uint id in list)
            {
                DesignInstance inst = instanceManager[id];

                using (Matrix ms = inst.GetMatrix().SysMatrix())
                {
                    ms.Translate(-center.X, -center.Y, MatrixOrder.Append);
                    ms.Multiply(itm, MatrixOrder.Append);
                    ms.Scale(scaleX, scaleY, MatrixOrder.Append);
                    ms.Multiply(tm, MatrixOrder.Append);
                    ms.Translate(center.X, center.Y, MatrixOrder.Append);

                    ms.Multiply(m, MatrixOrder.Append);
                    g.Transform = ms;
                    inst.DrawOutlineIntoRaw(g, 0, 0);
                }
            }

            tm.Dispose();
            itm.Dispose();

            g.Transform = m;
        }
コード例 #18
0
        public Vex.Rectangle CalculateBounds(uint[] instances, out Vex.Point topLeft)
        {
            Vex.Rectangle bounds = Vex.Rectangle.Empty;
            float         top    = int.MaxValue;
            float         left   = int.MaxValue;

            foreach (uint id in instances)
            {
                DesignInstance inst = instanceManager[id];
                if (bounds.IsEmpty)
                {
                    bounds = inst.StrokeBounds;
                }
                else
                {
                    bounds = inst.StrokeBounds.Union(bounds);// Rectangle.Union(bounds, inst.Bounds);
                }

                left = Math.Min(left, inst.Location.X);
                top  = Math.Min(top, inst.Location.Y);
            }
            topLeft = new Vex.Point(left, top);
            return(bounds);
        }
コード例 #19
0
 public ScaleTransformCommand(float scaleX, float scaleY, Vex.Point scaleCenter)
 {
     this.scaleX      = scaleX;
     this.scaleY      = scaleY;
     this.scaleCenter = scaleCenter;
 }
コード例 #20
0
 public Vex.Point LocalToTransform(Vex.Point p)
 {
     return(Gdi.GdiRenderer.GetTransformedPoint(p.SysPointF(), TransformMatrix, false).VexPoint());
 }
コード例 #21
0
 public Vex.Point TransformToLocal(Vex.Point p)
 {
     return(Gdi.GdiRenderer.GetTransformedPoint(p.SysPointF(), TransformMatrix, true).VexPoint());
 }
コード例 #22
0
 public DuplicateSelectedCommand(Vex.Point offset)
 {
     this.offset = offset;
 }
コード例 #23
0
 public NudgeSelectionCommand(float xAmount, float yAmount)
 {
     offset = new Vex.Point(xAmount, yAmount);
 }
コード例 #24
0
 public TranslateRotationCenterCommand(Vex.Point prevLocation, Vex.Point newLocation)
 {
     this.prevLocation = prevLocation;
     this.newLocation  = newLocation;
 }
コード例 #25
0
 public void Translate(Vex.Point p)
 {
     TranslateX += p.X;
     TranslateY += p.Y;
 }
コード例 #26
0
        public void Execute()
        {
            StageView       stage   = MainForm.CurrentStage;
            InstanceGroup   sel     = stage.Selection;
            InstanceManager instMgr = stage.InstanceManager;

            prevSelection = sel.IdsByDepth;
            List <uint> addedInstances = new List <uint>();

            List <uint> newSelection   = new List <uint>();
            List <uint> toBreakApart   = new List <uint>();
            List <int>  originalDepths = new List <int>();

            for (int i = 0; i < prevSelection.Length; i++)
            {
                DesignInstance di = instMgr[prevSelection[i]];
                if (CanBreakApart(di))
                {
                    toBreakApart.Add(prevSelection[i]);
                    originalDepths.Add(di.Depth);
                }
                else
                {
                    newSelection.Add(prevSelection[i]);
                }
            }

            prevInstances = toBreakApart.ToArray();
            prevDepths    = originalDepths.ToArray();

            sel.Clear();
            for (int i = 0; i < toBreakApart.Count; i++)
            {
                uint           id        = toBreakApart[i];
                DesignInstance di        = instMgr[id];
                int            orgDepth  = di.Depth;
                Matrix         orgMatrix = di.GetSysMatrix();

                Vex.Point offset    = di.Location;
                uint[]    instances = ((DesignTimeline)di).InstanceIds;

                for (int j = instances.Length - 1; j >= 0; j--)
                {
                    DesignInstance orgInstance = instMgr[instances[j]];
                    uint           subLibId    = orgInstance.LibraryItem.DefinitionId;
                    DesignInstance inst        = stage.AddInstance(subLibId, Vex.Point.Zero);
                    stage.CurrentEditItem.ChangeDepth(inst.Depth, orgDepth);

                    using (Matrix m = orgInstance.GetSysMatrix().Clone())
                    {
                        m.Multiply(orgMatrix, MatrixOrder.Append);
                        stage.SetDesignInstanceMatrix(inst, m.VexMatrix());
                    }

                    addedInstances.Add(inst.InstanceHash);
                    newSelection.Add(inst.InstanceHash);
                }
                stage.RemoveInstancesById(new uint[] { id });
            }

            newInstances = addedInstances.ToArray();
            sel.Set(newSelection.ToArray());
            stage.ResetTransformHandles();
        }