Beispiel #1
0
            public int Compare(DataPoint x, DataPoint y)
            {
                CFuturocomDataPoint fX = x as CFuturocomDataPoint;
                CFuturocomDataPoint fY = y as CFuturocomDataPoint;

                if (fX != null && fY != null)
                {
                    object v1 = fX.ValeurSort;
                    object v2 = fY.ValeurSort;
                    if (v1 != null || v2 != null)
                    {
                        if (v1 == null && v2 != null)
                        {
                            return(-1);
                        }
                        if (v2 == null && v1 != null)
                        {
                            return(1);
                        }
                        if (v1 is IComparable && v2 is IComparable)
                        {
                            return(((IComparable)v1).CompareTo((IComparable)v2));
                        }
                        return(0);
                    }
                }
                return(x.XValue.CompareTo(y.XValue));
            }
Beispiel #2
0
        //------------------------------------------------------------------------


        //------------------------------------------------------------------------
        private void ShowToolTip(CFuturocomDataPoint point, int nX, int nY)
        {
            if (m_lastToolTipPoint != null && m_lastToolTipPoint != point)
            {
                m_lastToolTipPoint.MarkerSize  = m_lastTooltipMarkerSize;
                m_lastToolTipPoint.MarkerStyle = m_lastTooltipMarkerStyle;
            }
            if (point != null && point != m_lastToolTipPoint)
            {
                m_lastTooltipMarkerStyle = point.MarkerStyle;
                m_lastTooltipMarkerSize  = point.MarkerSize;
                point.MarkerStyle        = MarkerStyle.Circle;
                point.MarkerSize         = Math.Max(point.MarkerSize * 2, 3);
                m_chartTooltip.Show(point.CustomToolTip, m_chartControl, nX, nY, 5000);
            }
            if (point == null && m_lastToolTipPoint != null)
            {
                m_chartTooltip.Hide(m_chartControl);
            }
            m_lastToolTipPoint = point;
        }
Beispiel #3
0
        //------------------------------------------------------------------------
        private void m_chartControl_MouseUp(object sender, MouseEventArgs e)
        {
            if (m_chartAreaFor3D != null)
            {
                if (Math.Abs(m_chartAreaFor3D.Area3DStyle.Inclination) <= 3 &&
                    Math.Abs(m_chartAreaFor3D.Area3DStyle.Rotation) <= 3)
                {
                    m_chartAreaFor3D.Area3DStyle.Enable3D = false;
                }
            }
            m_chartAreaFor3D       = null;
            m_chartControl.Capture = false;

            if (m_modeSouris == EModeMouseChart.SimpleMouse && m_bEnableActions)
            {
                HitTestResult test = m_chartControl.HitTest(e.X, e.Y, ChartElementType.DataPoint);
                if (test != null && test.Series != null && test.PointIndex >= 0)
                {
                    CParametreSerieDeChart pSerie = test.Series.Tag as CParametreSerieDeChart;
                    if (pSerie != null && pSerie.ClickAction != null)
                    {
                        try
                        {
                            CFuturocomDataPoint    pt     = test.Series.Points[test.PointIndex] as CFuturocomDataPoint;
                            CValeurPourChartAction valeur = new CValeurPourChartAction();
                            valeur.ValueForAction = pt.ValeurPourAction;
                            CResultAErreur result = CExecuteurActionSur2iLink.ExecuteAction(this,
                                                                                            pSerie.ClickAction, valeur);
                            if (!result)
                            {
                                CFormAlerte.Afficher(result.Erreur);
                            }
                        }
                        catch { }
                    }
                }
            }
        }
