예제 #1
0
        private void AllowXamlEditing_Changed(object sender, RoutedEventArgs e)
        {
            bool allowXamlEditing = AllowXamlEditing.IsChecked();

            ChartXamlTextBox.IsReadOnly = !allowXamlEditing;
            //ChartXamlTextBox.Background = allowXamlEditing ? null : Application.Current.Resources["ReadOnlyTextBoxBackground"] as Brush;
            foreach (
                Control control in
                new Control[]
            {
                ChartTitle, LegendTitle, RecreateChart, NumberOfSeries, SeriesSettingsContainer, NumberOfAxes,
                AxisSettingsContainer
            })
            {
                control.IsEnabled = !allowXamlEditing;
            }
            if (allowXamlEditing)
            {
                ChartXamlTextBox_TextChanged(null, null);
            }
            else
            {
                CreateNewChart();
            }
        }
예제 #2
0
 private void ChartXamlTextBox_TextChanged(object sender, TextChangedEventArgs e)
 {
     if (AllowXamlEditing.IsChecked())
     {
         CallAndReportExceptions(() => { CreateChartFromXaml(ChartXamlTextBox.Text); });
     }
 }
예제 #3
0
        private void CreateChartFromXaml(string xaml)
        {
            ChartDisplayPanel.Children.Clear();
#if SILVERLIGHT
            var panel = XamlReader.Load(xaml) as Panel;
#else
            Panel panel;
            using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(xaml)))
            {
                panel = XamlReader.Load(stream) as Panel;
            }
#endif
            if (AllowXamlEditing.IsChecked())
            {
                Chart = null;
            }
            else
            {
                Chart = panel.Children[0] as Chart;
                for (int i = 0; i < Chart.Series.Count; i++)
                {
                    var series = Chart.Series[i] as DataPointSeries;
                    _seriesSettingsCollection[i].Series = null;
                    _seriesSettingsCollection[i].Series = series;
                }
                for (int i = 0; i < Chart.Axes.Count; i++)
                {
                    var axis = Chart.Axes[i] as DisplayAxis;
                    _axisSettingsCollection[i].Axis = axis;
                }
            }
            ChartDisplayPanel.Children.Add(panel);
        }