public KNXApp ToKnx(BackgroundWorker worker) { KNXApp knx = new KNXApp(); base.ToKnx(knx, worker); GetProjectVersion(); //knx.Width = this.Width; //knx.Height = this.Height; knx.Width = this.Size.Width; knx.Height = this.Size.Height; knx.About = this.About; knx.Symbol = this.Symbol; knx.BackgroundImage = this.BackgroundImage; knx.Areas = new System.Collections.Generic.List <KNXArea>(); MyCache.ValidResImgNames.Add(knx.Symbol); MyCache.ValidResImgNames.Add(knx.BackgroundImage); return(knx); }
public KNXApp ExportTo(BackgroundWorker worker, string dir) { KNXApp knx = this.ToKnx(worker); knx.Symbol = FileHelper.CopyFileSole(Path.Combine(MyCache.ProjImgPath, this.Symbol), dir); knx.BackgroundImage = FileHelper.CopyFileSole(Path.Combine(MyCache.ProjImgPath, this.BackgroundImage), dir); return(knx); }
public static void Save(KNXApp knxApp) { var settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto }; var jsonData = JsonConvert.SerializeObject(knxApp, Formatting.None, settings); File.WriteAllText(Path.Combine(MyCache.ProjectFolder, MyConst.KnxUiMetaDataFile), jsonData, Encoding.UTF8); }
private static AppNode ImportAppNode(BackgroundWorker worker, KNXApp app, string ResImgDir) { AppNode appNode = new AppNode(app, worker, ResImgDir); foreach (KNXArea knx in app.Areas) { ImportAreaNode(worker, appNode, knx, ResImgDir); } return(appNode); }
/// <summary> /// 导入 JSON 文件,生成 Treeview 节点 /// </summary> /// <param name="app"></param> /// <param name="tvwAppdata"></param> public static AppNode ImportNode(KNXApp app /*, TreeView tv, UIEditor.Entity.ViewNode.PropertiesChangedDelegate proChangedDelegate*/) { AppNode appNode = null; if (app != null) { //tvwAppdata.BeginUpdate(); //tvwAppdata.Nodes.Clear(); appNode = new AppNode(app); //tvwAppdata.Nodes.Add(appNode); if (app.Areas != null && app.Areas.Count > 0) { foreach (KNXArea itemArea in app.Areas) { var areaNode = new AreaNode(itemArea); appNode.Nodes.Add(areaNode); if (itemArea.Rooms != null && itemArea.Rooms.Count > 0) { foreach (KNXRoom itemRoom in itemArea.Rooms) { var roomNode = new RoomNode(itemRoom); areaNode.Nodes.Add(roomNode); if (itemRoom.Pages != null && itemRoom.Pages.Count > 0) { foreach (KNXPage itemPage in itemRoom.Pages) { var pageNode = new PageNode(itemPage); //pageNode.PropertiesChangedEvent += proChangedDelegate; roomNode.Nodes.Add(pageNode); // 给页面添加控件 if (itemPage.Controls != null && itemPage.Controls.Count > 0) { foreach (var item in itemPage.Controls) { AddControlNode(pageNode, item /*, proChangedDelegate*/); } } } } } } } } //tvwAppdata.EndUpdate(); } return(appNode); }
private static KNXApp ExportApp(BackgroundWorker worker, AppNode node, string ImgResDir) { KNXApp app = node.ExportTo(worker, ImgResDir); foreach (AreaNode cNode in node.Nodes) { ExportArea(worker, app, cNode, ImgResDir); } return(app); }
public KNXApp ToKnx() { KNXApp knx = new KNXApp(); base.ToKnx(knx); knx.About = this.About; knx.Logo = this.Logo; knx.Symbol = this.Symbol; knx.Areas = new System.Collections.Generic.List <KNXArea>(); return(knx); }
/// <summary> /// 导入 JSON 文件,生成 Treeview 节点 /// </summary> /// <param name="app"></param> /// <param name="tvwAppdata"></param> public static AppNode ImportNode(KNXApp app, BackgroundWorker worker) { AppNode appNode = null; if (app != null) { appNode = new AppNode(app, worker); if (app.Areas != null && app.Areas.Count > 0) { foreach (KNXArea itemArea in app.Areas) { var areaNode = new AreaNode(itemArea, worker); appNode.Nodes.Add(areaNode); if (itemArea.Rooms != null && itemArea.Rooms.Count > 0) { foreach (KNXRoom itemRoom in itemArea.Rooms) { var roomNode = new RoomNode(itemRoom, worker); areaNode.Nodes.Add(roomNode); if (itemRoom.Pages != null && itemRoom.Pages.Count > 0) { foreach (KNXPage itemPage in itemRoom.Pages) { var pageNode = new PageNode(itemPage, worker); roomNode.Nodes.Add(pageNode); PageNode pageNodeClone = pageNode.CreateTwinsPageNode(); // 给页面添加控件 if (itemPage.Controls != null && itemPage.Controls.Count > 0) { foreach (var item in itemPage.Controls) { AddControlNode(pageNodeClone, item, worker); } } } } } } } } } return(appNode); }
private static KNXArea ExportArea(BackgroundWorker worker, KNXApp app, AreaNode node, string ImgResDir) { KNXArea area = node.ExportTo(worker, ImgResDir); foreach (RoomNode cNode in node.Nodes) { ExportRoom(worker, area, cNode, ImgResDir); } if (null != app) { app.Areas.Add(area); } return(area); }
public AppNode(KNXApp knx, BackgroundWorker worker) : base(knx, worker) { this.Name = ImageKey = SelectedImageKey = MyConst.View.KnxAppType; SetText(this.Title); //MyCache.Width = this.Width; //MyCache.Height = this.Height; MyCache.AppSize = this.Size; this.About = knx.About; if (ImportedHelper.IsLessThan2_0_3()) { //this.Width = 1280; //this.Height = 800; this.Size = new Size(1280, 800); if (!string.IsNullOrEmpty(knx.Symbol)) { this.Symbol = ProjResManager.CopyImageSole(Path.Combine(this.ImagePath, knx.Symbol)); } else if (!string.IsNullOrEmpty(knx.Logo)) { this.Symbol = ProjResManager.CopyImageSole(Path.Combine(this.ImagePath, knx.Logo)); } if (!string.IsNullOrEmpty(knx.BackgroundImage)) { this.BackgroundImage = ProjResManager.CopyImageSole(Path.Combine(this.ImagePath, knx.BackgroundImage)); } } else if (ImportedHelper.IsLessThan2_5_6()) { this.Symbol = ProjResManager.CopyImageSole(Path.Combine(this.ImagePath, NAME_SYMBOL)); this.BackgroundImage = ProjResManager.CopyImageSole(Path.Combine(this.ImagePath, NAME_BACKGROUNDIMAGE)); } else { //this.Width = knx.Width; //this.Height = knx.Height; this.Size = new Size(knx.Width, knx.Height); this.Symbol = knx.Symbol; this.BackgroundImage = knx.BackgroundImage; } GetProjectVersion(); }
public AppNode(KNXApp knx) : base(knx) { string FileDefaultIcon = Path.Combine(MyCache.ProjImagePath, MyConst.DefaultIcon); if (!File.Exists(FileDefaultIcon)) { File.Copy(Path.Combine(MyCache.ProjectResImgDir, MyConst.DefaultIcon), Path.Combine(MyCache.ProjImagePath, MyConst.DefaultIcon)); } this.Name = ImageKey = SelectedImageKey = MyConst.View.KnxAppType; this.Text = knx.Text; this.About = knx.About; this.Logo = knx.Logo; this.Symbol = knx.Symbol; //this.DefaultLanguage = knx.DefaultLanguage; }
public AppNode(KNXApp knx, BackgroundWorker worker, string DirSrcImg) : this(knx, worker) { this.Id = GenId(); // 创建新的Id if (ImportedHelper.IsLessThan2_5_6()) { string knxImage = GetImageName(knx.Id); // KNX图片资源名称 string knxImagePath = Path.Combine(DirSrcImg, knxImage); // KNX图片资源路径 this.Symbol = ProjResManager.CopyImageRename(Path.Combine(knxImagePath, NAME_SYMBOL)); this.BackgroundImage = ProjResManager.CopyImageRename(Path.Combine(knxImagePath, NAME_BACKGROUNDIMAGE)); } else { this.Symbol = ProjResManager.CopyImageRename(Path.Combine(DirSrcImg, knx.Symbol)); this.BackgroundImage = ProjResManager.CopyImageRename(Path.Combine(DirSrcImg, knx.BackgroundImage)); } }
/// <summary> /// 导出树形结构为json文件 /// </summary> /// <param name="tvwAppdata"></param> /// <param name="fileName"></param> public static KNXApp ExportAppNodeAndResources(AppNode appNode, BackgroundWorker worker) { KNXApp app = new KNXApp(); if (appNode != null) { app = appNode.ToKnx(worker); if (appNode.Nodes.Count > 0) { foreach (TreeNode it1 in appNode.Nodes) { #region 添加区域 if (MyConst.View.KnxAreaType == it1.Name) { var areaNode = it1 as AreaNode; if (areaNode != null) { var area = areaNode.ToKnx(worker); app.Areas.Add(area); if (it1.Nodes.Count > 0) { #region 添加房间 foreach (TreeNode it2 in it1.Nodes) { if (MyConst.View.KnxRoomType == it2.Name) { var roomNode = it2 as RoomNode; if (roomNode != null) { var room = roomNode.ToKnx(worker); area.Rooms.Add(room); if (it2.Nodes.Count > 0) { #region 添加页面 foreach (TreeNode it3 in it2.Nodes) { if (MyConst.View.KnxPageType == it3.Name) { var pageNode = it3 as PageNode; if (pageNode != null) { #region 添加页面 PageNode mPageNode = pageNode.GetTwinsPageNode(); if (null != mPageNode) { var page = mPageNode.ToKnx(worker); room.Pages.Add(page); if (mPageNode.Nodes.Count > 0) { // 添加 grid foreach (TreeNode it4 in mPageNode.Nodes) { ExportControls(page, it4, worker); } } } #endregion } } } #endregion } } } } #endregion } } } #endregion } } } return(app); }
/// <summary> /// 导出树形结构为json文件 /// </summary> /// <param name="tvwAppdata"></param> /// <param name="fileName"></param> public static KNXApp ExportTreeView(TreeView tvwAppdata) { KNXApp app = new KNXApp(); if (tvwAppdata.Nodes.Count > 0) { // 生成应用 var appNode = tvwAppdata.Nodes[0] as AppNode; if (appNode != null) { app = appNode.ToKnx(); if (appNode.Nodes.Count > 0) { foreach (TreeNode it1 in appNode.Nodes) { #region 添加区域 if (MyConst.View.KnxAreaType == it1.Name) { var areaNode = it1 as AreaNode; if (areaNode != null) { var area = areaNode.ToKnx(); app.Areas.Add(area); if (it1.Nodes.Count > 0) { #region 添加房间 foreach (TreeNode it2 in it1.Nodes) { if (MyConst.View.KnxRoomType == it2.Name) { var roomNode = it2 as RoomNode; if (roomNode != null) { var room = roomNode.ToKNX(); area.Rooms.Add(room); if (it2.Nodes.Count > 0) { #region 添加页面 foreach (TreeNode it3 in it2.Nodes) { if (MyConst.View.KnxPageType == it3.Name) { var pageNode = it3 as PageNode; if (pageNode != null) { #region 添加页面 var page = pageNode.ToKnx(); room.Pages.Add(page); if (it3.Nodes.Count > 0) { // 添加 grid foreach (TreeNode it4 in it3.Nodes) { ExportControls(page, it4); //if (MyConst.View.KnxGroupBoxType == it4.Name) //{ // #region 添加控件 // var gridNode = it4 as GroupBoxNode; // if (gridNode != null) // { // var grid = gridNode.ToKnx(); // page.GroupBoxs.Add(grid); // if (it4.Nodes.Count > 0) // { // // 添加控件 // foreach (TreeNode it5 in it4.Nodes) // { // ExportControls(grid, it5); // } // } // } // #endregion //} //else //{ // #region 添加控件 // ExportControls(page, it4); // #endregion //} } } #endregion } } } #endregion } } } } #endregion } } } #endregion } } //// 写 Json 文件 //var settings = new JsonSerializerSettings(); //settings.TypeNameHandling = TypeNameHandling.Auto; //string json = JsonConvert.SerializeObject(app, Formatting.Indented, settings); //File.WriteAllText(fileName, json); } } return(app); }