Esempio n. 1
0
 public void MoveDivider(Tab tabSelect)
 {
     foreach (var tab in TabCollection)
     {
         if (Equals(tab, tabSelect))
         {
             ActualSelect      = tab;
             tab.Title.Opacity = 1;
             if (_oldSelection == null)
             {
                 dt.Stop();
                 Divider.BeginAnimation(Canvas.LeftProperty,
                                        new DoubleAnimation(0, Canvas.GetLeft(tab), TimeSpan.FromMilliseconds(150)));
                 Animations.AnimateWidth(Divider.ActualWidth, tab.ActualWidth, Divider, 0.15, 0, () => dt.Start());
             }
             else
             {
                 dt.Stop();
                 Divider.BeginAnimation(Canvas.LeftProperty,
                                        new DoubleAnimation(Canvas.GetLeft(_oldSelection), Canvas.GetLeft(tab),
                                                            TimeSpan.FromMilliseconds(150)));
                 Animations.AnimateWidth(Divider.ActualWidth, tab.ActualWidth, Divider, 0.15, 0, () => dt.Start());
             }
         }
     }
 }
Esempio n. 2
0
        public List <string> Divide(string text)
        {
            string        subLex = string.Empty;
            List <string> result = new List <string>();
            int           begin  = 0;

            for (int i = 0; i < text.Length; i++)
            {
                if (Divider.IsDivide(text[i]))
                {
                    subLex = text.Substring(begin, i - begin);
                    subLex = subLex.Trim().Trim(' ');
                    begin  = i;
                    if (subLex != string.Empty)
                    {
                        result.Add(subLex);
                    }
                }
            }
            string buf = text.Substring(begin);

            buf = buf.Trim().Trim(' ');
            if (buf != string.Empty)
            {
                result.Add(buf);
            }
            return(result);
        }
Esempio n. 3
0
        public void Dividing4By2Gives2()
        {
            Divider div    = new Divider();
            var     result = div.Divide(4, 2);

            Assert.AreEqual(2, result, "Dividing 4 by 2 does not result in 2.");
        }
Esempio n. 4
0
        public void CalculateTest()
        {
            ITwoArgumentsCalculator calculator = new Divider();
            double result = calculator.Calculate(4, 2);

            Assert.AreEqual(2, result);
        }
Esempio n. 5
0
        public void DividingBy0Gives0()
        {
            Divider div    = new Divider();
            var     result = div.Divide(4, 0);

            Assert.AreEqual(0, result, "Dividing by 0 does not result in 0.");
        }
Esempio n. 6
0
        public void CalculatorTests()
        {
            var    calculator = new Divider();
            double actual     = calculator.Calculate(4, 2);

            Assert.AreEqual(2, actual: actual);
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            int     lowNumber  = 0;
            int     highNumber = 0;
            Divider divider;

            NObjects nObjects = new NObjects();

            lowNumber = CommonUI.GetAPositiveIntegerFromUserInput(AppConsts.numericalInputLowerBound, AppConsts.lowNumerPrompt);

            highNumber = CommonUI.GetAPositiveIntegerFromUserInput(lowNumber + 1, AppConsts.highNumberPrompt);
            PopulateNObjects(nObjects);

            try
            {
                Delegates.DisplayDelegate display = Display.DisplayMessageOnConsole;
                divider = new Divider(lowNumber, highNumber);
                nObjects.RunDivider(divider, display);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.Write("Hit any key to exit this program...");
            Console.ReadKey();
        }
Esempio n. 8
0
        public void DividerTest()
        {
            Divider calculator = new Divider();
            double  result     = calculator.Calculate(6, 3);

            Assert.AreEqual(2, result);
        }
Esempio n. 9
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            l = 0;
            t = 0;
            r = Width;
            b = Height;

            if (Header != null)
            {
                var headerHeight = Header.MeasuredHeight;
                Header.Layout(l, t, r, headerHeight);
                ItemTop = headerHeight;
                Item.Layout(l, headerHeight, r, b);
            }
            else if (Divider != null)
            {
                Divider.SetBounds(l, t, r, DividerHeight);
                ItemTop = DividerHeight;
                Item.Layout(l, DividerHeight, r, b);
            }
            else
            {
                ItemTop = t;
                Item.Layout(l, t, r, b);
            }
        }
Esempio n. 10
0
        public void Calculate()
        {
            Divider calculator = new Divider();
            double  result     = calculator.Calculate(10, 5);

            Assert.AreEqual(2, result);
        }
