Example #1
0
        public bool IsEqual(GraphInfo graphinf)
        {
            bool ret = true;
            if (graphinf.AxisNameX != this.AxisNameX || graphinf.AxisNameY != this.AxisNameY || graphinf.AxisPositionX != this.AxisPositionX
                || graphinf.AxisPositionY != this.AxisPositionY || graphinf.DateTimeFormat != this.DateTimeFormat || graphinf.DecimalPointX != this.DecimalPointX
                || graphinf.DecimalPointY != this.DecimalPointY || graphinf.DistanceX != this.DistanceX || graphinf.DistanceY != this.DistanceY || graphinf.GraphMode != this.GraphMode
                || graphinf.GraphName != this.GraphName || graphinf.GraphNo != this.GraphNo || graphinf.IncrementX != this.IncrementX || graphinf.IsEnabled != this.IsEnabled
                || graphinf.IsLineGraph != this.IsLineGraph || graphinf.MaxChannel != this.MaxChannel || graphinf.MaxDataSizeX != this.MaxDataSizeX || graphinf.MaxValueX != this.MaxValueX
                || graphinf.MaxValueY != this.MaxValueY || graphinf.MeasureButtonShow != this.MeasureButtonShow || graphinf.MinMaxRangeX != this.MinMaxRangeX || graphinf.MinValueX != this.MinValueX
                || graphinf.MinValueY != this.MinValueY || graphinf.PlotCountX != this.PlotCountX || graphinf.ShotCount != this.ShotCount || graphinf.ShowDateTimeAxisX != this.ShowDateTimeAxisX
                || graphinf.ShowValueLabelX != this.ShowValueLabelX || graphinf.ShowValueLabelY != this.ShowValueLabelY)
            {
                ret = false;
            }

            return ret;
        }
