当前位置: 首页 > wzjs >正文

网站建设很简单营销策略分析包括哪些内容

网站建设很简单,营销策略分析包括哪些内容,北京网站搭建公司电话,网络销售入门基本知识配置文件的读取 在AutoCAD插件开发中,可能需要生成、修改、读取配置文件中一些参数或设置。JSON格式的配置文件易于编写和修改,且可以方便地反序列化为对象进行使用。 运行后效果如下 using Autodesk.AutoCAD.ApplicationServices; using Autodesk.Au…

配置文件的读取

在AutoCAD插件开发中,可能需要生成、修改、读取配置文件中一些参数或设置。JSON格式的配置文件易于编写和修改,且可以方便地反序列化为对象进行使用。

运行后效果如下

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using Newtonsoft.Json;
using System;
using System.IO;
using Path = System.IO.Path;
// AutoCAD 命令示例
public class ConfigCommands
{[CommandMethod("xx")]public void 加载文件配置(){Document doc = Application.DocumentManager.MdiActiveDocument;Editor ed = doc.Editor;// 加载配置AppConfig config = ConfigManager.LoadConfig();// 应用配置到图纸ConfigManager.ApplyConfigToDrawing(config);ed.WriteMessage($"\n已加载配置:默认图层 {config.DefaultLayer}");}[CommandMethod("tt")]public void 修改文件配置(){Document doc = Application.DocumentManager.MdiActiveDocument;Editor ed = doc.Editor;// 获取当前配置AppConfig config = ConfigManager.LoadConfig();// 修改配置示例config.DefaultLayer = "MyNewLayer";config.DefaultLineWeight = 0.5;// 保存配置ConfigManager.SaveConfig(config);ed.WriteMessage("\n配置已更新并保存");}
}
// 配置文件数据结构(示例)
public class AppConfig
{public string DefaultLayer { get; set; } = "0";      // 默认图层public double DefaultLineWeight { get; set; } = 0.3; // 默认线宽(毫米)public string[] RecentFiles { get; set; }            // 最近打开文件记录public ColorSetting Colors { get; set; }             // 颜色配置
}public class ColorSetting
{public int Background { get; set; } = 16777215;     // 背景色(RGB白色)public int SelectionHighlight { get; set; } = 255;   // 选择高亮色(红色)
}public static class ConfigManager
{private static readonly string ConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),"MyAutoCADPlugin","config.json");/// <summary>/// 加载配置文件/// </summary>public static AppConfig LoadConfig(){try{// 如果配置文件不存在,创建默认配置if (!File.Exists(ConfigPath)){var defaultConfig = new AppConfig();SaveConfig(defaultConfig);return defaultConfig;}// 读取并反序列化JSONstring json = File.ReadAllText(ConfigPath);return JsonConvert.DeserializeObject<AppConfig>(json);}catch (Exception ex){Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage($"\n配置加载失败: {ex.Message}");return new AppConfig(); // 返回空配置}}/// <summary>/// 保存配置文件/// </summary>public static void SaveConfig(AppConfig config){try{// 确保目录存在Directory.CreateDirectory(Path.GetDirectoryName(ConfigPath));// 序列化并保存string json = JsonConvert.SerializeObject(config, Formatting.Indented);File.WriteAllText(ConfigPath, json);}catch (Exception ex){Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage($"\n配置保存失败: {ex.Message}");}}/// <summary>/// 应用配置到当前图纸/// </summary>public static void ApplyConfigToDrawing(AppConfig config){Database db = HostApplicationServices.WorkingDatabase;using (Transaction tr = db.TransactionManager.StartTransaction()){try{// 获取层表LayerTable lt = tr.GetObject(db.LayerTableId, OpenMode.ForRead) as LayerTable;// 检查默认图层是否存在if (!lt.Has(config.DefaultLayer)){// 创建新图层LayerTableRecord ltr = new LayerTableRecord{Name = config.DefaultLayer,LineWeight = LineWeight.LineWeight030};lt.UpgradeOpen();lt.Add(ltr);tr.AddNewlyCreatedDBObject(ltr, true);}// 设置当前图层db.Clayer = lt[config.DefaultLayer];tr.Commit();}catch (Exception ex){tr.Abort();Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage($"\n配置应用失败: {ex.Message}");}}}
}

http://www.dtcms.com/wzjs/404027.html

相关文章:

  • 中国建设银官方网站最新国际新闻大事件
  • 电子印章在线制作网站baidu com百度一下
  • 临沂网站排名北京网络营销推广外包
  • 泉州地区网站建设公司互联网营销策划是做什么的
  • 物流网站开发公司怎么做私人网站
  • 网站日记在哪里看友情下载网站
  • 做加工都在哪个网站推广seo项目培训
  • 尚未设置自定义缩略图wordpressseo优化排名价格
  • 做网站不用服务器怎么做线上推广
  • 网站建设 华南商网趣丁号友情链接
  • 中小企业网站制作价格海南百度总代理
  • 陕西高速建设集团网站现在有哪些网址
  • 绵阳最有实力的公司网站建设网络推广与推广
  • 网站做关键词排名杭州seo渠道排名
  • 上海市建设工程交易平台谷歌seo搜索优化
  • 做网站抬头seo网站优化服务
  • 赣州那里有做网站的公司免费精准客源
  • 免费的中文logo网站寻找外贸客户的网站
  • 芮城网站开发湖北网络推广
  • 做网站用什么样的电脑河南seo网站多少钱
  • 怎么查询网站的点击量百度下载app下载安装到手机
  • 怎么创建网页活动百度seo刷排名网址
  • 单位网站建设意见建议上海发布微信公众号
  • 早晨网站建设专业网站seo推广
  • 阿里巴巴网站国际重大新闻
  • 如何为网站做推广山东今日热搜
  • 建设工程报建网站查询产品推销方案
  • 宁波做外贸网站推广下载安装
  • 做网站最清晰的字体广告投放优化师
  • 网站建设技术方案怎么写网站建设方案范文