Esempio n. 11
0
 public void CalculateTestByZero()
 {
     ITwoArgumentsCalculator calculator = new Divider();
     double result = calculator.Calculate(4, 2);
     //Assert.Throws<>(() =>
     //calculator.Calculate());
 }
        /// <summary>
        /// Event Handler from Form Load Event
        /// Setup the ink overlay for collection
        /// </summary>
        /// <param name="sender">The control that raised the event.</param>
        /// <param name="e">The event arguments.</param>
        private void InkDividerForm_Load(object sender, System.EventArgs e)
        {
            // Create the ink overlay and associate it with the form
            myInkOverlay = new Microsoft.Ink.InkOverlay(DrawArea.Handle);

            // Hook event handler for the Stroke event to myInkOverlay_Stroke.
            // This is necessary since the application needs to pass the strokes
            // to the ink divider.
            myInkOverlay.Stroke += new InkCollectorStrokeEventHandler(myInkOverlay_Stroke);

            // Hook the event handler for StrokeDeleting event to myInkOverlay_StrokeDeleting.
            // This is necessary as the application needs to remove the strokes from
            // ink divider object as well.
            myInkOverlay.StrokesDeleting += new InkOverlayStrokesDeletingEventHandler(myInkOverlay_StrokeDeleting);

            // Hook the event handler for StrokeDeleted event to myInkOverlay_StrokeDeleted.
            // This is necessary to update the layout analysis result when automatic layout analysis
            // option is selected.
            myInkOverlay.StrokesDeleted += new InkOverlayStrokesDeletedEventHandler(myInkOverlay_StrokeDeleted);

            // Create the ink divider object
            myInkDivider = new Divider();

            // Add a default recognizer context to the divider object
            // without adding the recognizer context, the divider would
            // not use a recognizer to do its word segmentation and would
            // have less accurate results.
            // Adding the recognizer context will slow down the call to
            // myInkDivider.Divide though.
            // It is possible that there is no recognizer installed on the
            // machine for this language. In that case the divider will
            // not use a recognizer to improve its accuracy.
            // Get the default recognizer if any
            try
            {
                Recognizers recognizers = new Recognizers();
                myInkDivider.RecognizerContext = recognizers.GetDefaultRecognizer().CreateRecognizerContext();
            }
            catch (InvalidOperationException)
            {
                //We are in the case where no default recognizers can be found
            }

            // The LineHeight property helps the InkDivider distinguish between
            // drawing and handwriting. The value should be the expected height
            // of the user's handwriting in ink space units (0.01mm).
            // Here we set the LineHeight to 840, which is about 1/3 of an inch.
            myInkDivider.LineHeight = 840;

            // Assign ink overlay's strokes collection to the ink divider
            // This strokes collection will be updated in the event handler
            myInkDivider.Strokes = myInkOverlay.Ink.Strokes;

            // Enable ink collection
            myInkOverlay.Enabled = true;

            // Set check for ink menu item
            miInk.Checked = true;
        }
Esempio n. 13
0
 private void OnEnable()
 {
     _divider  = target as Divider;
     _lastTool = Tools.current;
     // remove transform manipulation
     _divider.transform.hideFlags = UnityEngine.HideFlags.HideInInspector;
     Tools.current = Tool.None;
 }
Esempio n. 14
0
        public int Remainder(int a, int b)
        {
            if (Verbose)
            {
                Console.WriteLine("METHOD CALL  - DefaultCalculator.Remainder({0}, {1})", a, b);
            }

            return(Divider.Remainder(a, b));
        }
Esempio n. 15
0
        public void CalculateTest(
            double firstValue,
            double secondValue,
            double expected)
        {
            var calculator   = new Divider();
            var actualResult = calculator.Calculate(firstValue, secondValue);

            Assert.AreEqual(expected, actualResult);
        }
Esempio n. 16
0
 private void Dt_Tick(object sender, EventArgs e)
 {
     if (ActualSelect != null)
     {
         Divider.BeginAnimation(Canvas.LeftProperty,
                                new DoubleAnimation(Canvas.GetLeft(Divider), Canvas.GetLeft(ActualSelect),
                                                    TimeSpan.FromMilliseconds(1)));
         Animations.AnimateWidth(Divider.ActualWidth, ActualSelect.ActualWidth, Divider, 0, 0, null);
     }
 }
Esempio n. 17
0
        public void Dividing4By2Gives2()
        {
            // Arrange
            Divider div = new Divider();

            // Act
            int result = div.Divide(4, 2);

            // Assert
            Assert.AreEqual(2, result, "Dividing 4 by 2 does not result in 2.");
        }
Esempio n. 18
0
        public void ItShouldAddTwoNumbers()
        {
            var number1        = 16;
            var number2        = 8;
            var expectedResult = 2;

            var target       = new Divider();
            var actualResult = target.Divide(number1, number2);

            actualResult.Should().Be(expectedResult);
        }
