Example #1
0
        private void MoveItemDown(object obj)
        {
            if (selectedIndex == -1)
            {
                return;
            }

            lock (this)
            {
                Debug.Assert(selectedIndex >= 0, "SelectedIndex must be valid, not -1, for moving.");
                Debug.Assert(
                    selectedIndex < (Highlighters.Count - 1),
                    "SelectedIndex must be a value less than the max index of the collection.");
                Debug.Assert(
                    Highlighters.Count > 1,
                    "Can only move an item if there are more than one items in the collection.");

                var oldIndex = selectedIndex;
                SelectedIndex = -1;
                lock (Highlighters)
                {
                    Highlighters.Swap(oldIndex, oldIndex + 1);
                }

                SelectedIndex = oldIndex + 1;
            }
        }
Example #2
0
        public void AddHilighter(string searchString, Color foreColor, Color backColor)
        {
            if (Highlighters.Rows.Count == 15)
            {
                MessageBox.Show(@"Can only have 15 highlighers active at a time."); return;
            }
            if (string.IsNullOrEmpty(searchString))
            {
                return;
            }
            var newRow = Highlighters.NewRow();

            newRow[HighlightSearch.Attributes.Key.ToString()]       = searchString;
            newRow[HighlightSearch.Attributes.Sample.ToString()]    = searchString;
            newRow[HighlightSearch.Attributes.ForeColor.ToString()] = foreColor;
            newRow[HighlightSearch.Attributes.BackColor.ToString()] = backColor;

            Highlighters.Rows.Add(newRow);

            var lastRow = dgvHighlights.Rows[dgvHighlights.Rows.GetLastRow(DataGridViewElementStates.Visible)];

            lastRow.Cells[HighlightSearch.Attributes.Sample.ToString()].Style.ForeColor = foreColor;
            lastRow.Cells[HighlightSearch.Attributes.Sample.ToString()].Style.BackColor = backColor;

            lastRow.Cells[HighlightSearch.Attributes.Sample.ToString()].Style.SelectionForeColor = foreColor;
            lastRow.Cells[HighlightSearch.Attributes.Sample.ToString()].Style.SelectionBackColor = backColor;

            lblCounter.Text    = Highlighters.Rows.Count + @"/15";
            txtNewHilight.Text = null;
            FixGridColumnWidths(dgvHighlights);

            HilightTab();
        }
Example #3
0
 public ReplaceViewModel()
 {
     Highlighters = ThemedHighlightingManager.Instance.HighlightingNames.ToList();
     Highlighters.Sort();
     Highlighters.Insert(0, "None");
     CurrentSyntax = "None";
 }
Example #4
0
 public ReplaceViewModel()
 {
     Highlighters = ThemedHighlightingManager.Instance.HighlightingNames.ToList();
     Highlighters.Sort();
     Highlighters.Insert(0, "None");
     CurrentSyntax         = "None";
     ApplicationFontFamily = GrepSettings.Instance.Get <string>(GrepSettings.Key.ApplicationFontFamily);
     ReplaceFormFontSize   = GrepSettings.Instance.Get <double>(GrepSettings.Key.ReplaceFormFontSize);
 }
Example #5
0
        public PreviewViewModel()
        {
            Highlighters = ThemedHighlightingManager.Instance.HighlightingNames.ToList();
            Highlighters.Sort();
            Highlighters.Insert(0, "None");
            CurrentSyntax = "None";

            PropertyChanged += PreviewViewModel_PropertyChanged;
        }
Example #6
0
        private void RemoveHighlighter(object obj)
        {
            IRemoveHighlighterService service = new RemoveHighlighterService();
            var highlighter = Highlighters.ElementAt(SelectedIndex);

            Debug.Assert(highlighter != null, "Should not be able to run this if no highlighter is selected!");

            service.Remove(highlighter);
        }
