示例#1
0
        private void UpdateUIResources()
        {
            ResourceDictionary resources = new ResourceDictionary
            {
                Source = new Uri("/SS2Widget;component/Charts/Axes/AxisControlStyle.xaml", UriKind.Relative)
            };

            AxisPlacement   placement = GetBetterPlacement(this.placement);
            ControlTemplate template  = (ControlTemplate)resources[templateKey + placement.ToString()];

            Verify.AssertNotNull(template);
            var content = (FrameworkElement)template.LoadContent();

            ticksPath = (Path)content.FindName(PART_TicksPath);
            ticksPath.SnapsToDevicePixels = true;
            Verify.AssertNotNull(ticksPath);

            commonLabelsCanvas = (StackCanvas)content.FindName(PART_CommonLabelsCanvas);
            Verify.AssertNotNull(commonLabelsCanvas);
            commonLabelsCanvas.Placement = placement;

            additionalLabelsCanvas = (StackCanvas)content.FindName(PART_AdditionalLabelsCanvas);
            Verify.AssertNotNull(additionalLabelsCanvas);
            additionalLabelsCanvas.Placement = placement;

            mainGrid = (Grid)content.FindName(PART_ContentsGrid);
            Verify.AssertNotNull(mainGrid);

            mainGrid.SetBinding(Control.BackgroundProperty, new Binding {
                Path = new PropertyPath("Background"), Source = this
            });

            Content = mainGrid;

            string transformKey = additionalLabelTransformKey + placement.ToString();

            if (resources.Contains(transformKey))
            {
                additionalLabelTransform = (Transform)resources[transformKey];
            }
        }
示例#2
0
        private void UpdateUIResources()
        {
            ResourceDictionary resources = new ResourceDictionary
            {
                Source = new Uri("/DynamicDataDisplay;component/Charts/Axes/AxisControlStyle.xaml", UriKind.Relative)
            };

            AxisPlacement   placement = GetBetterPlacement(this.placement);
            ControlTemplate template  = (ControlTemplate)resources[templateKey + placement.ToString()];

            Verify.AssertNotNull(template);
            var content = (FrameworkElement)template.LoadContent();

            if (ticksPath != null && ticksPath.Data != null)
            {
                GeometryGroup group = (GeometryGroup)ticksPath.Data;
                foreach (var child in group.Children)
                {
                    LineGeometry geometry = (LineGeometry)child;
                    lineGeomPool.Put(geometry);
                }
                group.Children.Clear();
            }

            ticksPath = (Path)content.FindName(PART_TicksPath);
            ticksPath.SnapsToDevicePixels = true;
            Verify.AssertNotNull(ticksPath);

            // as this method can be called not only on loading of axisControl, but when its placement changes, internal panels
            // can be not empty and their contents should be released
            if (commonLabelsCanvas != null && labelProvider != null)
            {
                foreach (UIElement child in commonLabelsCanvas.Children)
                {
                    if (child != null)
                    {
                        labelProvider.ReleaseLabel(child);
                    }
                }

                labels = null;
                commonLabelsCanvas.Children.Clear();
            }

            commonLabelsCanvas = (StackCanvas)content.FindName(PART_CommonLabelsCanvas);
            Verify.AssertNotNull(commonLabelsCanvas);
            commonLabelsCanvas.Placement = placement;

            if (additionalLabelsCanvas != null && majorLabelProvider != null)
            {
                foreach (UIElement child in additionalLabelsCanvas.Children)
                {
                    if (child != null)
                    {
                        majorLabelProvider.ReleaseLabel(child);
                    }
                }
            }

            additionalLabelsCanvas = (StackCanvas)content.FindName(PART_AdditionalLabelsCanvas);
            Verify.AssertNotNull(additionalLabelsCanvas);
            additionalLabelsCanvas.Placement = placement;

            mainGrid = (Grid)content.FindName(PART_ContentsGrid);
            Verify.AssertNotNull(mainGrid);

            mainGrid.SetBinding(Control.BackgroundProperty, new Binding {
                Path = new PropertyPath("Background"), Source = this
            });
            mainGrid.SizeChanged += new SizeChangedEventHandler(mainGrid_SizeChanged);

            Content = mainGrid;

            string transformKey = additionalLabelTransformKey + placement.ToString();

            if (resources.Contains(transformKey))
            {
                additionalLabelTransform = (Transform)resources[transformKey];
            }
        }