/*--------------------------------------------------------------------------------------------*/
        protected virtual void AddLatestHighlightsAndFindNearest()
        {
            float minDist = float.MaxValue;
            List <ICursorData> cursors = CursorDataProvider.Cursors;
            int cursorCount            = cursors.Count;

            for (int i = 0; i < cursorCount; i++)
            {
                ICursorData cursor = cursors[i];

                if (!cursor.CanCauseSelections)
                {
                    continue;
                }

                Highlight high = CalculateHighlight(cursor);
                high.IsNearestAcrossAllItems = vIsNearestForCursorTypeMap.Contains(cursor.Type);
                Highlights.Add(high);

                if (high.Distance >= minDist)
                {
                    continue;
                }

                minDist          = high.Distance;
                NearestHighlight = high;
            }

            IsNearestAcrossAllItemsForAnyCursor = (vIsNearestForCursorTypeMap.Count > 0);
        }
Exemple #2
0
        private void AddHighlightEvent(TouchLocation touch)
        {
            //add a highlight event at that location
            var coord = ConvertCoordinate(touch.Position);

            Highlights.Add(new HighlightEventArgs(coord, this));
        }
        /*--------------------------------------------------------------------------------------------*/
        private void AddLatestHighlightsAndFindNearest()
        {
            float minDist = float.MaxValue;
            List <ICursorData> cursors = CursorDataProvider.Cursors;
            int cursorCount            = cursors.Count;

            for (int i = 0; i < cursorCount; i++)
            {
                ICursorData cursor = cursors[i];

                if (!cursor.CanCauseSelections)
                {
                    continue;
                }

                Highlight high = CalculateHighlight(cursor);
                Highlights.Add(high);

                if (high.Distance >= minDist)
                {
                    continue;
                }

                minDist          = high.Distance;
                NearestHighlight = high;
            }
        }
Exemple #4
0
        private T FindSource(bool randomize)
        {
            if (!randomize && Highlights.Count > 0)
            {
                return(Highlights[0]);
            }

            T source = FindNode(NodeLocation.Random);

            Highlights.Clear();
            Highlights.Add(source);

            return(source);
        }
Exemple #5
0
        public bool ShowAStar()
        {
            // highlight top left node
            T source = FindNode(NodeLocation.TopLeft);

            Highlights.Clear();
            Highlights.Add(source);

            // highlight bottom right node
            T target = FindNode(NodeLocation.BottomRight);

            Highlights.Add(target);

            // find best path from top left to bottom right node
            var aStar = new AStar <T>(Graph);

            aStar.UseWorldDistance = true;
            bool success = aStar.FindBestPath(this, source, target);

            Locations = aStar.Nodes;

            Renderer.InvalidateVisual();
            return(success);
        }
 /// <summary>
 /// Adds an highlight
 /// </summary>
 /// <param name="highlight">Highlight</param>
 public void AddHighlight(String highlight)
 {
     Highlights.Add(highlight);
 }
Exemple #7
0
        private void ParseHintFile(string FileName)
        {
            StreamReader rd = new StreamReader(FileName);

            Position Pos = Position.Nothing;

            Hint      nHint = new Hint();
            SmartWord SW    = new SmartWord();

            string LastParentClass = null;

            while (rd.Peek() > 0)
            {
                string Line = rd.ReadLine().Trim();

                if (Line.Length > 5)
                {
                    if (Line.Substring(0, 3) == "///")
                    {
                        string[] Parts;
                        switch (Pos)
                        {
                        case Position.Nothing:     // first ///
                            nHint        = new Hint();
                            SW           = new SmartWord();
                            nHint.Params = new Dictionary <string, string>();
                            SW.Params    = new Dictionary <string, string>();

                            Parts = Line.Substring(3).Trim().Split(new char[] { ':' }, 2);
                            Color HighColor;

                            nHint.Text = Parts[1].Trim();
                            Pos        = Position.Params;
                            // add to highliting list since we have got function name now

                            SW.Description = nHint.Text;

                            if (Parts[0].Length > "const".Length && Parts[0].Trim().Substring(0, "const".Length) == "const")
                            {
                                nHint.Word = Parts[0].Substring("const".Length).Trim();
                                HighColor  = Color.HotPink;
                                SW.Type    = SmartWord.SWType.Constant;
                            }
                            else if (Parts[0].Length > "class".Length && Parts[0].Trim().Substring(0, "class".Length) == "class")
                            {
                                nHint.Word      = Parts[0].Substring("class".Length).Trim();
                                HighColor       = Color.Orange;
                                SW.Type         = SmartWord.SWType.Class;
                                LastParentClass = nHint.Word;
                            }
                            else if (Parts[0].Length > "static".Length && Parts[0].Trim().Substring(0, "static".Length) == "static")
                            {
                                nHint.Word     = Parts[0].Substring(Parts[0].LastIndexOf(" ")).Trim();
                                HighColor      = Color.Brown;
                                SW.Type        = SmartWord.SWType.StaticMethod;
                                SW.ParentClass = Parts[0].Substring("static".Length, Parts[0].Length - "static".Length - nHint.Word.Length).Trim();
                                for (int i = 0; i < Suggestions.Count; i++)
                                {
                                    if (Suggestions[i].Word == LastParentClass && Suggestions[i].Type == SmartWord.SWType.Class)
                                    {
                                        Suggestions[i].HasStatic = true;
                                    }
                                }
                            }
                            else if (Parts[0].Trim().LastIndexOf(" ") > -1)
                            {
                                HighColor = Color.Red;
                            }
                            else
                            {
                                nHint.Word = Parts[0].Trim();
                                HighColor  = Color.BlueViolet;
                                SW.Type    = SmartWord.SWType.Function;
                            }
                            SW.Word = nHint.Word;


                            Highlights.Add(new SmartSyntax()
                            {
                                Bold = false, Highlight = HighColor, Word = nHint.Word
                            });


                            break;

                        case Position.Params:
                            Parts = Line.Substring(3).Trim().Split(new char[] { ':' }, 2);
                            nHint.Params.Add(Parts[0].Trim(), Parts[1].Trim());
                            SW.Params.Add(Parts[0].Trim(), Parts[1].Trim());
                            break;
                        }
                    }
                    else
                    {
                        if (Pos != Position.Nothing)
                        {
                            Hints.Add(nHint);
                            Pos = Position.Nothing;
                            Suggestions.Add(SW);
                        }
                    }
                }
            }
        }
