Example #1
0
        public bool OnSizeChange(KeyDate key, double x, double y)
        {
            if (lines.ContainsKey(key))
            {
                lines[key].X1 = x;
                lines[key].Y1 = y;
                if (key == lines.Head)
                {
                    lines[key].X2 = x;
                    lines[key].Y2 = y;
                }

                if (!lines.IsTail(key))
                {
                    lines[lines.GetPrevius(key)].X2 = x;
                    lines[lines.GetPrevius(key)].Y2 = y;
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        public void UpdateHead(double y, double pxShifted, double x0, KeyDate left, KeyDate right)
        {
            if (!lines.IsHead(HeadKey))
            {
                if (HeadKey < left)
                {
                    lines[HeadKey].X2 = x0 + DistanseX(left, lines.GetNext(HeadKey)) * pxShifted;
                }
                else if (HeadKey > right)
                {
                    lines[lines.GetPrevius(HeadKey)].X2 = x0 + DistanseX(left, HeadKey) * pxShifted;
                    lines[lines.GetPrevius(HeadKey)].Y2 = y;
                }
                else
                {
                    lines[HeadKey].X2 = lines[HeadKey].X1 + DistanseX(HeadKey, lines.GetNext(HeadKey)) * pxShifted;
                }

                lines[HeadKey].Y2 = y;
            }
            else
            {
                lines[lines.GetPrevius(HeadKey)].X2 = x0 + DistanseX(left, HeadKey) * pxShifted;
                lines[lines.GetPrevius(HeadKey)].Y2 = y;
            }
        }
Example #3
0
        public void GetLine(string key, bool moveForward, Canvas canvas)
        {
            KeyDate Key = new KeyDate(key);

            if (moveForward)
            {
                HeadKey = Key;
                if (!canvas.Children.Contains(lines[Key]))
                {
                    canvas.Children.Add(lines[Key]);
                    GetNewSize = true;
                }
            }
            else
            {
                if (Key != lines.Tail)
                {
                    TailKey = lines.GetPrevius(Key);
                    canvas.Children.Add(lines[TailKey]);
                    GetNewSize = true;
                }
                else
                {
                    TailKey = Key;
                }
            }
        }
Example #4
0
        public void OutOfRange(string key, bool moveForward, Canvas canvas)
        {
            KeyDate Key = new KeyDate(key);

            if (moveForward)
            {
                TailKey = Key;
                if (!lines.IsTail(Key))
                {
                    canvas.Children.Remove(lines[lines.GetPrevius(Key)]);
                    GetNewSize = true;
                }
            }
            else
            {
                if (lines.IsTail(Key))
                {
                    HeadKey = Key;
                }
                else
                {
                    HeadKey = lines.GetPrevius(Key);
                }

                canvas.Children.Remove(lines[Key]);
                GetNewSize = true;
            }
        }
Example #5
0
 private bool LessThan(KeyDate toCompere)
 {
     if (Year == toCompere.Year)
     {
         if (Month == toCompere.Month)
         {
             if (Day < toCompere.Day)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         else if (Month < toCompere.Month)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else if (Year < toCompere.Year)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #6
0
        private int DistanseX(KeyDate date1, KeyDate date2)
        {
            DateTime dt1 = new DateTime(date1.Year, date1.Month, date1.Day);
            DateTime dt2 = new DateTime(date2.Year, date2.Month, date2.Day);

            return((dt2 - dt1).Days);
        }
Example #7
0
 private bool MoreThan(KeyDate toCompere)
 {
     if (Year == toCompere.Year)
     {
         if (Month == toCompere.Month)
         {
             if (Day > toCompere.Day)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         else if (Month > toCompere.Month)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else if (Year > toCompere.Year)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #8
0
 public bool DrawTail(KeyDate left, out Line tail)
 {
     if (TailKey != null && TailKey < left)
     {
         tail       = lines[TailKey];
         GetNewSize = true;
         return(true);
     }
     tail = null;
     return(false);
 }
Example #9
0
 public KeyDate GetNext(KeyDate key)
 {
     if (!lines.IsHead(key))
     {
         return(lines.GetNext(key));
     }
     else
     {
         return(key);
     }
 }
Example #10
0
        public string GetNext(string key)
        {
            KeyDate Key = new KeyDate(key);

            if (!lines.IsHead(Key))
            {
                return(lines.GetNext(Key).ToString());
            }
            else
            {
                return(key);
            }
        }
Example #11
0
 public bool TailNeedUpdate(out string key, KeyDate left)
 {
     key = string.Empty;
     if (Initialized)
     {
         if (lines.Tail < left && lines.Head >= left)
         {
             key = TailKey.ToString();
             return(true);
         }
     }
     return(false);
 }
Example #12
0
        private bool FindPoint(KeyDate key, KeyDate next, Line line)
        {
            if (key > next)
            {
                if (key < lines.GetNext(next))
                {
                    lines.InsertFront(next, key, line);

                    lines[key].X2 = lines[lines.GetNext(key)].X1;
                    lines[key].Y2 = lines[lines.GetNext(key)].Y1;

                    return(true);
                }
            }

            return(false);
        }
Example #13
0
        public override bool Equals(object obj)
        {
            if (this as object == null && obj == null)
            {
                return(true);
            }
            else if (obj == null)
            {
                return(false);
            }
            else if (this as object == null)
            {
                return(false);
            }

            KeyDate Obj = obj as KeyDate;

            return(Day == Obj.Day && Month == Obj.Month && Year == Obj.Year);
        }
Example #14
0
        public bool HeadNeedUpdate(out string key, KeyDate right)
        {
            key = string.Empty;
            if (Initialized)
            {
                if (lines.Head > right && lines.Tail <= right)
                {
                    if (lines.IsHead(HeadKey) || HeadKey > right)
                    {
                        key = HeadKey.ToString();
                    }
                    else
                    {
                        key = lines.GetNext(HeadKey).ToString();
                    }

                    return(true);
                }
            }
            return(false);
        }
Example #15
0
        public void OnSizeChange(string key, double x, double y)
        {
            if (Initialized)
            {
                KeyDate Key = new KeyDate(key);

                if (lines.ContainsKey(Key))
                {
                    lines[Key].X1 = x;
                    lines[Key].Y1 = y;
                    if (Key == lines.Head)
                    {
                        lines[Key].X2 = x;
                        lines[Key].Y2 = y;
                    }

                    if (!lines.IsTail(Key))
                    {
                        lines[lines.GetPrevius(Key)].X2 = x;
                        lines[lines.GetPrevius(Key)].Y2 = y;
                    }
                }
            }
        }
Example #16
0
        public void Add(string key, KeyDate left, KeyDate right, Canvas canvas)
        {
            KeyDate Key = new KeyDate(key);

            if (!lines.ContainsKey(Key))
            {
                Line line = new Line
                {
                    StrokeThickness = this.StrokeThickness,
                    //Stroke = Brushes.Blue
                    Stroke = lineColur
                };

                if (lines.Initialized)
                {
                    if (Key < lines.Tail)
                    {
                        lines.InsertTail(Key, line);

                        lines[Key].X2 = lines[lines.GetNext(Key)].X1;
                        lines[Key].Y2 = lines[lines.GetNext(Key)].Y1;
                    }
                    else if (Key > lines.Head)
                    {
                        lines.InsertHead(Key, line);
                    }
                    else
                    {
                        KeyDate next = lines.Tail;
                        while (!FindPoint(Key, next, line))
                        {
                            next = lines.GetNext(next);
                        }
                    }

                    if (Key < left)
                    {
                        if (Key > TailKey)
                        {
                            canvas.Children.Remove(lines[TailKey]);
                            TailKey = Key;
                            canvas.Children.Add(lines[TailKey]);
                            GetNewSize = true;
                        }
                        else if (left < TailKey)
                        {
                            TailKey = Key;
                            canvas.Children.Add(lines[TailKey]);
                            GetNewSize = true;
                        }
                        if (Key > HeadKey)
                        {
                            HeadKey = Key;
                        }
                    }
                    else if (Key > right)
                    {
                        if (Key < TailKey)
                        {
                            TailKey = Key;
                        }
                        if (Key < HeadKey)
                        {
                            HeadKey = Key;
                        }
                    }
                }
                else
                {
                    lines.Initialize(Key, line);
                    TailKey     = HeadKey = Key;
                    Initialized = true;
                    GetNewSize  = true;

                    if (Key < left)
                    {
                        canvas.Children.Add(lines[Key]);
                    }
                }
            }
        }
Example #17
0
        public void Add(string key, KeyDate right, double x, double y, Canvas canvas)
        {
            KeyDate Key = new KeyDate(key);

            if (!OnSizeChange(Key, x, y))
            {
                Line line = new Line
                {
                    StrokeThickness = this.StrokeThickness,
                    Stroke          = lineColur,
                    //Stroke = Brushes.Blue,

                    X1 = x,
                    Y1 = y,
                    X2 = x,
                    Y2 = y
                };

                if (lines.Initialized)
                {
                    if (Key < lines.Tail)
                    {
                        lines.InsertTail(Key, line);
                        TailKey = Key;

                        lines[Key].X2 = lines[lines.GetNext(Key)].X1;
                        lines[Key].Y2 = lines[lines.GetNext(Key)].Y1;
                    }
                    else if (Key > lines.Head)
                    {
                        lines.InsertHead(Key, line);
                        HeadKey = Key;
                    }
                    else
                    {
                        KeyDate next = lines.Tail;
                        while (!FindPoint(Key, next, line))
                        {
                            next = lines.GetNext(next);
                        }

                        if (Key > HeadKey)
                        {
                            HeadKey = Key;
                        }
                    }

                    if (right < HeadKey)
                    {
                        if (canvas.Children.Contains(lines[HeadKey]))
                        {
                            canvas.Children.Remove(lines[HeadKey]);
                        }
                        HeadKey = Key;
                    }

                    if (!lines.IsTail(Key))
                    {
                        lines[lines.GetPrevius(Key)].X2 = x;
                        lines[lines.GetPrevius(Key)].Y2 = y;
                    }
                }
                else
                {
                    lines.Initialize(Key, line);
                    TailKey = HeadKey = Key;

                    Initialized = true;
                }

                if (!canvas.Children.Contains(lines[Key]))
                {
                    canvas.Children.Add(lines[Key]);
                }
            }
            GetNewSize = true;
        }
Example #18
0
        public Line GetLine(string key)
        {
            KeyDate Key = new KeyDate(key);

            return(lines[Key]);
        }