예제 #1
0
        /// <summary>
        /// Fills a cell with appropriate brush based on its data, and writes variable names if under variable control.
        /// </summary>
        private void refreshCell(Graphics g, Point p)
        {
            DigitalDataPoint dp = cellPointToDigitalDataPoint(p);

            Pen outlinePen = normalOutlinePen;

            /* if (dp != null)
             * {
             *   if (dp.usesPulse())
             *   {
             *       outlinePen = pulseOutlintPen;
             *   }
             *   else
             *   {
             *       outlinePen = normalOutlinePen;
             *   }
             * }*/


            if (dp == null)
            {
                paintCell(g, p, nullBrush, outlinePen);
                return;
            }

            if (dp.variable == null)
            {
                Brush br;
                if (dp.DigitalContinue)
                {
                    int stepID    = cellPointToTimeStepId(p);
                    int channelID = cellPointToChannelID(p);
                    if (stepID == -1 || channelID == -1)
                    {
                        return;
                    }
                    TimeStep step          = Storage.sequenceData.TimeSteps[stepID];
                    bool     continueValue = step.getDigitalValue(channelID,
                                                                  Storage.sequenceData.TimeSteps,
                                                                  stepID);

                    br = continueBrush(p.Y, continueValue);
                }
                else if (dp.ManualValue)
                {
                    br = trueBrush(p.Y);
                    // paintCell(g, p, trueBrush(p.Y), outlinePen);
                }
                else
                {
                    br = falseBrush;
                    // paintCell(g, p, falseBrush, outlinePen);
                    //painCellRectInternal(g, p, new Pen(trueBrush(p.Y)));
                    //drawCellTopAndBottomInternalLines(g, p, new Pen(trueBrush(p.Y)));
                }
                paintCell(g, p, br, outlinePen);
            }
            else
            {
                // this will probably never get used. Though there is functionality for having a variable value for a digital
                // this does not get set anywhere. Probably this is superseeded by pulse capability
                paintCell(g, p, variableBrush, outlinePen);
                g.DrawString(dp.variable.ToString(), variableFont, Brushes.Black, new RectangleF(p.X * colWidth, p.Y * rowHeight, colWidth, rowHeight));
            }

            if (dp.DigitalPulse != null)
            {
                p = paintPulse(g, p, dp);
            }

            if (WordGenerator.MainClientForm.instance.studentEdition)
            {
                paintCell(g, p, seb, null);
            }
        }