/// <summary>
        /// 建立圖片BitmapImage
        /// </summary>
        /// <param name="filePath">影像路徑</param>
        /// <param name="decodePixelWidth">影像解析</param>
        public BitmapImage SettingBitmapImage(string filePath, int decodePixelWidth)
        {
            BitmapImage bi = new BitmapImage();

            try
            {
                if (File.Exists(filePath))
                {
                    FileStream fs = new FileStream(filePath, FileMode.Open);
                    bi.BeginInit();
                    bi.StreamSource     = fs;
                    bi.DecodePixelWidth = decodePixelWidth;
                    bi.CacheOption      = BitmapCacheOption.OnLoad;
                    bi.EndInit();
                    bi.Freeze();
                    fs.Close();
                }
                return(bi);
            }
            catch (Exception ex)
            {
                Error_Log.ErrorMessageOutput(ex.ToString());
                return(bi);
            }
        }
Beispiel #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public static bool ReadSetting(string key)
 {
     try
     {
         var appSettings = ConfigurationManager.AppSettings;
         if (appSettings[key] != null)
         {
             if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings[key]))
             {
                 return(true);
             }
         }
         return(false);
     }
     catch (ConfigurationErrorsException cex)
     {
         Error_Log.ErrorMessageOutput(cex.ToString());
     }
     return(false);
 }
Beispiel #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="key"></param>
 /// <param name="value"></param>
 public static void AddUpdateAppCongig(string key, string value)
 {
     try
     {
         var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
         var settings   = configFile.AppSettings.Settings;
         if (settings[key] == null)
         {
             settings.Add(key, value);
         }
         else
         {
             settings[key].Value = value;
         }
         configFile.Save(ConfigurationSaveMode.Modified);
         ConfigurationManager.RefreshSection(configFile.AppSettings.SectionInformation.Name);
     }
     catch (ConfigurationErrorsException cex)
     {
         Error_Log.ErrorMessageOutput(cex.ToString());
     }
 }