Exemple #1
0
        public WordResult IntToWord([FromBody] IntInput numberInput)
        {
            var wordResult = new WordResult();

            if (string.IsNullOrWhiteSpace(numberInput.Number))
            {
                wordResult.Message  = "Please provide a valid number that larger than 0.";
                Response.StatusCode = 400;
                return(wordResult);
            }

            try
            {
                wordResult.Result = NumberTextConverter.IntegerToWritten(numberInput.Number);
            }
            catch (NumberTextConverterException e)
            {
                wordResult.Message  = e.Message;
                Response.StatusCode = 400;
                return(wordResult);
            }
            catch
            {
                wordResult.Message  = "Internal Server Error";
                Response.StatusCode = 500;
                return(wordResult);
            }

            return(wordResult);
        }
        public static MethodResult Wait(object sender, IEventInput input)
        {
            IntInput IInput = (IntInput)input;

            System.Threading.Thread.Sleep(IInput.Input);

            return(MethodResult.Success);
        }
Exemple #3
0
    public void SetInt(byte i_Key, int i_Value)
    {
        RemoveInt(i_Key);

        IntInput intInput = new IntInput(i_Key, i_Value);

        m_Ints.Add(intInput);
    }
        public override void Setup(IInputControl <int> controlToUse)
        {
            base.Setup(controlToUse);
            IntInput controlAsIntInput = controlToUse as IntInput;

            if (controlAsIntInput == null)
            {
                return;
            }
            controlAsIntInput.Setup(_minValue, _maxValue, _increment);
            controlAsIntInput.Value = _defaultValue;
        }
Exemple #5
0
    public int GetInt(byte i_Key)
    {
        int index = GetIntInputIndex(i_Key);

        if (index >= 0)
        {
            IntInput intInput = m_Ints[index];
            return(intInput.value);
        }

        return(0);
    }
Exemple #6
0
        /// <summary>
        /// Overrides <see cref="CADability.Actions.ConstructAction.OnSetAction ()"/>
        /// </summary>
        public override void OnSetAction()
        {
            base.TitleId = "CopyCircularObjects";

            BoundingRect result = originals.GetExtent(Frame.ActiveView.ProjectedModel.Projection, true, false);

            centerPoint = base.ActiveDrawingPlane.ToGlobal(result.GetCenter());
            //			rotationPoint =  base.ActiveDrawingPlane.ToGlobal(result.GetLowerLeft());
            rotationPoint = centerPoint;
            distX         = result.Width;
            if (copCount == 0)
            {
                copCount = 4;
                copAngle = Math.PI / 2.0;
            }

            GeoPointInput rotPoint = new GeoPointInput("CopyCircularObjects.RotationPoint");

            rotPoint.SetGeoPointEvent += new CADability.Actions.ConstructAction.GeoPointInput.SetGeoPointDelegate(SetRotPoint);
            rotPoint.GetGeoPointEvent += new CADability.Actions.ConstructAction.GeoPointInput.GetGeoPointDelegate(GetRotPoint);
            rotPoint.Optional          = true;
            rotPoint.DefinesHotSpot    = true;
            rotPoint.HotSpotSource     = "Hotspots.png:0";

            IntInput copiesCount = new IntInput("CopyCircularObjects.CopiesCount", copCount);

            copiesCount.SetMinMax(0, int.MaxValue, true);
            copiesCount.SetIntEvent += new CADability.Actions.ConstructAction.IntInput.SetIntDelegate(SetCopiesCount);
            //			copiesCount.CalculateIntEvent +=new CADability.Actions.ConstructAction.IntInput.CalculateIntDelegate(CalcCopiesCount);

            BooleanInput fullCircle = new BooleanInput("CopyCircularObjects.FullCircle", "CopyCircularObjects.FullCircle.Values");

            fullCircle.SetBooleanEvent += new CADability.Actions.ConstructAction.BooleanInput.SetBooleanDelegate(SetFullCircle);
            fullCircle.GetBooleanEvent += new CADability.Actions.ConstructAction.BooleanInput.GetBooleanDelegate(GetFullCircle);

            copiesAngle                      = new AngleInput("CopyCircularObjects.CopiesAngle", copAngle);
            copiesAngle.ReadOnly             = !partOfCircle;
            copiesAngle.Optional             = !partOfCircle;
            copiesAngle.SetAngleEvent       += new CADability.Actions.ConstructAction.AngleInput.SetAngleDelegate(SetCopAngle);
            copiesAngle.GetAngleEvent       += new CADability.Actions.ConstructAction.AngleInput.GetAngleDelegate(GetCopAngle);
            copiesAngle.CalculateAngleEvent += new CADability.Actions.ConstructAction.AngleInput.CalculateAngleDelegate(CalculateCopAngle);

            BooleanInput rotObject = new BooleanInput("CopyCircularObjects.ObjectsRotation", "CopyCircularObjects.ObjectsRotation.Values");

            rotObject.SetBooleanEvent += new CADability.Actions.ConstructAction.BooleanInput.SetBooleanDelegate(SetObjectsRotation);
            rotObject.GetBooleanEvent += new CADability.Actions.ConstructAction.BooleanInput.GetBooleanDelegate(GetObjectsRotation);

            base.SetInput(rotPoint, copiesCount, fullCircle, copiesAngle, rotObject);

            base.OnSetAction();
            showCirc();
        }
