예제 #1
0
        private void mi_useAs(object sender, EventArgs e)
        {
            MenuItem mi = sender as MenuItem;

            if (mi != null)
            {
                ComponentIconLocal cil = mi.Tag as ComponentIconLocal;
                if (cil != null)
                {
                    MethodDesignerHolder mh = null;
                    Control c = this.Parent;
                    while (c != null)
                    {
                        mh = c as MethodDesignerHolder;
                        if (mh != null)
                        {
                            break;
                        }
                        c = c.Parent;
                    }
                    if (mh != null)
                    {
                        ParameterClassSubMethod pc = this.ClassPointer as ParameterClassSubMethod;
                        mh.LoadNewCastAs(pc, cil.LocalPointer);
                    }
                }
            }
        }
예제 #2
0
        public override object Clone()
        {
            ComponentIconLocal obj = (ComponentIconLocal)base.Clone();

            obj._name         = _name;
            obj._type         = _type;
            obj._scopeGroupId = _scopeGroupId;
            return(obj);
        }
 public override void CancelEdit()
 {
     foreach (Control c in Controls)
     {
         ComponentIconLocal cil = c as ComponentIconLocal;
         if (cil != null)
         {
             LocalVariable.RemoveLocalVariable(cil.LocalPointer);
         }
     }
 }
예제 #4
0
 protected override void OnRemoveLocalVariable(ComponentIconLocal v)
 {
     if (v != null)
     {
         ISubMethod af = _actions as ISubMethod;
         if (af != null)
         {
             //include removing from sub-scope
             //
             af.RemoveLocalVariable(v);
         }
     }
 }
