/// <summary>
        /// Updates the <see cref="BaseUbiIniGameConfigViewModel{Handler}.ConfigData"/>
        /// </summary>
        /// <returns>The task</returns>
        protected override Task UpdateConfigAsync()
        {
            ConfigData.GLI_Mode = new RayGLI_Mode()
            {
                ColorMode  = IsTextures32Bit ? 32 : 16,
                IsWindowed = !FullscreenMode,
                ResX       = ResX,
                ResY       = ResY
            }.ToString();

            ConfigData.FormattedTriLinear               = TriLinear;
            ConfigData.FormattedTnL                     = TnL;
            ConfigData.FormattedTexturesCompressed      = CompressedTextures;
            ConfigData.Video_WantedQuality              = VideoQuality.ToString();
            ConfigData.FormattedVideo_AutoAdjustQuality = AutoVideoQuality;
            ConfigData.Video_BPP = IsVideo32Bpp ? "32" : "16";
            ConfigData.Language  = CurrentLanguage.ToString();
            ConfigData.FormattedDynamicShadows = DynamicShadows;
            ConfigData.FormattedStaticShadows  = StaticShadows;
            ConfigData.Camera_VerticalAxis     = VerticalAxis.ToString();
            ConfigData.Camera_HorizontalAxis   = HorizontalAxis.ToString();
            ConfigData.TexturesFile            = $"Tex{(IsTextures32Bit ? 32 : 16)}.cnt";

            return(Task.CompletedTask);
        }
 void CalculateHorizontalAxisScalers()
 {
     if (HorizontalAxis != null)
     {
         HorizontalAxis.Recalculate();
     }
 }
		void MainWindow_Loaded(object sender, RoutedEventArgs e)
		{
			//lineChart.ItemsSource = new Func<double, double>(i => Math.Sin(i * 10));

			//plotter.MainHorizontalAxis = null;
			//plotter.Children.Remove(plotter.MainHorizontalAxis);

			var axis = new HorizontalAxis();

			plotter.Children.Add(axis);

			CustomBaseNumericTicksProvider ticksProvider = new CustomBaseNumericTicksProvider(Math.PI);
			CustomBaseNumericLabelProvider labelProvider = new CustomBaseNumericLabelProvider(Math.PI, "π");
			axis.LabelProvider = labelProvider;
			axis.TicksProvider = ticksProvider;

			for (int i = 0; i < count; i++)
			{
				data.Add(new Point(i, Math.Sin(i / 10)));
			}

			LineChart chart = new LineChart
			{
				ItemsSource = data,
				StrokeThickness = 3
			};
			plotter.Children.Add(chart);

			List<double> xs = Enumerable.Range(0, count).Select(i => (double)i).ToList();
			List<double> ys = Enumerable.Range(0, count).Select(i => Math.Sin(i / 10.0)).ToList();

			xAndYSeqChart.DataSource = DataSource.Create(xs, ys);
		}
示例#4
0
        protected override PointF[] CalculatePoints()
        {
            double maxX  = HorizontalAxis.Transform(HorizontalAxis.Maximum);
            double DX    = HorizontalAxis.Transform(HorizontalAxis.Minimum + dX) - HorizontalAxis.Transform(HorizontalAxis.Minimum);
            int    start = 0;

            if (minX < HorizontalAxis.Minimum)
            {
                start = (int)Math.Floor((HorizontalAxis.Minimum - minX) / dX);
            }
            if (start >= Y.Length)
            {
                start = Y.Length - 1;
            }
            List <PointF> pointList = new List <PointF>();
            double        prevX     = HorizontalAxis.Transform(X0 + start * dX);
            double        prevY     = VerticalAxis.Transform(Y[start]);

            pointList.Add(new PointF((float)prevX, (float)prevY));
            double curX = prevX;
            double curY;

            for (int i = start + 1; i < Y.Length && ((DX > 0 && curX <= maxX) || (DX < 0 && curX >= maxX)); i++)
            {
                curX += DX;
                curY  = VerticalAxis.Transform(Y[i]);
                if (curX - prevX > 1.5 || curY - prevY > 1.5 || prevX - curX > 1.5 || prevY - curY > 1.5)
                {
                    prevX = curX;
                    prevY = curY;
                    pointList.Add(new PointF((float)prevX, (float)prevY));
                }
            }
            return(pointList.ToArray());
        }
示例#5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NumericSelector"/> class.
        /// </summary>
        public NumericSelector()
        {
            var axis = new HorizontalAxis();

            Children.Add(axis);
            ValueConversion = axis;
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Create first source
            source1 = new ObservableDataSource <Tuple <double, double> >();
            source1.SetXYMapping(z => {
                Point p = new Point(z.Item1, z.Item2);
                return(p);
            });
            HorizontalAxis axis = (HorizontalAxis)plotter.MainHorizontalAxis;

            //axis.LabelProvider.SetCustomFormatter(info => info.Tick.ToString("#.######E+0"));
            axis.LabelProvider.SetCustomFormatter(info => StringUtils.CodeString(info.Tick));

            VerticalAxis axis2 = (VerticalAxis)plotter.MainVerticalAxis;

            //axis.LabelProvider.SetCustomFormatter(info => info.Tick.ToString("#.######E+0"));
            axis2.LabelProvider.SetCustomFormatter(info => StringUtils.CodeString(info.Tick));

            Random rnd = new Random();

            for (int i = 0; i < 50; i++)
            {
                source1.Collection.Add(new Tuple <double, double>(i, rnd.Next(100)));
                //sourcevoltage.Collection.Add(new Tuple<double, double>(i, 10 + rnd.Next(20)));
            }

            linegraph.DataSource = source1;
        }
        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            //lineChart.ItemsSource = new Func<double, double>(i => Math.Sin(i * 10));

            //plotter.MainHorizontalAxis = null;
            //plotter.Children.Remove(plotter.MainHorizontalAxis);

            var axis = new HorizontalAxis();

            plotter.Children.Add(axis);

            CustomBaseNumericTicksProvider ticksProvider = new CustomBaseNumericTicksProvider(Math.PI);
            CustomBaseNumericLabelProvider labelProvider = new CustomBaseNumericLabelProvider(Math.PI, "π");

            axis.LabelProvider = labelProvider;
            axis.TicksProvider = ticksProvider;

            for (int i = 0; i < count; i++)
            {
                data.Add(new Point(i, Math.Sin(i / 10)));
            }

            LineChart chart = new LineChart
            {
                ItemsSource     = data,
                StrokeThickness = 3
            };

            plotter.Children.Add(chart);

            List <double> xs = Enumerable.Range(0, count).Select(i => (double)i).ToList();
            List <double> ys = Enumerable.Range(0, count).Select(i => Math.Sin(i / 10.0)).ToList();

            xAndYSeqChart.DataSource = DataSource.Create(xs, ys);
        }
示例#8
0
        /// <summary>
        /// Creates a new graph with a 1 to 1 graph space with absolute layout
        /// </summary>
        public GraphView()
        {
            CanFocus = true;

            AxisX = new HorizontalAxis();
            AxisY = new VerticalAxis();
        }
 void OnHorizontalAxisChanged(DependencyPropertyChangedEventArgs args)
 {
     if (HorizontalAxis != null)
     {
         HorizontalAxis.Parent        = this;
         HorizontalAxis.PointProperty = "X";
         HorizontalAxis.Recalculate();
     }
 }
示例#10
0
        private double GetClientX(double model)
        {
            var client = (_cachedScale.X * (HorizontalAxis.ViewToHomogenous(model) - HorizontalAxis.ViewToHomogenous(_boundsRect.Left)));

            if (HorizontalAxis.IsReversed)
            {
                return(_canvas.ActualWidth - client);
            }
            return(client + 0);
        }
        public void HorizontalAxisTest()
        {
            ChartPlotter target   = new ChartPlotter();
            var          expected = new HorizontalAxis();
            GeneralAxis  actual;

            target.MainHorizontalAxis = expected;
            actual = target.MainHorizontalAxis;
            Assert.AreEqual(expected, actual);
        }
