Наследование: INamedResource, INotifyPropertyChanged, IPropertyProvider
Пример #1
0
        private void ShowPreviewMarker(PointerEventInfo info)
        {
            if (ActiveObjectClass == null)
                return;

            if (ActiveObjectClass != _activeClass) {
                HidePreviewMarker();
                _previewMarker = null;
                _activeClass = ActiveObjectClass;
            }

            if (!_previewMarkerVisible) {
                if (_previewMarker == null) {
                    _previewMarker = new ImageAnnot() {
                        Image = ActiveObjectClass.Image,
                        BlendColor = new Color(255, 255, 255, 128),
                    };
                }

                _annots.Add(_previewMarker);
                _previewMarkerVisible = true;
            }

            Point xlat = new Point((int)info.X - _activeClass.ImageBounds.Width / 2, (int)info.Y - _activeClass.ImageBounds.Height / 2);
            if (SnapManager != null)
                xlat = SnapManager.Translate(xlat, SnappingTarget);

            _previewMarker.Position = xlat;
        }
        public void CommandClone(object param)
        {
            if (!ObjectExists(param))
                return;

            Guid uid = (Guid)param;
            ObjectPool objPool = Editor.Project.ObjectPoolManager.PoolFromItemKey(uid);
            ObjectClass objClass = objPool.GetObject(uid);

            ObjectClass newClass = new ObjectClass(objPool.Objects.CompatibleName(objClass.Name), objClass);
            objPool.AddObject(newClass);
        }
Пример #3
0
        public ObjectInstance(ObjectClass objClass, int posX, int posY)
        {
            _uid = Guid.NewGuid();
            _class = objClass;
            _posX = posX;
            _posY = posY;
            _rotation = 0;
            _scaleX = 1f;
            _scaleY = 1f;

            _propertyManager = new PropertyManager(_propertyClassManager, this);
            _propertyManager.PropertyParent = objClass;
            _propertyManager.CustomProperties.Modified += (s, e) => OnModified(EventArgs.Empty);

            UpdateBounds();
        }
Пример #4
0
        public ObjectClass(string name, ObjectClass template)
            : this(name)
        {
            if (template != null) {
                if (template.Image != null)
                    _image = template.Image.Crop(template.Image.Bounds);

                _canRotate = template._canRotate;
                _canScale = template._canScale;
                _imageBounds = template._imageBounds;
                _maskBounds = template._maskBounds;
                _origin = template._origin;

                foreach (var item in template.PropertyManager.CustomProperties)
                    PropertyManager.CustomProperties.Add(item.Clone() as Property);
            }
        }
Пример #5
0
        public ObjectInstance(ObjectClass objClass, int posX, int posY)
        {
            _uid = Guid.NewGuid();
            _class = objClass;
            _posX = posX;
            _posY = posY;
            _rotation = 0;
            _scaleX = 1f;
            _scaleY = 1f;

            _properties = new PropertyCollection(_reservedPropertyNames);
            _properties.Modified += (s, e) => OnModified(EventArgs.Empty);

            _predefinedProperties = new ObjectInstanceProperties(this);

            UpdateBounds();
        }
Пример #6
0
        public ImportObject(ObjectClass obj)
        {
            InitializeForm();

            base.Text = "Edit Object";

            _sourceImage = obj.Image.Crop(obj.Image.Bounds);
            _sourceFileValid = true;
            _name = obj.Name;

            _originX = obj.Origin.X;
            _originY = obj.Origin.Y;
            _maskLeft = obj.MaskBounds.Left;
            _maskTop = obj.MaskBounds.Top;
            _maskRight = obj.MaskBounds.Right;
            _maskBottom = obj.MaskBounds.Bottom;

            UpdateMaskPropertyFields();

            _validateController.UnregisterControl(_textSource);
            _validateController.Validate();
        }
Пример #7
0
 protected SnappingManager GetSnappingManager(ObjectClass objClass)
 {
     return new SnappingManager(GetSnappingSourceOrigin(objClass), GetSnappingSourceBounds(objClass), GridSize);
 }
Пример #8
0
        private ObjectInstance(LevelX.ObjectInstanceX proxy, ObjectClass objClass)
            : this(objClass, proxy.X, proxy.Y)
        {
            _uid = proxy.Uid;
            _rotation = MathEx.DegToRad(proxy.Rotation);

            if (proxy.Properties != null) {
                foreach (var propertyProxy in proxy.Properties)
                    PropertyManager.CustomProperties.Add(Property.FromXmlProxy(propertyProxy));
            }

            UpdateBounds();
        }