Example #7
0
        private void EditHighlighter(object obj)
        {
            IEditHighlighterService editService = new EditHighlighterService();
            var highlighter = Highlighters.ElementAt(SelectedIndex);

            if (highlighter != null)
            {
                editService.Edit(highlighter);
            }
        }
Example #8
0
        public PreviewViewModel()
        {
            Highlighters = ThemedHighlightingManager.Instance.HighlightingNames.ToList();
            Highlighters.Sort();
            Highlighters.Insert(0, "None");
            CurrentSyntax = "None";

            HighlightsOn = GrepSettings.Instance.Get <bool>(GrepSettings.Key.HighlightMatches);

            PropertyChanged += PreviewViewModel_PropertyChanged;
        }
Example #9
0
        public ReplaceViewModel()
        {
            Highlighters = ThemedHighlightingManager.Instance.HighlightingNames.ToList();
            Highlighters.Sort();
            Highlighters.Insert(0, Resources.Replace_SyntaxNone);
            CurrentSyntax         = Resources.Replace_SyntaxNone;
            ApplicationFontFamily = GrepSettings.Instance.Get <string>(GrepSettings.Key.ApplicationFontFamily);
            ReplaceFormFontSize   = GrepSettings.Instance.Get <double>(GrepSettings.Key.ReplaceFormFontSize);
            ResultsFontFamily     = GrepSettings.Instance.Get <string>(GrepSettings.Key.ResultsFontFamily);

            IsFullDialog = GrepSettings.Instance.Get <bool>(GrepSettings.Key.ShowFullReplaceDialog);
        }
Example #10
0
        private static int getBorder(Highlighters control)
        {
            int border = Preferences.HighlighterBorder;

            if (control == Highlighters.Parent)
            {
                border = Preferences.HighlighterBorderParent;
            }
//            else if (control == Highlighters.FirstChild) {
//                border = Preferences.HighlighterBorderFirstChild;
//            }
            return(border);
        }
Example #11
0
        private void InitializeHighlighters()
        {
            var items = ThemedHighlightingManager.Instance.HighlightingNames.ToList();

            items.Sort();
            items.Insert(0, Resources.Preview_SyntaxNone);
            Highlighters.Clear();
            foreach (var item in items)
            {
                Highlighters.Add(item);
            }

            CurrentSyntax = Resources.Preview_SyntaxNone;
        }
Example #12
0
        public PreviewViewModel()
        {
            Highlighters = ThemedHighlightingManager.Instance.HighlightingNames.ToList();
            Highlighters.Sort();
            Highlighters.Insert(0, "None");
            CurrentSyntax = "None";

            HighlightsOn = GrepSettings.Instance.Get <bool>(GrepSettings.Key.HighlightMatches);

            ApplicationFontFamily = GrepSettings.Instance.Get <string>(GrepSettings.Key.ApplicationFontFamily);
            MainFormFontSize      = GrepSettings.Instance.Get <double>(GrepSettings.Key.MainFormFontSize);

            PropertyChanged += PreviewViewModel_PropertyChanged;
        }
Example #13
0
 private void paintTopSide(
     Highlighters control,
     int border,
     NativeMethods.CursorPoint p,
     double height,
     double width,
     Color?color)
 // System.Nullable<System.Drawing.Color> color)
 {
     topSide = new Side(p.X,
                        p.Y - (border / 2),
                        width,
                        border,
                        control,
                        color);
 }
Example #14
0
        private void createHighlighter(
            double height,
            double width,
            double X,
            double Y,
            int intHandle,
            Highlighters control,
            Color?color)
        {
            try {
                if (height == 0 || width == 0)
                {
                    return;
                }
                int border = getBorder(control);
                NativeMethods.CursorPoint p =
                    getPoint(
                        X,
                        Y,
                        intHandle); //;

                paintLeftSide(control, border, p, height, width, color);
                paintTopSide(control, border, p, height, width, color);
                paintRightSide(control, border, p, height, width, color);
                paintBottomSide(control, border, p, height, width, color);

                /*
                 * if (height != 0 && width != 0) {
                 *
                 *  int border = getBorder(control);
                 *  NativeMethods.CursorPoint p =
                 *      getPoint(
                 *          X,
                 *          Y,
                 *          intHandle);;
                 *
                 *  this.paintLeftSide(control, border, p, height, width, color);
                 *  this.paintTopSide(control, border, p, height, width, color);
                 *  this.paintRightSide(control, border, p, height, width, color);
                 *  this.paintBottomSide(control, border, p, height, width, color);
                 * }
                 */
            }
            catch { //(Exception eHighlighter) {
            }
        }
