private void btnAddLocation_Click(object sender, EventArgs e) { if (ActiveTheme == null) { return; } PageWidthMarkerFormat existing = lstLocations.SelectedItem as PageWidthMarkerFormat; PageWidthMarkerFormat format; if (existing != null) { format = (PageWidthMarkerFormat)existing.Clone(ActiveTheme); } else { format = new PageWidthMarkerFormat(ActiveTheme); } if (existing != null) { format.Position = existing.Position + 10; while (ActiveTheme.LineFormats.ContainsKey(format.GetFormatIndex())) { format.Position += 10; } } format.FormatIndex = format.GetFormatIndex(); ActiveTheme.LineFormats[format.FormatIndex.Value] = format; OnThemeChanged(ActiveTheme); lstLocations.Items.Add(format); lstLocations.SelectedItem = format; }
private void btnRemoveLocation_Click(object sender, EventArgs e) { if (ActiveTheme == null) { return; } int index = lstLocations.SelectedIndex; PageWidthMarkerFormat existing = lstLocations.SelectedItem as PageWidthMarkerFormat; if (existing != null) { ActiveTheme.LineFormats.Remove(existing.FormatIndex.Value); OnThemeChanged(ActiveTheme); lstLocations.Items.Remove(existing); } if (lstLocations.Items.Count > index) { lstLocations.SelectedIndex = index; } else if (lstLocations.Items.Count > 0) { lstLocations.SelectedIndex = lstLocations.Items.Count - 1; } else { lstLocations.SelectedIndex = -1; } }
private void lstLocations_Format(object sender, ListControlConvertEventArgs e) { PageWidthMarkerFormat format = e.ListItem as PageWidthMarkerFormat; Debug.Assert(format != null); if (format == null) { return; } e.Value = format.Position.ToString(CultureInfo.CurrentUICulture); }
private void lstLocations_SelectedIndexChanged(object sender, EventArgs e) { PageWidthMarkerFormat format = lstLocations.SelectedItem as PageWidthMarkerFormat; if (format == null) { gridLineStyle.SelectedObject = null; return; } gridLineStyle.SelectedObject = format; 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; }
private void gridLineStyle_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) { PageWidthMarkerFormat 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); }