示例#12
0
        public void HorizontalAxisTest()
        {
            ChartPlotter plotter  = new ChartPlotter();
            var          expected = new HorizontalAxis();

            plotter.MainHorizontalAxis = expected;
            GeneralAxis actual = plotter.MainHorizontalAxis;

            Assert.AreEqual(expected, actual);
            Assert.IsTrue(plotter.Children.OfType <HorizontalAxis>().Count() == 1);
        }
示例#13
0
        private void CacheTransform()
        {
            if (HorizontalAxis == null || VerticalAxis == null)
            {
                return;
            }
            var scaleX = _canvas.ActualWidth / (HorizontalAxis.ViewToHomogenous(_boundsRect.Right) - HorizontalAxis.ViewToHomogenous(_boundsRect.Left));
            var scaleY = _canvas.ActualHeight / (VerticalAxis.ViewToHomogenous(_boundsRect.Bottom) - HorizontalAxis.ViewToHomogenous(_boundsRect.Top));

            _cachedScale = new Point(scaleX, scaleY);
        }
示例#14
0
        private void SetupOneThirdAxis()
        {
            HorizontalAxis axis = new HorizontalAxis();

            CustomBaseNumericTicksProvider ticksProvider = new CustomBaseNumericTicksProvider(0.5);
            CustomBaseNumericLabelProvider labelProvider = new CustomBaseNumericLabelProvider(0.5, "·½");

            axis.LabelProvider = labelProvider;
            axis.TicksProvider = ticksProvider;

            plotter.Children.Add(axis);
        }
示例#15
0
 public virtual double GetModelX(double client)
 {
     if (HorizontalAxis.IsReversed)
     {
         client = _canvas.ActualWidth - client;
     }
     else
     {
         client = client - 0;
     }
     return(HorizontalAxis.HomogenousToView((client) / _cachedScale.X + HorizontalAxis.ViewToHomogenous(_boundsRect.Left)));
 }
示例#16
0
        private void SetupPiAxis()
        {
            HorizontalAxis axis = new HorizontalAxis();

            CustomBaseNumericTicksProvider ticksProvider = new CustomBaseNumericTicksProvider(Math.PI);
            CustomBaseNumericLabelProvider labelProvider = new CustomBaseNumericLabelProvider(Math.PI, "π");

            axis.LabelProvider = labelProvider;
            axis.TicksProvider = ticksProvider;

            plotter.Children.Add(axis);
        }
示例#17
0
		public Window2()
		{
			InitializeComponent();

			plotter.MainVerticalAxis.Placement = AxisPlacement.Right;
			//dateAxis.SetConversion(0, new DateTime(2008, 1, 1), 1, new DateTime(2008, 12, 1));
			//dateAxis.LabelProvider += LabelProvider_LabelCreated;

			horizTimeAxis.SetConversion(0, new TimeSpan(), 1, TimeSpan.FromHours(1));
			vertTimeAxis.SetConversion(0, new TimeSpan(), 1, TimeSpan.FromDays(1));
			//horizDateAxis.SetConversion(0, new DateTime(2008, 1, 1), 1, new DateTime(2008, 12, 1));
			//vertDateAxis.SetConversion(0, new DateTime(2008, 1, 1), 1, new DateTime(2008, 12, 1));

			//TypifiedChartPlotter<double, double> pl1 = new TypifiedChartPlotter<double, double>();
			//pl1.HorizontalAxis = new HorizontalTimeSpanAxis();



			HorizontalAxis axis = new HorizontalAxis();

			List<CityInfo> cities = new List<CityInfo>
			{
				new CityInfo{ Name = "Paris", Coordinate = -3},
				new CityInfo{ Name = "Berlin", Coordinate = -1.9},
				new CityInfo{ Name = "Minsk", Coordinate = -0.8},
				new CityInfo{ Name = "Moscow", Coordinate = 0},
				new CityInfo{ Name = "Perm", Coordinate = 2},
				new CityInfo{ Name = "Ekaterinburg", Coordinate = 4},
				new CityInfo{ Name = "Vladivostok", Coordinate = 9}
			};

			GenericLocationalLabelProvider<CityInfo, double> labelProvider = new GenericLocationalLabelProvider<CityInfo, double>(cities, city => city.Name);
			labelProvider.SetCustomView((li, uiElement) =>
			{
				FrameworkElement element = (FrameworkElement)uiElement;
				element.LayoutTransform = new RotateTransform(-45, 1, 0);
			});
			GenericLocationalTicksProvider<CityInfo, double> ticksProvider = new GenericLocationalTicksProvider<CityInfo, double>(cities, city => city.Coordinate);

			axis.LabelProvider = labelProvider;
			axis.TicksProvider = ticksProvider;

			plotter.Children.Add(axis);

			HorizontalAxis axis2 = new HorizontalAxis();
			CustomBaseNumericTicksProvider provider2 = new CustomBaseNumericTicksProvider(Math.PI);
			CustomBaseNumericLabelProvider labelProvider2 = new CustomBaseNumericLabelProvider(Math.PI, "π");
			axis2.LabelProvider = labelProvider2;
			axis2.TicksProvider = provider2;

			plotter.Children.Add(axis2);
		}
示例#18
0
        public void RemovingWhileViewportChange()
        {
            ChartPlotter   plotter = new ChartPlotter();
            HorizontalAxis axis    = new HorizontalAxis();

            plotter.Children.Add(axis);

            plotter.PerformLoad();

            plotter.Viewport.Visible = new DataRect(2, 3, 4, 5);
            plotter.Children.Remove(axis);

            plotter.Wait(DispatcherPriority.Background);
        }
示例#19
0
        private void Update()
        {
            var horizontal = Input.GetAxis("Horizontal");

            if (!Mathf.Approximately(horizontal, 0f))
            {
                //Debug.Log("Horizontal " + horizontal);
                HorizontalAxis.SafeInvoke(horizontal);
            }

            var vertical = Input.GetAxis("Vertical");

            if (!Mathf.Approximately(vertical, 0f))
            {
                //Debug.Log("Vertical " + vertical);
                VerticalAxis.SafeInvoke(vertical);
            }

            var fire = Input.GetAxis("Fire1");

            if (!Mathf.Approximately(fire, 0f) && !_firePress)
            {
                _firePress = true;
                Fire.SafeInvoke();
            }

            if (Mathf.Approximately(fire, 0f))
            {
                _firePress = false;
            }

            var weapon = Input.GetAxis("WeaponChange");

            if (!Mathf.Approximately(weapon, 0f) && !_weaponPress)
            {
                _weaponPress = true;
                WeaponChange.SafeInvoke(weapon);
            }

            if (Mathf.Approximately(weapon, 0f))
            {
                _weaponPress = false;
            }

            if (Input.GetKeyDown(KeyCode.X))
            {
                Fire.SafeInvoke();
            }
        }
示例#20
0
        private void ChartPlotter_Loaded(object sender, RoutedEventArgs e)
        {
            if (!alreadyLoaded)
            {
                VerticalAxis = new VerticalAxis();

                #region Different initialization
                if (settings.HorizontalAxisType == ChartPlotterSettings.AxisType.NumericAxis)
                {
                    var h = new HorizontalAxis();
                    HorizontalAxis = h;
                }
                else
                {
                    HorizontalAxis = new HorizontalDateTimeAxis();
                }

                if (settings.IsButtonNavigationPresents)
                {
                    buttonsNavigation = new buttonsNavigation(this);
                    HoveringStackPanel.Children.Add(buttonsNavigation);
                }

                if (settings.IsLegendPresents)
                {
                    legend = new Legend(this);
                    ScrollWraper legendWraper = new ScrollWraper(legend);
                    legendWraper.Margin = new Thickness(5, 10, 10, 10);
                    HoveringStackPanel.Children.Add(legendWraper);
                }
                #endregion

                Children.Add(axisGrid);
                if (mouseNavigation != null)
                {
                    Children.Add(mouseNavigation);
                }



                MainCanvas.SizeChanged         += new SizeChangedEventHandler(MainCanvas_SizeChanged);
                HoveringStackPanel.SizeChanged += new SizeChangedEventHandler(hoveringPanel_SizeChanged);
                Viewport.FitToView();
                alreadyLoaded = true;
            }
        }
