void PlotterConfigurator_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (DataContext != null)
            {
                x = ((ChartPlotter)DataContext).Children.OfType <HorizontalAxisTitle>().FirstOrDefault();
                y = ((ChartPlotter)DataContext).Children.OfType <VerticalAxisTitle>().FirstOrDefault();

                tx.Text = x.Content.ToString();
                ty.Text = y.Content.ToString();
            }
        }
예제 #2
0
        void Page_Loaded(object sender, RoutedEventArgs e)
        {
            mainHeader = new Header();
            TextBlock anotherHeaderText = new TextBlock();

            anotherHeaderText.Text          = "Layout Tutorial";
            anotherHeaderText.TextAlignment = TextAlignment.Center;
            anotherHeaderText.FontSize      = 22;
            mainHeader.Content = anotherHeaderText;
            PlotterMain.Children.Add(mainHeader);

            additioanlHeader = new Header();
            TextBlock headerText = new TextBlock();

            headerText.Text          = "Additional header";
            headerText.FontSize      = 20;
            headerText.FontWeight    = FontWeights.Bold;
            additioanlHeader.Content = headerText;
            PlotterMain.Children.Add(additioanlHeader);


            footer = new Footer();
            TextBlock footerText = new TextBlock();

            footerText.Text      = "Small footer";
            footerText.FontSize  = 8;
            footerText.FontStyle = FontStyles.Italic;
            footer.Content       = footerText;


            TextBlock vertTitleTextBlock = new TextBlock();

            vertTitleTextBlock.Text = "This is Vertical title";
            //Only VerticalAxisTitle should be created this way, to create HorizonatalAxisTitle use its Content property
            //DO NOT use Content property in VerticalAxisTitle
            vertTitle = new VerticalAxisTitle(vertTitleTextBlock);
            PlotterMain.Children.Add(vertTitle);

            //Use Content property of the HorizontalAxisTitle to set its content
            horiTitle         = new HorizontalAxisTitle();
            horiTitle.Content = new TextBlock()
            {
                Text = "Horizontal axis title set from code", HorizontalAlignment = HorizontalAlignment.Center
            };
            PlotterMain.Children.Add(horiTitle);

            TextBoxUpperHeaderTitle.Text = anotherHeaderText.Text;
            TextBoxVerticalTitle.Text    = vertTitleTextBlock.Text;
        }
예제 #3
0
        private void ButtonChangeVertAxis_CLick(object sender, RoutedEventArgs e)
        {
            if (vertTitle != null)
            {
                PlotterMain.Children.Remove(vertTitle);
            }



            TextBlock newTitleTextBlock = new TextBlock();

            newTitleTextBlock.Text = TextBoxVerticalTitle.Text;

            vertTitle = new VerticalAxisTitle(newTitleTextBlock);

            PlotterMain.Children.Add(vertTitle);
        }
        private void drowChartPlotter(ChartPlotter cp)
        {
            this.chartGrid_.Children.Clear();

            Header h = new Header();

            h.Content = "Payoff";
            cp.Children.Add(h);
            VerticalAxisTitle vat = new VerticalAxisTitle();

            vat.Content = "억원";
            HorizontalAxisTitle hat = new HorizontalAxisTitle();

            hat.Content = "P";
            cp.Children.Add(vat);
            cp.Children.Add(hat);
        }
예제 #5
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);
        }
예제 #6
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);
                }
            }
        }
예제 #7
0
        private void MakePlots()
        {
            if (!PlotsMade) //Only do this once
            {
                Model mShe = new Model(SheFileName);
                DFS3  dfs  = new DFS3(Dfs3FileName);
                Item  dfsI = dfs.Items[ItemNumber - 1];

                List <TimestampSeries> well_Concentration = new List <TimestampSeries>();

                int[] TimeSteps   = ParseString(TimeStepsAsString, 0, dfs.NumberOfTimeSteps - 1);
                int[] WellNumbers = ParseString(WellsAsString, 0, mShe.ExtractionWells.Count - 1);

                List <MikeSheWell> wells = new List <MikeSheWell>();
                foreach (int j in WellNumbers)
                {
                    wells.Add(mShe.ExtractionWells[j]);
                }

                foreach (int i in TimeSteps)
                {
                    int k = 0;
                    foreach (var w in wells)
                    {
                        if (i == TimeSteps[0])
                        {
                            well_Concentration.Add(new TimestampSeries(w.ID, new Unit(dfsI.EumQuantity.UnitAbbreviation, 1, 0)));
                        }
                        well_Concentration[k].Items.Add(new TimestampValue(dfs.TimeSteps[i], (dfs.GetData(i, ItemNumber)[w.Row, w.Column, w.Layer])));
                        k++;
                    }
                }

                //Sets the upper title
                Header.Content = dfsI.Name;

                //Sets the title of the y-axis
                var ytitle = new VerticalAxisTitle();
                ytitle.Content = dfsI.EumQuantity.ItemDescription + " [" + dfsI.EumQuantity.UnitAbbreviation + "]";
                TheChart.Children.Add(ytitle);

                int l = 0;
                //Loop the wells for plotting
                foreach (var w in wells)
                {
                    if (g != null)
                    {
                        TheChart.Children.Remove(g);
                        TheChart.FitToView();
                    }

                    var axis = new Microsoft.Research.DynamicDataDisplay.Charts.HorizontalDateTimeAxis();
                    TheChart.MainHorizontalAxis = axis;
                    TheChart.MainVerticalAxis   = new Microsoft.Research.DynamicDataDisplay.Charts.VerticalAxis();
                    //set the data source
                    EnumerableDataSource <TimestampValue> ds = new EnumerableDataSource <TimestampValue>(well_Concentration[l].Items);
                    ds.SetXMapping(var => axis.ConvertToDouble(var.Time));
                    ds.SetYMapping(var => var.Value);
                    //create the graph
                    g = TheChart.AddLineGraph(ds, new Pen(Brushes.Black, 3), new PenDescription(w.ID));
                    //create a filename
                    outfile = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Dfs3FileName), "Well_No" + "_" + WellNumbers[l].ToString() + "_" + dfsI.EumQuantity.ItemDescription);
                    //now save to file
                    this.UpdateLayout();

                    MainWindow.SaveScreen(this, outfile + ".jpg", (int)ActualWidth, (int)ActualHeight);


                    //Now create the dfs0-file
                    using (DFS0 dfs0 = new DFS0(outfile + ".dfs0", 1))
                    {
                        dfs0.FirstItem.Name      = dfsI.Name;
                        dfs0.FirstItem.EumItem   = dfsI.EumItem;
                        dfs0.FirstItem.EumUnit   = dfsI.EumUnit;
                        dfs0.FirstItem.ValueType = dfsI.ValueType;

                        int t = 0;
                        foreach (var v in well_Concentration[l].Items)
                        {
                            dfs0.InsertTimeStep(v.Time);
                            dfs0.SetData(t, 1, v.Value);
                            t++;
                        }
                    }

                    //Now create the text-file
                    using (StreamWriter sw = new StreamWriter(outfile + ".txt", false))
                    {
                        foreach (var v in well_Concentration[l].Items)
                        {
                            sw.WriteLine(v.Time + "; " + v.Value);
                        }
                    }
                    l++;
                }
                mShe.Dispose();
                dfs.Dispose();
                PlotsMade = true;
            }
        }