public static void Send(IntPtr fd, IPListElement plist) { PListRoot root = new PListRoot(); root.Root = plist; byte[] buffer; using (MemoryStream stream = new MemoryStream()) { root.Save(stream, PListFormat.Xml); buffer = stream.ToArray(); } var be_length = IPAddress.HostToNetworkOrder(buffer.Length); var be_buffer = BitConverter.GetBytes(be_length); int sent; sent = send(fd, be_buffer, 4, 0); if (sent != 4) { throw new PlistServiceException("发送数据边界失败"); } sent = send(fd, buffer, buffer.Length, 0); if (sent != buffer.Length) { throw new PlistServiceException("发送数据失败"); } }
public MainWindow() { InitializeComponent(); try { var backupFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Apple Computer\\MobileSync\\Backup"); var files = Directory.GetDirectories(backupFolder); foreach (string file in files) { var infoPath = Path.Combine(file, "Info.plist"); var plist = PListRoot.Load(infoPath).Root as PListDict; var apps = plist["Installed Applications"] as PListArray; if (apps.Contains(new PListString("MZCZ5SMF8U.iCacher"))) { var date = plist["Last Backup Date"] as PListDate; var name = plist["Display Name"] as PListString; availableBackups.Add(new Tuple <string, string, string>(date.Value.ToShortDateString(), name.Value, file)); } } } catch (Exception e) { MessageBox.Show("Unable to find iTunes backup folder. You must make an unencrypted backup of your device using iTunes before running this application."); } backupListView.DataContext = availableBackups; //selectListButton.IsEnabled = true; }
public static IPhoneBackup New(DirectoryInfo path) { try { string filename = System.IO.Path.Combine(path.FullName, "Info.plist"); PListRoot root = PListRoot.Load(filename); PListDict dict = root.Root as PListDict; IPhoneBackup backup = new IPhoneBackup(); backup.Path = path.FullName; foreach (var p in dict) { switch (p.Key) { case "Device Name": backup.DeviceName = p.Value().ToString(); break; case "Display Name": backup.DisplayName = p.Value().ToString(); break; case "Last Backup Date": backup.LastBackupDate = p.Value().ToString(); break; } } return(backup); } catch (Exception e) { throw new FileLoadException("No backup at " + path, e); } }
void Modify() { string src = dirName + "\\" + fileName + @"\Payload\WeChat.app\Info.plist"; try { PListRoot root = PListRoot.Load(src); PListDict dic = (PListDict)root.Root; dic["CFBundleDisplayName"] = new PListString(WeChatName); dic["CFBundleIdentifier"] = new PListString(Guid.NewGuid().ToString()); root.Root = dic; root.Save(src, PListFormat.Xml); } catch (Exception ex) { MessageBox.Show("修改失败"); } if (iconNum != 3) { string route = dirName + "\\" + fileName + @"\Payload\WeChat.app"; string desPath = route + @"\[email protected]"; del(desPath, true); System.IO.File.Copy(System.AppDomain.CurrentDomain.BaseDirectory + @"img\" + iconNum.ToString() + ".png", desPath); string infoPlist = route + @"\zh_CN.lproj\InfoPlist.strings"; del(infoPlist, true); ChangeFileName(route + @"\zh_CN.lproj\" + iconNum.ToString() + ".plist", route + @"\zh_CN.lproj\InfoPlist.strings"); } }
private static PListDict ReadPlist(string filePath) { PListRoot plistRoot = (PListRoot)null; using (FileStream fileStream = File.Open(filePath, FileMode.Open, FileAccess.Read)) plistRoot = PListRoot.Load((Stream)fileStream); return((PListDict)plistRoot.Root); }
public PListBrowser(PListRoot root) { InitializeComponent(); if (root.Root is PListArray) PopulateArray(root.Root as PListArray, ""); else PopulateRecurse(root.Root as PListDict, ""); }
public static IPListElement Receive(IntPtr fd) { int bytes = 0; IntPtr p_length = IntPtr.Zero; IntPtr p_content = IntPtr.Zero; try { //读取边界 p_length = Marshal.AllocHGlobal(4); bytes = recv(fd, p_length, 4, 0); if (bytes != 4) { throw new PlistServiceException("接收数据边界失败"); } var be_length = Marshal.ReadInt32(p_length); var length = IPAddress.NetworkToHostOrder(be_length); if (length > (1 << 24)) { throw new PlistServiceException("接收数据长度过大"); } //读取内容 p_content = Marshal.AllocHGlobal(length); int offset = 0; while (offset < length) { bytes = recv(fd, new IntPtr((long)p_content + offset), length - offset, 0); if (bytes <= 0) { throw new PlistServiceException("接收数据失败"); } offset += bytes; } byte[] content = new byte[length]; Marshal.Copy(p_content, content, 0, length); using (MemoryStream stream = new MemoryStream(content)) { PListRoot plist = PListRoot.Load(stream); return(plist.Root); } } finally { Marshal.FreeHGlobal(p_length); Marshal.FreeHGlobal(p_content); } }
static void Main(string[] args) { PListRoot root = PListRoot.Load("com.apple.springboard.plist"); using (MemoryStream memStream = new MemoryStream()) { root.Save(memStream, PListFormat.Xml); Console.Write(Encoding.UTF8.GetString(memStream.ToArray())); } root.Save("com.apple.springboard.XML.plist", PListFormat.Xml); root.Save("com.apple.springboard.BIN.plist", PListFormat.Binary); }
private string GetTextureFileName(string plistFilePath) { try { string path2 = ((PListElement <string>)((PListRoot.Load(plistFilePath).Root as PListDict)["metadata"] as PListDict)["textureFileName"]).Value; return(Path.Combine(Path.GetDirectoryName(plistFilePath), path2)); } catch { return((string)null); } }
public static PlistImageFormat CreatePlistFormat(string plistFilePath) { try { return(PlistImageFormatFactory.CreatePlistFormat(PListRoot.Load(plistFilePath).Root as PListDict)); } catch (Exception ex) { LogConfig.Logger.Error((object)ex); return((PlistImageFormat)null); } }
public static bool CheckIsImage(string plistFilePath) { if (!PListImageReader.CheckFile(plistFilePath)) { return(false); } PListRoot listRoot = (PListRoot)null; using (FileStream fileStream = File.Open(plistFilePath, FileMode.Open, FileAccess.Read)) listRoot = PListRoot.Load((Stream)fileStream); return(PListImageReader.CheckPList(listRoot)); }
/// <summary> /// 将Plist数据转换成Json /// </summary> /// <param name="buffer"></param> /// <returns></returns> public static JToken PlistToJson(Stream plistFile) { PListRoot root = PListRoot.Load(plistFile); using (MemoryStream memXmlStream = new MemoryStream()) { root.Save(memXmlStream, PListFormat.Xml); memXmlStream.Seek(0, SeekOrigin.Begin); return(PlistXmlToJson(memXmlStream)); } }
public PListBrowser(PListRoot root) { InitializeComponent(); if (root.Root is PListArray) { PopulateArray(root.Root as PListArray, ""); } else { PopulateRecurse(root.Root as PListDict, ""); } }
public static void ShowIPListElement(IPListElement plist) { PListRoot r = new PListRoot(); r.Format = PListFormat.Xml; r.Root = plist; var xml = System.IO.Path.GetTempPath() + ".xml"; r.Save(xml); Process.Start("IEXPLORE.EXE", xml); }
public Form Open() { IPhoneFile file = SelectedFiles.FirstOrDefault(); if (file != null) { FileInfo info = FileManager.GetWorkingFile(SelectedBackup, file, true); PListRoot root = PListRoot.Load(info.FullName); return(new PListBrowser(root)); } return(null); }
//private void button1_Click(object sender, EventArgs e) //{ // string path = @"E:\MyWorkSpace\CS\PlistResResolver\PlistResResolver\testres\battleStart.plist"; // string destPath = @"E:\MyWorkSpace\CS\PlistResResolver\PlistResResolver\testres"; // ExportPlist(path, destPath); //} void ExportPlist(string plistFilePath, string exportDestPath) { PListRoot root = PListRoot.Load(plistFilePath); PListDict dic = (PListDict)root.Root; PListDict frames = (PListDict)dic["frames"]; PListDict metadata = (PListDict)dic["metadata"]; // string texFileName = (PListString)metadata["textureFileName"]; texFileName = texFileName.Replace(".ccz", ".png"); string dir = Path.GetDirectoryName(plistFilePath); string texPath = Path.Combine(dir, texFileName); string alphaTexPath = texPath.Insert(texPath.IndexOf("."), "@alpha"); Console.Out.WriteLine("texPath = " + texPath + "alphaTex = " + alphaTexPath); try { if (!File.Exists(texPath)) { _syncContext.Post(ShowMessage, "File Not Found:" + texPath); return; } Bitmap image = new Bitmap(texPath, false); Bitmap alpha = null; if (hasAlphaSource) { if (!File.Exists(alphaTexPath)) { _syncContext.Post(ShowMessage, "File Not Found:" + alphaTexPath); return; } alpha = new Bitmap(alphaTexPath, false); } // foreach (KeyValuePair <string, IPListElement> pair in frames) { string picName = pair.Key; string newPicPath = Path.Combine(exportDestPath, picName); //Console.Out.WriteLine("newPicPath = " + newPicPath); ReadPic(newPicPath, (PListDict)pair.Value, image, alpha); } } catch (Exception e) { _syncContext.Post(ShowMessage, e.ToString()); } Console.Out.WriteLine("End"); }
/// <summary> /// 将Plist数据转换成Json /// </summary> /// <param name="buffer"></param> /// <returns></returns> public static JToken PlistToJson(byte[] buffer) { using (MemoryStream memSourceStream = new MemoryStream()) { memSourceStream.Write(buffer, 0, buffer.Length); memSourceStream.Seek(0, SeekOrigin.Begin); PListRoot root = PListRoot.Load(memSourceStream); using (MemoryStream memXmlStream = new MemoryStream()) { root.Save(memXmlStream, PListFormat.Xml); memXmlStream.Seek(0, SeekOrigin.Begin); return(PlistXmlToJson(memXmlStream)); } } }
public void SavePlist(List <PackerSprite> saveSpriteList, string strImageName) { this.SavePlistList(strImageName + ".plist", false); PListRoot plistRoot = new PListRoot(); PListDict plistDict1 = new PListDict(); plistRoot.Root = (IPListElement)plistDict1; PListDict plistDict2 = new PListDict(); plistDict1.Add("frames", (IPListElement)plistDict2); foreach (PackerSprite saveSprite in saveSpriteList) { PListDict plistDict3 = new PListDict(); plistDict2.Add(saveSprite.name, (IPListElement)plistDict3); plistDict3.Add("width", (IPListElement) new PListInteger((long)(int)saveSprite.width)); plistDict3.Add("height", (IPListElement) new PListInteger((long)(int)saveSprite.height)); plistDict3.Add("originalWidth", (IPListElement) new PListInteger((long)(int)saveSprite.originalWidth)); plistDict3.Add("originalHeight", (IPListElement) new PListInteger((long)(int)saveSprite.originalHeight)); plistDict3.Add("x", (IPListElement) new PListInteger((long)(int)saveSprite.x)); plistDict3.Add("y", (IPListElement) new PListInteger((long)(int)saveSprite.y)); plistDict3.Add("offsetX", (IPListElement) new PListReal((double)saveSprite.offsetX)); plistDict3.Add("offsetY", (IPListElement) new PListReal((double)saveSprite.offsetY)); } string str1 = strImageName + ".png"; string str2 = Path.Combine(this.fullPathStr, strImageName); PListDict plistDict4 = new PListDict(); plistDict1.Add("metadata", (IPListElement)plistDict4); plistDict4.Add("format", (IPListElement) new PListInteger(0L)); plistDict4.Add("textureFileName", (IPListElement) new PListString(str1)); plistDict4.Add("realTextureFileName", (IPListElement) new PListString(str1)); string str3 = "{" + (object)this.maxWidth + "," + (object)this.maxHeight + "}"; plistDict4.Add("size", (IPListElement) new PListString(str3)); PListDict plistDict5 = new PListDict(); plistDict1.Add("texture", (IPListElement)plistDict5); plistDict5.Add("width", (IPListElement) new PListInteger((long)this.maxWidth)); plistDict5.Add("height", (IPListElement) new PListInteger((long)this.maxHeight)); this.PlistDirectory.Add(str2 + ".plist", plistRoot); }
protected override PListRoot OnToPlist(List <ImageInfo> imageList, Size size, string imageKey) { PListRoot plistRoot = new PListRoot(); PListDict plistDict1 = new PListDict(); plistRoot.Root = (IPListElement)plistDict1; PListDict plistDict2 = new PListDict(); plistDict1.Add("frames", (IPListElement)plistDict2); foreach (ImageInfo image in imageList) { PListDict plistDict3 = new PListDict(); plistDict2.Add(image.Name, (IPListElement)plistDict3); string str1 = PlistFormatHelp.ConvertToString(image.Bounding); plistDict3.Add("frame", (IPListElement) new PListString(str1)); string str2 = PlistFormatHelp.ConvertToString(new Point(image.SourceLocation.X + image.Bounding.Width / 2 - image.SourceSize.Width / 2, image.SourceSize.Height / 2 - (image.SourceLocation.Y + image.Bounding.Height / 2))); plistDict3.Add("offset", (IPListElement) new PListString(str2)); plistDict3.Add("rotated", (IPListElement) new PListBool(image.IsRotation)); string str3 = PlistFormatHelp.ConvertToString(image.SourceSize); plistDict3.Add("sourceSize", (IPListElement) new PListString(str3)); } PListDict plistDict4 = new PListDict(); plistDict1.Add("metadata", (IPListElement)plistDict4); plistDict4.Add("format", (IPListElement) new PListInteger(2L)); plistDict4.Add("textureFileName", (IPListElement) new PListString(imageKey)); plistDict4.Add("realTextureFileName", (IPListElement) new PListString(imageKey)); string str = "{" + (object)size.Width + "," + (object)size.Height + "}"; plistDict4.Add("size", (IPListElement) new PListString(str)); PListDict plistDict5 = new PListDict(); plistDict1.Add("texture", (IPListElement)plistDict5); plistDict5.Add("width", (IPListElement) new PListInteger((long)size.Width)); plistDict5.Add("height", (IPListElement) new PListInteger((long)size.Height)); return(plistRoot); }
private PListDict decompressPlist(string encodedPList) { var data = Convert.FromBase64String(encodedPList); var z = new ZStream(); MemoryStream oInStream = new MemoryStream(data); MemoryStream oOutStream = new MemoryStream(); var zIn = new ZInputStream(oInStream); byte[] buffer = new byte[2000]; int len; while ((len = zIn.read(buffer, 0, 2000)) > 0) { oOutStream.Write(buffer, 0, len); } oOutStream.Flush(); zIn.Close(); var plist = PListRoot.Load(oOutStream).Root as PListDict; oOutStream.Close(); return(plist); }
//GHashTable* eti_sync_get_contacts(EtiSync* sync, GError** error) public List <object> eti_sync_get_contacts() { IPListElement entities; IPListElement actions; long is_last; var contacts = new List <Object>(); sync.mobilesync_get_all_records_from_device(); do { sync.mobilesync_receive_changes(out entities, out is_last, out actions); var xml_string = entities.ToXmlString(); PListRoot r = new PListRoot(); r.Format = PListFormat.Xml; r.Root = entities; var xml = System.IO.Path.GetTempFileName() + ".xml"; r.Save(xml); Process.Start("IEXPLORE.EXE", xml); sync.mobilesync_acknowledge_changes_from_device(); Debug.WriteLine(entities); // if (!eti_contact_plist_parser_parse(parser, entities, error)) // break; } while (is_last == 0); //contacts = eti_contact_plist_parser_get_contacts(parser); return(contacts); }
public PListImageReader(string plistFilePath) { PListImageReader.CheckFile(plistFilePath); PListRoot listRoot = (PListRoot)null; using (FileStream fileStream = File.Open(plistFilePath, FileMode.Open, FileAccess.Read)) listRoot = PListRoot.Load((Stream)fileStream); if (listRoot == null || listRoot.Root == null || !(listRoot.Root is PListDict)) { throw new ArgumentException("给定的PList文件格式不正确."); } if (!PListImageReader.CheckPList(listRoot)) { throw new ArgumentException("给定的PList文件,不是大图合并的文件."); } this.rootElement = listRoot.Root as PListDict; this.plistFilePath = plistFilePath; this.plistFormatAnalysis = PlistImageFormatFactory.CreatePlistFormat(this.rootElement); this.ImageFilePath = this.plistFormatAnalysis.GetImageFilePath(plistFilePath); if (this.ImageFilePath == null || !File.Exists(this.ImageFilePath)) { throw new ArgumentException("对应的图片文件不存在."); } }
public DatabaseManager(string backupDir) { try { var manifestPath = Path.Combine(backupDir, "Manifest.db"); var manifestConn = new SQLiteConnection("Data Source=" + manifestPath + ";Version=3;"); manifestConn.Open(); DataSet mData = new DataSet(); string sql = "select fileId from Files where relativePath = \"Library/Preferences/MZCZ5SMF8U.iCacher.plist\""; SQLiteCommand command = new SQLiteCommand(sql, manifestConn); SQLiteDataAdapter DB = new SQLiteDataAdapter(command.CommandText, manifestConn); DB.Fill(mData); var fileId = mData.Tables[0].DefaultView[0]["fileId"].ToString(); var prefix = fileId.Substring(0, 2); var infoPath = Path.Combine(backupDir, prefix, fileId); //var infoPath = "C:\\Users\\Casey Cady\\Documents\\Documents\\cindy.plist"; var plist = PListRoot.Load(infoPath).Root as PListDict; token = (plist["GEOGlobals_mApiAccessToken"] as PListString).Value; var guid = (plist["GEOGlobals_mLoggedInUserGuid"] as PListString).Value; sql = "select fileId from Files where domain = \"AppDomain-MZCZ5SMF8U.iCacher\" and relativePath = \"Documents/" + guid + ".db\""; command = new SQLiteCommand(sql, manifestConn); DB = new SQLiteDataAdapter(command.CommandText, manifestConn); mData = new DataSet(); DB.Fill(mData); fileId = mData.Tables[0].DefaultView[0]["fileId"].ToString(); prefix = fileId.Substring(0, 2); var dbPath = Path.Combine(backupDir, prefix, fileId); // var dbPath = "C:\\Users\\Casey Cady\\Documents\\Documents\\cindy2.db"; conn = new SQLiteConnection("Data Source=" + dbPath + ";Version=3;"); conn.Open(); manifestConn.Close(); } catch (Exception e) { System.Windows.MessageBox.Show(e.ToString()); } }
public List <IPhoneApp> GetApps() { if (File.Exists(System.IO.Path.Combine(Path, "Manifest.mbdb"))) { List <IPhoneApp> list = new List <IPhoneApp>(); mbdb.MBFileRecord[] files = mbdb.ReadMBDB(Path, false, true); PListRoot root = PListRoot.Load(System.IO.Path.Combine(Path, "Manifest.plist")); PListDict di = root.Root as PListDict; PListDict apps = null; if ((apps = di["Applications"] as PListDict) == null) { return(list); } Dictionary <string, List <int> > filesByDomain = new Dictionary <string, List <int> >(); for (int i = 0; i < files.Length; ++i) { if ((files[i].Mode & 0xF000) == 0x8000) { string d = files[i].Domain; if (!filesByDomain.ContainsKey(d)) { filesByDomain.Add(d, new List <int>()); } filesByDomain[d].Add(i); } } foreach (var p in apps) { IPhoneApp app = new IPhoneApp(); app.Key = p.Key; PListDict appd = p.Value as PListDict; KeyValuePair <string, IPListElement> name = appd.FirstOrDefault(x => x.Key == "CFBundleDisplayName"); if (name.Value != null) { app.DisplayName = name.Value.Value().ToString(); } KeyValuePair <string, IPListElement> bname = appd.FirstOrDefault(x => x.Key == "CFBundleName"); if (bname.Value != null) { app.Name = bname.Value.Value().ToString(); } KeyValuePair <string, IPListElement> ident = appd.FirstOrDefault(x => x.Key == "CFBundleIdentifier"); if (ident.Value != null) { app.Identifier = ident.Value.Value().ToString(); } KeyValuePair <string, IPListElement> cont = appd.FirstOrDefault(x => x.Key == "Container"); if (cont.Value != null) { app.Container = cont.Value.Value().ToString(); } if (app.Name == null) { app.Name = app.Key; } if (app.DisplayName == null) { app.DisplayName = app.Name; } if (filesByDomain.ContainsKey("AppDomain-" + app.Key)) { app.Files = new List <IPhoneFile>(); foreach (int i in filesByDomain["AppDomain-" + app.Key]) { IPhoneFile ff = new IPhoneFile(); mbdb.MBFileRecord x = files[i]; ff.Key = x.key; ff.Domain = x.Domain; ff.Path = x.Path; ff.ModificationTime = x.aTime.ToString(); ff.FileLength = x.FileLength; app.Files.Add(ff); } filesByDomain.Remove("AppDomain-" + app.Key); } list.Add(app); } IPhoneApp system = new IPhoneApp(); system.Name = "System"; system.DisplayName = "---"; system.Identifier = "---"; system.Container = "---"; system.Files = new List <IPhoneFile>(); foreach (List <int> i in filesByDomain.Values) { foreach (int j in i) { IPhoneFile ff = new IPhoneFile(); mbdb.MBFileRecord x = files[j]; ff.Key = x.key; ff.Domain = x.Domain; ff.Path = x.Path; ff.ModificationTime = x.aTime.ToString(); ff.FileLength = x.FileLength; system.Files.Add(ff); } } list.Add(system); return(list); } else { throw new FileLoadException("Can only handle iTunes <= v9.2"); } }
private static bool CheckPList(PListRoot listRoot) { return(((Dictionary <string, IPListElement>)listRoot.Root).ContainsKey("metadata")); }
private static PListRoot ExportDocument(Omnigraffle.Document doc) { var root = new PListRoot(); root.Format = PListFormat.Xml; var dict = new PListDict(); var applicationVersion = new PListArray(); applicationVersion.Add(new PListString(doc.ApplicationVersion.Name)); applicationVersion.Add(new PListString(doc.ApplicationVersion.Version)); dict.Add("ApplicationVersion", applicationVersion); var sheets = new PListArray(); foreach (var sheet in doc.Canvas) { var sheet_dict = new PListDict(); sheet_dict.Add("ActiveLayerIndex", new PListInteger(sheet.ActiveLayerIndex)); sheet_dict.Add("AutoAdjust", new PListBool(sheet.AutoAdjust)); var backgroundGraphic = new PListDict(); backgroundGraphic.Add("Bounds", ExportBounds(sheet.BackgroundGraphic.Bounds)); backgroundGraphic.Add("Class", ExportBackgroundGraphicClass(sheet.BackgroundGraphic.Class)); backgroundGraphic.Add("ID", new PListInteger(sheet.BackgroundGraphic.ID)); var style = new PListDict(); var shadow = ExportShadow(sheet.BackgroundGraphic.Shadow); var stroke = new PListDict(); stroke.Add("Draws", new PListString(sheet.BackgroundGraphic.DrawStroke ? "YES" : "NO")); style.Add("shadow", shadow); style.Add("stroke", stroke); backgroundGraphic.Add("Style", style); sheet_dict.Add("BackgroundGraphic", backgroundGraphic); sheet_dict.Add("BaseZoom", new PListInteger(sheet.BaseZoom)); sheet_dict.Add("CanvasOrigin", new PListString(sheet.CanvasOrigin)); sheet_dict.Add("ColumnAlign", new PListInteger(sheet.ColumnAlign)); sheet_dict.Add("ColumnSpacing", new PListReal(sheet.ColumnSpacing)); sheet_dict.Add("DisplayScale", new PListString(sheet.DisplayScale)); sheet_dict.Add("HPages", new PListInteger(sheet.HPages)); var layers = new PListArray(); if (sheet.Layers.Count > 1) { foreach (var layer in sheet.Layers) { layers.Add(ExportLayer(layer)); } } else { layers.Add(ExportLayer(new Omnigraffle.Layer())); } sheet_dict.Add("Layers", layers); var layoutInfo = new PListDict(); layoutInfo.Add("Animate", new PListString(sheet.LayoutInfo.Animate ? "YES" : "NO")); if (sheet.LayoutInfo.AutoLayout) { layoutInfo.Add("AutoLayout", new PListInteger(1)); } if (sheet.LayoutInfo.HierarchicalOrientation == Omnigraffle.HierarchicalOrientation.LeftRight) { layoutInfo.Add("HierarchicalOrientation", new PListInteger(0)); } else if (sheet.LayoutInfo.HierarchicalOrientation == Omnigraffle.HierarchicalOrientation.TopBottom) { layoutInfo.Add("HierarchicalOrientation", new PListInteger(1)); } else if (sheet.LayoutInfo.HierarchicalOrientation == Omnigraffle.HierarchicalOrientation.RightLeft) { layoutInfo.Add("HierarchicalOrientation", new PListInteger(2)); } else if (sheet.LayoutInfo.HierarchicalOrientation == Omnigraffle.HierarchicalOrientation.BottomTop) { layoutInfo.Add("HierarchicalOrientation", new PListInteger(3)); } if (sheet.LayoutInfo.LayoutEngine == Omnigraffle.LayoutEngine.Circo) { layoutInfo.Add("layoutEngine", new PListString("circo")); } else if (sheet.LayoutInfo.LayoutEngine == Omnigraffle.LayoutEngine.Dot) { layoutInfo.Add("layoutEngine", new PListString("dot")); } else if (sheet.LayoutInfo.LayoutEngine == Omnigraffle.LayoutEngine.Neato) { layoutInfo.Add("layoutEngine", new PListString("neato")); } else if (sheet.LayoutInfo.LayoutEngine == Omnigraffle.LayoutEngine.Twopi) { layoutInfo.Add("layoutEngine", new PListString("twopi")); } layoutInfo.Add("circoMinDist", new PListReal(sheet.LayoutInfo.CircoMinDist)); layoutInfo.Add("circoSeparation", new PListReal(sheet.LayoutInfo.CircoSeparation)); layoutInfo.Add("dotRankSep", new PListReal(sheet.LayoutInfo.DotRankSep)); layoutInfo.Add("neatoSeparation", new PListReal(sheet.LayoutInfo.NeatoSeparation)); layoutInfo.Add("neatoLineLength", new PListReal(sheet.LayoutInfo.NeatoLineLength)); layoutInfo.Add("neatoOverlap", new PListBool(sheet.LayoutInfo.NeatoOverlap)); layoutInfo.Add("twopiOverlap", new PListBool(sheet.LayoutInfo.TwopiOverlap)); layoutInfo.Add("twopiSeparation", new PListReal(sheet.LayoutInfo.TwopiSeparation)); layoutInfo.Add("twopiRankSep", new PListReal(sheet.LayoutInfo.TwopiRankSep)); sheet_dict.Add("LayoutInfo", layoutInfo); if (sheet.Orientation == Omnigraffle.Orientation.Portrait) { sheet_dict.Add("Orientation", new PListInteger(0)); } else if (sheet.Orientation == Omnigraffle.Orientation.Landscape) { sheet_dict.Add("Orientation", new PListInteger(1)); } else if (sheet.Orientation == Omnigraffle.Orientation.PageSetup) { sheet_dict.Add("Orientation", new PListInteger(2)); } sheet_dict.Add("PrintOnePage", new PListBool(sheet.PrintOnePage)); sheet_dict.Add("RowAlign", new PListInteger(sheet.RowAlign)); sheet_dict.Add("RowSpacing", new PListReal(sheet.RowSpacing)); sheet_dict.Add("SheetTitle", new PListString(sheet.Title)); sheet_dict.Add("UniqueID", new PListInteger(sheet.UniqueId)); sheet_dict.Add("VPages", new PListInteger(sheet.VPages)); var graphics_array = new PListArray(); foreach (var graphic in sheet.GraphicsList) { graphics_array.Add(ExportGraphic(graphic)); } sheet_dict.Add("GraphicsList", graphics_array); sheet_dict.Add("GridInfo", new PListDict()); sheets.Add(sheet_dict); } dict.Add("Sheets", sheets); dict.Add("CreationDate", new PListString(doc.CreationDate.ToString("yyyy-MM-dd hh:mm:ss +0000"))); dict.Add("ModificationDate", new PListString(doc.ModificationDate.ToString("yyyy-MM-dd hh:mm:ss +0000"))); dict.Add("Creator", new PListString(doc.Creator)); dict.Add("GraphDocumentVersion", new PListInteger(doc.GraphDocumentVersion)); dict.Add("GuidesLocked", new PListString(doc.GuidesLocked ? "YES" : "NO")); dict.Add("GuidesVisible", new PListString(doc.GuidesVisible ? "YES" : "NO")); dict.Add("ImageCounter", new PListInteger(doc.ImageCounter)); dict.Add("KeepToScale", new PListBool()); dict.Add("LinksVisible", new PListString(doc.LinksVisible ? "YES" : "NO")); dict.Add("MagnetsVisible", new PListString(doc.MagnetsVisible ? "YES" : "NO")); dict.Add("NotesVisible", new PListString(doc.NotesVisible ? "YES" : "NO")); dict.Add("OriginVisible", new PListString(doc.OriginVisible ? "YES" : "NO")); dict.Add("PageBreaks", new PListString(doc.PageBreaks ? "YES" : "NO")); dict.Add("MasterSheets", new PListArray()); dict.Add("Modifier", new PListString()); var printInfo = new PListDict(); var bottomMargin = new PListArray(); bottomMargin.Add(new PListString("float")); bottomMargin.Add(new PListString(doc.PrintInfo.BottomMargin.ToString())); printInfo.Add("NSBottomMargin", bottomMargin); var leftMargin = new PListArray(); leftMargin.Add(new PListString("float")); leftMargin.Add(new PListString(doc.PrintInfo.LeftMargin.ToString())); printInfo.Add("NSLeftMargin", leftMargin); var rightMargin = new PListArray(); rightMargin.Add(new PListString("float")); rightMargin.Add(new PListString(doc.PrintInfo.RightMargin.ToString())); printInfo.Add("NSRightMargin", rightMargin); var topMargin = new PListArray(); topMargin.Add(new PListString("float")); topMargin.Add(new PListString(doc.PrintInfo.TopMargin.ToString())); printInfo.Add("NSTopMargin", topMargin); var horizonalPagination = new PListArray(); horizonalPagination.Add(new PListString("coded")); horizonalPagination.Add(new PListString(doc.PrintInfo.HorizonalPagination)); printInfo.Add("NSHorizonalPagination", horizonalPagination); var paperSize = new PListArray(); paperSize.Add(new PListString("size")); paperSize.Add(new PListString(doc.PrintInfo.PaperSize)); printInfo.Add("NSPaperSize", paperSize); var printReverseOrientation = new PListArray(); printReverseOrientation.Add(new PListString("int")); printReverseOrientation.Add(new PListString(doc.PrintInfo.PrintReverseOrientation ? "1" : "0")); printInfo.Add("NSPrintReverseOrientation", printReverseOrientation); dict.Add("PrintInfo", printInfo); dict.Add("ReadOnly", new PListString(doc.ReadOnly ? "YES" : "NO")); dict.Add("SmartAlignmentGuidesActive", new PListString(doc.SmartAlignmentGuidesActive ? "YES" : "NO")); dict.Add("SmartDistanceGuidesActive", new PListString(doc.SmartDistanceGuidesActive ? "YES" : "NO")); dict.Add("UseEntirePage", new PListBool(doc.UseEntirePage)); var windowInfo = new PListDict(); windowInfo.Add("CurrentSheet", new PListInteger(doc.WindowInfo.CurrentSheet)); var expanded_canvases = new PListArray(); foreach (var sheet in doc.Canvas.Where(s => s.Expanded)) { var canvas_dict = new PListDict(); canvas_dict.Add("name", new PListString(sheet.Title)); expanded_canvases.Add(canvas_dict); } windowInfo.Add("ExpandedCanvases", expanded_canvases); windowInfo.Add("Frame", new PListString(doc.WindowInfo.Frame)); windowInfo.Add("ListView", new PListBool(doc.WindowInfo.ListView)); windowInfo.Add("RightSidebar", new PListBool(doc.WindowInfo.RightSidebar)); windowInfo.Add("ShowRuler", new PListBool(doc.WindowInfo.ShowRuler)); windowInfo.Add("Sidebar", new PListBool(doc.WindowInfo.Sidebar)); windowInfo.Add("SidebarWidth", new PListInteger(doc.WindowInfo.SidebarWidth)); windowInfo.Add("OutlineWidth", new PListInteger(doc.WindowInfo.OutlineWidth)); windowInfo.Add("VisibleRegion", new PListString("{{0, 0}, {558, 720}}")); windowInfo.Add("Zoom", new PListReal(doc.WindowInfo.Zoom)); var zoom_values = new PListArray(); foreach (var sheet in doc.Canvas) { var zoom_array = new PListArray(); zoom_array.Add(new PListString(sheet.Title)); zoom_array.Add(new PListReal(sheet.Zoom)); zoom_array.Add(new PListReal(1)); } windowInfo.Add("ZoomValues", zoom_values); dict.Add("WindowInfo", windowInfo); root.Root = dict; return(root); }
private static PListRoot ExportDocument(Omnigraffle.Document doc) { var root = new PListRoot (); root.Format = PListFormat.Xml; var dict = new PListDict (); var applicationVersion = new PListArray (); applicationVersion.Add (new PListString (doc.ApplicationVersion.Name)); applicationVersion.Add (new PListString (doc.ApplicationVersion.Version)); dict.Add ("ApplicationVersion", applicationVersion); var sheets = new PListArray (); foreach (var sheet in doc.Canvas) { var sheet_dict = new PListDict (); sheet_dict.Add ("ActiveLayerIndex", new PListInteger (sheet.ActiveLayerIndex)); sheet_dict.Add ("AutoAdjust", new PListBool (sheet.AutoAdjust)); var backgroundGraphic = new PListDict (); backgroundGraphic.Add ("Bounds", ExportBounds (sheet.BackgroundGraphic.Bounds)); backgroundGraphic.Add ("Class", ExportBackgroundGraphicClass (sheet.BackgroundGraphic.Class)); backgroundGraphic.Add ("ID", new PListInteger (sheet.BackgroundGraphic.ID)); var style = new PListDict (); var shadow = ExportShadow (sheet.BackgroundGraphic.Shadow); var stroke = new PListDict (); stroke.Add ("Draws", new PListString (sheet.BackgroundGraphic.DrawStroke ? "YES" : "NO")); style.Add ("shadow", shadow); style.Add ("stroke", stroke); backgroundGraphic.Add ("Style", style); sheet_dict.Add ("BackgroundGraphic", backgroundGraphic); sheet_dict.Add ("BaseZoom", new PListInteger (sheet.BaseZoom)); sheet_dict.Add ("CanvasOrigin", new PListString (sheet.CanvasOrigin)); sheet_dict.Add ("ColumnAlign", new PListInteger (sheet.ColumnAlign)); sheet_dict.Add ("ColumnSpacing", new PListReal (sheet.ColumnSpacing)); sheet_dict.Add ("DisplayScale", new PListString (sheet.DisplayScale)); sheet_dict.Add ("HPages", new PListInteger (sheet.HPages)); var layers = new PListArray (); if (sheet.Layers.Count > 1) { foreach (var layer in sheet.Layers) { layers.Add (ExportLayer (layer)); } } else { layers.Add (ExportLayer (new Omnigraffle.Layer ())); } sheet_dict.Add ("Layers", layers); var layoutInfo = new PListDict (); layoutInfo.Add ("Animate", new PListString (sheet.LayoutInfo.Animate ? "YES" : "NO")); if (sheet.LayoutInfo.AutoLayout) layoutInfo.Add ("AutoLayout", new PListInteger (1)); if (sheet.LayoutInfo.HierarchicalOrientation == Omnigraffle.HierarchicalOrientation.LeftRight) layoutInfo.Add ("HierarchicalOrientation", new PListInteger (0)); else if (sheet.LayoutInfo.HierarchicalOrientation == Omnigraffle.HierarchicalOrientation.TopBottom) layoutInfo.Add ("HierarchicalOrientation", new PListInteger (1)); else if (sheet.LayoutInfo.HierarchicalOrientation == Omnigraffle.HierarchicalOrientation.RightLeft) layoutInfo.Add ("HierarchicalOrientation", new PListInteger (2)); else if (sheet.LayoutInfo.HierarchicalOrientation == Omnigraffle.HierarchicalOrientation.BottomTop) layoutInfo.Add ("HierarchicalOrientation", new PListInteger (3)); if (sheet.LayoutInfo.LayoutEngine == Omnigraffle.LayoutEngine.Circo) layoutInfo.Add ("layoutEngine", new PListString ("circo")); else if (sheet.LayoutInfo.LayoutEngine == Omnigraffle.LayoutEngine.Dot) layoutInfo.Add ("layoutEngine", new PListString ("dot")); else if (sheet.LayoutInfo.LayoutEngine == Omnigraffle.LayoutEngine.Neato) layoutInfo.Add ("layoutEngine", new PListString ("neato")); else if (sheet.LayoutInfo.LayoutEngine == Omnigraffle.LayoutEngine.Twopi) layoutInfo.Add ("layoutEngine", new PListString ("twopi")); layoutInfo.Add ("circoMinDist", new PListReal (sheet.LayoutInfo.CircoMinDist)); layoutInfo.Add ("circoSeparation", new PListReal (sheet.LayoutInfo.CircoSeparation)); layoutInfo.Add ("dotRankSep", new PListReal (sheet.LayoutInfo.DotRankSep)); layoutInfo.Add ("neatoSeparation", new PListReal (sheet.LayoutInfo.NeatoSeparation)); layoutInfo.Add ("neatoLineLength", new PListReal (sheet.LayoutInfo.NeatoLineLength)); layoutInfo.Add ("neatoOverlap", new PListBool (sheet.LayoutInfo.NeatoOverlap)); layoutInfo.Add ("twopiOverlap", new PListBool (sheet.LayoutInfo.TwopiOverlap)); layoutInfo.Add ("twopiSeparation", new PListReal (sheet.LayoutInfo.TwopiSeparation)); layoutInfo.Add ("twopiRankSep", new PListReal (sheet.LayoutInfo.TwopiRankSep)); sheet_dict.Add ("LayoutInfo", layoutInfo); if (sheet.Orientation == Omnigraffle.Orientation.Portrait) sheet_dict.Add ("Orientation", new PListInteger(0)); else if (sheet.Orientation == Omnigraffle.Orientation.Landscape) sheet_dict.Add ("Orientation", new PListInteger(1)); else if (sheet.Orientation == Omnigraffle.Orientation.PageSetup) sheet_dict.Add ("Orientation", new PListInteger(2)); sheet_dict.Add ("PrintOnePage", new PListBool (sheet.PrintOnePage)); sheet_dict.Add ("RowAlign", new PListInteger (sheet.RowAlign)); sheet_dict.Add ("RowSpacing", new PListReal (sheet.RowSpacing)); sheet_dict.Add ("SheetTitle", new PListString (sheet.Title)); sheet_dict.Add ("UniqueID", new PListInteger (sheet.UniqueId)); sheet_dict.Add ("VPages", new PListInteger (sheet.VPages)); var graphics_array = new PListArray (); foreach (var graphic in sheet.GraphicsList) { graphics_array.Add (ExportGraphic (graphic)); } sheet_dict.Add ("GraphicsList", graphics_array); sheet_dict.Add ("GridInfo", new PListDict ()); sheets.Add (sheet_dict); } dict.Add ("Sheets", sheets); dict.Add ("CreationDate", new PListString (doc.CreationDate.ToString ("yyyy-MM-dd hh:mm:ss +0000"))); dict.Add ("ModificationDate", new PListString (doc.ModificationDate.ToString ("yyyy-MM-dd hh:mm:ss +0000"))); dict.Add ("Creator", new PListString (doc.Creator)); dict.Add ("GraphDocumentVersion", new PListInteger (doc.GraphDocumentVersion)); dict.Add ("GuidesLocked", new PListString (doc.GuidesLocked ? "YES" : "NO")); dict.Add ("GuidesVisible", new PListString (doc.GuidesVisible ? "YES" : "NO")); dict.Add ("ImageCounter", new PListInteger (doc.ImageCounter)); dict.Add ("KeepToScale", new PListBool ()); dict.Add ("LinksVisible", new PListString (doc.LinksVisible ? "YES" : "NO")); dict.Add ("MagnetsVisible", new PListString (doc.MagnetsVisible ? "YES" : "NO")); dict.Add ("NotesVisible", new PListString (doc.NotesVisible ? "YES" : "NO")); dict.Add ("OriginVisible", new PListString (doc.OriginVisible ? "YES" : "NO")); dict.Add ("PageBreaks", new PListString (doc.PageBreaks ? "YES" : "NO")); dict.Add ("MasterSheets", new PListArray ()); dict.Add ("Modifier", new PListString ()); var printInfo = new PListDict (); var bottomMargin = new PListArray (); bottomMargin.Add (new PListString ("float")); bottomMargin.Add (new PListString (string.Format (CultureInfo.InvariantCulture, "{0:0.######}", doc.PrintInfo.BottomMargin))); printInfo.Add ("NSBottomMargin", bottomMargin); var leftMargin = new PListArray (); leftMargin.Add (new PListString ("float")); leftMargin.Add (new PListString (string.Format (CultureInfo.InvariantCulture, "{0:0.######}", doc.PrintInfo.LeftMargin))); printInfo.Add ("NSLeftMargin", leftMargin); var rightMargin = new PListArray (); rightMargin.Add (new PListString ("float")); rightMargin.Add (new PListString (string.Format (CultureInfo.InvariantCulture, "{0:0.######}", doc.PrintInfo.RightMargin))); printInfo.Add ("NSRightMargin",rightMargin); var topMargin = new PListArray (); topMargin.Add (new PListString ("float")); topMargin.Add (new PListString (string.Format (CultureInfo.InvariantCulture, "{0:0.######}", doc.PrintInfo.TopMargin))); printInfo.Add ("NSTopMargin", topMargin); var horizonalPagination = new PListArray (); horizonalPagination.Add (new PListString ("coded")); horizonalPagination.Add (new PListString (doc.PrintInfo.HorizonalPagination)); printInfo.Add ("NSHorizonalPagination", horizonalPagination); var paperSize = new PListArray (); paperSize.Add (new PListString ("size")); paperSize.Add (new PListString (doc.PrintInfo.PaperSize)); printInfo.Add ("NSPaperSize", paperSize); var printReverseOrientation = new PListArray (); printReverseOrientation.Add (new PListString ("int")); printReverseOrientation.Add (new PListString (doc.PrintInfo.PrintReverseOrientation ? "1" : "0")); printInfo.Add ("NSPrintReverseOrientation", printReverseOrientation); dict.Add ("PrintInfo", printInfo); dict.Add ("ReadOnly", new PListString (doc.ReadOnly ? "YES" : "NO")); dict.Add ("SmartAlignmentGuidesActive", new PListString (doc.SmartAlignmentGuidesActive ? "YES" : "NO")); dict.Add ("SmartDistanceGuidesActive", new PListString (doc.SmartDistanceGuidesActive ? "YES" : "NO")); dict.Add ("UseEntirePage", new PListBool (doc.UseEntirePage)); var windowInfo = new PListDict (); windowInfo.Add ("CurrentSheet", new PListInteger (doc.WindowInfo.CurrentSheet)); var expanded_canvases = new PListArray (); foreach (var sheet in doc.Canvas.Where (s => s.Expanded)) { var canvas_dict = new PListDict (); canvas_dict.Add ("name", new PListString(sheet.Title)); expanded_canvases.Add (canvas_dict); } windowInfo.Add ("ExpandedCanvases", expanded_canvases); windowInfo.Add ("Frame", new PListString (doc.WindowInfo.Frame)); windowInfo.Add ("ListView", new PListBool (doc.WindowInfo.ListView)); windowInfo.Add ("RightSidebar", new PListBool (doc.WindowInfo.RightSidebar)); windowInfo.Add ("ShowRuler", new PListBool (doc.WindowInfo.ShowRuler)); windowInfo.Add ("Sidebar", new PListBool (doc.WindowInfo.Sidebar)); windowInfo.Add ("SidebarWidth", new PListInteger (doc.WindowInfo.SidebarWidth)); windowInfo.Add ("OutlineWidth", new PListInteger (doc.WindowInfo.OutlineWidth)); windowInfo.Add ("VisibleRegion", new PListString ("{{0, 0}, {558, 720}}")); windowInfo.Add ("Zoom", new PListReal (doc.WindowInfo.Zoom)); var zoom_values = new PListArray (); foreach (var sheet in doc.Canvas) { var zoom_array = new PListArray (); zoom_array.Add (new PListString (sheet.Title)); zoom_array.Add (new PListReal (sheet.Zoom)); zoom_array.Add (new PListReal (1)); } windowInfo.Add ("ZoomValues", zoom_values); dict.Add ("WindowInfo", windowInfo); root.Root = dict; return root; }