コード例 #1
0
        private void PaintChart(Graphics graphics)
        {
            if (BarList == null || BarList.Count == 0)
            {
                return;
            }
            var proc       = new BarChartProcessor();
            var headerList = proc.GetFullHeaderList(this.StartDate, this.EndDate, this.Width, this.TimeFont);

            if (headerList.Count == 0 || this.DistinctItemCount == 0)
            {
                return;
            }

            var pixelsPerSecond = proc.GetPixelsPerSecond(headerList);

            this.AvailableWidth = Width - ChartConstants.BarStartLeft - ChartConstants.BarStartRight;

            if (this.DistinctItemCount * (ChartConstants.BarHeight + ChartConstants.BarSpace) > Height)
            {
                this.VScrollBar1.Visible = true;
                this.VScrollBar1.Maximum = this.DistinctItemCount - 3;
            }

            graphics.Clear(BackColor);
            DrawChartHeadersAndNet(graphics, headerList);

            DrawBars(graphics, this.BarList, pixelsPerSecond);
        }
コード例 #2
0
        public void ShowBarChart(DateTime chartStartDate, DateTime chartEndDate, List <ItemModel> items)
        {
            this.StartDate = chartStartDate;
            this.EndDate   = chartEndDate;
            var proc = new BarChartProcessor();

            this.BarList           = proc.GetBarList(items);
            this.DistinctItemCount = items.Select(i => i.ItemName).Distinct().Count();

            this.Refresh();
        }
コード例 #3
0
        private void ChartMouseClick(Object sender, MouseEventArgs e)
        {
            if (BarList == null || BarList.Count == 0)
            {
                return;
            }

            var localMousePosition = new Point(e.X, e.Y);

            var proc = new BarChartProcessor();

            this.BarList = proc.MouseClickHandler(this.BarList, localMousePosition);
        }
コード例 #4
0
        private void ChartMouseMove(Object sender, MouseEventArgs e)
        {
            var localMousePosition = new Point(e.X, e.Y);

            if (BarList == null || BarList.Count == 0)
            {
                return;
            }

            if (localMousePosition == this.OldMousePosition)
            {
                return;
            }

            var proc = new BarChartProcessor();

            var mouseOverObject = false;
            var tempText        = new List <string>();
            var tempTitle       = "";

            Parallel.ForEach(this.BarList, bar =>
            {
                if (proc.MouseInsideBar(localMousePosition, bar) && bar.Visible)
                {
                    bar.IsMouseOver = true;
                    tempTitle       = bar.Name;
                    tempText.Add("Event Start:  " + bar.StartValue.ToUniversalTime());
                    tempText.Add("Event End:   " + bar.EndValue.ToUniversalTime());
                    mouseOverObject = true;
                }
                else
                {
                    bar.IsMouseOver = false;
                }
            });

            this.ToolTipTextList  = tempText;
            this.ToolTipTextTitle = tempTitle;
            this.ToolTip.SetToolTip(this, this.ToolTipTextList.Count > 0 ? this.ToolTipTextList.ToString() : "");

            if (mouseOverObject)
            {
                this.Refresh();
            }

            this.OldMousePosition = localMousePosition;
        }
コード例 #5
0
        private void DrawBars(Graphics graphics, IEnumerable <BarModel> barList, double pixelsPerSecond)
        {
            //list of machineNames to add to the left of each row
            var rowTitleList = new List <string>();

            var proc = new BarChartProcessor();

            // Draws each bar
            foreach (var bar in barList)
            {
                var numberOfBarsInControl = (Height - ChartConstants.BarStartTop) / (ChartConstants.BarHeight + ChartConstants.BarSpace);

                if ((bar.RowIndex >= this.ScrollPosition &&
                     bar.RowIndex < numberOfBarsInControl + this.ScrollPosition))
                {
                    var newBar = proc.GetBar(bar, this.StartDate, pixelsPerSecond, ScrollPosition, this.Width);
                    DrawBarAndRowText(newBar, rowTitleList, graphics);
                }
                else
                {
                    bar.Visible = false;
                }
            }
        }