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);
        }
Exemplo n.º 2
0
 private void btTest_Click(object sender, EventArgs e)
 {
     btTest.Enabled = false;
     try
     {
         //check if compilation is needed
         _testData = null;
         IObjectTypeUnitTester uc = (IObjectTypeUnitTester)MathNode.GetService(typeof(IObjectTypeUnitTester));
         if (uc != null)
         {
             _testData = uc.UseMemberTest(this);
         }
         if (_testData == null)
         {
             //
             CompileResult result = mathExpCtrl1.CreateMethodCompilerUnit("TestMathExpression", "Test", "TestMathExpression");
             //
             thTest = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(test));
             thTest.SetApartmentState(System.Threading.ApartmentState.STA);
             _testData = new TestData(result);                    //"Test", "TestMathExpression", variables, pointerList, code, imports);
             thTest.Start(_testData);
         }
         timer1.Enabled = true;
     }
     catch (Exception err)
     {
         MathNode.Log(this.FindForm(), err);
     }
     //
     timer1.Enabled = true;
 }
Exemplo n.º 3
0
 private void btTest_Click(object sender, EventArgs e)
 {
     btTest.Enabled = false;
     try
     {
         _testData = null;
         //generate the result
         result = root.Export();
         //
         //check if compilation is needed
         IObjectTypeUnitTester uc = (IObjectTypeUnitTester)MathNode.GetService(typeof(IObjectTypeUnitTester));
         if (uc != null)
         {
             _testData = uc.UseMemberTest(this);
         }
         if (_testData == null)
         {
             CompileResult compiled = result.CreateMethodCompilerUnit("TestMathExpression", "Test", "TestMathExpGroup");
             //
             thTest = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(test));
             thTest.SetApartmentState(System.Threading.ApartmentState.STA);
             _testData = new TestData(compiled);
             thTest.Start(_testData);
         }
         //
         timer1.Enabled = true;
     }
     catch (Exception err)
     {
         MathNode.Log(this.FindForm(), err);
     }
 }
        // Draws a representation of the property's value.
        public override void PaintValue(System.Drawing.Design.PaintValueEventArgs e)
        {
            IMethodSelector ts = (IMethodSelector)MathNode.GetService(typeof(IMethodSelector));

            if (ts != null)
            {
                ts.PaintValue(e);
            }
        }
        // Indicates whether the UITypeEditor supports painting a
        // representation of a property's value.
        public override bool GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext context)
        {
            IMethodSelector ts = (IMethodSelector)MathNode.GetService(typeof(IMethodSelector));

            if (ts != null)
            {
                return(ts.GetPaintValueSupported(context));
            }
            return(false);
        }
        public override System.Drawing.Design.UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
        {
            IMethodSelector ts = (IMethodSelector)MathNode.GetService(typeof(IMethodSelector));

            if (ts != null)
            {
                return(ts.GetUIEditorStyle(context));
            }
            return(UITypeEditorEditStyle.None);
        }
        public MathNodeArgument(MathNode parent)
            : base(parent)
        {
            MethodType mt = (MethodType)MathNode.GetService(typeof(MethodType));

            if (mt != null && mt.ParameterCount > 0)
            {
                _dataType = mt.Parameters[0];
            }
        }
        public ArguementListControl(IWindowsFormsEditorService edSvc)
        {
            _srv = edSvc;
            MethodType mt = (MethodType)MathNode.GetService(typeof(MethodType));

            if (mt != null)
            {
                for (int i = 0; i < mt.ParameterCount; i++)
                {
                    Items.Add(mt.Parameters[i]);
                }
            }
        }
        public override string CreatePhpScript(StringCollection method)
        {
            MathNode.Trace("{0}.CreatePhpScript for {1}", this.GetType().Name, _value);
            if (_value == null)
            {
                throw new MathException("object reference is not set");
            }
            IRaisCodeCompiler cc = (IRaisCodeCompiler)MathNode.GetService(typeof(IRaisCodeCompiler));

            if (cc == null)
            {
                throw new MathException("IRaisCodeCompiler is not available");
            }
            return(_value.CreatePhpScript(method, cc.CurrentXPath));
        }
        /// <summary>
        /// it should be a reference to the object
        /// </summary>
        /// <returns></returns>
        public override CodeExpression ExportCode(IMethodCompile method)
        {
            MathNode.Trace("{0}.ExportCode for {1}", this.GetType().Name, _value);
            if (_value == null)
            {
                throw new MathException("object reference is not set");
            }
            IRaisCodeCompiler cc = (IRaisCodeCompiler)MathNode.GetService(typeof(IRaisCodeCompiler));

            if (cc == null)
            {
                throw new MathException("IRaisCodeCompiler is not available");
            }
            return(_value.ExportCode(cc.CurrentXPath));
        }
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (edSvc != null)
            {
                edSvc.CloseDropDown();
                IMethodSelector ts = (IMethodSelector)MathNode.GetService(typeof(IMethodSelector));
                if (ts != null)
                {
                    UITypeEditorEditStyle style = ts.GetUIEditorStyle(context);
                    if (style == UITypeEditorEditStyle.DropDown)
                    {
                        IDataSelectionControl dropdown = ts.GetUIEditorDropdown(context, provider, value);
                        if (dropdown != null)
                        {
                            edSvc.DropDownControl((Control)dropdown);
                            object v = dropdown.UITypeEditorSelectedValue;
                            if (v != null)
                            {
                                return(v);
                            }
                        }
                    }
                    else if (style == UITypeEditorEditStyle.Modal)
                    {
                        IDataSelectionControl modal = ts.GetUIEditorModal(context, provider, value);
                        if (modal != null)
                        {
                            if (edSvc.ShowDialog((Form)modal) == DialogResult.OK)
                            {
                                IMethodNode mn = context.Instance as IMethodNode;
                                if (mn != null)
                                {
                                    mn.SetFunction(modal.UITypeEditorSelectedValue);
                                    return(mn.GetFunctionName());
                                }
                                return(modal.UITypeEditorSelectedValue);
                            }
                        }
                    }
                }
            }
            return(value);
        }
