[]
Abstract class that provides base functionality to store and resolve formatting in objects.
public abstract class FormattingBag
For internal use.
protected const string KeyDelimiter = "#"
For internal use.
protected const string KeyFormat = "{0}#{1}"
Gets the base (this class) key for formatting properties.
protected virtual string BaseKey { get; }
Gets the parent (previous level) key for formatting properties.
protected string ParentKey { get; }
Gets the root (concatenation of the parent and base) key for formatting properties.
protected string RootKey { get; }
Gets the base keys to synchronize formatting properties with this object.
protected string[] SyncBaseKeys { get; }
Clears direct formatting in the object.
public virtual void ClearFormatting()
Concatenates a root key with a short formatting key.
protected string ConcateKeys(string rootKey, string key)
rootKey
stringA root formatting key.
key
stringA short formatting key.
The final formatting key.
Concatenates a root key with a short formatting key array.
protected string[] ConcateKeys(string rootKey, string[] keys)
rootKey
stringA root formatting key.
keys
string[]A short formatting key array.
The final formatting key array.
Concatenates a root key array with a short formatting key.
protected string[] ConcateKeys(string[] rootKeys, string key)
rootKeys
string[]A root formatting key array.
key
stringA short formatting key.
The final formatting key array.
Fixes all inherited values as "direct" values for this instance.
protected virtual void FixInheritedValues()
Gets the first part of short key from the full key for the formatting property.
protected string GetChildKeyPart(string formattingKey)
formattingKey
stringA full key of the formatting property/
A first part of short key of the formatting property.
Gets the direct formatting property value.
protected T GetDirectFormatting<T>(string key, T defaultValue)
key
stringThe short formatting property key.
defaultValue
TThe default value of the property.
A value of the property, if the property key not found, returns defaultValue
.
T
A type of the returning value.
Gets the direct formatting property value.
protected T GetDirectPropertyFormatting<T>(T defaultValue, string key = "")
defaultValue
TThe default value of the property.
key
stringThe property name. It should start with "Direct" prefix.
A value of the property, if the property key not found, returns defaultValue
.
T
A type of the returning value.
Gets the formatting property value.
protected T GetFormatting<T>(string key, T defaultValue, out int level, bool isFullKey = false)
key
stringThe short formatting property key.
defaultValue
TThe default value of the property.
level
intReturns the level of inheritance where the property is assigned.
isFullKey
boolWhether the key is full or short.
A value of the property, if the property key not found, returns defaultValue
.
T
A type of the returning value.
Gets the formatting property value.
protected T GetFormatting<T>(string key, T defaultValue)
key
stringThe short formatting property key.
defaultValue
TThe default value of the property.
A value of the property, if the property key not found, returns defaultValue
.
T
A type of the returning value.
Gets a full key for the formatting property.
protected string GetFormattingKey(string key)
key
stringA short key of the formatting property.
A full key for the formatting property.
Gets the formatting property value.
protected T GetPropertyFormatting<T>(T defaultValue, string key = "")
defaultValue
TThe default value of the property.
key
stringThe short formatting property key.
A value of the property, if the property key not found, returns defaultValue
.
T
A type of the returning value.
Gets a short key from the full key for the formatting property.
protected string GetShortKey(string formattingKey)
formattingKey
stringA full key of the formatting property/
A short key of the formatting property.
Gets whether the direct formatting contains any data for an object with specified keys.
protected virtual bool HasDirectFormatting(string parentKey, string baseKey)
parentKey
stringThe parent key of the object.
baseKey
stringThe base key of the object.
true if the direct formatting is applied to the object with specified keys.
Gets whether the direct formatting applied for the property.
protected bool HasDirectFormatting(string key = "")
key
stringThe short formatting property key.
true if the property is assigned in direct formatting.
Gets whether the attached FormattingBag class has direct formatting in the shape except ignored key.
protected bool HasDirectFormattingWithIgnore(string parentKey, string baseKey, string ignoredKeyPart)
parentKey
stringThe parent key of the object.
baseKey
stringThe base formatting key of the class.
ignoredKeyPart
stringThe ignored formatting key (or key part) of the class.
True if the attached FormattingBag class has direct formatting in the shape, otherwise false. Keys contained ignoredKeyPart
are ignored.
Gets whether the attached FormattingBag class has direct formatting in the shape except ignored key.
protected bool HasDirectFormattingWithIgnore(string baseKey, string ignoredKeyPart)
baseKey
stringThe base formatting key of the class.
ignoredKeyPart
stringThe ignored formatting key (or key part) of the class.
True if the attached FormattingBag class has direct formatting in the shape, otherwise false. Keys contained ignoredKeyPart
are ignored.
Gets whether the direct formatting applied for the property.
protected bool HasDirectPropertyFormatting(string key = "")
key
stringThe property name. It should start with "HasDirect" prefix.
true if the property is assigned in direct formatting.
Resets the direct formatting property.
protected void RemoveDirectFormatting(string key)
key
stringThe short formatting property key.
Sets the direct formatting property value.
protected void SetDirectPropertyFormatting(object value, string key = "")
value
objectThe formatting property value.
key
stringThe short formatting property key to set value.
Sets the direct formatting property value.
protected void SetDirectPropertyFormattingEx<T>(object value, T defaultValue, string key = "")
value
objectThe formatting property value.
defaultValue
TThe default value of the property.
key
stringThe short formatting property key to set value.
T
A type of the value.
If value equals default value then formatting will be removed.
Sets the formatting property value.
protected virtual void SetFormatting(string key, object value, bool tryRemoveInheritance = true)
key
stringThe short formatting property key to set value.
value
objectThe formatting property value.
tryRemoveInheritance
boolWhether to remove this instance inheritance and fix all inherited values as "direct" values.
Sets the formatting property value.
protected void SetFormatting<T>(string key, object value, T defaultValue, bool tryRemoveInheritance = true)
key
stringThe short formatting property key to set value.
value
objectThe formatting property value.
defaultValue
TThe default value of the property.
tryRemoveInheritance
boolWhether to remove this instance inheritance and fix all inherited values as "direct" values.
T
A type of the value.
If value equals default value then formatting will be removed.
Sets the formatting property value.
protected void SetPropertyFormatting(object value, string key = "")
value
objectThe formatting property value.
key
stringThe short formatting property key to set value.
Sets the formatting property value.
protected void SetPropertyFormattingEx<T>(object value, T defaultValue, string key = "")
value
objectThe formatting property value.
defaultValue
TThe default value of the property.
key
stringThe short formatting property key to set value.
T
A type of the value.
If value equals default value then formatting will be removed.
Gets the direct formatting property value.
protected bool TryGetDirectFormatting<T>(string key, T defaultValue, out T value, bool isFullKey = false)
key
stringThe short formatting property key.
defaultValue
TThe default value of the property.
value
TA value of the property, if the property key not found, returns defaultValue
.
isFullKey
boolWhether the key is full or short.
True if the property key found, otherwise false.
T
A type of the returning value.
Updates version of current GrapeCity.Documents.Word.IVersionedFormatting.
protected void UpdateVersion(int? newValue = null)
newValue
int?New value. If null then version will be increased by 1.