示例#1
0
        public virtual int UpdateProperty(uint commandId, ref PropertyKey key, PropVariantRef currentValue, out PropVariant newValue)
        {
            Command command = ParentCommandManager.Get((CommandId)commandId);

            if (command == null)
            {
                return(NullCommandUpdateProperty(commandId, ref key, currentValue, out newValue));
            }

            try
            {
                newValue = new PropVariant();
                command.GetPropVariant(key, currentValue, ref newValue);

                if (newValue.IsNull())
                {
                    Trace.Fail("Didn't property update property for " + PropertyKeys.GetName(key) + " on command " + ((CommandId)commandId).ToString());

                    newValue = PropVariant.FromObject(currentValue.PropVariant.Value);
                }
            }
            catch (Exception ex)
            {
                Trace.Fail("Exception in UpdateProperty for " + PropertyKeys.GetName(key) + " on command " + commandId + ": " + ex);
                newValue = PropVariant.FromObject(currentValue.PropVariant.Value);
            }

            return(HRESULT.S_OK);
        }
示例#2
0
        /// <summary>
        /// Called during Loaded() method to copy values from PropertyKeys and PropertyValues
        /// to the CustomFields NameValueCollection
        /// </summary>
        internal void DeserializeCustomFields()
        {
            _nvc.Clear();

            if (PropertyKeys != null && PropertyValues != null)
            {
                char[] splitter = new char[1] {
                    ':'
                };
                string[] keyNames = PropertyKeys.Split(splitter);

                for (int i = 0; i < (keyNames.Length / 4); i++)
                {
                    int    start = int.Parse(keyNames[(i * 4) + 2], CultureInfo.InvariantCulture);
                    int    len   = int.Parse(keyNames[(i * 4) + 3], CultureInfo.InvariantCulture);
                    string key   = keyNames[i * 4];

                    if (((keyNames[(i * 4) + 1] == "S") && (start >= 0)) && (len > 0) && (PropertyValues.Length >= (start + len)))
                    {
                        _nvc[key] = PropertyValues.Substring(start, len);
                    }
                }
            }

            _isCustomReady = true;
        }