Exemplo n.º 12
0
        public MathExpEditor()
        {
            InitializeComponent();
            //
            mathExpCtrl1.SetMathEditor(this);
            //
            List <Type> NodeTypes;
            List <Type> NodeTypesLogic;
            List <Type> NodeTypesInteger;
            List <Type> NodeTypesString;
            List <Type> NodeTypesOther;

            propertyGrid1.PropertyValueChanged += new PropertyValueChangedEventHandler(propertyGrid1_PropertyValueChanged);
            propertyGrid2.PropertyValueChanged += new PropertyValueChangedEventHandler(propertyGrid2_PropertyValueChanged);
            tabGreek.Text    = new string((char)0x03b1, 1) + " - " + new string((char)0x03c9, 1);
            NodeTypes        = new List <Type>();     //decimal nodes
            NodeTypesLogic   = new List <Type>();     //logic nodes
            NodeTypesInteger = new List <Type>();     //integer nodes
            NodeTypesString  = new List <Type>();     //string nodes
            NodeTypesOther   = new List <Type>();     //other nodes
            //load types in this DLL
            Type[]      tps0  = this.GetType().Assembly.GetExportedTypes();
            List <Type> types = MathNode.MathNodePlugIns;

            Type[] tps = new Type[tps0.Length + types.Count];
            tps0.CopyTo(tps, 0);
            types.CopyTo(tps, tps0.Length);
            for (int i = 0; i < tps.Length; i++)
            {
                enumOperatorCategory opCat = MathNodeCategoryAttribute.GetTypeCategory(tps[i]);
                if (opCat != enumOperatorCategory.Internal)
                {
                    if (!tps[i].IsAbstract && tps[i].IsSubclassOf(typeof(MathNode)))
                    {
                        if (!tps[i].Equals(typeof(MathNodeRoot)))
                        {
                            if ((opCat & enumOperatorCategory.Logic) != 0)
                            {
                                NodeTypesLogic.Add(tps[i]);
                            }
                            if ((opCat & enumOperatorCategory.Integer) != 0)
                            {
                                NodeTypesInteger.Add(tps[i]);
                            }
                            if ((opCat & enumOperatorCategory.String) != 0)
                            {
                                NodeTypesString.Add(tps[i]);
                            }
                            if ((opCat & enumOperatorCategory.System) != 0)
                            {
                                if (ExcludeProjectItem)
                                {
                                    object[] vs = tps[i].GetCustomAttributes(typeof(ProjectItemAttribute), true);
                                    if (vs != null && vs.Length > 0)
                                    {
                                        continue;
                                    }
                                }
                                NodeTypesOther.Add(tps[i]);
                            }
                            if ((opCat & enumOperatorCategory.Decimal) != 0)
                            {
                                NodeTypes.Add(tps[i]);
                            }
                        }
                    }
                }
            }
            //load types from configuration XML
            string file = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(this.GetType().Assembly.Location), "MathTypes.xml");

            if (System.IO.File.Exists(file))
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(file);
                if (doc.DocumentElement != null)
                {
                    for (int i = 0; i < doc.DocumentElement.ChildNodes.Count; i++)
                    {
                        try
                        {
                            Type t = XmlUtil.GetLibTypeAttribute(doc.DocumentElement.ChildNodes[i]);
                            enumOperatorCategory opCat = MathNodeCategoryAttribute.GetTypeCategory(t);
                            if (opCat != enumOperatorCategory.Internal)
                            {
                                if ((opCat & enumOperatorCategory.Logic) != 0)
                                {
                                    if (!NodeTypesLogic.Contains(t))
                                    {
                                        NodeTypesLogic.Add(t);
                                    }
                                }
                            }
                            if ((opCat & enumOperatorCategory.Integer) != 0)
                            {
                                if (!NodeTypesInteger.Contains(t))
                                {
                                    NodeTypesInteger.Add(t);
                                }
                            }
                            if ((opCat & enumOperatorCategory.String) != 0)
                            {
                                if (!NodeTypesString.Contains(t))
                                {
                                    NodeTypesString.Add(t);
                                }
                            }
                            if ((opCat & enumOperatorCategory.System) != 0)
                            {
                                if (!NodeTypesOther.Contains(t))
                                {
                                    NodeTypesOther.Add(t);
                                }
                            }
                            if ((opCat & enumOperatorCategory.Decimal) != 0)
                            {
                                if (!NodeTypes.Contains(t))
                                {
                                    NodeTypes.Add(t);
                                }
                            }
                        }
                        catch (Exception err)
                        {
                            MessageBox.Show(err.Message);
                        }
                    }
                }
            }
            typeIcons1.Category        = enumOperatorCategory.Decimal;
            typeIcons1.lblTooltips     = lblTooltips;
            typeIcons1.OnTypeSelected += new EventHandler(typeIcons1_OnTypeSelected);
            typeIcons1.LoadData(NodeTypes);

            typeIconsLogic.lblTooltips     = lblTooltips;
            typeIconsLogic.Category        = enumOperatorCategory.Logic;
            typeIconsLogic.OnTypeSelected += new EventHandler(typeIcons1_OnTypeSelected);
            typeIconsLogic.LoadData(NodeTypesLogic);

            typeIconsInteger.lblTooltips     = lblTooltips;
            typeIconsInteger.Category        = enumOperatorCategory.Integer;
            typeIconsInteger.OnTypeSelected += new EventHandler(typeIcons1_OnTypeSelected);
            typeIconsInteger.LoadData(NodeTypesInteger);

            typeIconsString.lblTooltips     = lblTooltips;
            typeIconsString.Category        = enumOperatorCategory.String;
            typeIconsString.OnTypeSelected += new EventHandler(typeIcons1_OnTypeSelected);
            typeIconsString.LoadData(NodeTypesString);

            typeIconsOther.lblTooltips     = lblTooltips;
            typeIconsOther.Category        = enumOperatorCategory.System;
            typeIconsOther.OnTypeSelected += new EventHandler(typeIcons1_OnTypeSelected);
            typeIconsOther.LoadData(NodeTypesOther);

            //
            greekLetters1.OnLetterSelected += new EventHandler(greekLetters1_OnLetterSelected);
            //
            mathExpCtrl1.OnFinish         += new EventHandler(btOK_Click);
            mathExpCtrl1.OnCancel         += new EventHandler(btCancel_Click);
            mathExpCtrl1.OnCreateCompound += new EventHandler(mathExpCtrl1_OnCreateCompound);
            //
            //
            MethodType mt = (MethodType)MathNode.GetService(typeof(MethodType));

            typeIconsOther.SetIconVisible(typeof(MathNodeArgument), (mt != null && mt.ParameterCount > 0));
            //
            propertyGrid2.SetOnValueChange(onValueChanged);
            //
            if (Clipboard.ContainsData("MathNode"))
            {
                btPaste.Enabled    = true;
                btPaste.ImageIndex = IMG_Paste_Enable;
            }
            tabControl1.SelectedTab = tabPageOther;
            typeIconsOther.LoadIcons();
        }