예제 #1
0
        private void AddFractal(int currentIndex)
        {
            int size = 20;

            var qqq = Fractals.Calculate(candlesList, currentIndex);

            if (qqq.Item1)
            {
                CustomAnnotation annotation = null;

                if (qqq.Item2 == Fractals.Type.Top)
                {
                    var         uri = new Uri(AppDomain.CurrentDomain.BaseDirectory + "up.png", UriKind.RelativeOrAbsolute);
                    BitmapImage bi  = new BitmapImage();
                    bi.BeginInit();
                    bi.UriSource = uri;
                    bi.EndInit();

                    Image arrow = new Image()
                    {
                        Source = bi,
                        Width  = size,
                        Height = size
                    };
                    annotation = new CustomAnnotation()
                    {
                        X1                    = currentIndex,
                        Y1                    = candlesList[currentIndex].High,
                        Content               = arrow,
                        ContentTemplate       = (DataTemplate)sciChart.Resources["AnnotationTemplate"],
                        VerticalAnchorPoint   = VerticalAnchorPoint.Bottom,
                        HorizontalAnchorPoint = HorizontalAnchorPoint.Center
                    };
                }
                else if (qqq.Item2 == Fractals.Type.Bottom)
                {
                    var         uri = new Uri(AppDomain.CurrentDomain.BaseDirectory + "down.png", UriKind.RelativeOrAbsolute);
                    BitmapImage bi  = new BitmapImage();
                    bi.BeginInit();
                    bi.UriSource = uri;
                    bi.EndInit();
                    Image arrow = new Image()
                    {
                        Source = bi,
                        Width  = size,
                        Height = size
                    };
                    annotation = new CustomAnnotation()
                    {
                        X1                    = currentIndex,
                        Y1                    = candlesList[currentIndex].Low,
                        Content               = arrow,
                        ContentTemplate       = (DataTemplate)sciChart.Resources["AnnotationTemplate"],
                        VerticalAnchorPoint   = VerticalAnchorPoint.Top,
                        HorizontalAnchorPoint = HorizontalAnchorPoint.Center
                    };
                }
                sciChart.Annotations.Add(annotation);
            }
        }