| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.ComponentModel;
- using System.Diagnostics;
- using System.Threading;
- using System.Runtime.InteropServices;
- using System.Windows.Forms;
- using System.Drawing.Imaging;
- namespace Ips.Library.DxpLib
- {
- public static class ToolWinform
- {
- public static bool IsDesignMode()
- {
- bool returnFlag = false;
- #if DEBUG
- if (LicenseManager.UsageMode == LicenseUsageMode.Designtime)
- {
- returnFlag = true;
- }
- else if (Process.GetCurrentProcess().ProcessName == "devenv")
- {
- returnFlag = true;
- }
- #endif
- return returnFlag;
- }
- public static void SaveCtrlValueToConfig(Control ctrl)
- {
- try
- {
- Dictionary<string, string> settings = new Dictionary<string, string>();
- SaveValueToSettings(ctrl, settings);
- ToolConfig.SetAppSetting(settings);
- }
- catch (Exception ex)
- {
- ToolMsg.ShowError("保存配置异常,错误消息:" + ex.Message);
- }
- }
- public static void LoadCtrlValueFromConfig(Control ctrl)
- {
- try
- {
- LoadValueFromSettings(ctrl);
- }
- catch (Exception ex)
- {
- ToolMsg.ShowError("加载配置异常,错误消息:" + ex.Message);
- }
- }
- private static void SaveValueToSettings(Control ctrl, Dictionary<string, string> settings)
- {
- foreach (Control item in ctrl.Controls)
- {
- if (item is TextBoxBase)
- {
- settings.Add(item.Name, item.Text);
- }
- SaveValueToSettings(item, settings);
- }
- }
- private static void LoadValueFromSettings(Control ctrl)
- {
- foreach (Control item in ctrl.Controls)
- {
- if (item is TextBoxBase)
- {
- item.Text = ToolConfig.GetAppSetting(item.Name);
- }
- LoadValueFromSettings(item);
- }
- }
- }
- }
|