Beispiel #1
0
		public void Clear ()
		{
			ResourceDictionary rd = new ResourceDictionary ();
			rd.Add ("key", new object ());
			Assert.AreEqual (1, rd.Count, "Count-1");
			rd.Clear ();
			Assert.AreEqual (0, rd.Count, "Count-2");
		}
Beispiel #2
0
        void Page_Loaded(object sender, RoutedEventArgs e)
        {
            RotateTransform rotateTransform = new RotateTransform();
            rotateTransform.Angle = 0.90;

            _rotateStyle.Setters.Add(new Setter(CategoryAxis.RenderTransformProperty, rotateTransform));

            if (App.Current.Resources.Contains("chartTitle"))
            {
                _chartTitle = App.Current.Resources["chartTitle"].ToString();
                Chart.Title = _chartTitle;
            }
            if (App.Current.Resources.Contains("independentLabel"))
            {
                _independentLabel = App.Current.Resources["independentLabel"].ToString();
            }

            if (App.Current.Resources.Contains("dependentLabel"))
            {
                _dependentLabel = App.Current.Resources["dependentLabel"].ToString();
            }

            if (App.Current.Resources.Contains("chartLineSeries"))
            {
                _chartLineSeries = App.Current.Resources["chartLineSeries"].ToString();
                _chartLineSeries = _chartLineSeries.Replace(Statics.Comma, ",");
            }

            if (App.Current.Resources.Contains("chartType"))
            {
                _chartType = App.Current.Resources["chartType"].ToString();
                List<object> objectList = new List<object>();

                if (ProcessSeriesData(ref objectList, _chartType, _chartLineSeries, ref _failOverMessage))
                {
                    try
                    {
                        switch (_chartType.ToUpper().Replace(" ", ""))
                        {
                            case Statics.Area:
                                foreach (object line in objectList)
                                {
                                    Chart.Series.Add(line as AreaSeries);
                                }
                                break;

                            case Statics.Bar:

                                foreach (object columnSeries in objectList)
                                {
                                    #region REM rotate label candidate
                                    //if (independentValue.GetType() == Type.GetType("System.String"))
                                    //{
                                    //    //Style style = new Style(typeof(CategoryAxis));
                                    //    //RotateTransform rotateTransform = new RotateTransform();
                                    //    //rotateTransform.Angle = 0.90;

                                    //    //style.Setters.Add(new Setter(CategoryAxis.RenderTransformProperty, rotateTransform));

                                    //    //((ColumnSeries)series).IndependentAxis = new CategoryAxis
                                    //    //{
                                    //    //    Title = _independentLabel,
                                    //    //    Orientation = AxisOrientation.X,
                                    //    //    AxisLabelStyle = _rotateStyle
                                    //    //};

                                    //    ((ColumnSeries)series).IndependentAxis = new CategoryAxis
                                    //    {
                                    //        Title = _independentLabel,
                                    //        Orientation = AxisOrientation.X
                                    //    };
                                    //}
                                    //else if (independentValue.GetType() == Type.GetType("System.DateTime"))
                                    //{
                                    //    ((ColumnSeries)series).IndependentAxis = new DateTimeAxis
                                    //    {
                                    //        Title = _independentLabel,
                                    //        Orientation = AxisOrientation.X
                                    //    };
                                    //}
                                    //else
                                    //{
                                    //    ((ColumnSeries)series).IndependentAxis = new LinearAxis
                                    //    {
                                    //        Title = _independentLabel,
                                    //        Orientation = AxisOrientation.X
                                    //    };
                                    //}
                                    #endregion
                                    Chart.Series.Add(columnSeries as ColumnSeries);
                                }
                                #region REM rotate label candidate
                                //((ColumnSeries)objectList[0] as ColumnSeries).DependentRangeAxis = new LinearAxis
                                //{
                                //    Title = _dependentLabel,
                                //    ShowGridLines = true,
                                //    Orientation = AxisOrientation.Y
                                //};
                                #endregion
                                break;

                            case Statics.Bubble:
                                foreach (object line in objectList)
                                {
                                    Chart.Series.Add(line as BubbleSeries);
                                }
                                break;

                            case Statics.RotatedBar:
                                foreach (object line in objectList)
                                {
                                    Chart.Series.Add(line as BarSeries);
                                }
                                break;

                            case Statics.Histogram:
                                foreach (object line in objectList)
                                {
                                    System.Windows.Controls.DataVisualization.ResourceDictionaryCollection pallete = new ResourceDictionaryCollection();
                                    ResourceDictionary rd = new ResourceDictionary();
                                    Style style = new Style();
                                    style.TargetType = typeof(ColumnDataPoint);

                                    style.Setters.Clear();
                                    //style.Setters.Add(new Setter() { Property = ColumnDataPoint.BackgroundProperty, Value = new SolidColorBrush(Colors.Orange) });
                                    style.Setters.Add(new Setter() { Property = ColumnDataPoint.MarginProperty, Value = new Thickness(0) });
                                    style.Setters.Add(new Setter() { Property = ColumnDataPoint.PaddingProperty, Value = new Thickness(0, 0, 0, 0) });
                                    style.Setters.Add(new Setter() { Property = ColumnDataPoint.MinWidthProperty, Value = 256 });

                                    rd.Clear();
                                    rd.Add("DataPointStyle", style);
                                    pallete.Clear();
                                    pallete.Add(rd);
                                    Chart.Palette = pallete;

                                    Chart.Series.Add(line as ColumnSeries);
                                }
                                break;

                            case Statics.Line:
                                foreach (object line in objectList)
                                {
                                    Chart.Series.Add(line as LineSeries);
                                }
                                break;

                            case Statics.Pie:
                                foreach (object column in objectList)
                                {
                                    Chart.Series.Add(column as PieSeries);
                                }
                                break;

                            case Statics.Scatter:
                                foreach (object line in objectList)
                                {
                                    Chart.Series.Add(line as ScatterSeries);
                                }
                                break;

                            case Statics.Stacked:
                                foreach (object line in objectList)
                                {
                                    Chart.Series.Add(line as StackedBarSeries);
                                }
                                break;

                            default:
                                _failOverMessage = "The specified graph type supplied in the input parameters (initParams) could not be parsed or is not supported.";
                                break;
                        }
                    }
                    catch (Exception exception)
                    {
                        _failOverMessage = exception.Message;
                    }
                }
                else
                {
                    if (_failOverMessage == string.Empty)
                    {
                        _failOverMessage = "The input parameters (initParams) could not be parsed.";
                    }
                }

                if (_failOverMessage.Length > 0)
                {
                    Chart.Visibility = Visibility.Collapsed;
                    FailOverMessage.Text = _failOverMessage;
                }
            }
        }