示例#21
0
        private void SetupLocationalAxis()
        {
            HorizontalAxis axis = new HorizontalAxis();

            List <CityInfo> cities = new List <CityInfo>
            {
                new CityInfo {
                    Name = "Paris", Coordinate = 0.05
                },
                new CityInfo {
                    Name = "Berlin", Coordinate = 0.2
                },
                new CityInfo {
                    Name = "Minsk", Coordinate = 0.3
                },
                new CityInfo {
                    Name = "Moscow", Coordinate = 0.5
                },
                new CityInfo {
                    Name = "Perm", Coordinate = 0.7
                },
                new CityInfo {
                    Name = "Ekaterinburg", Coordinate = 0.85
                },
                new CityInfo {
                    Name = "Vladivostok", Coordinate = 0.9
                }
            };

            GenericLocationalLabelProvider <CityInfo, double> labelProvider = new GenericLocationalLabelProvider <CityInfo, double>(cities, city => city.Name);

            labelProvider.SetCustomView((li, uiElement) =>
            {
                FrameworkElement element = (FrameworkElement)uiElement;
                element.LayoutTransform  = new RotateTransform(-15, 0, 0);
            });
            GenericLocationalTicksProvider <CityInfo, double> ticksProvider = new GenericLocationalTicksProvider <CityInfo, double>(cities, city => city.Coordinate);

            axis.LabelProvider = labelProvider;
            axis.TicksProvider = ticksProvider;

            plotter.Children.Add(axis);
        }
        public void HorizontalAxisIsDefaultTest()
        {
            ChartPlotter plotter = new ChartPlotter();

            HorizontalAxis axis  = (HorizontalAxis)plotter.MainHorizontalAxis;
            HorizontalAxis axis2 = new HorizontalAxis();

            plotter.Children.Add(axis2);

            Assert.AreEqual(plotter.MainHorizontalAxis, axis);
            Assert.IsTrue(axis.IsDefaultAxis);

            axis2.IsDefaultAxis = true;
            Assert.AreEqual(plotter.MainHorizontalAxis, axis2);
            Assert.IsFalse(axis.IsDefaultAxis);

            axis.IsDefaultAxis = true;
            Assert.AreEqual(plotter.MainHorizontalAxis, axis);
            Assert.IsFalse(axis2.IsDefaultAxis);
        }
示例#23
0
        public void Render(Image <Rgba32> target, GraphicsOptions renderOptions)
        {
            target.Mutate(context =>
            {
                GridLayer?.Render(this, context, renderOptions);
                VerticalAxis?.Render(this, context, renderOptions);
                VerticalAxisLabeler?.Render(this, context, renderOptions);
                HorizontalAxis?.Render(this, context, renderOptions);
                HorizontalAxisLabeler?.Render(this, context, renderOptions);

                foreach (var dataLayer in DataSets)
                {
                    dataLayer?.Render(this, context, renderOptions);
                }

                foreach (var extraLayer in AdditionalLayers)
                {
                    extraLayer?.Render(this, context, renderOptions);
                }
            });
        }
示例#24
0
        protected virtual PointF[] CalculatePoints()
        {
            List <PointF> pointList = new List <PointF>();
            float         prevX     = (float)HorizontalAxis.Transform(X[0]);
            float         prevY     = (float)VerticalAxis.Transform(Y[0]);

            pointList.Add(new PointF(prevX, prevY));
            float curX, curY;

            for (int i = 1; i < X.Length; i++)
            {
                curX = (float)HorizontalAxis.Transform(X[i]);
                curY = (float)VerticalAxis.Transform(Y[i]);
                if (curX - prevX > 1.5 || curY - prevY > 1.5 || prevX - curX > 1.5 || prevY - curY > 1.5)
                {
                    prevX = curX;
                    prevY = curY;
                    pointList.Add(new PointF(prevX, prevY));
                }
            }
            return(pointList.ToArray());
        }
示例#25
0
        public void HorizontalAxisIsDefaultTest()
        {
            ChartPlotter plotter = new ChartPlotter();

            plotter.PerformLoad();

            HorizontalAxis axis  = (HorizontalAxis)plotter.MainHorizontalAxis;
            HorizontalAxis axis2 = new HorizontalAxis();

            plotter.Children.Add(axis2);

            Assert.AreEqual(plotter.MainHorizontalAxis, axis);
            Assert.IsTrue(axis.IsDefaultAxis);
            Assert.AreEqual(2, plotter.Children.OfType <HorizontalAxis>().Count());

            axis2.IsDefaultAxis = true;
            Assert.AreEqual(axis2, plotter.MainHorizontalAxis);
            Assert.IsFalse(axis.IsDefaultAxis);

            axis.IsDefaultAxis = true;
            Assert.AreEqual(plotter.MainHorizontalAxis, axis);
            Assert.IsFalse(axis2.IsDefaultAxis);
        }
示例#26
0
        /// <summary>
        /// Sets properties of the newly created graph object and
        /// gets references to important scripts of the new object
        /// </summary>
        /// <param name="graphWidget">The corresponding GraphWidget which holds the data</param>
        private void InitGraphObject(GraphWidget graphWidget)
        {
            graph = GetComponentInChildren <GraphChart>();
            if (graph == null)
            {
                // the ChartGraph info is obtained via the inspector
                Debug.LogWarning("No GraphChart found! Place this script into a graph chart!");
                return;
            }

            lineMaterial = new Material(Shader.Find("Chart/Canvas/Solid"));
            graph.DataSource.AddCategory(graphWidget.name, lineMaterial, 20, new MaterialTiling(false, 20), null, true, null, 20);

            graph.AutoScrollHorizontally             = true;
            graph.DataSource.AutomaticHorizontalView = graphWidget.showCompleteHistory;
            if (verticalAxis == null)
            {
                verticalAxis          = graph.GetComponent <VerticalAxis>();
                horizontalAxis        = graph.GetComponent <HorizontalAxis>();
                horizontalAxis.Format = AxisFormat.Time;
            }
            // has to be changed if the graph gets other TextMeshProUGUI scripts
            titleText = GetComponentInChildren <TextMeshProUGUI>();
        }
