Example #1
0
        public static LibraryItem LoadFromPath(StageView stage, string type, string dataPath)
        {
            LibraryItem result = null;

            if (File.Exists(dataPath)) // todo: account for missing files
            {
                FileStream    fs = new FileStream(dataPath, FileMode.Open);
                XmlSerializer xs = null;
                switch (type)
                {
                case "DDW.Vex.Timeline":
                    xs = new XmlSerializer(typeof(Vex.Timeline));
                    break;

                case "DDW.Vex.Symbol":
                    xs = GetShapeSerializer();
                    break;

                case "DDW.Vex.Image":
                    xs = new XmlSerializer(typeof(Vex.Image));
                    break;
                }

                if (xs != null)
                {
                    Vex.IDefinition def = (Vex.IDefinition)xs.Deserialize(fs);
                    result      = new LibraryItem(stage, def);
                    result.date = File.GetLastWriteTimeUtc(dataPath);
                    result.HasSaveableChanges = false;
                }

                fs.Close();
            }
            return(result);
        }
Example #2
0
        public void UnExecute()
        {
            StageView     stage = MainForm.CurrentStage;
            InstanceGroup sel   = MainForm.CurrentStage.Selection;

            uint[] ids = sel.SelectedIds;

            foreach (Bond b in addedBonds)
            {
                stage.CurrentEditItem.BondStore.RemoveBond(b);
            }

            for (int i = 0; i < ids.Length; i++)
            {
                DesignInstance di = MainForm.CurrentInstanceManager[ids[i]];

                Vex.Matrix m      = di.GetMatrix();
                Vex.Point  offset = new Vex.Point(-offsets[i].X, -offsets[i].Y);
                m.Translate(offset);
                stage.SetDesignInstanceMatrix(di, m);
            }

            if (useSmartBonds)
            {
                foreach (Bond b in previousBonds)
                {
                    stage.CurrentEditItem.BondStore.AddBond(b);
                }
            }

            sel.Update();
            MainForm.CurrentStage.ResetTransformHandles();
            MainForm.CurrentStage.InvalidateTransformedSelection();
        }
        public void Execute()
        {
            StageView stage = MainForm.CurrentStage;

            prevTransforMatrix = stage.Selection.TransformMatrix.VexMatrix();
            prevMatrices       = stage.RemoveSelectionTransform();
        }
Example #4
0
 public LibraryItem(StageView stage, Vex.IDefinition definition)
 {
     this.stage      = stage;
     this.definition = definition;
     this.Date       = (definition.Path == null) ? DateTime.Now.ToUniversalTime() : File.GetLastAccessTimeUtc(definition.Path);
     this.Name       = (definition.Name == null) ? null : definition.Name;
 }
Example #5
0
        public void UnExecute()
        {
            StageView   stage = MainForm.CurrentStage;
            LibraryView currentLibraryView = MainForm.CurrentLibraryView;

            if (addToStage)
            {
                for (int i = 0; i < addInstanceCommands.Count; i++)
                {
                    addInstanceCommands[i].UnExecute();
                }
                addInstanceCommands.Clear();
                stage.InvalidateAll();
            }

            for (int i = 0; i < libraryItems.Length; i++)
            {
                currentLibraryView.RemoveItemFromLibrary(libraryItems[i].DefinitionId);
            }
            libraryItems = null;

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


            stage.HasSaveableChanges = true;
            currentLibraryView.Invalidate();
        }
        public void Execute()
        {
            StageView stage = MainForm.CurrentStage;

            prevLocation = stage.Selection.StrokeBounds.Point;
            stage.ScaleSelectionAt(scaleX, scaleY, scaleCenter);
        }