Exemple #8
0
        public async void LoadHighlights()
        {
            if (!Application.Current.Properties.ContainsKey("EnableHighlights") || (bool)Application.Current.Properties["EnableHighlights"])
            {
                var year = NetworkDatabase.YearList[CurrentYear].year;

                var Thresholds = new Dictionary <string, double>();

                foreach (MiniNetwork n in NetworkDatabase.NetworkList)
                {
                    Thresholds[n.name] = n.model.GetNetworkRatingsThreshold(year);
                }

                HighlightsList.BindingContext = this;

                await Task.Run(async() =>
                {
                    try
                    {
                        await Device.InvokeOnMainThreadAsync(() => HighlightsList.IsVisible = true);

                        var NewShows = NetworkDatabase.NetworkList.SelectMany(x => x.shows).Where(x => x.year == year && x.OldOdds == 0 && x.OldRating == 0).OrderByDescending(x => x.PredictedOdds);

                        foreach (Show s in NewShows)
                        {
                            var prediction = new PredictionContainer(s, s.network, Thresholds[s.network.name]);
                            var highlight  = new ShowHighlights(prediction, 0);
                            await Device.InvokeOnMainThreadAsync(() => Highlights.Add(highlight));
                        }

                        var RenewedOrCanceledShows = NetworkDatabase.NetworkList.SelectMany(x => x.shows).Where(x => x.year == year && (x.Renewed || x.Canceled) && x.FinalPrediction == x.OldOdds).OrderByDescending(x => x.PredictedOdds);

                        foreach (Show s in RenewedOrCanceledShows)
                        {
                            var prediction = new PredictionContainer(s, s.network, Thresholds[s.network.name]);
                            var highlight  = new ShowHighlights(prediction, 1);
                            await Device.InvokeOnMainThreadAsync(() => Highlights.Add(highlight));
                        }

                        var PredictionChanged = NetworkDatabase.NetworkList.SelectMany(x => x.shows).Where(x => x.year == year && x.RenewalStatus == "" && ((int)(x.OldOdds / 0.5) != (int)(x.PredictedOdds / 0.5)) && (x.OldOdds > 0 || x.OldRating > 0)).OrderByDescending(x => x.PredictedOdds);

                        foreach (Show s in PredictionChanged)
                        {
                            var prediction = new PredictionContainer(s, s.network, Thresholds[s.network.name]);
                            var highlight  = new ShowHighlights(prediction, 2);
                            await Device.InvokeOnMainThreadAsync(() => Highlights.Add(highlight));
                        }

                        var UpgradedOrDownGradedShows = NetworkDatabase.NetworkList.SelectMany(x => x.shows).Where(x => !PredictionChanged.Contains(x) && x.year == year && x.RenewalStatus == "" && ((int)(x.OldOdds / 0.2) != (int)(x.PredictedOdds / 0.2)) && (x.OldOdds > 0 || x.OldRating > 0)).OrderByDescending(x => x.PredictedOdds);

                        foreach (Show s in UpgradedOrDownGradedShows)
                        {
                            var prediction = new PredictionContainer(s, s.network, Thresholds[s.network.name]);
                            var highlight  = new ShowHighlights(prediction, 2);
                            await Device.InvokeOnMainThreadAsync(() => Highlights.Add(highlight));
                        }
                    }
                    catch (Exception ex)
                    {
                        string error = ex.ToString();
                    }
                });
            }

            if (NetworkDatabase.YearList[NetworkDatabase.CurrentYear] == NetworkDatabase.MaxYear)
            {
                UnhideHighlights();
            }
        }