示例#27
0
        /// <summary>
        /// Creates a new graph with a 1 to 1 graph space with absolute layout
        /// </summary>
        public GraphView()
        {
            CanFocus = true;

            AxisX = new HorizontalAxis();
            AxisY = new VerticalAxis();

            // Things this view knows how to do
            AddCommand(Command.ScrollUp, () => { Scroll(0, CellSize.Y); return(true); });
            AddCommand(Command.ScrollDown, () => { Scroll(0, -CellSize.Y); return(true); });
            AddCommand(Command.ScrollRight, () => { Scroll(CellSize.X, 0); return(true); });
            AddCommand(Command.ScrollLeft, () => { Scroll(-CellSize.X, 0); return(true); });
            AddCommand(Command.PageUp, () => { PageUp(); return(true); });
            AddCommand(Command.PageDown, () => { PageDown(); return(true); });

            AddKeyBinding(Key.CursorRight, Command.ScrollRight);
            AddKeyBinding(Key.CursorLeft, Command.ScrollLeft);
            AddKeyBinding(Key.CursorUp, Command.ScrollUp);
            AddKeyBinding(Key.CursorDown, Command.ScrollDown);

            // Not bound by default (preserves backwards compatibility)
            //AddKeyBinding (Key.PageUp, Command.PageUp);
            //AddKeyBinding (Key.PageDown, Command.PageDown);
        }
        public Window2()
        {
            InitializeComponent();

            plotter.MainVerticalAxis.Placement = AxisPlacement.Right;
            //dateAxis.SetConversion(0, new DateTime(2008, 1, 1), 1, new DateTime(2008, 12, 1));
            //dateAxis.LabelProvider += LabelProvider_LabelCreated;

            horizTimeAxis.SetConversion(0, new TimeSpan(), 1, TimeSpan.FromHours(1));
            vertTimeAxis.SetConversion(0, new TimeSpan(), 1, TimeSpan.FromDays(1));
            //horizDateAxis.SetConversion(0, new DateTime(2008, 1, 1), 1, new DateTime(2008, 12, 1));
            //vertDateAxis.SetConversion(0, new DateTime(2008, 1, 1), 1, new DateTime(2008, 12, 1));

            //TypifiedChartPlotter<double, double> pl1 = new TypifiedChartPlotter<double, double>();
            //pl1.HorizontalAxis = new HorizontalTimeSpanAxis();



            HorizontalAxis axis = new HorizontalAxis();

            List <CityInfo> cities = new List <CityInfo>
            {
                new CityInfo {
                    Name = "Paris", Coordinate = -3
                },
                new CityInfo {
                    Name = "Berlin", Coordinate = -1.9
                },
                new CityInfo {
                    Name = "Minsk", Coordinate = -0.8
                },
                new CityInfo {
                    Name = "Moscow", Coordinate = 0
                },
                new CityInfo {
                    Name = "Perm", Coordinate = 2
                },
                new CityInfo {
                    Name = "Ekaterinburg", Coordinate = 4
                },
                new CityInfo {
                    Name = "Vladivostok", Coordinate = 9
                }
            };

            GenericLocationalLabelProvider <CityInfo, double> labelProvider = new GenericLocationalLabelProvider <CityInfo, double>(cities, city => city.Name);

            labelProvider.SetCustomView((li, uiElement) =>
            {
                FrameworkElement element = (FrameworkElement)uiElement;
                element.LayoutTransform  = new RotateTransform(-45, 1, 0);
            });
            GenericLocationalTicksProvider <CityInfo, double> ticksProvider = new GenericLocationalTicksProvider <CityInfo, double>(cities, city => city.Coordinate);

            axis.LabelProvider = labelProvider;
            axis.TicksProvider = ticksProvider;

            plotter.Children.Add(axis);

            HorizontalAxis axis2 = new HorizontalAxis();
            CustomBaseNumericTicksProvider provider2      = new CustomBaseNumericTicksProvider(Math.PI);
            CustomBaseNumericLabelProvider labelProvider2 = new CustomBaseNumericLabelProvider(Math.PI, "π");

            axis2.LabelProvider = labelProvider2;
            axis2.TicksProvider = provider2;

            plotter.Children.Add(axis2);
        }
示例#29
0
		private void SetupLocationalAxis()
		{
			HorizontalAxis axis = new HorizontalAxis();

			List<CityInfo> cities = new List<CityInfo>
			{
				new CityInfo{ Name = "Paris", Coordinate = 0.05},
				new CityInfo{ Name = "Berlin", Coordinate = 0.2},
				new CityInfo{ Name = "Minsk", Coordinate = 0.3},
				new CityInfo{ Name = "Moscow", Coordinate = 0.5},
				new CityInfo{ Name = "Perm", Coordinate = 0.7},
				new CityInfo{ Name = "Ekaterinburg", Coordinate = 0.85},
				new CityInfo{ Name = "Vladivostok", Coordinate = 0.9}
			};

			GenericLocationalLabelProvider<CityInfo, double> labelProvider = new GenericLocationalLabelProvider<CityInfo, double>(cities, city => city.Name);
			labelProvider.SetCustomView((li, uiElement) =>
			{
				FrameworkElement element = (FrameworkElement)uiElement;
				element.LayoutTransform = new RotateTransform(-15, 0, 0);
			});
			GenericLocationalTicksProvider<CityInfo, double> ticksProvider = new GenericLocationalTicksProvider<CityInfo, double>(cities, city => city.Coordinate);

			axis.LabelProvider = labelProvider;
			axis.TicksProvider = ticksProvider;

			plotter.Children.Add(axis);
		}
示例#30
0
		private void SetupOneThirdAxis()
		{
			HorizontalAxis axis = new HorizontalAxis();

			CustomBaseNumericTicksProvider ticksProvider = new CustomBaseNumericTicksProvider(0.5);
			CustomBaseNumericLabelProvider labelProvider = new CustomBaseNumericLabelProvider(0.5, "·½");
			axis.LabelProvider = labelProvider;
			axis.TicksProvider = ticksProvider;

			plotter.Children.Add(axis);
		}
示例#31
0
		private void SetupPiAxis()
		{
			HorizontalAxis axis = new HorizontalAxis();

			CustomBaseNumericTicksProvider ticksProvider = new CustomBaseNumericTicksProvider(Math.PI);
			CustomBaseNumericLabelProvider labelProvider = new CustomBaseNumericLabelProvider(Math.PI, "π");
			axis.LabelProvider = labelProvider;
			axis.TicksProvider = ticksProvider;

			plotter.Children.Add(axis);
		}
