public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value.GetType() == typeof(string)) { if (culture.Equals(CultureInfo.CurrentCulture)) { return(FromCurrentCulture[(string)value]); } else if (culture.Equals(CultureInfo.InvariantCulture)) { return((T)Enum.Parse(typeof(T), (string)value)); } var prefix = typeof(T).Name + "_"; foreach (var name in Enum.GetNames(typeof(T))) { var localized = ResourceLoader.LoadString(prefix + name, null, culture); if (localized.Equals(value)) { return((T)Enum.Parse(typeof(T), name)); } } return(default(T)); } else { return(base.ConvertFrom(context, culture, value)); } }
private void gridLineStyle_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) { var format = gridLineStyle.SelectedObject as PageWidthMarkerFormat; if (format != null) { if (e.ChangedItem.PropertyDescriptor.Name == "Position") { if (ActiveTheme != null) { if (ActiveTheme.LineFormats.ContainsKey(format.GetFormatIndex())) { format.Position = (int)e.OldValue; MessageBox.Show(ResourceLoader.LoadString("PageWidthExists"), ResourceLoader.LoadString("Title")); return; } ActiveTheme.LineFormats.Remove(format.FormatIndex.Value); format.FormatIndex = format.GetFormatIndex(); ActiveTheme.LineFormats[format.FormatIndex.Value] = format; } lstLocations.FormattingEnabled = false; lstLocations.FormattingEnabled = true; } linePreview.ForeColor = format.LineColor; linePreview.GlowColor = format.LineColor; linePreview.Style = format.LineStyle; linePreviewHighlight.ForeColor = format.HighlightStyle.HasFlag(LineStyle.Glow) ? format.LineColor : format.HighlightColor; linePreviewHighlight.GlowColor = format.HighlightColor; linePreviewHighlight.Style = format.HighlightStyle; } OnThemeChanged(ActiveTheme); }
public EnumResourceTypeConverter() : base(typeof(T)) { ToCurrentCulture = new Dictionary <T, string>(); FromCurrentCulture = new Dictionary <string, T>(); var prefix = typeof(T).Name + "_"; foreach (var name in Enum.GetNames(typeof(T))) { var localized = ResourceLoader.LoadString(prefix + name, null, CultureInfo.CurrentCulture); var value = (T)Enum.Parse(typeof(T), name); ToCurrentCulture[value] = localized; FromCurrentCulture[localized] = value; } }
protected void LoadControlStrings(IEnumerable <Control> controls) { try { foreach (var control in controls) { try { control.Text = ResourceLoader.LoadString(control.Name) ?? control.Text; } catch (InvalidOperationException) { } if (control.Controls.Count > 0) { LoadControlStrings(control.Controls.OfType <Control>()); } } } catch (Exception ex) { Trace.WriteLine(string.Format("IndentGuide::LoadControlStrings: {0}", ex)); } }
private void lstNames_SelectedIndexChanged(object sender, EventArgs e) { var item = lstNames.SelectedItem as CaretHandlerInfo; if (item == null) { webDocumentation.DocumentText = ResourceLoader.LoadString("NoDocumentationHtml"); } else { webDocumentation.DocumentText = item.Documentation; var theme = ActiveTheme; if (theme != null && lstNames.Enabled) { theme.CaretHandler = item.TypeName; OnThemeChanged(theme); } } }
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(string)) { if (culture.Equals(CultureInfo.CurrentCulture)) { return(ToCurrentCulture[(T)value]); } else if (culture.Equals(CultureInfo.InvariantCulture)) { return(value.ToString()); } var name = value.ToString(); return(ResourceLoader.LoadString(typeof(T).Name + "_" + name, name, culture)); } else { return(base.ConvertTo(context, culture, value, destinationType)); } }
private void cmbTheme_SelectedIndexChanged(object sender, EventArgs e) { if (Suppress_cmbTheme_SelectedIndexChanged) { return; } ActiveTheme = cmbTheme.SelectedItem as IndentTheme; if (ActiveTheme != null) { btnThemeDelete.Enabled = true; btnThemeDelete.Text = ResourceLoader.LoadString(ActiveTheme.IsDefault ? "btnThemeReset" : "btnThemeDelete"); } else { btnThemeDelete.Enabled = false; btnThemeDelete.Text = ResourceLoader.LoadString("btnThemeReset"); } UpdateDisplay(); }
public DisplayOptionsControl() { InitializeComponent(); lstOverrides.BeginUpdate(); lstOverrides.Items.Clear(); lstOverrides.Items.Add(new OverrideInfo { Index = LineFormat.DefaultFormatIndex, Text = ResourceLoader.LoadString("DefaultFormatName") }); lstOverrides.Items.Add(new OverrideInfo { Index = LineFormat.UnalignedFormatIndex, Text = ResourceLoader.LoadString("UnalignedFormatName") }); for (int key = 0; key <= 30; ++key) { var name = string.Format(CultureInfo.CurrentCulture, "#{0}", key); lstOverrides.Items.Add(new OverrideInfo { Index = key, Text = name }); } lstOverrides.EndUpdate(); }
private void ThemeOptionsControl_Load(object sender, EventArgs e) { LoadControlStrings(Controls.OfType <Control>()); toolTip.SetToolTip(btnCustomizeThisContentType, ResourceLoader.LoadString("tooltipCustomizeThisContentType")); }
public string GetDocumentation(CultureInfo culture) { return(ResourceLoader.LoadString("CaretNoneDocumentation", culture)); }
public string GetDisplayName(CultureInfo culture) { return(ResourceLoader.LoadString("CaretNoneDisplayName", culture)); }
public string GetDocumentation(CultureInfo culture) { return(ResourceLoader.LoadString("CaretAboveBelowEndsDocumentation", culture)); }
public string GetDisplayName(CultureInfo culture) { return(ResourceLoader.LoadString("CaretAboveBelowEndsDisplayName", culture)); }
public ResourceDisplayNameAttribute(string resourceId) : base(ResourceLoader.LoadString(resourceId)) { }
public ResourceCategoryAttribute(string resourceId) : base(ResourceLoader.LoadString(resourceId)) { }
public ResourceDescriptionAttribute(string resourceId) : base(ResourceLoader.LoadString(resourceId)) { }