public void ShouldReturnCorrectSuperHappyCornersSumOfShapeCollection()
        {
            //Arrange
            var shapeCollection = new ShapeCollection();

            shapeCollection.Add(new Triangle(2, 3)
            {
                Mood = MoodTypes.SuperHappy
            });
            shapeCollection.Add(new Square(2)
            {
                Mood = MoodTypes.SuperHappy
            });
            shapeCollection.Add(new Rectangle(4, 3)
            {
                Mood = MoodTypes.SuperHappy
            });
            shapeCollection.Add(new Circle(5)
            {
                Mood = MoodTypes.SuperHappy
            });

            //Act
            //Assert
            Assert.AreEqual(shapeCollection.CornerSum(), 11 * 3 + 10);
        }
示例#2
0
        /// <summary>
        /// Overridden save function
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        public override bool Save(string filename)
        {
            PrefabDesc      prefab = new PrefabDesc(filename);
            ShapeCollection all    = new ShapeCollection();

            // the following shapes go into the prefab: lightgrid boxes, lights
            foreach (ShapeBase shape in this.FilteredSupplier)
            {
                all.Add(shape);
            }

            foreach (ShapeBase shape in this.FilteredLights)
            {
                if (!all.Contains(shape))
                {
                    all.Add(shape);
                }
            }

            if (!prefab.CreateFromInstances(all, Vector3F.Zero, false, false))
            {
                return(false);
            }
            return(prefab.SaveToFile(null));
        }
示例#3
0
        /// <summary>
        /// 布局线路 
        /// </summary>
        /// <param name="pshape"></param>
        void layeroutmx(BaseShape pshape)
        {
            ShapeCollection childshapes = pshape.GetChildShapes();

            if (pshape is MX1Shape)
            {
                MX1Shape mx1 = pshape as MX1Shape;
                mx1.Width           = Math.Max(mx1.Width, 40 * childshapes.Count);
                mx1.ConnectorNumber = childshapes.Count;
            }
            foreach (Connector cr in pshape.Connectors)
            {
                if (cr.ConnectorLocation == ConnectorLocation.South)
                {
                    foreach (Connection cn in cr.Connections)
                    {
                        Connector crto = cn.From;
                        if (cn.From == cr)
                        {
                            crto = cn.To;
                        }
                        if (!movedshapes.Contains(crto.BelongsTo))
                        {
                            movedshapes.Add(crto.BelongsTo);
                            PointF pf1  = crto.BelongsTo.ConnectionPoint(crto);
                            PointF pf2  = cr.BelongsTo.ConnectionPoint(cr);
                            float  offx = pf2.X - pf1.X;
                            float  offy = 50;
                            crto.BelongsTo.X += offx;
                            crto.BelongsTo.Y += offy;
                        }
                    }
                }
            }
            float xlright = 0;  //线路右边范围
            int   xlnum   = -1; //有设备的线路

            foreach (BaseShape sp1 in childshapes)
            {
                if (!layershapes.Contains(sp1))
                {
                    layershapes.Add(sp1);
                    {
                        if (sp1.GetChildShapes().Count > 1)
                        {
                            if (xlright > sp1.X)
                            {
                                sp1.X = xlright + 30;
                            }
                            if (sp1.DeviceType != "01")
                            {
                                sp1.Y -= xlnum * 3; xlnum++;
                            }
                            layeroutsb(sp1, ref xlright);
                        }
                    }
                }
            }
            curWidth = Math.Max(xlright, pshape.X + pshape.Width);
        }
        public void ShouldReturnCorrectSuperHappyAreaSumOfShapeCollection()
        {
            //Arrange
            var shapeCollection = new ShapeCollection();

            shapeCollection.Add(new Triangle(2, 3)
            {
                Mood = MoodTypes.SuperHappy
            });                                                                     //3
            shapeCollection.Add(new Square(2)
            {
                Mood = MoodTypes.SuperHappy
            });                                                                //4
            shapeCollection.Add(new Square(3)
            {
                Mood = MoodTypes.SuperHappy
            });                                                                //9
            shapeCollection.Add(new Circle(5)
            {
                Mood = MoodTypes.SuperHappy
            });                                                                //78.5875

            //Act
            //Assert
            Assert.AreEqual(shapeCollection.AreaSum(), 94.5375f * 3);
        }
示例#5
0
        public void SelectUIShape(UIShapeBase shape)
        {
            if (m_bCopying == true)
            {
                return;
            }

            if (m_selectedShapeList.Contains(shape) == false)
            {
                m_selectedShapeList.Add(shape);                        // 선택에 넣음
            }
            if (shape == m_baseDialog || shape.Parent == m_baseDialog) // 작업 다이얼로그는 그대로
            {
                m_UIShapeList.Clear();

                foreach (ShapeBase child in m_baseDialog.ChildCollection)
                {
                    if (child is UIShapeBase)
                    {
                        m_UIShapeList.Add(child as UIShapeBase);
                    }
                }

                m_UIShapeList.Add(m_baseDialog); // 다이얼로그는 제일 마지막에 추가 ( 나중에 검색할때 가장 나중에 검색되도록 )

                return;
            }

            // 작업 다이얼로그가 변경됨
            if (shape is UIShapeDialog)
            {
                m_baseDialog = shape as UIShapeDialog;
            }
            else if (shape.Parent is UIShapeDialog)
            {
                m_baseDialog = shape.Parent as UIShapeDialog;
            }
            else
            {
                return;
            }

            m_UIShapeList.Clear();
            foreach (ShapeBase child in m_baseDialog.ChildCollection)
            {
                if (child is UIShapeBase)
                {
                    m_UIShapeList.Add(child as UIShapeBase);
                }
            }

            m_UIShapeList.Add(m_baseDialog); // 다이얼로그는 제일 마지막에 추가 ( 나중에 검색할때 가장 나중에 검색되도록 )
        }
        public void ShouldReturnCorrectCornersSumOfShapeCollection()
        {
            //Arrange
            var shapeCollection = new ShapeCollection();

            shapeCollection.Add(new Triangle(2, 3));
            shapeCollection.Add(new Square(2));
            shapeCollection.Add(new Rectangle(4, 3));
            shapeCollection.Add(new Circle(4));

            //Act
            //Assert
            Assert.AreEqual(shapeCollection.CornerSum(), 11);
        }
        public void ShouldReturnCorrectAreaSumOfShapeCollection()
        {
            //Arrange
            var shapeCollection = new ShapeCollection();

            shapeCollection.Add(new Triangle(2, 3)); //3
            shapeCollection.Add(new Square(2));      //4
            shapeCollection.Add(new Square(3));      //9
            shapeCollection.Add(new Circle(5));      //78.5875

            //Act
            //Assert
            Assert.AreEqual(shapeCollection.AreaSum(), 94.5375f);
        }
    public void SetUp()
    {
      TestManager.Helpers.CreateTestScene("TransformActionTests.scene");

      _testShapes.Add( new Shape3D("1") );
      _testShapes.Add( new Shape3D("2") );

      Layer layer = EditorManager.Scene.ActiveLayer;
      EditorManager.Actions.Add(AddShapesAction.CreateAddShapesAction(_testShapes, null,layer,false, "add"));
      
      // setup property changed listener
      ResetPropertyChanged();
      EditorScene.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged);
    }
