WPF uses the ARCGIS App file to configure the Cs background file, wpfarcgis

Source: Internet
Author: User

WPF uses the ARCGIS App file to configure the Cs background file, wpfarcgis

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. interaction logic of xaml // </summary> public partial class App: Application {# region License protected override void OnS Tartup (StartupEventArgs e) {SettingsManager. OnStartup (); base. OnStartup (e); if (! LicenseManager. InitializeLicense. InitializeEngineLicense () {MessageBox. Show ("unable to initialize ArcGIS Engine authorization or earth extension. As... ") ;}# endregion # region private class static Class SettingsManager {# region class Members static Settings settings = new Settings (); const string applicationDirectory =" SWGW "; // configuration file name const string settingsFileName = "XXXX. xml "; # endregion Class Members # region Constructor static SettingsManager () {EnsureDirectoryExists () ;}# endregion Constructor # region Properties public static Settings Applicat IonSettings {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 () {t Ry {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 Ens UreDirectoryExists () {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 }}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.