public bool AddNewFormula(ParserFormula formula) { //проверка на совподении имени foreach (var v in Formulas) { if (v.Name == formula.Name) { return(false); } } //регистрируем функцию switch (formula.variables.Count) { case 0: Log.SetMessage("Количество параметров = 0, " + formula.Name); break; case 1: Parser.DefineFun(formula.Name, new Parser.Fun1Delegate(formula.Eval)); break; case 2: Parser.DefineFun(formula.Name, new Parser.Fun2Delegate(formula.Eval)); break; case 3: Parser.DefineFun(formula.Name, new Parser.Fun3Delegate(formula.Eval)); break; case 4: Parser.DefineFun(formula.Name, new Parser.Fun4Delegate(formula.Eval)); break; case 5: Parser.DefineFun(formula.Name, new Parser.Fun5Delegate(formula.Eval)); break; default: Log.SetMessage("Первышено количество параметров, " + formula.Name); return(false); } //если все прошло успешно Formulas.Add(formula); return(true); }
public Rectangle() { List <ParameterTypes> params_ = new List <ParameterTypes> { ParameterTypes.SIDE_A, ParameterTypes.SIDE_B }; Formulas.Add(new Formula ( (parameters) => { double a = 0, b = 0; foreach (FormulaParameter fp in parameters) { switch (fp.Type) { case ParameterTypes.SIDE_A: a = fp.Value; break; case ParameterTypes.SIDE_B: b = fp.Value; break; } } return(a * b); } , params_ )); }
public async void PreviousPage() { Formulas.Clear(); _page--; var formulas = await _context.Formulas .OrderBy(x => x.Name) .Skip(_pagePayload * _page) .Take(_pagePayload) .ToListAsync(); foreach (var formula in formulas) { Formulas.Add(formula.ToDomain()); } RaisePropertyChanged("Formulas"); if (_page == 0) { IsPreviousPageButtonEnabled = false; } if (formulas.Count >= 10) { IsNextPageButtonEnabled = true; } }
public HexagonType() { this.ShapeConcentricFill = true; this.Joins = JoinStyle.miter; this.Path = "m@0,l,10800@0,21600@1,21600,21600,10800@1,xe"; this.Formulas = new List <string>(); Formulas.Add("val #0"); Formulas.Add("sum width 0 #0"); Formulas.Add("sum height 0 #0"); Formulas.Add("prod @0 2929 10000"); Formulas.Add("sum width 0 @3"); Formulas.Add("sum height 0 @3"); this.AdjustmentValues = "5400"; this.ConnectorLocations = "Rectangle"; this.TextboxRectangle = "1800,1800,19800,19800;3600,3600,18000,18000;6300,6300,15300,15300"; this.Handles = new List <Handle>(); Handle HandleOne = new Handle(); HandleOne.position = "#0,topLeft"; HandleOne.xrange = "0,10800"; Handles.Add(HandleOne); }
public void SetFormulaActive(object parameter) { FormulaQueries.setActive(SelectedInactive.CodFormula); Formulas.Add(SelectedInactive); InactiveFormulas.Remove(SelectedInactive); }
private string addFormulaToCache(IFormula formula) { if (!Formulas.Contains(formula)) { Formulas.Add(formula); } return(formula.Id); }
/// <summary> /// Setter for <see cref="Formulas"/> /// </summary> /// <param name="formula">Target formula</param> /// <exception cref="ArgumentNullException">If <paramref name="formula"/> is null</exception> /// <exception cref="ArgumentException"> /// If same formula already exist in <see cref="Formulas"/> /// </exception> public static void AddFormula(Formula formula) { if (formula == null) { throw new ArgumentNullException($"{nameof(formula)} can`t be null!"); } var formulaFromList = Formulas.FirstOrDefault(c => c.Equals(formula)); Formulas.Add(formula); }
public void AddFormulas(XmlNodeList formuls) { if (Formulas == null) { Formulas = new List <Formula>(); } foreach (XmlNode formulNode in formuls) { Formulas.Add(new Formula(formulNode)); } foreach (Area area in Areas) { area.InitArea(); } }
/// <summary> /// Рекурсивное разделение сложной формулы на простые /// </summary> /// <returns></returns> protected string SplitFormula(string input) { int open, close, begin, end; open = close = begin = end = 0; for (int i = 0; i < input.Length; i++) { if (input[i] == '(') { open++; begin = i; i++; while (open != close) { if (input[i] == '(') { open++; } if (input[i] == ')') { close++; } i++; } end = i - 1; var forReplace = input.Substring(begin, end - begin + 1); //со скобками var forNextStep = forReplace.Trim(new char[] { '(', ')' }); //без input = input.Replace(forReplace, SplitFormula(forNextStep)); input = "(" + input + ")"; //проверка на то, содержит ли формула отрицание всего if (input.StartsWith("(" + Formula.AccessNegativeOperator + "{") && input.EndsWith("})")) { input = Formulas.Last().View.Insert(1, Formula.AccessNegativeOperator.ToString()); Formulas.RemoveAt(Formulas.Count - 1); //удалить последний, чтобы потом заменить } Formulas.Add(new Formula(input)); return("{" + (Formulas.Count - 1) + "}"); } } input = "(" + input + ")"; Formulas.Add(new Formula(input)); var result = "{" + (Formulas.Count - 1) + "}"; return(result); }
public Circle() { List <ParameterTypes> params_ = new List <ParameterTypes>() { ParameterTypes.RADIUS }; Formulas.Add(new Formula ( (parameters) => { return(Circle.PI * Math.Pow(parameters[0].Value, 2)); } , params_ )); }
public Triangle() { //создаем список объектов формул. Сначала задаем необходимые параметры, //а потом - саму функцию, которая представляет собой формулу List <ParameterTypes> params_ = new List <ParameterTypes>() { ParameterTypes.SIDE_A, ParameterTypes.SIDE_B, ParameterTypes.SIDE_C }; Formulas.Add(new Formula ((parameters) => { double a = 0, b = 0, c = 0; foreach (FormulaParameter fp in parameters) { switch (fp.Type) { case ParameterTypes.SIDE_A: a = fp.Value; break; case ParameterTypes.SIDE_B: b = fp.Value; break; case ParameterTypes.SIDE_C: c = fp.Value; break; } } if (CheckIsRight(a, b, c) || CheckIsRight(a, c, b) || CheckIsRight(b, c, a)) { IsRight = true; } double p = (a + b + c) / 2; return(Math.Sqrt(p * (p - a) * (p - b) * (p - c))); } , params_ )); }
private async void SearchHandler(object param) { Formulas.Clear(); var textBox = param as TextBox; var searchQuery = textBox.Text; var formulas = await _context.Formulas .Where(p => p.Name.Contains(searchQuery)) .ToListAsync(); foreach (var formula in formulas) { Formulas.Add(formula.ToDomain()); } RaisePropertyChanged("Formulas"); }
protected async Task LoadFormulasFromFile() { try { var fmlList = await CoreManager.Current.FileHandler.GetFormulas(SubjectType); if (fmlList != null) { Formulas.Clear(); foreach (var f in fmlList) { Formulas.Add(f); } OnPropertyChanged(nameof(Formulas)); } } catch (Exception e) { Debug.WriteLine(e); } }
public void OrganizarFormulas(DataTable dt, int row) { if (dt.GetValue("SubSum", row) == "N") { return; } for (int i = 1; i < Addon._quantidade_campos_contas_formula; i++) { var catid_param = dt.GetValue(Addon._prefixo_campos_contas_formula + i, row); if (catid_param == 0) { continue; } var str_operacao = dt.GetValue(Addon._prefixo_campos_operacao_formula + i, row); var operacao = str_operacao == "+" ? TipoOperacao.Soma : (str_operacao == "-" ? TipoOperacao.Subtracao : TipoOperacao.Nenhuma); Formula formula = new Formula(catid_param, operacao); Formulas.Add(formula); } ; }
public void createFormula() { if (FormulaQueries.isRepeatedFormula(NewFormula.CodFormula)) { MessageBox.Show("Codigo de Formula ya existe."); } else { if (isTransform) { NewFormula.Transformacion = TransformFormula.CodFormula; } else { NewFormula.Transformacion = ""; } //MessageBox.Show(NewFormula.FormaFarm + NewFormula.Cantidad); //System.Windows.MessageBox.Show("This is form" + NewFormula.FormaFarm); FormulaQueries.agregarFormula(NewFormulaDetalles.ToList(), NewFormula); Formulas.Add(NewFormula); if (NewFormulaInstructions.Count > 0) { foreach (var element in NewFormulaInstructions) { CurrentStep++; FormulaQueries.agregarProcedimiento(element.Instruction, CurrentStep, NewFormula.CodFormula); } } System.Windows.MessageBox.Show("Formula Maestra creada."); limpiar(1); } }
internal void FromConditionalFormattingRule(ConditionalFormattingRule cfr) { SetAllNull(); if (cfr.Type != null) { Type = cfr.Type.Value; } if (cfr.FormatId != null) { FormatId = cfr.FormatId.Value; } Priority = cfr.Priority.Value; if (cfr.StopIfTrue != null) { StopIfTrue = cfr.StopIfTrue.Value; } if (cfr.AboveAverage != null) { AboveAverage = cfr.AboveAverage.Value; } if (cfr.Percent != null) { Percent = cfr.Percent.Value; } if (cfr.Bottom != null) { Bottom = cfr.Bottom.Value; } if (cfr.Operator != null) { Operator = cfr.Operator.Value; HasOperator = true; } if (cfr.Text != null) { Text = cfr.Text.Value; } if (cfr.TimePeriod != null) { TimePeriod = cfr.TimePeriod.Value; HasTimePeriod = true; } if (cfr.Rank != null) { Rank = cfr.Rank.Value; } if (cfr.StdDev != null) { StdDev = cfr.StdDev.Value; } if (cfr.EqualAverage != null) { EqualAverage = cfr.EqualAverage.Value; } using (var oxr = OpenXmlReader.Create(cfr)) { while (oxr.Read()) { if (oxr.ElementType == typeof(Formula)) { Formulas.Add((Formula)oxr.LoadCurrentElement().CloneNode(true)); } else if (oxr.ElementType == typeof(ColorScale)) { ColorScale = new SLColorScale(); ColorScale.FromColorScale((ColorScale)oxr.LoadCurrentElement()); HasColorScale = true; } else if (oxr.ElementType == typeof(DataBar)) { DataBar = new SLDataBar(); DataBar.FromDataBar((DataBar)oxr.LoadCurrentElement()); HasDataBar = true; } else if (oxr.ElementType == typeof(IconSet)) { IconSet = new SLIconSet(); IconSet.FromIconSet((IconSet)oxr.LoadCurrentElement()); HasIconSet = true; } else if (oxr.ElementType == typeof(ConditionalFormattingRuleExtension)) { Extensions.Add((ConditionalFormattingRuleExtension)oxr.LoadCurrentElement().CloneNode(true)); } } } }
internal void FromConditionalFormattingRule(X14.ConditionalFormattingRule cfr) { SetAllNull(); if (cfr.Type != null) { Type = cfr.Type.Value; } if (cfr.Priority != null) { Priority = cfr.Priority.Value; } if (cfr.StopIfTrue != null) { StopIfTrue = cfr.StopIfTrue.Value; } if (cfr.AboveAverage != null) { AboveAverage = cfr.AboveAverage.Value; } if (cfr.Percent != null) { Percent = cfr.Percent.Value; } if (cfr.Bottom != null) { Bottom = cfr.Bottom.Value; } if (cfr.Operator != null) { Operator = cfr.Operator.Value; HasOperator = true; } if (cfr.Text != null) { Text = cfr.Text.Value; } if (cfr.TimePeriod != null) { TimePeriod = cfr.TimePeriod.Value; HasTimePeriod = true; } if (cfr.Rank != null) { Rank = cfr.Rank.Value; } if (cfr.StandardDeviation != null) { StandardDeviation = cfr.StandardDeviation.Value; } if (cfr.EqualAverage != null) { EqualAverage = cfr.EqualAverage.Value; } if (cfr.ActivePresent != null) { ActivePresent = cfr.ActivePresent.Value; } if (cfr.Id != null) { Id = cfr.Id.Value; } using (var oxr = OpenXmlReader.Create(cfr)) { while (oxr.Read()) { if (oxr.ElementType == typeof(Formula)) { Formulas.Add((Formula)oxr.LoadCurrentElement().CloneNode(true)); } else if (oxr.ElementType == typeof(X14.ColorScale)) { ColorScale = new SLColorScale2010(); ColorScale.FromColorScale((X14.ColorScale)oxr.LoadCurrentElement()); HasColorScale = true; } else if (oxr.ElementType == typeof(X14.DataBar)) { DataBar = new SLDataBar2010(); DataBar.FromDataBar((X14.DataBar)oxr.LoadCurrentElement()); HasDataBar = true; } else if (oxr.ElementType == typeof(X14.IconSet)) { IconSet = new SLIconSet2010(); IconSet.FromIconSet((X14.IconSet)oxr.LoadCurrentElement()); HasIconSet = true; } else if (oxr.ElementType == typeof(X14.DifferentialType)) { DifferentialType = new SLDifferentialFormat(); DifferentialType.FromDifferentialType((X14.DifferentialType)oxr.LoadCurrentElement()); HasDifferentialType = true; } } } }