WPF使用ARCGIS App文件配置Cs后台文件
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Data;
- using System.Linq;
- using System.Windows;
- using ESRI.ArcGIS.esriSystem;
- using System.Xml.Serialization;
- using System.IO;
- using SWGW.Properties;
- using System.Diagnostics;
- namespace SWGW
- {
- /// <summary>
- /// App.xaml 的交互逻辑
- /// </summary>
- public partial class App : Application
- {
- #region License
- protected override void OnStartup(StartupEventArgs e)
- {
- SettingsManager.OnStartup();
- base.OnStartup(e);
- if (!LicenseManager.InitializeLicense.InitializeEngineLicense())
- {
- MessageBox.Show("无法初始化ArcGIS Engine的授权或地球扩展。截止...");
- }
- }
- #endregion
- #region 私有类
- static class SettingsManager
- {
- #region Class Members
- static Settings settings = new Settings();
- const string applicationDirectory = "SWGW";
- //配置文件名称
- const string settingsFileName = "XXXX.xml";
- #endregion Class Members
- #region Constructor
- static SettingsManager()
- {
- EnsureDirectoryExists();
- }
- #endregion Constructor
- #region Properties
- public static Settings ApplicationSettings
- {
- get { return settings; }
- }
- #endregion Properties
- #region Startup, Exit
- public static void OnStartup()
- {
- LoadSettings();
- }
- public static void OnExit()
- {
- SaveSettings();
- }
- #endregion Overrides
- #region Other Functions
- static string SettingsFileName
- {
- get
- {
- return Path.Combine(
- Path.Combine(
- Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
- applicationDirectory),
- settingsFileName);
- }
- }
- static void LoadSettings()
- {
- Settings tmp;
- try
- {
- XmlSerializer xml = new XmlSerializer(typeof(Settings));
- using (Stream stream = new System.IO.FileStream(SettingsFileName,
- FileMode.Open, FileAccess.Read, FileShare.Read))
- {
- tmp = (Settings)xml.Deserialize(stream);
- }
- }
- catch (Exception e)
- {
- Trace.WriteLine(e.Message);
- return;
- }
- settings = tmp;
- }
- static void SaveSettings()
- {
- try
- {
- XmlSerializer xml = new XmlSerializer(typeof(Settings));
- using (Stream stream = new System.IO.FileStream(SettingsFileName,
- FileMode.Create, FileAccess.Write, FileShare.None))
- {
- xml.Serialize(stream, settings);
- }
- }
- catch (Exception e)
- {
- Trace.WriteLine(e.Message);
- }
- }
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
- static void EnsureDirectoryExists()
- {
- try
- {
- DirectoryInfo info = new DirectoryInfo(
- Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
- applicationDirectory));
- if (!info.Exists)
- {
- info.Create();
- }
- }
- catch (Exception ex)
- {
- Trace.WriteLine(ex.Message);
- }
- }
- #endregion Other Functions
- }
- #endregion
- }
- }
WPF使用ARCGIS App文件配置Cs后台文件的更多相关文章
- webpack4 单入口文件配置 多入口文件配置 以及常用的配置
单入口文件配置 webpack.config.js const path = require('path'); const HtmlWebpackPlugin = require('html-webp ...
- 虚拟主机ip配置,nginx.conf文件配置及日志文件切割
今天粗略整理了一下虚拟主机配置,nginx.conf文件的配置,及日志文件的切割,记录如下: nginx虚拟主机配置:1.IP地址配置,2.绑定ip地址和虚拟主机详情:1.ip地址的配置:ifconf ...
- maven中pom文件配置解决资源文件的编码问题
<build> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId& ...
- Vue插件配置和 后台交互
Vue插件配置和 后台交互 一.全局配置静态文件(csss, js..) 1.1 全局配置css文件 创建css文件 在main.js配置css文件 // 配置全局css样式 // 方式一 impor ...
- mybatis 自动生成文件配置
maven 依赖配置: <!-- sql server --><dependency> <groupId>com.microsoft.sqlserver</g ...
- Django-03-静态文件配置
一.django静态文件配置原理 静态文件配置就是为了让用户请求时django服务器能找到静态文件返回. 首先要理解几个概念: 媒体文件:用户上传的文件 静态文件:css,js,image等 开发环境 ...
- informatica 参数文件配置
Informatica 中 parameter file 参数文件配置规则: 参数文件的头部内容 [Global] All Integration Services, Integration Serv ...
- Django学习——静态文件配置、request对象方法、pycharm如何链接数据库、Django如何指定数据库、Django orm操作
静态文件配置 # 1.静态文件 网站所使用的已经提前写好的文件 css文件 js文件 img文件 第三方文件 我们在存储静态文件资源的时候一般默认都是放在static文件夹下 # 2.Django静态 ...
- c#Winform程序调用app.config文件配置数据库连接字符串 SQL Server文章目录 浅谈SQL Server中统计对于查询的影响 有关索引的DMV SQL Server中的执行引擎入门 【译】表变量和临时表的比较 对于表列数据类型选择的一点思考 SQL Server复制入门(一)----复制简介 操作系统中的进程与线程
c#Winform程序调用app.config文件配置数据库连接字符串 你新建winform项目的时候,会有一个app.config的配置文件,写在里面的<connectionStrings n ...
随机推荐
- AC日记——矩阵取数游戏 洛谷 P1005
矩阵取数游戏 思路: dp+高精: 代码: #include <bits/stdc++.h> using namespace std; #define ll long long struc ...
- Vue结合原生js实现自定义组件自动生成
就目前三大前端主流数据驱动框架(vue,ng,react)而言,均具有创建自定义组件的api,但都是必须先做到事先写好挂载点,这个挂载点可以是原有静态元素标签也可以是自定义模板:对于多种组件通过同一数 ...
- IllegalStateException: Unable to find a @SpringBootConfiguration
此处需要改掉包名和类名
- 在centos 6.9安装wordpress,浏览器不能访问问题
在centos 6.9安装wordpress浏览器访问先出现403错误,然后提示access denied nginx错误打印FastCGI sent in stderr: "Unable ...
- Optional int parameter 'id' is present but cannot be translated into a null value due to being decla
这个错误可以将参数由int改为Integer
- python学习第一天_环境的搭建
Python linux环境的安装: 1.https://www.python.org/ftp/python/ 大家可以在这里下载自己所需的linux下的版本 ,这里我下载的2.6.6版本: 2.在C ...
- VMware Workstation虚拟机进入BIOS
1.<F2>键 2.
- Flask实战第57天:UEditor编辑器集成以及配置上传文件到七牛
相关链接 UEditor:http://ueditor.baidu.com/website/ 下载地址:http://ueditor.baidu.com/website/download.html# ...
- Python开发基础-Day21多态与多态性、绑定方法和非绑定方法
多态与多态性 多态 多态并不是一个新的知识 多态是指一类事物有多种形态,在类里就是指一个抽象类有多个子类,因而多态的概念依赖于继承 举个栗子:动物有多种形态,人.狗.猫.猪等,python的序列数据类 ...
- 【枚举】【最小表示法】XVII Open Cup named after E.V. Pankratiev Stage 14, Grand Prix of Tatarstan, Sunday, April 2, 2017 Problem F. Matrix Game
给你一个n*m的字符矩阵,将横向(或纵向)全部裂开,然后以任意顺序首尾相接,然后再从中间任意位置切开,问你能构成的字典序最大的字符串. 以横向切开为例,纵向类似. 将所有横排从大到小排序,枚举最后切开 ...