示例#1
0
 private void value_Changed(FunctionParameters parameters, EventArgs e)
 {
     if (null != OnItemChange)
     {
         OnItemChange(parameters, e);
     }
 }
示例#2
0
        /// <summary>
        /// Show or hide some context menu items
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void contextMenu_Popup(object sender, System.EventArgs e)
        {
            try
            {
                FunctionParameters equation = null;
                if (this.tvEquations.SelectedNode != null)
                {
                    equation = ((FunctionNode)this.tvEquations.SelectedNode).Item as FunctionParameters;
                }


                if (equation == null)
                {
                    _currentItem = null;
                    this.menuItem_Delete.Visible = false;
                    this.menuItem_Edit.Visible   = false;
                    this.menuItem_Use.Visible    = false;
                    this.menuItem1.Visible       = false;
                }
                else
                {
                    _currentItem = equation;
                    this.menuItem_Delete.Visible = true;
                    this.menuItem_Edit.Visible   = true;
                    this.menuItem_Use.Visible    = true;
                    this.menuItem1.Visible       = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Can't get node tag. Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#3
0
        private static bool CheckUsageFunction(MethodInfo methodInfo)
        {
            //int inputDimension = XRandom.next(8, (XRandom.next(9, Configuration.InputDimension)));
            int inputDimension = Configuration.maxInputDimension;

            // generate parameters
            FunctionParameters functionParameters = new FunctionParameters(methodInfo, inputDimension, 0);

            debug($"Method : {methodInfo.Name}");
            string json = JsonConvert.SerializeObject(functionParameters);

            debug($"Params: {json}");

            // execute function
            var function = new Function(methodInfo);

            double[] result = function.Execute(functionParameters, out var code);

            debug($"Code: {code}");
            string resultJson = JsonConvert.SerializeObject(result);

            debug($"Result : {resultJson}");

            // check function output
            if (result == null || result.Length <= 1 || double.IsNegativeInfinity(result[0]) || double.IsPositiveInfinity(result[0]) ||
                double.IsNaN(result[0]) || double.IsInfinity(result[0]) || IsArrayRepeating(result))
            {
                return(false);
            }

            return(true);
        }
示例#4
0
        private void EditEquation(FunctionParameters equation)
        {
            if (equation != null)
            {
                FunctionParameters newEquation = (FunctionParameters)equation.Clone();

                NugenCCalcBase component = null;
                if (_is3DDesigner)
                {
                    component = new NugenCCalc3D();
                    component.FunctionParameters = (Function3DParameters)newEquation;
                }
                else
                {
                    component = new NugenCCalc2D();
                    component.FunctionParameters = (Function2DParameters)newEquation;
                }


                EquationForm frmEquation = new EquationForm(component);

                if (frmEquation.ShowDialog() == DialogResult.OK)
                {
                    equation.Name    = component.FunctionParameters.Name;
                    equation.Formula = component.FunctionParameters.Formula;
                    //equation.FunctionType = frmEquation.Equation.FunctionType;
                }
            }
            this.equationExplorer.Init();
        }
 public FunctionsStruct(string funcNam, string funcPars, string ret, PawnDocParser pwnDoc)
 {
     FuncName       = funcNam;
     FuncParameters = new FunctionParameters(funcPars);
     FuncPawnDoc    = pwnDoc;
     ReturnTag      = ret;
 }
        private void EditExpression(FunctionParameters expression)
        {
            if (expression != null)
            {
                FunctionParameters newExpression = (FunctionParameters)expression.Clone();

                NugenCCalcBase component = null;
                if (_is3DDesigner)
                {
                    component = new NugenCCalc3D();
                    component.FunctionParameters = (Function3DParameters)newExpression;
                }
                else
                {
                    component = new NugenCCalc2D();
                    component.FunctionParameters = (Function2DParameters)newExpression;
                }
                ExpressionForm frmExpression = new ExpressionForm(component);

                if (frmExpression.ShowDialog() == DialogResult.OK)
                {
                    expression.Name         = frmExpression.Component.FunctionParameters.Name;
                    expression.CodeLanguage = frmExpression.Component.FunctionParameters.CodeLanguage;
                    expression.Code         = frmExpression.Component.FunctionParameters.Code;
                }
            }
            this.expressionExplorer.Init();
        }
示例#7
0
 private void UseEquation(FunctionParameters equation)
 {
     if (equation != null)
     {
         if (MessageBox.Show(this, "Are you sure that you want use this equation as source for component?", "Equation repository", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             //_component.FunctionParameters = equation;
             _component.FunctionParameters         = (FunctionParameters)Activator.CreateInstance(equation.GetType());
             _component.FunctionParameters.Formula = equation.Formula;
             if (_component.FunctionParameters.GetType() == typeof(Parametric2DParameters))
             {
                 (_component.FunctionParameters as Parametric2DParameters).FormulaY = (equation as Parametric2DParameters).FormulaY;
             }
             if (_component.FunctionParameters.GetType() == typeof(Parametric3DParameters))
             {
                 (_component.FunctionParameters as Parametric3DParameters).FormulaY = (equation as Parametric3DParameters).FormulaY;
                 (_component.FunctionParameters as Parametric3DParameters).FormulaZ = (equation as Parametric3DParameters).FormulaZ;
             }
             if (_component.FunctionParameters.GetType() == typeof(ParametricSurfaceParameters))
             {
                 (_component.FunctionParameters as ParametricSurfaceParameters).FormulaY = (equation as ParametricSurfaceParameters).FormulaY;
                 (_component.FunctionParameters as ParametricSurfaceParameters).FormulaZ = (equation as ParametricSurfaceParameters).FormulaZ;
             }
             _component.FunctionParameters.Name       = equation.Name;
             _component.FunctionParameters.SourceType = SourceType.Equation;
         }
     }
 }
		public int Add(FunctionParameters value)  
		{
			int retValue = List.Add( value );
			value.Changed +=new ParametersChangeHandler(value_Changed);
			Change(this, new EventArgs());
			return retValue;
		}
示例#9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="item"></param>
 /// <param name="action"></param>
 private void ItemAction(FunctionParameters item, string action)
 {
     if (OnItemAction != null)
     {
         OnItemAction(this, new ItemEventArgs(item, action));
     }
 }
 private void DeleteExpression(FunctionParameters expression)
 {
     if (expression != null)
     {
         PredefinedSettings.Instance.Expressions.Remove(expression);
         this.expressionExplorer.Init();
     }
 }
示例#11
0
        public int Add(FunctionParameters value)
        {
            int retValue = List.Add(value);

            value.Changed += new ParametersChangeHandler(value_Changed);
            Change(this, new EventArgs());
            return(retValue);
        }
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
        {
            PropertyDescriptorCollection baseProps =
                TypeDescriptor.GetProperties(value, attributes, true);

            FunctionParameters           parameters     = value as FunctionParameters;
            PropertyDescriptorCollection propCollection = null;

            PropertyDescriptor[] resultPropCollection = null;


            if (parameters != null)
            {
                propCollection = TypeDescriptor.GetProperties(parameters.GetType(), new Attribute[] { new BrowsableAttribute(true) });
                int index = 0;
                switch (parameters.SourceType)
                {
                case SourceType.Equation:
                    resultPropCollection = (PropertyDescriptor[])Array.CreateInstance(typeof(PropertyDescriptor), propCollection.Count - 2);

                    foreach (PropertyDescriptor propertyDescriptor in propCollection)
                    {
                        if (propertyDescriptor.DisplayName != "Code" && propertyDescriptor.DisplayName != "CodeLanguage")
                        {
                            resultPropCollection.SetValue(propertyDescriptor, index);
                            index++;
                        }
                    }
                    break;

                case SourceType.CodeExpression:
                    int formulaCount = 0;
                    foreach (PropertyDescriptor propertyDescriptor in propCollection)
                    {
                        if (propertyDescriptor.DisplayName.StartsWith("Formula"))
                        {
                            formulaCount++;
                        }
                    }


                    resultPropCollection = (PropertyDescriptor[])Array.CreateInstance(typeof(PropertyDescriptor), propCollection.Count - formulaCount);

                    foreach (PropertyDescriptor propertyDescriptor in propCollection)
                    {
                        if (!propertyDescriptor.DisplayName.StartsWith("Formula"))
                        {
                            resultPropCollection.SetValue(propertyDescriptor, index);
                            index++;
                        }
                    }
                    break;
                }
            }

            return(new PropertyDescriptorCollection(resultPropCollection));
        }
示例#13
0
 /// <inheritdoc/>
 public IObservable <QueuedStoreDto> Enqueue(EnqueueRequest enqueueRequest, FunctionParameters parameters) =>
 Observable.Return(new QueuedStoreDto
 {
     Store = enqueueRequest.Store,
     User  = new UserDto {
         Id = enqueueRequest.UserId
     },
     RemainingQueueTime = DateTimeOffset.Now.AddHours(1.5)
 });
示例#14
0
        public static void Parse(string code, string fileName, CodeParts parts, bool add = true)
        {
            foreach (Match match in Regex.Matches(code, "enum\\s+([^\\n;\\(\\)\\{\\}\\s]*)\\s+(?:(?:[{])([^}]+)(?:[}]))"))
            {
                string[] enumds = match.Groups[2].Value.Split(',');

                //Variable to store the enums contents.
                List <EnumsContentsClass> enumStuff = new List <EnumsContentsClass>();

                foreach (string enumatmp in enumds)
                {
                    string enuma = enumatmp;
                    //Check if empty
                    if (ReferenceEquals(enuma, null) || enuma.Trim() == "")
                    {
                        continue;
                    }

                    int length = enuma.Length + 1;
                    enuma = enuma.Trim();
                    var type = FunctionParameters.GetVarType(enuma);

                    //Do what needs to be changed
                    if (type == FunctionParameters.VarTypes.TypeFloat)
                    {
                        enuma = enuma.Remove(0, 6);
                    }
                    else if (type == FunctionParameters.VarTypes.TypeArray)
                    {
                        enuma = enuma.Remove(enuma.IndexOf("["), (enuma.IndexOf("]") - enuma.IndexOf("[")) + 1);
                    }
                    else if (type == FunctionParameters.VarTypes.TypeTagged)
                    {
                        enuma = enuma.Remove(0, enuma.IndexOf(":") + 1);
                    }

                    try
                    {
                        enumStuff.Add(new EnumsContentsClass(enuma, type));
                    }
                    catch (Exception)
                    {
                    }
                }

                //Now add it to the actual list.
                if (add)
                {
                    parts.Enums.Add(new EnumsStruct(match.Groups[1].Value.Trim(), enumStuff));
                }
                else
                {
                    parts.Enums.RemoveAll(x => x.EnumName == match.Groups[1].Value.Trim());
                }
            }
        }
示例#15
0
        public SetterFunction(ClassMember classMember) : base(classMember.Owner, $"set{classMember.Name.ToUpperFirstCharacter()}", JavaVoid)
        {
            ClassMember = classMember;
            var fp = new FunctionParameter(classMember.Name, ClassMember.Type);

            FunctionParameters.Add(fp);
            Expressions.Add(new AssignExpression {
                Destination = classMember, Source = fp
            });
        }
    public string npcName(NPC npc)
    {
        //if (!stringFunctions.ContainsKey("s_npcName"))
        //    return "{npcName}";

        FunctionParameters parameters = new FunctionParameters("_NPC", npc);

        //return stringFunctions["s_npcName"].value(parameters);
        return(functionExecute("s_npcName", parameters));
    }
 internal FunctionImportModel(IEdmModel model, IEdmFunctionImport functionImport, string endpointUri, string proxyClassNamespace)
 {
     FunctionImport     = functionImport;
     EndpointUri        = endpointUri;
     HttpMethod         = model.GetHttpMethod(functionImport) ?? "POST";
     FunctionParameters = functionImport.Parameters.ToList();
     BindableParameter  = FunctionParameters.FirstOrDefault(fp => fp.Type.IsEntity() || fp.Type.IsCollection() && fp.Type.AsCollection().ElementType().IsEntity());
     EntitySetName      = functionImport.IsBindable && BindableParameter != null
         ? (BindableParameter.Type.IsCollection() ? BindableParameter.Type.AsCollection().ElementType().FullNameWithNamespace(proxyClassNamespace).Split('.').Last() : BindableParameter.Type.FullNameWithNamespace(proxyClassNamespace).Split('.').Last())
         : string.Empty;
     FunctionReturnType = functionImport.ReturnType;
 }
示例#18
0
 public ConstructorFunction(Class clazz) : base(clazz, $"{clazz.Name}", JavaVoid)
 {
     Class = clazz;
     Class.ClassMembers.ClassMembers.ForEach(x =>
     {
         var fp = new FunctionParameter(x.Name, x.Type);
         FunctionParameters.Add(fp);
         Expressions.Add(new AssignExpression {
             Destination = x, Source = fp
         });
     });
 }
示例#19
0
        public Function(int id, string name)
        {
            ID          = id;
            Name        = name;
            CodeLines   = new CodeLines(this);
            Parameters  = new FunctionParameters(this);
            ReturnValue = new FunctionReturnValue(this);
            Variables   = new FunctionVariables(this);

#if NAV2016
            EventPublisherObject = new ObjectReference();
#endif
        }
 private void UseExpression(FunctionParameters expression)
 {
     if (expression != null)
     {
         if (MessageBox.Show(this, "Are you sure that you want use this expression as source for component?", "Equation repository", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             _component.FunctionParameters              = (FunctionParameters)Activator.CreateInstance(expression.GetType());
             _component.FunctionParameters.Name         = expression.Name;
             _component.FunctionParameters.CodeLanguage = expression.CodeLanguage;
             _component.FunctionParameters.Code         = expression.Code;
             _component.FunctionParameters.SourceType   = SourceType.CodeExpression;
         }
     }
 }
    public dynamic functionExecute(string id, FunctionParameters parameters)
    {
        switch (id)
        {
        case "npcIsPresent":
            return(GameManager.Instance.npcIsPresent(parameters["_NPCID"]));
        }

        if (!_dict.ContainsKey(id))
        {
            throw new NotImplementedException($"Function {id} can not be found");
        }

        return(_dict[id].value(parameters));
    }
示例#22
0
    public void procedureExecute(string id, Data data, IEnumerable <dynamic> parameters = null)
    {
        Dictionary <string, Data> paramDict = new Dictionary <string, Data>();

        paramDict["_GLOBAL"] = GameManager.Instance.GameData;//data;
        paramDict["_P"]      = new FunctionParameters(data, parameters);

        Data d = new DataCombined(paramDict);

        if (!_dict.ContainsKey(id))
        {
            throw new NotImplementedException($"Function {id} can not be found");
        }


        _dict[id].execute(d);
    }
示例#23
0
        /// <summary>
        /// Create nodes
        /// </summary>
        public void Init()
        {
            try
            {
                if (this._equations == null)
                {
                    return;
                }

                _currentItem = null;
                this.tvEquations.Nodes.Clear();
                // create root nodes
                TreeNode root = new TreeNode();
                root.Text               = "Equations";
                root.ImageIndex         = 0;
                root.SelectedImageIndex = 1;
                FunctionNode node = null;

                if (_is3DDesigner)
                {
                    foreach (FunctionParameters equation in _equations.Functions3D)
                    {
                        node                    = new FunctionNode(equation);
                        node.ImageIndex         = 2;
                        node.SelectedImageIndex = 2;
                        root.Nodes.Add(node);
                    }
                }
                else
                {
                    foreach (FunctionParameters equation in _equations.Functions2D)
                    {
                        node                    = new FunctionNode(equation);
                        node.ImageIndex         = 2;
                        node.SelectedImageIndex = 2;
                        root.Nodes.Add(node);
                    }
                }
                this.tvEquations.Nodes.Add(root);
                this.tvEquations.ExpandAll();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Unknown error. Error:" + ex.Message, "Equation repository view", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#24
0
        private string GetFunctionFooter(FunctionParameters function, CodeLanguage codeLanguage)
        {
            Type functionType = function.GetType();;

            FunctionCodeAttribute[] attributes =
                (FunctionCodeAttribute[])functionType.GetCustomAttributes(
                    typeof(FunctionCodeAttribute), false);
            switch (codeLanguage)
            {
            case CodeLanguage.CSharp:
                return((attributes.Length > 0) ? attributes[0].SharpFooter : "");

            case CodeLanguage.VBNET:
                return((attributes.Length > 0) ? attributes[0].VBFooter : "");
            }
            return("");
        }
示例#25
0
        private void tvEquations_DoubleClick(object sender, System.EventArgs e)
        {
            try
            {
                FunctionNode FunctionNode = tvEquations.GetNodeAt(tvEquations.PointToClient(Cursor.Position)) as FunctionNode;

                _currentItem = null;

                if (FunctionNode != null)
                {
                    _currentItem             = (FunctionParameters)FunctionNode.Item;
                    tvEquations.SelectedNode = FunctionNode;
                    ItemAction(_currentItem, "Edit");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Can't get node tag. Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#26
0
        private void tvEquations_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
        {
            try
            {
                FunctionNode FunctionNode = e.Node as FunctionNode;

                _currentItem = null;

                if (FunctionNode != null)
                {
                    _currentItem = (FunctionParameters)FunctionNode.Item;
                }
                else
                {
                    this.tvEquations.SelectedNode = e.Node.NextVisibleNode;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Can't get node tag. Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#27
0
        public static IFitnessFunction<double[], double[]> GetFitnessFunction(FunctionParameters parameters)
        {
            if (functionCache.ContainsKey(parameters.FitnessFunctionType))
            {
                return functionCache[parameters.FitnessFunctionType];
            }
            if (parameters.FitnessFunctionType.Contains("bbob"))
            {
                var functionId = parameters.FitnessFunctionType;
                Problem problem;
                /* Iterate over all problems in the suite */
                restartBbob(parameters.Dimension);
                while ((problem = benchmark.getNextProblem()) != null)
                {
                    if (problem.Id != functionId) continue;
                    var upper = problem.getLargestValuesOfInterest();
                    var bounds =
                        problem.getSmallestValuesOfInterest()
                            .Select((x, i) => new DimensionBound(x, upper[i]))
                            .ToArray();
                    parameters.SearchSpace = bounds;
                    var function = new FitnessFunction(problem.evaluateFunction);
                    return function;
                }

            }
            switch (parameters.FitnessFunctionType)
            {
                case "quadratic":
                    return new QuadraticFunction(parameters);
                case "rastrigin":
                    return new RastriginFunction(parameters);
                case "rosenbrock":
                    return new RosenbrockFunction(parameters);
                default:
                    throw new ArgumentException("Unknown function type.");
            }
        }
示例#28
0
        /// <summary>
        /// Добавить параметры функции.
        /// </summary>
        /// <param name="function"></param>
        /// <param name="method"></param>
        private void GetFunctionParameters(IFunction function, MethodInfo method)
        {
            IValue             default_value = null;
            FunctionParameters parameters    = new FunctionParameters();


            var array_param = method.GetParameters().Where(x => x.ParameterType == typeof(IValue[]));

            if (array_param.Count() > 0)
            {
                parameters.AnyCount = true;
                if (array_param.Count() > 1)
                {
                    throw new Exception("Тип параметра IValue[] может быть только один.");
                }
                if (array_param.First().HasDefaultValue)
                {
                    throw new Exception("Тип параметра IValue[] не может иметь значение по умолчанию.");
                }

                function.DefinedParameters = parameters;
                return;
            }

            foreach (ParameterInfo param_info in method.GetParameters())
            {
                if (param_info.HasDefaultValue)
                {
                    default_value = ValueFactory.Create(param_info.ParameterType, param_info.DefaultValue);
                }

                parameters.CreateByRef(param_info.Name, null, default_value);
            }

            function.DefinedParameters = parameters;
        }
		private void DeleteExpression(FunctionParameters expression)
		{
			if (expression != null)
			{
				PredefinedSettings.Instance.Expressions.Remove(expression);
				this.expressionExplorer.Init();
			}
		}
		private void value_Changed(FunctionParameters parameters, EventArgs e)
		{
			if( null != OnItemChange )
			{
				OnItemChange( parameters, e);
			}
		}
示例#31
0
 public IObservable <IEnumerable <StoreDto> > GetStores(FunctionParameters parameters) =>
 Observable
 .Return(Items)
 .Delay(TimeSpan.FromSeconds(5));
示例#32
0
 public RastriginFunction(FunctionParameters functionParams)
     : base(functionParams)
 {
 }
示例#33
0
 public QuadraticFunction(FunctionParameters functionParams)
     : base(functionParams)
 {
 }
		private void Expressions_OnItemChange(FunctionParameters item, EventArgs e)
		{
			PredefinedSettings.SavePredefinedSettings();
		}
		private void tvExpressions_DoubleClick(object sender, System.EventArgs e)
		{
			try
			{
				FunctionNode FunctionNode = tvExpressions.GetNodeAt(tvExpressions.PointToClient(Cursor.Position)) as FunctionNode;

				_currentItem = null;

				if (FunctionNode != null) 
				{
					_currentItem = FunctionNode.Item;
					tvExpressions.SelectedNode = FunctionNode;
					ItemAction(_currentItem, "Edit");
				}
			}
			catch(Exception ex)
			{
				MessageBox.Show(this,"Can't get node tag. Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
			}
		}
		/// <summary>
		/// Show or hide some context menu items
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void contextMenuTreeView_Popup(object sender, System.EventArgs e)
		{
			FunctionParameters expression = null;
			if (this.tvExpressions.SelectedNode != null)
			{
				expression = ((FunctionNode)this.tvExpressions.SelectedNode).Item as FunctionParameters;
			}

			try
			{
				if (expression == null) 
				{
					_currentItem = null;
					this.menuItem_Delete.Visible = false;
					this.menuItem_Edit.Visible = false;
					this.menuItem_Use.Visible = false;
					this.menuItem1.Visible = false;
				}
				else
				{
					_currentItem = expression;
					this.menuItem_Delete.Visible = true;
					this.menuItem_Edit.Visible = true;
					this.menuItem_Use.Visible = true;
					this.menuItem1.Visible = true;
				}
			}
			catch(Exception ex)
			{
				MessageBox.Show(this,"Can't get node tag. Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
			}
		}
		private void tvExpressions_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
		{
			try
			{
				FunctionNode FunctionNode = e.Node as FunctionNode;

				_currentItem = null;

				if (FunctionNode != null) 
					_currentItem = (FunctionParameters)FunctionNode.Item;
				else
					tvExpressions.SelectedNode = e.Node.NextVisibleNode;				
			}
			catch(Exception ex)
			{
				MessageBox.Show(this,"Can't get node tag. Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
			}
		}
		private void ItemAction (FunctionParameters item, string action)
		{
			if (OnItemAction!=null)
			{
				OnItemAction(this, new ItemEventArgs(item,action));
			}
		}
		/// <summary>
		/// Create tree nodes
		/// </summary>
		public void Init()
		{
			try
			{
				if (this._expressions == null)
					return;

				_currentItem = null;
				this.tvExpressions.Nodes.Clear();
				// create root nodes
				TreeNode root = new TreeNode();
				root.Text = "Code Expressions";
				root.ImageIndex = 0;
				root.SelectedImageIndex = 1;
				FunctionNode node = null;


				if (_is3DDesigner)
				{
					foreach(FunctionParameters expression in _expressions.Functions3D)
					{
						node = new FunctionNode(expression);
						switch(expression.CodeLanguage)
						{
							case CodeLanguage.CSharp:
								node.ImageIndex = 2;
								node.SelectedImageIndex = 2;
								break;
							case CodeLanguage.VBNET:
								node.ImageIndex = 3;
								node.SelectedImageIndex = 3;
								break;
						}

						root.Nodes.Add(node);

					}
				}
				else
				{
					foreach(FunctionParameters expression in _expressions.Functions2D)
					{
						node = new FunctionNode(expression);
						switch(expression.CodeLanguage)
						{
							case CodeLanguage.CSharp:
								node.ImageIndex = 2;
								node.SelectedImageIndex = 2;
								break;
							case CodeLanguage.VBNET:
								node.ImageIndex = 3;
								node.SelectedImageIndex = 3;
								break;
						}

						root.Nodes.Add(node);

					}
				}


				this.tvExpressions.Nodes.Add(root);
				this.tvExpressions.ExpandAll();
			}
			catch (Exception ex)
			{
				MessageBox.Show(this, "Unknown error. Error:" + ex.Message, "Expression repository view", MessageBoxButtons.OK, MessageBoxIcon.Error);
			}
		}
		public void Insert( int index, FunctionParameters value )  
		{
			List.Insert( index, value );
			value.Changed+=new ParametersChangeHandler(value_Changed);
			Change(this, new EventArgs());
		}
示例#41
0
		/// <summary>
		/// Subscribe on seft event Changed
		/// </summary>
		/// <param name="item"></param>
		/// <param name="e"></param>
		private void _functionParameters_Changed(FunctionParameters parameters, EventArgs e)
		{
			NotifyDataChanged();
		}
		private void EditExpression(FunctionParameters expression)
		{
			if (expression != null)
			{
				FunctionParameters newExpression = (FunctionParameters)expression.Clone();

				NugenCCalcBase component = null;
				if (_is3DDesigner)
				{
					component = new NugenCCalc3D();
					component.FunctionParameters = (Function3DParameters)newExpression;
				}
				else
				{
					component = new NugenCCalc2D();
					component.FunctionParameters = (Function2DParameters)newExpression;
				}
				ExpressionForm frmExpression = new ExpressionForm(component);

				if (frmExpression.ShowDialog() == DialogResult.OK)
				{
					expression.Name = frmExpression.Component.FunctionParameters.Name;
					expression.CodeLanguage = frmExpression.Component.FunctionParameters.CodeLanguage;
					expression.Code = frmExpression.Component.FunctionParameters.Code;
				}
			}
			this.expressionExplorer.Init();

		}
		private void UseExpression(FunctionParameters expression)
		{
			if (expression != null)
			{
				if (MessageBox.Show(this, "Are you sure that you want use this expression as source for component?", "Equation repository", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
				{
                    _component.FunctionParameters = (FunctionParameters)Activator.CreateInstance(expression.GetType());
                    _component.FunctionParameters.Name = expression.Name;
                    _component.FunctionParameters.CodeLanguage = expression.CodeLanguage;
                    _component.FunctionParameters.Code = expression.Code;
                    _component.FunctionParameters.SourceType = SourceType.CodeExpression;
				}
			}
		}
 private void Expressions_OnItemChange(FunctionParameters item, EventArgs e)
 {
     PredefinedSettings.SavePredefinedSettings();
 }
		public bool Contains( FunctionParameters value )  
		{
			return( List.Contains( value ) );
		}
示例#46
0
		/// <summary>
		/// Initializes a new instance of the ItemEventArgs class 
		/// </summary>
		/// <param name="item"></param>
		/// <param name="action"></param>
		public ItemEventArgs(FunctionParameters item, string action) : this (item)
		{
			this._action = action;
		}
		public void Remove( FunctionParameters value )  
		{
			List.Remove( value );
			Change(this, new EventArgs());
		}
示例#48
0
		public FunctionNode(FunctionParameters item) : base(item.ToString())
		{
			_item = item;
			//BindEvents();
		}
示例#49
0
		/// <summary>
		/// Initializes a new instance of the ItemEventArgs class 
		/// </summary>
		/// <param name="item"></param>
		public ItemEventArgs(FunctionParameters item) : base ()
		{
			this._item = item;
		}
		private void EditEquation(FunctionParameters equation)
		{
			if (equation != null)
			{
				FunctionParameters newEquation = (FunctionParameters)equation.Clone();

				NugenCCalcBase component = null;
				if (_is3DDesigner)
				{
					component = new NugenCCalc3D();
					component.FunctionParameters = (Function3DParameters)newEquation;
				}
				else
				{
					component = new NugenCCalc2D();
					component.FunctionParameters = (Function2DParameters)newEquation;
				}


				EquationForm frmEquation = new EquationForm(component);

				if (frmEquation.ShowDialog() == DialogResult.OK)
				{
					equation.Name = component.FunctionParameters.Name;
					equation.Formula = component.FunctionParameters.Formula;
					//equation.FunctionType = frmEquation.Equation.FunctionType;
				}
			}
			this.equationExplorer.Init();
		}
		private void UseEquation(FunctionParameters equation)
		{
			if (equation != null)
			{
				if (MessageBox.Show(this, "Are you sure that you want use this equation as source for component?", "Equation repository", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
				{
                    //_component.FunctionParameters = equation;
                    _component.FunctionParameters = (FunctionParameters)Activator.CreateInstance(equation.GetType());
                    _component.FunctionParameters.Formula = equation.Formula;
                    if (_component.FunctionParameters.GetType() == typeof(Parametric2DParameters))
                        (_component.FunctionParameters as Parametric2DParameters).FormulaY = (equation as Parametric2DParameters).FormulaY;
                    if (_component.FunctionParameters.GetType() == typeof(Parametric3DParameters))
                    {
                        (_component.FunctionParameters as Parametric3DParameters).FormulaY = (equation as Parametric3DParameters).FormulaY;
                        (_component.FunctionParameters as Parametric3DParameters).FormulaZ = (equation as Parametric3DParameters).FormulaZ;
                    }
                    if (_component.FunctionParameters.GetType() == typeof(ParametricSurfaceParameters))
                    {
                        (_component.FunctionParameters as ParametricSurfaceParameters).FormulaY = (equation as ParametricSurfaceParameters).FormulaY;
                        (_component.FunctionParameters as ParametricSurfaceParameters).FormulaZ = (equation as ParametricSurfaceParameters).FormulaZ;
                    }
                    _component.FunctionParameters.Name = equation.Name;
                    _component.FunctionParameters.SourceType = SourceType.Equation;

				}
			}
		}
示例#52
0
 public IObservable <StoreDto> GetStore(Guid storeId, FunctionParameters parameters) =>
 Observable
 .Return(Items.FirstOrDefault(x => x.Id == storeId))
 .Delay(TimeSpan.FromSeconds(1));
示例#53
0
 public RosenbrockFunction(FunctionParameters functionParams)
     : base(functionParams)
 {
 }
		public int IndexOf( FunctionParameters value )  
		{
			return( List.IndexOf( value ) );
		}
示例#55
0
 public IObservable <IEnumerable <string> > GetMetadata(FunctionParameters parameters) =>
 Observable
 .Return(Items.Select(x => x.Name).Distinct())
 .Delay(TimeSpan.FromSeconds(3));
示例#56
0
		private void _item_Changed(FunctionParameters parameters, EventArgs e)
		{
			base.Text = parameters.ToString();
		}