示例#9
0
 public ShapeBase AddShape(ShapeBase shape)
 {
     shapes.Add(shape);
     shape.Site = this;
     this.Invalidate(true);
     return(shape);
 }
        private void windowLoadedHandler()
        {
            // Load sections from database and display on canvas
            _storeSectionList = _db.TableStoreSection.GetAllStoreSections(_floorplanID);
            foreach (var section in _storeSectionList)
            {
                SectionShape loadedSectionShape = new SectionShape();
                loadedSectionShape.Top   = section.CoordinateY;
                loadedSectionShape.Left  = section.CoordinateX;
                loadedSectionShape.Shape = ShapeButtonCreator.CreateShapeForButton();
                loadedSectionShape.Name  = "Button" + section.StoreSectionID;
                loadedSectionShape.ID    = section.StoreSectionID;

                ShapeCollection.Add(loadedSectionShape);
            }

            // Load items from database and display on itemdatagrid
            ListOfItems.Populate(_db.TableItem.SearchItems(""));


            // Load floorplan and display on canvas
            _db.TableFloorplan.DownloadFloorplan(@"../../images/");

            FloorplanImage = null;
            ImageBrush       floorplanImgBrush = new ImageBrush();
            RefreshableImage refresh           = new RefreshableImage();
            BitmapImage      result            = refresh.Get("../../images/floorplan.jpg");

            floorplanImgBrush.ImageSource = result;
            FloorplanImage = floorplanImgBrush;
        }
示例#11
0
        private void recentItem_Click(object sender, EventArgs e)
        {
            this.Focus();
            ToolStripMenuItem recentItem = sender as ToolStripMenuItem;

            if (recentItem == null)
            {
                return;
            }

            object obj = recentItem.Tag;

            if (obj == null)
            {
                return;
            }

            if (obj.GetType() == typeof(Layer) || obj.GetType() == typeof(V3DLayer))
            {
                IScene.SendLayerChangedEvent(new LayerChangedArgs((Layer)obj, null, LayerChangedArgs.Action.Selected));
            }
            else if (obj.GetType() == typeof(Zone))
            {
                IScene.SendZoneChangedEvent(new ZoneChangedArgs((Zone)obj, ZoneChangedArgs.Action.Selected));
            }
            else
            {
                ShapeCollection shapes = new ShapeCollection();
                shapes.Add((ShapeBase)obj);
                EditorManager.SelectedShapes = shapes;

                // Fire event manually in case selection was the same (so event will not get fired)
                EditorManager.OnShapeSelectionChanged(new ShapeSelectionChangedArgs(null, shapes));
            }
        }
示例#12
0
        private void SelectEntities(ShapeBase shape, String classText, String modelText, ShapeCollection sel)
        {
            //check the entity
            EntityShape entity = shape as EntityShape;

            if (entity != null)
            {
                bool bSelect = true;

                if (checkEntityClass.Checked)
                {
                    bSelect &= (entity.EntityClass.ToUpper().IndexOf(classText) != -1);
                }
                if (checkModel.Checked)
                {
                    bSelect &= (entity.ModelFile.ToUpper().IndexOf(modelText) != -1);
                }

                if (bSelect)
                {
                    sel.Add(shape);
                }
            }

            //check it's children
            foreach (ShapeBase child in shape.ChildCollection)
            {
                SelectEntities(child, classText, modelText, sel);
            }
        }
        /// <summary>
        /// Overridden save function
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        public override bool Save(string filename)
        {
            PrefabDesc prefab = new PrefabDesc(filename);
              ShapeCollection all = new ShapeCollection();

              // the following shapes go into the prefab: lightgrid boxes, lights
              foreach (ShapeBase shape in this.FilteredSupplier)
            all.Add(shape);

              foreach (ShapeBase shape in this.FilteredLights)
            if (!all.Contains(shape))
              all.Add(shape);

              if (!prefab.CreateFromInstances(all, Vector3F.Zero, false, false))
            return false;
              return prefab.SaveToFile(null);
        }
示例#14
0
 /// <summary>
 /// Alternative constructor that takes a single shape
 /// </summary>
 /// <param name="shape"></param>
 /// <param name="mode"></param>
 /// <param name="axis"></param>
 /// <param name="includeShapes"></param>
 public DropToFloorAction(Shape3D shape, Shape3D.DropToFloorMode mode, Vector3F axis, bool includeShapes)
     : base("Drop to Floor")
 {
     _shapes = new ShapeCollection();
     _shapes.Add(shape);
     _mode          = mode;
     _axis          = axis;
     _includeShapes = includeShapes;
 }
示例#15
0
 /// <summary>
 /// Alternative constructor that takes a single shape
 /// </summary>
 /// <param name="shape"></param>
 /// <param name="mode"></param>
 /// <param name="axis"></param>
 /// <param name="includeShapes"></param>
 public DropToFloorAction(Shape3D shape, Shape3D.DropToFloorMode mode, Vector3F axis, bool includeShapes)
     : base("Drop to Floor")
 {
     _shapes = new ShapeCollection();
       _shapes.Add(shape);
       _mode = mode;
       _axis = axis;
       _includeShapes = includeShapes;
 }
示例#16
0
        /// <summary>
        /// Mouse down function.
        /// </summary>
        /// <param name="document">Informations transferred from DrawingPanel.</param>
        /// <param name="e">MouseEventArgs.</param>
        public override void MouseDown(IDocument document, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            base.MouseDown(document, e);


            //Added By rm 920617

            ShapeCollection sTemp = new ShapeCollection();

            foreach (var ss in document.Shapes)
            {
                if (ss is BodyBackground)
                {
                    continue;
                }
                sTemp.Add(ss);
            }
            //Added By rm 920617



            //if (Control.ModifierKeys == Keys.Control && ((document.DrawingControl as DrawingPanel).BackgroundLayer != null))
            //  {
            //      _tool = new Hand();
            //  }
            //else
            {
                // HitPositions hitPosition = SelectShape(document.Shapes, e.Location); //Commented By rm 920617

                HitPositions hitPosition = SelectShape(sTemp, e.Location);

                switch (hitPosition)
                {
                case HitPositions.Center:
                    _tool = new Move();
                    break;

                case HitPositions.None:
                    _tool = new MultiSelect();
                    break;

                default:
                    _tool = new Resize();
                    break;
                }
            }



            _tool.MouseDown(document, e);
        }