Example #7
0
        public void UnExecute()
        {
            StageView   stage   = MainForm.CurrentStage;
            Library     lib     = MainForm.CurrentLibrary;
            LibraryView libView = MainForm.CurrentLibraryView;

            for (int i = removedTreeNodes.Length - 1; i >= 0; i--)
            {
                LibraryTreeNode liv = removedTreeNodes[i];
                lib.AddLibraryItem(liv.item);
                libView.InsertNode(liv, removedPaths[i], removedIndexes[i]);
            }

            // todo: need to readd bonds and snaps.
            for (int i = removedInstances.Length - 1; i >= 0; i--)
            {
                stage.AddInstance(removedInstances[i]);
            }

            libView.SelectNode(selectedNode);


            removedInstances = null;
            removedTreeNodes = null;
            removedPaths     = null;
            removedIndexes   = null;
            selectedNode     = null;

            stage.InvalidateAll();
            libView.RefreshCurrentNode();
        }
Example #8
0
        public void Execute()
        {
            StageView stage = MainForm.CurrentStage;

            this.rotateCenter = stage.Selection.GlobalRotationCenter;
            stage.RotateSelectionAt(angle, rotateCenter);
        }
Example #9
0
        public DesignTimeline(StageView stage, Vex.Instance inst) : base(stage, inst)
        {
            selectedItems = new InstanceGroup(stage.InstanceManager);

            SnapStore  = new SnapStore(this);
            BondStore  = new BondStore(this);
            Guidelines = new Guidelines(this);
        }
Example #10
0
 public GdiRenderer(StageView stage)
 {
     this.stage          = stage;
     outlinePen          = new Pen(Color.DarkBlue, 0);
     outlinePen.StartCap = LineCap.Round;
     outlinePen.EndCap   = LineCap.Round;
     outlinePen.LineJoin = LineJoin.Round;
 }
Example #11
0
 void stageView_LostFocus(object sender, EventArgs e)
 {
     if (sender is StageView)
     {
         StageView sv = (StageView)sender;
         OnSelectionChanged(sv, 0);
     }
 }
Example #12
0
 private void Construct(ButtonController buttonController, IButtonContainerUseCase buttonContainerUseCase,
                        IStageObjectContainerUseCase stageObjectContainerUseCase, StageView stageView)
 {
     _buttonController            = buttonController;
     _stageObjectContainerUseCase = stageObjectContainerUseCase;
     _buttonContainerUseCase      = buttonContainerUseCase;
     _stageView = stageView;
 }
        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);
        }
Example #14
0
 public StageObjectFactory(IWriteOnlyPlayerContainer playerContainer, IWriteOnlyFlagContainer flagContainer,
                           IWriteOnlyColorBlockContainer colorBlockContainer, StageView stageView)
 {
     _playerContainer     = playerContainer;
     _flagContainer       = flagContainer;
     _colorBlockContainer = colorBlockContainer;
     _stageView           = stageView;
 }
Example #15
0
 // Use this for initialization
 void Start()
 {
     destroyTimer = Const.DESTROY_EXPLOSION_TIMER;
     model        = new Stage(Const.WIDTH, Const.HEIGHT);
     view         = GetComponent <StageView>();
     view.Width   = Const.WIDTH;
     view.Height  = Const.HEIGHT;
     view.InitiView(model.GetField());
 }
Example #16
0
        public void Execute()
        {
            StageView stage = MainForm.CurrentStage;

            removedBonds = stage.CurrentEditItem.BondStore.GetBondsForInstances(stage.Selection.SelectedIds).ToArray();
            stage.CurrentEditItem.BondStore.RemoveBonds(removedBonds);
            stage.Selection.Update();
            MainForm.CurrentStage.InvalidateSelection();
        }
