// This function will load ISF into the ink object. // It will also pull the data stored in the object's extended properties and // repopulate the text boxes. private void LoadISF(Stream s) { Microsoft.Ink.Ink loadedInk = new Microsoft.Ink.Ink(); byte[] isfBytes = new byte[s.Length]; // read in the ISF s.Read(isfBytes, 0, (int)s.Length); // load the ink into a new ink object // once an ink object has been "dirtied" it can never load ink again loadedInk.Load(isfBytes); // temporarily disable the ink collector and swap ink objects // We checked the InkCollector.CollectingInk property to verify // the user has stopped inking. Otherwise, Enabled will throw // InvalidOperationException. ic.Enabled = false; ic.Ink = loadedInk; ic.Enabled = true; // Repaint the inkable region Signature.Invalidate(); ExtendedProperties inkProperties = ic.Ink.ExtendedProperties; // Get the raw data out of this stroke's extended // properties list, using our previously defined // Guid as a key to the extended property we want. // Since the save method stored the first and last // name information as extended properties, we can // remove this information now that the load is complete. if (inkProperties.DoesPropertyExist(FirstName)) { FirstNameBox.Text = (String)inkProperties[FirstName].Data; inkProperties.Remove(FirstName); } else { FirstNameBox.Text = String.Empty; } if (inkProperties.DoesPropertyExist(LastName)) { LastNameBox.Text = (String)inkProperties[LastName].Data; inkProperties.Remove(LastName); } else { LastNameBox.Text = String.Empty; } }
virtual public void ExtendedProperties_SetValue(String propertyName, String propertyValue) { if (ExtendedProperties.ContainsKey(propertyName)) { ExtendedProperties.Remove(propertyName); } ExtendedProperties.Add(propertyName, propertyValue); return; }
private void merge(ExtendedProperties repoExtendedProperties, ExtendedProperties columnExtendedProperties) { foreach (var extendedProperty in columnExtendedProperties.ToList()) { if (repoExtendedProperties.Contains(extendedProperty.Name)) { continue; } repoExtendedProperties.Add(extendedProperty); columnExtendedProperties.Remove(extendedProperty.Name); } }
private T GetExtendedProperty <T>(string propertyName, T defaultValue) { if (ExtendedProperties.ContainsKey(propertyName)) { object obj = ExtendedProperties[propertyName]; if (obj != null && obj is T) { return((T)obj); } ExtendedProperties.Remove(propertyName); } return(null); }
// This function saves the form in ISF format. // It uses ExtendedProperties to preserve the first and last names. // ExtendedProperties are an easy way to store non-ink data within an // ink object. In this case, there is no outer format which contains the // ink, so the only place to store the names is within the ink object itself. private void SaveISF(Stream s) { byte[] isf; // This is the ink object which will be serialized ExtendedProperties inkProperties = ic.Ink.ExtendedProperties; // Store the name fields in the ink object // These fields will roundtrip through the ISF format // Ignore empty fields since strictly empty strings // cannot be stored in ExtendedProperties. if (FirstNameBox.Text.Length > 0) { inkProperties.Add(FirstName, FirstNameBox.Text); } if (LastNameBox.Text.Length > 0) { inkProperties.Add(LastName, LastNameBox.Text); } // Perform the serialization isf = ic.Ink.Save(PersistenceFormat.InkSerializedFormat); // If the first and last names were added as extended // properties to the ink, remove them - these properties // are only used for the save and there is no need to // keep them around on the ink object. if (inkProperties.DoesPropertyExist(FirstName)) { inkProperties.Remove(FirstName); } if (inkProperties.DoesPropertyExist(LastName)) { inkProperties.Remove(LastName); } // Write the ISF to the stream s.Write(isf, 0, isf.Length); }
private void SetExtendedProperty <T>(string propertyName, string value) { if (string.IsNullOrEmpty(value)) { if (ExtendedProperties.ContainsKey(propertyName)) { ExtendedProperties.Remove(propertyName); } } else if (ExtendedProperties.ContainsKey(propertyName)) { ExtendedProperties[propertyName] = value; } else { ExtendedProperties.Add(propertyName, value); } }
private void SetExtendedProperty <T>(string propertyName, T?value) where T : struct { if (value.HasValue) { if (ExtendedProperties.ContainsKey(propertyName)) { ExtendedProperties[propertyName] = value.Value; } else { ExtendedProperties.Add(propertyName, value.Value); } } else if (ExtendedProperties.ContainsKey(propertyName)) { ExtendedProperties.Remove(propertyName); } }
public void RemoveItem(IContext context, string path, bool recurse) { _collection.Remove(_property.ID); }