示例#17
0
        public void Add_ShouldAddTargetedInstanceInCollection()
        {
            AbstractShape   expectedShape         = new Square("SqareName", 44);
            ShapeCollection actualShapeCollection = new ShapeCollection();

            actualShapeCollection.Add(expectedShape);

            Assert.AreEqual(1, actualShapeCollection.Count);

            Assert.AreEqual(expectedShape.Name, actualShapeCollection.Single <AbstractShape>().Name);
            Assert.AreEqual(expectedShape.Surface, actualShapeCollection.Single <AbstractShape>().Surface);
        }
        public static void Run()
        {
            // ExStart:ConvertVisioWithSelectiveShapes
            // the path to the documents directory.
            string dataDir = RunExamples.GetDataDir_LoadSaveConvert();

            // call the diagram constructor to load diagram from a VSD file
            Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx");

            // create an instance SVG save options class
            SVGSaveOptions  options = new SVGSaveOptions();
            ShapeCollection shapes  = options.Shapes;

            // get shapes by page index and shape ID, and then add in the shape collection object
            shapes.Add(diagram.Pages[0].Shapes.GetShape(1));
            shapes.Add(diagram.Pages[0].Shapes.GetShape(2));

            // save Visio drawing
            diagram.Save(dataDir + "SelectiveShapes_out.svg", options);
            // ExEnd:ConvertVisioWithSelectiveShapes
        }
示例#19
0
        /// <summary>
        /// Paste action.
        /// </summary>
        virtual public void Paste()
        {
            History <ShapeCollection> .Memorize(_shapes);

            foreach (IShape shape in Clipboard <ShapeCollection> .Clip)
            {
                shape.Location = new PointF(shape.Location.X + 10, shape.Location.Y + 10);
                _shapes.Add(shape.Clone() as IShape);
            }

            Invalidate();
        }
示例#20
0
        public virtual ShapeCollection GetChildShapes()
        {
            ShapeCollection sc = new ShapeCollection();

            foreach (Connector cr in this.Connectors)
            {
                foreach (Connection cn in cr.Connections)
                {
                    sc.Add(cn.From == cr ? cn.To.BelongsTo : cn.From.BelongsTo);
                }
            }
            return(sc);
        }
示例#21
0
        /// <summary>
        /// Gets ghostable shapes.
        /// </summary>
        /// <param name="shapes">Shape on drawing panel.</param>
        virtual protected ShapeCollection GetGhostableShapes(ShapeCollection shapes)
        {
            ShapeCollection ghostableShapes = new ShapeCollection();

            foreach (IShape shape in shapes)
            {
                if (shape.Selected && !shape.Locked)
                {
                    ghostableShapes.Add(shape);
                }
            }

            return(ghostableShapes);
        }
示例#22
0
 void RecursiveAddRelevantChildren(ShapeCollection childList)
 {
     foreach (ShapeBase child in childList)
     {
         if (child is StaticMeshShape)
         {
             _relevantShapes.Add(child);
         }
         if (child.HasChildren())
         {
             RecursiveAddRelevantChildren(child.ChildCollection);
         }
     }
 }
示例#23
0
        private void ScriptListSubmenuItem_Click(object sender, EventArgs e)
        {
            var item = sender as ToolStripMenuItem;

            ShapeBase shape = EditorManager.Scene.FindShapeByID((ulong)item.Tag);

            if (shape != null)
            {
                ShapeCollection shapeColl = new ShapeCollection();
                shapeColl.Add(shape);
                EditorManager.Scene.ActiveLayer = shape.ParentLayer;
                EditorManager.SelectedShapes    = shapeColl;
            }
        }
        public void CreateStoreSection(object sender, MouseButtonEventArgs e)
        {
            Canvas       canvas          = sender as Canvas;
            SectionShape newSectionShape = new SectionShape();

            newSectionShape.Top  = e.GetPosition(canvas).Y - 7;
            newSectionShape.Left = e.GetPosition(canvas).X - 7;

            newSectionShape.Shape = ShapeButtonCreator.CreateShapeForButton();

            ShapeCollection.Add(newSectionShape);
            _newlyCreatedSection = newSectionShape;

            NewlyCreatedStoreSectionName = "";
        }
示例#25
0
        public static void recursivelyAddShapes(ShapeCollection siblings, ref ShapeCollection shapesOut)
        {
            foreach (ShapeBase shape in siblings)
            {
                recursivelyAddShapes(shape.ChildCollection, ref shapesOut);

                if (shape is StaticMeshShape || shape is EntityShape || shape is TerrainShape
#if USE_SPEEDTREE
                    || shape is SpeedTree5GroupShape ||
                    shape is Speedtree6GroupShape
#endif
                    )
                {
                    shapesOut.Add(shape);
                }
            }
        }
示例#26
0
        void AddPhysXComponentsRecursive(ShapeComponentCollection list, ShapeCollection entityList, ShapeBase parent)
        {
            if (parent.ShapeVirtualCounter > 0 || !parent.Modifiable)
            {
                return;
            }
            if (parent.ComponentCount > 0)
            {
                foreach (ShapeComponent comp in parent.Components)
                {
                    if (!comp.Missing)
                    {
                        continue;
                    }
                    if (comp.DisplayName == "vPhysXRigidBody" || comp.DisplayName == "vPhysXCharacterController")
                    {
                        // Catch invalid casts
                        try
                        {
                            UInt32 iValue = System.Convert.ToUInt32(comp.GetPropertyValue("m_iCollisionBitmask", false));
                            if (iValue != 0)
                            {
                                list.Add(comp);
                            }
                        }
                        catch (InvalidCastException)
                        {}
                    }
                }
            }
            EntityShape entity = parent as EntityShape;

            if (entity != null && (entity.EntityClass == "vPhysXEntity" || entity.EntityClass == "LineFollowerEntity_cl"))
            {
                entityList.Add(entity);
            }

            if (parent.HasChildren())
            {
                foreach (ShapeBase shape in parent.ChildCollection)
                {
                    AddPhysXComponentsRecursive(list, entityList, shape);
                }
            }
        }
示例#27
0
        private void reportlist_DoubleClick(object sender, System.EventArgs e)
        {
            ShapeBase shape = (ShapeBase)reportlist.SelectedItems[0].Tag;
              ShapeCollection shapes = new ShapeCollection();
              shapes.Add(shape);

              EditorManager.SelectedShapes = shapes;

              //jump to selection
              BoundingBox mergedBox = EditorManager.SelectedShapes.BoundingBox;
              if (!mergedBox.Valid)
            return;

              // make it local again
              Vector3F center = mergedBox.Center;
              mergedBox.Translate(-center);

              EditorManager.ActiveView.LookAt(center, mergedBox);
        }
