Esempio n. 1
0
        public static void TestDoubleField()
        {
            AgentData agent = new AgentData();

            agent.StartNode = new NodeData();

            DoubleField doubleField = new DoubleField();

            doubleField.FieldName = "DoubleField";
            doubleField.Value     = 100.001d;
            agent.StartNode.Fields.Add(doubleField);

            RepeatDoubleField repeatDoubleField = new RepeatDoubleField();

            repeatDoubleField.FieldName = "RepeatDoubleField";
            repeatDoubleField.Value     = new List <double>();
            repeatDoubleField.Value.Add(1.1d);
            repeatDoubleField.Value.Add(100.11d);
            repeatDoubleField.Value.Add(1000.11d);
            repeatDoubleField.Value.Add(10000.1119d);
            agent.StartNode.Fields.Add(repeatDoubleField);

            byte[]    bytes       = Serializer.Serialize(agent);
            AgentData deAgentData = Serializer.DeSerialize <AgentData>(bytes);
        }
Esempio n. 2
0
        /// <summary>
        /// Adds a stored or un-stored <see cref="DoubleField"/> with the provided value.
        /// <para/>
        /// Expert: allows you to customize the <see cref="FieldType"/>.
        /// </summary>
        /// <param name="document">This <see cref="Document"/>.</param>
        /// <param name="name"> field name </param>
        /// <param name="value"> 64-bit double value </param>
        /// <param name="type"> customized field type: must have <see cref="FieldType.NumericType"/>
        ///         of <see cref="NumericType.DOUBLE"/>. </param>
        /// <returns>The field that was added to this <see cref="Document"/>.</returns>
        /// <exception cref="System.ArgumentNullException"> if the field name or type is <c>null</c>, or
        ///          if the field type does not have a <see cref="NumericType.DOUBLE"/> <see cref="FieldType.NumericType"/> </exception>
        public static DoubleField AddDoubleField(this Document document, string name, double value, FieldType type)
        {
            var field = new DoubleField(name, value, type);

            document.Add(field);
            return(field);
        }
Esempio n. 3
0
        /// <summary>
        /// Adds a stored or un-stored <see cref="DoubleField"/> with the provided value
        /// and default <c>precisionStep</c>
        /// <see cref="Util.NumericUtils.PRECISION_STEP_DEFAULT"/> (4).
        /// </summary>
        /// <param name="document">This <see cref="Document"/>.</param>
        /// <param name="name"> field name </param>
        /// <param name="value"> 64-bit <see cref="double"/> value </param>
        /// <param name="stored"> <see cref="Field.Store.YES"/> if the content should also be stored </param>
        /// <returns>The field that was added to this <see cref="Document"/>.</returns>
        /// <exception cref="System.ArgumentNullException"> if the field name is <c>null</c>.  </exception>
        public static DoubleField AddDoubleField(this Document document, string name, double value, Field.Store stored)
        {
            var field = new DoubleField(name, value, stored);

            document.Add(field);
            return(field);
        }
Esempio n. 4
0
        public static void TestDoubleField()
        {
            BehaviorTreeElement behaviorTree = new BehaviorTreeElement();

            behaviorTree.StartNode = new NodeData();

            DoubleField doubleField = new DoubleField();

            doubleField.FieldName = "DoubleField";
            doubleField.Value     = 100.001d;
            behaviorTree.StartNode.Fields.Add(doubleField);

            RepeatDoubleField repeatDoubleField = new RepeatDoubleField();

            repeatDoubleField.FieldName = "RepeatDoubleField";
            repeatDoubleField.Value     = new List <double>();
            repeatDoubleField.Value.Add(1.1d);
            repeatDoubleField.Value.Add(100.11d);
            repeatDoubleField.Value.Add(1000.11d);
            repeatDoubleField.Value.Add(10000.1119d);
            behaviorTree.StartNode.Fields.Add(repeatDoubleField);

            byte[] bytes = Serializer.Serialize(behaviorTree);
            BehaviorTreeElement deBehaviorTreeData = Serializer.DeSerialize <BehaviorTreeElement>(bytes);
        }