Example #15
0
        public Highlighter(
            double height,
            double width,
            double X,
            double Y,
            int intHandle,
            Highlighters control)
        {
			this.disposeSides();
			
        	this.createHighlighter(
        		height,
        		width,
        		X,
        		Y,
        		intHandle,
        		control);
        }
Example #16
0
        /// <summary>
        /// Writes the given record to the console and highlights certain parts of the line.
        /// </summary>
        /// <param name="record">The record to write to the console.</param>
        protected void WriteConsoleRecord(string record)
        {
            if (!Highlighters.Any())
            {
                return;
            }

            // Create base highlighter collection instance
            var highlights = Highlighters[0].GetHighlights(ref record);

            // Combine all the other collections with the first
            for (int i = 1; i < Highlighters.Count; i++)
            {
                highlights.AddRange(Highlighters[i].GetHighlights(ref record));
            }

            // Write the record using the highlight colors
            highlights.Print();
        }
Example #17
0
 public Highlighter(
     double height,
     double width,
     double X,
     double Y,
     int intHandle,
     Highlighters control,
     Color? color)
 {
     disposeSides();
     
     createHighlighter(
         height,
         width,
         X,
         Y,
         intHandle,
         control,
         color);
 }
Example #18
0
        public Highlighter(
            double height,
            double width,
            double X,
            double Y,
            int intHandle,
            Highlighters control,
            Color?color)
        {
            disposeSides();

            createHighlighter(
                height,
                width,
                X,
                Y,
                intHandle,
                control,
                color);
        }
Example #19
0
        private void MoveItemUp(object obj)
        {
            if (selectedIndex != -1)
            {
                lock (this)
                {
                    Debug.Assert(selectedIndex >= 0, "SelectedIndex must be valid, e.g not -1.");
                    Debug.Assert(
                        Highlighters.Count > 1, "Can not move item unless more than one item in the collection.");

                    int oldIndex = selectedIndex;
                    SelectedIndex = -1;
                    lock (Highlighters)
                    {
                        Highlighters.Swap(oldIndex, oldIndex - 1);
                    }

                    SelectedIndex = oldIndex - 1;
                }
            }
        }
Example #20
0
 public Highlighter(
     double height,
     double width,
     double X,
     double Y,
     int intHandle,
     Highlighters control,
     int highlighterNumber,
     string highlighterData)
 {
     createHighlighter(
         height,
         width,
         X,
         Y,
         intHandle,
         control,
         null);
     
     PaintLabel(highlighterNumber, highlighterData);
 }
Example #21
0
        public Highlighter(
            double height,
            double width,
            double X,
            double Y,
            int intHandle,
            Highlighters control,
            int highlighterNumber,
            string highlighterData)
        {
            createHighlighter(
                height,
                width,
                X,
                Y,
                intHandle,
                control,
                null);

            PaintLabel(highlighterNumber, highlighterData);
        }
Example #22
0
        public Highlighter(
            double height,
            double width,
            double X,
            double Y,
            int intHandle,
            Highlighters control,
            // 20130423
            System.Nullable<System.Drawing.Color> color)
        {
			this.disposeSides();
			
        	this.createHighlighter(
        		height,
        		width,
        		X,
        		Y,
        		intHandle,
        		control,
        	    // 20130423
        	    color);
        }