Example #2
0
        /// <summary>
        /// Update Graph Info to graph model
        /// </summary>
        /// <param name="graphinfo"></param>
        /// <param name="updateCH"></param>
        public void UpdateGraphInfo(GraphInfo graphinfo, bool updateCH, bool redrawGrid)
        {
            try
            {
                _IsAxisYZoom = false;

                bool isequal = _GraphInfo.IsEqual(graphinfo);
                _Log4NetClass.ShowInfo("isequal", isequal.ToString());
                _Log4NetClass.ShowInfo("graphinfo", graphinfo.ToString());

                _GraphInfo = graphinfo;
                this.IsRealTime = false;
                GraphLib.Model.GraphGridLine gridline = _GraphModel.GridLineData;
                gridline.AxisNameX = _GraphInfo.AxisNameX;
                gridline.AxisNameY = _GraphInfo.AxisNameY;

                gridline.MaxGridValueX = _GraphInfo.MaxValueX;
                gridline.MinGridValueX = _GraphInfo.MinValueX;
                gridline.MaxGridValueY = _GraphInfo.MaxValueY;
                gridline.MinGridValueY = _GraphInfo.MinValueY;

                //Check if AxispoitionX is null set MinValueX to default
                if (_GraphInfo.AxisPositionX != null)
                {
                    //check in range
                    if (_GraphInfo.AxisPositionX >= _GraphInfo.MinValueX && _GraphInfo.AxisPositionX <= _GraphInfo.MaxValueX)
                    {
                        gridline.AxisPositionX = Convert.ToDouble(_GraphInfo.AxisPositionX);
                    }
                    else
                    {
                        _GraphInfo.AxisPositionX = null;
                        gridline.AxisPositionX = null;
                    }

                }
                else
                {
                    _GraphInfo.AxisPositionX = null;
                    gridline.AxisPositionX = null;
                }

                //Check if AxispoitionY is null set MinValueY to default
                if (_GraphInfo.AxisPositionY != null)
                {
                    //check in range
                    if (_GraphInfo.AxisPositionY >= _GraphInfo.MinValueY && _GraphInfo.AxisPositionY <= _GraphInfo.MaxValueY)
                    {
                        gridline.AxisPositionY = Convert.ToDouble(_GraphInfo.AxisPositionY);
                    }
                    else
                    {
                        _GraphInfo.AxisPositionY = null;
                        gridline.AxisPositionY = null;
                    }
                }
                else
                {
                    _GraphInfo.AxisPositionY = null;
                    gridline.AxisPositionY = null;
                }

                _GraphModel.MaxDataSizeX = _GraphInfo.MaxDataSizeX;
                _GraphModel.MaxPlotY = _GraphInfo.MaxValueY;
                _GraphModel.MinPlotY = _GraphInfo.MinValueY;
                _GraphModel.IsEnabled = _GraphInfo.IsEnabled;
                _GraphModel.IsLineGraph = _GraphInfo.IsLineGraph;
                _GraphModel.MaxGraphNo = _GraphInfo.MaxChannel;
                _GraphModel.GridLineData.DecimalPointX = _GraphInfo.DecimalPointX;
                _GraphModel.GridLineData.DecimalPointY = _GraphInfo.DecimalPointY;
                _GraphModel.GraphMode = _GraphInfo.GraphMode;
                _IsShowValueLabelX = _GraphInfo.ShowValueLabelX;
                _IsShowValueLabelY = _GraphInfo.ShowValueLabelY;
                _GraphModel.PlotCountX = _GraphInfo.PlotCountX;
                _IsMeasureButtonShow = _GraphInfo.MeasureButtonShow;
                _ZoomValueX = 0;
                _ZoomValueY = 0;

                if (_GraphInfo.ShotCount <= 0 || _GraphInfo.ShotCount > _MaximumShot)
                    _GraphInfo.ShotCount = 1;

                //Clear graph when change shot
                if (_GraphModel.ShotCount != _GraphInfo.ShotCount)
                {
                    if (this.grid1.Children.Count == 1)
                    {
                        Canvas graphcanvas = this.grid1.Children[0] as Canvas;
                        graphcanvas.Children.Clear();
                    }
                }

                _GraphModel.ShotCount = _GraphInfo.ShotCount;

                _GraphModel.IncrementX = _GraphInfo.IncrementX;

                if (_GraphInfo.DistanceX != 0)
                {
                    if (_DistanceX != _GraphInfo.DistanceX || _MinMaxRangeX != _GraphInfo.PlotCountX)
                    {
                        _DistanceX = _GraphInfo.DistanceX;
                        _GraphModel.GridLineData.DistanceX = Convert.ToDouble(_DistanceX);

                        //_MinMaxRangeX = _GraphInfo.MinMaxRangeX;
                        _MinMaxRangeX = _GraphInfo.PlotCountX;

                        //double maxgrid = (Math.Abs((_GraphModel.GridLineData.MaxGridValueX - _GraphModel.GridLineData.MinGridValueX) / Convert.ToDouble(_DistanceX)));
                        double maxgrid = (_GraphModel.PlotCountX * _GraphModel.IncrementX) / Convert.ToDouble(_DistanceX);
                        if (maxgrid > 0)
                            _GraphModel.GridLineData.MaxGridNoX = maxgrid;

                        if (_GraphModel.GridLineData.MaxGridNoX > _MaxGridNumber)
                            _GraphModel.GridLineData.MaxGridNoX = _MaxGridNumber;
                    }
                }

                //Check X is need show Decimal point
                double diffvalgrid = (_GraphInfo.PlotCountX * _GraphModel.IncrementX) / _GraphModel.GridLineData.MaxGridNoX;
                if (diffvalgrid < 3 && _GraphInfo.DecimalPointX == 0)
                    _GraphInfo.DecimalPointX = 2;

                if (_GraphInfo.DistanceY != 0)
                {
                    if (_DistanceY != _GraphInfo.DistanceY)
                    {
                        _DistanceY = _GraphInfo.DistanceY;
                        _GraphModel.GridLineData.DistanceY = Convert.ToDouble(_DistanceY);
                    }

                    double maxgrid = Math.Abs((_GraphModel.GridLineData.MaxGridValueY - _GraphModel.GridLineData.MinGridValueY) / Convert.ToDouble(_DistanceY));
                    if (maxgrid != 0 && Math.Round(_GraphModel.GridLineData.MaxGridNoY, 4) != Math.Round(maxgrid, 4))
                        _GraphModel.GridLineData.MaxGridNoY = maxgrid;

                    if (_GraphModel.GridLineData.MaxGridNoY > _MaxGridNumber)
                        _GraphModel.GridLineData.MaxGridNoY = _MaxGridNumber;
                }

                _AxisZoomConstValueX = (double)(_GraphModel.PlotCountX * _ZoomPercent * 0.01);

                _GraphController.GraphInfo = graphinfo;

                if (_IsLoadedData && (!_IsRealTime || !_GraphModel.IsEnabled))
                {
                    _GraphController.UpdatePlotData();
                    this.RefreshGraph();

                    //_Log4NetClass.ShowInfo("RefreshGraph", "UpdateGraphInfo");
                }

                //Update Channel
                if (updateCH)
                {
                    if (_GraphInfo.ChannelInfos != null)
                    {
                        bool chkinfosame = CheckChannelInfoIsSame();
                        if (!chkinfosame)
                        {
                            this.Dispatcher.BeginInvoke(new Action(ClearGraph), System.Windows.Threading.DispatcherPriority.Normal, null);
                            _GraphModel.GraphColor = new Color[_GraphInfo.ChannelInfos.Count];
                            _GraphModel.GraphLineSize = new double[_GraphInfo.ChannelInfos.Count];
                            _GraphModel.GraphShow = new bool[_GraphInfo.ChannelInfos.Count];
                            _GraphModel.ChannelNumber = new int[_GraphInfo.ChannelInfos.Count];
                            for (int i = 0; i < _GraphInfo.ChannelInfos.Count; i++)
                            {
                                _GraphModel.ChannelNumber[i] = _GraphInfo.ChannelInfos[i].CHNo;
                                _GraphModel.GraphColor[i] = _GraphInfo.ChannelInfos[i].CHColor;
                                _GraphModel.GraphLineSize[i] = _GraphThickness;
                                //_GraphModel.GraphLineSize[i] = _GraphInfo.ChannelInfos[i].CHLineSize;
                                _GraphModel.GraphShow[i] = _GraphInfo.ChannelInfos[i].IsEnabled;
                            }

                            this.Dispatcher.BeginInvoke(new Action(CreateLegendPanel), System.Windows.Threading.DispatcherPriority.Normal, null);
                            //_Log4NetClass.ShowInfo("chkinfosame False", "UpdateGraphInfo");
                        }
                    }
                }

                if (!isequal && redrawGrid)
                {
                    _ZoomNumberAxisY = 0;
                    _GraphModel.AxisZoomX = 0;
                    _GraphModel.AxisZoomY = 0;
                    this.Dispatcher.BeginInvoke(new Action(UpdateLabelNameX), System.Windows.Threading.DispatcherPriority.Send, null);
                    this.Dispatcher.BeginInvoke(new Action(UpdateLabelNameY), System.Windows.Threading.DispatcherPriority.Send, null);

                    this.Dispatcher.BeginInvoke(new Action(UpdateLabelValueY), System.Windows.Threading.DispatcherPriority.Send, null);
                    this.Dispatcher.BeginInvoke(new Action(UpdateLabelValueX), System.Windows.Threading.DispatcherPriority.Send, null);
                    this.Dispatcher.BeginInvoke(new Action(this.RedrawGraphUpdateGraphInfo), System.Windows.Threading.DispatcherPriority.Send, null);
                    //_Log4NetClass.ShowInfo("isequal False", "UpdateGraphInfo");
                }
            }
            catch (Exception ex)
            {
                _Log4NetClass.ShowError(ex.ToString(), " UpdateGraphInfo(GraphInfo graphinfo, bool updateCH)");
            }
        }