Esempio n. 5
0
        public DoubleField AddDoubleField(string labelText, int doubleFieldHeight = -1)
        {
            var label = AddLabel(labelText);

            var doubleField = new DoubleField();

            doubleField.Initialize();
            container.AddDrawBox(doubleField);
            if (doubleFieldHeight == -1)
            {
                doubleField.Height = doubleField.Font.CharHeight + 4;
            }
            else
            {
                doubleField.Height = doubleFieldHeight;
            }
            Push.ToTheRightSideOf(doubleField, label, HorizontalMargin, Push.HorizontalAlign.Top);

            doubleField.Width = FieldWidth - doubleField.X;

            AddNewFieldList();
            lastField.Add(label);
            lastField.Add(doubleField);

            alignments.Add(doubleField, new DrawBoxAlignment(AlignTop, AlignBottom, true, true));

            return(doubleField);
        }
Esempio n. 6
0
        public void InterpolationNormalFormConstTest()
        {
            var pointContainer = new PointContainer2D <double, double>();

            pointContainer.Add(1, 5);
            var doubleField  = new DoubleField();
            var interpolator = new UnivarNormalFromInterpolator <double, double>(
                pointContainer,
                "x",
                new DoubleToIntegerConversion(),
                doubleField,
                doubleField,
                doubleField);

            var actual = interpolator.Interpolate(0);

            Assert.AreEqual(5, actual);

            actual = interpolator.Interpolate(2);
            Assert.AreEqual(5, actual);

            var interpolationPol = interpolator.InterpolatingPolynomial;
            var expected         = new UnivariatePolynomialNormalForm <double>(5, 0, "x", doubleField);

            Assert.AreEqual(expected, interpolationPol);
        }