示例#32
0
        public void Update(Boolean useTransition)
        {
            LegendAreaWidth = 0;
            D3Data          = new Data()
            {
                List = Data.Select(d => d as Object).ToList()
            };

            firstColumnViewModel  = Data[0].ColumnViewModel;
            secondColumnViewModel = Data[0].Children[0].ColumnViewModel;

            // chart data 수정
            ChartData   = Data.SelectMany(d => d.Children).ToList();
            D3ChartData = new Data()
            {
                List = ChartData.Select(d => d as Object).ToList()
            };

            /*
             *  기존 데이터를 여러 각도로 수정해야함
             *  1. 레전드용 데이터: 두번째 키만 모아야함. 이것은 색깔을 배치할때도 쓰임
             *  2. 사각형 그리기용 데이터: 왜냐하면 hierarchical하게 있으면 안되므로
             */

            // legend 데이터 수정

            if (LegendVisibility == Visibility.Visible)
            {
                LegendData.Clear();
                foreach (GroupedBarChartDatum gbcd in Data)
                {
                    foreach (BarChartDatum bcd in gbcd.Children)
                    {
                        if (LegendData.Select(d => d.Key).Count(d => d == bcd.Key) == 0)
                        {
                            LegendData.Add(bcd);
                        }
                    }
                }

                LegendData = LegendData.OrderBy(d => d.Order).ToList();

                LegendRectangleElement.Data = new Data()
                {
                    List = LegendData.Select(d => d as Object).ToList()
                };
                LegendRectangleElement.Update(useTransition ? TransitionType.Opacity : TransitionType.None);

                LegendTextElement.Data = new Data()
                {
                    List = LegendData.Select(d => d as Object).ToList()
                };
                LegendTextElement.Update(useTransition ? TransitionType.Opacity : TransitionType.None);
                LegendTextElement.ForceMeasure();

                LegendAreaWidth          = Math.Max(LegendTextElement.MaxActualWidth + Const.LegendPatchWidth + Const.LegendPatchSpace + Const.PaddingRight, Const.MinimumLegendWidth);
                LegendTitleElement.Width = LegendAreaWidth;
                LegendTitleElement.Text  = LegendTitle;
                Canvas.SetTop(LegendTitleElement, LegendPatchYGetter(null, 0) - 30);
            }

            Canvas.SetLeft(LegendPanel, this.Width - LegendAreaWidth);

            if (HorizontalAxisVisibility == Visibility.Visible)
            {
                ChartAreaEndY = this.Height - Const.PaddingBottom - Const.HorizontalAxisHeight - Const.HorizontalAxisLabelHeight;
            }
            else
            {
                ChartAreaEndY = this.Height - Const.PaddingBottom;
            }

            if (LegendVisibility == Visibility.Visible)
            {
                ChartAreaEndX = this.Width - Const.PaddingRight - LegendAreaWidth;
            }
            else
            {
                ChartAreaEndX = this.Width - Const.PaddingRight;
            }

            HorizontalAxisLabelCanvasLeft = Const.PaddingLeft + Const.VerticalAxisWidth + Const.VerticalAxisLabelWidth;
            HorizontalAxisLabelCanvasTop  = ChartAreaEndY + Const.HorizontalAxisHeight;
            HorizontalAxisLabelWidth      = ChartAreaEndX - Const.PaddingLeft - Const.VerticalAxisWidth - Const.VerticalAxisLabelWidth;

            VerticalAxisCanvasLeft      = Const.PaddingLeft + Const.VerticalAxisLabelWidth + Const.VerticalAxisWidth;
            VerticalAxisLabelCanvasLeft = Const.PaddingLeft + Const.VerticalAxisLabelWidth / 2 - (ChartAreaEndY - Const.PaddingTop) / 2;
            VerticalAxisLabelCanvasTop  = Const.PaddingTop + (ChartAreaEndY - Const.PaddingTop) / 2;
            VerticalAxisLabelHeight     = ChartAreaEndY - Const.PaddingTop;

            isSelectionEnabled = ChartData.Any(bcd => bcd.BarState == BarState.FullySelected || bcd.BarState == BarState.PartiallySelected);

            // 최솟 최댓값 모두 envelope의 값은 고려해야함
            // 그냥 값은 선택되어 있을때만 고려해야함
            Double yMin = ChartData.Select(d => d.EnvelopeValue).Min(),
                   yMax = ChartData.Select(d => d.EnvelopeValue).Max();

            if (isSelectionEnabled) // 선택된게 하나라도 있으면
            {
                IEnumerable <Double> selected = ChartData.Where(cd => cd.BarState == BarState.FullySelected || cd.BarState == BarState.PartiallySelected).Select(cd => cd.Value);
                yMin = Math.Min(yMin, selected.Min());
                yMax = Math.Max(yMax, selected.Max());
            }

            if (YStartsFromZero)
            {
                yMin = 0;
            }
            else if (yMin == yMax)
            {
                if (yMin == 0.0)
                {
                    yMin = -1; yMax = 1;
                }
                else if (yMin < 0)
                {
                    yMin *= 1.2;
                    yMax *= 0.8;
                }
                else
                {
                    yMin *= 0.8;
                    yMax *= 1.2;
                }
            }
            else
            {
                if (yMin > 0)
                {
                    yMin *= 0.9;
                }
                else
                {
                    yMin *= 1.1;
                }
            }

            YScale = new Linear()
            {
                DomainStart = yMin,
                DomainEnd   = yMax,
                RangeStart  = ChartAreaEndY,
                RangeEnd    = Const.PaddingTop
            };

            YScale.Nice();

            XScale = new Ordinal()
            {
                RangeStart = VerticalAxisCanvasLeft,
                RangeEnd   = ChartAreaEndX + Const.PaddingLeft
            };

            foreach (GroupedBarChartDatum datum in Data)
            {
                XScale.Domain.Add(datum);
            }

            MaxBarCountInAGroup = Data.Select(d => d.Children.Count()).Max();


            // update 시 재대입 할 것들 대입

            HandleRectangleElement.Data   = D3ChartData;
            EnvelopeRectangleElement.Data = D3ChartData;
            RectangleElement.Data         = D3ChartData;

            HorizontalAxis.Scale = XScale;
            Canvas.SetTop(HorizontalAxis, ChartAreaEndY);
            HorizontalAxis.Visibility = HorizontalAxisVisibility;

            Canvas.SetTop(HorizontalAxisTitleElement, HorizontalAxisLabelCanvasTop);
            Canvas.SetLeft(HorizontalAxisTitleElement, HorizontalAxisLabelCanvasLeft);
            HorizontalAxisTitleElement.Width      = HorizontalAxisLabelWidth;
            HorizontalAxisTitleElement.Visibility = HorizontalAxisVisibility;
            HorizontalAxisTitleElement.Text       = HorizontalAxisTitle;

            VerticalAxis.Scale = YScale;
            Canvas.SetLeft(VerticalAxis, VerticalAxisCanvasLeft);

            Canvas.SetTop(VerticalAxisTitleElement, VerticalAxisLabelCanvasTop);
            Canvas.SetLeft(VerticalAxisTitleElement, VerticalAxisLabelCanvasLeft);
            VerticalAxisTitleElement.Width = VerticalAxisLabelHeight;
            VerticalAxisTitleElement.Text  = VerticalAxisTitle;

            LegendHandleRectangleElement.Data = new Data()
            {
                List = LegendData.Select(d => d as Object).ToList()
            };
            LegendHandleRectangleElement.Visibility = LegendVisibility;

            LegendRectangleElement.Data = new Data()
            {
                List = LegendData.Select(d => d as Object).ToList()
            };
            LegendRectangleElement.Visibility = LegendVisibility;

            LegendTextElement.Data = new Data()
            {
                List = LegendData.Select(d => d as Object).ToList()
            };
            LegendTextElement.Visibility = LegendVisibility;

            IndicatorTextElement.Data = new Data()
            {
                List = ChartData.Select(d => d as Object).ToList()
            };

            LegendHandleRectangleElement.Update(useTransition ? TransitionType.Opacity : TransitionType.None);
            HandleRectangleElement.Update(TransitionType.None);
            EnvelopeRectangleElement.Update(useTransition ? TransitionType.All : TransitionType.None);
            RectangleElement.Update(useTransition ? TransitionType.All : TransitionType.None);
            IndicatorTextElement.Update(useTransition ? TransitionType.All : TransitionType.None);
            HorizontalAxis.Update(useTransition);
            VerticalAxis.Update(useTransition);
        }