Beispiel #3
0
		public void InterfaceTest ()
		{
			IDictionary<object, object> d = new ResourceDictionary ();
			Assert.Throws<ArgumentException> (delegate {
				d.Add (new KeyValuePair<object, object> (new object (), new object ()));
			}, "#1");
			d.Add (new KeyValuePair<object, object> ("bob", new object ()));
			Assert.Throws<NotImplementedException> (delegate {
				int a = d.Count;
				GC.KeepAlive (a);
			}, "#2");
			Assert.AreEqual (1, ((ResourceDictionary) d).Count, "#3");
			Assert.Throws<ArgumentException> (delegate {
				d.Add (new object (), new object ());
			}, "#4");
			d.Add ("str", new object ());
			Assert.AreEqual (2, ((ResourceDictionary) d).Count, "#5");
			Assert.Throws<ArgumentException> (delegate {
				d.ContainsKey (new object ());
			}, "#6");
			Assert.IsTrue (d.Contains (new KeyValuePair<object, object> ("str", new object ())), "#7");
			d.Clear ();
			Assert.AreEqual (0, ((ResourceDictionary) d).Count, "#8");

			// this doesn't throw in SL4 for any runtime version
			d.GetEnumerator ();

			Assert.Throws<NotImplementedException> (delegate {
				var v = d.Keys;
				GC.KeepAlive (v);
			}, "#10");
			Assert.Throws<NotImplementedException> (delegate {
				var v = d.Values;
				GC.KeepAlive (v);
			}, "#11");
			Assert.IsFalse (d.IsReadOnly, "#12");
			Assert.Throws<NotImplementedException> (delegate {
				d.CopyTo (new KeyValuePair<object, object> [10], 0);
			}, "#13");
		}