public void DrawHighlights(NodeHighlighter nh)
        {
            var hpen     = new Pen(Brushes.White, 20);
            var crossPen = new Pen(Brushes.Red, 20);

            using (DrawingContext dc = picHighlights.RenderOpen())
            {
                foreach (var pair in nh.nodeHighlights)
                {
                    // TODO: Make more elegant? Needs profiling.
                    HighlightState hs = pair.Value;

                    if (hs != HighlightState.Crossed)
                    {
                        byte red   = (byte)(hs.HasFlag(HighlightState.FromSearch) ? 255 : 0);
                        byte green = (byte)(hs.HasFlag(HighlightState.FromAttrib) ? 255 : 0);
                        byte blue  = (byte)(hs.HasFlag(HighlightState.FromNode) ? 255 : 0);
                        hpen = new Pen(new SolidColorBrush(Color.FromRgb(red, green, blue)), 20);

                        dc.DrawEllipse(null, hpen, pair.Key.Position, 80, 80);
                    }

                    if (hs.HasFlag(HighlightState.Crossed))
                    {
                        // Crossed nodes get highlighted with two crossing lines.
                        var x = pair.Key.Position.X;
                        var y = pair.Key.Position.Y;
                        dc.DrawLine(crossPen, new Point(x + 50, y + 70), new Point(x - 50, y - 70));
                        dc.DrawLine(crossPen, new Point(x + 50, y - 70), new Point(x - 50, y + 70));
                    }
                }
            }
        }
Exemple #2
0
        public void DrawHighlights()
        {
            var nh       = _nodeHighlighter;
            var crossPen = new Pen(Brushes.Red, 20);
            var checkPen = new Pen(Brushes.Lime, 20);

            using (DrawingContext dc = picHighlights.RenderOpen())
            {
                foreach (var pair in nh.nodeHighlights)
                {
                    // TODO: Make more elegant? Needs profiling.
                    HighlightState hs = pair.Value;

                    // These should not appear together, so not checking for their conjunction.
                    if (hs != HighlightState.Crossed && hs != HighlightState.Checked)
                    {
                        Pen hpen;

                        // If it has FromHover, don't mix it with the other highlights.
                        if (hs.HasFlag(HighlightState.FromHover))
                        {
                            hpen = new Pen(Brushes.DodgerBlue, 20);
                        }
                        else
                        {
                            byte red   = (byte)(hs.HasFlag(HighlightState.FromSearch) ? 255 : 0);
                            byte green = (byte)(hs.HasFlag(HighlightState.FromAttrib) ? 255 : 0);
                            hpen = new Pen(new SolidColorBrush(Color.FromRgb(red, green, 0)), 20);
                        }

                        dc.DrawEllipse(null, hpen, pair.Key.Position, 80, 80);
                    }

                    var x = pair.Key.Position.X;
                    var y = pair.Key.Position.Y;

                    if (hs.HasFlag(HighlightState.Checked))
                    {
                        // Checked nodes get highlighted with two green lines resembling a check mark.
                        // TODO a better looking check mark
                        dc.DrawLine(checkPen, new Point(x - 10, y + 50), new Point(x - 50, y + 20));
                        dc.DrawLine(checkPen, new Point(x + 50, y - 50), new Point(x - 22, y + 52));
                    }

                    if (hs.HasFlag(HighlightState.Crossed))
                    {
                        // Crossed nodes get highlighted with two crossing red lines.
                        dc.DrawLine(crossPen, new Point(x + 50, y + 70), new Point(x - 50, y - 70));
                        dc.DrawLine(crossPen, new Point(x + 50, y - 70), new Point(x - 50, y + 70));
                    }
                }
            }
        }
Exemple #3
0
        public void DrawHighlights(NodeHighlighter nh)
        {
            var hpen = new Pen(Brushes.White, 20);

            using (DrawingContext dc = picHighlights.RenderOpen())
            {
                foreach (var pair in nh.nodeHighlights)
                {
                    // TODO: Make more elegant? Needs profiling.
                    HighlightState hs    = pair.Value;
                    byte           red   = (byte)(hs.HasFlag(HighlightState.FromSearch) ? 255 : 0);
                    byte           green = (byte)(hs.HasFlag(HighlightState.FromAttrib) ? 255 : 0);
                    byte           blue  = (byte)(hs.HasFlag(HighlightState.FromNode) ? 255 : 0);
                    hpen = new Pen(new SolidColorBrush(Color.FromRgb(red, green, blue)), 20);

                    dc.DrawEllipse(null, hpen, pair.Key.Position, 80, 80);
                }
            }
        }
