示例#1
0
 public EventArg(AverageLine timeline, Line line)
 {
     if (timeline != null)
     {
         ID          = timeline.ID;
         Score       = timeline.Score;
         Type        = timeline.Type;
         Value       = timeline.Value;
         UpperBorder = timeline.UpperBorder;
         LowerBorder = timeline.LowerBorder;
     }
     Line = line;
 }
示例#2
0
        public static List <AverageLine> Merge(List <AverageLine> lines)
        {
            var list = new List <AverageLine>();

            if (lines != null && lines.Count > 0)
            {
                if (lines.Count == 1)
                {
                    list.Add(lines[0]);
                }
                else
                {
                    AverageLine line1 = null;
                    AverageLine line2 = null;
                    do
                    {
                        if (line1 == null)
                        {
                            line1 = lines[0];
                            lines.RemoveAt(0);
                        }
                        if (line2 == null)
                        {
                            line2 = lines[0];
                            lines.RemoveAt(0);
                        }

                        if (Overlapped(line1, line2))
                        {
                            line1 = (line1.ID > line2.ID) ? line1 : line2;
                        }
                        else
                        {
                            list.Add(line1);
                            line1 = line2;
                        }
                        line2 = null;
                    } while (lines.Count > 0);

                    if (line1 != null)
                    {
                        list.Add(line1);
                    }
                }
            }
            return(list);
        }
示例#3
0
        public static bool Overlapped(AverageLine line1, AverageLine line2)
        {
            if (line1 == null || line2 == null)
            {
                return(false);
            }
            if (line1.Value == line2.Value)
            {
                return(true);
            }

            AverageLine upper = null;
            AverageLine lower = null;

            if (line1.Value > line2.Value)
            {
                upper = line1;
                lower = line2;
            }
            else
            {
                upper = line2;
                lower = line1;
            }

            var overlap = lower.UpperBorder - upper.LowerBorder;

            if (overlap <= decimal.Zero)
            {
                return(false);
            }

            var max = Math.Max(upper.UpperBorder, lower.UpperBorder);
            var min = Math.Min(upper.LowerBorder, lower.LowerBorder);
            var cap = max - min;

            if (cap == decimal.Zero)
            {
                return(false);
            }

            var proportion = Math.Round((overlap / cap), 3);

            return(proportion >= 0.618m);
        }