示例#28
0
        void EndEditing()
        {
            _shape.ConstructionFinished = true;
            Cursor.Show();

            // Close dialog and remove callbacks
            _contextDialog.FormClosed        -= new FormClosedEventHandler(FormClosed);
            IScene.ShapeChanged              -= new ShapeChangedEventHandler(ShapeChanged);
            IScene.PropertyChanged           -= new CSharpFramework.PropertyChangedEventHandler(PropertyChanged);
            EditorManager.BeforeSceneClosing -= new BeforeSceneClosing(SceneClosing);
            EditorManager.SceneEvent         -= new SceneEventHandler(EditorManager_SceneEvent);
            _contextDialog.Close();

            // Set selection to the edited custom volume shape
            ShapeCollection selection = new ShapeCollection();

            selection.Add(_shape);
            EditorManager.SelectedShapes = selection;
        }
示例#29
0
        public override void OnRemoveFromScene()
        {
            base.OnRemoveFromScene();
            if (EditorManager.Scene != null && _lastParent != null && _lastParent.EngineInstance != null && !_lastParent.CustomStaticMesh)
            {
                _lastParent.EngineInstance.UpdateStaticMesh(EngineInstanceCustomVolumeObject.VUpdateType_e.VUT_UPDATE_RETRIANGULATE);

                //Select last parent to not loose focus
                ShapeCollection selection = new ShapeCollection();
                selection.Add(_lastParent);
                EditorManager.SelectedShapes = selection;
            }

            //finally remove the engine instance
            if (this._engineInstance != null)
            {
                // Important: We must call the base implementation here because the overload in this class prevents the deletion
                base.RemoveEngineInstance(false);
            }
        }
示例#30
0
  ShapeCollection GetRelevantShapes()
  {
      if (_relevantShapes == null)
      {
          _relevantShapes = new ShapeCollection();
 #if (MESHGROUP_USE_LINKING)
          LinkCollection links = GetGroupStaticMeshesLinkSource().Links;
          foreach (LinkTarget t in links)
          {
              if (t.OwnerShape is StaticMeshShape)
              {
                  _relevantShapes.Add(t.OwnerShape);
              }
          }
 #else
          RecursiveAddRelevantChildren(ChildCollection);
 #endif
      }
      return(_relevantShapes);
  }
示例#31
0
        void AddSoundShapesRecursive(ShapeCollection shapeList, ShapeBase parent)
        {
            if (parent.ShapeVirtualCounter > 0 || !parent.Modifiable)
            {
                return;
            }

            ShapeBase soundShape = parent as ShapeObject3D;

            if (soundShape != null && (soundShape.GetType().FullName == "SoundEditorPlugin.SoundShape" || soundShape.GetType().FullName == "SoundEditorPlugin.SoundCollisionShape"))
            {
                shapeList.Add(soundShape);
            }

            if (parent.HasChildren())
            {
                foreach (ShapeBase shape in parent.ChildCollection)
                {
                    AddSoundShapesRecursive(shapeList, shape);
                }
            }
        }
示例#32
0
        private ShapeCollection InternalExecute(IPixelComparer comparer, PixelColor[,] pixels)
        {
            var map = _mapBuilder.GetExplorationMap(comparer, pixels);

            var shapeDetector = new ShapeDetector(map);
            var edgePlotter   = new EdgePlotter(_logger);
            var shapeMap      = shapeDetector.CreateShapeMap();

            var edgeList = new ShapeCollection();

            while (shapeDetector.GenerateShape(shapeMap))
            {
                var edge = edgePlotter.CalculateEdge(shapeMap);

                if (edge.Count > 2)
                {
                    edgeList.Add(edge);
                }
            }

            return(edgeList);
        }
示例#33
0
        private void reportlist_DoubleClick(object sender, System.EventArgs e)
        {
            ShapeBase       shape  = (ShapeBase)reportlist.SelectedItems[0].Tag;
            ShapeCollection shapes = new ShapeCollection();

            shapes.Add(shape);

            EditorManager.SelectedShapes = shapes;

            //jump to selection
            BoundingBox mergedBox = EditorManager.SelectedShapes.BoundingBox;

            if (!mergedBox.Valid)
            {
                return;
            }

            // make it local again
            Vector3F center = mergedBox.Center;

            mergedBox.Translate(-center);

            EditorManager.ActiveView.LookAt(center, mergedBox);
        }
