コード例 #1
0
ファイル: BlockViewFactory.cs プロジェクト: samiz/kitsune
        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);
            }
        }
コード例 #2
0
ファイル: BlockViewFactory.cs プロジェクト: samiz/kitsune
        void ProcDefTextBit_TextChanged(object sender, string newText)
        {
            ProcDefTextBit    ptb = (ProcDefTextBit)sender;
            EditableLabelView ev  = (EditableLabelView)ViewFromBlock(ptb);
            int    height         = ArgBitTextHeight(ptb);
            Bitmap bmp            = MakeTextBitBitmap(newText, height);

            ev.SetBitmap(bmp);
        }
コード例 #3
0
ファイル: BlockViewFactory.cs プロジェクト: samiz/kitsune
        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);
        }
コード例 #4
0
        public void AddText()
        {
            //string text = GenerateNewName("label");
            string         text = "";
            ProcDefTextBit t    = new ProcDefTextBit(text);

            t.ParentRelationship = new ParentRelationship(ParentRelationshipType.None, model, -1);
            model.AddBit(t);
            ITextualView v = (ITextualView)factory.ViewFromBlock(t);

            SetEditState(v);
        }
コード例 #5
0
 public void AddText()
 {
     //string text = GenerateNewName("label");
     string text = "";
     ProcDefTextBit t = new ProcDefTextBit(text);
     t.ParentRelationship = new ParentRelationship(ParentRelationshipType.None, model, -1);
     model.AddBit(t);
     ITextualView v = (ITextualView) factory.ViewFromBlock(t);
     SetEditState(v);
 }