protected override void SetNativeImpl(PropertyReceiver receiver, T value)
        {
            UpdateLinkTargets(receiver, value);

            // base handles things like ensuring redraws and such happen
            base.SetNativeImpl(receiver, value);
        }
        //------------------------------------------------------------------------//
        protected override T GetNativeImpl(PropertyReceiver receiver)
        {
            var wnd = (Window)receiver;

            // the try/catch is used instead of querying the existence of the user
            // string in order that for the 'usual' case - where the user string
            // exists - there is basically no additional overhead, and that any
            // overhead is incurred only for the initial creation of the user
            // string.
            // Maybe the only negative here is that an error gets logged, though
            // this can be treated as a 'soft' error.
            try
            {
                return(PropertyHelper.FromString <T>(wnd.GetUserString(d_userStringName)));
            }
            catch (UnknownObjectException)
            {
                System.GetSingleton().Logger
                .LogEvent("PropertyDefiniton::get: Defining new user string: " + d_userStringName);

                // HACK: FIXME: TODO: This const_cast is basically to allow the
                // above mentioned performance measure; the alternative would be
                // to just return d_default, and while technically correct, it
                // would be very slow.
                wnd.SetUserString(d_userStringName, d_default);

                return(PropertyHelper.FromString <T>(d_default));
            }
        }
Exemple #3
0
        //public override Property Clone()
        //{
        //    return new TypedProperty<T>(d_name, d_help,
        //                                _getter, _stringGetter,
        //                                _setter, _stringSetter);
        //}

        /// <summary>
        /// native set method, sets the property given a native type
        /// </summary>
        /// <param name="receiver"></param>
        /// <param name="value"></param>
        /// <seealso cref="Property.Set"/>
        public virtual void SetNative(PropertyReceiver receiver, T value)
        {
            if (IsWritable())
            {
                SetNativeImpl(receiver, value);
            }
            else
            {
                throw new InvalidRequestException("Property " + d_origin + ":" + d_name + " is not writable!");
            }
        }
Exemple #4
0
 /// <summary>
 /// native get method, returns the native type by copy
 /// </summary>
 /// <param name="receiver"></param>
 /// <returns></returns>
 /// <seealso cref="Property.Get"/>
 public virtual T GetNative(PropertyReceiver receiver)
 {
     if (IsReadable())
     {
         return(GetNativeImpl(receiver));
     }
     else
     {
         throw new InvalidRequestException("Property " + d_origin + ":" + d_name + " is not readable!");
     }
 }
        /// <summary>
        /// Return a pointer to the target window with the given name.
        /// </summary>
        /// <param name="receiver"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        protected Window GetTargetWindow(PropertyReceiver receiver, string name)
        {
            if (String.IsNullOrEmpty(name))
            {
                return((Window)receiver);
            }

            // handle link back to parent.  Return receiver if no parent.
            if (name == S_parentIdentifier)
            {
                return(((Window)receiver).GetParent());
            }

            return(((Window)receiver).GetChild(name));
        }
        protected void UpdateLinkTargets(PropertyReceiver receiver, T value)
        {
            foreach (var i in d_targets)
            {
                var targetWnd = GetTargetWindow(receiver, i.Item1);

                // only try to set property if target is currently valid.
                if (targetWnd != null)
                {
                    targetWnd.SetProperty(String.IsNullOrEmpty(i.Item2)
                                              ? d_name
                                              : i.Item2, PropertyHelper.ToString(value));
                }
            }
        }
        // override members from FalagardPropertyBase
        //------------------------------------------------------------------------//
        protected override T GetNativeImpl(PropertyReceiver receiver)
        {
            var i          = d_targets[0];
            var target_wnd = GetTargetWindow(receiver, i.Item1);

            // if no target, or target (currently) invalid, return the default value
            if (d_targets.Count == 0 || target_wnd == null)
            {
                return(PropertyHelper.FromString <T>(d_default));
            }

            // otherwise return the value of the property for first target, since
            // this is considered the 'master' target for get operations.
            return(PropertyHelper.FromString <T>(target_wnd.GetProperty(String.IsNullOrEmpty(i.Item2) ? d_name : i.Item2)));
        }
        protected override void SetNativeImpl(PropertyReceiver receiver, T value)
        {
            if (d_writeCausesLayout)
            {
                ((Window)receiver).PerformChildWindowLayout();
            }

            if (d_writeCausesRedraw)
            {
                ((Window)receiver).Invalidate(false);
            }

            if (!String.IsNullOrEmpty(d_eventFiredOnWrite))
            {
                throw new NotImplementedException();
                //WindowEventArgs args = new WindowEventArgs((Window) receiver);
                //args.window.FireEvent(d_eventFiredOnWrite, args, d_eventNamespace);
            }
        }