Beispiel #4
0
        //------------------------------------------------------------------------
        private void m_chartControl_MouseMove(object sender, MouseEventArgs e)
        {
            if (ModeSouris == EModeMouseChart.Mouse3D &&
                (e.Button & MouseButtons.Left) == MouseButtons.Left &&
                m_chartAreaFor3D != null)
            {
                int nInclination = -m_ptStartDrag.Y + e.Y + m_n3DInclinationStart;
                if (nInclination > 89)
                {
                    nInclination = 89;
                }
                if (nInclination < -89)
                {
                    nInclination = -89;
                }
                int nRotation = (m_ptStartDrag.X - e.X + m_n3DRotationStart);
                if (nRotation < 180)
                {
                    nRotation = 360 + nRotation;
                }
                if (nRotation > 180)
                {
                    nRotation = -360 + nRotation;
                }
                m_chartAreaFor3D.Area3DStyle.Inclination = nInclination;
                m_chartAreaFor3D.Area3DStyle.Rotation    = nRotation;
            }
            if (ModeSouris == EModeMouseChart.Mouse3D &&
                (e.Button & MouseButtons.Right) == MouseButtons.Right &&
                m_chartAreaFor3D != null)
            {
                int nPointDepth  = -m_ptStartDrag.Y + e.Y + m_n3DPointDepthStart;
                int nPerspective = m_ptStartDrag.X - e.X + m_n3DPerspectiveStart;
                if (nPointDepth < 0)
                {
                    nPointDepth = 0;
                }
                if (nPointDepth > 1000)
                {
                    nPointDepth = 1000;
                }
                if (nPerspective > 100)
                {
                    nPerspective = 100;
                }
                if (nPerspective < 0)
                {
                    nPerspective = 0;
                }
                m_chartAreaFor3D.Area3DStyle.PointDepth  = nPointDepth;
                m_chartAreaFor3D.Area3DStyle.Perspective = nPerspective;
            }

            if (ModeSouris == EModeMouseChart.SimpleMouse)
            {
                HitTestResult test = m_chartControl.HitTest(e.X, e.Y, ChartElementType.DataPoint);
                if (test != null && test.Series != null && test.PointIndex >= 0)
                {
                    CFuturocomDataPoint pt = test.Series.Points[test.PointIndex] as CFuturocomDataPoint;
                    ShowToolTip(pt, e.X + (Cursor != null?Cursor.Size.Width:16), e.Y + (Cursor != null?Cursor.Size.Height:16));
                }
                else
                {
                    ShowToolTip(null, e.X, e.Y);
                }
            }
        }