示例#33
0
        public void Update(Boolean useTransition)
        {
            LegendAreaWidth = 0;
            D3Data          = new Data()
            {
                List = Data.Select(d => d as Object).ToList()
            };

            CircleData   = Data.SelectMany(l => l.DataPoints).Where(dp => dp.Item2 != null).ToList();
            D3CircleData = new Data()
            {
                List = CircleData.Select(d => d as Object).ToList()
            };

            if (LegendVisibility == Visibility.Visible)
            {
                LegendRectangleElement.Data = D3Data;
                LegendRectangleElement.Update(useTransition ? TransitionType.Opacity : TransitionType.None);

                LegendTextElement.Data = D3Data;
                LegendTextElement.Update(useTransition ? TransitionType.Opacity : TransitionType.None);
                LegendTextElement.ForceMeasure();

                LegendAreaWidth          = Math.Max(LegendTextElement.MaxActualWidth + Const.LegendPatchWidth + Const.LegendPatchSpace + Const.PaddingRight, Const.MinimumLegendWidth);
                LegendTitleElement.Width = LegendAreaWidth;
                LegendTitleElement.Text  = LegendTitle;
                Canvas.SetTop(LegendTitleElement, LegendPatchYGetter(null, 0) - 30);
            }

            Canvas.SetLeft(LegendPanel, this.Width - LegendAreaWidth);

            if (HorizontalAxisVisibility == Visibility.Visible)
            {
                ChartAreaEndY = this.Height - Const.PaddingBottom - Const.HorizontalAxisHeight - Const.HorizontalAxisLabelHeight;
            }
            else
            {
                ChartAreaEndY = this.Height - Const.PaddingBottom;
            }

            if (LegendVisibility == Visibility.Visible)
            {
                ChartAreaEndX = this.Width - Const.PaddingRight - LegendAreaWidth;
            }
            else
            {
                ChartAreaEndX = this.Width - Const.PaddingRight;
            }

            HorizontalAxisLabelCanvasLeft = Const.PaddingLeft + Const.VerticalAxisWidth + Const.VerticalAxisLabelWidth;
            HorizontalAxisLabelCanvasTop  = ChartAreaEndY + Const.HorizontalAxisHeight;
            HorizontalAxisLabelWidth      = ChartAreaEndX - Const.PaddingLeft - Const.VerticalAxisWidth - Const.VerticalAxisLabelWidth;

            VerticalAxisCanvasLeft      = Const.PaddingLeft + Const.VerticalAxisLabelWidth + Const.VerticalAxisWidth;
            VerticalAxisLabelCanvasLeft = Const.PaddingLeft + Const.VerticalAxisLabelWidth / 2 - (ChartAreaEndY - Const.PaddingTop) / 2;
            VerticalAxisLabelCanvasTop  = Const.PaddingTop + (ChartAreaEndY - Const.PaddingTop) / 2;
            VerticalAxisLabelHeight     = ChartAreaEndY - Const.PaddingTop;


            Double yMin = Math.Min(CircleData.Select(d => (Double)d.EnvelopeItem2).Min(), CircleData.Select(d => (Double)d.Item2).Min()),
                   yMax = Math.Max(CircleData.Select(d => (Double)d.EnvelopeItem2).Max(), CircleData.Select(d => (Double)d.Item2).Max());

            if (YStartsFromZero)
            {
                yMin = 0;
            }
            else if (yMin == yMax)
            {
                if (yMin == 0.0)
                {
                    yMin = -1; yMax = 1;
                }
                else if (yMin < 0)
                {
                    yMin *= 1.2;
                    yMax *= 0.8;
                }
                else
                {
                    yMin *= 0.8;
                    yMax *= 1.2;
                }
            }
            else
            {
                if (yMin > 0)
                {
                    yMin *= 0.9;
                }
                else
                {
                    yMin *= 1.1;
                }
            }

            YScale = new Linear()
            {
                DomainStart = yMin,
                DomainEnd   = yMax,
                RangeStart  = ChartAreaEndY,
                RangeEnd    = Const.PaddingTop
            };

            YScale.Nice();

            XScale = new Ordinal()
            {
                RangeStart = VerticalAxisCanvasLeft,
                RangeEnd   = ChartAreaEndX + Const.PaddingLeft
            };

            foreach (Object item1 in CircleData.OrderBy(dp => dp.Order)
                     .Select(cd => cd.Item1).Distinct())
            {
                XScale.Domain.Add(item1);
            }

            HandleLineElement.Data   = D3Data;
            EnvelopeLineElement.Data = D3Data;
            LineElement.Data         = D3Data;

            EnvelopeCircleElement.Data = D3CircleData;
            CircleElement.Data         = D3CircleData;

            HorizontalAxis.Scale = XScale;
            Canvas.SetTop(HorizontalAxis, ChartAreaEndY);
            HorizontalAxis.Visibility = HorizontalAxisVisibility;

            Canvas.SetTop(HorizontalAxisTitleElement, HorizontalAxisLabelCanvasTop);
            Canvas.SetLeft(HorizontalAxisTitleElement, HorizontalAxisLabelCanvasLeft);
            HorizontalAxisTitleElement.Width      = HorizontalAxisLabelWidth;
            HorizontalAxisTitleElement.Visibility = HorizontalAxisVisibility;
            HorizontalAxisTitleElement.Text       = HorizontalAxisTitle;

            VerticalAxis.Scale = YScale;
            Canvas.SetLeft(VerticalAxis, VerticalAxisCanvasLeft);

            Canvas.SetTop(VerticalAxisTitleElement, VerticalAxisLabelCanvasTop);
            Canvas.SetLeft(VerticalAxisTitleElement, VerticalAxisLabelCanvasLeft);
            VerticalAxisTitleElement.Width = VerticalAxisLabelHeight;
            VerticalAxisTitleElement.Text  = VerticalAxisTitle;

            LegendHandleRectangleElement.Data       = D3Data;
            LegendHandleRectangleElement.Visibility = LegendVisibility;

            IndicatorTextElement.Data = D3CircleData;

            HandleLineElement.Update(useTransition ? TransitionType.Opacity : TransitionType.None);
            LineElement.Update(useTransition ? TransitionType.Opacity & TransitionType.Color: TransitionType.None);
            EnvelopeCircleElement.Update(useTransition ? TransitionType.Opacity : TransitionType.None);
            EnvelopeLineElement.Update(useTransition ? TransitionType.Opacity & TransitionType.Color : TransitionType.None);
            CircleElement.Update(TransitionType.None);        // useTransition ? TransitionType.Opacity : TransitionType.None);
            LegendHandleRectangleElement.Update(TransitionType.None);
            IndicatorTextElement.Update(TransitionType.None); // useTransition ? TransitionType.Opacity : TransitionType.None);
            HorizontalAxis.Update(useTransition);
            VerticalAxis.Update(useTransition);
        }
示例#34
0
		private void DrawPlots()
		{
			HorizontalAxis xAxis = (HorizontalAxis)plotter.MainHorizontalAxis;
			xAxis.TicksProvider = new LogarithmNumericTicksProvider(10);
			xAxis.LabelProvider = new UnroundingLabelProvider();
			xAxis.ShowMajorLabels = true;
			xAxis.ShowMinorTicks = true;
			xAxis.SnapsToDevicePixels = true;

			xAxis.LabelProvider.SetCustomFormatter(info => info.Tick.ToString("#.######e0"));

			HorizontalAxisTitle HAT = new HorizontalAxisTitle()
			{
				Content = _xAxisInfo.AxisTitle
			};

			plotter.MainHorizontalAxis = xAxis;
			plotter.Children.Add(HAT);
			((NumericAxis)plotter.MainHorizontalAxis).AxisControl.TicksPath.Stroke = Brushes.Blue;

			VerticalAxis yAxis = (VerticalAxis)plotter.MainVerticalAxis;
			yAxis.TicksProvider = new NumericTicksProvider();
			yAxis.LabelProvider = new UnroundingLabelProvider();
			yAxis.ShowMajorLabels = true;
			yAxis.ShowMinorTicks = true;
			yAxis.SnapsToDevicePixels = true;


			VerticalAxisTitle VAT = new VerticalAxisTitle()
			{
				Content = _yAxisInfoList[0].AxisTitle
			};

			plotter.MainVerticalAxis = yAxis;
			plotter.Children.Add(VAT);
			plotter.AxisGrid.DrawVerticalMinorTicks = true;
			plotter.AxisGrid.DrawHorizontalMinorTicks = true;
			plotter.MainVerticalAxis.Background = new LinearGradientBrush(Colors.White, Colors.LightGray, 90);

			var xPoints = _xAxisInfo.AxisDataPoints.AsXDataSource();

			// Create the main plot
			foreach (AxisInfo yAxInfo in _yAxisInfoList)
			{
				var yPoints = yAxInfo.AxisDataPoints.AsYDataSource();

				CompositeDataSource plot = xPoints.Join(yPoints);
				plotter.AddLineGraph(plot, yAxInfo.PlotColor, yAxInfo.PlotLineThickness, yAxInfo.AxisLegend);
			}


			// add secondary y-axis plots if any exist
			if (_yAxisInfoSecList != null)
			{
				InjectedPlotter innerPlotter = new InjectedPlotter();
				innerPlotter.SetViewportBinding = false;
				plotter.Children.Add(innerPlotter);

				HorizontalAxis ax = new HorizontalAxis();
				ax.Placement = AxisPlacement.Top;
				ax.TicksProvider = new LogarithmNumericTicksProvider(10);
				ax.LabelProvider = new UnroundingLabelProvider();
				ax.LabelProvider.SetCustomFormatter(info => info.Tick.ToString("#.######e0"));
				ax.ShowMajorLabels = true;
				ax.ShowMinorTicks = true;
				ax.SnapsToDevicePixels = true;
				ax.AxisControl.TicksPath.Stroke = Brushes.Red;
				plotter.Children.Add(ax);


				VerticalAxis yAxisSec = new VerticalAxis()
				{
					TicksProvider = new NumericTicksProvider(),
					LabelProvider = new UnroundingLabelProvider(),
					ShowMinorTicks = true,
					ShowMajorLabels = true,
					SnapsToDevicePixels = true,
					Placement = AxisPlacement.Right
				};

				VerticalAxisTitle VATsecondary = new VerticalAxisTitle()
				{
					Content = _yAxisInfoSecList[0].AxisTitle,
					Placement = AxisPlacement.Right
				};

				innerPlotter.MainVerticalAxis = yAxisSec;
				innerPlotter.Children.Add(VATsecondary);
				innerPlotter.MainVerticalAxis.Background = new LinearGradientBrush(Colors.White, Colors.Red, 90);

				foreach (AxisInfo yAxInfoSec in _yAxisInfoSecList)
				{
					var ySecPoints = yAxInfoSec.AxisDataPoints.AsYDataSource();

					CompositeDataSource plotSec = xPoints.Join(ySecPoints);
					/*innerP*/
					plotter.AddLineGraph(plotSec, yAxInfoSec.PlotColor, yAxInfoSec.PlotLineThickness, yAxInfoSec.AxisLegend);
				}

			}
		}