Exemple #4
0
        /// <param name="search">The string to search each node name and attribute for.</param>
        /// <param name="useregex">If the string should be interpreted as a regex.</param>
        /// <param name="flag">The flag to highlight found nodes with.</param>
        /// <param name="matchCount">The number of attributes of a node that must match the search to get highlighted, -1 if the count doesn't matter.</param>
        public void HighlightNodesBySearch(string search, bool useregex, HighlightState flag, int matchCount = -1)
        {
            if (search == "")
            {
                _nodeHighlighter.UnhighlightAllNodes(flag);
                DrawHighlights(_nodeHighlighter);
                return;
            }

            var matchFct = matchCount >= 0 ? (Func <string[], Func <string, bool>, bool>)
                               ((attributes, predicate) => attributes.Count(predicate) == matchCount)
                : (attributes, predicate) => attributes.Any(predicate);

            if (useregex)
            {
                try
                {
                    var regex = new Regex(search, RegexOptions.IgnoreCase);
                    var nodes =
                        Skillnodes.Values.Where(
                            nd => matchFct(nd.attributes, att => regex.IsMatch(att)) ||
                            regex.IsMatch(nd.Name) && !nd.IsMastery);
                    _nodeHighlighter.ReplaceHighlights(nodes, flag);
                    DrawHighlights(_nodeHighlighter);
                }
                catch (Exception)
                {
                    // ?
                }
            }
            else
            {
                search = search.ToLowerInvariant();
                var nodes =
                    Skillnodes.Values.Where(
                        nd => matchFct(nd.attributes, att => att.ToLowerInvariant().Contains(search)) ||
                        nd.Name.ToLowerInvariant().Contains(search) && !nd.IsMastery);
                _nodeHighlighter.ReplaceHighlights(nodes, flag);
                DrawHighlights(_nodeHighlighter);
            }
        }
Exemple #5
0
        public void HighlightNodesBySearch(string search, bool useregex, bool fromSearchBox)
        {
            HighlightState flag = fromSearchBox ? HighlightState.FromSearch : HighlightState.FromAttrib;

            if (search == "")
            {
                _nodeHighlighter.UnhighlightAllNodes(flag);
                DrawHighlights(_nodeHighlighter);
                return;
            }

            if (useregex)
            {
                try
                {
                    List <SkillNode> nodes =
                        Skillnodes.Values.Where(
                            nd =>
                            nd.attributes.Any(att => new Regex(search, RegexOptions.IgnoreCase).IsMatch(att)) ||
                            new Regex(search, RegexOptions.IgnoreCase).IsMatch(nd.Name) && !nd.IsMastery)
                        .ToList();
                    _nodeHighlighter.ReplaceHighlights(nodes, flag);
                    DrawHighlights(_nodeHighlighter);
                }
                catch (Exception)
                {
                    Debugger.Break();
                    // ?
                }
            }
            else
            {
                List <SkillNode> nodes =
                    Skillnodes.Values.Where(
                        nd =>
                        nd.attributes.Count(att => att.ToLower().Contains(search.ToLower())) != 0 ||
                        nd.Name.ToLower().Contains(search.ToLower()) && !nd.IsMastery).ToList();
                _nodeHighlighter.ReplaceHighlights(nodes, flag);
                DrawHighlights(_nodeHighlighter);
            }
        }
        /// <param name="search">The string to search each node name and attribute for.</param>
        /// <param name="useregex">If the string should be interpreted as a regex.</param>
        /// <param name="flag">The flag to highlight found nodes with.</param>
        /// <param name="matchCount">The number of attributes of a node that must match the search to get highlighted, -1 if the count doesn't matter.</param>
        public void HighlightNodesBySearch(string search, bool useregex, HighlightState flag, int matchCount = -1)
        {
            if (search == "")
            {
                _nodeHighlighter.UnhighlightAllNodes(flag);
                DrawHighlights();
                return;
            }

            var matchFct = matchCount >= 0 ? (Func<string[], Func<string, bool>, bool>)
                 ((attributes, predicate) => attributes.Count(predicate) == matchCount)
                : (attributes, predicate) => attributes.Any(predicate);
            if (useregex)
            {
                try
                {
                    var regex = new Regex(search, RegexOptions.IgnoreCase);
                    var nodes =
                        Skillnodes.Values.Where(
                            nd => matchFct(nd.attributes, att => regex.IsMatch(att)) ||
                                  regex.IsMatch(nd.Name) && !nd.IsMastery);
                    _nodeHighlighter.ReplaceHighlights(nodes, flag);
                    DrawHighlights();
                }
                catch (Exception)
                {
                    // ?
                }
            }
            else
            {
                search = search.ToLowerInvariant();
                var nodes =
                    Skillnodes.Values.Where(
                        nd => matchFct(nd.attributes, att => att.ToLowerInvariant().Contains(search)) ||
                              nd.Name.ToLowerInvariant().Contains(search) && !nd.IsMastery);
                _nodeHighlighter.ReplaceHighlights(nodes, flag);
                DrawHighlights();
            }
        }
