Beispiel #1
0
 public void Update(IndentTheme active, IndentTheme previous)
 {
     if (active != null)
     {
         SelectItem(active.CaretHandler);
     }
 }
Beispiel #2
0
 public void Update(IndentTheme active, IndentTheme previous)
 {
     if (active != null)
     {
         gridLineMode.SelectedObject = active.Behavior;
         lineTextPreview.Theme       = active;
         lineTextPreview.Invalidate();
     }
 }
Beispiel #3
0
        private void OnThemeChanged(IndentTheme theme)
        {
            if (theme == null)
            {
                return;
            }
            EventHandler <ThemeEventArgs> evt = ThemeChanged;

            evt?.Invoke(this, new ThemeEventArgs(theme));
        }
        public LineTextPreview()
        {
            SetStyle(ControlStyles.OptimizedDoubleBuffer |
                     ControlStyles.ResizeRedraw | ControlStyles.Opaque, true);

            InitializeComponent();

            _IndentSize = 4;
            _Theme      = null;
            Analysis    = null;
        }
        public LineTextPreview()
        {
            SetStyle(ControlStyles.OptimizedDoubleBuffer |
                ControlStyles.ResizeRedraw | ControlStyles.Opaque, true);

            InitializeComponent();

            _IndentSize = 4;
            _Theme = null;
            Analysis = null;
        }
Beispiel #6
0
 private void OnThemeChanged(IndentTheme theme)
 {
     if (theme != null)
     {
         EventHandler <ThemeEventArgs> evt = ThemeChanged;
         if (evt != null)
         {
             evt(this, new ThemeEventArgs(theme));
         }
     }
 }
Beispiel #7
0
 public void Update(IndentTheme active, IndentTheme previous)
 {
     if (active != null)
     {
         foreach (LineTextPreview p in Presets)
         {
             p.Theme.LineFormats.Clear();
             foreach (KeyValuePair <int, LineFormat> kv in active.LineFormats)
             {
                 p.Theme.LineFormats[kv.Key] = kv.Value;
             }
             p.Checked = p.Theme.Behavior.Equals(active.Behavior);
             p.Invalidate();
         }
     }
 }
Beispiel #8
0
        private void lstNames_SelectedIndexChanged(object sender, EventArgs e)
        {
            CaretHandlerInfo item = lstNames.SelectedItem as CaretHandlerInfo;

            if (item == null)
            {
                webDocumentation.DocumentText = ResourceLoader.LoadString("NoDocumentationHtml");
            }
            else
            {
                webDocumentation.DocumentText = item.Documentation;
                IndentTheme theme = ActiveTheme;
                if (theme != null && lstNames.Enabled)
                {
                    theme.CaretHandler = item.TypeName;
                    OnThemeChanged(theme);
                }
            }
        }
		/// <summary>
		/// Instantiates a new indent guide manager for a view.
		/// </summary>
		/// <param name="view">The text view to provide guides for.</param>
		/// <param name="service">The Indent Guide service.</param>
		public IndentGuideView(IWpfTextView view, IIndentGuide service)
		{
			View = view;

			if (!service.Themes.TryGetValue(View.TextDataModel.ContentType.DisplayName, out Theme))
			{
				Theme = service.DefaultTheme;
			}
			if (Theme != null && Theme.Behavior != null && Theme.Behavior.Disabled)
				return;

			GuideBrushCache = new Dictionary<System.Drawing.Color, Brush>();
			GlowEffectCache = new Dictionary<System.Drawing.Color, Effect>();

			View.Caret.PositionChanged += Caret_PositionChanged;
			View.LayoutChanged += View_LayoutChanged;
			View.Options.OptionChanged += View_OptionChanged;

			Layer = view.GetAdornmentLayer("IndentGuide");
			Canvas = new Canvas();
			Canvas.HorizontalAlignment = HorizontalAlignment.Stretch;
			Canvas.VerticalAlignment = VerticalAlignment.Stretch;
			Layer.AddAdornment(AdornmentPositioningBehavior.OwnerControlled, null, null, Canvas, CanvasRemoved);

			Debug.Assert(Theme != null, "No themes loaded");
			if (Theme == null)
			{
				Theme = new IndentTheme();
			}
			service.ThemesChanged += new EventHandler(Service_ThemesChanged);

			Analysis = new DocumentAnalyzer(
				View.TextSnapshot,
				Theme.Behavior,
				View.Options.GetOptionValue(DefaultOptions.IndentSizeOptionId),
				View.Options.GetOptionValue(DefaultOptions.TabSizeOptionId)
			);

			GlobalVisible = service.Visible;
			service.VisibleChanged += new EventHandler(Service_VisibleChanged);

			var t = AnalyzeAndUpdateAdornments();
		}
