예제 #1
0
        private void Grid_KeyUp(object sender, KeyEventArgs e)
        {
            //(sender as DevExpress.Xpf.Charts.ChartControl).CrosshairEnabled = true;
            //while (true)
            if (chart.CrosshairEnabled == false)
            {
                if (e.Key == Key.Right)
                {
                    if (indexOfSelected < PointsCollectionForGraphs[indexOfPane].Count - 1)
                    {
                        indexOfSelected++;
                        GraphicsCollection.ShowCrosshair(PointsCollectionForGraphs[indexOfPane][indexOfSelected].X, PointsCollectionForGraphs[indexOfPane][indexOfSelected].Y, GraphicsCollection.AxisX, GraphicsCollection.AxisY);// new Point(0.1, 1));
                    }
                    //GraphicsCollection.ShowCrosshair(new Point(my_x+1,my_y+1));

                    //GraphicsCollection.ShowCrosshair(my_x+0.1, my_y, GraphicsCollection.AxisX, GraphicsCollection.AxisY);
                    //my_x += 0.1;
                }
                else if (e.Key == Key.Left)
                {
                    if (indexOfSelected > 0)
                    {
                        indexOfSelected--;
                        GraphicsCollection.ShowCrosshair(PointsCollectionForGraphs[indexOfPane][indexOfSelected].X, PointsCollectionForGraphs[indexOfPane][indexOfSelected].Y, GraphicsCollection.AxisX, GraphicsCollection.AxisY);// new Point(0.1, 1));
                    }
                }
            }

            //var k = GraphicsCollection.GetPositGraphicsCollection.ShowCrosshairion();
            //var s = Graph1Lines.CrosshairLabelPattern.ToString();
            //var s1 = Graph1Lines.ValueDataMember;
            //var c1 = GraphicsCollection.PointToDiagram(new Point(my_x, my_y));
            //int k = PointsCollectionForGraphs[0].IndexOf(new myPoint(my_x, my_y));
            //var tempColl = (PointsCollectionForGraphs[0].Where(i=>(i.X <= my_x))).Count() - 1 ;
        }
예제 #2
0
        private void GraphicsCollection_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (chart.CrosshairEnabled == true)
            {
                try
                {
                    DevExpress.Xpf.Charts.DiagramCoordinates coord = (sender as DevExpress.Xpf.Charts.XYDiagram2D).PointToDiagram(e.GetPosition(chart));
                    double my_x = coord.NumericalArgument;

                    if (GraphicsCollection.DefaultPane.IsMouseOver == true)
                    {
                        indexOfPane = 0;
                    }
                    else
                    {
                        for (int k = 0; k < GraphicsCollection.Panes.Count; k++)
                        {
                            if (GraphicsCollection.Panes[k].IsMouseOver == true)
                            {
                                indexOfPane = k + 1;
                            }
                        }
                    }
                    indexOfSelected = (PointsCollectionForGraphs[indexOfPane].Where(i => (i.X <= my_x))).Count() - 1;
                    //for (int k = 0; k< PointsCollectionForGraphs.Count; k++)
                    //{
                    //    indexOfSelected = (PointsCollectionForGraphs[k].Where(i => (i.X <= my_x))).Count() - 1;
                    //    if (indexOfSelected != -1)
                    //    {
                    //        indexOfPane = indexOfSelected;
                    //        break;
                    //    }
                    //}
                    GraphicsCollection.ShowCrosshair(PointsCollectionForGraphs[indexOfPane][indexOfSelected].X, PointsCollectionForGraphs[indexOfPane][indexOfSelected].Y, GraphicsCollection.AxisX, GraphicsCollection.AxisY);
                    chart.CrosshairEnabled = false;
                }
                catch
                {
                }
            }
            else
            {
                chart.CrosshairEnabled = true;
            }
        }
