Exemplo n.º 1
0
 void scheduleView1_TokenMouseLeave(EventToken token, Control sender, Point loc)
 {
     token.IsHighlighted = false;
     scheduleView1.Invalidate();
 }
Exemplo n.º 2
0
        private void drawTokenText(Graphics gc, EventToken token, TokenTextItem item)
        {
            int dispRow = item.Row;
            int dispCol = item.Col;
            int dispWidth = item.Width;
            bool continued = item.Continued;

            bool colHangOver = (LeftColumn > 0 && LeftColumn + DisplayedColumnCount > ColumnCount);
            bool rowHangOver = (TopRow > 0 && TopRow + DisplayedRowCount > RowCount);
            int xLeft = colHangOver ? (ViewRectangle.Width - DisplayedColumnCount * _colWidth) : 0;
            int yTop = rowHangOver ? (ViewRectangle.Height - TrueScaleHeight - DisplayedRowCount * _rowHeight) : 0;

            int x1 = _colWidth * dispCol + xLeft;
            int y1 = TrueScaleHeight + _rowHeight * dispRow + yTop;
            if (x1 < 0)
                x1 = 0;

            string text = (continued ? "<< " : "") + token.Name;
            gc.DrawString(text, (continued ? _italic : _bold),
                token.IsHighlighted ? _fontHighlight : _fontColor,
                new RectangleF(x1 + 2, y1 + 2, dispWidth * _colWidth - 4, _rowHeight - 4),
                new StringFormat() { FormatFlags = StringFormatFlags.NoWrap });
        }
Exemplo n.º 3
0
 void scheduleView1_TokenMouseEnter(EventToken token, Control sender, Point loc)
 {
     token.IsHighlighted = true;
     scheduleView1.Invalidate();
 }
Exemplo n.º 4
0
        private void drawRightToken(Graphics gc, int dispRow, int dispCol, EventToken token, bool edge)
        {
            bool colHangOver = (LeftColumn > 0 && LeftColumn + DisplayedColumnCount > ColumnCount);
            bool rowHangOver = (TopRow > 0 && TopRow + DisplayedRowCount > RowCount);
            int xLeft = colHangOver ? (ViewRectangle.Width - DisplayedColumnCount * _colWidth) : 0;
            int yTop = rowHangOver ? (ViewRectangle.Height - TrueScaleHeight - DisplayedRowCount * _rowHeight) : 0;

            int x2 = _colWidth * (dispCol + 1) + xLeft;
            int x1 = x2 - _colWidth / 2 - 1;
            int y1 = TrueScaleHeight + _rowHeight * dispRow + yTop;
            int y2 = y1 + _rowHeight - 1;

            /*
            gc.FillRectangle(new SolidBrush(token.Color), x1, y1, _colWidth / 2 + 1, _rowHeight);
            gc.DrawLine(Pens.Black, x1, y1, x2, y1);
            gc.DrawLine(Pens.Black, x1, y2, x2, y2);
            if (edge)
                gc.DrawLine(Pens.Black, x2, y1, x2, y2);
             */
            Color def = token.Color, lite = ControlPaint.LightLight(def);
            Color dark = ControlPaint.Dark(def, 0.01f);
            Color main = token.IsHighlighted ? def : lite;
            Brush fillBrush = token.IsHighlighted ? (Brush)(new SolidBrush(main)) :
                new LinearGradientBrush(new Point(0, y1), new Point(0, y2), lite, dark);
            Pen border = new Pen(token.IsHighlighted ? lite : def, token.IsHighlighted ? 2f : 1f);
            if (edge)
            {
                gc.FillRectangle(fillBrush, x1, y1, _colWidth / 2 - 2, _rowHeight);
                gc.FillRectangle(fillBrush, x2 - 3, y1 + 1, 2, _rowHeight - 2);
                gc.FillRectangle(fillBrush, x2 - 1, y1 + 2, 1, _rowHeight - 4);
                gc.FillRectangle(fillBrush, x2, y1 + 4, 1, _rowHeight - 8);
                gc.DrawLine(border, x1, y1, x2 - 4, y1);
                gc.DrawLine(border, x2 - 2, y1 + 1, x2 - 3, y1 + 1);
                gc.DrawLine(border, x2 - 1, y1 + 2, x2 - 1, y1 + 3);
                gc.DrawLine(border, x2, y1 + 4, x2, y2 - 4);
                gc.DrawLine(border, x2 - 1, y2 - 2, x2 - 1, y2 - 3);
                gc.DrawLine(border, x2 - 2, y2 - 1, x2 - 3, y2 - 1);
                gc.DrawLine(border, x1, y2, x2 - 4, y2);
            }
            else
            {
                gc.FillRectangle(fillBrush, x1, y1, _colWidth / 2 + 1, _rowHeight);
                gc.DrawLine(border, x1, y1, x2, y1);
                gc.DrawLine(border, x1, y2, x2, y2);
            }
        }
Exemplo n.º 5
0
        private void insertEvent(int row, ulong time, IScheduleEvent evt)
        {
            var token = new EventToken((int)time, evt, ColorProvider);

            acrossTime(time, (ulong)evt.Length, (ref EventToken[,] block) =>
            {
                if (block == null)
                    block = new EventToken[_rowCount, BlockWidth];
                if (block.GetLength(0) <= row)
                    block = block.Resize(_rowCount, block.GetLength(1));
                return true;
            }, (ref EventToken[,] block, ulong t, int i) =>
            {
                block[row, i] = token;
            });

            if (time + (ulong)evt.Length > ColumnCount)
                ColumnCount = time + (ulong)evt.Length;
        }
Exemplo n.º 6
0
        private void getBaseTime(ulong time, out EventToken[,] block, out int index)
        {
            ulong baseTime = _history.Keys.Where(t => (t <= time)).DefaultIfEmpty(0UL).Max();
            if (!_history.ContainsKey(baseTime))
            {
                block = null;
                index = 0;
                return;
            }

            block = _history[baseTime];
            index = (int)(time - baseTime);
            if (index >= block.GetLength(1))
            {
                block = null;
                index = 0;
            }
        }
Exemplo n.º 7
0
        private int findEmptyRow(ref EventToken[,] block, int col)
        {
            bool found = false;
            int row;
            for (row = 0; row < block.GetLength(0); row++)
            {
                if (block[row, col] == null)
                {
                    found = true;
                    break;
                }
            }
            if (!found)
            {
                row = (++_rowCount) - 1;
                block = block.Resize(_rowCount, block.GetLength(1));
            }

            return row;
        }
Exemplo n.º 8
0
        public void UpdateFuture(EventSchedule sched, ulong fromTime)
        {
            var future = sched.GetActualFuture(fromTime);

            acrossTime(fromTime, ColumnCount, (ref EventToken[,] block) =>
            {
                return (block != null);
            }, (ref EventToken[,] block, ulong t, int j) =>
            {
                for (int r = 0; r < block.GetLength(0); r++)
                {
                    if (block[r, j] != null && (!block[r, j].Event.Started || !block[r, j].Event.Active))
                    {
                        block[r, j] = null;
                    }
                }
            });

            acrossTime(fromTime, (ulong)future.Length, (ref EventToken[,] block) =>
            {
                if (block == null)
                    block = new EventToken[_rowCount, BlockWidth];
                return true;
            }, (ref EventToken[,] block, ulong t, int j) =>
            {
                foreach (var evt in future[(int)t])
                {
                    int r = findEmptyRow(ref block, j);
                    insertEvent(r, fromTime + t, evt);
                }
            });
        }