Пример #9
0
 public ObjectInstance(ObjectClass objClass)
     : this(objClass, 0, 0)
 {
 }
Пример #10
0
 public ObjectInstance(ObjectClass objClass)
     : this(objClass, 0, 0)
 {
 }
Пример #11
0
        public void PostDeserialize(Project project)
        {
            ObjectPool pool = project.ObjectPoolManager.PoolFromItemKey(_classId);
            if (pool == null)
                throw new Exception("Invalid ObjectClass Id");

            _class = pool.GetObject(_classId);
            if (_class == null)
                throw new Exception("Invalid ObjectClass Id");

            UpdateBounds();
        }
 public SyncObjectEventArgs(ObjectClass objectClass)
 {
     PreviousObject = objectClass;
 }
        private void CommandImportObject()
        {
            if (CommandCanImportObject()) {
                ImportObject form = new ImportObject();
                foreach (ObjectClass objClass in  SelectedObjectPool.Objects)
                    form.ReservedNames.Add(objClass.Name);

                if (form.ShowDialog() == DialogResult.OK) {
                    TextureResource resource = TextureResourceBitmapExt.CreateTextureResource(form.SourceFile);
                    ObjectClass objClass = new ObjectClass(form.ObjectName) {
                        MaskBounds = new Rectangle(form.MaskLeft ?? 0, form.MaskTop ?? 0,
                            form.MaskRight ?? 0 - form.MaskLeft ?? 0, form.MaskBottom ?? 0 - form.MaskTop ?? 0),
                        Origin = new Point(form.OriginX ?? 0, form.OriginY ?? 0),
                    };

                    SelectedObjectPool.AddObject(objClass);
                    objClass.Image = resource;

                    RefreshObjectPoolCollection();
                    OnSyncObjectPoolManager(EventArgs.Empty);
                }
            }
        }
Пример #14
0
        private void ObjectAdded(ObjectClass objClass)
        {
            if (_objTextureMap.ContainsKey(objClass.Id))
                _objTextureMap[objClass.Id].Dispose();

            if (objClass.Image != null) {
                Texture2D tex = objClass.Image.CreateTexture(_deviceService.GraphicsDevice);
                _objTextureMap[objClass.Id] = tex;
            }
        }
Пример #15
0
 public ObjectClassProperties(ObjectClass parent)
     : base(_reservedPropertyNames)
 {
     _parent = parent;
 }
Пример #16
0
        protected Rectangle GetSnappingSourceBounds(ObjectClass objClass)
        {
            if (objClass == null)
                return Rectangle.Empty;

            switch (SnappingSource) {
                case ObjectSnappingSource.ImageBounds:
                    return objClass.ImageBounds;
                case ObjectSnappingSource.MaskBounds:
                    return objClass.MaskBounds;
                case ObjectSnappingSource.Origin:
                    return new Rectangle(objClass.Origin, Size.Zero);
                default:
                    return Rectangle.Empty;
            }
        }
Пример #17
0
 public BatchEditBlock(ObjectClass resource)
 {
     _resource = resource;
     _resource.ModifyBlockCount++;
 }
Пример #18
0
        public static LibraryX.ObjectClassX ToXProxy(ObjectClass objClass)
        {
            if (objClass == null)
                return null;

            List<CommonX.PropertyX> props = new List<CommonX.PropertyX>();
            foreach (Property prop in objClass.PropertyManager.CustomProperties)
                props.Add(Property.ToXmlProxyX(prop));

            return new LibraryX.ObjectClassX() {
                Uid = objClass.Uid,
                Name = objClass.Name,
                Texture = objClass._image != null ? objClass._image.Uid : Guid.Empty,
                ImageBounds = objClass._imageBounds,
                MaskBounds = objClass._maskBounds,
                Origin = objClass._origin,
                Properties = props.Count > 0 ? props : null,
            };
        }
Пример #19
0
        private void ObjectRemoved(ObjectClass objClass)
        {
            if (_objTextureMap.ContainsKey(objClass.Id))
                _objTextureMap[objClass.Id].Dispose();

            _objTextureMap.Remove(objClass.Id);
        }
Пример #20
0
        protected Point GetSnappingSourceOrigin(ObjectClass objClass)
        {
            if (objClass == null)
                return Point.Zero;

            return objClass.Origin;
        }
Пример #21
0
 public BatchEditBlock(ObjectClass resource)
 {
     _resource = resource;
     _resource.ModifyBlockCount++;
 }