public Highlighter Construct(AddEditHighlighter data)
        {
            Color? background = null;
            Color? foreground = null;

            var highlighter = new Highlighter
                              {
                                  Name = data.Name,
                                  Field = data.Field,
                                  Pattern = data.Pattern,
                                  Mode = data.Mode,
                                  Enabled = true
                              };

            if (data.OverrideBackgroundColour)
            {
                background = data.BackgroundColour;
            }

            if (data.OverrideForegroundColour)
            {
                foreground = data.ForegroundColour;
            }

            highlighter.Style = new HighlighterStyle
                                    {
                                        Background = background,
                                        Foreground = foreground
                                    };
            return highlighter;
        }
예제 #2
0
        public Highlighter Construct(AddEditHighlighter data)
        {
            Color?background = null;
            Color?foreground = null;

            var highlighter = new Highlighter
            {
                Name    = data.Name,
                Field   = data.Field,
                Pattern = data.Pattern,
                Mode    = data.Mode,
                Enabled = true
            };

            if (data.OverrideBackgroundColour)
            {
                background = data.BackgroundColour;
            }

            if (data.OverrideForegroundColour)
            {
                foreground = data.ForegroundColour;
            }

            highlighter.Style = new HighlighterStyle {
                Background = background, Foreground = foreground
            };
            return(highlighter);
        }
        public void Add()
        {
            var window = new AddEditHighlighterWindow();
            var data = new AddEditHighlighter(window, false);
            window.DataContext = data;
            window.Owner = Application.Current.MainWindow;

            var dialogResult = window.ShowDialog();
            if (dialogResult != null && (bool)dialogResult)
            {
                var highlighter = Construct(data);

                if (highlighter != null)
                {
                    var service = ServiceLocator.Instance.Get<IHighlightingService<IHighlighter>>();
                    service?.Highlighters.Add(highlighter);
                }
            }
        }
예제 #4
0
        public void Add()
        {
            var window = new AddEditHighlighterWindow();
            var data   = new AddEditHighlighter(window, false);

            window.DataContext = data;
            window.Owner       = Application.Current.MainWindow;

            var dialogResult = window.ShowDialog();

            if (dialogResult != null && (bool)dialogResult)
            {
                var highlighter = Construct(data);

                if (highlighter != null)
                {
                    var service = ServiceLocator.Instance.Get <IHighlightingService <IHighlighter> >();
                    service?.Highlighters.Add(highlighter);
                }
            }
        }
예제 #5
0
        public void Edit(IHighlighter highlighter)
        {
            Debug.Assert(highlighter != null, "Highlighter must be supplied for editing.");

            var window = new AddEditHighlighterWindow();
            var data   = new AddEditHighlighter(window, false);

            window.DataContext = data;
            window.Owner       = Application.Current.MainWindow;

            data.Name    = highlighter.Name;
            data.Pattern = highlighter.Pattern;
            data.Mode    = highlighter.Mode;
            data.Field   = highlighter.Field;

            if (highlighter.Style?.Background != null)
            {
                data.OverrideBackgroundColour = true;
                data.BackgroundColour         = (Color)highlighter.Style.Background;
            }
            else
            {
                data.OverrideBackgroundColour = false;
                data.BackgroundColourIndex    = 1;
            }

            if (highlighter.Style?.Foreground != null)
            {
                data.OverrideForegroundColour = true;
                data.ForegroundColour         = (Color)highlighter.Style.Foreground;
            }
            else
            {
                data.OverrideForegroundColour = false;
                data.ForegroundColourIndex    = 0;
            }

            var dialogResult = window.ShowDialog();

            if (dialogResult != null && (bool)dialogResult)
            {
                highlighter.Name    = data.Name;
                highlighter.Pattern = data.Pattern;
                highlighter.Mode    = data.Mode;
                highlighter.Field   = data.Field;

                if (highlighter.Style == null && (data.OverrideBackgroundColour || data.OverrideForegroundColour))
                {
                    highlighter.Style = new HighlighterStyle();
                }

                if (highlighter.Style != null)
                {
                    highlighter.Style.Background = data.OverrideBackgroundColour
                                                       ? (Color?)data.BackgroundColour
                                                       : null;
                    highlighter.Style.Foreground = data.OverrideForegroundColour
                                                       ? (Color?)data.ForegroundColour
                                                       : null;
                }
            }
        }
예제 #6
0
        public void Edit(IHighlighter highlighter)
        {
            Debug.Assert(highlighter != null, "Highligher must be supplied for editing.");

            AddEditHighlighterWindow window = new AddEditHighlighterWindow();
            AddEditHighlighter data = new AddEditHighlighter(window, false);
            window.DataContext = data;
            window.Owner = Application.Current.MainWindow;

            data.Name = highlighter.Name;
            data.Pattern = highlighter.Pattern;
            data.Mode = highlighter.Mode;
            data.Field = highlighter.Field;

            if (highlighter.Style != null && highlighter.Style.Background != null)
            {
                data.OverrideBackgroundColour = true;
                data.BackgroundColour = (Color)highlighter.Style.Background;
            }
            else
            {
                data.OverrideBackgroundColour = false;
                data.BackgroundColourIndex = 1;
            }

            if (highlighter.Style != null && highlighter.Style.Foreground != null)
            {
                data.OverrideForegroundColour = true;
                data.ForegroundColour = (Color)highlighter.Style.Foreground;
            }
            else
            {
                data.OverrideForegroundColour = false;
                data.ForegroundColourIndex = 0;
            }

            bool? dialogResult = window.ShowDialog();

            if (dialogResult != null && (bool)dialogResult)
            {
                highlighter.Name = data.Name;
                highlighter.Pattern = data.Pattern;
                highlighter.Mode = data.Mode;
                highlighter.Field = data.Field;

                if (highlighter.Style == null && (data.OverrideBackgroundColour || data.OverrideForegroundColour))
                {
                    highlighter.Style = new HighlighterStyle();
                }

                if (highlighter.Style != null)
                {
                    highlighter.Style.Background = data.OverrideBackgroundColour
                                                       ? (Color?)data.BackgroundColour
                                                       : null;
                    highlighter.Style.Foreground = data.OverrideForegroundColour
                                                       ? (Color?)data.ForegroundColour
                                                       : null;
                }
            }
        }