//============================================================ // <T>扫描资源。</T> //============================================================ public override void Scan() { base.Scan(); // 扫描所有文件 _optionValid = true; FStrings fileNames = RDirectory.ListFiles(_directory); fileNames.Sort(); foreach (string fileName in fileNames) { // 文件是否图片 string name = fileName.Substring(fileName.LastIndexOf("\\") + 1); if (name.EndsWith(".png")) { name = name.Substring(0, name.Length - 4); // 是否符合命名标准 if (5 == name.Length) { int direction = RInt.Parse(name.Substring(0, 1)); int frameIndex = RInt.Parse(name.Substring(1)) - 1; // 同步剪辑 FRsResourceClip clip = SyncClip(direction); FRsResourceFrame frame = new FRsResourceFrame(); frame.FileName = fileName; clip.PushFrame(frame); // 设置有效 _optionValid = true; } else { RMoCore.TrackConsole.Write(this, "Scan", "Invalid picture define. (file_name={0})", fileName); } } } // 检查剪辑帧数相等 FRsResourceClip firstClip = FristClip; if (null != firstClip) { foreach (FRsResourceClip clip in _clips) { if (clip != null) { if (firstClip.FrameCount != clip.FrameCount) { RMoCore.TrackConsole.Write(this, "Scan", "Animation clip frame is differenty. (first_frames={0}, clip_frames={1})", firstClip.FrameCount, clip.FrameCount); } } } } string _configName = _directory + "\\config.xml"; if (RFile.Exists(_configName)) { FXmlDocument xdoc = new FXmlDocument(); xdoc.LoadFile(_configName); LoadConfig(xdoc.Root); } }
//============================================================= public void SaveXmlPath(string fileName, string rootname) { FXmlDocument xml = new FXmlDocument(); FXmlNode root = xml.Root; root.Name = rootname + "List"; string id = _columns[0].Name; string rid = null; foreach (FXlsRow row in _rows) { FXmlNode node = root.CreateNode("node"); foreach (string name in row.Names) { string excel = name; string value = row[excel].ToString(); if (id == excel) { rid = value; } node.Set(excel, value); node.Name = rootname; } } xml.SaveFile(fileName); _logger.Debug(this, "SaveXmlPath", "Save xml path. (file={0}, rows={1})", fileName, _rows.Count); }
//============================================================ // <T>加载窗体信息。<T> //============================================================ public void LoadConfig() { string applicationConfig = RMoCommon.GetEnvironment("application.root") + "\\Configuration\\excel.export.xml"; FXmlDocument xmldoc = new FXmlDocument(); xmldoc.LoadFile(applicationConfig); foreach (FXmlNode node in xmldoc.Root.Nodes) { if ("ExcelExportList" == node.Name) { _templateSource = node.Get("source_path"); _templateTarget = node.Get("target_path"); LoadTemplate(node); } if ("ConverterExportList" == node.Name) { _mergerTarget = node.Get("target_path"); LoadMerger(node); } if ("CommandList" == node.Name) { LoadCopy(node); } } }
public void SaveFile(string filename) { FXmlDocument xdoc = new FXmlDocument(); SaveConfig(xdoc.Root); xdoc.SaveFile(filename); }
//============================================================ // <T>保存设置文件。<T> // // @param fileName 保存路径 //============================================================ public virtual void SaveConfigFile(string fileName) { using (FXmlDocument document = new FXmlDocument()) { SaveConfig(document.Root); document.SaveFile(fileName); } }
static void FilterProject(string projectName, string path) { // 获得项目文件集合 FDictionary <SFileInfo> infos = new FDictionary <SFileInfo>(); foreach (string fileName in RDirectory.ListFiles(path)) { if (fileName.EndsWith(".h") || fileName.EndsWith(".cpp")) { string formatName = fileName.Replace('\\', '/'); string name = RString.Right(formatName, "/"); SFileInfo info = new SFileInfo(); info.fileName = formatName; info.include = false; infos.Set(name, info); } } // 查找使用中的文件集合 string configFileName = path + "/vcproject/" + projectName + ".vcxproj"; FXmlDocument document = new FXmlDocument(configFileName); foreach (FXmlNode xnode in document.Root.Nodes) { if (xnode.IsName("ItemGroup")) { foreach (FXmlNode xfile in xnode.Nodes) { if (xfile.IsName("ClInclude") || xfile.IsName("ClCompile")) { string include = xfile.Get("Include"); string name = RString.Right(include, "\\"); SFileInfo info = infos.Find(name); if (info != null) { info.include = true; } } } } } // 查找删除集合 foreach (SFileInfo info in infos.Values) { if (!info.include) { RLogger.Find(typeof(SFileInfo)).Debug(null, "FilterProject", info.fileName); File.Delete(info.fileName); } } // 查找没用目录 RDirectory.Delete(path + "/build"); RDirectory.Delete(path + "/dist"); RDirectory.Delete(path + "/nbproject/private"); RDirectory.Delete(path + "/maproject/libs"); RDirectory.Delete(path + "/maproject/obj"); RDirectory.Delete(path + "/vcproject/Debug"); RDirectory.Delete(path + "/vcproject/Release"); RDirectory.Delete(path + "/vcproject/x64"); File.Delete(path + "/vcproject/" + projectName + ".vcxproj.user"); }
//============================================================ // <T>保存处理。</T> //============================================================ public void Save() { FXmlDocument xdoc = new FXmlDocument(); SaveConfig(xdoc.Root); xdoc.SaveFile(ConfigFileName); }
//============================================================ // <T>打开处理。</T> //============================================================ public void Open() { if (!RDirectory.Exists(_configDirectory)) { return; } if (_opened) { return; } // 打开文件 foreach (string fileName in RDirectory.ListFiles(_configDirectory)) { // 检查类型 if (!fileName.EndsWith(".xml")) { continue; } // 创建主题 FTplTheme theme = new FTplTheme(); theme.FileName = fileName; using (FXmlDocument xdocument = new FXmlDocument(fileName)) { theme.LoadConfig(xdocument.Root); } _themes.Set(theme.Name, theme); // 设置默认主题 if (_activeTheme == null) { _activeTheme = theme; } } _opened = true; }
//============================================================ // <T>加载全部处理。</T> //============================================================ public virtual void LoadAll() { // 清空集合 if (_folders != null) { _folders.Clear(); } if (_objects != null) { _objects.Clear(); } // 加载所有子目录 foreach (string path in RDirectory.ListDirectories(_directory)) { // 跳过SVN目录 if (path.IndexOf(".svn") != -1) { continue; } // 加载子目录 OnLoadFolder(path); } if (_folders != null) { _folders.Sort(); } // 加载配置 if (RFile.Exists(ConfigFileName)) { FXmlDocument xdoc = new FXmlDocument(); xdoc.LoadFile(ConfigFileName); LoadConfig(xdoc.Root); } }
//============================================================ // <T>加载所有目录。</T> //============================================================ public virtual void LoadFolderAll() { // 加载所有子目录 foreach (string path in RDirectory.ListDirectories(_directory)) { // 跳过SVN目录 if (path.IndexOf(".svn") != -1) { continue; } // 加载子目录 OnLoadFolder(path); } if (_folders != null) { _folders.Sort(); } // 加载配置 if (RFile.Exists(ConfigFileName)) { FXmlDocument xdoc = new FXmlDocument(); try { xdoc.LoadFile(ConfigFileName); } catch (Exception e) { throw new FFatalException(e, "Open config file error. (file_name={0})", ConfigFileName); } LoadConfig(xdoc.Root); } }
//============================================================ public void ExportConfigFile(string fileName) { FXmlDocument document = new FXmlDocument(); ExportConfig(document.Root); document.SaveFile(fileName); }
//============================================================ // <T>产生doc节点。</T> // // @param space 命名空间对象 // @return 根节点 //============================================================ public FXmlNode RootSpaceNode(FCsSpace space) { FXmlDocument doc = new FXmlDocument(); FXmlNode config = doc.Root; FXmlNode nodeSpace = space.XMLMaker(config); return(nodeSpace); }
public void LoadFile(string filename) { Clear(); FXmlDocument xdoc = new FXmlDocument(filename); xdoc.LoadFile(filename); LoadConfig(xdoc.Root); }
//============================================================ // <T>建立输出XML文件的根节点。</T> // // @param package 当前类所在包的包对象 // @return 包含包对象的根节点 //============================================================ public FXmlNode RootPackageNode(FAsPackage package) { FXmlDocument doc = new FXmlDocument(); FXmlNode config = doc.Root; FXmlNode nodeSpace = package.XMLMaker(config); return(nodeSpace); }
//============================================================ // <T>保存设置文件。</T> //============================================================ public void SaveConfigFile(string fileName) { FXmlDocument xdoc = new FXmlDocument(); FXmlNode xroot = xdoc.Root; SaveConfig(xroot.CreateNode("Texture")); xdoc.SaveFile(fileName); }
static void Main() { //Bitmap bmp = new Bitmap("D:\\test.png"); //Bitmap nbmp = new Bitmap(bmp, 256, 256); //for (int y = 0; y < 256; y++) { // for (int x = 0; x < 256; x++) { // Color color = bmp.GetPixel(x, y); // int alpha = (0xFF - color.R) * 2; // nbmp.SetPixel(x, y, Color.FromArgb(Math.Min(alpha, 0xFF), 0xFF, 0xFF, 0xFF)); // } //} //nbmp.Save("D:\\test2.png"); // 设置应用程序 Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // 初始化系统 RMoCommon.Initialize(); RMoCore.Initialize(); // 加载环境文件 string environmentFileName = RSystem.Location(@"\..\Configuration\environment.mobile.xml"); RMoCommon.LoadEnvironment(environmentFileName); //............................................................ // 加载配置文件 string configFileName = RMoCommon.ParseEnvironment(@"${application.root}\Configuration\configuration.xml"); using (FXmlDocument xdoc = new FXmlDocument(configFileName)) { FXmlNode xconfig = xdoc.Root; RMoCore.LoadConfig(xconfig); RContent2dManager.LoadConfig(xconfig); RDesign2dManager.LoadConfig(xconfig); } //............................................................ // 配置处理 RMoCore.Setup(); RContent2dManager.Setup(); RDesign2dManager.Setup(); //............................................................ // 显示资源表单 QTrackForm.Instance.Open(); QTaskForm.Instance.Open(); // 显示工作界面 //QUiConsoleForm.Instance.Open(); //QUiConsoleForm.Instance.Text += " - [" + configFileName + "]"; //Application.Run(QUiConsoleForm.Instance); // 显示工作界面 //QUiDesignForm form = RDesign2dManager.FrameConsole.OpenDesignForm("runtime.window"); //Application.Run(form); QUiConsoleForm.Instance.Open(); QUiConsoleForm.Instance.Text += " - [" + configFileName + "] v131115"; Application.Run(QUiConsoleForm.Instance); //// 释放系统 //RDesign2dManager.Release(); //RContent2dManager.Release(); RMoCore.Release(); RMoCommon.Release(); }
//============================================================ // <T>存储配置文件。</T> // // @param fileName 文件名称 //============================================================ public void SaveFile(string fileName) { using (FXmlDocument xdocument = new FXmlDocument()) { // 创建控件 SaveConfig(xdocument.Root); // 存储文件 xdocument.SaveFile(fileName); } }
//============================================================ public override void Store() { base.Store(); string fileName = _directory + @"\config.xml"; FXmlDocument document = new FXmlDocument(); SaveConfig(document.Root); document.SaveFile(fileName); }
//============================================================ public void SaveConfigFile(string fileName) { FXmlDocument xdoc = new FXmlDocument(); FXmlNode xroot = xdoc.Root; SaveConfig(xroot.CreateNode("Map")); xdoc.SaveFile(fileName); _logger.Debug(this, "SaveConfigFile", "Save map config success. (file_name={0})", fileName); }
//============================================================ // <T>加载配置文件。</T> // // @param fileName 文件名称 //============================================================ public void LoadFile(string fileName) { string name = _name; using (FXmlDocument xdocument = new FXmlDocument(fileName)) { _fileName = fileName; LoadConfig(xdocument.Root); } _name = name; }
//============================================================ public void LoadConfigFile(string fileName) { FXmlDocument xdoc = new FXmlDocument(fileName); FXmlNode xroot = xdoc.Root; FXmlNode xmap = xroot.Find("Map"); if (null != xmap) { LoadConfig(xmap); } }
//============================================================ // <T>加载设置文件。</T> //============================================================ public void LoadConfigFile(string fileName) { FXmlDocument xdoc = new FXmlDocument(fileName); FXmlNode xroot = xdoc.Root; FXmlNode xmaterial = xroot.Find("Theme"); if (xmaterial != null) { LoadConfig(xmaterial); } }
//============================================================ // <T>加载设置文件。</T> //============================================================ public void LoadConfigFile(string fileName) { FXmlDocument xdoc = new FXmlDocument(fileName); FXmlNode xroot = xdoc.Root; FXmlNode xtexture = xroot.Find("Texture"); if (null != xtexture) { LoadConfig(xtexture); } }
//============================================================ // <T>关闭处理。</T> //============================================================ public void Close() { foreach (INamePair <FTplTheme> pair in _themes) { FTplTheme theme = pair.Value; using (FXmlDocument xdocument = new FXmlDocument()) { theme.SaveConfig(xdocument.Root); xdocument.SaveFile(theme.FileName); } } }
//============================================================ // <T>加载配置文件。</T> //============================================================ public void LoadDirectory() { // 获得文件名称 string fileName = _directory + @"\config.xml"; if (!RFile.Exists(fileName)) { return; } // 加载设置 using (FXmlDocument xmldoc = new FXmlDocument(fileName)) { LoadConfig(xmldoc.Root); } }
//============================================================ // <T>加载环境设置。</T> // // @param fileName 文件名称 //============================================================ public static void LoadEnvironment(string fileName) { FXmlDocument xdoc = new FXmlDocument(fileName); foreach (FXmlNode xnode in xdoc.Root.Nodes) { if (xnode.IsName("Property")) { _environments.Set(xnode.Get("name"), ParseEnvironment(xnode.Text)); } } }
//============================================================ // <T>保存内容。</T> //============================================================ public void Store() { // 存储信息 FXmlDocument xdoc = new FXmlDocument(); FXmlNode xroot = xdoc.Root; xroot.Name = "Scene"; xroot.Set("version", "1.0"); SaveConfig(xroot); xdoc.SaveFile(_configFileName); _logger.Debug(this, "SaveConfig", "Save Texture config success. (file_name={0})", _configFileName); }
//============================================================ // <T>导出内容信息。</T> //============================================================ public void ExportInfo() { string fileName = _directory + "\\model.info.xml"; Open(); FXmlDocument xdoc = new FXmlDocument(); SaveInfoConfig(xdoc.Root); xdoc.SaveFile(fileName); _logger.Debug(this, "Export", "Export model info success. (file_name={0})", fileName); Dispose(); }
//============================================================ // <T>关闭处理。</T> //============================================================ public void Close() { using (FXmlDocument xdocument = new FXmlDocument()) { FXmlNode xconfig = xdocument.Root; foreach (FTplConstant constant in _constants) { FXmlNode xnode = xconfig.CreateNode("Constant"); constant.SaveConfig(xnode); } xdocument.SaveFile(_configFileName); } }
//============================================================ // <T>关闭处理。</T> //============================================================ public void Close() { using (FXmlDocument xdocument = new FXmlDocument()) { FXmlNode xconfig = xdocument.Root; foreach (FTplStyle style in _styles) { FXmlNode xnode = xconfig.CreateNode("Style"); style.SaveConfig(xnode); } xdocument.SaveFile(_configFileName); } }