Пример #1
0
        static void OnIndicatorsChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            PriceChartElement thisPriceChartElement = obj as PriceChartElement;

            if (thisPriceChartElement == null)
            {
                return;
            }

            ObservableCollection <OverlayIndicator> old_obsCollection = e.OldValue as ObservableCollection <OverlayIndicator>;

            if (old_obsCollection != null)
            {
                old_obsCollection.CollectionChanged -= thisPriceChartElement.OnIndicatorsCollectionChanged;

                foreach (OverlayIndicator indicator in old_obsCollection)
                {
                    indicator.PropertyChanged -= thisPriceChartElement.OnIndicatorsCollectionItemChanged;
                }
            }

            ObservableCollection <OverlayIndicator> new_obsCollection = e.NewValue as ObservableCollection <OverlayIndicator>;

            if (new_obsCollection != null)
            {
                new_obsCollection.CollectionChanged += thisPriceChartElement.OnIndicatorsCollectionChanged;

                foreach (OverlayIndicator indicator in new_obsCollection)
                {
                    indicator.PropertyChanged += thisPriceChartElement.OnIndicatorsCollectionItemChanged;
                }
            }
        }
Пример #2
0
        private static object CoerceBearishCandleStroke(DependencyObject objWithOldDP, object newDPValue)
        {
            PriceChartElement thisElement   = (PriceChartElement)objWithOldDP;
            Brush             newBrushValue = (Brush)newDPValue;

            if (newBrushValue.IsFrozen)
            {
                Pen p = new Pen(newBrushValue, 1.0);
                p.Freeze();
                thisElement.bearishCandleStrokePen = p;
                return(newDPValue);
            }
            else
            {
                Brush b = (Brush)newBrushValue.GetCurrentValueAsFrozen();
                Pen   p = new Pen(b, 1.0);
                p.Freeze();
                thisElement.bearishCandleStrokePen = p;
                return(b);
            }
        }