Esempio n. 1
0
 void skin_Click(object sender, EventArgs e)
 {
     CommonHandler.Skin_Name = (sender as ToolStripMenuItem).Text;
     LookAndFeel.SetSkinStyle((sender as ToolStripMenuItem).Text);
 }
Esempio n. 2
0
        private void _drawRadar()
        {
            ChartModel model = Model;

            List <UIElement> dataElems = DataElements;
            bool             animate = (AnimationDuration > 0);
            double           marginLeft = MarginLeft, marginTop = MarginTop;
            double           gridWidth  = (ChartCanvas.Width - marginLeft - MarginRight);
            double           gridHeight = (ChartCanvas.Height - marginTop - MarginBottom);

            double cx = marginLeft + gridWidth / 2.0, cy = marginTop + gridHeight / 2.0;
            double radius = Math.Min(gridWidth, gridHeight) / 2.0;

            bool        isRadarArea = (Type == Chart.ChartType.RADAR_AREA);
            LookAndFeel lf          = CurrentLookAndFeel;
            string      pathXAML    = isRadarArea ? lf.GetAreaPathXAML() : lf.GetLinePathXAML();

            string lineDotXAML = null;

            string[] seriesLabels = model.SeriesLabels;
            int      seriesCount  = seriesLabels.Length;

            Color [] seriesColors = model.SeriesColors;
            double[,] yValues = model.YValues;
            double minValue = model.MinYValue, maxValue = model.MaxYValue;

            string          gradientXAML = lf.GetElementGradientXAML();
            MatrixTransform defaultTransform = null;

            int    yValueCount = yValues.GetUpperBound(0) + 1;
            double dx, dy;

            if (!isRadarArea)
            {
                lineDotXAML = CurrentLookAndFeel.GetLineDotXAML();
            }

            if (animate && _dotElements == null)
            {
                _dotElements = new UIElement[seriesCount, yValueCount];
            }

            for (int i = 0; i < seriesCount; ++i)
            {
                StringBuilder sb = new StringBuilder();

                for (int j = 0; j < yValueCount; ++j)
                {
                    double yPoint = radius * (yValues[j, i] - minValue) / (maxValue - minValue);

                    dx = cx + yPoint * Math.Sin((j) * 2 * Math.PI / yValueCount);
                    dy = cy - yPoint * Math.Cos((j) * 2 * Math.PI / yValueCount);

                    if (j == 0)
                    {
                        sb.Append("M").Append(dx).Append(",").Append(dy);
                    }
                    else
                    {
                        sb.Append(" L").Append(dx).Append(",").Append(dy);
                    }

                    if (!isRadarArea)
                    {
                        Path            dotElem = XamlReader.Load(lineDotXAML) as Path;
                        EllipseGeometry eg      = dotElem.Data as EllipseGeometry;
                        eg.Center = new Point(dx, dy);

                        if (gradientXAML != null)
                        {
                            SetGradientOnElement(dotElem, gradientXAML, seriesColors[i], 0xe5);
                        }
                        else
                        {
                            SetFillOnElement(dotElem, seriesColors[i]);
                        }
                        dotElem.SetValue(Path.StrokeProperty, new SolidColorBrush(seriesColors[i]));

                        if (animate)
                        {
                            _dotElements[i, j] = dotElem;
                            defaultTransform   = new MatrixTransform();
                            Matrix m = new Matrix();
                            m.M11 = m.M22 = 0.0;
                            defaultTransform.Matrix = m;
                            dotElem.SetValue(UIElement.RenderTransformProperty, defaultTransform);
                        }
                        ChartCanvas.Children.Add(dotElem);
                    }
                }
                sb.Append("Z");

                Path pathElem = CreatePathFromXAMLAndData(pathXAML, sb);

                if (animate)
                {
                    dataElems.Add(pathElem);
                    defaultTransform = new MatrixTransform();
                    Matrix m = new Matrix();
                    m.M11 = m.M22 = 0.0;
                    defaultTransform.Matrix = m;
                    pathElem.SetValue(UIElement.RenderTransformProperty, defaultTransform);
                }

                if (isRadarArea)
                {
                    if (gradientXAML != null)
                    {
                        SetGradientOnElement(pathElem, gradientXAML, seriesColors[i], 0x72);
                    }
                    else
                    {
                        SetFillOnElement(pathElem, seriesColors[i]);
                    }
                }


                pathElem.SetValue(Path.StrokeProperty, new SolidColorBrush(seriesColors[i]));
                (pathElem.Data as PathGeometry).FillRule = FillRule.Nonzero;

                SetExpandosOnElement(pathElem, -1, i, new Point());

                if (DisplayToolTip)
                {
                    pathElem.MouseMove  += new MouseEventHandler(ShowToolTip);
                    pathElem.MouseLeave += new MouseEventHandler(HideToolTip);
                }

                pathElem.MouseLeftButtonUp += new MouseButtonEventHandler(ChartDataClicked);

                ChartCanvas.Children.Add(pathElem);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// The load look and feel settings.
        /// </summary>
        private static void LoadLookAndFeelSettings()
        {
            try
            {
                string path = FileSystemPaths.PathSettings + "LookAndFeel.txt";

                if (!File.Exists(path))
                {
                    return;
                }

                string json = IO.ReadTextFromFile(path);

                lookAndFeel = JsonConvert.DeserializeObject(json, typeof(LookAndFeel)) as LookAndFeel;
            }
            catch (Exception exception)
            {
                XtraMessageBox.Show("Failed to load LookAndFeel settings. Please check log for more info.");
                Log.WriteToLog(LogSeverity.Error, 0, exception.Message, exception.StackTrace);
            }
        }
Esempio n. 4
0
        protected override void CreateTextMarkerGroup(Canvas gauge, double gaugeR)
        {
            ChartModel model = Model;
            Canvas     gElem = new Canvas();

            gauge.Children.Add(gElem);

            LookAndFeel lf = CurrentLookAndFeel;

            int    majorMarkerCount = YMajorGridCount;
            int    minorMarkerCount = YMinorGridCount;
            string majorMarkerXAML  = lf.GetGauageMarkerMajorXAML(),
                   minorMarkerXAML  = lf.GetGauageMarkerMinorXAML();
            string    textXAML      = lf.GetGauageTextXAML();
            TextBlock textElem;

            Canvas markerContainerCanvas = gauge.FindName("markerContainer") as Canvas;

            double markerContainerR = markerContainerCanvas.Width / 2;
            double minValue = model.MinYValue, maxValue = model.MaxYValue;

            double x, y, angle, textMargin = 0.0;

            for (int i = 0; i <= majorMarkerCount; ++i)
            {
                double theta = i * Math.PI / majorMarkerCount;
                x     = gaugeR - markerContainerR * (Math.Cos(theta));
                y     = gaugeR - markerContainerR * (Math.Sin(theta));
                angle = theta * 180 / Math.PI;

                Path marker = XamlReader.Load(majorMarkerXAML) as Path;

                TransformGroup     tg = new TransformGroup();
                TranslateTransform tt = new TranslateTransform();
                RotateTransform    rt = new RotateTransform();

                tt.X     = x;
                tt.Y     = y;
                rt.Angle = angle;
                tg.Children.Add(rt);
                tg.Children.Add(tt);
                marker.RenderTransform = tg;
                gElem.Children.Add(marker);


                double value = minValue + i * (maxValue - minValue) / (majorMarkerCount);

                textElem      = XamlReader.Load(textXAML) as TextBlock;
                textElem.Text = value.ToString(Format);

                if (i == 0)
                {
                    textMargin = textElem.ActualHeight / 2;
                }
                x = gaugeR - (markerContainerR - textMargin) * (Math.Cos(theta));
                y = gaugeR - (markerContainerR - textMargin) * (Math.Sin(theta));

                if (theta >= Math.PI / 3 && theta <= 2 * Math.PI / 3)
                {
                    x -= textElem.ActualWidth / 2;
                }
                else
                {
                    y -= textElem.ActualHeight / 2;
                    if (theta < Math.PI / 2)
                    {
                        x += 2 * _TEXT_MARGIN;
                    }
                    else
                    {
                        x -= textElem.ActualWidth + 2 * _TEXT_MARGIN;
                    }
                }

                tt   = new TranslateTransform();
                tt.X = x;
                tt.Y = y;

                textElem.RenderTransform = tt;
                gElem.Children.Add(textElem);
            }

            for (int i = 1; i <= (majorMarkerCount) * minorMarkerCount; ++i)
            {
                if (i % minorMarkerCount == 0)
                {
                    continue;
                }

                double theta = i * Math.PI / (majorMarkerCount * minorMarkerCount);
                x = gaugeR - markerContainerR * (Math.Cos(theta));
                y = gaugeR - markerContainerR * (Math.Sin(theta));

                angle = theta * 180 / Math.PI;

                Path               marker = XamlReader.Load(minorMarkerXAML) as Path;
                TransformGroup     tg     = new TransformGroup();
                TranslateTransform tt     = new TranslateTransform();
                RotateTransform    rt     = new RotateTransform();

                tt.X     = x;
                tt.Y     = y;
                rt.Angle = angle;
                tg.Children.Add(rt);
                tg.Children.Add(tt);
                marker.RenderTransform = tg;
                gElem.Children.Add(marker);
            }
        }
Esempio n. 5
0
        private void _drawPerspectiveLines(int mod, int rem)
        {
            bool   animate = (this.AnimationDuration > 0);
            double xOffset = XOffsetPerspective, yOffset = YOffsetPerspective;

            double marginLeft = MarginLeft, marginTop = MarginTop;
            double marginRight = MarginRight, marginBottom = MarginBottom;

            double           gridWidth  = (ChartCanvas.Width - marginLeft - marginRight - xOffset);
            double           gridHeight = (ChartCanvas.Height - marginTop - marginBottom - yOffset);
            LookAndFeel      lf         = CurrentLookAndFeel;
            string           pathXAML   = lf.GetLinePath3DXAML();
            Path             pathElem;
            List <UIElement> dataElems        = null;
            MatrixTransform  defaultTransform = null;

            if (animate)
            {
                dataElems = DataElements;
            }

            ChartModel model = Model;

            string[] groupLabels = model.GroupLabels;
            int      groupCount  = groupLabels.Length;

            string[] seriesLabels = model.SeriesLabels;
            int      seriesCount  = seriesLabels.Length;

            Color[] seriesColors = model.SeriesColors;
            double[,] yValues = model.YValues;

            double minValue = model.MinYValue, maxValue = model.MaxYValue;

            // For combo graphs we display every once in mod
            int seriesBars = (mod > 1) ? (int)Math.Ceiling(1 / (double)mod) : seriesCount;

            int yValueCount = yValues.GetUpperBound(0) + 1;

            string gradientXAML = lf.GetElementGradientXAML();

            double barWidth = (gridWidth / Math.Max(yValueCount, groupCount));
            double gridBottom = gridHeight + marginTop + yOffset, dx, dy;

            for (int i = 0; i < seriesCount; ++i)
            {
                // for combo charts we draw a bar every once in a mod.
                if ((mod > 1) && (i % mod) != rem)
                {
                    continue;
                }

                dx = marginLeft + barWidth / 2;

                StringBuilder sb = new StringBuilder();

                for (int j = 0; j < yValueCount; ++j)
                {
                    dy = gridBottom - gridHeight * (yValues[j, i] - minValue) / (maxValue - minValue);

                    if (j != yValueCount - 1)
                    {
                        sb.Append("M").Append(dx).Append(",").Append(dy);
                        sb.Append(" l").Append(xOffset).Append(",").Append(-yOffset);

                        var nextdy = gridBottom - gridHeight * (yValues[j + 1, i] - minValue) / (maxValue - minValue);
                        var nextdx = dx + barWidth;

                        sb.Append(" L").Append(nextdx + xOffset).Append(",").Append(nextdy - yOffset);
                        sb.Append(" L").Append(nextdx).Append(",").Append(nextdy);
                        sb.Append(" L").Append(dx).Append(",").Append(dy);
                        dx += barWidth;
                    }
                }
                pathElem = CreatePathFromXAMLAndData(pathXAML, sb);

                if (gradientXAML != null)
                {
                    SetGradientOnElement(pathElem, gradientXAML, seriesColors[i], 0xC0);
                }
                else
                {
                    SetFillOnElement(pathElem, seriesColors[i]);
                }
                pathElem.SetValue(Path.StrokeProperty, new SolidColorBrush(seriesColors[i]));
                (pathElem.Data as PathGeometry).FillRule = FillRule.Nonzero;

                SetExpandosOnElement(pathElem, -1, i, new Point());

                if (DisplayToolTip)
                {
                    pathElem.MouseMove  += new MouseEventHandler(ShowToolTip);
                    pathElem.MouseLeave += new MouseEventHandler(HideToolTip);
                }

                pathElem.MouseLeftButtonUp += new MouseButtonEventHandler(ChartDataClicked);

                if (animate)
                {
                    dataElems.Add(pathElem);
                    defaultTransform = new MatrixTransform();
                    Matrix m = new Matrix();
                    m.M11 = 0.0;
                    defaultTransform.Matrix = m;
                    pathElem.SetValue(UIElement.RenderTransformProperty, defaultTransform);
                }
                ChartCanvas.Children.Add(pathElem);
            }
        }
Esempio n. 6
0
        private void _drawLines(int mod, int rem)
        {
            bool animate = (this.AnimationDuration > 0);

            double marginLeft = MarginLeft, marginTop = MarginTop;
            double marginRight = MarginRight, marginBottom = MarginBottom;

            double      gridWidth = (ChartCanvas.Width - marginLeft - marginRight);
            double      gridHeight = (ChartCanvas.Height - marginTop - marginBottom);
            LookAndFeel lf = CurrentLookAndFeel;
            string      lineDotXAML = lf.GetLineDotXAML(),
                        pathXAML = lf.GetLinePathXAML();
            Path             pathElem, dotElement;
            List <UIElement> dataElems        = null;
            MatrixTransform  defaultTransform = null;

            if (animate)
            {
                dataElems = DataElements;
            }

            bool       isStacked = (Type == ChartType.AREA_STACKED);
            ChartModel model     = Model;

            string[] groupLabels = model.GroupLabels;
            int      groupCount  = groupLabels.Length;

            string[] seriesLabels = model.SeriesLabels;
            int      seriesCount  = seriesLabels.Length;

            Color[] seriesColors = model.SeriesColors;
            double[,] yValues = model.YValues;

            double minValue = model.MinYValue, maxValue = model.MaxYValue;

            int yValueCount = yValues.GetUpperBound(0) + 1;

            string gradientXAML = lf.GetElementGradientXAML();
            double barWidth = gridWidth / Math.Max(yValueCount, groupCount);
            double dx, dy;

            for (int i = 0; i < seriesCount; ++i)
            {
                // for combo charts we draw a bar every once in a mod.
                if ((mod > 1) && (i % mod) != rem)
                {
                    continue;
                }

                dx = marginLeft + barWidth / 2;

                StringBuilder sb = new StringBuilder();

                for (int j = 0; j < yValueCount; ++j)
                {
                    dy = gridHeight + marginTop - gridHeight * (yValues[j, i] - minValue) / (maxValue - minValue);

                    if (j == 0)
                    {
                        sb.Append("M").Append(dx).Append(",").Append(dy);
                    }
                    else
                    {
                        sb.Append("L").Append(dx).Append(",").Append(dy);
                    }

                    dotElement = XamlReader.Load(lineDotXAML) as Path;
                    EllipseGeometry rectG = dotElement.Data as EllipseGeometry;
                    rectG.Center = new Point(dx, dy);

                    if (gradientXAML != null)
                    {
                        SetGradientOnElement(dotElement, gradientXAML, seriesColors[i], 0xe5);
                    }
                    else
                    {
                        SetFillOnElement(dotElement, seriesColors[i]);
                    }

                    dotElement.SetValue(Path.StrokeProperty, new SolidColorBrush(seriesColors[i]));

                    if (animate)
                    {
                        dataElems.Add(dotElement);
                        defaultTransform = new MatrixTransform();
                        Matrix m = new Matrix();
                        m.M11 = 0.0;
                        defaultTransform.Matrix = m;
                        dotElement.SetValue(UIElement.RenderTransformProperty, defaultTransform);
                    }
                    ChartCanvas.Children.Add(dotElement);

                    dx += barWidth;
                }

                pathElem = CreatePathFromXAMLAndData(pathXAML, sb);
                // There is no fill for lines
                pathElem.SetValue(Path.StrokeProperty, new SolidColorBrush(seriesColors[i]));

                SetExpandosOnElement(pathElem, -1, i, new Point());
                if (DisplayToolTip)
                {
                    pathElem.MouseMove  += new MouseEventHandler(ShowToolTip);
                    pathElem.MouseLeave += new MouseEventHandler(HideToolTip);
                }
                pathElem.MouseLeftButtonUp += new MouseButtonEventHandler(ChartDataClicked);

                if (animate)
                {
                    dataElems.Add(pathElem);
                    defaultTransform = new MatrixTransform();
                    Matrix m = new Matrix();
                    m.M11 = 0.0;
                    defaultTransform.Matrix = m;
                    pathElem.SetValue(UIElement.RenderTransformProperty, defaultTransform);
                }
                ChartCanvas.Children.Add(pathElem);
            }
        }
Esempio n. 7
0
 public bool ShouldSerializeLookAndFeel()
 {
     return(LookAndFeel != null && LookAndFeel.ShouldSerialize());
 }
Esempio n. 8
0
        public override void DrawChartData()
        {
            // calculate the number of rows and columns
            ChartModel model = Model;

            double [,] yValues = model.YValues;
            int yValueCount = yValues.GetUpperBound(0) + 1;

            string[] groupLabels = model.GroupLabels;
            int      groupCount  = (groupLabels != null)?groupLabels.Length:1;

            int nCols = (int)Math.Ceiling(Math.Sqrt(yValueCount)),
                nRows = (int)Math.Round(Math.Sqrt(yValueCount));

            double dx = MarginLeft, dy = MarginTop;
            double quadWidth = (ChartCanvas.Width - MarginLeft - MarginRight) / (double)nCols;

            // We do not need any gap for 3D pie chart because of the vertical scaling
            double      vGap       = IsPerspective?0:2.0 * _TEXT_MARGIN;
            double      quadHeight = (ChartCanvas.Height - MarginTop - MarginBottom - (nRows - 1) * vGap) / (double)nRows;
            LookAndFeel lf         = CurrentLookAndFeel;
            string      labelXAML  = lf.GetGroupLabelXAML();
            TextBlock   labelElem  = null;

            for (int i = 0; i < nRows; ++i)
            {
                for (int j = 0; j < nCols; ++j)
                {
                    int iGroup = (groupLabels != null)?(i * nCols + j):(-1);
                    if (iGroup >= yValueCount)
                    {
                        break;
                    }

                    string groupLabel = (iGroup == -1)?null:groupLabels[iGroup];

                    Canvas fnlContainer = new Canvas();

                    ChartCanvas.Children.Add(fnlContainer);

                    double newHeight = DrawGroupLabelTitle(groupLabel, ChartCanvas, labelXAML, ref labelElem,
                                                           dx, dy, quadWidth, quadHeight);
                    double newWidth = quadWidth - 2 * _TEXT_MARGIN;

                    TranslateTransform transform = new TranslateTransform();
                    if (IsPerspective)
                    {
                        // Top ring has a height of 1/6 that of the width. So we need to compensate for half of it.
                        newHeight -= newWidth / 6;
                        _drawPerspectiveFunnel(fnlContainer, newWidth, newHeight, iGroup);
                        transform.X = (dx + _TEXT_MARGIN);
                        transform.Y = (dy + newWidth / 12);
                    }
                    else
                    {
                        _drawFunnel(fnlContainer, newWidth, newHeight, iGroup);
                        transform.X = dx + _TEXT_MARGIN;
                        transform.Y = dy;
                    }

                    fnlContainer.RenderTransform = transform;
                    dx += quadWidth;
                }
                dx  = MarginLeft;
                dy += quadHeight + vGap;
            }
        }
Esempio n. 9
0
        private void _drawPerspectiveBars(int mod, int rem)
        {
            bool   animate = (this.AnimationDuration > 0);
            double xOffset = XOffsetPerspective, yOffset = YOffsetPerspective;

            double marginLeft = MarginLeft, marginTop = MarginTop;
            double marginRight = MarginRight, marginBottom = MarginBottom;

            double           gridWidth  = (ChartCanvas.Width - marginLeft - marginRight - xOffset);
            double           gridHeight = (ChartCanvas.Height - marginTop - marginBottom - yOffset);
            LookAndFeel      lf         = CurrentLookAndFeel;
            string           pathXAML   = lf.GetBarPathXAML();
            Path             pathElem;
            List <UIElement> dataElems        = null;
            MatrixTransform  defaultTransform = null;

            if (animate)
            {
                dataElems = DataElements;
            }

            int  barItemPadding = _BARITEM_PADDING;
            bool isStacked      = (Type == ChartType.VBAR_STACKED);

            ChartModel model = Model;

            string [] groupLabels = model.GroupLabels;
            int       groupCount  = groupLabels.Length;

            string [] seriesLabels = model.SeriesLabels;
            int       seriesCount  = seriesLabels.Length;

            Color [] seriesColors = model.SeriesColors;
            double[,] yValues = model.YValues;

            double minValue = model.MinYValue, maxValue = model.MaxYValue;

            // For combo graphs we display every once in mod
            int    seriesBars = (mod > 1) ? (int)Math.Ceiling(seriesCount / (double)mod) : seriesCount;
            double barWidth;

            int yValueCount = yValues.GetUpperBound(0) + 1;

            if (isStacked)
            {
                barWidth = gridWidth / Math.Max(yValueCount, groupCount) - 2 * barItemPadding;
            }
            else
            {
                barWidth = (gridWidth / Math.Max(yValueCount, groupCount) - 2 * barItemPadding - (seriesBars) * barItemPadding) / seriesBars;
            }

            double dx = marginLeft, dy, barHeight, stackBase = minValue;
            string gradientXAML = lf.GetElementGradientXAML();

            for (int i = 0; i < yValueCount; ++i)
            {
                dx += barItemPadding;
                dy  = gridHeight + marginTop + yOffset;
                for (int j = 0; j < seriesCount; ++j)
                {
                    // for combo charts we draw a bar every once in a mod.
                    if ((mod > 1) && j % mod != rem)
                    {
                        continue;
                    }

                    // If we use non zero min and it is a stacked graph, we need to remove the min for only
                    // the first series.
                    if (isStacked)
                    {
                        stackBase = (j == 0?minValue:0);
                    }

                    barHeight = gridHeight * (yValues[i, j] - stackBase) / (maxValue - minValue);
                    if (isStacked)
                    {
                        dy -= barHeight;
                    }
                    else
                    {
                        dy = gridHeight + yOffset + marginTop - barHeight;
                    }



                    StringBuilder sb = new StringBuilder();
                    Get3DBarPathData(sb, dx, dy, xOffset, yOffset, barWidth, barHeight);
                    pathElem = CreatePathFromXAMLAndData(lf.GetBarPathXAML(), sb);

                    if (animate)
                    {
                        dataElems.Add(pathElem);
                        defaultTransform = new MatrixTransform();
                        Matrix m = new Matrix();
                        m.M22 = 0.0;
                        defaultTransform.Matrix = m;
                        pathElem.SetValue(UIElement.RenderTransformProperty, defaultTransform);
                    }

                    pathElem.SetValue(Path.StrokeProperty, new SolidColorBrush(seriesColors[j]));

                    if (gradientXAML != null)
                    {
                        SetGradientOnElement(pathElem, gradientXAML, seriesColors[j], 0xe5);
                    }
                    else
                    {
                        SetFillOnElement(pathElem, seriesColors[j]);
                    }

                    (pathElem.Data as PathGeometry).FillRule = FillRule.Nonzero;

                    SetExpandosOnElement(pathElem, i, j, new Point(dx + (xOffset + barWidth) / 2.0, dy - yOffset / 2.0));

                    if (DisplayToolTip)
                    {
                        pathElem.MouseEnter += new MouseEventHandler(ShowToolTip);
                        pathElem.MouseLeave += new MouseEventHandler(HideToolTip);
                    }

                    pathElem.MouseLeftButtonUp += new MouseButtonEventHandler(ChartDataClicked);

                    ChartCanvas.Children.Add(pathElem);
                    if (!isStacked)
                    {
                        dx += barWidth;
                        dx += barItemPadding;
                    }
                }

                if (isStacked)
                {
                    dx += barWidth;
                }
                dx += barItemPadding;
            }
        }
Esempio n. 10
0
        private void _drawBars(int mod, int rem)
        {
            bool animate = (this.AnimationDuration > 0);

            double marginLeft = MarginLeft, marginTop = MarginTop;
            double marginRight = MarginRight, marginBottom = MarginBottom;

            double gridWidth  = (ChartCanvas.Width - marginLeft - marginRight);
            double gridHeight = (ChartCanvas.Height - marginTop - marginBottom);

            LookAndFeel      lf       = CurrentLookAndFeel;
            string           rectXAML = lf.GetBarPathXAML();
            Path             rectElem;
            List <UIElement> dataElems        = null;
            MatrixTransform  defaultTransform = null;

            if (animate)
            {
                dataElems = DataElements;
            }

            int  barItemPadding = _BARITEM_PADDING;
            bool isStacked      = (Type == ChartType.VBAR_STACKED);

            ChartModel model = Model;

            string[] groupLabels = model.GroupLabels;
            int      groupCount  = groupLabels.Length;

            string[] seriesLabels = model.SeriesLabels;
            int      seriesCount  = seriesLabels.Length;

            Color[] seriesColors = model.SeriesColors;
            double[,] yValues = model.YValues;

            double minValue = model.MinYValue, maxValue = model.MaxYValue;

            // For combo graphs we display every once in mod
            double barDivider  = isStacked ? 1 : ((mod > 1) ? Math.Ceiling(seriesCount / (double)mod) : seriesCount);
            int    yValueCount = yValues.GetUpperBound(0) + 1;
            double barWidth    = (gridWidth / Math.Max(yValueCount, groupCount) - 2 * barItemPadding) / barDivider;

            double dx = marginLeft, dy, barHeight, stackBase = minValue;
            string gradientXAML = lf.GetElementGradientXAML();

            for (int i = 0; i < yValueCount; ++i)
            {
                dx += barItemPadding;
                dy  = gridHeight + marginTop;

                for (int j = 0; j < seriesCount; ++j)
                {
                    // for combo charts we draw a bar every once in a mod.
                    if ((mod > 1) && (j % mod) != rem)
                    {
                        continue;
                    }

                    // If we use non zero min and it is a stacked graph, we need to remove the min for only
                    // the first series.
                    if (isStacked)
                    {
                        stackBase = (j == 0?minValue:0);
                    }

                    rectElem = XamlReader.Load(rectXAML) as Path;
                    if (animate)
                    {
                        dataElems.Add(rectElem);

                        // FIXTHIS: This is inefficient. However Silverlight currently does not allow sharing transform attribute
                        defaultTransform = new MatrixTransform();
                        Matrix m = new Matrix();
                        m.M22 = 0.0;
                        defaultTransform.Matrix = m;
                        rectElem.SetValue(UIElement.RenderTransformProperty, defaultTransform);
                    }

                    barHeight = gridHeight * (yValues[i, j] - stackBase) / (maxValue - minValue);
                    if (isStacked)
                    {
                        dy -= barHeight;
                    }
                    else
                    {
                        dy = gridHeight + marginTop - barHeight;
                    }

                    RectangleGeometry rectGeometry = new RectangleGeometry();
                    rectGeometry.RadiusX = rectGeometry.RadiusY = 2;
                    rectGeometry.Rect    = new Rect(dx, dy, barWidth, barHeight);

                    rectElem.SetValue(Path.DataProperty, rectGeometry);

                    if (gradientXAML != null)
                    {
                        SetGradientOnElement(rectElem, gradientXAML, seriesColors[j], 0xe5);
                    }
                    else
                    {
                        SetFillOnElement(rectElem, seriesColors[j]);
                    }

                    rectElem.Stroke = new SolidColorBrush(seriesColors[j]);

                    SetExpandosOnElement(rectElem, i, j, new Point(dx + barWidth / 2.0, dy));

                    if (DisplayToolTip)
                    {
                        rectElem.MouseEnter += new MouseEventHandler(ShowToolTip);
                        rectElem.MouseLeave += new MouseEventHandler(HideToolTip);
                    }

                    rectElem.MouseLeftButtonUp += new MouseButtonEventHandler(ChartDataClicked);
                    ChartCanvas.Children.Add(rectElem);

                    if (!isStacked)
                    {
                        dx += barWidth;
                    }
                }
                if (isStacked)
                {
                    dx += barWidth;
                }
                dx += barItemPadding;
            }
        }
Esempio n. 11
0
        DialogResult ShowMessageBoxDialog()
        {
            if (Message.GetLookAndFeel() != null)
            {
                LookAndFeel.Assign(Message.GetLookAndFeel());
            }
            if (!AllowCustomLookAndFeel)
            {
                if (LookAndFeel.ActiveStyle != ActiveLookAndFeelStyle.Skin)
                {
                    ActiveLookAndFeelStyle active = UserLookAndFeel.Default.ActiveStyle;
                    if (active == ActiveLookAndFeelStyle.Office2003)
                    {
                        LookAndFeel.SetStyle(LookAndFeelStyle.Office2003, true, false, "");
                    }
                    else
                    {
                        LookAndFeel.SetDefaultStyle();
                    }
                }
            }
            this.Text       = Message.Caption;
            FormBorderStyle = FormBorderStyle.FixedSingle;
            MinimizeBox     = false;
            MaximizeBox     = false;
            IWin32Window owner = Message.Owner;

            if (owner == null)
            {
                Form activeForm = Form.ActiveForm;
                if (activeForm != null && !activeForm.InvokeRequired)
                {
                    owner = activeForm;
                }
            }
            if (owner != null)
            {
                Control ownerControl = owner as Control;
                if (ownerControl != null)
                {
                    if (!ownerControl.Visible)
                    {
                        owner = null;
                    }
                    else
                    {
                        Form ownerForm = ownerControl.FindForm();
                        if (ownerForm != null)
                        {
                            if ((!ownerForm.Visible) ||
                                ownerForm.WindowState == FormWindowState.Minimized ||
                                ownerForm.Right <= 0 ||
                                ownerForm.Bottom <= 0)
                            {
                                owner = null;
                            }
                        }
                    }
                }
            }
            if (owner == null)
            {
                ShowInTaskbar = true;
                StartPosition = FormStartPosition.CenterScreen;
            }
            else
            {
                ShowInTaskbar = false;
                StartPosition = FormStartPosition.CenterParent;
            }
            CreateButtons();
            CalcIconBounds();
            CalcMessageBounds();
            CalcFinalSizes();
            Form frm = owner as Form;

            if (frm != null && frm.TopMost)
            {
                this.TopMost = true;
            }
            return(DoShowDialog(owner));

            return(this.ShowDialog(owner));
        }
Esempio n. 12
0
        public override void DrawChartData()
        {
            bool animate = (this.AnimationDuration > 0);

            double marginLeft = MarginLeft, marginTop = MarginTop;
            double marginRight = MarginRight, marginBottom = MarginBottom;

            double gridWidth  = (ChartCanvas.Width - marginLeft - marginRight);
            double gridHeight = (ChartCanvas.Height - marginTop - marginBottom);

            LookAndFeel      lf       = CurrentLookAndFeel;
            string           rectXAML = lf.GetBarPathXAML();
            Path             rectElem;
            List <UIElement> dataElems        = null;
            MatrixTransform  defaultTransform = null;

            if (animate)
            {
                dataElems = DataElements;
            }

            if (!(Model is CandleStickChartModel))
            {
                throw new Exception("model is not a CandleStickChartModel");
            }

            CandleStickChartModel model = Model as CandleStickChartModel;

            string[] groupLabels = model.GroupLabels;
            int      groupCount  = groupLabels.Length;

            string[] seriesLabels = model.SeriesLabels;
            int      seriesCount  = seriesLabels.Length;

            Color[]      seriesColors       = model.SeriesColors;
            double[][][] candleStickYValues = model.CandleStickYValues;


            double minValue = model.MinYValue, maxValue = model.MaxYValue;
            int    yValueCount = candleStickYValues.Length;
            double barWidth    = ((gridWidth - _PADDING_LEFT) / Math.Max(yValueCount, groupCount));

            double dx = marginLeft + _PADDING_LEFT, dy, barStart, barEnd, stackBase = minValue;
            string gradientXAML = lf.GetElementGradientXAML();

            for (int i = 0; i < yValueCount; ++i)
            {
                dy = gridHeight + marginTop;

                // skip over missing values
                if (candleStickYValues[i] != null)
                {
                    for (int j = 0; j < seriesCount; ++j)
                    {
                        rectElem = XamlReader.Load(rectXAML) as Path;
                        double openValue  = candleStickYValues[i][j][0];
                        double closeValue = candleStickYValues[i][j][3];
                        double highValue  = candleStickYValues[i][j][1];
                        double lowValue   = candleStickYValues[i][j][2];

                        // use the stock open value
                        barStart = (gridHeight + marginTop) - (gridHeight * (openValue - stackBase) / (maxValue - minValue));
                        // use the stock close value
                        barEnd = (gridHeight + marginTop) - (gridHeight * (closeValue - stackBase) / (maxValue - minValue));

                        bool doFill = openValue > closeValue;

                        RectangleGeometry rectGeometry = new RectangleGeometry();
                        rectGeometry.Rect = new Rect(dx, Math.Min(barStart, barEnd), _CANDLE_WIDTH, Math.Abs(barStart - barEnd));
                        rectElem.SetValue(Path.DataProperty, rectGeometry);

                        if (doFill)
                        {
                            if (gradientXAML != null)
                            {
                                SetGradientOnElement(rectElem, gradientXAML, seriesColors[j], 0xe5);
                            }
                            else
                            {
                                SetFillOnElement(rectElem, seriesColors[j]);
                            }
                        }

                        SolidColorBrush scb = new SolidColorBrush(seriesColors[j]);
                        rectElem.SetValue(Rectangle.StrokeProperty, scb);

                        SetExpandosOnElement(rectElem, i, j,
                                             new Point(dx + _CANDLE_WIDTH / 2.0, Math.Min(barStart, barEnd)));

                        if (DisplayToolTip)
                        {
                            rectElem.MouseEnter += new MouseEventHandler(ShowToolTip);
                            rectElem.MouseLeave += new MouseEventHandler(HideToolTip);
                        }

                        rectElem.MouseLeftButtonUp += new MouseButtonEventHandler(ChartDataClicked);
                        ChartCanvas.Children.Add(rectElem);

                        // Draw the sticks for the candle
                        Line lineTop = new Line(), lineBottom = new Line();
                        if (animate)
                        {
                            dataElems.Add(lineTop);
                            dataElems.Add(lineBottom);
                            dataElems.Add(rectElem);
                            defaultTransform = new MatrixTransform();
                            Matrix m = new Matrix();
                            m.M22 = 0.0;
                            defaultTransform.Matrix = m;

                            lineTop.SetValue(UIElement.RenderTransformProperty, defaultTransform);
                            lineBottom.SetValue(UIElement.RenderTransformProperty, defaultTransform);
                            rectElem.SetValue(UIElement.RenderTransformProperty, defaultTransform);
                        }

                        lineTop.SetValue(Line.StrokeProperty, scb);
                        lineBottom.SetValue(Line.StrokeProperty, scb);

                        lineTop.X1    = lineTop.X2 = lineBottom.X1 = lineBottom.X2 = dx + _CANDLE_WIDTH / 2.0;
                        lineTop.Y1    = doFill ? barStart : barEnd;
                        lineTop.Y2    = (gridHeight + marginTop) - (gridHeight * (highValue - stackBase) / (maxValue - minValue));
                        lineBottom.Y1 = doFill ? barEnd : barStart;
                        lineBottom.Y2 = (gridHeight + marginTop) - (gridHeight * (lowValue - stackBase) / (maxValue - minValue));

                        ChartCanvas.Children.Add(lineTop);
                        ChartCanvas.Children.Add(lineBottom);
                    }
                }
                dx += barWidth;
            }
        }
Esempio n. 13
0
        private void ShowMessageBoxDialog(string caption, string exceptionMessage)
        {
            this.Text        = caption;
            this.messageText = exceptionMessage;
            if (GetLookAndFeel() != null)
            {
                LookAndFeel.Assign(GetLookAndFeel());
            }
            FormBorderStyle = FormBorderStyle.FixedDialog;
            MinimizeBox     = false;
            MaximizeBox     = false;
            IWin32Window owner = Owner;

            if (owner == null)
            {
                Form activeForm = Form.ActiveForm;
                if (activeForm != null && !activeForm.InvokeRequired)
                {
                    owner = activeForm;
                }
            }
            if (owner != null)
            {
                Control ownerControl = owner as Control;
                if (ownerControl != null)
                {
                    if (!ownerControl.Visible)
                    {
                        owner = null;
                    }
                    else
                    {
                        Form ownerForm = ownerControl.FindForm();
                        if (ownerForm != null)
                        {
                            if ((!ownerForm.Visible) ||
                                ownerForm.WindowState == FormWindowState.Minimized ||
                                ownerForm.Right <= 0 ||
                                ownerForm.Bottom <= 0)
                            {
                                owner = null;
                            }
                        }
                    }
                }
            }
            if (owner == null)
            {
                ShowInTaskbar = true;
                StartPosition = FormStartPosition.CenterScreen;
            }
            else
            {
                ShowInTaskbar = false;
                StartPosition = FormStartPosition.CenterParent;
            }
            CreateButtons();
            CalcIconBounds();
            CalcMessageBounds();
            CreateMemo();
            CalcFinalSizes();
            Form frm = owner as Form;

            if (frm != null && frm.TopMost)
            {
                this.TopMost = true;
            }
            ShowDialog(owner);
        }
Esempio n. 14
0
        private void _drawPoints()
        {
            bool animate = (this.AnimationDuration > 0);

            double marginLeft = MarginLeft, marginTop = MarginTop;
            double marginRight = MarginRight, marginBottom = MarginBottom;

            double           gridWidth  = (ChartCanvas.Width - marginLeft - marginRight);
            double           gridHeight = (ChartCanvas.Height - marginTop - marginBottom);
            LookAndFeel      lf         = CurrentLookAndFeel;
            string           dotXAML    = lf.GetScatterDotXAML();
            Path             dotElem;
            List <UIElement> dataElems = null;

            if (animate)
            {
                dataElems = DataElements;
            }

            ChartModel model = Model;

            string [] groupLabels = model.GroupLabels;
            int       groupCount  = groupLabels.Length;

            string [] seriesLabels = model.SeriesLabels;
            int       seriesCount  = seriesLabels.Length;

            Color [] seriesColors = model.SeriesColors;

            double[,] yValues = model.YValues;
            double minYValue = model.MinYValue, maxYValue = model.MaxYValue;
            int    nValues = yValues.GetUpperBound(0) + 1;

            double[,] xValues = model.XValues;
            double minXValue = model.MinXValue, maxXValue = model.MaxXValue;

            double barWidth = (gridWidth / (double)(groupCount - 1));
            double dx, dy, gridCx = 0, gridCy = 0;

            string gradientXAML = lf.GetElementGradientXAML();

            if (animate)
            {
                _cxs   = new double[seriesCount * nValues];
                _cys   = new double[seriesCount * nValues];
                gridCx = gridWidth / 2 + marginLeft;
                gridCy = gridHeight / 2 + marginTop;
            }

            for (int i = 0; i < seriesCount; ++i)
            {
                for (int j = 0; j < nValues; ++j)
                {
                    dy = gridHeight + marginTop - gridHeight * (yValues[j, i] - minYValue) / (maxYValue - minYValue);
                    dx = marginLeft + gridWidth * (xValues[j, i] - minXValue) / (maxXValue - minXValue);

                    dotElem = XamlReader.Load(dotXAML) as Path;

                    EllipseGeometry eg = dotElem.Data as EllipseGeometry;

                    if (gradientXAML != null)
                    {
                        SetGradientOnElement(dotElem, gradientXAML, seriesColors[i], 0xe5);
                    }
                    else
                    {
                        SetFillOnElement(dotElem, seriesColors[i]);
                    }
                    dotElem.SetValue(Path.StrokeProperty, new SolidColorBrush(seriesColors[i]));

                    SetExpandosOnElement(dotElem, j, i, new Point(dx, dy));

                    if (DisplayToolTip)
                    {
                        dotElem.MouseEnter += new MouseEventHandler(ShowToolTip);
                        dotElem.MouseLeave += new MouseEventHandler(HideToolTip);
                    }

                    dotElem.MouseLeftButtonUp += new MouseButtonEventHandler(ChartDataClicked);

                    if (animate)
                    {
                        dataElems.Add(dotElem);
                        eg.Center = new Point(gridCx, gridCy);

                        // we will use it during animation
                        int cIndex = (i * nValues + j);
                        _cxs[cIndex] = dx;
                        _cys[cIndex] = dy;
                    }
                    else
                    {
                        eg.Center = new Point(dx, dy);
                    }
                    ChartCanvas.Children.Add(dotElem);
                }
            }
        }
Esempio n. 15
0
 private void sbtnskin_Click(object sender, EventArgs e)
 {
     LookAndFeel.SetSkinStyle("Stardust");
 }
Esempio n. 16
0
 public static void RegisterLookAndFeel(LookAndFeel lAndF)
 {
   _LookAndFeelMap.Add(lAndF.GetId(), lAndF);
   // set the current look and feel to the newly registered ones
   _currentLookAndFeelId = lAndF.GetId();
   _currentLookAndFeel = lAndF;
 }
Esempio n. 17
0
	  protected internal virtual void uninstallDefaults()
	  {
		  LookAndFeel.uninstallBorder(this.popupPanel);
	  }