/// <summary> /// Initializes a new instance of the PropertyValue class. /// </summary> /// <param name="propertyContainer">The container of this property.</param> /// <param name="propertyName">The name of the property.</param> protected PropertyValue(IPropertyContainer propertyContainer, string propertyName) { Param.RequireNotNull(propertyContainer, "propertyContainer"); Param.RequireValidString(propertyName, "propertyName"); PropertyDescriptor descriptor = propertyContainer.PropertyDescriptors[propertyName]; if (descriptor == null) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Strings.PropertyDescriptorDoesNotExist, propertyName)); } this.propertyDescriptor = descriptor; }
public ContainerHelperBase(IPropertyContainer propertyContainer) { if( propertyContainer == null ) throw new ArgumentNullException( "propertyContainer" ); PropertyContainer = propertyContainer; var propChange = propertyContainer as INotifyPropertyChanged; if( propChange != null ) { propChange.PropertyChanged += new PropertyChangedEventHandler( OnPropertyContainerPropertyChanged ); } }
public static unsafe uint ReadUInt(IPropertyContainer propertyContainer, uint key) { uint output; propertyContainer.ReadProperty(key, new IntPtr(sizeof(uint)), &output); return output; }
public static unsafe void ReadPreAllocatedBytePtrArray(IPropertyContainer propertyContainer, uint key, byte[][] buffers) { GCHandle[] pinnedArrays = new GCHandle[buffers.Length]; // Pin arrays for( int i=0; i<buffers.Length; i++ ) pinnedArrays[i] = GCHandle.Alloc( buffers[i], GCHandleType.Pinned ); byte** pointerArray = stackalloc byte*[buffers.Length]; for( int i=0; i<buffers.Length; i++ ) pointerArray[i] = (byte*)(pinnedArrays[i].AddrOfPinnedObject().ToPointer()); propertyContainer.ReadProperty(key, new IntPtr(sizeof(IntPtr) * buffers.Length), pointerArray); for (int i = 0; i < buffers.Length; i++) pinnedArrays[i].Free(); }
public static unsafe IntPtr ReadIntPtr(IPropertyContainer propertyContainer, uint key) { IntPtr output; propertyContainer.ReadProperty(key, new IntPtr(sizeof(IntPtr)), &output); return output; }
public static unsafe bool ReadBool(IPropertyContainer propertyContainer, uint key) { return ReadUInt(propertyContainer, key) == (uint)Bool.TRUE ? true : false; }
private string ConstructCell(IPropertyRenderer propertyRenderer, IPropertyContainer source) { string textValue = propertyRenderer.Render(source); return(textValue); }
private static void ParseXML(XmlElement element, IPropertyContainer wo) { foreach (XmlNode node in element) { if (!(node is XmlElement)) continue; XmlElement childElement = (XmlElement)node; if (childElement.Name == "imgdir") { WzSubProperty sub = new WzSubProperty(childElement.GetAttribute("name")); wo.AddProperty(sub); ParseXML(childElement, (IPropertyContainer)sub); } else if (childElement.Name == "canvas") { WzCanvasProperty canvas = new WzCanvasProperty(childElement.GetAttribute("name")); canvas.PngProperty = new WzPngProperty(); MemoryStream pngstream = new MemoryStream(Convert.FromBase64String(childElement.GetAttribute("basedata"))); canvas.PngProperty.SetPNG((Bitmap)Image.FromStream(pngstream, true, true)); wo.AddProperty(canvas); ParseXML(childElement, (IPropertyContainer)canvas); } if (childElement.Name == "int") { WzCompressedIntProperty compressedInt = new WzCompressedIntProperty(childElement.GetAttribute("name"), int.Parse(childElement.GetAttribute("value"), formattingInfo)); wo.AddProperty(compressedInt); } if (childElement.Name == "double") { WzDoubleProperty doubleProp = new WzDoubleProperty(childElement.GetAttribute("name"), double.Parse(childElement.GetAttribute("value"), formattingInfo)); wo.AddProperty(doubleProp); } if (childElement.Name == "null") { WzNullProperty nullProp = new WzNullProperty(childElement.GetAttribute("name")); wo.AddProperty(nullProp); } if (childElement.Name == "sound") { WzSoundProperty sound = new WzSoundProperty(childElement.GetAttribute("name")); sound.SetDataUnsafe(Convert.FromBase64String(childElement.GetAttribute("basedata"))); wo.AddProperty(sound); } if (childElement.Name == "string") { string str = childElement.GetAttribute("value").Replace("<", "<").Replace("&", "&").Replace(">", ">").Replace("'", "'").Replace(""", "\""); WzStringProperty stringProp = new WzStringProperty(childElement.GetAttribute("name"), str); wo.AddProperty(stringProp); } if (childElement.Name == "short") { WzUnsignedShortProperty shortProp = new WzUnsignedShortProperty(childElement.GetAttribute("name"), ushort.Parse(childElement.GetAttribute("value"), formattingInfo)); wo.AddProperty(shortProp); } if (childElement.Name == "uol") { WzUOLProperty uol = new WzUOLProperty(childElement.GetAttribute("name"), childElement.GetAttribute("value")); wo.AddProperty(uol); } if (childElement.Name == "vector") { WzVectorProperty vector = new WzVectorProperty(childElement.GetAttribute("name"), new WzCompressedIntProperty("x", Convert.ToInt32(childElement.GetAttribute("x"))), new WzCompressedIntProperty("y", Convert.ToInt32(childElement.GetAttribute("y")))); wo.AddProperty(vector); } if (childElement.Name == "float") { WzByteFloatProperty floatProp = new WzByteFloatProperty(childElement.GetAttribute("name"), float.Parse(childElement.GetAttribute("value"), formattingInfo)); wo.AddProperty(floatProp); } if (childElement.Name == "extended") { WzConvexProperty convex = new WzConvexProperty(childElement.GetAttribute("name")); wo.AddProperty(convex); ParseXML(childElement, (IPropertyContainer)convex); } } }
public void Accept(IPropertyContainer container, IPropertyVisitor visitor) { Accept((TContainer)container, visitor); }
public override object GetObjectValue(IPropertyContainer container) { var c = (TContainer)container; return(GetValue(ref c)); }
public void SetValue(IPropertyContainer container, TValue value) { SetValue((TContainer)container, value); }
public TValue GetValue(IPropertyContainer container) { return(GetValue((TContainer)container)); }
internal abstract ObjectContainerHelperBase CreateContainerHelper( IPropertyContainer parent );
public void AddObject(IPropertyContainer container, object item) { var c = (TContainer)container; Add(ref c, TypeConversion.Convert <TItem>(item)); }
internal abstract ObjectContainerHelperBase CreateContainerHelper(IPropertyContainer parent);
public void RemoveAt(IPropertyContainer container, int index) { var c = (TContainer)container; RemoveAt(ref c, index); }
public void InsertObject(IPropertyContainer container, int index, object item) { var list = GetValue((TContainer)container); list.Insert(index, TypeConversion.Convert <TItem>(item)); }
private void CreateWzProp(IPropertyContainer parent, WzPropertyType propType, string propName, object value) { IWzImageProperty addedProp; switch (propType) { case WzPropertyType.ByteFloat: addedProp = new WzByteFloatProperty(propName); break; case WzPropertyType.Canvas: addedProp = new WzCanvasProperty(propName); ((WzCanvasProperty)addedProp).PngProperty = new WzPngProperty(); break; case WzPropertyType.CompressedInt: addedProp = new WzCompressedIntProperty(propName); break; case WzPropertyType.Double: addedProp = new WzDoubleProperty(propName); break; /*case WzPropertyType.Sound: addedProp = new WzSoundProperty(propName); break;*/ case WzPropertyType.String: addedProp = new WzStringProperty(propName); break; case WzPropertyType.UnsignedShort: addedProp = new WzUnsignedShortProperty(propName); break; case WzPropertyType.Vector: addedProp = new WzVectorProperty(propName); ((WzVectorProperty)addedProp).X = new WzCompressedIntProperty("X"); ((WzVectorProperty)addedProp).Y = new WzCompressedIntProperty("Y"); break; default: throw new NotSupportedException("not supported type"); } addedProp.SetValue(value); parent.AddProperty(addedProp); }
public void Clear(IPropertyContainer container) { var list = GetValue((TContainer)container); list.Clear(); }
public ObjectContainerHelper( IPropertyContainer propertyContainer, object selectedObject ) : base( propertyContainer ) { _selectedObject = selectedObject; }
private TValue GetListValue(IPropertyContainer container) { var c = (TContainer)container; return(GetValue(ref c)); }
public static unsafe byte[] ReadBytes(IPropertyContainer propertyContainer, uint key) { IntPtr size; size = propertyContainer.GetPropertySize(key); byte[] data = new byte[size.ToInt64()]; fixed (byte* pData = data) { propertyContainer.ReadProperty(key, size, pData); } return data; }
public int Count(IPropertyContainer container) { var list = GetListValue(container); return(list.Count); }
public static unsafe IntPtr[] ReadIntPtrArray(IPropertyContainer propertyContainer, uint key) { IntPtr size = propertyContainer.GetPropertySize(key); long numElements = (long)size / sizeof(IntPtr); IntPtr[] ptrs = new IntPtr[numElements]; byte[] data = InteropTools.ReadBytes(propertyContainer, key); fixed (byte* pData = data) { void** pBS = (void**)pData; for (int i = 0; i < numElements; i++) ptrs[i] = new IntPtr(pBS[i]); } return ptrs; }
public void InsertObject(IPropertyContainer container, int index, object item) { var c = (TContainer)container; Insert(ref c, index, TypeConversion.Convert <TItem>(item)); }
public static unsafe string ReadString(IPropertyContainer propertyContainer, uint key) { IntPtr size; string s; size = propertyContainer.GetPropertySize((uint)key); byte[] stringData = new byte[size.ToInt64()]; fixed (byte* pStringData = stringData) { propertyContainer.ReadProperty((uint)key, size, pStringData); } s = Encoding.UTF8.GetString(stringData); int nullIndex = s.IndexOf('\0'); if (nullIndex >= 0) return s.Substring(0, nullIndex); else return s; }
public void AddNewItem(IPropertyContainer container) { var c = (TContainer)container; Add(ref c, m_CreateInstanceMethod(ref c)); }
public static unsafe ulong ReadULong(IPropertyContainer propertyContainer, uint key) { ulong output; propertyContainer.ReadProperty(key, new IntPtr(sizeof(ulong)), &output); return output; }
private void SearchWzProperties(IPropertyContainer parent) { foreach (WzImageProperty prop in parent.WzProperties) { if ((0 <= prop.Name.IndexOf(searchText, StringComparison.InvariantCultureIgnoreCase)) || (searchValues && prop is WzStringProperty && (0 <= ((WzStringProperty)prop).Value.IndexOf(searchText, StringComparison.InvariantCultureIgnoreCase)))) { if (listSearchResults) searchResultsList.Add(prop.FullPath.Replace(";", @"\")); else if (currentidx == searchidx) { if (prop.HRTag == null) ((WzNode)prop.ParentImage.HRTag).Reparse(); WzNode node = (WzNode)prop.HRTag; //if (node.Style == null) node.Style = new ElementStyle(); node.BackColor = Color.Yellow; coloredNode = node; node.EnsureVisible(); //DataTree.Focus(); finished = true; searchidx++; return; } else currentidx++; } if (prop is IPropertyContainer && prop.WzProperties.Count != 0) { SearchWzProperties((IPropertyContainer)prop); if (finished) return; } } }