示例#35
0
        private void ChartPlotter_Loaded(object sender, RoutedEventArgs e)
        {
         
            if (!alreadyLoaded)
            {
                VerticalAxis = new VerticalAxis();

                #region Different initialization
                if (settings.HorizontalAxisType == ChartPlotterSettings.AxisType.NumericAxis)
                {
                  var h = new HorizontalAxis();
                    HorizontalAxis =h;
                }
                else HorizontalAxis = new HorizontalDateTimeAxis();

                if (settings.IsButtonNavigationPresents)
                {
                    buttonsNavigation = new buttonsNavigation(this);
                    HoveringStackPanel.Children.Add(buttonsNavigation);
                }

                if (settings.IsLegendPresents)
                {
                    legend = new Legend(this);
                    ScrollWraper legendWraper = new ScrollWraper(legend);
                    legendWraper.Margin = new Thickness(5, 10, 10, 10);
                    HoveringStackPanel.Children.Add(legendWraper);
                }
                #endregion

                Children.Add(axisGrid);
              if (mouseNavigation!=null)
                Children.Add(mouseNavigation);

              
              
                MainCanvas.SizeChanged += new SizeChangedEventHandler(MainCanvas_SizeChanged);
                HoveringStackPanel.SizeChanged += new SizeChangedEventHandler(hoveringPanel_SizeChanged);
                Viewport.FitToView();
                alreadyLoaded = true;
            }
        }
示例#36
0
        void IData.CalculateGraphics(RectangleF plotRectangle)
        {
            points       = CalculatePoints();
            GraphicsPath = new GraphicsPath();

            if (points.Length > 1)
            {
                if (Interpolation == Interpolation.Line)
                {
                    GraphicsPath.AddLines(points);
                }
                else if (Interpolation == Interpolation.Spline)
                {
                    GraphicsPath.AddCurve(points);
                }
                else if (Interpolation == Interpolation.StepNear)
                {
                    for (int i = 0; i < points.Length - 1; i++)
                    {
                        GraphicsPath.AddLine(points[i].X, points[i].Y, points[i].X, points[i + 1].Y);
                        GraphicsPath.AddLine(points[i].X, points[i + 1].Y, points[i + 1].X, points[i + 1].Y);
                    }
                }
                else if (Interpolation == Interpolation.StepFar)
                {
                    for (int i = 0; i < points.Length - 1; i++)
                    {
                        GraphicsPath.AddLine(points[i].X, points[i].Y, points[i + 1].X, points[i].Y);
                        GraphicsPath.AddLine(points[i + 1].X, points[i].Y, points[i + 1].X, points[i + 1].Y);
                    }
                }
                else if (Interpolation == Interpolation.StepCenter)
                {
                    float center1 = (points[1].X + points[0].X) / 2;
                    GraphicsPath.AddLine(points[0].X, points[0].Y, center1, points[0].Y);
                    float center2;

                    for (int i = 1; i < points.Length - 1; i++)
                    {
                        GraphicsPath.AddLine(center1, points[i - 1].Y, center1, points[i].Y);
                        center2 = (points[i + 1].X + points[i].X) / 2;
                        GraphicsPath.AddLine(center1, points[i].Y, center2, points[i].Y);
                        center1 = center2;
                    }
                    GraphicsPath.AddLine(center1, points[points.Length - 2].Y, center1, points[points.Length - 1].Y);
                    GraphicsPath.AddLine(center1, points[points.Length - 1].Y, points[points.Length - 1].X, points[points.Length - 1].Y);
                }
                else if (Interpolation == Interpolation.StepVertical)
                {
                    float center1 = (points[1].Y + points[0].Y) / 2;
                    GraphicsPath.AddLine(points[0].X, points[0].Y, points[0].X, center1);
                    float center2;

                    for (int i = 1; i < points.Length - 1; i++)
                    {
                        GraphicsPath.AddLine(points[i - 1].X, center1, points[i].X, center1);
                        center2 = (points[i + 1].Y + points[i].Y) / 2;
                        GraphicsPath.AddLine(points[i].X, center1, points[i].X, center2);
                        center1 = center2;
                    }
                    GraphicsPath.AddLine(points[points.Length - 2].X, center1, points[points.Length - 1].X, center1);
                    GraphicsPath.AddLine(points[points.Length - 1].X, center1, points[points.Length - 1].X, points[points.Length - 1].Y);
                }

                GraphicsPath flattenPath = new GraphicsPath();
                flattenPath.AddPath(GraphicsPath, false);
                flattenPath.Flatten();
                flatten = flattenPath.PathPoints;

                if (BarStyle != BarStyle.None)
                {
                    bars = new RectangleF[points.Length];
                    float barCount = BarGrouping ? ((IGroupedBar)this).BarCount : 1.0f;
                    float W;

                    if (BarStyle == BarStyle.Vertical)
                    {
                        float refPositionY = (float)VerticalAxis.Transform(BarValue);

                        for (int i = 0; i < points.Length; i++)
                        {
                            bars[i] = new RectangleF();
                            if (i == 0)
                            {
                                W = Math.Abs(points[1].X - points[0].X) / barCount;
                            }
                            else if (i == points.Length - 1)
                            {
                                W = Math.Abs(points[points.Length - 1].X - points[points.Length - 2].X) / barCount;
                            }
                            else
                            {
                                W = Math.Abs(points[i + 1].X - points[i - 1].X) / 2.0f / barCount;
                            }
                            bars[i].Width = W * BarDuty;
                            bars[i].X     = points[i].X;
                            bars[i].X    -= i == 0 ? (BarDuty * Math.Abs(points[1].X - points[0].X) / 2.0f) : (BarDuty * Math.Abs(points[i].X - points[i - 1].X) / 2.0f);
                            bars[i].X    += ((IGroupedBar)this).BarIndex * bars[i].Width;

                            if (refPositionY > points[i].Y)
                            {
                                bars[i].Y      = points[i].Y;
                                bars[i].Height = refPositionY - points[i].Y;
                            }
                            else
                            {
                                bars[i].Y      = refPositionY;
                                bars[i].Height = points[i].Y - refPositionY;
                            }
                        }
                    }
                    else if (BarStyle == BarStyle.Horisontal)
                    {
                        float refPositionX = (float)HorizontalAxis.Transform(BarValue);
                        float H;
                        for (int i = 0; i < points.Length; i++)
                        {
                            bars[i] = new RectangleF();
                            if (i == 0)
                            {
                                H = Math.Abs(points[1].Y - points[0].Y) / barCount;
                            }
                            else if (i == points.Length - 1)
                            {
                                H = Math.Abs(points[points.Length - 1].Y - points[points.Length - 2].Y) / barCount;
                            }
                            else
                            {
                                H = Math.Abs(points[i + 1].Y - points[i - 1].Y) / 2.0f / barCount;
                            }
                            bars[i].Height = H * BarDuty;
                            bars[i].Y      = points[i].Y;
                            bars[i].Y     -= i == 0 ? (BarDuty * Math.Abs(points[1].Y - points[0].Y) / 2.0f) : (BarDuty * Math.Abs(points[i].Y - points[i - 1].Y) / 2.0f);
                            bars[i].Y     += (barCount - ((IGroupedBar)this).BarIndex - 1) * bars[i].Height;

                            if (refPositionX > points[i].X)
                            {
                                bars[i].X     = points[i].X;
                                bars[i].Width = refPositionX - points[i].X;
                            }
                            else
                            {
                                bars[i].X     = refPositionX;
                                bars[i].Width = points[i].X - refPositionX;
                            }
                        }
                    }
                }
            }
        }
