コード例 #1
0
ファイル: InputTruthTable.cs プロジェクト: buptkang/LogicPad
        public override void DrawTruthTableValues()
        {
            Rect b;
            Point center;
            Brush color;
            InkFigure values = null;
            InkRegion inkRegion;

            int termSquares = (int)Math.Pow(2, number_of_terms);

            for (int i = 0; i < termSquares; i++)
            {
                //Draw sequence number
                b = new Rect(GAP, GAP + (i + 1) * GAP, GAP, GAP);
                center = new Point(b.X + b.Width / 2, b.Y + b.Height / 2);
                color = Brushes.Black;
                values = new InkFigure(i.ToString(), b, center, color);
                values.SetHeader();
                InkCanvas.Children.Add(values);

                //Draw truth table row numbers
                char[] rowValues = ComputeRowValue(i, number_of_terms);
                for (int j = 0; j < Terms_names.Length; j++)
                {
                    b = new Rect((j + 1) * GAP, (i + 1) * GAP, GAP, GAP);
                    center = new Point(b.X + b.Width + b.Width / 2, b.Y + b.Height + b.Height / 2);
                    color = Brushes.Blue;
                    values = new InkFigure(rowValues[j].ToString(), b, center, color);
                    InkCanvas.Children.Add(values);
                }

                //For output column
                //Output
                b = new Rect(GAP * Columns, (i + 2) * GAP, GAP, GAP);
                InkCanvas.Children.Add(CreateInkRegion(b));
                inkRegion = new InkRegion(b, i);
                InkRegions.Add(inkRegion);
            }
        }
コード例 #2
0
ファイル: InputTruthTable.cs プロジェクト: buptkang/LogicPad
        }//drawGrid

        //Black brush
        public override void DrawTruthTableHeaders()
        {
            Rect b;
            Point center;
            Brush color;
            InkFigure header = null;

            InkRegion inkRegion;

            //For Row 0, draw headers 
            for (int i = 0; i < Number_of_terms; i++)
            {
                b = new Rect(GAP + (i + 1) * GAP, GAP, GAP, GAP);
                center = new Point(b.X + b.Width / 2, b.Y + b.Height / 2);
                color = Brushes.Black;
                header = new InkFigure(Terms_names[i], b, center, color);
                header.SetHeader();
                InkCanvas.Children.Add(CreateInkRegion(b));
                InkCanvas.Children.Add(header);
                //Create one InkRegion
                inkRegion = new InkRegion(b);
                InkRegions.Add(inkRegion);

                TermNameDict.Add(b, Terms_names[i]);
            }

            //Output
            b = new Rect(GAP * Columns, GAP, GAP, GAP);
            center = new Point(b.X + b.Width / 2, b.Y + b.Height / 2);
            color = Brushes.Black;
            header = new InkFigure("Output", b, center, color);
            header.SetHeader();
            InkCanvas.Children.Add(CreateInkRegion(b));
            InkCanvas.Children.Add(header);

            inkRegion = new InkRegion(b);
            inkRegion.IsOutputHeader = true;
            InkRegions.Add(inkRegion);

            OutputMap.Add(b, "Output");
        }