Exemple #9
0
 /*!
  * \brief
  *  Writes out an XML representation of this class to the given stream.
  *
  * \note
  *  This would normally have been implemented via XMLGenerator base class, but in this
  *  case we require the target PropertyReceiver in order to obtain the property value.
  */
 public virtual void WriteXMLToStream(PropertyReceiver receiver, XMLSerializer xml_stream)
 {
     if (d_writeXML)
     {
         xml_stream.OpenTag(XMLElementName)
         .Attribute(NameXMLAttributeName, d_name);
         // Detect wether it is a long property or not
         // Long property are needed if
         var value = Get(receiver);
         if (value.Contains("\n"))
         {
             xml_stream.Text(value);
         }
         else
         {
             xml_stream.Attribute(ValueXMLAttributeName, Get(receiver));
         }
         xml_stream.CloseTag();
     }
 }
Exemple #10
0
 /// <summary>
 /// Return the current value of the Property as a String
 /// </summary>
 /// <param name="receiver">
 /// Pointer to the target object.
 /// </param>
 /// <returns>
 /// String object containing a textual representation of the current value of the Property
 /// </returns>
 public abstract string Get(PropertyReceiver receiver);
 //------------------------------------------------------------------------//
 public override void InitialisePropertyReceiver(PropertyReceiver receiver)
 {
     UpdateLinkTargets(receiver, PropertyHelper.FromString <T>(this.d_default));
 }
Exemple #12
0
 public override void Set(PropertyReceiver receiver, string value)
 {
     SetNative(receiver, PropertyHelper.FromString <T>(value));
 }
Exemple #13
0
 public override string Get(PropertyReceiver receiver)
 {
     return(PropertyHelper.ToString(GetNative(receiver)));
 }
Exemple #14
0
 /// <summary>
 /// function to allow initialisation of a PropertyReceiver.
 /// </summary>
 /// <param name="receiver"></param>
 public virtual void InitialisePropertyReceiver(PropertyReceiver receiver)
 {
 }
Exemple #15
0
 protected override void SetNativeImpl(PropertyReceiver receiver, T value)
 {
     _setter((TWindowRenderer)((Window)receiver).GetWindowRenderer(), value);
 }
Exemple #16
0
 protected override void SetNativeImpl(PropertyReceiver receiver, T value)
 {
     _setter((TWindow)receiver, value);
 }
Exemple #17
0
 protected abstract void SetNativeImpl(PropertyReceiver receiver, T value);
 protected override void SetNativeImpl(PropertyReceiver receiver, T value)
 {
     SetWindowUserString((Window)receiver, PropertyHelper.ToString(value));
     base.SetNativeImpl(receiver, value);
 }
        // TODO: ~PropertyDefinition() {}

        public override void InitialisePropertyReceiver(PropertyReceiver receiver)
        {
            SetWindowUserString((Window)receiver, this.d_default);
        }
Exemple #20
0
 protected abstract T GetNativeImpl(PropertyReceiver receiver);
Exemple #21
0
 /*!
  * \brief
  *  Sets the value of the property
  *
  * \param receiver
  *  Pointer to the target object.
  *
  * \param value
  *  A String object that contains a textual representation of the new value to assign to the Property.
  *
  * \return
  *  Nothing.
  *
  * \exception InvalidRequestException	Thrown when the Property was unable to interpret the content of \a value.
  */
 public abstract void Set(PropertyReceiver receiver, string value);
Exemple #22
0
 protected override T GetNativeImpl(PropertyReceiver receiver)
 {
     return(_getter((TWindow)receiver));
 }
Exemple #23
0
 /*!
  * \brief
  *  Returns whether the property is at it's default value.
  *
  * \param receiver
  *  Pointer to the target object.
  *
  * \return
  *  - true if the property has it's default value.
  *  - false if the property has been modified from it's default value.
  */
 public virtual bool IsDefault(PropertyReceiver receiver)
 {
     return(Get(receiver) == GetDefault(receiver));
 }
Exemple #24
0
 protected override T GetNativeImpl(PropertyReceiver receiver)
 {
     return(_getter((TWindowRenderer)((Window)receiver).GetWindowRenderer()));
 }
Exemple #25
0
 /// <summary>
 /// Returns the default value of the Property as a String.
 /// </summary>
 /// <param name="receiver">
 /// Pointer to the target object.
 /// </param>
 /// <returns>
 /// String object containing a textual representation of the default value for this property.
 /// </returns>
 public virtual string GetDefault(PropertyReceiver receiver)
 {
     return(d_default);
 }