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 ...
随机推荐
- 利用jquery.touchSwipe.js实现的移动滑屏效果。
利用jquery.touchSwipe.js实现的移动滑屏效果. 亲测:兼容ie8及各种浏览器 <script type="text/javascript" src=&quo ...
- 【剑指offer】面试题 16. 数值的整数次方
面试题 16. 数值的整数次方 题目描述 题目:给定一个double类型的浮点数base和int类型的整数exponent.求base的exponent次方. 解答过程 下面的讨论中 x 代表 bas ...
- CodeForces 144B Meeting
暴力. 题目只要求计算边上的点就可以了,一开始没看清题意,把内部的也算进去了.内部的计算可以延迟标记一下,但这题没有必要. #include<map> #include<set> ...
- Django常用内置过滤器
1.add 此过滤器将首先尝试将两个值强制为整数.如果失败,它会尝试将值一起添加.这将工作在一些数据类型(字符串,列表等)和失败在其他人.如果失败,结果将是一个空字符串. {{ value | add ...
- python队列、线程、进程、协程(转)
原文地址: http://www.cnblogs.com/wangqiaomei/p/5682669.html 一.queue 二.线程 #基本使用 #线程锁 #自定义线程池 #生产者消费者模型(队列 ...
- Find K Pairs with Smallest Sums -- LeetCode
You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. Define ...
- 数据库SQL归纳(二)
数据定义功能 对象 创建 修改 删除 架构 CREATE SCHEMA DROP SCHEMA 表 CREATE TABLE ALTER TABLE DROP TABLE 视图 CREATE VIEW ...
- Codeforces Testing Round 14
A:The Way to Home link:http://codeforces.com/contest/910/problem/A 题面:有每次最大跳跃距离d,只有一部分的点可以落脚,求最少几步达到 ...
- 【分块】【bitset】hdu6085 Rikka with Candies
给你数组A和B,A B中的元素大小都不超过5w,且两两不同. q次询问,每次给你个k,问你有多少对(i,j),满足A(i)%B(j)==k. 如题目所言模拟bitset的过程,实质上是个分块,每块的大 ...
- django查询
阅读目录 大于.大于等于 小于.小于等于 在...范围内 模糊查询 是否为空 不等于/不包含于 大于.大于等于 1 2 3 4 5 __gt 大于 __gte 大于等于 User.objects. ...