示例#34
0
        /// <summary>
        /// Exports the part of the diagram that encloses all given shapes (plus margin on each side) to an image of the given format.
        /// Pass null/Nothing for Parameter shapes in order to expor the whole diagram area.
        /// </summary>
        /// <param name="imageFormat">Specifies the format of the graphics file.</param>
        /// <param name="shapes">The shapes that should be drawn. If null/Nothing, the whole diagram area will be exported.</param>
        /// <param name="margin">Specifies the thickness of the margin around the exported diagram area.</param>
        /// <param name="withBackground">Specifies whether the diagram's background should be exported to the graphics file.</param>
        /// <param name="backgroundColor">Specifies a color for the exported image's background. 
        /// If the diagram is exported with background, the diagram's background will be drawn over the specified background color.</param>
        /// <param name="dpi">Specifies the resolution for the export file. Only applies to pixel based image file formats.</param>
        public Image CreateImage(ImageFileFormat imageFormat, IEnumerable<Shape> shapes, int margin, bool withBackground, Color backgroundColor, int dpi)
        {
            Image result = null;

            // Get/Create info graphics
            bool disposeInfoGfx;
            Graphics infoGraphics;
            if (DisplayService != null) {
                infoGraphics = DisplayService.InfoGraphics;
                disposeInfoGfx = false;
            } else {
                infoGraphics = Graphics.FromHwnd(IntPtr.Zero);
                disposeInfoGfx = true;
            }

            try {
                // If dpi value is not valid, get current dpi from display service
                if (dpi <= 0)
                    dpi = (int)Math.Round((infoGraphics.DpiX + infoGraphics.DpiY) / 2f);

                // Get bounding rectangle around the given shapes
                Rectangle imageBounds = Rectangle.Empty;
                if (shapes == null) {
                    imageBounds.X = imageBounds.Y = 0;
                    imageBounds.Width = Width;
                    imageBounds.Height = Height;
                } else {
                    int left, top, right, bottom;
                    left = top = int.MaxValue;
                    right = bottom = int.MinValue;
                    // Calculate the bounding rectangle of the given shapes
                    Rectangle boundingRect = Rectangle.Empty;
                    foreach (Shape shape in shapes) {
                        boundingRect = shape.GetBoundingRectangle(true);
                        if (boundingRect.Left < left) left = boundingRect.Left;
                        if (boundingRect.Top < top) top = boundingRect.Top;
                        if (boundingRect.Right > right) right = boundingRect.Right;
                        if (boundingRect.Bottom > bottom) bottom = boundingRect.Bottom;
                    }
                    if (Geometry.IsValid(left, top, right, bottom))
                        imageBounds = Rectangle.FromLTRB(left, top, right, bottom);
                }
                imageBounds.Inflate(margin, margin);
                imageBounds.Width += 1;
                imageBounds.Height += 1;

                bool originalQualitySetting = this.HighQualityRendering;
                HighQualityRendering = true;
                UpdateBrushes();

                float scaleX = 1, scaleY = 1;
                switch (imageFormat) {
                    case ImageFileFormat.Svg:
                        throw new NotImplementedException();

                    case ImageFileFormat.Emf:
                    case ImageFileFormat.EmfPlus:
                        // Create MetaFile and graphics context
                        IntPtr hdc = infoGraphics.GetHdc();
                        try {
                            Rectangle bounds = Rectangle.Empty;
                            bounds.Size = imageBounds.Size;
                            result = new Metafile(hdc, bounds, MetafileFrameUnit.Pixel,
                                                (imageFormat == ImageFileFormat.Emf) ? EmfType.EmfOnly : EmfType.EmfPlusDual,
                                                Name);
                        } finally {
                            infoGraphics.ReleaseHdc(hdc);
                        }
                        break;

                    case ImageFileFormat.Bmp:
                    case ImageFileFormat.Gif:
                    case ImageFileFormat.Jpeg:
                    case ImageFileFormat.Png:
                    case ImageFileFormat.Tiff:
                        int imgWidth = imageBounds.Width;
                        int imgHeight = imageBounds.Height;
                        if (dpi > 0 && dpi != infoGraphics.DpiX || dpi != infoGraphics.DpiY) {
                            scaleX = dpi / infoGraphics.DpiX;
                            scaleY = dpi / infoGraphics.DpiY;
                            imgWidth = (int)Math.Round(scaleX * imageBounds.Width);
                            imgHeight = (int)Math.Round(scaleY * imageBounds.Height);
                        }
                        result = new Bitmap(Math.Max(1, imgWidth), Math.Max(1, imgHeight));
                        ((Bitmap)result).SetResolution(dpi, dpi);
                        break;

                    default:
                        throw new NShapeUnsupportedValueException(typeof(ImageFileFormat), imageFormat);
                }

                // Draw diagram
                using (Graphics gfx = Graphics.FromImage(result)) {
                    GdiHelpers.ApplyGraphicsSettings(gfx, RenderingQuality.MaximumQuality);

                    // Fill background with background color
                    if (backgroundColor.A < 255) {
                        if (imageFormat == ImageFileFormat.Bmp || imageFormat == ImageFileFormat.Jpeg) {
                            // For image formats that do not support transparency, fill background with the RGB part of
                            // the given backgropund color
                            gfx.Clear(Color.FromArgb(255, backgroundColor));
                        } else if (backgroundColor.A > 0) {
                            // Skip filling background for meta files if transparency is 100%:
                            // Filling Background with Color.Transparent causes graphical glitches with many applications
                            gfx.Clear(backgroundColor);
                        }
                    } else {
                        // Graphics.Clear() does not work as expected for classic EMF (fills only the top left pixel
                        // instead of the whole graphics context).
                        if (imageFormat == ImageFileFormat.Emf) {
                            using (SolidBrush brush = new SolidBrush(backgroundColor))
                                gfx.FillRectangle(brush, gfx.ClipBounds);
                        } else gfx.Clear(backgroundColor);
                    }

                    // Transform graphics (if necessary)
                    gfx.TranslateTransform(-imageBounds.X, -imageBounds.Y, MatrixOrder.Prepend);
                    if (scaleX != 1 || scaleY != 1) gfx.ScaleTransform(scaleX, scaleY, MatrixOrder.Append);

                    // Draw diagram background
                    if (withBackground) DrawBackground(gfx, imageBounds);
                    // Draw diagram shapes
                    if (shapes == null) {
                        foreach (Shape shape in diagramShapes.BottomUp) shape.Draw(gfx);
                    } else {
                        // Add shapes to ShapeCollection (in order to maintain zOrder while drawing)
                        int cnt = (shapes is ICollection) ? ((ICollection)shapes).Count : -1;
                        ShapeCollection shapeCollection = new ShapeCollection(cnt);
                        foreach (Shape s in shapes) {
                            // Sort out duplicate references to shapes (as they can occur in the result of Diagram.FindShapes())
                            if (shapeCollection.Contains(s)) continue;
                            shapeCollection.Add(s, s.ZOrder);
                        }
                        // Draw shapes
                        foreach (Shape shape in shapeCollection.BottomUp)
                            shape.Draw(gfx);
                        shapeCollection.Clear();
                    }
                    // Reset transformation
                    gfx.ResetTransform();
                }
                // Restore original graphics settings
                HighQualityRendering = originalQualitySetting;
                UpdateBrushes();

                return result;
            } finally {
                if (disposeInfoGfx)
                    GdiHelpers.DisposeObject(ref infoGraphics);
            }
        }
        void AddPhysXComponentsRecursive(ShapeComponentCollection list, ShapeCollection entityList, ShapeBase parent)
        {
            if (parent.ShapeVirtualCounter > 0 || !parent.Modifiable)
            return;
              if (parent.ComponentCount > 0)
              {
            foreach (ShapeComponent comp in parent.Components)
            {
              if (!comp.Missing)
            continue;
              if (comp.DisplayName == "vPhysXRigidBody" || comp.DisplayName == "vPhysXCharacterController")
              {
            // Catch invalid casts
            try
            {
              UInt32 iValue = System.Convert.ToUInt32(comp.GetPropertyValue("m_iCollisionBitmask", false));
              if (iValue != 0)
                list.Add(comp);
            }
            catch(InvalidCastException)
            {}
              }
            }
              }
              EntityShape entity = parent as EntityShape;
              if (entity != null && (entity.EntityClass == "vPhysXEntity" || entity.EntityClass == "LineFollowerEntity_cl"))
              {
            entityList.Add(entity);
              }

              if (parent.HasChildren())
            foreach (ShapeBase shape in parent.ChildCollection)
              AddPhysXComponentsRecursive(list, entityList, shape);
        }
