internal PropertyDictionary Serialize(DocumentSerializationContext context) { EnsureSaved(context); PropertyDictionary dictionary = PropertyDictionary.EmptyDictionary(); dictionary.SetValueFor("fileName", context.GetRelativeFileName(_fileName)); dictionary.SetValueFor("physicalDimension", PropertyBuilders.FromSize(_physicalDimension)); return dictionary; }
void EnsureSaved(DocumentSerializationContext context) { if (_unsavedFileContents == null) return; DirectoryInfo directory = new DirectoryInfo(context.AbsolutePath); int nextAvailableNumber = 1; foreach (FileInfo file in directory.GetFiles()) { Match match = _unsavedPattern.Match(file.Name); if (!match.Success) continue; if (string.Compare(match.Groups[1].Value.Trim(), context.ExtensionlessName, true) != 0) continue; int thisNumber = int.Parse(match.Groups[2].Value); nextAvailableNumber = Math.Max(nextAvailableNumber, thisNumber + 1); } string extensionlessImageName = string.Format("{0}, Screen Shot {1}", context.ExtensionlessName, nextAvailableNumber); string fileName = Path.Combine(context.AbsolutePath, Path.ChangeExtension(extensionlessImageName, ".png")); using (Stream fileStream = new FileStream(fileName, FileMode.CreateNew, FileAccess.Write)) { fileStream.Write(_unsavedFileContents, 0, _unsavedFileContents.Length); } _fileName = fileName; _unsavedFileContents = null; }
internal override PropertyDictionary Serialize(DocumentSerializationContext context) { PropertyDictionary dictionary = base.Serialize(context); dictionary.SetValueFor("type", "label"); dictionary.SetValueFor("callOutOffsetInDocument", PropertyBuilders.FromSize(_callOutOffsetInDocument)); dictionary.SetValueFor("label", _label); dictionary.SetValueFor("caption", _caption); return dictionary; }
public PropertyDictionary Serialize(string desiredFilePath) { PropertyDictionary container = PropertyDictionary.EmptyDictionary(); PropertyDictionary document = PropertyDictionary.EmptyDictionary(); container.SetValueFor("pasteUp", document); // Later major versions can not be read: document.SetValueFor("majorVersion", 1); // Later minor versions can be read, but with potential loss of information; // they should not be saved over: document.SetValueFor("minorVersion", 0); DocumentSerializationContext context = new DocumentSerializationContext( Path.GetDirectoryName(desiredFilePath), Path.GetFileNameWithoutExtension(desiredFilePath)); PropertyDictionary imageLinkManagerDictionary = _imageLinkManager.Serialize(context); document.SetValueFor("imageLinkManager", imageLinkManagerDictionary); PropertyArray frames = PropertyArray.EmptyArray(); document.SetValueFor("frames", frames); foreach (DocumentFrame frame in _frames) { frames.AppendValue(frame.Serialize(context)); } return container; }
internal virtual PropertyDictionary Serialize(DocumentSerializationContext context) { PropertyDictionary dictionary = PropertyDictionary.EmptyDictionary(); dictionary.SetValueFor("offsetInDocument", PropertyBuilders.FromPoint(_offsetInDocument)); return dictionary; }
public PropertyDictionary Serialize(DocumentSerializationContext context) { PropertyDictionary dictionary = PropertyDictionary.EmptyDictionary(); dictionary.SetValueFor("type", "image"); dictionary.SetValueFor("imageLinkIndex", context.ImageLinkKeys[_imageLink]); return dictionary; }
public PropertyDictionary Serialize(DocumentSerializationContext context) { PropertyDictionary dictionary = PropertyDictionary.EmptyDictionary(); dictionary.SetValueFor("type", "fill"); dictionary.SetValueFor("color", PropertyBuilders.FromColor(_color)); return dictionary; }
internal override PropertyDictionary Serialize(DocumentSerializationContext context) { PropertyDictionary dictionary = base.Serialize(context); dictionary.SetValueFor("type", "rectangular"); dictionary.SetValueFor("clipBounds", PropertyBuilders.FromRectangle(_clipBounds)); dictionary.SetValueFor("framedObject", _framedObject.Serialize(context)); return dictionary; }
internal PropertyDictionary Serialize(DocumentSerializationContext context) { PropertyDictionary managerDictionary = PropertyDictionary.EmptyDictionary(); PropertyDictionary imageLinks = PropertyDictionary.EmptyDictionary(); managerDictionary.SetValueFor("imageLinks", imageLinks); int linkIndex = 1; foreach (ImageLink link in _referenceCountByLink.Keys) { context.ImageLinkKeys[link] = linkIndex; imageLinks.SetValueFor(linkIndex, link.Serialize(context)); linkIndex++; } return managerDictionary; }