Example #17
0
        // has selection
        // one selected
        // all selected
        private void OnSelectionChanged(StageView sender, int count)
        {
            bool hasFocus     = currentStage.HasEditFocus();
            int  instCount    = hasFocus ? currentStage.InstanceCount : 0;
            bool hasSelection = hasFocus ? count > 0 : false;

            if ((selectionCount > 0 && count == 0) ||
                (selectionCount == 0 && count > 0) ||
                !hasFocus)
            {
                cutToolStripMenuItem.Enabled        = hasSelection;
                copyToolStripMenuItem.Enabled       = hasSelection;
                deleteMenuItem.Enabled              = hasSelection;
                duplicateMenuItem.Enabled           = hasSelection;
                selectNoneToolStripMenuItem.Enabled = hasSelection;

                flipHorizontalToolStripMenuItem.Enabled  = hasSelection;
                flipVerticalToolStripMenuItem.Enabled    = hasSelection;
                rotateLeft15ToolStripMenuItem.Enabled    = hasSelection;
                rotateRight15ToolStripMenuItem.Enabled   = hasSelection;
                removeTransformToolStripMenuItem.Enabled = hasSelection;
            }

            if (hasSelection)
            {
                breakApartToolStripMenuItem.Enabled = currentStage.CanBreakApart();
            }

            // isTop/isBottom is a bit expensive, so sanity test first
            if (hasSelection && instCount > count)
            {
                DepthChanged();
            }
            else
            {
                toTopToolStripMenuItem.Enabled     = false;
                toBottomToolStripMenuItem.Enabled  = false;
                upOneToolStripMenuItem.Enabled     = false;
                backOneToolStripMenuItem.Enabled   = false;
                infrontOfToolStripMenuItem.Enabled = false;
                behindToolStripMenuItem.Enabled    = false;
            }

            editInPlaceToolStripMenuItem.Enabled = hasFocus && currentStage.CanEditInPlace();

            if (hasFocus && selectionCount == instCount)
            {
                selectAllToolStripMenuItem.Enabled = false;
            }
            else
            {
                selectAllToolStripMenuItem.Enabled = true;
            }

            selectionCount = count;
        }
        public void Execute()
        {
            StageView     stage = MainForm.CurrentStage;
            InstanceGroup sel   = MainForm.CurrentStage.Selection;

            removeBondsCommand.Execute();
            prevSelected = sel.SelectedIds;
            stage.RemoveInstancesById(instanceIds);
            MainForm.CurrentStage.InvalidateTransformedSelection();
        }
Example #19
0
        public void UnExecute()
        {
            StageView stage = MainForm.CurrentStage;

            InstanceGroup sel = stage.Selection;

            stage.RemoveInstancesById(instanceIds);
            sel.Set(prevSelected);
            stage.ResetTransformHandles();
            stage.InvalidateTransformedSelection();
        }
Example #20
0
        private void CreateNewStage(string name)
        {
            Library         lb = new Library();
            InstanceManager im = new InstanceManager();
            StageView       sv = new StageView(lb, im, name);

            sv.GotFocus  += new EventHandler(stageView_GotFocus);
            sv.LostFocus += new EventHandler(stageView_LostFocus);
            stages.Add(sv);
            SetStage(sv);
        }
Example #21
0
        public void UnExecute()
        {
            StageView stage = MainForm.CurrentStage;

            foreach (Bond b in removedBonds)
            {
                stage.CurrentEditItem.BondStore.AddBond(b);
            }
            stage.Selection.Update();
            MainForm.CurrentStage.InvalidateSelection();
        }
Example #22
0
        public void Execute()
        {
            StageView stage = MainForm.CurrentStage;

            for (int i = 0; i < defintions.Length; i++)
            {
                LibraryItem li = stage.CreateLibraryItem(defintions[i], true);
                newLibraryItemId = li.DefinitionId;
                stage.Library.AddLibraryItem(li);
                LibraryView.CurrentLibraryView.AddItemToLibrary(li);
            }
        }