示例#36
0
        void AddShapesRecursive(ShapeCollection target, ShapeBase parent, Rectangle2D selection )
        {
            if (parent.ShapeVirtualCounter==0 && parent.CanCopyPaste && (parent is Shape3D))
              {
            Shape3D shape3D = (Shape3D)parent;
            if (selection.IsInside(shape3D.x, shape3D.y))
            {
              target.Add(parent);
              //return; // iterate through children as well - the CloneForClipboard will take care of handling duplicates
            }
              }

              if (parent.HasChildren())
              {
            ShapeCollection children = parent.ChildCollection;
            foreach (ShapeBase child in children)
              AddShapesRecursive(target, child, selection);
              }
        }
示例#37
0
 void selectionSetComboBox_SelectedValueChanged(object sender, EventArgs e)
 {
     if (selectionSetComboBox.SelectedItem != null)
       {
     ShapeCollection list = (selectionSetComboBox.SelectedItem as SelectionSetItem).Shapes;
     ShapeCollection actualShapes = new ShapeCollection();
     foreach (ShapeBase shape in list)
       if (shape.IsAddedToScene)
     actualShapes.Add(shape);
     EditorManager.SelectedShapes = actualShapes;
       }
 }
        void BatchSaveScreenShots()
        {
            ShapeCollection shapes = new ShapeCollection();
              // step #1: filter shapes
              {
            foreach (ShapeBase shape in this.ChildCollection)
            {
              // filter?
              shapes.Add(shape);
            }
            if (shapes.Count == 0)
              return;
              }

              try
              {
            SetEditorCameraPosition();
            int iResX = EditorManager.ActiveView.Size.Width;
            int iResY = EditorManager.ActiveView.Size.Height;
            float fFOVX = 90;
            if (this.FOV > 0)
              fFOVX = this.FOV;

            // step #2: prepare the target dir
            string folder = EditorManager.Project.MakeAbsolute(ShapeName);
            Directory.CreateDirectory(folder);

            // step #3: turn them all to invisible
            {
              foreach (ShapeBase shape in shapes)
              {
            shape.SetVisible(false, true);
              }
            }

            // step #4: render each and save a screenshot
            foreach (ShapeBase shape in shapes)
            {
              shape.SetVisible(true, true);
              string filename = Path.Combine(folder, shape.ShapeName + ".jpg");

              // Render and save
              EditorManager.ActiveView.UpdateView(true);
              EditorManager.ActiveView.UpdateView(true);
              EditorManager.EngineManager.SaveScreenShot(filename, iResX, iResY, fFOVX, 0.0f);
              shape.SetVisible(false, true);
            }

              }
              catch (Exception ex)
              {
            EditorManager.DumpException(ex, true);
              }

              // #5: Cleanup
              {
            foreach (ShapeBase shape in shapes)
            {
              shape.SetVisible(shape.FinalVisibleState, true);
            }
              }
        }
        void AddSoundShapesRecursive(ShapeCollection shapeList, ShapeBase parent)
        {
            if (parent.ShapeVirtualCounter > 0 || !parent.Modifiable)
            return;

              ShapeBase soundShape = parent as ShapeObject3D;
              if (soundShape != null && (soundShape.GetType().FullName == "SoundEditorPlugin.SoundShape" || soundShape.GetType().FullName == "SoundEditorPlugin.SoundCollisionShape"))
            shapeList.Add(soundShape);

              if (parent.HasChildren())
            foreach (ShapeBase shape in parent.ChildCollection)
              AddSoundShapesRecursive(shapeList, shape);
        }
示例#40
0
        private void SortSelectedShapes(MoveShapesDirection moveDirection)
        {
            ShapeCollection selected = shapeTreeView.SelectedShapes;

              // return if any of the indices is already on the maximum.
              foreach (ShapeBase shape in selected)
              {
            if (moveDirection == MoveShapesDirection.Up)
            {
              if (shape.Parent.ChildCollection.FindIndex(i => i == shape) <= 0)
            return;
            }
            else
              if (shape.Parent.ChildCollection.FindIndex(i => i == shape) >= shape.Parent.ChildCollection.Count - 1)
            return;
              }

              // get all parents to share modified collections between their children.
              ShapeCollection parents = new ShapeCollection();
              foreach (ShapeBase shape in selected)
            if (!parents.Contains(shape.Parent))
              parents.Add(shape.Parent);

              EditorManager.Actions.StartGroup("Sort Shapes");
              foreach (ShapeBase parent in parents)
              {
            // create copy of the original collection before sorting
            ShapeCollection copyOfChildren = new ShapeCollection();
            copyOfChildren.AddRange(parent.ChildCollection);

            if (moveDirection == MoveShapesDirection.Up)
            {
              for (int i = 0; i < selected.Count; i++)
              {
            ShapeBase child = selected[i];
            if (child.Parent == parent)
            {
              int index = copyOfChildren.FindIndex(c => c == child);
              copyOfChildren.Remove(child);
              copyOfChildren.Insert(index - 1, child);
              EditorManager.Actions.Add(new SortShapeChildrenAction(parent, copyOfChildren));
            }
              }
            }
            else
              for (int i = selected.Count - 1; i > -1; i--)
              {
            ShapeBase child = selected[i];
            if (child.Parent == parent)
            {
              int index = copyOfChildren.FindIndex(c => c == child);
              copyOfChildren.Remove(child);
              copyOfChildren.Insert(index + 1, child);
              EditorManager.Actions.Add(new SortShapeChildrenAction(parent, copyOfChildren));
            }
              }
              }
              EditorManager.Actions.EndGroup();

              // recover selection
              ArrayList newSelection = new ArrayList();
              foreach (ShapeTreeNode node in shapeTreeView.Nodes)
              {
            if (selected.Contains(node.shape)) // root
              newSelection.Add(node);
            foreach (ShapeTreeNode subNode in shapeTreeView.GetChildNodes(node))
            {
              if (selected.Contains(subNode.shape)) // all children
            newSelection.Add(subNode);
            }
              }
              shapeTreeView.SelectedNodes = newSelection;
        }
示例#41
0
 private void moveShapesToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (!treeView_Layers.Selection_ZonesOnly)
     return;
       ShapeCollection shapes = new ShapeCollection();
       foreach (Zone zone in treeView_Layers.Selection_Zones)
       {
     Shape3D shape = zone.GetZoneMoveProxyShape();
     if (shape != null)
       shapes.Add(shape);
       }
       EditorManager.SelectedShapes = shapes;
 }
 ShapeCollection GetRelevantShapes()
 {
   if (_relevantShapes == null)
   {
     _relevantShapes = new ShapeCollection();
    #if (MESHGROUP_USE_LINKING)
     LinkCollection links = GetGroupStaticMeshesLinkSource().Links;
     foreach (LinkTarget t in links)
       if (t.OwnerShape is StaticMeshShape)
         _relevantShapes.Add(t.OwnerShape);
    #else
     RecursiveAddRelevantChildren(ChildCollection);
    #endif
   }
   return _relevantShapes;
 }