Exemple #7
0
    public bool HasInt(byte i_Key)
    {
        for (int index = 0; index < m_Ints.Count; ++index)
        {
            IntInput intInput = m_Ints[index];
            if (intInput.key == i_Key)
            {
                return(true);
            }
        }

        return(false);
    }
Exemple #8
0
    private int GetIntInputIndex(byte i_Key)
    {
        for (int index = 0; index < m_Ints.Count; ++index)
        {
            IntInput intInput = m_Ints[index];
            if (intInput.key == i_Key)
            {
                return(index);
            }
        }

        return(-1);
    }
Exemple #9
0
    public bool GetIntInput(int i_Index, out IntInput o_IntInput)
    {
        if (!IsValidIntIndex(i_Index))
        {
            o_IntInput = new IntInput(0, 0);
            return(false);
        }

        IntInput intInput = m_Ints[i_Index];

        o_IntInput = new IntInput(intInput);
        return(true);
    }
Exemple #10
0
        public override void OnSetAction()
        {
            // The title appears in the control center
            base.TitleId = "Constr.SplitCurve";

            CurveInput curveInput = null;

            if (theCurve == null)
            {
                curveInput = new CurveInput("Constr.SplitCurve.Curve");
                curveInput.MouseOverCurvesEvent += new CurveInput.MouseOverCurvesDelegate(OnMouseOverCurves);
            }

            IntInput numberInput = new IntInput("Constr.SplitCurve.Count");

            numberInput.SetIntEvent += new IntInput.SetIntDelegate(OnSetNumber);
            numberInput.SetMinMax(2, 100, false);
            numberInput.GetIntEvent += new IntInput.GetIntDelegate(OnGetNumber);

            MultipleChoiceInput modeInput = new MultipleChoiceInput("Constr.SplitCurve.Mode", "Constr.SplitCurve.Mode.Values");

            // |prozentual|Längen
            modeInput.SetChoiceEvent += new MultipleChoiceInput.SetChoiceDelegate(OnSetMode);

            distances = new InputContainer("Constr.SplitCurve.Distances");
            RefreshDistances();

            if (theCurve == null)
            {
                base.SetInput(curveInput, numberInput, modeInput, distances);
            }
            else
            {
                base.SetInput(numberInput, modeInput, distances);
            }
            base.OnSetAction();
            Recalc();
        }