Example #23
0
        public void Initialise()
        {
            Debug.Assert(!Highlighters.Any(), "Should not have any contents at initialisation");

            Highlighters.Add(new StandardHighlighter("Trace", true, LogEntryField.Type, MatchMode.Exact, "TRACE", new HighlighterStyle {
                Background = Colors.LightGray
            }) as T);
            Highlighters.Add(new StandardHighlighter("Debug", true, LogEntryField.Type, MatchMode.Exact, "DEBUG", new HighlighterStyle {
                Background = Colors.LightGreen
            }) as T);
            Highlighters.Add(new StandardHighlighter("Info", true, LogEntryField.Type, MatchMode.Exact, "INFO", new HighlighterStyle {
                Foreground = Colors.White, Background = Colors.Blue
            }) as T);
            Highlighters.Add(new StandardHighlighter("Warn", true, LogEntryField.Type, MatchMode.Exact, "WARN", new HighlighterStyle {
                Background = Colors.Yellow
            }) as T);
            Highlighters.Add(new StandardHighlighter("Error", true, LogEntryField.Type, MatchMode.Exact, "ERROR", new HighlighterStyle {
                Foreground = Colors.White, Background = Colors.Red
            }) as T);
            Highlighters.Add(new StandardHighlighter("Fatal", true, LogEntryField.Type, MatchMode.Exact, "FATAL", new HighlighterStyle {
                Foreground = Colors.Yellow, Background = Colors.Black
            }) as T);
        }
Example #24
0
        private void createHighlighter(
        	double height,
            double width,
            double X,
            double Y,
            int intHandle,
            Highlighters control)
        {
            try {

                if (height != 0 && width != 0) {
                    
                    int border = getBorder(control);
                    NativeMethods.CursorPoint p = 
                        getPoint(
                            X,
                            Y,
                            intHandle);;
                    
                    this.paintLeftSide(control, border, p, height, width);
                    this.paintTopSide(control, border, p, height, width);
                    this.paintRightSide(control, border, p, height, width);
                    this.paintBottomSide(control, border, p, height, width);
                }
            }
            catch { //(Exception eHighlighter) {
            }
        }
Example #25
0
        public Side(
            double left,
            double top,
            double width,
            double height,
            Highlighters control,
            Color?color)
        {
            TopMost         = true;
            FormBorderStyle = FormBorderStyle.FixedToolWindow;
            Visible         = false;
            Opacity         = 0.5;

            if (null != color)
            {
                BackColor = (Color)color;
                ForeColor = (Color)color;
            }
            else
            {
                switch (control)
                {
                case Highlighters.Parent:
                    BackColor = Preferences.HighlighterColorParent;
                    ForeColor = Preferences.HighlighterColorParent;
                    break;

                case Highlighters.Element:
                    BackColor = Preferences.HighlighterColor;
                    ForeColor = Preferences.HighlighterColor;
                    break;

                default:
                    BackColor = Color.FromKnownColor(ExecutionPlan.colorTable[(int)control]);
                    ForeColor = Color.FromKnownColor(ExecutionPlan.colorTable[(int)control]);
                    break;
                }
                //            else if (control == Highlighters.FirstChild) {
                //                this.BackColor = Preferences.HighlighterColorFirstChild;
                //                this.ForeColor = Preferences.HighlighterColorFirstChild;
                //            }

                /*
                 * if (control == Highlighters.Parent) {
                 *  this.BackColor = Preferences.HighlighterColorParent;
                 *  this.ForeColor = Preferences.HighlighterColorParent;
                 * } else if (control == Highlighters.Element) {
                 *  this.BackColor = Preferences.HighlighterColor;
                 *  this.ForeColor = Preferences.HighlighterColor;
                 * } else {
                 *  this.BackColor = Color.FromKnownColor(ExecutionPlan.colorTable[(int)control]);
                 *  this.ForeColor = Color.FromKnownColor(ExecutionPlan.colorTable[(int)control]);
                 * }
                 */
            }

            AllowTransparency = true;
            ControlBox        = false;
            ShowIcon          = false;
            ShowInTaskbar     = false;
            TopLevel          = true;
            UseWaitCursor     = false;
            WindowState       = FormWindowState.Normal;
            Left   = (int)left;
            Top    = (int)top;
            Width  = 0;
            Height = 0;
            Show();
            Hide();
            Left            = (int)left;
            Top             = (int)top;
            Width           = (int)width;
            Height          = (int)height;
            Enabled         = false;
            FormBorderStyle = FormBorderStyle.FixedToolWindow;
            ShowInTaskbar   = false;
            UseWaitCursor   = false;
            Visible         = true;
            Show();
        }
