Exemple #1
0
        static void InitialMethod()
        {
            var cont = new ContainerModule().GetConfiguredContainer();

            _constructorController = cont.Create <IConstructorController>();
            _propertyController    = cont.Create <IPropertyController>();
        }
Exemple #2
0
    public bool RemoveProperty(IPropertyController key)
    {
        bool bFlag = m_PercentPropertyDict.Remove(key);

        bFlag |= m_PointPropertyDict.Remove(key);
        OnPropertyChanged();
        return(bFlag);
    }
 /// <summary>
 /// Initializes a new instance of <see cref="T:Dataweb.NShape.Advanced.TypeDescriptorDgBase" />
 /// </summary>
 protected TypeDescriptorDgBase(ICustomTypeDescriptor parent, IPropertyController propertyController)
     : base(parent)
 {
     if (propertyController == null)
     {
         throw new ArgumentNullException("propertyController");
     }
     this.propertyController = propertyController;
 }
 /// <summary>
 /// Initializes a new instance of <see cref="T:Dataweb.NShape.WinFormsUI.PropertyPresenter" />.
 /// </summary>
 public PropertyPresenter(IPropertyController propertyController)
     : this()
 {
     if (propertyController == null)
     {
         throw new ArgumentNullException("propertyController");
     }
     this.PropertyController = propertyController;
 }
Exemple #5
0
        /// <summary>
        /// Initializes a new instance of <see cref="T:Dataweb.NShape.Advanced.PropertyDescriptorDg" />
        /// </summary>
        public PropertyDescriptorDg(PropertyDescriptor descriptor, IPropertyController controller, object propertyOwner)
            : base(descriptor.Name, GetAttributes(controller, descriptor, propertyOwner))
        {
            this.controller = controller;
            this.descriptor = descriptor;

            browsableAttr   = Attributes[typeof(BrowsableAttribute)] as BrowsableAttribute;
            readOnlyAttr    = Attributes[typeof(ReadOnlyAttribute)] as ReadOnlyAttribute;
            descriptionAttr = Attributes[typeof(DescriptionAttribute)] as DescriptionAttribute;
        }
Exemple #6
0
    public void SetPropertyByPercent(IPropertyController key, PropertyValue value)
    {
        float oldHpRatio = curHpRatio;

        m_PropertyContainer.SetPropertyByPercent(key, value);
        if (oldHpRatio != curHpRatio)
        {
            SetHp(oldHpRatio * hpMax);
        }
    }
 /// <ToBeCompleted></ToBeCompleted>
 protected bool IsGranted(IPropertyController controller, Permission permissions, SecurityAccess access, object instance)
 {
     if (instance is ISecurityDomainObject)
     {
         return(controller.Project.SecurityManager.IsGranted(permissions, access, (ISecurityDomainObject)instance));
     }
     else
     {
         return(controller.Project.SecurityManager.IsGranted(permissions, access));
     }
 }
Exemple #8
0
    public void ClearStaticProperty(IPropertyController effect)
    {
        float oldHpRatio = curHpRatio;

        staticProperty = PropertyValue.zero;
        OnPropertyChanged();
        if (oldHpRatio != curHpRatio)
        {
            SetHp(oldHpRatio * hpMax);
        }
    }
Exemple #9
0
 public void RemoveMark(IPropertyController effect, OperatorType type)
 {
     if (type == OperatorType.Add)
     {
         m_AddMark.Remove(effect);
     }
     else if (type == OperatorType.Remove)
     {
         m_RemoveMark.Remove(effect);
     }
 }
Exemple #10
0
 public void SetProperty(IPropertyController key, T value, ValueType valueType)
 {
     if (valueType == ValueType.Point)
     {
         SetPropertyByPoint(key, value);
     }
     else if (valueType == ValueType.Percent)
     {
         SetPropertyByPercent(key, value);
     }
 }