Exemple #11
0
        public static IntInput UsersInput(string prompt, int lower, int upper)
        {
            bool     valid  = false;
            IntInput output = new IntInput();

            Console.WriteLine($"{prompt}");

            do
            {
                Console.Write($"-- ");

                try
                {
                    var input = Console.ReadLine();

                    if (input == "q")
                    {
                        output = new IntInput(true);
                        valid  = true;
                    }
                    else
                    {
                        var i = int.Parse(input);

                        if ((i >= lower) && (i <= upper))
                        {
                            output = new IntInput(i);
                            valid  = true;
                        }
                    }
                }
                catch (FormatException)
                {
                }
            } while (!valid);

            return(output);
        }
        public static MethodResult AdjustGold(object sender, IEventInput input)
        {
            var      gold = EngineGlobals.DataManager.GetVariable("{gold}");
            IntInput temp = new IntInput();

            if (input is IntInput)
            {
                temp = (IntInput)input;
            }
            else
            {
                EquestriEngine.ErrorMessage = "Invalid input passed into Adjust Gold";
            }

            var newGoldDisplay = new SystemWidgets.GoldDisplay(gold.AsInt, temp.Input);


            GameReference.WidgetDrawer.AddWidget(newGoldDisplay);


            gold.AsInt += temp.Input;
            return(MethodResult.Success);
        }
Exemple #13
0
        public static MethodResult AdjustGold(object sender, IEventInput input)
        {
            var      gold = DataManager.GetVariable("{gold}");
            IntInput temp = new IntInput();

            if (input is IntInput)
            {
                temp = (IntInput)input;
            }
            else
            {
                EquestriEngine.ErrorMessage = "Invalid input passed into Adjust Gold";
            }

            if (sender is Achievement /*|| sender is Objects.GameObjects.NPC*/)
            {
                var newGoldDisplay = new SystemWidgets.GoldDisplay(gold.AsInt, temp.Input);
                GameReference.WidgetDrawer.AddWidget(newGoldDisplay);
            }

            gold.AsInt += temp.Input;
            TryContinueList();
            return(MethodResult.Success);
        }
Exemple #14
0
        public static Data.Inputs.MethodParamPair GenerateMethodFromString(string input)
        {
            Data.Inputs.MethodParamPair output = null;
            string[] temp       = input.Split(';');
            string   methodName = temp[0].ToLower();

            switch (methodName)
            {
            case "addgold":
            {
                if (temp.Length != 2)
                {
                    throw new Data.Exceptions.EngineException("Incorrect number of parameters passed", false);
                }
                try
                {
                    MethodParamResult method    = AdjustGold;
                    IntInput          parameter = new IntInput();
                    parameter.Input = int.Parse(temp[1]);
                    output          = new MethodParamPair(method, parameter);
                }
                catch
                {
                    EquestriEngine.ErrorMessage = "Error Creating MethodParamPair";
                }
                break;
            }

            case "addexp":
            {
                MethodParamResult method    = AdjustGold;
                IntInput          parameter = new IntInput();
                parameter.Input = int.Parse(temp[1]);
                output          = new MethodParamPair(method, parameter);
                break;
            }

            case "toggleswitch":
            {
                if (temp.Length != 2)
                {
                    throw new Data.Exceptions.EngineException("Incorrect number of parameters passed", false);
                }
                MethodParamResult method    = ToggleSwitch;
                StringInput       parameter = new StringInput();
                parameter.Input = temp[1];
                output          = new MethodParamPair(method, parameter);
                break;
            }

            case "activateswitch":
            {
                if (temp.Length != 2)
                {
                    throw new Data.Exceptions.EngineException("Incorrect number of parameters passed", false);
                }
                break;
            }

            case "deactivateswitch":
            {
                if (temp.Length != 2)
                {
                    throw new Data.Exceptions.EngineException("Incorrect number of parameters passed", false);
                }

                break;
            }

            default:
                throw new Data.Exceptions.EngineException("Method name Not Found", false);
            }
            return(output);
        }
Exemple #15
0
        public static void Wait(object sender, IEventInput input)
        {
            IntInput IInput = (IntInput)input;

            System.Threading.Thread.Sleep(IInput.Input);
        }