Esempio n. 19
0
        public void TestDivideZero()
        {
            // Arrange
            Divider div = new Divider();

            // Act
            int result = div.Divide(4, 0);

            // Assert
            Assert.AreEqual(0, result, "Dividing by zero fails");
        }
Esempio n. 20
0
 private void TryDivide(object obj)
 {
     try
     {
         Result = new Divider(DivisionNum, DividedNum).Execute();
     }
     catch (Exception e)
     {
         UserNotificationObject.NotifyError(e.Message);
     }
 }
Esempio n. 21
0
        public void DividerGeneratesCorrectJson()
        {
            var expected = new JObject(new JProperty("type", "divider"), new JProperty("block_id", "test"));
            var actual   = new Divider("test");

            Assert.True(JToken.DeepEquals(JObject.FromObject(actual), expected));

            var result = JsonConvert.DeserializeObject <IMessageBlock>(expected.ToString());

            Assert.IsType <Divider>(result);
        }
Esempio n. 22
0
        public override void CopyFrom(BindableObject bindableObject)
        {
            base.CopyFrom(bindableObject);

            if (bindableObject is PickerStyle pickerStyle)
            {
                ItemTextLabel.CopyFrom(pickerStyle.ItemTextLabel);
                Divider.CopyFrom(pickerStyle.Divider);
                StartScrollOffset = (pickerStyle.StartScrollOffset == null) ?
                                    new Size2D() : new Size2D(pickerStyle.StartScrollOffset.Width, pickerStyle.StartScrollOffset.Height);
            }
        }
Esempio n. 23
0
    private void placeDivider()
    {
        if (Settings.DividerObjects.Dividers.Any())
        {
            Divider    dividerToPlace = Settings.DividerObjects.Dividers[Random.Range(0, Settings.DividerObjects.Dividers.Length)];
            GameObject divider        = Instantiate(dividerToPlace.Prefab);
            divider.transform.position = new Vector3(divider.transform.position.x, 0, lastRowPlacedZ + 10);

            // Make sure we can see when the difficulty should change
            difficultyChangeDistances.Add(lastRowPlacedZ + 10f);
            lastRowPlacedZ += dividerToPlace.Height * 10;
        }
    }
Esempio n. 24
0
        protected override void DispatchDraw(Android.Graphics.Canvas canvas)
        {
            base.DispatchDraw(canvas);

            if (Header == null && Divider != null)
            {
                //Drawable.setbounds does not work on pre honeycomb, so you have to do a little work around
                //for anything pre-HC.
                if ((int)Build.VERSION.SdkInt < 11)
                {
                    canvas.ClipRect(0, 0, Width, DividerHeight);
                }
                Divider.Draw(canvas);
            }
        }
Esempio n. 25
0
        public void TestComplex()
        {
            IExpression e =
                new Divider(
                    new Multiplier(
                        new Negate(new Constant(5.0)),
                        new Divider(new Constant(9.0), new Constant(6.0))
                        ),
                    new Adder(
                        new Constant(7.0),
                        new Subtracter(new Constant(2.0), new Constant(1.5))
                        )
                    );

            Assert.AreEqual(-1, e.Calculate());
        }
Esempio n. 26
0
        static void Main(string[] args)
        {
            Overseer overseer = new Overseer();

            overseer.Setup();
            overseer.Expression.Print();
            var mTerm       = Multiplier.Multiply(overseer.Expression.PolynomialList[0].Terms[0], overseer.Expression.PolynomialList[0].Terms[1]);
            var dTerm       = Divider.Divide(overseer.Expression.PolynomialList[0].Terms[0], overseer.Expression.PolynomialList[0].Terms[1]);
            var rPolynomial = Multiplier.Multiply(overseer.Expression.PolynomialList[0], overseer.Expression.PolynomialList[0]);
            var aPolynomial = Adder.Add(overseer.Expression.PolynomialList[0], overseer.Expression.PolynomialList[0]);

            mTerm.Print();
            dTerm.Print();
            rPolynomial.Print();
            aPolynomial.Print();
        }
Esempio n. 27
0
        public void Train(NeuralNetwork.NeuralNetwork neuralNetwork, Matrix <double> inputs, Matrix <double> outputs, HyperParameters hyperParamters = null)
        {
            if (TrainingAlgorithm is LevenbergAlgorithm)
            {
                _isLeven = true;
            }
            else
            {
                _isLeven = false;
            }
            TrainingAlgorithm.Subscribe(this);
            var temp = Divider.Divide(inputs, outputs);

            Console.WriteLine(temp.Item1);
            Console.WriteLine(temp.Item2);
            _train(neuralNetwork, temp.Item1, temp.Item3, temp.Item2, temp.Item4, hyperParamters);
        }