示例#43
0
        private void recentItem_Click(object sender, EventArgs e)
        {
            this.Focus();
              ToolStripMenuItem recentItem = sender as ToolStripMenuItem;
              if (recentItem == null)
            return;

              object obj = recentItem.Tag;
              if (obj == null)
            return;

              if (obj.GetType() == typeof(Layer) || obj.GetType() == typeof(V3DLayer))
              {
            IScene.SendLayerChangedEvent(new LayerChangedArgs((Layer)obj, null, LayerChangedArgs.Action.Selected));
              }
              else if (obj.GetType() == typeof(Zone))
              {
            IScene.SendZoneChangedEvent(new ZoneChangedArgs((Zone)obj, ZoneChangedArgs.Action.Selected));
              }
              else
              {
            ShapeCollection shapes = new ShapeCollection();
            shapes.Add((ShapeBase)obj);
            EditorManager.SelectedShapes = shapes;

            // Fire event manually in case selection was the same (so event will not get fired)
            EditorManager.OnShapeSelectionChanged(new ShapeSelectionChangedArgs(null, shapes));
              }
        }
示例#44
0
        private void sortShapesIntoZonesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ZoneCollection zones = new ZoneCollection();
              foreach (Zone zone in EditorManager.Scene.Zones)
            if (zone.ConsiderForSortIntoZones)
              zones.Add(zone);
              if (zones.Count==0)
            return;

              ShapeCollection shapes = new ShapeCollection();
              foreach (Layer layer in treeView_Layers.Selection_Layers)
              {
            if (layer.ParentZone != null || !layer.Modifiable)
              continue;
            foreach (ShapeBase shape in layer.Root.ChildCollection)
              shapes.Add(shape);

              }

              if (shapes.Count > 0)
              {
            SortShapesIntoZonesAction action = new SortShapesIntoZonesAction(shapes, zones);
            EditorManager.Actions.Add(action);
              }
        }
示例#45
0
        public static void recursivelyAddShapes(ShapeCollection siblings, ref ShapeCollection shapesOut)
        {
            foreach (ShapeBase shape in siblings)
              {
            recursivelyAddShapes(shape.ChildCollection, ref shapesOut);

            if (shape is StaticMeshShape || shape is EntityShape || shape is TerrainShape
            #if !HK_ANARCHY
            || shape is DecorationGroupShape
            #endif
            #if USE_SPEEDTREE
            || shape is SpeedTree5GroupShape
            || shape is Speedtree6GroupShape
            #endif
            )
            {
              shapesOut.Add(shape);
            }
              }
        }
        public override void OnRemoveFromScene()
        {
            base.OnRemoveFromScene();
              if (EditorManager.Scene != null && _lastParent != null && _lastParent.EngineInstance != null && !_lastParent.CustomStaticMesh)
              {
            _lastParent.EngineInstance.UpdateStaticMesh(EngineInstanceCustomVolumeObject.VUpdateType_e.VUT_UPDATE_RETRIANGULATE);

            //Select last parent to not loose focus
            ShapeCollection selection = new ShapeCollection();
            selection.Add(_lastParent);
            EditorManager.SelectedShapes = selection;
              }

              //finally remove the engine instance
              if (this._engineInstance != null)
              {
            // Important: We must call the base implementation here because the overload in this class prevents the deletion
            base.RemoveEngineInstance(false);
              }
        }
示例#47
0
        private void SelectEntities(ShapeBase shape, String classText, String modelText, ShapeCollection sel)
        {
            //check the entity
            EntityShape entity = shape as EntityShape;
              if (entity!=null)
              {
            bool bSelect = true;

            if (checkEntityClass.Checked)
              bSelect &= (entity.EntityClass.ToUpper().IndexOf(classText)!=-1);
            if (checkModel.Checked)
              bSelect &= (entity.ModelFile.ToUpper().IndexOf(modelText)!=-1);

            if (bSelect)
              sel.Add(shape);
              }

            //check its children
            foreach(ShapeBase child in shape.ChildCollection)
            {
                SelectEntities(child, classText, modelText, sel);
            }
        }