Example #23
0
        private void SetStage(StageView sv)
        {
            if (currentStage != null)
            {
                currentLibraryView.Clear();

                currentStage.OnSelectionChanged  -= OnSelectionChanged;
                currentStage.OnUndoStackChanged  -= OnUndoStackChanged;
                currentStage.OnNestedEditChanged -= OnNestedEditChanged;
                currentStage.FormClosing         -= new FormClosingEventHandler(currentStage_FormClosing);
                currentStage.OnDepthChanged      -= OnDepthChanged;
                currentStage = null;
            }

            if (sv != null)
            {
                if (sv.rootFolder != null)
                {
                    Environment.CurrentDirectory = sv.rootFolder;
                }

                currentStage = sv;
                currentLibraryView.LoadCurrentLibrary();

                sv.Show(dockPanel);

                currentStage.OnSelectionChanged  += OnSelectionChanged;
                currentStage.OnUndoStackChanged  += OnUndoStackChanged;
                currentStage.OnNestedEditChanged += OnNestedEditChanged;
                currentStage.OnDepthChanged      += OnDepthChanged;
                currentStage.FormClosing         += new FormClosingEventHandler(currentStage_FormClosing);
                currentStage.Invalidate();

                saveToolStripMenuItem.Enabled         = currentStage.HasSaveableChanges;
                importToolStripMenuItem.Enabled       = true;
                saveAsToolStripMenuItem.Enabled       = true;
                closeToolStripMenuItem.Enabled        = true;
                exportSVGToolStripMenuItem.Enabled    = true;
                exportXAMLToolStripMenuItem.Enabled   = true;
                exportCanvasToolStripMenuItem.Enabled = true;
            }
            else
            {
                saveToolStripMenuItem.Enabled         = false;
                importToolStripMenuItem.Enabled       = false;
                saveAsToolStripMenuItem.Enabled       = false;
                closeToolStripMenuItem.Enabled        = false;
                exportSVGToolStripMenuItem.Enabled    = false;
                exportXAMLToolStripMenuItem.Enabled   = false;
                exportCanvasToolStripMenuItem.Enabled = false;
            }
        }
Example #24
0
        public void UnExecute()
        {
            StageView stage = MainForm.CurrentStage;

            uint[] selIds = stage.Selection.SelectedIds;
            foreach (uint id in selIds)
            {
                DesignInstance di = stage.InstanceManager[id];
                di.AspectConstraint = prevConstraint;
            }

            stage.Selection.Update();
            MainForm.CurrentStage.InvalidateSelection();
        }
Example #25
0
        public Rulers(StageView stage)
        {
            this.stage = stage;

            topLeftBox     = new Rectangle(-RulerSize, -RulerSize, RulerSize, RulerSize);
            topLeftOutline = new Point[] {
                new Point(-RulerSize + 1, -RulerSize + 1),
                new Point(-RulerSize + 1, -2),
                new Point(-2, -2),
                new Point(-2, -RulerSize + 1),
                new Point(-RulerSize + 1, -RulerSize + 1)
            };

            guidePen.DashStyle   = DashStyle.Dash;
            guidePen.DashPattern = new float[] { 2f, 3f };
        }
Example #26
0
        public void UnExecute()
        {
            StageView stage = MainForm.CurrentStage;
            //DDW.Display.DesignTimeline curEditItem = stage.CurrentEditItem;
            InstanceGroup sel = stage.Selection;

            stage.RemoveInstancesById(newInstances);

            for (int i = 0; i < prevInstances.Length; i++)
            {
                stage.InsertExistingInstance(prevDepths[i], MainForm.CurrentInstanceManager[prevInstances[i]]);
            }

            sel.Set(prevSelection);
            stage.ResetTransformHandles();
            stage.InvalidateSelection();
        }
Example #27
0
        public static DesignInstance LoadFromPath(StageView stage, string type, string dataPath)
        {
            DesignInstance result = null;

            FileStream    fs = new FileStream(dataPath, FileMode.Open);
            XmlSerializer xs = new XmlSerializer(typeof(Vex.Instance));

            Vex.Instance inst = (Vex.Instance)xs.Deserialize(fs);
            fs.Close();

            result = stage.CreateInstance(inst);
            if (result != null)
            {
                result.HasSaveableChanges = false;
            }
            return(result);
        }
        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();
        }
Example #29
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();
        }
Example #30
0
        public void UnExecute()
        {
            StageView sv = MainForm.CurrentStage;

            if (isBegin)
            {
                sv.EditInPlacePop(popCount);
            }
            else
            {
                // can push into multiple levels at once
                // when undoing a bread crumbs click
                for (int i = instanceId.Length - 1; i >= 0; i--)
                {
                    sv.EditInPlacePush(instanceId[i]);
                }
            }
        }