예제 #3
0
        public Graphs(DevExpress.Xpf.NavBar.NavBarGroup inputData)
        {
            PointsCollectionForGraphs = new ObservableCollection <ObservableCollection <myPoint> >();
            //PointsCollectionForGraphs.Add(new ObservableCollection<myPoint>());

            //MKIO_visual.Graphs.Graphs myGraph = new Graphs.Graphs(filteredData[(o as MKIO_visual.Graphs.GraphOptions).ChooseFilter.SelectedIndex], (o as MKIO_visual.Graphs.GraphOptions).numberSD.SelectedIndex);
            //((sender as GridControl).View as TableView).GetSelectedCells().Count
            int mask = 0;

            int[] byteWord = new int[16];

            int    numBits   = 0;
            double CHSR      = 0;
            double tempValue = 0;
            int    sdvig     = 0;

            //if (((inputData.Items[0] as GraphOptions).MKIO_word_table.View as DevExpress.Xpf.Grid.TableView).GetSelectedCells().Count != 0)
            //{
            //    for (int j = 0; j < ((inputData.Items[0] as GraphOptions).MKIO_word_table.View as DevExpress.Xpf.Grid.TableView).GetSelectedCells().Count; j++)
            //    {
            //        byteWord[15 - int.Parse(((inputData.Items[0] as GraphOptions).MKIO_word_table.View as DevExpress.Xpf.Grid.TableView).GetSelectedCells()[j].Column.FieldName)] = 1;
            //        sdvig = 15 - int.Parse(((inputData.Items[0] as GraphOptions).MKIO_word_table.View as DevExpress.Xpf.Grid.TableView).GetSelectedCells()[j].Column.FieldName);
            //    }
            //    for (int i = 0; i < 16; i++)
            //    {
            //        mask += byteWord[i] * (int)Math.Pow(2, i);
            //    }
            //    //CHSR = (double.Parse((inputData.Items[0] as GraphOptions).cena_mlad.Text) / Math.Pow(2, 15 - (inputData.Items[0] as GraphOptions).number_razr - 4)) * Math.Pow(2,((inputData.Items[0] as GraphOptions).MKIO_word_table.View as DevExpress.Xpf.Grid.TableView).GetSelectedCells().Count - 1);
            //    numBits = ((inputData.Items[0] as GraphOptions).MKIO_word_table.View as DevExpress.Xpf.Grid.TableView).GetSelectedCells().Count;
            //}
            //else
            //{
            //    mask = 0xFFFF;
            //    //CHSR = (double.Parse((inputData.Items[0] as GraphOptions).cena_mlad.Text) / Math.Pow(2, 15 - (inputData.Items[0] as GraphOptions).number_razr - 4)) * Math.Pow(2, 15);
            //    numBits = 16;
            //}
            ////MessageBox.Show(mask.ToString());
            ////((inputData.Items[0] as GraphOptions).MKIO_word_table.View as DevExpress.Xpf.Grid.TableView).GetSelectedCells();
            //if ((inputData.Items[0] as GraphOptions).checked_1_word.IsChecked == true)
            //{
            //    CHSR = (double.Parse((inputData.Items[0] as GraphOptions).cena_mlad.Text) / Math.Pow(2, 15 - ((inputData.Items[0] as GraphOptions).number_razr - 4 + sdvig))) * Math.Pow(2, numBits - 1);
            //    foreach (MKIO_visual.MKIO.MKIO_PACK_CLI_EXT o in MKIO_visual.Table.myTable.filteredData[(inputData.Items[0] as GraphOptions).ChooseFilter.SelectedIndex].MKIO_REG)
            //    {
            //        if ((inputData.Items[0] as GraphOptions).znak.Content.ToString() == "Беззнаковое")
            //            tempValue = MKIO_visual.ConvertExt.LibConvert.UnpackUINT32toDouble((UInt32)((o.MKIO_PACK.Data[(inputData.Items[0] as GraphOptions).numberSD.SelectedIndex] & mask) >> sdvig), CHSR, (UInt16)(numBits));
            //        else
            //        {
            //            if (numBits == 0 || numBits == 16)
            //                tempValue = MKIO_visual.ConvertExt.LibConvert.UnpackINT32toDouble(ConvertExt.LibConvert.UInt16TOInt16((UInt16)(o.MKIO_PACK.Data[(inputData.Items[0] as GraphOptions).numberSD.SelectedIndex])), CHSR, (UInt16)(numBits));
            //            else
            //                tempValue = MKIO_visual.ConvertExt.LibConvert.UnpackINT32toDouble(ConvertExt.LibConvert.UInt32ToInt32((UInt32)((o.MKIO_PACK.Data[(inputData.Items[0] as GraphOptions).numberSD.SelectedIndex] & mask) >> sdvig)), CHSR, (UInt16)(numBits));
            //        }
            //        PointsCollectionForGraphs[0].Add(new myPoint((o.MKIO_PACK.time_IRQ - Table.myTable.monitorData.MKIO_REG[0].MKIO_PACK.time_IRQ) / 1000.0, tempValue));

            //    }
            //}
            //else if ((inputData.Items[0] as GraphOptions).checked_2_word.IsChecked == true)
            //{
            //    CHSR = (double.Parse((inputData.Items[0] as GraphOptions).cena_mlad.Text) / Math.Pow(2, 15 - ((inputData.Items[0] as GraphOptions).number_razr - 4))) * Math.Pow(2, 16 - 1);
            //    foreach (MKIO_visual.MKIO.MKIO_PACK_CLI_EXT o in MKIO_visual.Table.myTable.filteredData[(inputData.Items[0] as GraphOptions).ChooseFilter.SelectedIndex].MKIO_REG)
            //    {
            //        if ((inputData.Items[0] as GraphOptions).znak.Content.ToString() == "Беззнаковое")
            //            tempValue = MKIO_visual.ConvertExt.LibConvert.UnpackUINT32toDouble((UInt32)((o.MKIO_PACK.Data[(inputData.Items[0] as GraphOptions).numberSD.SelectedIndex] << numBits) + ((o.MKIO_PACK.Data[(inputData.Items[0] as GraphOptions).numberSD.SelectedIndex + 1] & mask) >> sdvig)), CHSR, (UInt16)(numBits+16));
            //        else
            //            tempValue = MKIO_visual.ConvertExt.LibConvert.UnpackINT32toDouble(ConvertExt.LibConvert.UInt32ToInt32((UInt32)((o.MKIO_PACK.Data[(inputData.Items[0] as GraphOptions).numberSD.SelectedIndex] << numBits) + ((o.MKIO_PACK.Data[(inputData.Items[0] as GraphOptions).numberSD.SelectedIndex + 1] & mask) >> sdvig))), CHSR, (UInt16)(numBits + 16));
            //        PointsCollectionForGraphs[0].Add(new myPoint((o.MKIO_PACK.time_IRQ - Table.myTable.monitorData.MKIO_REG[0].MKIO_PACK.time_IRQ) / 1000.0, tempValue));

            //    }
            //}
            InitializeComponent();
            if (Properties.Settings.Default.GraphsPosition != Rect.Empty)
            {
                this.SetBounds(Properties.Settings.Default.GraphsPosition);
            }
            if (Properties.Settings.Default.GraphsMaximized == true)
            {
                WindowState = WindowState.Maximized;
            }
            //Graph1Lines.DisplayName = (inputData.Items[0] as GraphOptions).NameOfGraph.Text.ToString();//"Название линии";
            //Graph1Name.Content = (inputData.Items[0] as GraphOptions).NameOfGraph.Text.ToString();
            //Graph1Lines.DataSource = PointsCollectionForGraphs[0];
            string xaml = @"<ItemsPanelTemplate   xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
                            <Grid>                            
                                <Grid.RowDefinitions>
                                   <RowDefinition Height='1*'/>";

            //             <RowDefinition Height='1*'/>
            //             <RowDefinition Height='1.2*'/>
            //         </Grid.RowDefinitions >
            //      </Grid >
            //</ItemsPanelTemplate > ";


            for (int i = 0; i < inputData.Items.Count - 1; i++)
            {
                mask      = 0;
                sdvig     = 0;
                numBits   = 0;
                tempValue = 0;
                byteWord  = new int[16];
                if (((inputData.Items[i] as GraphOptions).MKIO_word_table.View as DevExpress.Xpf.Grid.TableView).GetSelectedCells().Count != 0)
                {
                    for (int j = 0; j < ((inputData.Items[i] as GraphOptions).MKIO_word_table.View as DevExpress.Xpf.Grid.TableView).GetSelectedCells().Count; j++)
                    {
                        byteWord[15 - int.Parse(((inputData.Items[i] as GraphOptions).MKIO_word_table.View as DevExpress.Xpf.Grid.TableView).GetSelectedCells()[j].Column.FieldName)] = 1;
                        sdvig = 15 - int.Parse(((inputData.Items[i] as GraphOptions).MKIO_word_table.View as DevExpress.Xpf.Grid.TableView).GetSelectedCells()[j].Column.FieldName);
                    }
                    for (int k = 0; k < 16; k++)
                    {
                        mask += byteWord[k] * (int)Math.Pow(2, k);
                    }
                    numBits = ((inputData.Items[i] as GraphOptions).MKIO_word_table.View as DevExpress.Xpf.Grid.TableView).GetSelectedCells().Count;
                }
                else
                {
                    mask    = 0xFFFF;
                    numBits = 16;
                }
                PointsCollectionForGraphs.Add(new ObservableCollection <myPoint>());
                if ((inputData.Items[i] as GraphOptions).cena_mlad.Text.Contains("."))
                {
                    (inputData.Items[i] as GraphOptions).cena_mlad.Text = (inputData.Items[i] as GraphOptions).cena_mlad.Text.Replace(".", ",");
                }
                if ((inputData.Items[i] as GraphOptions).checked_1_word.IsChecked == true)
                {
                    CHSR = (double.Parse((inputData.Items[i] as GraphOptions).cena_mlad.Text) / Math.Pow(2, 15 - ((inputData.Items[i] as GraphOptions).number_razr - 4 + sdvig))) * Math.Pow(2, numBits - 1);
                    foreach (MKIO_visual.MKIO.MKIO_PACK_CLI_EXT o in MKIO_visual.Table.myTable.filteredData[(inputData.Items[i] as GraphOptions).ChooseFilter.SelectedIndex].MKIO_REG)
                    {
                        if ((inputData.Items[i] as GraphOptions).znak.Content.ToString() == "Беззнаковое")
                        {
                            tempValue = MKIO_visual.ConvertExt.LibConvert.UnpackUINT32toDouble((UInt32)((o.MKIO_PACK.Data[(inputData.Items[i] as GraphOptions).numberSD.SelectedIndex] & mask) >> sdvig), CHSR, (UInt16)(numBits));
                        }
                        else
                        {
                            if (numBits == 0 || numBits == 16)
                            {
                                tempValue = MKIO_visual.ConvertExt.LibConvert.UnpackINT32toDouble(ConvertExt.LibConvert.UInt16TOInt16((UInt16)(o.MKIO_PACK.Data[(inputData.Items[i] as GraphOptions).numberSD.SelectedIndex])), CHSR, (UInt16)(numBits));
                            }
                            else
                            {
                                tempValue = MKIO_visual.ConvertExt.LibConvert.UnpackINT32toDouble(ConvertExt.LibConvert.UInt32ToInt32((UInt32)((o.MKIO_PACK.Data[(inputData.Items[i] as GraphOptions).numberSD.SelectedIndex] & mask) >> sdvig)), CHSR, (UInt16)(numBits));
                            }
                        }
                        PointsCollectionForGraphs[i].Add(new myPoint((o.MKIO_PACK.time_IRQ - Table.myTable.monitorData.MKIO_REG[0].MKIO_PACK.time_IRQ) / 1000000.0, tempValue));
                    }
                }
                else if ((inputData.Items[i] as GraphOptions).checked_2_word.IsChecked == true)
                {
                    CHSR = (double.Parse((inputData.Items[i] as GraphOptions).cena_mlad.Text) / Math.Pow(2, 15 - ((inputData.Items[i] as GraphOptions).number_razr - 4))) * Math.Pow(2, 16 - 1);
                    foreach (MKIO_visual.MKIO.MKIO_PACK_CLI_EXT o in MKIO_visual.Table.myTable.filteredData[(inputData.Items[i] as GraphOptions).ChooseFilter.SelectedIndex].MKIO_REG)
                    {
                        if ((inputData.Items[i] as GraphOptions).znak.Content.ToString() == "Беззнаковое")
                        {
                            tempValue = MKIO_visual.ConvertExt.LibConvert.UnpackUINT32toDouble((UInt32)((o.MKIO_PACK.Data[(inputData.Items[i] as GraphOptions).numberSD.SelectedIndex] << numBits) + ((o.MKIO_PACK.Data[(inputData.Items[i] as GraphOptions).numberSD.SelectedIndex + 1] & mask) >> sdvig)), CHSR, (UInt16)(numBits + 16));
                        }
                        else
                        {
                            tempValue = MKIO_visual.ConvertExt.LibConvert.UnpackINT32toDouble(((Int32)(ConvertExt.LibConvert.UInt16TOInt16((UInt16)(o.MKIO_PACK.Data[(inputData.Items[i] as GraphOptions).numberSD.SelectedIndex])) << numBits) | ((o.MKIO_PACK.Data[(inputData.Items[i] as GraphOptions).numberSD.SelectedIndex + 1] & mask) >> sdvig)), CHSR, (UInt16)(numBits + 16));
                        }
                        PointsCollectionForGraphs[i].Add(new myPoint((o.MKIO_PACK.time_IRQ - Table.myTable.monitorData.MKIO_REG[0].MKIO_PACK.time_IRQ) / 1000000.0, tempValue));
                    }
                }
                if (i == 0)
                {
                    Graph1Lines.DisplayName = (inputData.Items[0] as GraphOptions).NameOfGraph.Text.ToString();//"Название линии";
                    Graph1Name.Content      = (inputData.Items[0] as GraphOptions).NameOfGraph.Text.ToString();
                    Graph1Lines.DataSource  = PointsCollectionForGraphs[0];
                    if (GraphicsCollection.AxisY.ActualWholeRange.ActualMinValueInternal == 0)
                    {
                        GraphicsCollection.AxisY.ActualWholeRange.SetMinMaxValues(0 - (GraphicsCollection.AxisY.ActualWholeRange.ActualMaxValueInternal * 0.1), GraphicsCollection.AxisY.ActualWholeRange.ActualMaxValueInternal);
                    }
                    if (inputData.Items.Count - 1 == 1)
                    {
                        VisibilityFirstGraph.Visible = true;
                    }
                }
                else
                {
                    if (i != (inputData.Items.Count - 2))
                    {
                        xaml += @"<RowDefinition Height='1*'/>";
                        GraphicsCollection.Panes.Add(new DevExpress.Xpf.Charts.Pane()
                        {
                            EnableAxisXNavigation = true, EnableAxisYNavigation = false, AxisXScrollBarOptions = new DevExpress.Xpf.Charts.ScrollBarOptions()
                            {
                                Visible = false
                            }
                        });
                        Grid.SetRow(GraphicsCollection.Panes[GraphicsCollection.Panes.Count - 1], i);
                        myAxisX.VisibilityInPanes.Add(new DevExpress.Xpf.Charts.VisibilityInPane()
                        {
                            Pane = GraphicsCollection.Panes[i - 1], Visible = false
                        });
                    }
                    else
                    {
                        xaml += @"<RowDefinition Height='1.4*'/>";
                        GraphicsCollection.Panes.Add(new DevExpress.Xpf.Charts.Pane()
                        {
                            EnableAxisXNavigation = true, EnableAxisYNavigation = false, AxisXScrollBarOptions = new DevExpress.Xpf.Charts.ScrollBarOptions()
                            {
                                Visible = true
                            }
                        });
                        Grid.SetRow(GraphicsCollection.Panes[GraphicsCollection.Panes.Count - 1], i);
                        myAxisX.VisibilityInPanes.Add(new DevExpress.Xpf.Charts.VisibilityInPane()
                        {
                            Pane = GraphicsCollection.Panes[i - 1], Visible = true
                        });
                    }
                    GraphicsCollection.SecondaryAxesY.Add(new DevExpress.Xpf.Charts.SecondaryAxisY2D()
                    {
                        Alignment = DevExpress.Xpf.Charts.AxisAlignment.Near, Title = new DevExpress.Xpf.Charts.AxisTitle()
                        {
                            Content = (inputData.Items[i] as GraphOptions).NameOfGraph.Text
                        }, GridLinesVisible = true, GridLinesMinorVisible = true
                    });
                    GraphicsCollection.Series.Add(new DevExpress.Xpf.Charts.LineStepSeries2D()
                    {
                        DisplayName = (inputData.Items[i] as GraphOptions).NameOfGraph.Text, ArgumentDataMember = "X", ValueDataMember = "Y", DataSource = PointsCollectionForGraphs[i]                                                                         /*, CrosshairLabelPattern = " {S} - Время: {A} сек - {V}"*/
                    });
                    DevExpress.Xpf.Charts.XYDiagram2D.SetSeriesPane((DevExpress.Xpf.Charts.XYSeries)GraphicsCollection.Series[i], GraphicsCollection.Panes[i - 1]);
                    DevExpress.Xpf.Charts.XYDiagram2D.SetSeriesAxisY(((DevExpress.Xpf.Charts.XYSeries)GraphicsCollection.Series[i]), GraphicsCollection.SecondaryAxesY[i - 1]);
                    if (GraphicsCollection.SecondaryAxesY[i - 1].ActualWholeRange.ActualMinValueInternal == 0)
                    {
                        GraphicsCollection.SecondaryAxesY[i - 1].ActualWholeRange.SetMinMaxValues(0 - (GraphicsCollection.SecondaryAxesY[i - 1].ActualWholeRange.ActualMaxValueInternal * 0.1), GraphicsCollection.SecondaryAxesY[i - 1].ActualWholeRange.ActualMaxValueInternal);
                    }
                }
            }

            GraphicsCollection.ShowCrosshair(new Point(0.1, 1));
            xaml += @"</Grid.RowDefinitions >
                               </Grid >
                       </ItemsPanelTemplate > ";
            GraphicsCollection.PanesPanel = (System.Windows.Markup.XamlReader.Parse(xaml) as ItemsPanelTemplate);


            //PointsCollectionForGraphs[0].Add(new MKIO_visual.Graphs.myPoint(0, 0));
        }