示例#48
0
        public void Open(string filename)
        {
            if (filename.Length == 0)
                return;
            if (!File.Exists(filename))
            {
                var directoryName = Path.GetDirectoryName(Filename);
                if (directoryName == null)
                {
                    MessageBox.Show("Error?!?");
                    return;
                }
                var nfilename = Path.Combine(directoryName, Path.GetFileName(filename));
                if (File.Exists(nfilename))
                    filename = nfilename;
                else
                {
                    MessageBox.Show("File non trovato:\n" + filename, "Diagram Drawer", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    MessageBox.Show("File non trovato:\n" + nfilename, "Diagram Drawer", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            var sett = new XmlReaderSettings
            {
                IgnoreWhitespace = true
            };
            try
            {
                using (var reader = XmlReader.Create(filename, sett))
                {
                    reader.ReadToFollowing("size");
                    Width = reader.MoveToAttribute("width")
                        ? Convert.ToInt32(reader.Value, CultureInfo.InvariantCulture)
                        : 1000;
                    Height = reader.MoveToAttribute("height")
                        ? Convert.ToInt32(reader.Value, CultureInfo.InvariantCulture)
                        : 800;
                    reader.MoveToElement();
                    var toLoad = new ShapeCollection();
                    do
                    {
                        reader.Read();
                        IShapeCreator creator = null;
                        switch (reader.Name)
                        {
                            case "shape":
                                if (reader.MoveToAttribute("type"))
                                {
                                    var type = reader.ReadContentAsString();
                                    creator = ShapeTypes[type];
                                }
                                else
                                    creator = RoundedBox.Creator;
                                break;
                            case "line":
                                if (reader.MoveToAttribute("type"))
                                {
                                    var type = reader.ReadContentAsString();
                                    creator = ArrowTypes[type];
                                }
                                else
                                    creator = Line.Creator;
                                break;
                        }
                        IPersistableShape s;
                        if (creator != null)
                            s = creator.Create();
                        else
                            break;//We're done!
                        reader.MoveToElement();
                        using (var r = reader.ReadSubtree())
                            s.Load(r);
                        toLoad.Add(s);
                    } while (true);
                    container.ClearShapes();
                    container.LoadShapes(toLoad);
                }

                container.ForceRefresh();
                Filename = filename;
                if (Opened != null)
                    Opened(this, EventArgs.Empty);
            }
            catch (FileNotFoundException fnfe)
            {
                MessageBox.Show("[WAAAAAAAAA]\nFile non trovato: " + fnfe.FileName, "Diagram Drawer", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// This function converts all shapes from the old SoundPlugin to the corresponding shapes of the new FmodPlugin
        /// </summary>
        void MigrateToFmodShapes()
        {
            // If old Sound plugin is not loaded, don't do anything
              IEditorPluginModule soundPlugin = EditorManager.GetPluginByName("SoundEditorPlugin.EditorPlugin");
              if (soundPlugin == null || !soundPlugin.Initialized)
            return;

              // collect all sound specific shapes
              ShapeCollection soundShapes = new ShapeCollection();
              foreach (Layer layer in EditorManager.Scene.Layers)
            if (layer.Modifiable && layer.Loaded)
              AddSoundShapesRecursive(soundShapes, layer.Root);

              if (soundShapes.Count == 0)
            return;

              // prompt a dialog
              DialogResult res = EditorManager.ShowMessageBox("Shapes from old Sound Plugin have been found in loaded layers.\n\nShould these be permanently converted to the corresponding shapes of the Fmod Plugin?", "Old Sound Plugin and Fmod Plugin are both loaded", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
              if (res != DialogResult.Yes)
            return;

              ShapeCollection newShapes = new ShapeCollection();
              int iConvertedCount = 0;
              if (soundShapes.Count > 0)
              {
            GroupAction actions = new GroupAction("Migrate Sound shapes");
            foreach (ShapeObject3D oldShape in soundShapes)
            {
              ShapeObject3D newShape = null;
              if (oldShape.GetType().FullName == "SoundEditorPlugin.SoundShape")
              {
            newShape = new FmodSoundShape(oldShape.ShapeName);
            MigrateSoundShapeProperties(oldShape, (FmodSoundShape)newShape);

            actions.Add(AddShapeAction.CreateAddShapeAction(newShape, oldShape.Parent, oldShape.ParentLayer, false));

            actions.Add(new MigrateSoundLinksAction(oldShape, (FmodSoundShape)newShape));
            actions.Add(new MigrateChildrenAction(oldShape, newShape));
            actions.Add(RemoveShapeAction.CreateRemoveShapeAction(oldShape));
            newShapes.Add(newShape);
              }
              else if (oldShape.GetType().FullName == "SoundEditorPlugin.SoundCollisionShape")
              {
            newShape = new FmodCollisionMeshShape(oldShape.ShapeName);
            MigrateSoundCollisionShapeProperties(oldShape, (FmodCollisionMeshShape)newShape);

            actions.Add(AddShapeAction.CreateAddShapeAction(newShape, oldShape.Parent, oldShape.ParentLayer, false));
            actions.Add(new MigrateChildrenAction(oldShape, newShape));
            actions.Add(RemoveShapeAction.CreateRemoveShapeAction(oldShape));
            newShapes.Add(newShape);
              }
              if (newShape == null)
            continue;

              iConvertedCount++;
            }

            // EditorManager.Actions.Add() is not used, in order to prevent a undo of the conversion
            actions.Do();
              }

              // ensure, that all migrated childs have valid engine instances
              foreach (ShapeBase shape in newShapes)
            foreach (ShapeBase child in shape.ChildCollection)
              child.ReCreateEngineInstance(true);

              EditorManager.ShowMessageBox(iConvertedCount.ToString() + " Shape(s) have been successfully converted.", "Sound to Fmod shapes conversion", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
示例#50
0
        public override void Perform2DViewAction(Scene2DView view, GroupAction parent, string action)
        {
            base.Perform2DViewAction(view, parent, action);

              // sector range - used by all actions
              BoundingBox selBox = view.SelectionMarqueeWorldBox;
              int x1, y1, x2, y2;
              Config.GetSectorIndicesAtWorldPos(selBox.vMin, out x1, out y1);
              Config.GetSectorIndicesAtWorldPos(selBox.vMax, out x2, out y2);
              Config.ClampSectorRange(ref x1, ref y1, ref x2, ref y2);

              if (action == VA_EDIT_SECTOR_PROPERTIES)
              {
             ShapeCollection shapes = new ShapeCollection();
             for (int sy = y1; sy <= y2; sy++)
               for (int sx = x1; sx <= x2; sx++)
             shapes.Add(GetZone(sx, sy));
             EditorManager.SelectedShapes = shapes;
              }
              else if (action == VA_IMPORT_HEIGHTMAP)
              {
            ImportHeightmapDDS import = new ImportHeightmapDDS();
            x1 *= Config.SamplesPerSectorX;
            y1 *= Config.SamplesPerSectorY;
            x2 = (x2 + 1) * Config.SamplesPerSectorX;
            y2 = (y2 + 1) * Config.SamplesPerSectorY;
            ApplyHeightmapFilterDlg.RunFilter(import, x1, y1, x2, y2);
              }
              else if (action == VA_REPAIR_SECTORS)
              {
            EditorManager.Progress.ShowProgressDialog("Repair Sectors");
            EngineTerrain.EnsureSectorRangeLoaded(x1, y1, x2, y2, (int)SectorEditorFlags_e.AnythingDirty, true, true, EditorManager.Progress);
            EditorManager.Progress.HideProgressDialog();
              }
              else if (action == VA_RELOAD_SECTORS)
              {
            EditorManager.Progress.ShowProgressDialog("Reload Sectors");
            EngineTerrain.ReloadSectorRange(x1, y1, x2, y2, false, EditorManager.Progress);
            EditorManager.Progress.HideProgressDialog();
            EditorManager.ActiveView.UpdateView(false);
              }
        }
        void EndEditing()
        {
            _shape.ConstructionFinished = true;
              Cursor.Show();

              // Close dialog and remove callbacks
              _contextDialog.FormClosed -= new FormClosedEventHandler(FormClosed);
              IScene.ShapeChanged -= new ShapeChangedEventHandler(ShapeChanged);
              IScene.PropertyChanged -= new CSharpFramework.PropertyChangedEventHandler(PropertyChanged);
              EditorManager.BeforeSceneClosing -= new BeforeSceneClosing(SceneClosing);
              EditorManager.SceneEvent -= new SceneEventHandler(EditorManager_SceneEvent);
              _contextDialog.Close();

              // Set selection to the edited custom volume shape
              ShapeCollection selection = new ShapeCollection();
              selection.Add(_shape);
              EditorManager.SelectedShapes = selection;
        }
示例#52
0
        private void ScriptListSubmenuItem_Click(object sender, EventArgs e)
        {
            var item = sender as ToolStripMenuItem;

              ShapeBase shape = EditorManager.Scene.FindShapeByID((ulong)item.Tag);

              if (shape != null)
              {
            ShapeCollection shapeColl = new ShapeCollection();
            shapeColl.Add(shape);
            EditorManager.Scene.ActiveLayer = shape.ParentLayer;
            EditorManager.SelectedShapes = shapeColl;
              }
        }