Exemple #11
0
 public void SetPropertyByPercent(IPropertyController key, T value)
 {
     if (m_PercentPropertyDict.ContainsKey(key))
     {
         m_PercentPropertyDict[key] = value;
     }
     else
     {
         m_PercentPropertyDict.Add(key, value);
     }
     OnPropertyChanged();
 }
Exemple #12
0
 private static bool IsGranted(IPropertyController controller, Permission permissions, object propertyOwner)
 {
     if (propertyOwner is Shape)
     {
         Shape s = propertyOwner as Shape;
         if (s != null)
         {
             return(controller.Project.SecurityManager.IsGranted(permissions, s));
         }
     }
     return(controller.Project.SecurityManager.IsGranted(permissions));
 }
Exemple #13
0
    public void RemoveProperty(IPropertyController key)
    {
        float oldHpRatio = curHpRatio;

        if (m_PropertyContainer.RemoveProperty(key))
        {
            if (oldHpRatio != curHpRatio)
            {
                SetHp(oldHpRatio * hpMax);
            }
        }
    }
        /// <summary>
        /// Initializes a new instance of <see cref="T:Dataweb.NShape.Advanced.PropertyDescriptorDg" />
        /// </summary>
        public PropertyDescriptorDg(IPropertyController controller, PropertyDescriptor descriptor, Attribute[] attributes) :
            base(descriptor.Name, attributes)
        {
            this.descriptor = descriptor;
            this.controller = controller;

            // We have to store the attributes and return their values in the appropriate
            // methods because if we don't, modifying the readonly attribute will not work
            browsableAttr   = Attributes[typeof(BrowsableAttribute)] as BrowsableAttribute;
            readOnlyAttr    = Attributes[typeof(ReadOnlyAttribute)] as ReadOnlyAttribute;
            descriptionAttr = Attributes[typeof(DescriptionAttribute)] as DescriptionAttribute;
            permissionAttr  = descriptor.Attributes[typeof(RequiredPermissionAttribute)] as RequiredPermissionAttribute;
        }
