public override void Draw(System.Drawing.Graphics g) { Pen p = new Pen(Selected ? System.Drawing.Color.Red : System.Drawing.Color.Black); g.DrawRectangle(p, DrawRect); g.DrawString(InitialValue.ToString(), DCSFont, p.Brush, X, Y); }
private void AssociatedObject_Initialized(object sender, EventArgs e) { //LastKnowCaretPosition = 1; ((TextBox)sender).Text = InitialValue.ToString(); AssociatedObject.CaretIndex = InitialValue.ToString().Length; AssociatedObject.Focus(); }
public void OnCalculate() { try { dynamic initTemp = InitialValue; this.InitialValue = Convert.ToDecimal(Regex.Replace(InitialValue.ToString(), "-", "")); var initialValue = Convert.ToDouble(InitialValue.ToString().Contains("-") ? InitialValue : Convert.ToDecimal("-" + InitialValue)); var diff = UpperBoundRate - LowerBoundRate; int numberOfIncrement = Convert.ToInt32(diff / Increment); decimal lbr = LowerBoundRate; decimal ValueRate = Increment; for (int i = 1; i <= numberOfIncrement; i++) { //CashFlow 1 var discountFactor1 = 1 / Math.Pow(Convert.ToDouble(1 + lbr), 1); var presentValue1 = discountFactor1 * Convert.ToDouble(CashFlow1); //CashFlow 2 var discountFactor2 = 1 / Math.Pow(Convert.ToDouble(1 + lbr), 2); var presentValue2 = discountFactor2 * Convert.ToDouble(CashFlow2); //CashFlow 2 var discountFactor3 = 1 / Math.Pow(Convert.ToDouble(1 + lbr), 3); var presentValue3 = discountFactor3 * Convert.ToDouble(CashFlow3); var totalPresentValue = initialValue + presentValue1 + presentValue2 + presentValue3; NetPresentationValueModel netPV = new NetPresentationValueModel(); lbr += Increment; ValueRate += Increment; netPV.InitialValue = initTemp; netPV.DiscountRate = lbr; netPV.NPV = Convert.ToDecimal(totalPresentValue); netPV.CashFlowAmount = InitialValue + Convert.ToDecimal(totalPresentValue); netPV.DateCreated = DateTime.Now; NPVModelList.Add(netPV); this.SaveNPV(netPV.InitialValue, netPV.CashFlowAmount, netPV.DiscountRate, netPV.NPV); } InitialValue = initTemp; } catch (Exception ex) { MessageBox.Show(ex.Message + " Fill all filelds with correct values.", "Net Presentation Value"); } }
public string GetStringValue() { if (SetToDefault || SetToNull || SetToUndefined) { return(null); } else if (SetToEmptyString) { return(""); } else { return(InitialValue.ToString()); } }
public override void WriteXml(XmlWriter writer) { base.WriteXml(writer); writer.WriteElementString("BGPlateImage", BGPlateImage); writer.WriteElementString("KnobImage", KnobImage); writer.WriteElementString("Needle_Scale", Needle_Scale.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("Needle_PosX", Needle_PosX.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("Needle_PosY", Needle_PosY.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("Needle_PivotX", Needle_PivotX.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("Needle_PivotY", Needle_PivotY.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("InitialValue", InitialValue.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("StepValue", StepValue.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("MaxValue", MaxValue.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("MinValue", MinValue.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("InitialRotation", InitialRotation.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("RotationTravel", RotationTravel.ToString(CultureInfo.InvariantCulture)); }
/// <summary> /// Provides the surface of this function if it has been statically defined /// </summary> /// <param name="context">the context used to create the surface</param> /// <param name="xParam">The X axis of this surface</param> /// <param name="yParam">The Y axis of this surface</param> /// <returns>The surface which corresponds to this expression</returns> public override Functions.Surface createSurface(Interpreter.InterpretationContext context, Parameter xParam, Parameter yParam) { Functions.Surface retVal = base.createSurface(context, xParam, yParam); Functions.Surface surface = InitialValue.createSurface(context, xParam, yParam); if (surface != null) { Values.ListValue value = ListExpression.GetValue(context) as Values.ListValue; if (value != null) { int token = PrepareIteration(context); AccumulatorVariable.Value = surface.Function; foreach (Values.IValue v in value.Val) { if (v != EFSSystem.EmptyValue) { IteratorVariable.Value = v; if (conditionSatisfied(context)) { AccumulatorVariable.Value = IteratorExpression.GetValue(context); } } NextIteration(); } Functions.Function function = AccumulatorVariable.Value as Functions.Function; if (function != null) { retVal = function.Surface; } else { throw new Exception("Expression does not reduces to a function"); } EndIteration(context, token); } } else { throw new Exception("Cannot create surface for initial value " + InitialValue.ToString()); } retVal.XParameter = xParam; retVal.YParameter = yParam; return(retVal); }
public override void WriteXml(XmlWriter writer) { base.WriteXml(writer); writer.WriteElementString("KnobImage", KnobImage); writer.WriteElementString("InitialValue", InitialValue.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("StepValue", StepValue.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("MaxValue", MaxValue.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("MinValue", MinValue.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("InitialRotation", InitialRotation.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("RotationTravel", RotationTravel.ToString(CultureInfo.InvariantCulture)); writer.WriteStartElement("ClickType"); writer.WriteElementString("Type", ClickType.ToString()); if (ClickType == Controls.ClickType.Swipe) { writer.WriteElementString("Sensitivity", SwipeSensitivity.ToString(CultureInfo.InvariantCulture)); } writer.WriteEndElement(); }
/// <summary> /// Creates the graph associated to this expression, when the given parameter ranges over the X axis /// </summary> /// <param name="context">The interpretation context</param> /// <param name="parameter">The parameters of *the enclosing function* for which the graph should be created</param> /// <returns></returns> public override Functions.Graph createGraph(InterpretationContext context, Parameter parameter) { Functions.Graph retVal = base.createGraph(context, parameter); Functions.Graph graph = InitialValue.createGraph(context, parameter); if (graph != null) { Values.ListValue value = ListExpression.GetValue(context) as Values.ListValue; if (value != null) { int token = PrepareIteration(context); AccumulatorVariable.Value = graph.Function; foreach (Values.IValue v in value.Val) { if (v != EFSSystem.EmptyValue) { IteratorVariable.Value = v; if (conditionSatisfied(context)) { AccumulatorVariable.Value = IteratorExpression.GetValue(context); } } NextIteration(); } Functions.Function function = AccumulatorVariable.Value as Functions.Function; if (function != null) { retVal = function.Graph; } else { retVal = Functions.Function.createGraphForValue(AccumulatorVariable.Value); } EndIteration(context, token); } } else { throw new Exception("Cannot create graph for initial value " + InitialValue.ToString()); } return(retVal); }
public override string?ToString() => IsAnimated ? string.Join(" -> ", KeyFrames.Select(kf => kf.Value.ToString())) : InitialValue.ToString();
/// <summary> /// draws the custom inspector for an element /// </summary> /// <param name="rect">size of element</param> /// <param name="line_height">height of a line</param> /// <see cref="IListItemDrawer"/> public override void OnDrawElement(Rect rect, float line_height) { //base.OnDrawElement(rect, line_height); InitialValue = EditorGUI.FloatField(new Rect(rect.position, new Vector2(rect.width, line_height - 2)), name, InitialValue); GUI.Label(new Rect(rect.x, rect.y + line_height, rect.width, line_height - 2), "Runtime: " + RuntimeValue.ToString() + " | Default: " + InitialValue.ToString()); }
/// <summary> /// draws the custom inspector for an attribute element /// </summary> /// <param name="rect">size of element</param> /// <param name="line_height">height of a line</param> /// <see cref="IListItemDrawer"/> public override void OnDrawElement(Rect rect, float line_height) { InitStyles(); //base.OnDrawElement(rect, line_height); GUI.Label(new Rect(rect.x, rect.y, rect.width / 2, line_height - 2), name); InitialValue = EditorGUI.Slider(new Rect(rect.x + (rect.width / 2), rect.y, rect.width / 2, line_height - 2), InitialValue, 0, InitialMax); InitialMax = EditorGUI.FloatField(new Rect(rect.x, rect.y + line_height, rect.width / 3, line_height - 2), InitialMax); InitialUnavailable = EditorGUI.FloatField(new Rect(rect.x + rect.width / 3, rect.y + line_height, rect.width / 3, line_height - 2), InitialUnavailable); //OnAfterDeserialize(); Rect r = new Rect(rect.x, rect.y + line_height * 2, rect.width, line_height + 4); GUI.Box(r, ""); GUI.Box(new Rect(r.x + 1, r.y + 1, (r.width - 2) * InitialValue / InitialMax, r.height - 2), InitialValue.ToString(), valueStyle); float w = (r.width - 2) * InitialUnavailable / InitialMax; GUI.Box(new Rect(r.x + r.width - w, r.y + 1, w, r.height - 2), InitialUnavailable.ToString(), unavailableStyle); GUILayout.Space(26); }
/// <summary> /// Provides the string representation of the expression /// </summary> /// <returns></returns> public override string ToString() { string retVal = "STABILIZE " + Expression.ToString() + " INITIAL_VALUE " + InitialValue.ToString() + " STOP_CONDITION " + Condition.ToString(); return(retVal); }
/// <summary> /// Provides the expression text /// </summary> /// <returns></returns> public override string ToString() { string retVal = OPERATOR + " " + ListExpression.ToString(); if (Condition != null) { retVal += " | " + Condition.ToString(); } retVal = retVal + " USING " + IteratorExpression.ToString() + " INITIAL_VALUE " + InitialValue.ToString(); return(retVal); }