public JSetting GetProperty(string name) { JSetting setting = null; settings.TryGetValue(name, out setting); return(setting); }
override protected void CreateProperties() { base.CreateProperties(); JSetting setting = FrwConfig.Instance.CreatePropertyIfNotExist(new JSetting() { Name = "SetProcessDPIAware", Description = FrwCRUDRes.DPI_Awareness_Support_for_Windows_Fonts, Help = FrwCRUDRes.DPI_Awareness_Support_for_Windows_Fonts_____Windows_8___Application_restart_required_, Value = true, IsUser = true, IsAttachedToComputer = true }); setting.ValueChanged += SetProcessDPIAware_ValueChanged; //special storage, //we need this prorerty at the start ogf program FrwConfig.Instance.SetPropertyValue(setting.Name, Properties.Settings.Default.SetProcessDPIAware); setting = FrwConfig.Instance.CreatePropertyIfNotExist(new JSetting() { Name = APPLICATION_FONT, Description = FrwCRUDRes.Application_Font, ValueType = typeof(Font), IsUser = true, IsAttachedToComputer = true, }); }
public BaseMainAppForm() { InitializeComponent(); //if (CreateWindowNotClosable) NotClosable = true; // // eventWarrningButton // this.eventWarrningButton = new System.Windows.Forms.ToolStripSplitButton(); this.eventWarrningButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; //this.eventWarrningButton.Enabled = false; this.eventWarrningButton.ImageTransparentColor = System.Drawing.Color.Magenta; this.eventWarrningButton.Name = "eventWarrningButton"; this.eventWarrningButton.Size = new System.Drawing.Size(19, 23); this.eventWarrningButton.Text = "toolStripSplitButton1"; this.eventWarrningButton.Click += eventWarrningButton_ButtonClick; setEventWarrningButton(false); ToolStripItem item = new ToolStripMenuItem(); item.Text = "Notifications"; item.Click += (s1, em) => { try { CreateList(typeof(JNotification)); } catch (Exception ex) { Log.ShowError(ex); } }; eventWarrningButton.DropDownItems.Add(item); this.notificationTimer = new System.Windows.Forms.Timer(this.components); this.notificationTimer.Interval = 3000; this.notificationTimer.Tick += new System.EventHandler(this.notificationTimer_Tick); AppManager.Instance.RegisterDocPanelContainer(this); Text = Text + ((DocPanelIndex > 0) ? (" " + DocPanelIndex) : "");//index exists after registration in AppManager this.Load += BaseMainAppForm_Load; this.FormClosing += BaseMainAppForm_FormClosing; JSetting s = FrwConfig.Instance.GetProperty(FrwSimpleWinCRUDConfig.APPLICATION_FONT); if (s != null) { if (s.Value == null) { s.Value = this.Font; } s.ValueChanged += FontSetting_ValueChanged; } //create panes m_deserializeDockContent = new DeserializeDockContent(GetContentFromPersistString); }
public JSetting CreatePropertyIfNotExist(string name, string description, object defaultValue = null) { JSetting setting = new JSetting(); setting.Name = name; setting.Description = description; setting.Value = defaultValue; return(CreatePropertyIfNotExist(setting)); }
public string GetPropertyValueAsString(string name) { JSetting setting = GetProperty(name); if (setting != null && setting.Value != null) { return(setting.Value.ToString()); } else { return(null); } }
public object GetPropertyValue(string name, object defaultValue) { JSetting setting = GetProperty(name); if (setting != null) { return(setting.Value); } else { return(defaultValue); } }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { var svc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); PropertyBag bag = (PropertyBag)context.Instance; string pName = context.PropertyDescriptor.Name; PropertySpecDescriptor pd = context.PropertyDescriptor as PropertySpecDescriptor; JSetting setting = pd.PropTag as JSetting; bool complated = false; object res = AppManager.Instance.EditCustomSettingValue(setting, out complated, null); if (complated) { setting.ForceValueChangedEvent(this); bag.OnValueModified(null); } return(res); }
public string GetPropertyValueAsString(string name, string defaultValue) { JSetting setting = GetProperty(name); if (setting != null && setting.Value != null) { return(setting.Value.ToString()); } else { if (setting != null) { setting.Value = defaultValue; } return(defaultValue); } }
public JSetting SetPropertyValue(string name, object value) { JSetting setting = GetProperty(name); if (setting != null) { setting.Value = value; if (setting.Value != null) { setting.ValueType = setting.Value.GetType(); } return(setting); } else { throw new ArgumentException("Setting not found withd name: " + name + ". Create it first."); } }
public JSetting CreatePropertyIfNotExist(JSetting newSetting) { JSetting setting = GetProperty(newSetting.Name); if (setting == null) { setting = newSetting; if (string.IsNullOrEmpty(setting.Name)) { throw new ArgumentException("Name can not be empty"); } //if (setting.Value == null && setting.ValueType == null) throw new ArgumentException("Both Value and ValueType can not be empty"); //set valuetype if (setting.ValueType == null) { if (setting.Value != null) { setting.ValueType = setting.Value.GetType(); } else { setting.ValueType = typeof(string); } } else if (setting.Value != null && setting.ValueType != null) { if (setting.Value.GetType().Equals(setting.ValueType) == false) { throw new ArgumentException("ValueTypeName (" + setting.ValueType.FullName + ") not equals Value type (" + setting.Value.GetType() + ")"); } } settings[setting.Name] = setting; } else { //wee need due to i18n setting.Description = newSetting.Description; setting.Help = newSetting.Help; setting.Group = newSetting.Group; } return(setting); }
/// <summary> /// Virtual method for create you own user settings /// </summary> virtual protected void CreateProperties() { JSetting setting = FrwConfig.Instance.CreatePropertyIfNotExist(new JSetting() { Name = "Language", Description = FrwUtilsRes.Interface_Language, DictId = DictNames.Lang, Value = "system", IsUser = true, IsAttachedToComputer = false }); string lang = FrwConfig.Instance.GetPropertyValueAsString(setting.Name, null); if (lang != null && "system".Equals(lang) == false) { Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(lang); //wee need due to i18n setting.Description = FrwUtilsRes.Interface_Language; } }
public void Load() { components = new System.ComponentModel.Container(); notifyIcon = new NotifyIcon(components) { ContextMenuStrip = new ContextMenuStrip(), Icon = new Icon(IconFileName), Text = DefaultTooltip, Visible = true }; notifyIcon.ContextMenuStrip.Opening += ContextMenuStrip_Opening; //notifyIcon.DoubleClick += notifyIcon_DoubleClick; notifyIcon.MouseUp += notifyIcon_MouseUp; notifyIcon.BalloonTipClicked += NotifyIcon_BalloonTipClicked; JSetting setting = FrwConfig.Instance.CreatePropertyIfNotExist(new JSetting() { Name = SETTING_showMainFormOnStartup, Description = FrwCRUDRes.BaseApplicationContext_Show_Main_Window_OnStartup, Value = true, IsUser = true }); if (FrwConfig.Instance.GetPropertyValueAsBool(setting.Name, true)) { CreateOrShowDetailsForm(true); } else { //we need allways create form because some logic will be activated in form constructor CreateOrShowDetailsForm(false); } //timer for balloon tooltips and change systray icon notificationTimer.Interval = 3000; notificationTimer.Tick += NotificationTimer_Tick; notificationTimer.Enabled = true; Log.EventLogEvent += Log_EventLogEvent; AppManager.Instance.NotificationEvent += Instance_NotificationEvent; AppManager.Instance.RequestForExitEvent += Instance_RequestForExitEvent; }
private void bag1_SetValue(object sender, PropertySpecEventArgs e) { try { if (e.Property.PropTag != null && e.Property.PropTag is JSetting) { JSetting setting = e.Property.PropTag as JSetting; if (setting.IsCustomSetting()) { } else { setting.Value = e.Value; setting.ForceValueChangedEvent(this); } } } catch (Exception ex) { Log.ShowError(ex); } }
private void bag1_GetValue(object sender, PropertySpecEventArgs e) { try { if (e.Property.PropTag != null && e.Property.PropTag is JSetting) { JSetting setting = e.Property.PropTag as JSetting; if (setting.IsCustomSetting()) { e.Value = Dm.Instance.GetCustomSettingValue(setting, true, AppManager.Instance.PropertyWindowTruncatedMaxItemCount, AppManager.Instance.PropertyWindowTruncatedMaxLength); } else { e.Value = setting.Value; } } } catch (Exception ex) { Log.ShowError(ex); } }
static void Main() { AppManager.AjustVideoSetting(); try { Form form = null; try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (!AppManager.CheckForSingleInstance()) { return; } //Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en"); log = Log.GetLogger(); //http://stackoverflow.com/questions/8137070/force-application-close-on-system-shutdown //SystemEvents can help you. The SessionEnding occurs when the user is trying to log off or shut down the system. //Microsoft.Win32.SystemEvents.SessionEnding += SystemEvents_SessionEnding; //If you don't want to cancel the event, but just react to it appropriately, you should handle the SystemEvents.SessionEnded event instead. //Microsoft.Win32.SystemEvents.SessionEnded += SystemEvents_SessionEnded; //create instances of manager classes FrwConfig.Instance = new FrwSimpleWinCRUDConfig();// WebAccountConfig(); Dm.Instance = new NADm(); AppManager.Instance = new NAAppManager(); AppManager.Instance.MainAppFormType = typeof(NetworkAccountHelperMainForm); AppManager.Instance.DefaultViewWindowType = typeof(BrowserViewWindow); //force load dlls with entities VpnSelectorLibLoader.Load(); WebAccountLibLoader.Load(); NetworkAccountHelperLibLoader.Load(); AppManager.Instance.InitApplication(); JSetting setting = FrwConfig.Instance.CreatePropertyIfNotExist(new JSetting() { Name = "RunAppInWindowsTray", Description = VpnSelectorLibRes.Run_application_in_windows_system_tray__next_run_, Value = true, IsUser = true, IsAttachedToComputer = false }); if (FrwConfig.Instance.GetPropertyValueAsBool(setting.Name, true)) { applicationContext = new BaseApplicationContext(); applicationContext.DefaultTooltip = VpnSelectorLibRes.VPN_selector; applicationContext.IconFileName = "tools_icon.ico";// "bookmark_icon.ico"; applicationContext.Load(); BaseApplicationContext.NotifyIcon.Icon = VpnSelectorLibRes.vpn_off; applicationContext.ThreadExit += ApplicationContext_ThreadExit; Application.Run(applicationContext); } else { form = AppManager.Instance.LoadDocPanelContainersState(true); form.FormClosing += Form_FormClosing; form.FormClosed += Form_FormClosed; } } catch (Exception ex) { Log.ShowError("Error start app", ex); Application.Exit(); } if (form != null && !form.IsDisposed) { Application.ThreadException += Application_ThreadException; Application.Run(form); } } catch (Exception ex) { Log.ShowError("Error running main app form", ex); MessageBox.Show("Unexpected error: " + ex); Application.Exit(); } }