Beispiel #1
0
 void ProcDef_FormalParamTextChanged(object sender, string newText)
 {
     VarDefBlock        b = (VarDefBlock)sender;
     EditableVarDefView v = (EditableVarDefView)ViewFromBlock(b);
     int    height        = ArgBitTextHeight(b);
     Bitmap bmp           = MakeTextBitBitmap(newText, height);
 }
Beispiel #2
0
        void ProcDefBlock_FormalParamAdded(object sender, IProcDefBit newBit)
        {
            ProcDefBlock b    = (ProcDefBlock)sender;
            ProcDefView  v    = (ProcDefView)ViewFromBlock(b);
            DataType     type = DataType.Invalid;

            if (newBit is VarDefBlock)
            {
                VarDefBlock vb = (VarDefBlock)newBit;
                type = (vb).Type;
                int height            = ArgBitTextHeight(newBit);
                EditableVarDefView vv = new EditableVarDefView(vb,
                                                               MakeTextBitBitmap(vb.Name, height),
                                                               varb_parts,
                                                               textMetrics, textFont);
                blockViews[vb]  = vv;
                vb.TextChanged += new VarDefBlockTextChangedEvent(ProcDef_FormalParamTextChanged);
                v.AddFormalBit(vv, type);
            }
            else
            {
                ProcDefTextBit pb = (ProcDefTextBit)newBit;
                pb.TextChanged += new ProcDefTextBitTextChangedEvent(ProcDefTextBit_TextChanged);
                EditableLabelView lv = new EditableLabelView(MakeTextBitBitmap(pb.Text, ArgBitTextHeight(pb)),
                                                             (ProcDefTextBit)newBit);
                blockViews[pb] = lv;

                v.AddFormalBit(lv, DataType.Invalid);
            }
        }
Beispiel #3
0
        private IBlockView ViewFromProcDefBlock(ProcDefBlock b)
        {
            List <IBlockView> subContent = new List <IBlockView>();
            int i = 0;
            int n = b.Bits.Count;

            BitArray trueArgs = new BitArray(n);

            DataType[] argTypes = new DataType[n];
            // slow: Repeats instanceof test twice for all bits; once for height and once to add to subContent
            int height = b.Bits.Count == 0?1: b.Bits.Max(bb => ArgBitTextHeight(bb));

            foreach (IProcDefBit bit in b.Bits)
            {
                if (bit is VarDefBlock)
                {
                    VarDefBlock        vb = (VarDefBlock)bit;
                    EditableVarDefView vv = new EditableVarDefView(vb,
                                                                   MakeTextBitBitmap(vb.Name, height),
                                                                   varb_parts,
                                                                   textMetrics, textFont);
                    blockViews[vb] = vv;
                    subContent.Add(vv);
                    trueArgs[i]     = true;
                    argTypes[i]     = vb.Type;
                    vb.TextChanged += new VarDefBlockTextChangedEvent(ProcDef_FormalParamTextChanged);
                }
                else
                {
                    ProcDefTextBit    ptb = (ProcDefTextBit)bit;
                    EditableLabelView ev  = new EditableLabelView(
                        MakeTextBitBitmap(ptb.Text, height),
                        ptb);
                    blockViews[ptb] = ev;
                    subContent.Add(ev);
                    argTypes[i]      = DataType.Invalid;
                    trueArgs[i]      = false;
                    ptb.TextChanged += new ProcDefTextBitTextChangedEvent(ProcDefTextBit_TextChanged);
                }
                ++i;
            }

            Bitmap[]    defineTextView = RenderTextBits(new string[] { "define" });
            ContentView innerContent   = new ContentView(subContent.ToArray(), argTypes, trueArgs, sb_parts);
            ContentView outerContent   = new ContentView(new IBlockView[] {
                new LabelView(defineTextView[0]),
                innerContent
            }, new DataType[] { DataType.Invalid },
                                                         new BitArray(new bool[] { false, true }), pdb_parts);

            ProcDefView pdb = new ProcDefView(b, outerContent, innerContent);

            b.FormalParamAdded   += new ProcDefBitAddedEvent(ProcDefBlock_FormalParamAdded);
            b.FormalParamRemoved += new ProcDefBitRemovedEvent(ProcDefBlock_FormalParamRemoved);
            b.FormalParamChanged += new ProcDefBitChangedEvent(ProcDefBlock_FormalParamChanged);
            return(pdb);
        }