Beispiel #10
0
 public void Update(IndentTheme active, IndentTheme previous)
 {
     if (active != null)
     {
         int previousIndex = lstOverrides.SelectedIndex;
         lstOverrides.SelectedItem = null; // ensure a change event occurs
         if (0 <= previousIndex && previousIndex < lstOverrides.Items.Count)
         {
             lstOverrides.SelectedIndex = previousIndex;
         }
         else if (lstOverrides.Items.Count > 0)
         {
             lstOverrides.SelectedIndex = 0;
         }
         else
         {
             lstOverrides.SelectedIndex = -1;
         }
     }
 }
Beispiel #11
0
 public void Update(IndentTheme active, IndentTheme previous)
 {
     lstLocations.BeginUpdate();
     try
     {
         lstLocations.Items.Clear();
         if (active != null)
         {
             foreach (PageWidthMarkerFormat item in active.PageWidthMarkers.OrderBy(i => i.Position))
             {
                 lstLocations.Items.Add(item);
             }
         }
     }
     finally
     {
         lstLocations.EndUpdate();
         gridLineStyle.SelectedObject = null;
         lstLocations.SelectedIndex   = lstLocations.Items.Count > 0 ? 0 : -1;
     }
 }
        internal void Activate()
        {
            try {
                IVsTextView view = null;
                IWpfTextView wpfView = null;
                TextManagerService.GetActiveView(0, null, out view);
                if (view == null) {
                    CurrentContentType = null;
                } else {
                    wpfView = EditorAdapters.GetWpfTextView(view);
                    CurrentContentType = wpfView.TextDataModel.ContentType.DisplayName;
                }
            } catch {
                CurrentContentType = null;
            }

            Child.Activate();

            if (ActiveTheme == null) {
                IndentTheme activeTheme;
                if (CurrentContentType == null ||
                    !Service.Themes.TryGetValue(CurrentContentType, out activeTheme) ||
                    activeTheme == null) {
                    activeTheme = Service.DefaultTheme;
                }
                if (activeTheme == null) {
                    activeTheme = Service.DefaultTheme = new IndentTheme();
                }
                ActiveTheme = activeTheme;
            }

            UpdateThemeList();
            UpdateDisplay();
        }
        public void Load(IVsSettingsReader reader)
        {
            lock (_Themes) {
                _Themes.Clear();
                DefaultTheme = new IndentTheme();

                string themeKeysString;
                reader.ReadSettingString("Themes", out themeKeysString);

                foreach (var key in themeKeysString.Split(';')) {
                    if (string.IsNullOrWhiteSpace(key)) continue;

                    try {
                        var theme = IndentTheme.Load(reader, key);
                        if (theme.IsDefault) {
                            DefaultTheme = theme;
                        } else {
                            _Themes[theme.ContentType] = theme;
                        }
                    } catch (Exception ex) {
                        Trace.WriteLine(string.Format("IndentGuide::LoadSettingsFromXML: {0}", ex));
                    }
                }

                int tempInt;
                reader.ReadSettingLong("Visible", out tempInt);
                Visible = (tempInt != 0);
            }

            OnThemesChanged();
        }
		/// <summary>
		/// Raised when the theme is updated.
		/// </summary>
		async void Service_ThemesChanged(object sender, EventArgs e)
		{
			var service = (IIndentGuide)sender;
			if (!service.Themes.TryGetValue(View.TextDataModel.ContentType.DisplayName, out Theme))
			{
				Theme = service.DefaultTheme;
			}

			Analysis = new DocumentAnalyzer(
				View.TextSnapshot,
				Theme.Behavior,
				View.Options.GetOptionValue(DefaultOptions.IndentSizeOptionId),
				View.Options.GetOptionValue(DefaultOptions.TabSizeOptionId)
			);
			GuideBrushCache.Clear();
			GlowEffectCache.Clear();

			await AnalyzeAndUpdateAdornments();
		}
        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();
        }
        private void btnThemeDelete_Click(object sender, EventArgs e)
        {
            if (ActiveTheme == null) return;

            try {
                if (ActiveTheme.IsDefault) {
                    var theme = Service.DefaultTheme = new IndentTheme();
                    UpdateThemeList();
                    ActiveTheme = theme;
                } else {
                    if (Service.Themes.Remove(ActiveTheme.ContentType)) {
                        int i = cmbTheme.SelectedIndex;
                        cmbTheme.Items.Remove(ActiveTheme);
                        if (i < cmbTheme.Items.Count) cmbTheme.SelectedIndex = i;
                        else cmbTheme.SelectedIndex = cmbTheme.Items.Count - 1;
                    }
                }
            } catch (Exception ex) {
                Trace.WriteLine(string.Format("IndentGuide::btnThemeDelete_Click: {0}", ex));
            }
        }
 private void btnCustomizeThisContentType_Click(object sender, EventArgs e)
 {
     try {
         IndentTheme theme;
         if (!Service.Themes.TryGetValue(CurrentContentType, out theme)) {
             if (ActiveTheme == null)
                 theme = new IndentTheme();
             else
                 theme = ActiveTheme.Clone();
             theme.ContentType = CurrentContentType;
             Service.Themes[CurrentContentType] = theme;
             UpdateThemeList();
         }
         cmbTheme.SelectedItem = theme;
     } catch (Exception ex) {
         Trace.WriteLine(string.Format("IndentGuide::btnCustomizeThisContentType_Click: {0}", ex));
     }
 }
 protected void UpdateDisplay(IndentTheme active, IndentTheme previous)
 {
     Suppress_cmbTheme_SelectedIndexChanged = true;
     try {
         if (active != null && cmbTheme.Items.Contains(active)) {
             cmbTheme.SelectedItem = active;
         } else {
             cmbTheme.SelectedItem = null;
         }
     } finally {
         Suppress_cmbTheme_SelectedIndexChanged = false;
     }
     Child.Update(active, previous);
 }
 public ThemeEventArgs(IndentTheme theme)
     : base()
 {
     Theme = theme;
 }
Beispiel #20
0
 internal PageWidthMarkerGetter(IndentTheme theme)
 {
     Theme = theme;
 }
        private void LoadFromRegistry(RegistryKey reg)
        {
            Debug.Assert(reg != null, "reg cannot be null");

            lock (_Themes) {
                _Themes.Clear();
                DefaultTheme = new IndentTheme();
                foreach (var themeName in reg.GetSubKeyNames()) {
                    if (CARETHANDLERS_SUBKEY_NAME.Equals(themeName, StringComparison.InvariantCulture)) {
                        continue;
                    }
                    var theme = IndentTheme.Load(reg, themeName);
                    if (theme.IsDefault) {
                        DefaultTheme = theme;
                    } else {
                        _Themes[theme.ContentType] = theme;
                    }
                }

                Visible = (int)reg.GetValue("Visible", 1) != 0;
            }

            OnThemesChanged();
        }
Beispiel #22
0
 public ThemeEventArgs(IndentTheme theme)
 {
     Theme = theme;
 }
 internal void Close()
 {
     Child.Close();
     _ActiveTheme = null;
 }