示例#37
0
        private UIElement GenerateResultLayout(int channel, string sampleNum, string sampleName)
        {
            Border border = new Border()
            {
                Width               = 600,
                Height              = 440,
                Margin              = new Thickness(2),
                BorderThickness     = new Thickness(5),
                BorderBrush         = _borderBrushNormal,
                CornerRadius        = new CornerRadius(10),
                HorizontalAlignment = System.Windows.HorizontalAlignment.Right,
                Name = "border"
            };
            StackPanel stackPanel = new StackPanel()
            {
                Width  = 600,
                Height = 420,
                HorizontalAlignment = System.Windows.HorizontalAlignment.Right,
                Name = "stackPanel"
            };
            Grid grid = new Grid()
            {
                Width  = 600,
                Height = 40,
                HorizontalAlignment = System.Windows.HorizontalAlignment.Right
            };
            Label label = new Label()
            {
                FontSize            = 20,
                HorizontalAlignment = System.Windows.HorizontalAlignment.Center,
                VerticalAlignment   = System.Windows.VerticalAlignment.Center,
                Content             = " 检测通道" + (channel + 1)
            };
            Canvas canvas = new Canvas()
            {
                Width      = 600,
                Height     = 400,
                Background = Brushes.Gray,
                Name       = "canvas"
            };

            plotter = new ChartPlotter()
            {
                Width  = 600,
                Height = 380,
                HorizontalAlignment = System.Windows.HorizontalAlignment.Right,
                VerticalAlignment   = System.Windows.VerticalAlignment.Stretch
            };
            plotter.MouseDoubleClick += new MouseButtonEventHandler(plotter_MouseDoubleClick);
            plotter.Name              = "chartPlotter";

            HorizontalAxis horizontalAxis = new HorizontalAxis()
            {
                Name = "horizontalAxis"
            };

            dateAxis = new HorizontalDateTimeAxis()
            {
                //dateAxis = new HorizontalIntegerAxis();
                Name = "dateAxis"
            };
            VerticalAxis verticalAxis = new VerticalAxis()
            {
                Name = "verticalAxis"
            };
            VerticalIntegerAxis countAxis = new VerticalIntegerAxis()
            {
                Name = "countAxis"
            };
            VerticalAxisTitle arialy = new VerticalAxisTitle()
            {
                Content = "y"
            };
            HorizontalAxisTitle arialx = new HorizontalAxisTitle()
            {
                Content = "x"
            };

            canvas.Children.Add(plotter);
            canvas.Children.Add(dateAxis);
            canvas.Children.Add(verticalAxis);
            canvas.Children.Add(countAxis);
            canvas.Children.Add(arialy);
            canvas.Children.Add(arialx);

            WrapPanel wrapPannelSampleNum = new WrapPanel()
            {
                Width  = 180,
                Height = 30
            };
            Label labelSampleNum = new Label()
            {
                Width    = 85,
                Height   = 26,
                Margin   = new Thickness(0, 2, 0, 0),
                FontSize = 15,
                Content  = " 样品编号:",
                VerticalContentAlignment = System.Windows.VerticalAlignment.Center
            };
            TextBox textBoxSampleNum = new TextBox()
            {
                Width    = 90,
                Height   = 26,
                Margin   = new Thickness(0, 2, 0, 2),
                FontSize = 15,
                Text     = string.Empty + sampleNum,
                VerticalContentAlignment = System.Windows.VerticalAlignment.Center,
                IsReadOnly = true
            };
            WrapPanel wrapPannelSampleName = new WrapPanel()
            {
                Width  = 180,
                Height = 30
            };
            Label labelSampleName = new Label()
            {
                Width    = 85,
                Height   = 26,
                Margin   = new Thickness(0, 2, 0, 0),
                FontSize = 15,
                Content  = " 样品名称:",
                VerticalContentAlignment = System.Windows.VerticalAlignment.Center
            };
            TextBox textBoxSampleName = new TextBox()
            {
                Width    = 90,
                Height   = 26,
                Margin   = new Thickness(0, 2, 0, 2),
                FontSize = 15,
                Text     = string.Empty + _item.Hole[channel].SampleName,
                VerticalContentAlignment = System.Windows.VerticalAlignment.Center,
                IsReadOnly = true
            };
            WrapPanel wrapPannelRGBValue = new WrapPanel()
            {
                Width  = 180,
                Height = 30
            };
            Label labelRGBValue = new Label()
            {
                Width    = 85,
                Height   = 26,
                Margin   = new Thickness(0, 2, 0, 0),
                FontSize = 15,
                Content  = " 灰度值:",
                VerticalContentAlignment = System.Windows.VerticalAlignment.Center
            };
            TextBox textBoxRGBValue = new TextBox()
            {
                Width    = 90,
                Height   = 26,
                Margin   = new Thickness(0, 2, 0, 2),
                FontSize = 15,
                Text     = string.Empty,
                VerticalContentAlignment = System.Windows.VerticalAlignment.Center,
                IsReadOnly = true,
                Name       = "textBoxRGBValue"
            };
            WrapPanel wrapPannelDetectResult = new WrapPanel()
            {
                Width  = 180,
                Height = 30
            };
            Label labelDetectResult = new Label()
            {
                Width    = 85,
                Height   = 26,
                Margin   = new Thickness(0, 2, 0, 0),
                FontSize = 15,
                Content  = " 检测结果:",
                VerticalContentAlignment = System.Windows.VerticalAlignment.Center
            };
            TextBox textBoxDetectResult = new TextBox()
            {
                Width    = 90,
                Height   = 26,
                Margin   = new Thickness(0, 2, 0, 2),
                FontSize = 15,
                Text     = "0.00",
                VerticalContentAlignment = System.Windows.VerticalAlignment.Center,
                IsReadOnly = true,
                Name       = "textBoxDetectResult"
            };

            //判定结果
            WrapPanel wrapJudgemtn = new WrapPanel()
            {
                Width  = 180,
                Height = 30
            };
            Label labelJudgment = new Label()
            {
                Width    = 85,
                Height   = 26,
                Margin   = new Thickness(0, 2, 0, 0),
                FontSize = 15,
                Content  = " 判定结果:",
                VerticalContentAlignment = System.Windows.VerticalAlignment.Center
            };
            TextBox textJugmentResult = new TextBox()
            {
                Width    = 90,
                Height   = 26,
                Margin   = new Thickness(0, 2, 0, 2),
                FontSize = 15,
                Text     = "合格",
                VerticalContentAlignment = System.Windows.VerticalAlignment.Center,
                Name = "textJugmentResult"
            };
            //判定标准值
            WrapPanel wrapStandValue = new WrapPanel()
            {
                Width  = 180,
                Height = 30
            };
            Label labelStandValue = new Label()
            {
                Width    = 85,
                Height   = 26,
                Margin   = new Thickness(0, 2, 0, 0),
                FontSize = 15,
                Content  = " 标准值:",
                VerticalContentAlignment = System.Windows.VerticalAlignment.Center
            };
            TextBox textStandValue = new TextBox()
            {
                Width    = 90,
                Height   = 26,
                Margin   = new Thickness(0, 2, 0, 2),
                FontSize = 15,
                Text     = "1.00",
                VerticalContentAlignment = System.Windows.VerticalAlignment.Center,
                Name = "textStandValue"
            };

            wrapPannelSampleNum.Children.Add(labelSampleNum);
            wrapPannelSampleNum.Children.Add(textBoxSampleNum);
            wrapPannelSampleName.Children.Add(labelSampleName);
            wrapPannelSampleName.Children.Add(textBoxSampleName);
            wrapPannelDetectResult.Children.Add(labelDetectResult);
            wrapPannelDetectResult.Children.Add(textBoxDetectResult);
            wrapJudgemtn.Children.Add(labelJudgment);
            wrapJudgemtn.Children.Add(textJugmentResult);
            wrapStandValue.Children.Add(labelStandValue);
            wrapStandValue.Children.Add(textStandValue);

            grid.Children.Add(label);
            stackPanel.Children.Add(grid);
            stackPanel.Children.Add(canvas);
            //stackPanel.Children.Add(wrapPannelSampleNum);
            //stackPanel.Children.Add(wrapPannelSampleName);
            //stackPanel.Children.Add(wrapPannelDetectResult);
            //stackPanel.Children.Add(wrapJudgemtn);
            //stackPanel.Children.Add(wrapStandValue);
            border.Child = stackPanel;
            return(border);
        }