Beispiel #4
0
        private IBlockView ViewFromProcDefBlock(ProcDefBlock b)
        {
            List<IBlockView> subContent = new List<IBlockView>();
            int i = 0;
            int n = b.Bits.Count;

            BitArray trueArgs = new BitArray(n);
            DataType[] argTypes = new DataType[n];
            // slow: Repeats instanceof test twice for all bits; once for height and once to add to subContent
            int height = b.Bits.Count==0?1: b.Bits.Max(bb => ArgBitTextHeight(bb));

            foreach (IProcDefBit bit in b.Bits)
            {
                if (bit is VarDefBlock)
                {
                    VarDefBlock vb = (VarDefBlock)bit;
                    EditableVarDefView vv = new EditableVarDefView(vb,
                        MakeTextBitBitmap(vb.Name, height),
                        varb_parts,
                        textMetrics, textFont);
                    blockViews[vb] = vv;
                    subContent.Add(vv);
                    trueArgs[i] = true;
                    argTypes[i] = vb.Type;
                    vb.TextChanged += new VarDefBlockTextChangedEvent(ProcDef_FormalParamTextChanged);
                }
                else
                {
                    ProcDefTextBit ptb = (ProcDefTextBit) bit;
                    EditableLabelView ev = new EditableLabelView(
                        MakeTextBitBitmap(ptb.Text, height),
                        ptb);
                    blockViews[ptb] = ev;
                    subContent.Add(ev);
                    argTypes[i] = DataType.Invalid;
                    trueArgs[i] = false;
                    ptb.TextChanged += new ProcDefTextBitTextChangedEvent(ProcDefTextBit_TextChanged);

                }
                ++i;
            }

            Bitmap[] defineTextView = RenderTextBits(new string[] { "define" });
            ContentView innerContent = new ContentView(subContent.ToArray(), argTypes, trueArgs, sb_parts);
            ContentView outerContent = new ContentView(new IBlockView[] {
                new LabelView(defineTextView[0]),
                innerContent
            }, new DataType[] { DataType.Invalid },
                new BitArray(new bool[] { false, true }), pdb_parts);

            ProcDefView pdb = new ProcDefView(b, outerContent, innerContent);
            b.FormalParamAdded += new ProcDefBitAddedEvent(ProcDefBlock_FormalParamAdded);
            b.FormalParamRemoved += new ProcDefBitRemovedEvent(ProcDefBlock_FormalParamRemoved);
            b.FormalParamChanged += new ProcDefBitChangedEvent(ProcDefBlock_FormalParamChanged);
            return pdb;
        }
Beispiel #5
0
        void ProcDefBlock_FormalParamAdded(object sender, IProcDefBit newBit)
        {
            ProcDefBlock b = (ProcDefBlock) sender;
            ProcDefView v = (ProcDefView) ViewFromBlock(b);
            DataType type = DataType.Invalid;
            if (newBit is VarDefBlock)
            {
                VarDefBlock vb = (VarDefBlock)newBit;
                type = (vb).Type;
                int height = ArgBitTextHeight(newBit);
                EditableVarDefView vv = new EditableVarDefView(vb,
                       MakeTextBitBitmap(vb.Name, height),
                       varb_parts,
                       textMetrics, textFont);
                blockViews[vb] = vv;
                vb.TextChanged += new VarDefBlockTextChangedEvent(ProcDef_FormalParamTextChanged);
                v.AddFormalBit(vv, type);
            }
            else
            {
                ProcDefTextBit pb = (ProcDefTextBit)newBit;
                pb.TextChanged += new ProcDefTextBitTextChangedEvent(ProcDefTextBit_TextChanged);
                EditableLabelView lv = new EditableLabelView(MakeTextBitBitmap(pb.Text, ArgBitTextHeight(pb)),
                    (ProcDefTextBit) newBit);
                blockViews[pb] = lv;

                v.AddFormalBit(lv, DataType.Invalid);
            }
        }