Example #26
0
        public Side(
            double left, 
            double top, 
            double width, 
            double height, 
            Highlighters control,
            Color? color)
        {
            TopMost = true;
            FormBorderStyle = FormBorderStyle.FixedToolWindow;
            Visible = false;
            Opacity = 0.5;
            
            if (null != color) {
                BackColor = (Color)color;
                ForeColor = (Color)color;
            } else {
                switch (control)
                {
                    case Highlighters.Parent:
                        BackColor = Preferences.HighlighterColorParent;
                        ForeColor = Preferences.HighlighterColorParent;
                        break;
                    case Highlighters.Element:
                        BackColor = Preferences.HighlighterColor;
                        ForeColor = Preferences.HighlighterColor;
                        break;
                    default:
                        BackColor = Color.FromKnownColor(ExecutionPlan.colorTable[(int)control]);
                        ForeColor = Color.FromKnownColor(ExecutionPlan.colorTable[(int)control]);
                        break;
                }
    //            else if (control == Highlighters.FirstChild) {
    //                this.BackColor = Preferences.HighlighterColorFirstChild;
    //                this.ForeColor = Preferences.HighlighterColorFirstChild;
    //            }

                /*
                if (control == Highlighters.Parent) {
                    this.BackColor = Preferences.HighlighterColorParent;
                    this.ForeColor = Preferences.HighlighterColorParent;
                } else if (control == Highlighters.Element) {
                    this.BackColor = Preferences.HighlighterColor;
                    this.ForeColor = Preferences.HighlighterColor;
                } else {
                    this.BackColor = Color.FromKnownColor(ExecutionPlan.colorTable[(int)control]);
                    this.ForeColor = Color.FromKnownColor(ExecutionPlan.colorTable[(int)control]);
                }
                */
            }
            
            AllowTransparency = true;
            ControlBox = false;
            ShowIcon = false;
            ShowInTaskbar = false;
            TopLevel = true;
            UseWaitCursor = false;
            WindowState = FormWindowState.Normal;
            Left = (int)left;
            Top = (int)top;
            Width = 0;
            Height = 0;
            Show();
            Hide();
            Left = (int)left;
            Top = (int)top;
            Width = (int)width;
            Height = (int)height;
            Enabled = false;
            FormBorderStyle = FormBorderStyle.FixedToolWindow;
            ShowInTaskbar = false;
            UseWaitCursor = false;
            Visible = true;
            Show();
        }
Example #27
0
 public IHighlighterStyle IsHighlighted(ILogEntry logEntry)
 {
     return(Highlighters.Where(h => h.IsMatch(logEntry)).Select(h => h.Style).FirstOrDefault());
 }
Example #28
0
 private void paintLeftSide(
     //AutomationElement element, 
     Highlighters control,
     int border,
     NativeMethods.CursorPoint p,
     double height,
     double width,
     // 20130423
     System.Nullable<System.Drawing.Color> color)
 {
     leftSide = new Side(p.X - (border / 2),
                         p.Y,
                         border,
                         height,
                         control,
                         // 20130423
                         color);
 }
Example #29
0
 private void paintRightSide(
     Highlighters control,
     int border,
     NativeMethods.CursorPoint p,
     double height,
     double width,
     // 20130423
     System.Nullable<System.Drawing.Color> color)
 {
     rightSide = new Side(p.X +
                          width -
                              (border / 2),
                          p.Y,
                          border,
                          height,
                          control,
                          // 20130423
                          color);
 }