Esempio n. 7
0
        public static IndexableField InstantiateField(string key, object value, FieldType fieldType)
        {
            IndexableField field;

            if (value is Number)
            {
                Number number = ( Number )value;
                if (value is long?)
                {
                    field = new LongField(key, number.longValue(), Field.Store.YES);
                }
                else if (value is float?)
                {
                    field = new FloatField(key, number.floatValue(), Field.Store.YES);
                }
                else if (value is double?)
                {
                    field = new DoubleField(key, number.doubleValue(), Field.Store.YES);
                }
                else
                {
                    field = new IntField(key, number.intValue(), Field.Store.YES);
                }
            }
            else
            {
                field = new Field(key, value.ToString(), fieldType);
            }
            return(field);
        }
        public async Task DoubleFieldTest()
        {
            var theme     = MatterHackers.MatterControl.AppContext.Theme;
            var testField = new DoubleField(theme);

            await ValidateAgainstValueMap(
                testField,
                theme,
                (field) => (field.Content as MHNumberEdit).ActuallNumberEdit.Text,
                new List <ValueMap>()
            {
                { "0.12345", "0.12345" },
                { "1.2345", "1.2345" },
                { "12.345", "12.345" },
                { "12.7", "12.7" },
                { "+0.12345", "0.12345" },
                { "+1.2345", "1.2345" },
                { "+12.345", "12.345" },
                { "-0.12345", "-0.12345" },
                { "-1.2345", "-1.2345" },
                { "-12.345", "-12.345" },
                { "12.7", "12.7" },
                { "22", "22" },
                // Invalid values revert to expected
                { "abc", "0" },
                { "+abc", "0" },
                { "-abc", "0" },
            });
        }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = ByteField.GetHashCode();
         hashCode = (hashCode * 397) ^ SByteField.GetHashCode();
         hashCode = (hashCode * 397) ^ Int16Field.GetHashCode();
         hashCode = (hashCode * 397) ^ UInt16Field.GetHashCode();
         hashCode = (hashCode * 397) ^ Int32Field;
         hashCode = (hashCode * 397) ^ (int)UInt32Field;
         hashCode = (hashCode * 397) ^ Int64Field.GetHashCode();
         hashCode = (hashCode * 397) ^ UInt64Field.GetHashCode();
         hashCode = (hashCode * 397) ^ DecimalField.GetHashCode();
         hashCode = (hashCode * 397) ^ SingleFiled.GetHashCode();
         hashCode = (hashCode * 397) ^ DoubleField.GetHashCode();
         hashCode = (hashCode * 397) ^ (StringField != null ? StringField.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (int)MyEnumField;
         hashCode = (hashCode * 397) ^ BooleanField.GetHashCode();
         hashCode = (hashCode * 397) ^ DateTimeField.GetHashCode();
         hashCode = (hashCode * 397) ^ DateTimeOffsetField.GetHashCode();
         hashCode = (hashCode * 397) ^ GuidField.GetHashCode();
         hashCode = (hashCode * 397) ^ TimeSpanField.GetHashCode();
         hashCode = (hashCode * 397) ^ (UrlField != null ? UrlField.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (NullField != null ? NullField.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (IntArrayField != null ? IntArrayField.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (StringArrayField != null ? StringArrayField.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (EmptyArrayField != null ? EmptyArrayField.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (NullArrayField != null ? NullArrayField.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (DictionaryArrayField != null ? DictionaryArrayField.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ObjectArrayField != null ? ObjectArrayField.GetHashCode() : 0);
         return(hashCode);
     }
 }
Esempio n. 10
0
 private static decimal SafeDecimalValue(DoubleField field)
 {
     if (field != null)
     {
         return((decimal)field.getValue());
     }
     return(0m);
 }
        /// <summary>
        /// Returns true if EntityViewModel instances are equal
        /// </summary>
        /// <param name="other">Instance of EntityViewModel to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(EntityViewModel other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                     ) &&
                 (
                     StringField == other.StringField ||
                     StringField != null &&
                     StringField.Equals(other.StringField)
                 ) &&
                 (
                     RelationIdField == other.RelationIdField ||
                     RelationIdField != null &&
                     RelationIdField.Equals(other.RelationIdField)
                 ) &&
                 (
                     DictionaryField == other.DictionaryField ||
                     DictionaryField != null &&
                     DictionaryField.Equals(other.DictionaryField)
                 ) &&
                 (
                     IntegerField == other.IntegerField ||
                     IntegerField != null &&
                     IntegerField.Equals(other.IntegerField)
                 ) &&
                 (
                     DoubleField == other.DoubleField ||
                     DoubleField != null &&
                     DoubleField.Equals(other.DoubleField)
                 ) &&
                 (
                     DateField == other.DateField ||
                     DateField != null &&
                     DateField.Equals(other.DateField)
                 ) &&
                 (
                     ExampleType == other.ExampleType ||
                     ExampleType != null &&
                     ExampleType.Equals(other.ExampleType)
                 ) &&
                 (
                     ExampleStatus == other.ExampleStatus ||
                     ExampleStatus != null &&
                     ExampleStatus.Equals(other.ExampleStatus)
                 ));
        }
Esempio n. 12
0
        private DoubleField CreateDoubleField(string name, string value)
        {
            DoubleField field = new DoubleField();

            field.Name = name;
            field.SetValue(Convert.ToDouble(value));

            return(field);
        }
Esempio n. 13
0
        public void RunTest_OneEquality()
        {
            var inputConstraintsMatrixText = "[[1,0,3],[0,2,2]]";
            var inputConstraintsVectorText = "[4,12,18]";
            var cost = new SimplexMaximumNumberField <double>(0, -18);
            var nonBasicVariables = new[] { 0, 1 };
            var basicVariables    = new[] { 2, 3, 4 };

            // Leitura da matriz das retrições.
            var doubleElementsParser   = new DoubleParser <string>();
            var inputConstraintsMatrix = TestsHelper.ReadMatrix <double>(
                3,
                2,
                inputConstraintsMatrixText,
                (i, j) => new ArrayMathMatrix <double>(i, j),
                doubleElementsParser,
                true);

            // Leitura do vector de restrições.
            var vectorFactory          = new ArrayVectorFactory <double>();
            var inputConstraintsVector = TestsHelper.ReadVector <double>(
                3,
                inputConstraintsVectorText,
                vectorFactory,
                doubleElementsParser,
                true);

            // Introdução da função objectivo.
            var inputObjectiveFunction = new ArrayMathVector <SimplexMaximumNumberField <double> >(2);

            inputObjectiveFunction[0] = new SimplexMaximumNumberField <double>(
                -3,
                -3);
            inputObjectiveFunction[1] = new SimplexMaximumNumberField <double>(
                -5,
                -2);

            // Objecto de entrada para o algoritmo do simplex.
            var simplexInput = new SimplexInput <double, SimplexMaximumNumberField <double> >(
                basicVariables,
                nonBasicVariables,
                inputObjectiveFunction,
                cost,
                inputConstraintsMatrix,
                inputConstraintsVector);

            var doubleField = new DoubleField();
            var target      = new SimplexAlgorithm <double>(Comparer <double> .Default, doubleField);
            var actual      = target.Run(simplexInput);

            // Verifica o custo
            Assert.AreEqual(36, actual.Cost);

            // Verifica a solução
            Assert.AreEqual(2, actual.Solution[0]);
            Assert.AreEqual(6, actual.Solution[1]);
        }
Esempio n. 14
0
        public void RunSimplexTest_NoFeasibleSolution()
        {
            var inputConstraintsMatrixText = "[[0.3,0.5,0.6],[0.1,0.5,0.4],[0,0,-1]]";
            var inputConstraintsVectorText = "[1.8,6,6]";
            var cost = new SimplexMaximumNumberField <double>(0, -12);
            var nonBasicVariables = new[] { 0, 1, 2 };
            var basicVariables    = new[] { 3, 4, 5 };

            // Leitura da matriz das retrições.
            var doubleElementsParser   = new DoubleParser <string>();
            var inputConstraintsMatrix = TestsHelper.ReadMatrix <double>(
                3,
                3,
                inputConstraintsMatrixText,
                (i, j) => new ArrayMathMatrix <double>(i, j),
                doubleElementsParser,
                true);

            // Leitura do vector de restrições.
            var vectorFactory          = new ArrayVectorFactory <double>();
            var inputConstraintsVector = TestsHelper.ReadVector <double>(
                3,
                inputConstraintsVectorText,
                vectorFactory,
                doubleElementsParser,
                true);

            // Introdução da função objectivo.
            var inputObjectiveFunction = new ArrayMathVector <SimplexMaximumNumberField <double> >(3);

            inputObjectiveFunction[0] = new SimplexMaximumNumberField <double>(
                0.4,
                -1.1);
            inputObjectiveFunction[1] = new SimplexMaximumNumberField <double>(
                0.5,
                -0.9);
            inputObjectiveFunction[2] = new SimplexMaximumNumberField <double>(
                0,
                1);

            // Objecto de entrada para o algoritmo do simplex.
            var simplexInput = new SimplexInput <double, SimplexMaximumNumberField <double> >(
                basicVariables,
                nonBasicVariables,
                inputObjectiveFunction,
                cost,
                inputConstraintsMatrix,
                inputConstraintsVector);

            var doubleField = new DoubleField();
            var target      = new SimplexAlgorithm <double>(Comparer <double> .Default, doubleField);
            var actual      = target.Run(simplexInput);

            // O problema tem uma solução cujo custo é inifito.
            Assert.IsFalse(actual.HasSolution);
        }
        public static void RenderDoubleProperty(VisualElement container, string name, object value,
                                                Action <object> setter)
        {
            var field = new DoubleField(name);

            field.SetValueWithoutNotify((double)value);
            field.MarkDirtyRepaint();
            field.RegisterValueChangedCallback(evt => setter(evt.newValue));
            container.Add(field);
        }
Esempio n. 16
0
        public void TestAddDoubleField_Stored()
        {
            DoubleField field  = null;
            double      value  = 123.456d;
            var         stored = Field.Store.YES;

            AssertDocumentExtensionAddsToDocument(document => field = document.AddDoubleField("theName", value, stored));
            Assert.AreEqual("theName", field.Name);
            Assert.AreEqual(value, field.GetDoubleValueOrDefault(), 0.0000001d); // We don't really care about precision, just checking to see if the value got passed through
            Assert.AreSame(DoubleField.TYPE_STORED, field.FieldType);
        }
    public override void Enable()
    {
        var floatNode = nodeTarget as MultiAddNode;

        DoubleField floatField = new DoubleField
        {
            value = floatNode.output
        };

        controlsContainer.Add(floatField);
    }
Esempio n. 18
0
        public void InterpolationNormalFormMultiPointTest()
        {
            var pointContainer      = new PointContainer2D <double, double>();
            var interpolationPoints = new double[] { 0, 1, -2, 3, -4 };

            for (int i = 0; i < interpolationPoints.Length; ++i)
            {
                pointContainer.Add(interpolationPoints[i], 0);
            }

            var doubleField  = new DoubleField();
            var interpolator = new UnivarNormalFromInterpolator <double, double>(
                pointContainer,
                "x",
                new DoubleToIntegerConversion(),
                doubleField,
                doubleField,
                doubleField);


            // Verifica os valores da interpolação.
            for (int i = 0; i < interpolationPoints.Length; ++i)
            {
                var actual = interpolator.Interpolate(interpolationPoints[i]);
                Assert.AreEqual(0, actual);
            }

            var interpolationPol = interpolator.InterpolatingPolynomial;
            var expected         = TestsHelper.ReadUnivarPolynomial(
                "0",
                doubleField,
                new DoubleParser <string>(),
                new DoubleToIntegerConversion(),
                "x",
                true);

            Assert.AreEqual(expected, interpolationPol);

            pointContainer.Add(5, -1);
            pointContainer.Add(-6, 1);

            for (int i = 0; i < interpolationPoints.Length; ++i)
            {
                var actual = interpolator.Interpolate(interpolationPoints[i]);
                Assert.IsTrue(Math.Abs(actual - 0) < 0.000001);
            }

            var actualValue = interpolator.Interpolate(5);

            Assert.IsTrue(Math.Abs(actualValue + 1) < 0.000001);

            actualValue = interpolator.Interpolate(-6);
            Assert.IsTrue(Math.Abs(actualValue - 1) < 0.000001);
        }
Esempio n. 19
0
        /// <summary>
        /// Adds a stored or un-stored <see cref="DoubleField"/> with the provided value.
        /// <para/>
        /// Expert: allows you to customize the <see cref="FieldType"/>.
        /// </summary>
        /// <param name="document">This <see cref="Document"/>.</param>
        /// <param name="name"> field name </param>
        /// <param name="value"> 64-bit double value </param>
        /// <param name="type"> customized field type: must have <see cref="FieldType.NumericType"/>
        ///         of <see cref="NumericType.DOUBLE"/>. </param>
        /// <returns>The field that was added to this <see cref="Document"/>.</returns>
        /// <exception cref="ArgumentNullException"> if this <paramref name="document"/>, the field <paramref name="name"/> or <paramref name="type"/> is <c>null</c>, or
        ///          if the field type does not have a <see cref="NumericType.DOUBLE"/> <see cref="FieldType.NumericType"/> </exception>
        public static DoubleField AddDoubleField(this Document document, string name, double value, FieldType type)
        {
            if (document is null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            var field = new DoubleField(name, value, type);

            document.Add(field);
            return(field);
        }
Esempio n. 20
0
        public DecimalField() : base(null, null)
        {
            // Set up styling
            AddToClassList("UdonValueField");

            // Create Char Editor and listen for changes
            DoubleField field = new DoubleField();

            field.RegisterValueChangedCallback(
                e =>
                value = Convert.ToDecimal(e.newValue));

            Add(field);
        }
Esempio n. 21
0
    public override void Enable()
    {
        var floatNode = nodeTarget as MultiAddNode;

        DoubleField floatField = new DoubleField
        {
            value = floatNode.output
        };

        // Update the UI value after each processing
        nodeTarget.onProcessed += () => floatField.value = floatNode.output;

        controlsContainer.Add(floatField);
    }
Esempio n. 22
0
	public override void Enable()
	{
		var floatNode = nodeTarget as FloatNode;

		DoubleField floatField = new DoubleField
		{
			value = floatNode.output
		};

		floatField.OnValueChanged((v) => {
			owner.RegisterCompleteObjectUndo("Updated floatNode output");
			floatNode.output = (float)v.newValue;
		});

		controlsContainer.Add(floatField);
	}
Esempio n. 23
0
        public override void AddedToContainer()
        {
            base.AddedToContainer();

            CloseButtonOn = false;

            var builder = new FieldBuilder();

            builder.BuildSessionStart(this);

            nameField      = builder.AddTextField("Name: ");
            nameField.Text = neuronGene.Name;

            isMutableCheckBox         = builder.AddCheckBoxField("Gene Mutability: ");
            isMutableCheckBox.Checked = neuronGene.IsMutable;

            builder.AddLabelField("Bias:");
            biasMin = builder.AddDoubleField("Min: ");
            biasMax = builder.AddDoubleField("Max: ");
            biasVal = builder.AddDoubleField("Value: ");


            biasMin.Value = neuronGene.Bias.Min;
            biasMax.Value = neuronGene.Bias.Max;
            biasVal.Value = neuronGene.Bias.Value;

            builder.AddResizableButtonField("Edit Sigmoid Function", delegate(object sender)
            {
                neuronGene.SigmoidFunction.GetType().InvokeMember("GUI_Edit", BindingFlags.Default | BindingFlags.InvokeMethod, null, null, new object[] { Parent, neuronGene.SigmoidFunction });
            }, FieldBuilder.ResizableButtonOrientation.FillWidth);

            builder.AddResizableButtonField("Edit Connections", delegate(object sender)
            {
                EditConnectionGeneListForm.ShowDialogue(Parent, neuronGene.Connections);
            }, FieldBuilder.ResizableButtonOrientation.FillWidth);

            builder.AddResizableButtonField("OK", delegate(object sender)
            {
                Close();
            }, FieldBuilder.ResizableButtonOrientation.Left);

            builder.BuildSessionEnd();

            X = (Parent.Width / 2) - (Width / 2);
            Y = (Parent.Height / 2) - (Height / 2);
        }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Id != null)
         {
             hashCode = hashCode * 59 + Id.GetHashCode();
         }
         if (StringField != null)
         {
             hashCode = hashCode * 59 + StringField.GetHashCode();
         }
         if (RelationIdField != null)
         {
             hashCode = hashCode * 59 + RelationIdField.GetHashCode();
         }
         if (DictionaryField != null)
         {
             hashCode = hashCode * 59 + DictionaryField.GetHashCode();
         }
         if (IntegerField != null)
         {
             hashCode = hashCode * 59 + IntegerField.GetHashCode();
         }
         if (DoubleField != null)
         {
             hashCode = hashCode * 59 + DoubleField.GetHashCode();
         }
         if (DateField != null)
         {
             hashCode = hashCode * 59 + DateField.GetHashCode();
         }
         if (ExampleType != null)
         {
             hashCode = hashCode * 59 + ExampleType.GetHashCode();
         }
         if (ExampleStatus != null)
         {
             hashCode = hashCode * 59 + ExampleStatus.GetHashCode();
         }
         return(hashCode);
     }
 }
Esempio n. 25
0
    public override void Enable()
    {
        var floatNode = nodeTarget as FloatNode;

        DoubleField floatField = new DoubleField
        {
            value = floatNode.input
        };

        floatNode.onProcessed += () => floatField.value = floatNode.input;

        floatField.RegisterValueChangedCallback((v) => {
            owner.RegisterCompleteObjectUndo("Updated floatNode input");
            floatNode.input = (float)v.newValue;
        });

        controlsContainer.Add(floatField);
    }
Esempio n. 26
0
        public override VisualElement CreatePropertyGUI(SerializedProperty property)
        {
            BindableElement newField = null;

            if (property.propertyType == SerializedPropertyType.Float)
            {
                if (property.type == "float")
                {
                    newField = new FloatField(property.displayName);
                    ((TextInputBaseField <float>)newField).isDelayed = true;
                }
                else if (property.type == "double")
                {
                    newField = new DoubleField(property.displayName);
                    ((TextInputBaseField <double>)newField).isDelayed = true;
                }
            }
            else if (property.propertyType == SerializedPropertyType.Integer)
            {
                if (property.type == "int")
                {
                    newField = new IntegerField(property.displayName);
                    ((TextInputBaseField <int>)newField).isDelayed = true;
                }
                else if (property.type == "long")
                {
                    newField = new LongField(property.displayName);
                    ((TextInputBaseField <long>)newField).isDelayed = true;
                }
            }
            else if (property.propertyType == SerializedPropertyType.String)
            {
                newField = new TextField(property.displayName);
                ((TextInputBaseField <string>)newField).isDelayed = true;
            }

            if (newField != null)
            {
                newField.bindingPath = property.propertyPath;
                return(newField);
            }

            return(new Label(s_InvalidTypeMessage));
        }
Esempio n. 27
0
        private void DrawValueField()
        {
            // Clear previous field
            if (fieldContainer.Children().Any())
            {
                fieldContainer.Clear();
            }

            // Create a type-specific field for each different variable type, set the right value (mainly null handling),
            // and register the type-specific callback
            VisualElement field;

            switch (worldVars.GetType(guid))
            {
            case VariableType.String:
                field = new TextField();
                field.RegisterCallback <ChangeEvent <string> >(UpdateWorldvarValue);
                break;

            case VariableType.Bool:
                field = new Toggle();
                field.RegisterCallback <ChangeEvent <bool> >(UpdateWorldvarValue);
                break;

            case VariableType.Long:
                field = new LongField();
                field.RegisterCallback <ChangeEvent <long> >(UpdateWorldvarValue);
                break;

            case VariableType.Double:
                field = new DoubleField();
                field.RegisterCallback <ChangeEvent <double> >(UpdateWorldvarValue);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            field.name = fieldName;
            fieldContainer.Add(field);

            SetFieldValue(worldVars.GetValue(guid));
        }
Esempio n. 28
0
            internal Field GetNumericField(string name, NumericType type)
            {
                Field f;

                if (reuseFields)
                {
                    numericFields.TryGetValue(name, out f);
                }
                else
                {
                    f = null;
                }

                if (f == null)
                {
                    switch (type)
                    {
                    case NumericType.INT32:
                        f = new Int32Field(name, 0, Field.Store.NO);
                        break;

                    case NumericType.INT64:
                        f = new Int64Field(name, 0L, Field.Store.NO);
                        break;

                    case NumericType.SINGLE:
                        f = new SingleField(name, 0.0F, Field.Store.NO);
                        break;

                    case NumericType.DOUBLE:
                        f = new DoubleField(name, 0.0, Field.Store.NO);
                        break;

                    default:
                        throw new InvalidOperationException("Cannot get here");
                    }
                    if (reuseFields)
                    {
                        numericFields[name] = f;
                    }
                }
                return(f);
            }
Esempio n. 29
0
        public void TestAddDoubleField_FieldType()
        {
            DoubleField field     = null;
            double      value     = 123.456d;
            var         fieldType = new FieldType
            {
                IsIndexed    = true,
                IsTokenized  = true,
                OmitNorms    = false,
                IndexOptions = IndexOptions.DOCS_ONLY,
                NumericType  = NumericType.DOUBLE,
                IsStored     = true
            }.Freeze();

            AssertDocumentExtensionAddsToDocument(document => field = document.AddDoubleField("theName", value, fieldType));
            Assert.AreEqual("theName", field.Name);
            Assert.AreEqual(value, field.GetDoubleValueOrDefault(), 0.0000001d); // We don't really care about precision, just checking to see if the value got passed through
            Assert.AreSame(fieldType, field.FieldType);
        }
Esempio n. 30
0
        public DoubleNode()
        {
            Initialize("Double", DefaultNodePosition);
            var inputField = new DoubleField {
                label = "x:", value = 0
            };

            inputField.labelElement.style.minWidth = 0;
            inputField.RegisterValueChangedCallback(evt => {
                CodeGraph.Instance.InvalidateSaveButton();
                value = evt.newValue;
            });
            inputContainer.Add(inputField);

            var valuePort = base.InstantiatePort(Orientation.Horizontal, Direction.Output, Port.Capacity.Multi, typeof(float));

            valuePort.portName = "value";
            AddOutputPort(valuePort, () => $"{value}d");
            Refresh();
        }
Esempio n. 31
0
        protected override void ConstructFields()
        {
            SupportsNotificationBinding = false;
               NoBuildCrosschecks = true;
               FieldValidationSuspended = true;

               TableName = "TBL_TESTPERSON";
               StoreFlag = StoreFlag.LoadAndStore;

               m_fldName = new StringField()
               {
             Owner = this,
             FieldName = "PERSON_NAME",
             Required = true,
             Size = 50
               };

               m_fldRating = new IntField()
               {
               Owner = this,
               FieldName = "RATING",
               MinMaxChecking = true,
               MinValue = 0,
               MaxValue = 10
               };

               m_fldRegistered = new BoolField()
               {
               Owner = this,
               FieldName = "IS_REGISTERED",
               Required = true
               };

               m_fldDOB = new DateTimeField()
               {
               Owner = this,
               FieldName = "DOB"
               };

               m_fldScore = new DoubleField()
               {
               Owner = this,
               FieldName = "SCORE"
               };

               m_fldData1 = new StringField()
               {
               Owner = this,
               FieldName = "Data1"
               };

               m_fldData2 = new StringField()
               {
               Owner = this,
               FieldName = "Data2"
               };

               m_fldData3 = new StringField()
               {
               Owner = this,
               FieldName = "Data3"
               };

               m_fldData4 = new IntField()
               {
               Owner = this,
               FieldName = "Data4"
               };

               m_fldData5 = new IntField()
               {
               Owner = this,
               FieldName = "Data5"
               };

               m_fldData6 = new IntField()
               {
               Owner = this,
               FieldName = "Data6"
               };

               m_fldData7 = new BoolField()
               {
               Owner = this,
               FieldName = "Data7"
               };

               m_fldData8 = new BoolField()
               {
               Owner = this,
               FieldName = "Data8"
               };

               m_fldData9 = new BoolField()
               {
               Owner = this,
               FieldName = "Data9"
               };

               m_fldData10 = new DoubleField()
               {
               Owner = this,
               FieldName = "Data10"
               };
        }
Esempio n. 32
0
        protected override void ConstructFields()
        {
            TableName = "TBL_TESTPERSON";
               StoreFlag = StoreFlag.LoadAndStore;

               m_fldName = new StringField()
               {
             Owner = this,
             FieldName = "PERSON_NAME",
             Required = true,
             Size = 50
               };

               m_fldSex = new StringField()
               {
             Owner = this,
             FieldName = "SEX",
             Required = true,
             Size = 1,
             DataEntryType = DataEntryType.DirectEntryOrLookupWithValidation,
             LookupType = LookupType.Dictionary
               };
               m_fldSex.LookupDictionary.AddRange(new string[]{"M,Male", "F,Female", "U,Unspecified"});

               m_fldRating = new IntField()
               {
             Owner = this,
             FieldName = "RATING",
             MinMaxChecking = true,
             MinValue = 0,
             MaxValue = 10
               };

               m_fldRegistered = new BoolField()
               {
             Owner = this,
             FieldName = "IS_REGISTERED",
             Required = true
               };

               m_fldDOB = new DateTimeField()
               {
             Owner = this,
             FieldName = "DOB"
               };

               m_fldSalary = new DecimalField()
               {
             Owner = this,
             FieldName = "PAYROLL_VOLUME",
             MinMaxChecking = true,
             MinValue = 0M,
             MaxValue = Decimal.MaxValue
               };

               //calculated field returns salary * 10 years
               m_fldDecadeSalary = new DecimalField()
               {
             Owner = this,
             FieldName = "DECADE_SALARY",
             StoreFlag = StoreFlag.None,
             DataEntryType = DataEntryType.None,
             Calculated = true,
             Formula = "850-10 +(::PAYROLL_VOLUME * 10)"
               };

               m_fldScore = new DoubleField()
               {
             Owner = this,
             FieldName = "SCORE"
               };

               m_fldMovieNames = new ListField<string>()
               {
             Owner = this,
             FieldName = "MOVIES",
             Required = true
               };

               //ths is business logic-driven computed column for GUI
               m_fldBusinessCode = new StringField()
               {
             Owner = this,
             FieldName = "BUSINESS_CODE",
             StoreFlag = StoreFlag.None,
             DataEntryType = DataEntryType.None
               };
        }