示例#3
0
        public T GetPropertyValue <T>(string key)
        {
            var pk = PropertyKeys.FindByName(key);

            if (!pk.HasValue)
            {
                return(default);
示例#4
0
 internal override void PreviewMessage(Message message)
 {
     if (!this.IsTreeLoaded)
     {
         message.StopDispatch = true;
     }
     else
     {
         if (message.Id == Node.PropertyChangedMessage)
         {
             CalendarInvalidateFlags flags = PropertyKeys.GetPropertyFlags <CalendarInvalidateFlags>((message.Data as RadPropertyEventArgs).Key);
             this.Invalidate(flags);
         }
     }
 }
示例#5
0
        public static void WriteObject(IPortableDeviceKeyCollection collection)
        {
            Trace.WriteLine("###############################");
            uint num = 0;

            collection.GetCount(ref num);
            for (uint index = 0; index < num; index++)
            {
                PropertyKey key = new PropertyKey();
                collection.GetAt(index, ref key);

                PropertyKeys propertyKey = key.GetEnumFromAttrKey <PropertyKeys>();
                Trace.WriteLine($"##### {propertyKey}");
            }
        }
示例#6
0
 internal override void PreviewMessage(Message message)
 {
     if (!this.IsTreeLoaded)
     {
         message.StopDispatch = true;
     }
     else
     {
         if (message.Id == Node.PropertyChangedMessage)
         {
             ChartAreaInvalidateFlags flags = PropertyKeys.GetPropertyFlags <ChartAreaInvalidateFlags>((message.Data as RadPropertyEventArgs).Key);
             this.Invalidate(flags);
         }
         else if (message.Id == ChartSeriesModel.DataPointsModifiedMessageKey)
         {
             this.Invalidate(ChartAreaInvalidateFlags.All);
         }
     }
 }
示例#7
0
        public int NullCommandUpdateProperty(uint commandId, ref PropertyKey key, PropVariantRef currentValue, out PropVariant newValue)
        {
            try
            {
                newValue = new PropVariant();
                if (key == PropertyKeys.Enabled)
                {
                    newValue.SetBool(false);
                }
                else if (key == PropertyKeys.SmallImage)
                {
                    Bitmap bitmap = CommandResourceLoader.LoadCommandBitmap(((CommandId)commandId).ToString(), "SmallImage");
                    RibbonHelper.CreateImagePropVariant(bitmap, out newValue);
                }
                else if (key == PropertyKeys.SmallHighContrastImage)
                {
                    Bitmap bitmap =
                        CommandResourceLoader.LoadCommandBitmap(((CommandId)commandId).ToString(),
                                                                "SmallHighContrastImage") ??
                        CommandResourceLoader.LoadCommandBitmap(((CommandId)commandId).ToString(), "SmallImage");

                    RibbonHelper.CreateImagePropVariant(bitmap, out newValue);
                }
                else if (key == PropertyKeys.LargeImage)
                {
                    Bitmap bitmap = CommandResourceLoader.LoadCommandBitmap(((CommandId)commandId).ToString(), "LargeImage");
                    RibbonHelper.CreateImagePropVariant(bitmap, out newValue);
                }
                else if (key == PropertyKeys.LargeHighContrastImage)
                {
                    Bitmap bitmap =
                        CommandResourceLoader.LoadCommandBitmap(((CommandId)commandId).ToString(),
                                                                "LargeHighContrastImage") ??
                        CommandResourceLoader.LoadCommandBitmap(((CommandId)commandId).ToString(), "LargeImage");

                    RibbonHelper.CreateImagePropVariant(bitmap, out newValue);
                }
                else if (key == PropertyKeys.Label)
                {
                    string str = "Command." + ((CommandId)commandId).ToString() + ".LabelTitle";
                    newValue = new PropVariant(TextHelper.UnescapeNewlines(Res.GetProp(str)) ?? String.Empty);
                }
                else if (key == PropertyKeys.LabelDescription)
                {
                    string str = "Command." + ((CommandId)commandId).ToString() + ".LabelDescription";
                    newValue = new PropVariant(Res.GetProp(str) ?? String.Empty);
                }
                else if (key == PropertyKeys.TooltipTitle)
                {
                    string commandName = ((CommandId)commandId).ToString();
                    string str         = "Command." + commandName + ".TooltipTitle";
                    newValue = new PropVariant(Res.GetProp(str) ?? (Res.GetProp("Command." + commandName + ".LabelTitle") ?? String.Empty));
                }
                else if (key == PropertyKeys.TooltipDescription)
                {
                    string str = "Command." + ((CommandId)commandId).ToString() + ".TooltipDescription";
                    newValue = new PropVariant(Res.GetProp(str) ?? String.Empty);
                }
                else if (key == PropertyKeys.Keytip)
                {
                    newValue = new PropVariant("XXX");
                }
                else if (key == PropertyKeys.ContextAvailable)
                {
                    newValue.SetUInt((uint)ContextAvailability.NotAvailable);
                }
                else if (key == PropertyKeys.Categories)
                {
                    newValue = new PropVariant();
                    newValue.SetIUnknown(currentValue);
                }
                else if (key == PropertyKeys.RecentItems)
                {
                    object[] currColl = (object[])currentValue.PropVariant.Value;
                    newValue = new PropVariant();
                    newValue.SetSafeArray(currColl);
                    return(HRESULT.S_OK);
                }
                else if (key == PropertyKeys.ItemsSource)
                {
                    // This should only be necessary if you have created a gallery in the ribbon markup that you have not yet put into the command manager.
                    List <IUISimplePropertySet> list = new List <IUISimplePropertySet>();

                    OpenLiveWriter.Interop.Com.Ribbon.IEnumUnknown enumUnk = new BasicCollection(list);
                    newValue = new PropVariant();
                    newValue.SetIUnknown(enumUnk);
                    return(HRESULT.S_OK);
                }
                else if (key == PropertyKeys.StringValue)
                {
                    newValue = new PropVariant(String.Empty);
                }
                else if (key == PropertyKeys.SelectedItem)
                {
                    newValue = new PropVariant(0);
                }
                else if (key == PropertyKeys.DecimalValue)
                {
                    newValue.SetDecimal(new decimal(0));
                }
                else if (key == PropertyKeys.MinValue)
                {
                    newValue.SetDecimal(new decimal(0));
                }
                else if (key == PropertyKeys.MaxValue)
                {
                    newValue.SetDecimal(new decimal(100));
                }
                else if (key == PropertyKeys.Increment)
                {
                    newValue.SetDecimal(new decimal(1));
                }
                else if (key == PropertyKeys.DecimalPlaces)
                {
                    newValue.SetDecimal(new decimal(0));
                }
                else if (key == PropertyKeys.RepresentativeString)
                {
                    newValue.SetString("9999");
                }
                else if (key == PropertyKeys.FormatString)
                {
                    newValue.SetString(String.Empty);
                }
                else if (key == PropertyKeys.StandardColors)
                {
                    newValue = new PropVariant();
                    newValue.SetUIntVector(new uint[] { });
                }
                else if (key == PropertyKeys.StandardColorsTooltips)
                {
                    newValue = new PropVariant();
                    newValue.SetStringVector(new string[] { });
                }
                else if (key == PropertyKeys.BooleanValue)
                {
                    newValue = new PropVariant();
                    newValue.SetBool(false);
                }
                else
                {
                    Trace.Fail("Didn't properly update property for " + PropertyKeys.GetName(key) + " on command " + ((CommandId)commandId));
                    newValue = new PropVariant();
                }
            }
            catch (Exception ex)
            {
                Trace.Fail("Exception in UpdateProperty for " + PropertyKeys.GetName(key) + " on command " + commandId + ": " + ex);
                newValue = new PropVariant();
            }

            return(HRESULT.S_OK);
        }
示例#8
0
        public int CancelOverride(uint commandId, ref PropertyKey key)
        {
            try
            {
                IOverridableCommand overridableCommand = Get((CommandId)commandId) as IOverridableCommand;
                if (overridableCommand == null)
                {
                    return(HRESULT.E_INVALIDARG);
                }

                return(overridableCommand.CancelOverride(ref key));
            }
            catch (Exception ex)
            {
                Debug.Fail("Exception throw in CommandManager.OverrideProperty: " + ex + "\r\n\r\nCommand: " + commandId + " Key: " + PropertyKeys.GetName(key));
                throw;
            }
        }
示例#9
0
        public int UpdateProperty(uint commandId, ref PropertyKey key, PropVariantRef currentValue, out PropVariant newValue)
        {
            try
            {
                Command command = Get((CommandId)commandId);
                if (command == null)
                {
                    return(genericCommandHandler.NullCommandUpdateProperty(commandId, ref key, currentValue, out newValue));
                }

                return(command.UpdateProperty(ref key, currentValue, out newValue));
            }
            catch (Exception ex)
            {
                Debug.Fail("Exception throw in CommandManager.UpdateProperty: " + ex + "\r\n\r\nCommand: " + commandId + " Key: " + PropertyKeys.GetName(key));
                throw;
            }
        }
示例#10
0
 public Dictionary <string, PropertyKey> GetPropertiesWithNames()
 {
     return(PropertyKeys.PropListToDict(GetPropertyStore()));
 }