Beispiel #5
0
        //-------------------------------------------------------------------------
        private void UpdateSeries()
        {
            m_bIsCheckingFiltresSeries = true;
            HashSet <string> areasToHide = new HashSet <string>();

            foreach (ChartArea a in m_chartControl.ChartAreas)
            {
                areasToHide.Add(a.Name);
            }
            m_chartControl.Series.Clear();
            foreach (CParametreSerieDeChart pSerie in ChartSetup.Series)
            {
                if (!SerieIsChecked(pSerie))
                {
                    continue;
                }

                Series s = new Series(pSerie.SerieName);
                s.Tag             = pSerie;
                s.ChartType       = CConvertisseurChartEnumToMSEnum.GetMSChartType(pSerie.ChartType);
                s.XAxisType       = CConvertisseurChartEnumToMSEnum.GetMSAxisType(pSerie.XAxisType);
                s.YAxisType       = CConvertisseurChartEnumToMSEnum.GetMSAxisType(pSerie.YAxisType);
                s.IsXValueIndexed = pSerie.IsValueIndexed;
                s.ToolTip         = "";
                if (pSerie.ChartArea != null && pSerie.ChartArea.Length > 0)
                {
                    foreach (ChartArea a in m_chartControl.ChartAreas)
                    {
                        if (a.Name == pSerie.ChartArea)
                        {
                            s.ChartArea = a.Name;
                        }
                        ;
                    }
                }

                s.Legend            = pSerie.LegendArea;
                s.IsVisibleInLegend = pSerie.ShowInLegend;
                if (pSerie.LegendLabel.Length > 0)
                {
                    s.LegendText = pSerie.LegendLabel;
                }
                if (pSerie.LegendTooltip.Length > 0)
                {
                    s.LegendToolTip = pSerie.LegendTooltip;
                }

                s.XValueType = CConvertisseurChartEnumToMSEnum.GetMSChartValueType(pSerie.XValueType);
                s.YValueType = CConvertisseurChartEnumToMSEnum.GetMSChartValueType(pSerie.YValueType);

                List <double>         lstX = GetValues <double>(pSerie.XValues, Double.NaN);
                List <List <double> > lstY = new List <List <double> >();
                lstY.Add(GetValues <double>(pSerie.Y1Values, Double.NaN));
                lstY.Add(GetValues <double>(pSerie.Y1Values, Double.NaN));
                lstY.Add(GetValues <double>(pSerie.Y2Values, Double.NaN));
                lstY.Add(GetValues <double>(pSerie.Y3Values, Double.NaN));
                List <string> lstLabels        = GetValues <string>(pSerie.LabelValues);
                List <string> lstAxisValues    = GetValues <string>(pSerie.AxisLabelValues);
                List <string> lstTooltips      = GetValues <string>(pSerie.ToolTipValues);
                List <object> lstValeursAction = GetValues <object>(pSerie.ActionValues);
                List <object> lstValeursSort   = GetValues <object>(pSerie.SortValues);
                List <object> lstIncludePoint  = GetValues <object>(pSerie.IncludePointValues);

                if (pSerie.XValues == null || lstX.Count == 0)
                {
                    //Ajoute des indices en fonction des valeurs d'axe
                    for (int nIndex = 0; nIndex < lstAxisValues.Count; nIndex++)
                    {
                        lstX.Add(nIndex);
                    }
                }

                List <CFuturocomDataPoint> lstPoints = new List <CFuturocomDataPoint>();
                bool bAllNull = true;
                for (int n = 0; n < lstX.Count; n++)
                {
                    bool          bNullPoint = false;
                    List <double> vals       = new List <double>();
                    foreach (List <double> lstVals in lstY)
                    {
                        if (n < lstVals.Count)
                        {
                            vals.Add(lstVals[n]);
                            if (Double.IsNaN(lstVals[n]))
                            {
                                bNullPoint = true;
                            }
                        }
                        else if (lstVals.Count > 0)
                        {
                            vals.Add(0);
                        }
                    }

                    bool bInclude = true;

                    if (n < lstIncludePoint.Count)
                    {
                        if (lstIncludePoint[n] is bool && !((bool)lstIncludePoint[n]))
                        {
                            bInclude = false;
                        }
                    }
                    if (bInclude)
                    {
                        CFuturocomDataPoint pt = new CFuturocomDataPoint();
                        pt.XValue = lstX[n];
                        if (!bNullPoint)
                        {
                            bAllNull   = false;
                            pt.YValues = vals.ToArray();
                        }
                        else
                        {
                            pt.IsEmpty = true;
                        }
                        if (n < lstLabels.Count)
                        {
                            pt.Label = lstLabels[n] == null ? "" : lstLabels[n];
                        }
                        if (n < lstAxisValues.Count)
                        {
                            pt.AxisLabel = lstAxisValues[n] == null ? "" : lstAxisValues[n];
                        }
                        if (n < lstTooltips.Count)
                        {
                            pt.CustomToolTip = lstTooltips[n] == null ? "" : lstTooltips[n];
                        }
                        if (n < lstValeursAction.Count)
                        {
                            pt.ValeurPourAction = lstValeursAction[n];
                        }
                        if (n < lstValeursSort.Count)
                        {
                            pt.ValeurSort = lstValeursSort[n];
                        }
                        lstPoints.Add(pt);
                    }
                }
                if (bAllNull)
                {
                    lstPoints.Clear();
                }
                lstPoints.Sort(new CPointSorter());
                foreach (CFuturocomDataPoint pt in lstPoints)
                {
                    s.Points.Add(pt);
                }
                if (s.Points.Count != 0)
                {
                    if (s.ChartArea != null && s.ChartArea != "")
                    {
                        areasToHide.Remove(s.ChartArea);
                    }
                    else
                    {
                        areasToHide.Remove(m_chartControl.ChartAreas[0].Name);
                    }
                    ApplyMarkerStyle(pSerie, s);
                    ApplySerieStyle(pSerie, s);
                    ApplyLabelStyle(pSerie, s);
                    ApplyEmptyPointStyle(pSerie, s);
                    ApplyEmptyPointMarkerStyle(pSerie, s);
                    m_chartControl.Series.Add(s);
                    //m_chartControl.DataManipulator.Sort(new CPointSorter(), s);
                    foreach (ListViewItem item in m_wndListeSeries.Items)
                    {
                        if (item.Tag == pSerie)
                        {
                            item.ImageIndex  = 0;
                            item.ToolTipText = "";
                        }
                    }
                }
                else
                {
                    foreach (ListViewItem item in m_wndListeSeries.Items)
                    {
                        if (item.Tag == pSerie)
                        {
                            m_wndListeSeries.ShowItemToolTips = true;
                            item.ImageIndex  = 1;
                            item.ToolTipText = I.T("@1 has no data|20047", item.Text);
                        }
                    }
                }
            }
            foreach (ChartArea a in m_chartControl.ChartAreas)
            {
                a.Visible = !areasToHide.Contains(a.Name);
            }

            m_bIsCheckingFiltresSeries = false;
        }