Exemple #16
0
 public IntInput(IntInput i_Original)
 {
     m_Key   = i_Original.key;
     m_Value = i_Original.value;
 }
        /// <summary>
        /// Overrides <see cref="CADability.Actions.ConstructAction.OnSetAction ()"/>
        /// </summary>
        public override void OnSetAction()
        {
            base.TitleId = "CopyMatrixObjects";

            BoundingRect result = originals.GetExtent(Frame.ActiveView.ProjectedModel.Projection, true, false);

            centerPoint = base.ActiveDrawingPlane.ToGlobal(result.GetCenter());
            distX       = result.Width;
            distY       = result.Height;
            // da oben static private, werden diese Variablen gemerkt. Beim ersten Mal vorbesetzen:
            if ((horRight == 0) & (horLeft == 0) & (verUp == 0) & (verDown == 0))
            {
                horRight = 3;
                verUp    = 2;
            }
            // da oben static private, wird diese Variable gemerkt. Beim ersten Mal vorbesetzen:
            if (dirV.IsNullVector())
            {
                dirV = new GeoVector(1.0, 0.0, 0.0);
            }

            IntInput horCountRight = new IntInput("CopyMatrixObjects.HorCountRight", horRight);

            horCountRight.SetMinMax(0, int.MaxValue, true);
            horCountRight.SetIntEvent += new CADability.Actions.ConstructAction.IntInput.SetIntDelegate(SetHorCountRight);
            //			horCountRight.CalculateIntEvent +=new CADability.Actions.ConstructAction.IntInput.CalculateIntDelegate(CalcHorCountRight);

            IntInput verCountUp = new IntInput("CopyMatrixObjects.VerCountUp", verUp);

            verCountUp.SetMinMax(0, int.MaxValue, true);
            verCountUp.SetIntEvent += new CADability.Actions.ConstructAction.IntInput.SetIntDelegate(SetVerCountUp);
            //			verCountUp.CalculateIntEvent +=new CADability.Actions.ConstructAction.IntInput.CalculateIntDelegate(CalcVerCountUp);

            horDist = new LengthInput("CopyMatrixObjects.HorDist", distX);
            horDist.SetDistanceFromLine(centerPoint, centerPoint + (dirV ^ base.ActiveDrawingPlane.Normal));
            horDist.SetLengthEvent += new CADability.Actions.ConstructAction.LengthInput.SetLengthDelegate(SetHorDist);

            verDist = new LengthInput("CopyMatrixObjects.VerDist", distY);
            verDist.SetDistanceFromLine(centerPoint, centerPoint + dirV);
            verDist.SetLengthEvent += new CADability.Actions.ConstructAction.LengthInput.SetLengthDelegate(SetVerDist);

            GeoVectorInput dir = new GeoVectorInput("CopyMatrixObjects.Direction", dirV);

            dir.Optional = true;
            dir.SetVectorFromPoint(centerPoint);
            dir.SetGeoVectorEvent += new CADability.Actions.ConstructAction.GeoVectorInput.SetGeoVectorDelegate(SetDir);
            dir.IsAngle            = true;

            IntInput horCountLeft = new IntInput("CopyMatrixObjects.HorCountLeft", horLeft);

            horCountLeft.SetMinMax(0, int.MaxValue, true);
            horCountLeft.Optional     = true;
            horCountLeft.SetIntEvent += new CADability.Actions.ConstructAction.IntInput.SetIntDelegate(SetHorCountLeft);
            //			horCountLeft.CalculateIntEvent +=new CADability.Actions.ConstructAction.IntInput.CalculateIntDelegate(CalcHorCountLeft);

            IntInput verCountDown = new IntInput("CopyMatrixObjects.VerCountDown", verDown);

            verCountDown.SetMinMax(0, int.MaxValue, true);
            verCountDown.Optional     = true;
            verCountDown.SetIntEvent += new CADability.Actions.ConstructAction.IntInput.SetIntDelegate(SetVerCountDown);
            //			verCountDown.CalculateIntEvent +=new CADability.Actions.ConstructAction.IntInput.CalculateIntDelegate(CalcVerCountDown);


            base.SetInput(horCountRight, verCountUp, horDist, verDist, dir, horCountLeft, verCountDown);

            base.OnSetAction();
            showMatrix();
        }