Beispiel #1
0
        public IDataSelectionControl GetUIEditorDropdown(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (edSvc != null)
            {
                PrimaryTypeList c = new PrimaryTypeList();
                Type            t = value as Type;
                if (t == null)
                {
                    RaisDataType rt = value as RaisDataType;
                    if (rt != null)
                    {
                        t = rt.LibType;
                    }
                }
                if (t != null)
                {
                    c.SelectType(t);
                }
                MathNodeValue mv = context.Instance as MathNodeValue;
                if (mv != null)
                {
                    RaisDataType rt = mv.GetRelatedType();
                    c.InsertType(rt.LibType, rt.LibType.Name);
                }
                c.SetCaller(edSvc);
                return(c);
            }
            return(null);
        }
        public IDataSelectionControl GetUIEditorModal(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (edSvc != null)
            {
                MathNodeValue mv = context.Instance as MathNodeValue;
                if (mv != null)
                {
                    dlgValue c = new dlgValue();
                    c.SetProperty(new PropertySpec("Value", mv.DataType.Type, "", "choose a value"));
                    c.SetCaller(edSvc);
                    c.ReturnValue = mv.Value;
                    return(c);
                }
                else
                {
                    MathNodeObjRef mo = context.Instance as MathNodeObjRef;
                    if (mo != null)
                    {
                        IObjectRefSelector selector = (IObjectRefSelector)MathNode.GetService(typeof(IObjectRefSelector));
                        if (selector != null)
                        {
                            IDataSelectionControl dlg = selector.GetSelector(mo);
                            dlg.SetCaller(edSvc);
                            return(dlg);
                        }
                    }
                }
            }
            return(null);
        }
 protected override void OnCloneDataType(MathNode cloned)
 {
     if (_dataType != null)
     {
         MathNodeValue m = (MathNodeValue)cloned;
         m._dataType = _dataType.Clone() as RaisDataType;
     }
 }
Beispiel #4
0
        void typeIcons1_OnTypeSelected(object sender, EventArgs e)
        {
            Type t = sender as Type;

            if (t != null)
            {
                enumOperatorCategory     category = enumOperatorCategory.Decimal;
                EventArgsEletementSelect ec       = e as EventArgsEletementSelect;
                if (ec != null)
                {
                    category = ec.Category;
                }
                MathNode newNode = null;
                MathNode node    = mathExpCtrl1.FocusedNode;
                if (node != null && node != mathExpCtrl1.Root[0])
                {
                    newNode = mathExpCtrl1.ReplaceMathNode(node, t);
                }
                else
                {
                    newNode = mathExpCtrl1.AddMathNode(t);
                }
                mathExpCtrl1.RefreshVariableMap();
                if (newNode != null)
                {
                    MathNodeValue nv = newNode as MathNodeValue;
                    if (nv != null)
                    {
                        if (category == enumOperatorCategory.Integer)
                        {
                            nv.ValueType = new RaisDataType(typeof(Int32));
                        }
                        else if (category == enumOperatorCategory.Logic)
                        {
                            nv.ValueType = new RaisDataType(typeof(bool));
                        }
                        else if (category == enumOperatorCategory.String)
                        {
                            nv.ValueType = new RaisDataType(typeof(string));
                        }
                    }
                    object[] vs = t.GetCustomAttributes(typeof(UseModalSelectorAttribute), true);
                    if (vs != null && vs.Length > 0)
                    {
                        mathExpCtrl1.SetNodeSelection(newNode);
                        mathExpCtrl1.DoDoubleClick();
                    }
                }
            }
        }
        public override object CloneExp(MathNode parent)
        {
            MathNodeValue node = (MathNodeValue)base.CloneExp(parent);

            node.ValueType = this.ValueType;
            ICloneable ic = _value as ICloneable;

            if (ic != null)
            {
                node.Value = ic.Clone();
            }
            else
            {
                if (this.ValueType.Type.IsValueType)
                {
                    node.Value = _value;
                }
            }
            return(node);
        }
Beispiel #6
0
 public override void OnReplaceNode(MathNode replaced)
 {
     if (replaced != null)
     {
         _dataType = replaced.DataType;
         int n = this.ChildNodeCount;
         for (int i = 0; i < n; i++)
         {
             MathNodeCondition mc = this[i] as MathNodeCondition;
             if (mc != null)
             {
                 mc[1] = replaced.CloneExp(mc) as MathNode;
             }
             else
             {
                 MathNodeValue v = this[i] as MathNodeValue;
                 if (v != null)
                 {
                     v.ValueType = replaced.DataType.Clone() as RaisDataType;
                 }
             }
         }
     }
 }