Esempio n. 28
0
    private void Initialize_BSP_Root()
    {
        divides = numberDivides;

        //Create the initial root divider
        root = new Divider
        {
            id    = 0,
            depth = 0,
            x1    = roomMaxSize,
            y1    = roomMaxSize,
            x2    = mapWidth - roomMaxSize,
            y2    = mapHeight - roomMaxSize
        };

        dividerList.Add(root);
    }
Esempio n. 29
0
        public ActionResult <Adder> Post([FromBody] CalculatorRequest calculatorRequest)
        {
            CalculatorOperatorBase calculator;

            switch (calculatorRequest.CalculatorOperatorType)
            {
            case CalculatorOperatorTypeEnum.Adder:
            {
                calculator = new Adder(calculatorRequest.LeftVal, calculatorRequest.RightVal);
                break;
            }

            case CalculatorOperatorTypeEnum.Substracter:
            {
                calculator = new Substracter(calculatorRequest.LeftVal, calculatorRequest.RightVal);
                break;
            }

            case CalculatorOperatorTypeEnum.Multiplier:
            {
                calculator = new Multiplier(calculatorRequest.LeftVal, calculatorRequest.RightVal);
                break;
            }

            case CalculatorOperatorTypeEnum.Divider:
            {
                calculator = new Divider(calculatorRequest.LeftVal, calculatorRequest.RightVal);
                break;
            }

            default:
            {
                return(BadRequest("Invalid CalculatorOperatorType"));
            }
            }

            calculator.Calculate();

            var calculatorResponse = new CalculatorResponse
            {
                Result = calculator.Result
            };

            return(Ok(calculatorResponse));
        }
Esempio n. 30
0
        static void Main()
        {
            try
            {
                Divider d   = new Divider(10, 0);
                int     res = d.Run();

                Console.WriteLine("{0} ", res);
            }
            catch (DividerException ex)
            {
                Console.WriteLine(ex);
            }



            Console.ReadKey();
        }
        /// <summary>
        /// Event Handler from Form Load Event
        /// Setup the ink overlay for collection
        /// </summary>
        /// <param name="sender">The control that raised the event.</param>
        /// <param name="e">The event arguments.</param>
        private void InkDividerForm_Load(object sender, System.EventArgs e)
        {
            // Create the ink overlay and associate it with the form
            myInkOverlay = new Microsoft.Ink.InkOverlay(DrawArea.Handle);

            // Hook event handler for the Stroke event to myInkOverlay_Stroke.
            // This is necessary since the application needs to pass the strokes
            // to the ink divider.
            myInkOverlay.Stroke += new InkCollectorStrokeEventHandler(myInkOverlay_Stroke);

            // Hook the event handler for StrokeDeleting event to myInkOverlay_StrokeDeleting.
            // This is necessary as the application needs to remove the strokes from
            // ink divider object as well.
            myInkOverlay.StrokesDeleting += new InkOverlayStrokesDeletingEventHandler(myInkOverlay_StrokeDeleting);

            // Hook the event handler for StrokeDeleted event to myInkOverlay_StrokeDeleted.
            // This is necessary to update the layout analysis result when automatic layout analysis
            // option is selected.
            myInkOverlay.StrokesDeleted += new InkOverlayStrokesDeletedEventHandler(myInkOverlay_StrokeDeleted);

            // Create the ink divider object
            myInkDivider = new Divider();

            // Add a default recognizer context to the divider object
            // without adding the recognizer context, the divider would
            // not use a recognizer to do its word segmentation and would
            // have less accurate results.
            // Adding the recognizer context will slow down the call to
            // myInkDivider.Divide though.
            // It is possible that there is no recognizer installed on the
            // machine for this language. In that case the divider will
            // not use a recognizer to improve its accuracy.
            // Get the default recognizer if any
            try
            {
                Recognizers recognizers = new Recognizers();
                myInkDivider.RecognizerContext = recognizers.GetDefaultRecognizer().CreateRecognizerContext();
            }
            catch (InvalidOperationException)
            {
                //We are in the case where no default recognizers can be found
            }

            // The LineHeight property helps the InkDivider distinguish between
            // drawing and handwriting. The value should be the expected height
            // of the user's handwriting in ink space units (0.01mm).
            // Here we set the LineHeight to 840, which is about 1/3 of an inch.
            myInkDivider.LineHeight = 840;

            // Assign ink overlay's strokes collection to the ink divider
            // This strokes collection will be updated in the event handler
            myInkDivider.Strokes = myInkOverlay.Ink.Strokes;

            // Enable ink collection
            myInkOverlay.Enabled = true;

            // Set check for ink menu item
            miInk.Checked = true;
        }