Example #30
0
 private void paintBottomSide(
     Highlighters control,
     int border,
     NativeMethods.CursorPoint p,
     double height,
     double width,
     // 20130423
     System.Nullable<System.Drawing.Color> color)
 {
     bottomSide = new Side(p.X,
                           p.Y +
                           height -
                               (border / 2),
                           width,
                           border,
                           control,
                           // 20130423
                           color);
 }
Example #31
0
 private void paintTopSide(
     Highlighters control,
     int border,
     NativeMethods.CursorPoint p,
     double height,
     double width,
     Color? color)
     // System.Nullable<System.Drawing.Color> color)
 {
     topSide = new Side(p.X,
                        p.Y - (border / 2),
                        width,
                        border,
                        control,
                        color);
 }
Example #32
0
        public Side(
            double left, 
            double top, 
            double width, 
            double height, 
            Highlighters control)
        {
            //this.Left = 0;
            //this.Top = 0;
            //this.Width = 1;
            //this.Height = 1;
            this.TopMost = true;
            //this.FormBorderStyle = FormBorderStyle.None;
            this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
            this.Visible = false;
            this.Opacity = 0.5;
            if (control == Highlighters.Parent) {
                this.BackColor = Preferences.HighlighterColorParent;
                this.ForeColor = Preferences.HighlighterColorParent;
            } else if (control == Highlighters.Element) {
                this.BackColor = Preferences.HighlighterColor;
                this.ForeColor = Preferences.HighlighterColor;
            } else {
            	this.BackColor = Color.FromKnownColor(ExecutionPlan.colorTable[(int)control]);
            	this.ForeColor = Color.FromKnownColor(ExecutionPlan.colorTable[(int)control]);
            }
//            else if (control == Highlighters.FirstChild) {
//                this.BackColor = Preferences.HighlighterColorFirstChild;
//                this.ForeColor = Preferences.HighlighterColorFirstChild;
//            }
            
            this.AllowTransparency = true;
            this.ControlBox = false;
            this.ShowIcon = false;
            this.ShowInTaskbar = false;
            this.TopLevel = true;
            this.UseWaitCursor = false;
            this.WindowState = FormWindowState.Normal;
            // 20130322
            this.Left = (int)left;
            this.Top = (int)top;
            this.Width = 0;
            this.Height = 0;
            this.Show();
            this.Hide();
            this.Left = (int)left;
            this.Top = (int)top;
            this.Width = (int)width;
            this.Height = (int)height;
            this.Enabled = false;
            this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
            this.ShowInTaskbar = false;
            this.UseWaitCursor = false;
            this.Visible = true;
            this.Show();
        }
Example #33
0
 private void paintBottomSide(
     Highlighters control,
     int border,
     NativeMethods.CursorPoint p,
     double height,
     double width)
 {
     bottomSide = new Side(p.X,
                           p.Y +
                           height -
                               (border / 2),
                           width,
                           border,
                           control);
 }
Example #34
0
 private void paintRightSide(
     Highlighters control,
     int border,
     NativeMethods.CursorPoint p,
     double height,
     double width)
 {
     rightSide = new Side(p.X +
                          width -
                              (border / 2),
                          p.Y,
                          border,
                          height,
                          control);
 }
Example #35
0
 private void paintLeftSide(
     //AutomationElement element, 
     Highlighters control,
     int border,
     NativeMethods.CursorPoint p,
     double height,
     double width)
 {
     leftSide = new Side(p.X - (border / 2),
                         p.Y,
                         border,
                         height,
                         control);
 }
Example #36
0
        private static int getBorder(Highlighters control)
        {
            int border = Preferences.HighlighterBorder;
            if (control == Highlighters.Parent) {
                border = Preferences.HighlighterBorderParent;
            } 
//            else if (control == Highlighters.FirstChild) {
//                border = Preferences.HighlighterBorderFirstChild;
//            }
            return border;
        }