Exemple #15
0
 public void AddMark(IPropertyController effect, OperatorType type, DamageMark mark, CheckDamageDelegate condition = null)
 {
     if (mark != DamageMark.None)
     {
         if (type == OperatorType.Add && !m_AddMark.ContainsKey(effect))
         {
             m_AddMark.Add(effect, new MarkData <DamageMark>(mark, condition));
         }
         else if (type == OperatorType.Remove && !m_RemoveMark.ContainsKey(effect))
         {
             m_RemoveMark.Add(effect, new MarkData <DamageMark>(mark, condition));
         }
     }
 }
    public bool RemovePropertyMark(IPropertyController effect)
    {
        PropertyMark oldMark = GetAllMark();

        if (m_MarkDict.Remove(effect))
        {
            if (oldMark != GetAllMark())
            {
                onPropertyMarkChanged.Invoke();
            }
            return(true);
        }
        else
        {
            return(false);
        }
    }
 public bool AddPropertyMark(IPropertyController effect, PropertyMark mark)
 {
     if (!m_MarkDict.ContainsKey(effect))
     {
         PropertyMark oldMark = GetAllMark();
         m_MarkDict.Add(effect, mark);
         if (oldMark != GetAllMark())
         {
             onPropertyMarkChanged.Invoke();
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
        public override void RegisterProperties(IPropertyController propertycontroller)
        {
            base.RegisterProperties(propertycontroller);

            propertycontroller.RegisterIntProperty("Hollow", primitive.Hollow, 0, 200, new SetIntPropertyHandler(SetHollow));
            propertycontroller.RegisterIntProperty("Twist", primitive.Twist, -360, 360, new SetIntPropertyHandler(SetTwist));
            propertycontroller.RegisterIntProperty("Shear", (int)(primitive.Shear * 100), -100, 100, new SetIntPropertyHandler(SetShear));
            propertycontroller.RegisterIntProperty("TopSize X", (int)(primitive.TopSizeX * 200), 0, 200, new SetIntPropertyHandler(SetTopSizeX));
            propertycontroller.RegisterIntProperty("TopSize Y", (int)(primitive.TopSizeY * 200), 0, 200, new SetIntPropertyHandler(SetTopSizeY));
            propertycontroller.RegisterIntProperty("Cut Begin", primitive.CutStart, 0, 200, new SetIntPropertyHandler(SetCutStart));
            propertycontroller.RegisterIntProperty("Cut End", primitive.CutEnd, 0, 200, new SetIntPropertyHandler(SetCutEnd));
            propertycontroller.RegisterIntProperty("Advanced Cut Start", primitive.AdvancedCutStart, 0, 200, new SetIntPropertyHandler(SetAdvancedCutStart));
            propertycontroller.RegisterIntProperty("Advanced Cut End", primitive.AdvancedCutEnd, 0, 200, new SetIntPropertyHandler(SetAdvancedCutEnd));

            propertycontroller.RegisterIntProperty("Texture Offset X", (int)(TextureOffsetX * 200), 0, 200, new SetIntPropertyHandler(SetTextureOffsetX));
            propertycontroller.RegisterIntProperty("Texture Offset Y", (int)(TextureOffsetY * 200), 0, 200, new SetIntPropertyHandler(SetTextureOffsetY));
            propertycontroller.RegisterIntProperty("Texture Scale X", (int)(TextureScaleX * 20), 0, 200, new SetIntPropertyHandler(SetTextureScaleX));
            propertycontroller.RegisterIntProperty("Texture Scale Y", (int)(TextureScaleY * 20), 0, 200, new SetIntPropertyHandler(SetTextureScaleY));
            propertycontroller.RegisterIntProperty("Texture Rotate", (int)(TextureRotate / 2), 0, 180, new SetIntPropertyHandler(SetTextureRotate));
        }
		/// <summary>
		/// Initializes a new instance of <see cref="T:Dataweb.NShape.Advanced.TypeDescriptorDg" />
		/// </summary>
		public LayerTypeDescriptor(ICustomTypeDescriptor parent, IPropertyController propertyController)
			: base(parent, propertyController)
		{
		}
        public override void RegisterProperties( IPropertyController propertycontroller )
        {
            base.RegisterProperties( propertycontroller );

            propertycontroller.RegisterIntProperty( "Hollow", primitive.Hollow, 0, 200, new SetIntPropertyHandler( SetHollow ) );
            propertycontroller.RegisterIntProperty( "Twist", primitive.Twist, -360, 360, new SetIntPropertyHandler( SetTwist ) );
            propertycontroller.RegisterIntProperty( "Shear", (int)( primitive.Shear * 100 ), -100, 100, new SetIntPropertyHandler( SetShear ) );
            propertycontroller.RegisterIntProperty( "TopSize X", (int)(primitive.TopSizeX * 200 ), 0, 200, new SetIntPropertyHandler( SetTopSizeX ) );
            propertycontroller.RegisterIntProperty( "TopSize Y", (int)(primitive.TopSizeY * 200 ), 0, 200, new SetIntPropertyHandler( SetTopSizeY ) );
            propertycontroller.RegisterIntProperty( "Cut Begin", primitive.CutStart, 0, 200, new SetIntPropertyHandler( SetCutStart ) );
            propertycontroller.RegisterIntProperty( "Cut End", primitive.CutEnd, 0, 200, new SetIntPropertyHandler( SetCutEnd ) );
            propertycontroller.RegisterIntProperty( "Advanced Cut Start", primitive.AdvancedCutStart, 0, 200, new SetIntPropertyHandler( SetAdvancedCutStart ) );
            propertycontroller.RegisterIntProperty( "Advanced Cut End", primitive.AdvancedCutEnd, 0, 200, new SetIntPropertyHandler( SetAdvancedCutEnd ) );

            propertycontroller.RegisterIntProperty( "Texture Offset X", (int)( TextureOffsetX * 200 ), 0, 200, new SetIntPropertyHandler( SetTextureOffsetX ) );
            propertycontroller.RegisterIntProperty( "Texture Offset Y", (int)( TextureOffsetY * 200 ), 0, 200, new SetIntPropertyHandler( SetTextureOffsetY ) );
            propertycontroller.RegisterIntProperty( "Texture Scale X", (int)( TextureScaleX * 20 ), 0, 200, new SetIntPropertyHandler( SetTextureScaleX ) );
            propertycontroller.RegisterIntProperty( "Texture Scale Y", (int)( TextureScaleY * 20 ), 0, 200, new SetIntPropertyHandler( SetTextureScaleY ) );
            propertycontroller.RegisterIntProperty( "Texture Rotate", (int)( TextureRotate / 2 ), 0, 180, new SetIntPropertyHandler( SetTextureRotate ) );
        }
 /// <summary>
 /// Initializes a new instance of <see cref="T:Dataweb.NShape.Advanced.TypeDescriptorDg" />
 /// </summary>
 public LayerTypeDescriptor(ICustomTypeDescriptor parent, IPropertyController propertyController)
     : base(parent, propertyController)
 {
 }
Exemple #22
0
 public void RemoveMark(IPropertyController key)
 {
     m_AddMark.Remove(key);
     m_RemoveMark.Remove(key);
 }
        /// <ToBeCompleted></ToBeCompleted>
        protected Attribute[] GetPropertyAttributes(IPropertyController controller, PropertyDescriptor descriptor)
        {
            if (controller == null)
            {
                throw new ArgumentNullException("controller");
            }
            if (descriptor == null)
            {
                throw new ArgumentNullException("descriptor");
            }
            try {
                int attrCount = descriptor.Attributes.Count;
                BrowsableAttribute          browsableAttr          = descriptor.Attributes[typeof(BrowsableAttribute)] as BrowsableAttribute;
                ReadOnlyAttribute           readOnlyAttr           = descriptor.Attributes[typeof(ReadOnlyAttribute)] as ReadOnlyAttribute;
                DescriptionAttribute        descriptionAttr        = descriptor.Attributes[typeof(DescriptionAttribute)] as DescriptionAttribute;
                RequiredPermissionAttribute requiredPermissionAttr = descriptor.Attributes[typeof(RequiredPermissionAttribute)] as RequiredPermissionAttribute;

                if (requiredPermissionAttr != null)
                {
                    object     propertyOwner = GetPropertyOwner(descriptor);
                    Permission permission    = requiredPermissionAttr.Permission;
                    // Check if property is viewable
                    if (!IsGranted(controller, permission, SecurityAccess.Modify, propertyOwner))
                    {
                        // Hide if PropertyDisplayMode is 'Hidden' and 'View' access is not granted,
                        // otherwise set peroperty to readonly
                        if (controller.PropertyDisplayMode == NonEditableDisplayMode.Hidden &&
                            !IsGranted(controller, permission, SecurityAccess.View, propertyOwner))
                        {
                            browsableAttr = BrowsableAttribute.No;
                        }
                        else
                        {
                            readOnlyAttr    = ReadOnlyAttribute.Yes;
                            descriptionAttr = GetNotGrantedDescription(descriptionAttr, permission);
                        }
                    }
                }

                // Now copy all attributes
                int cnt = descriptor.Attributes.Count;
                List <Attribute> result = new List <Attribute>(attrCount);
                // Add stored/modified attributes first
                if (browsableAttr != null)
                {
                    result.Add(browsableAttr);
                }
                if (readOnlyAttr != null)
                {
                    result.Add(readOnlyAttr);
                }
                if (descriptionAttr != null)
                {
                    result.Add(descriptionAttr);
                }
                if (requiredPermissionAttr != null)
                {
                    result.Add(requiredPermissionAttr);
                }
                // Copy all other attributes
                for (int i = 0; i < cnt; ++i)
                {
                    // Skip stored/modified attributes
                    if (descriptor.Attributes[i] is BrowsableAttribute)
                    {
                        continue;
                    }
                    else if (descriptor.Attributes[i] is ReadOnlyAttribute)
                    {
                        continue;
                    }
                    else if (descriptor.Attributes[i] is DescriptionAttribute)
                    {
                        continue;
                    }
                    else if (descriptor.Attributes[i] is EditorAttribute)
                    {
                        if (readOnlyAttr != null && readOnlyAttr.IsReadOnly)
                        {
                            continue;
                        }
                    }
                    result.Add(descriptor.Attributes[i]);
                }
                return(result.ToArray());
            } catch (Exception) {
                throw;
            }
        }
Exemple #24
0
 public void RegisterProperties(IPropertyController propertycontroller)
 {
     propertycontroller.RegisterStringProperty("Name", name, 64, new SetStringPropertyHandler(SetName));
     propertycontroller.RegisterIntProperty("Hollow", hollow, 0, 200, new SetIntPropertyHandler(SetHollow));
 }
		/// <summary>
		/// Initializes a new instance of <see cref="T:Dataweb.NShape.WinFormsUI.PropertyPresenter" />.
		/// </summary>
		public PropertyPresenter(IPropertyController propertyController)
			: this() {
			if (propertyController == null) throw new ArgumentNullException("propertyController");
			this.PropertyController = propertyController;
		}
		/// <ToBeCompleted></ToBeCompleted>
		protected bool IsGranted(IPropertyController controller, Permission permissions, SecurityAccess access,
		                         object instance)
		{
			if (instance is ISecurityDomainObject)
				return controller.Project.SecurityManager.IsGranted(permissions, access, (ISecurityDomainObject) instance);
			else return controller.Project.SecurityManager.IsGranted(permissions, access);
		}
Exemple #27
0
 //public override static Entity operator=( Entity ent1 )
 //{
 //   return new Entity();
 // }
 // used to get a list of properties of this class, eg for properties dialog
 public virtual void RegisterProperties( IPropertyController propertycontroller )
 {
     propertycontroller.RegisterStringProperty( "Name", name, 64, new SetStringPropertyHandler( SetName ) );
 }
		private static bool IsGranted(IPropertyController controller, Permission permissions, object propertyOwner) {
			if (propertyOwner is Shape) {
				Shape s = propertyOwner as Shape;
				if (s != null) return controller.Project.SecurityManager.IsGranted(permissions, s);
			}
			return controller.Project.SecurityManager.IsGranted(permissions);
		}
		private static Attribute[] GetAttributes(IPropertyController controller, PropertyDescriptor descriptor, object propertyOwner) {
			if (controller == null) throw new ArgumentNullException("controller");
			if (descriptor == null) throw new ArgumentNullException("descriptor");
			if (propertyOwner == null) throw new ArgumentNullException("propertyOwner");
			try {
				int attrCount = descriptor.Attributes.Count;
				BrowsableAttribute browsableAttr = descriptor.Attributes[typeof(BrowsableAttribute)] as BrowsableAttribute;
				ReadOnlyAttribute readOnlyAttr = descriptor.Attributes[typeof(ReadOnlyAttribute)] as ReadOnlyAttribute;
				DescriptionAttribute descriptionAttr = descriptor.Attributes[typeof(DescriptionAttribute)] as DescriptionAttribute;
				RequiredPermissionAttribute requiredPermissionAttr = descriptor.Attributes[typeof(RequiredPermissionAttribute)] as RequiredPermissionAttribute;

				if (requiredPermissionAttr != null) {
					Permission permission = requiredPermissionAttr.Permission;
					// Check if property is viewable
					if (!IsGranted(controller, permission, propertyOwner)) {
						// Hide if PropertyDisplayMode is 'Hidden' and 'View' access is not granted,
						// otherwise set peroperty to readonly 
						if (controller.PropertyDisplayMode == NonEditableDisplayMode.Hidden
							&& !IsGranted(controller, permission, propertyOwner)) {
							browsableAttr = BrowsableAttribute.No;
						} else {
							readOnlyAttr = ReadOnlyAttribute.Yes;
							descriptionAttr = GetNotGrantedDescription(permission);
						}
					}
				}

				// Now copy all attributes
				int cnt = descriptor.Attributes.Count;
				List<Attribute> result = new List<Attribute>(attrCount);
				// Add stored/modified attributes first
				if (browsableAttr != null) result.Add(browsableAttr);
				if (readOnlyAttr != null) result.Add(readOnlyAttr);
				if (descriptionAttr != null) result.Add(descriptionAttr);
				if (requiredPermissionAttr != null) result.Add(requiredPermissionAttr);
				// Copy all other attributes
				for (int i = 0; i < cnt; ++i) {
					// Skip stored/modified attributes
					if (descriptor.Attributes[i] is BrowsableAttribute) continue;
					else if (descriptor.Attributes[i] is ReadOnlyAttribute) continue;
					else if (descriptor.Attributes[i] is DescriptionAttribute) continue;
					else if (descriptor.Attributes[i] is EditorAttribute) {
						if (readOnlyAttr != null && readOnlyAttr.IsReadOnly)
							continue;
					}
					result.Add(descriptor.Attributes[i]);
				}
				return result.ToArray();
			} catch (Exception) {
				throw;
			}
		}
		/// <summary>
		/// Initializes a new instance of <see cref="T:Dataweb.NShape.Advanced.PropertyDescriptorDg" />
		/// </summary>
		public PropertyDescriptorDg(PropertyDescriptor descriptor, IPropertyController controller, object propertyOwner)
			: base(descriptor.Name, GetAttributes(controller, descriptor, propertyOwner)) {
			this.controller = controller;
			this.descriptor = descriptor;

			browsableAttr = Attributes[typeof(BrowsableAttribute)] as BrowsableAttribute;
			readOnlyAttr = Attributes[typeof(ReadOnlyAttribute)] as ReadOnlyAttribute;
			descriptionAttr = Attributes[typeof(DescriptionAttribute)] as DescriptionAttribute;
		}
		/// <summary>
		/// Initializes a new instance of <see cref="T:Dataweb.NShape.Advanced.TypeDescriptorDg" />
		/// </summary>
		public TypeDescriptorDg(ICustomTypeDescriptor parent, IPropertyController propertyController)
			: base(parent) {
			if (propertyController == null) throw new ArgumentNullException("propertyController");
			this.propertyController = propertyController;
		}
Exemple #32
0
        //public override static Entity operator=( Entity ent1 )
        //{
        //   return new Entity();
        // }

        // used to get a list of properties of this class, eg for properties dialog
        public virtual void RegisterProperties(IPropertyController propertycontroller)
        {
            propertycontroller.RegisterStringProperty("Name", name, 64, new SetStringPropertyHandler(SetName));
        }
		/// <summary>
		/// Initializes a new instance of <see cref="T:Dataweb.NShape.Advanced.PropertyDescriptorDg" />
		/// </summary>
		public PropertyDescriptorDg(IPropertyController controller, PropertyDescriptor descriptor, Attribute[] attributes) :
			base(descriptor.Name, attributes)
		{
			this.descriptor = descriptor;
			this.controller = controller;

			// We have to store the attributes and return their values in the appropriate 
			// methods because if we don't, modifying the readonly attribute will not work
			browsableAttr = Attributes[typeof (BrowsableAttribute)] as BrowsableAttribute;
			readOnlyAttr = Attributes[typeof (ReadOnlyAttribute)] as ReadOnlyAttribute;
			descriptionAttr = Attributes[typeof (DescriptionAttribute)] as DescriptionAttribute;
			permissionAttr = descriptor.Attributes[typeof (RequiredPermissionAttribute)] as RequiredPermissionAttribute;
		}