Exemple #7
0
        /// <param name="search">The string to search each node name and attribute for.</param>
        /// <param name="useregex">If the string should be interpreted as a regex.</param>
        /// <param name="flag">The flag to highlight found nodes with.</param>
        /// <param name="matchCount">The number of attributes of a node that must match the search to get highlighted, -1 if the count doesn't matter.</param>
        public void HighlightNodesBySearch(string search, bool useregex, HighlightState flag, int matchCount = -1)
        {
            if (search == "")
            {
                _nodeHighlighter.UnhighlightAllNodes(flag);
                DrawHighlights();
                return;
            }

            var matchFct = matchCount >= 0 ? (Func<string[], Func<string, bool>, bool>)
                 ((attributes, predicate) => attributes.Count(predicate) == matchCount)
                : (attributes, predicate) => attributes.Any(predicate);
            if (useregex)
            {
                try
                {
                    var regex = new Regex(search, RegexOptions.IgnoreCase);
                    var nodes =
                        Skillnodes.Values.Where(
                            nd => (matchFct(nd.attributes, att => regex.IsMatch(att)) ||
                                  regex.IsMatch(nd.Name) && nd.Type != NodeType.Mastery) &&
                                  (DrawAscendancy ? (_persistentData.Options.ShowAllAscendancyClasses || (nd.ascendancyName == GetAscendancyClass(SkilledNodes) || nd.ascendancyName == null)) : nd.ascendancyName == null));
                    _nodeHighlighter.ResetHighlights(nodes, flag);
                    DrawHighlights();
                }
                catch (Exception)
                {
                    // ?
                }
            }
            else
            {
                search = search.ToLowerInvariant();
                var nodes =
                    Skillnodes.Values.Where(
                        nd => (matchFct(nd.attributes, att => att.ToLowerInvariant().Contains(search)) ||
                              nd.Name.ToLowerInvariant().Contains(search) && nd.Type != NodeType.Mastery) &&
                              (DrawAscendancy ? (_persistentData.Options.ShowAllAscendancyClasses || (nd.ascendancyName == GetAscendancyClass(SkilledNodes) || nd.ascendancyName == null)) : nd.ascendancyName == null));
                _nodeHighlighter.ResetHighlights(nodes, flag);
                DrawHighlights();
            }
        }
        public void DrawHighlights()
        {
            var nh       = _nodeHighlighter;
            var crossPen = new Pen(Brushes.Red, 20);
            var checkPen = new Pen(Brushes.Lime, 20);

            using (DrawingContext dc = picHighlights.RenderOpen())
            {
                foreach (var pair in nh.nodeHighlights)
                {
                    // TODO: Make more elegant? Needs profiling.
                    HighlightState hs = pair.Value;

                    // These should not appear together, so not checking for their conjunction.
                    if (hs != HighlightState.Crossed && hs != HighlightState.Checked)
                    {
                        Pen hpen;

                        // If it has FromHover, don't mix it with the other highlights.
                        if (hs.HasFlag(HighlightState.FromHover))
                        {
                            var brushColor = (Brush) new BrushConverter().ConvertFromString(_persistentData.Options.NodeHoverHighlightColor);
                            hpen = new Pen(brushColor, 20);
                        }
                        else
                        {
                            int red   = 0;
                            int green = 0;
                            int blue  = 0;
                            System.Drawing.Color attrHighlight   = System.Drawing.Color.FromName(_persistentData.Options.NodeAttrHighlightColor);
                            System.Drawing.Color searchHighlight = System.Drawing.Color.FromName(_persistentData.Options.NodeSearchHighlightColor);

                            if (hs.HasFlag(HighlightState.FromAttrib))
                            {
                                red   = (red | attrHighlight.R);
                                green = (green | attrHighlight.G);
                                blue  = (blue | attrHighlight.B);
                            }
                            if (hs.HasFlag(HighlightState.FromSearch))
                            {
                                red   = (red | searchHighlight.R);
                                green = (green | searchHighlight.G);
                                blue  = (blue | searchHighlight.B);
                            }
                            hpen = new Pen(new SolidColorBrush(Color.FromRgb((byte)red, (byte)green, (byte)blue)), 20);
                        }

                        dc.DrawEllipse(null, hpen, pair.Key.Position, 80, 80);
                    }

                    var x = pair.Key.Position.X;
                    var y = pair.Key.Position.Y;

                    if (hs.HasFlag(HighlightState.Checked))
                    {
                        // Checked nodes get highlighted with two green lines resembling a check mark.
                        // TODO a better looking check mark
                        dc.DrawLine(checkPen, new Point(x - 10, y + 50), new Point(x - 50, y + 20));
                        dc.DrawLine(checkPen, new Point(x + 50, y - 50), new Point(x - 22, y + 52));
                    }

                    if (hs.HasFlag(HighlightState.Crossed))
                    {
                        // Crossed nodes get highlighted with two crossing red lines.
                        dc.DrawLine(crossPen, new Point(x + 50, y + 70), new Point(x - 50, y - 70));
                        dc.DrawLine(crossPen, new Point(x + 50, y - 70), new Point(x - 50, y + 70));
                    }
                }
            }
        }