예제 #5
0
        protected override void OnCreateContextMenu(ContextMenu mnu, Point location)
        {
            base.OnCreateContextMenu(mnu, location);
            Type t = null;
            ParameterClassArrayItem      ap = this.ClassPointer as ParameterClassArrayItem;
            ParameterClassCollectionItem ci = this.ClassPointer as ParameterClassCollectionItem;

            if (ap != null)
            {
                t = ap.BaseClassType;
            }
            else if (ci != null)
            {
                t = ci.BaseClassType;
            }
            if (t != null)
            {
                if (this.Parent != null)
                {
                    List <ComponentIconLocal> list = new List <ComponentIconLocal>();
                    foreach (Control c in this.Parent.Controls)
                    {
                        ComponentIconLocal cil = c as ComponentIconLocal;
                        if (cil != null)
                        {
                            if (t.IsAssignableFrom(cil.LocalPointer.BaseClassType))
                            {
                                list.Add(cil);
                            }
                        }
                    }
                    if (list.Count > 0)
                    {
                        if (mnu.MenuItems.Count > 0)
                        {
                            mnu.MenuItems.Add("-");
                        }
                        MenuItemWithBitmap mi = new MenuItemWithBitmap("Use it as", Resources._as.ToBitmap());
                        mnu.MenuItems.Add(mi);
                        foreach (ComponentIconLocal cil in list)
                        {
                            MenuItemWithBitmap mi0 = new MenuItemWithBitmap(cil.Label.Text, mi_useAs, VPL.VPLUtil.GetTypeIcon(cil.ClassPointer.ObjectType));
                            mi0.Tag = cil;
                            mi.MenuItems.Add(mi0);
                        }
                    }
                }
            }
        }
        public void ReloadActions()
        {
            ActionGroupDesignerHolder holder = DesignerHolder as ActionGroupDesignerHolder;
            AB_Squential actions             = holder.Actions;
            bool         b = holder.DisableUndo;

            holder.DisableUndo = true;
            holder.ClearAllComponent();
            Controls.Clear();

            BranchList bl = actions.ActionList;

            LoadActions(bl);

            //load component icons
            List <ComponentIcon> iconList = IconList;

            if (iconList == null)
            {
                iconList = new List <ComponentIcon>();
            }
            List <ComponentIcon> invalids = new List <ComponentIcon>();

            foreach (ComponentIcon ci in iconList)
            {
                if (ci.ClassPointer == null)
                {
                    invalids.Add(ci);
                }
            }
            foreach (ComponentIcon ci in invalids)
            {
                iconList.Remove(ci);
            }
            //find root
            ClassPointer  root = holder.Designer.GetRootId();
            List <IClass> objList;

            if (Method.IsStatic)
            {
                objList = new List <IClass>();
            }
            else
            {
                objList = root.GetClassList();
            }
            SubMethodInfoPointer smi = null;

            if (Method.SubMethod.Count > 0)
            {
                smi = Method.SubMethod.Peek() as SubMethodInfoPointer;
            }
            //initialize existing icons, creating ComponentIcon.ClassPointer
            foreach (ComponentIcon ic in iconList)
            {
                ic.SetDesigner(holder.Designer);
                ComponentIconPublic cip = ic as ComponentIconPublic;
                if (cip == null)
                {
                    ComponentIconLocal lv = ic as ComponentIconLocal;
                    if (lv != null)
                    {
                        lv.ReadOnly = true;
                        if (!ParentEditor.LocalVariableDeclared(lv))
                        {
                            lv.ScopeGroupId = actions.BranchId;
                        }
                    }
                    else
                    {
                    }
                    if (smi != null)
                    {
                        ParameterClassSubMethod sm = ic.ClassPointer as ParameterClassSubMethod;
                        if (sm != null)
                        {
                            if (sm.ActionId == 0)
                            {
                                sm.ActionId = smi.ActionOwner.ActionId;
                            }
                            ParameterClass pc = ic.ClassPointer as ParameterClass;
                            if (pc != null && pc.ObjectType != null)
                            {
                                if (pc.ObjectType.IsGenericParameter)
                                {
                                    if (pc.ConcreteType == null)
                                    {
                                        if (smi.ActionOwner.MethodOwner != null)
                                        {
                                            CustomPropertyPointer cpp = smi.ActionOwner.MethodOwner.Owner as CustomPropertyPointer;
                                            if (cpp != null)
                                            {
                                                pc.ConcreteType = cpp.GetConcreteType(pc.ObjectType);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                }
            }
            //add new public component icons
            int x0 = 10;
            int y0 = 30;
            int x  = x0;
            int y  = y0;
            int dx = 10;
            int dy = 10;

            foreach (IClass c in objList)
            {
                bool bFound = false;
                foreach (ComponentIcon ic in iconList)
                {
                    if (ic.ClassPointer == null)
                    {
                    }
                    else
                    {
                        if (ic.ClassPointer.IsSameObjectRef(c))
                        {
                            bFound = true;
                            break;
                        }
                    }
                }
                if (!bFound)
                {
                    ComponentIconPublic cip = new ComponentIconPublic(holder.Designer, c, Method);
                    cip.Location = new Point(x, y);
                    y           += dy;
                    y           += cip.Height;
                    if (y >= this.Height)
                    {
                        y  = y0;
                        x += dx;
                        x += cip.Width;
                    }
                    iconList.Add(cip);
                }
            }
            //add new local component icons
            List <ComponentIcon> picons = ParentEditor.IconList;

            foreach (ComponentIcon lv in picons)
            {
                ComponentIconPublic cip0 = lv as ComponentIconPublic;
                if (cip0 == null)
                {
                    bool bFound = false;
                    foreach (ComponentIcon ic in iconList)
                    {
                        if (ic.ClassPointer.IsSameObjectRef(lv.ClassPointer))
                        {
                            bFound = true;
                            break;
                        }
                    }
                    if (!bFound)
                    {
                        ComponentIcon cip = (ComponentIcon)lv.Clone();
                        cip.SetDesigner(holder.Designer);
                        cip.ReadOnly = true;
                        cip.Location = new Point(x, y);
                        y           += dy;
                        y           += cip.Height;
                        if (y >= this.Height)
                        {
                            y  = y0;
                            x += dx;
                            x += cip.Width;
                        }
                        iconList.Add(cip);
                    }
                }
            }
            //add parameters
            if (Method.ParameterCount > 0)
            {
                foreach (ParameterClass c in Method.Parameters)
                {
                    bool bFound = false;
                    foreach (ComponentIcon ic in iconList)
                    {
                        if (ic.ClassPointer.IsSameObjectRef(c))
                        {
                            bFound = true;
                            break;
                        }
                    }
                    if (!bFound)
                    {
                        ComponentIconParameter cip = new ComponentIconParameter(holder.Designer, c, Method);
                        cip.Location = new Point(x, y);
                        y           += dy;
                        y           += cip.Height;
                        if (y >= this.Height)
                        {
                            y  = y0;
                            x += dx;
                            x += cip.Width;
                        }
                        iconList.Add(cip);
                    }
                }
            }
            //add action parameters
            ISingleAction sa = actions as ISingleAction;

            if (sa != null && sa.ActionData != null && sa.ActionData.ActionMethod != null && sa.ActionData.ActionMethod.MethodPointed.MethodParameterTypes != null)
            {
                List <ParameterClass> plist = new List <ParameterClass>();
                SubMethodInfoPointer  smp   = sa.ActionData.ActionMethod.MethodPointed as SubMethodInfoPointer;
                if (smp != null)
                {
                    foreach (ParameterClassSubMethod p in smp.Parameters)
                    {
                        plist.Add(p);
                    }
                }
                else
                {
                    foreach (IParameter p in sa.ActionData.ActionMethod.MethodPointed.MethodParameterTypes)
                    {
                        ParameterClass c = p as ParameterClass;
                        if (c == null)
                        {
                            try
                            {
                                c = sa.ActionData.ActionMethod.MethodPointed.GetParameterType(p.ParameterID) as ParameterClass;
                                if (c == null)
                                {
                                    DesignUtil.WriteToOutputWindowAndLog("Cannot get ParameterClass {0} for method {1} of {2}.", p.Name, sa.ActionData.ActionMethod.MethodName, sa.ActionData.ActionMethod.MethodPointed.GetType());
                                    continue;
                                }
                            }
                            catch (Exception errp)
                            {
                                DesignUtil.WriteToOutputWindowAndLog(errp, "Cannot get ParameterClass {0} for method {1} of {2}", p.Name, sa.ActionData.ActionMethod.MethodName, sa.ActionData.ActionMethod.MethodPointed.GetType());
                                continue;
                            }
                        }
                        if (c != null)
                        {
                            plist.Add(c);
                        }
                    }
                }
                foreach (ParameterClass c in plist)
                {
                    bool bFound = false;
                    foreach (ComponentIcon ic in iconList)
                    {
                        if (ic.ClassPointer.IsSameObjectRef(c))
                        {
                            ParameterClass c0 = ic.ClassPointer as ParameterClass;
                            c0.ReadOnly    = true;
                            c0.Description = c.Description;
                            bFound         = true;
                            break;
                        }
                    }
                    if (!bFound)
                    {
                        ComponentIcon         cip;
                        ActionBranchParameter abp = c as ActionBranchParameter;
                        if (abp != null)
                        {
                            cip = new ComponentIconActionBranchParameter(actions);
                            cip.ClassPointer = abp;
                            cip.SetDesigner(holder.Designer);
                        }
                        else
                        {
                            cip = new ComponentIconParameter(holder.Designer, c, Method);
                        }
                        cip.Location = new Point(x, y);
                        y           += dy;
                        y           += cip.Height;
                        if (y >= this.Height)
                        {
                            y  = y0;
                            x += dx;
                            x += cip.Width;
                        }
                        iconList.Add(cip);
                    }
                }
            }
            //add icons
            holder.AddControlsToIconsHolder(iconList.ToArray());
            foreach (ComponentIcon ic in iconList)
            {
                ComponentIconPublic cip = ic as ComponentIconPublic;
                if (cip == null)
                {
                    if (ic.Left < 0)
                    {
                        ic.Left = 2;
                    }
                    if (ic.Top < 0)
                    {
                        ic.Top = 2;
                    }
                    ic.BringToFront();
                    ic.RefreshLabelPosition();
                    ic.RefreshLabelText();
                    ComponentIconLocal cil = ic as ComponentIconLocal;
                    if (cil != null)
                    {
                        cil.HookNameChecker();
                    }
                }
            }
            //}
            InitializeInputTypes();
            ValidateControlPositions();
            holder.DisableUndo = b;
        }