private void InitializeComponent()
        {
            _label = new LabelControl();
            _yesButton = new ButtonControl();
            _noButton = new ButtonControl();

            Children.Add(_label);
            Children.Add(_yesButton);
            Children.Add(_noButton);

            //
            // label
            //
            _label.Bounds = new UniRectangle(25, 15, 500, 45);
            _label.Text = "";

            //
            // yesButton
            //
            _yesButton.Bounds = new UniRectangle(new UniScalar(1.0F, -85), new UniScalar(1.0F, -45), 70, 30);
            _yesButton.Text = "Yes";

            //
            // noButton
            //
            _noButton.Bounds = new UniRectangle(new UniScalar(1.0F, -160), new UniScalar(1.0F, -45), 70, 30);
            _noButton.Text = "No";

            Bounds = new UniRectangle(0, 0, 550, 120);
        }
 /// <summary>Ensures that two unified vectors are nearly equal to each other</summary>
 /// <param name="expected">Expected unified vector</param>
 /// <param name="actual">Actual unified vector</param>
 /// <param name="deltaUlps">
 ///   Allowed deviation in representable floating point values for each of the
 ///   unified vector's fields
 /// </param>
 public static void AreAlmostEqual(
   UniRectangle expected, UniRectangle actual, int deltaUlps
 ) {
   if(!areAlmostEqual(expected, actual, deltaUlps)) {
     Assert.AreEqual(expected, actual);
   }
 }
Exemple #3
0
        public void TestAlmostEqualRectangles()
        {
            UniRectangle testRectangle = new UniRectangle(
                new UniVector(
                    new UniScalar(minusOneFloat, plusOneFloat),
                    new UniScalar(plusOneFloat, minusOneFloat)
                    ),
                new UniVector(
                    new UniScalar(plusOneFloat, minusOneFloat),
                    new UniScalar(minusOneFloat, plusOneFloat)
                    )
                );
            UniRectangle exactRectangle = new UniRectangle(
                new UniVector(
                    new UniScalar(exactFloat, exactFloat),
                    new UniScalar(exactFloat, exactFloat)
                    ),
                new UniVector(
                    new UniScalar(exactFloat, exactFloat),
                    new UniScalar(exactFloat, exactFloat)
                    )
                );

            UniAssertHelper.AreAlmostEqual(exactRectangle, testRectangle, 1);
        }
Exemple #4
0
        public void TestThrowOnAlmostEqualVectorsWithSizeDifference()
        {
            UniRectangle testRectangle = new UniRectangle(
                new UniVector(
                    new UniScalar(minusOneFloat, plusOneFloat),
                    new UniScalar(plusOneFloat, minusOneFloat)
                    ),
                new UniVector(
                    new UniScalar(plusTwoFloat, minusTwoFloat),
                    new UniScalar(minusTwoFloat, plusTwoFloat)
                    )
                );
            UniRectangle exactRectangle = new UniRectangle(
                new UniVector(
                    new UniScalar(exactFloat, exactFloat),
                    new UniScalar(exactFloat, exactFloat)
                    ),
                new UniVector(
                    new UniScalar(exactFloat, exactFloat),
                    new UniScalar(exactFloat, exactFloat)
                    )
                );

            Assert.Throws <AssertionException>(
                delegate() { UniAssertHelper.AreAlmostEqual(exactRectangle, testRectangle, 1); }
                );
        }
        private void InitializeComponent()
        {
            EnableDragging = false;

            _return = new ButtonControl();
            _mainMenu = new ButtonControl();
            _exit = new ButtonControl();

            // new game
            _return.Text = "Return";
            _return.Bounds = new UniRectangle(15, 15, 150, 45);

            // continue
            _mainMenu.Text = "Main Menu";
            _mainMenu.Bounds = new UniRectangle(15, 65, 150, 45);

            // load game
            _exit.Text = "Exit";
            _exit.Bounds = new UniRectangle(15, 115, 150, 45);

            Children.Add(_return);
            Children.Add(_mainMenu);
            Children.Add(_exit);

            Bounds = new UniRectangle(10, 10, 180, 175);
        }
 /// <summary> 
 ///   Required method for user interface initialization -
 ///   do modify the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     _helloWorldLabel = new LabelControl();
     _okButton = new ButtonControl();
     _cancelButton = new ButtonControl();
     //
     // helloWorldLabel
     //
     _helloWorldLabel.Text = "Hello World! This is a label.";
     _helloWorldLabel.Bounds = new UniRectangle(10.0f, 15.0f, 110.0f, 30.0f);
     //
     // okButton
     //
     _okButton.Bounds = new UniRectangle(
       new UniScalar(1.0f, -180.0f), new UniScalar(1.0f, -40.0f), 80, 24
     );
     //
     // cancelButton
     //
     _cancelButton.Bounds = new UniRectangle(
       new UniScalar(1.0f, -90.0f), new UniScalar(1.0f, -40.0f), 80, 24
     );
     //
     // DemoDialog
     //
     Bounds = new UniRectangle(0.0f, 0.0f, 250.0f, 125.0f);
     Children.Add(_helloWorldLabel);
     Children.Add(_okButton);
     Children.Add(_cancelButton);
 }
        private void InitializeComponent()
        {
            EnableDragging = false;

            Bounds = new UniRectangle(
                new UniScalar(0.0f, 0.0f), new UniScalar(0.0f, 0.0f),
                new UniScalar(1.0f, 0.0f), new UniScalar(0.0f, 95.0f)
            );

            _statusButton = new ButtonControl();
            _statusButton.Text = "Status";
            _statusButton.Bounds = new UniRectangle(
                new UniScalar(0.025f, 0.0f), new UniScalar(0.0f, 15.0f),
                new UniScalar(0.30f, 0.0f), new UniScalar(0.0f, 65.0f)
            );
            Children.Add(_statusButton);

            _inventoryButton = new ButtonControl();
            _inventoryButton.Text = "Inventory";
            _inventoryButton.Bounds = new UniRectangle(
                new UniScalar(0.35f, 0.0f), new UniScalar(0.0f, 15.0f),
                new UniScalar(0.30f, 0.0f), new UniScalar(0.0f, 65.0f)
            );
            Children.Add(_inventoryButton);

            _settingsButton = new ButtonControl();
            _settingsButton.Text = "Settings";
            _settingsButton.Bounds = new UniRectangle(
                new UniScalar(0.675f, 0.0f), new UniScalar(0.0f, 15.0f),
                new UniScalar(0.30f, 0.0f), new UniScalar(0.0f, 65.0f)
            );
            Children.Add(_settingsButton);
        }
        private void InitializeComponent()
        {
            _healthbar = new ProgressControl();
            _healthbar.Bounds = new UniRectangle(
                new UniScalar(0.0F, 15),    
                new UniScalar(0.0F, 15),
                new UniScalar(1.0F, -30),
                new UniScalar(0.0F, 30)
            );
            _healthbar.Progress = 0.5F;

            _playerlives = new TiledIconControl();
            _playerlives.Height = 1;
            _playerlives.Width = 18;
            _playerlives.Count = 18;
            _playerlives.ImageFrame = "playerlives";
            _playerlives.Bounds = new UniRectangle(
                new UniScalar(0.5F, 0 - 450), 
                new UniScalar(1.0F, 0 - 55), 
                900, 40
            );

            Children.Add(_healthbar);
            Children.Add(_playerlives);

            Bounds = new UniRectangle(
                new UniScalar(0.0F, 0.0F), new UniScalar(0.0F, 0.0F), 
                new UniScalar(1.0F, 0.0F), new UniScalar(0.0F, 110.0F)
            );
            EnableDragging = false;
        }
        private void InitializeComponent()
        {
            Bounds = new UniRectangle(
                10, 10, new UniScalar(1.0f, -20), 35
            );

            var label = new LabelControl();
            label.Text = _ability.Name;
            label.Bounds = new UniRectangle(10, 5, 180, 30);
            Children.Add(label);

            label = new LabelControl();
            label.Text = ((int)(_exp / 100)).ToString();
            label.Bounds = new UniRectangle(190, 5, 30, 30);
            Children.Add(label);

            var progress = new ProgressControl();
            progress.Progress = (_exp % 100) / 100.0f;
            progress.Bounds = new UniRectangle(225, 5, new UniScalar(1.0f, -270), new UniScalar(1.0f, -5.0f));
            Children.Add(progress);

            label = new LabelControl();
            label.Text = ((int)(_exp % 100)).ToString();
            label.Bounds = new UniRectangle(new UniScalar(1.0f, -35), 5, 30, 30);
            Children.Add(label);
        }
        private void InitializeComponent()
        {
            EnableDragging = false;

            _dialogText = new LabelControl();
            _dialogText.Bounds = new UniRectangle(
                new UniScalar(0.0f, 15.0f), new UniScalar(0.0f, 15.0f),
                new UniScalar(1.0f, -30.0f), new UniScalar(1.0f, -85.0f)
            );
            Children.Add(_dialogText);

            _optionsList = new ListControl();
            _optionsList.Bounds = new UniRectangle(10, 10, new UniScalar(1, -20), 150);
            _optionsList.SelectionMode = ListSelectionMode.Single;

            _nextButton = new ButtonControl();
            _nextButton.Text = "Continue";
            _nextButton.Bounds = new UniRectangle(
                new UniScalar(1.0f, -110), new UniScalar(1.0f, -55f),
                new UniScalar(100), new UniScalar(45)
            );
            Children.Add(_nextButton);

            Bounds = new UniRectangle(
                new UniScalar(0.0f, 0.0f), new UniScalar(1.0f, -225.0f),
                new UniScalar(1.0f, 0.0f), new UniScalar(0.0f, 225.0f)
            );
        }
        public void TestEqualsWithNullReference()
        {
            UniRectangle testRectangle = new UniRectangle(
                firstTestScalar, secondTestScalar, thirdTestScalar, fourthTestScalar
                );

            Assert.IsFalse(testRectangle.Equals(null));
        }
        public void TestEqualsWithDifferentType()
        {
            UniRectangle testRectangle = new UniRectangle(
                firstTestScalar, secondTestScalar, thirdTestScalar, fourthTestScalar
                );

            Assert.IsFalse(testRectangle.Equals(DateTime.MinValue));
        }
 private void InitializeComponent()
 {
     Bounds = new UniRectangle(
         new UniScalar(0.0f, 0.0f), new UniScalar(0.0f, 105.0f),
         new UniScalar(1.0f, 0.0f), new UniScalar(1.0f, -105.0f)
     );
     EnableDragging = false;
 }
        private void InitializeComponent()
        {
            _cannonButton = new ImageButtonControl();
            _laserButton = new ImageButtonControl();
            _missileButton = new ImageButtonControl();
            _mgButton = new ImageButtonControl();

            // cannon
            _cannonButton = new ImageButtonControl();
            _cannonButton.Bounds = new UniRectangle(
                new UniScalar(0.0F, 15),
                new UniScalar(0.0F, 15),
                new UniScalar(0.0F, 50), 
                new UniScalar(0.0F, 50)
            );
            _cannonButton.ImageFrame = "hotbar.cannon";

            // laser
            _laserButton = new ImageButtonControl();
            _laserButton.Bounds = new UniRectangle(
                new UniScalar(0.0F, 80),
                new UniScalar(0.0F, 15),
                new UniScalar(0.0F, 50),
                new UniScalar(0.0F, 50)
            );
            _laserButton.ImageFrame = "hotbar.laser";

            // missile
            _missileButton = new ImageButtonControl();
            _missileButton.Bounds = new UniRectangle(
                new UniScalar(0.0F, 145),
                new UniScalar(0.0F, 15),
                new UniScalar(0.0F, 50),
                new UniScalar(0.0F, 50)
            );
            _missileButton.ImageFrame = "hotbar.missile";

            // machine gun
            _mgButton = new ImageButtonControl();
            _mgButton.Bounds = new UniRectangle(
                new UniScalar(0.0F, 210),
                new UniScalar(0.0F, 15),
                new UniScalar(0.0F, 50),
                new UniScalar(0.0F, 50)
            );
            _mgButton.ImageFrame = "hotbar.mg";

            Children.Add(_cannonButton);
            Children.Add(_laserButton);
            Children.Add(_missileButton);
            Children.Add(_mgButton);

            Bounds = new UniRectangle(
                new UniScalar(0.0F, 0.0F), new UniScalar(0.0F, 0.0F),
                new UniScalar(0.0F, 275.0F), new UniScalar(0.0F, 80F)
            );
            EnableDragging = false;
        }
        public void TestBottomProperty()
        {
            UniRectangle testRectangle = new UniRectangle();

            testRectangle.Bottom = firstTestScalar;

            Assert.AreEqual(firstTestScalar, testRectangle.Bottom);
            Assert.AreEqual(firstTestScalar, testRectangle.Size.Y);
        }
        public void TestLeftProperty()
        {
            UniRectangle testRectangle = new UniRectangle();

            testRectangle.Left = firstTestScalar;

            Assert.AreEqual(firstTestScalar, testRectangle.Left);
            Assert.AreEqual(firstTestScalar, testRectangle.Location.X);
        }
        public void TestTopProperty()
        {
            UniRectangle testRectangle = new UniRectangle();

            testRectangle.Top = firstTestScalar;

            Assert.AreEqual(firstTestScalar, testRectangle.Top);
            Assert.AreEqual(firstTestScalar, testRectangle.Location.Y);
        }
        public void TestRightProperty()
        {
            UniRectangle testRectangle = new UniRectangle();

            testRectangle.Right = firstTestScalar;

            Assert.AreEqual(firstTestScalar, testRectangle.Right);
            Assert.AreEqual(firstTestScalar, testRectangle.Size.X);
        }
 /// <summary>Ensures that two unified vectors are nearly equal to each other</summary>
 /// <param name="expected">Expected unified vector</param>
 /// <param name="actual">Actual unified vector</param>
 /// <param name="deltaUlps">
 ///   Allowed deviation in representable floating point values for each of the
 ///   unified vector's fields
 /// </param>
 public static void AreAlmostEqual(
     UniRectangle expected, UniRectangle actual, int deltaUlps
     )
 {
     if (!areAlmostEqual(expected, actual, deltaUlps))
     {
         Assert.AreEqual(expected, actual);
     }
 }
        public void TestGetHashCode()
        {
            UniRectangle testRectangle = new UniRectangle(
                firstTestScalar, secondTestScalar, thirdTestScalar, fourthTestScalar
                );
            UniRectangle equivalentRectangle = new UniRectangle(
                firstTestScalar, secondTestScalar, thirdTestScalar, fourthTestScalar
                );

            Assert.AreEqual(testRectangle.GetHashCode(), equivalentRectangle.GetHashCode());
        }
        private void InitializeComponent()
        {
            EnableDragging = false;

            _controls = new List<QueuedCommandControl>();
            Bounds = new UniRectangle(
                new UniScalar(0.0f, 0.0f), new UniScalar(1.0f, 0.0f),
                new UniScalar(0.0f, 300.0f), new UniScalar(0.0f, 100.0f)
            );
            UpdateControls();
        }
    public void TestToOffset() {
      UniRectangle testRectangle = new UniRectangle(
        firstTestScalar, secondTestScalar, thirdTestScalar, fourthTestScalar
      );

      RectangleF offsetRectangle = testRectangle.ToOffset(new Vector2(100.0f, 100.0f));

      Assert.That(offsetRectangle.X, Is.EqualTo(102.0f).Within(4).Ulps);
      Assert.That(offsetRectangle.Y, Is.EqualTo(304.0f).Within(4).Ulps);
      Assert.That(offsetRectangle.Width, Is.EqualTo(10.2f).Within(4).Ulps);
      Assert.That(offsetRectangle.Height, Is.EqualTo(30.4f).Within(4).Ulps);
    }
        public void TestToOffset()
        {
            UniRectangle testRectangle = new UniRectangle(
                firstTestScalar, secondTestScalar, thirdTestScalar, fourthTestScalar
                );

            RectangleF offsetRectangle = testRectangle.ToOffset(new Vector2(100.0f, 100.0f));

            Assert.That(offsetRectangle.X, Is.EqualTo(102.0f).Within(4).Ulps);
            Assert.That(offsetRectangle.Y, Is.EqualTo(304.0f).Within(4).Ulps);
            Assert.That(offsetRectangle.Width, Is.EqualTo(10.2f).Within(4).Ulps);
            Assert.That(offsetRectangle.Height, Is.EqualTo(30.4f).Within(4).Ulps);
        }
        public void TestMaxProperty()
        {
            UniVector    minVector     = new UniVector(firstTestScalar, secondTestScalar);
            UniVector    maxVector     = new UniVector(thirdTestScalar, fourthTestScalar);
            UniRectangle testRectangle = new UniRectangle(UniVector.Zero, minVector);

            testRectangle.Max = maxVector;

            Assert.AreEqual(UniVector.Zero, testRectangle.Min);
            Assert.AreEqual(UniVector.Zero, testRectangle.Location);

            UniAssertHelper.AreAlmostEqual(maxVector, testRectangle.Max, 4);
            UniAssertHelper.AreAlmostEqual(maxVector, testRectangle.Size, 4);
        }
    public void TestScalarConstructor() {
      UniRectangle testRectangle = new UniRectangle(
        firstTestScalar, secondTestScalar, thirdTestScalar, fourthTestScalar
      );

      Assert.AreEqual(1.0f, testRectangle.Location.X.Fraction);
      Assert.AreEqual(2.0f, testRectangle.Location.X.Offset);
      Assert.AreEqual(3.0f, testRectangle.Location.Y.Fraction);
      Assert.AreEqual(4.0f, testRectangle.Location.Y.Offset);
      Assert.AreEqual(0.1f, testRectangle.Size.X.Fraction);
      Assert.AreEqual(0.2f, testRectangle.Size.X.Offset);
      Assert.AreEqual(0.3f, testRectangle.Size.Y.Fraction);
      Assert.AreEqual(0.4f, testRectangle.Size.Y.Offset);
    }
        private void InitializeComponent()
        {
            EnableDragging = false;

            Bounds = new UniRectangle(
                new UniScalar(0.2f, 15.0f), new UniScalar(0.0f, 105.0f),
                new UniScalar(0.8f, -15.0f), new UniScalar(1.0f, -105.0f)
            );

            //
            // overview dialog
            //
            _overviewDialog = new CharacterOverviewDialog();
            _overviewDialog.Bounds =  new UniRectangle(
                new UniScalar(20), new UniScalar(0, 20.0F),
                new UniScalar(0.6F, -40.0F), new UniScalar(0.0f, 200.0f)
            );
            Children.Add(_overviewDialog);

            //
            // stats dialog
            //
            _statsDialog = new CharacterStatsDialog();
            _statsDialog.Bounds = new UniRectangle(
                new UniScalar(0.6F, 0F), new UniScalar(0.0F, 20.0F),
                new UniScalar(0.4F, -20.0F), new UniScalar(0.0f, 200.0f)
            );
            Children.Add(_statsDialog);

            //
            // inventory dialog
            //
            _inventoryDialog = new CharacterInventoryDialog();
            _inventoryDialog.Bounds = new UniRectangle(
                new UniScalar(0.0F, 20.0F), new UniScalar(0.0F, 233.0F),
                new UniScalar(0.6F, -40.0F), new UniScalar(0.0f, 152.0f)
            );
            Children.Add(_inventoryDialog);

            //
            // ability dialog
            //
            _abilityDialog = new CharacterAbilityDialog();
            _abilityDialog.Bounds = new UniRectangle(
                new UniScalar(20), new UniScalar(400),
                new UniScalar(1.0f, -40), new UniScalar(1.0f, -420.0f)
            );
            Children.Add(_abilityDialog);
        }
        public void TestScalarConstructor()
        {
            UniRectangle testRectangle = new UniRectangle(
                firstTestScalar, secondTestScalar, thirdTestScalar, fourthTestScalar
                );

            Assert.AreEqual(1.0f, testRectangle.Location.X.Fraction);
            Assert.AreEqual(2.0f, testRectangle.Location.X.Offset);
            Assert.AreEqual(3.0f, testRectangle.Location.Y.Fraction);
            Assert.AreEqual(4.0f, testRectangle.Location.Y.Offset);
            Assert.AreEqual(0.1f, testRectangle.Size.X.Fraction);
            Assert.AreEqual(0.2f, testRectangle.Size.X.Offset);
            Assert.AreEqual(0.3f, testRectangle.Size.Y.Fraction);
            Assert.AreEqual(0.4f, testRectangle.Size.Y.Offset);
        }
        public void TestMinProperty()
        {
            UniVector    minVector     = new UniVector(firstTestScalar, secondTestScalar);
            UniVector    maxVector     = new UniVector(thirdTestScalar, fourthTestScalar);
            UniRectangle testRectangle = new UniRectangle(UniVector.Zero, maxVector);

            // This doesn't move the rectangle, it resizes it!
            testRectangle.Min = minVector;

            Assert.AreEqual(minVector, testRectangle.Min);
            Assert.AreEqual(minVector, testRectangle.Location);

            UniAssertHelper.AreAlmostEqual(maxVector, testRectangle.Max, 4);
            UniAssertHelper.AreAlmostEqual(maxVector - minVector, testRectangle.Size, 4);
        }
        public void TestEqualsWithDowncast()
        {
            UniRectangle testRectangle = new UniRectangle(
                firstTestScalar, secondTestScalar, thirdTestScalar, fourthTestScalar
                );
            UniRectangle equivalentRectangle = new UniRectangle(
                firstTestScalar, secondTestScalar, thirdTestScalar, fourthTestScalar
                );
            UniRectangle differingRectangle = new UniRectangle(
                fourthTestScalar, thirdTestScalar, secondTestScalar, firstTestScalar
                );

            Assert.IsTrue(testRectangle.Equals((object)equivalentRectangle));
            Assert.IsFalse(testRectangle.Equals((object)differingRectangle));
        }
        public void TestEqualityOperator()
        {
            UniRectangle testRectangle = new UniRectangle(
                firstTestScalar, secondTestScalar, thirdTestScalar, fourthTestScalar
                );
            UniRectangle equivalentRectangle = new UniRectangle(
                firstTestScalar, secondTestScalar, thirdTestScalar, fourthTestScalar
                );
            UniRectangle differingRectangle = new UniRectangle(
                fourthTestScalar, thirdTestScalar, secondTestScalar, firstTestScalar
                );

            Assert.IsTrue(testRectangle == equivalentRectangle);
            Assert.IsFalse(testRectangle == differingRectangle);
        }
        private void InitializeComponent()
        {
            Bounds = new Nuclex.UserInterface.UniRectangle(200, 200, 200, 400);

            _itemList = new ListControl();
            _itemList.Bounds = new UniRectangle(
                new UniScalar(0, 10), new UniScalar(0, 10),
                new UniScalar(1, -20), new UniScalar(1, -65)
            );
            Children.Add(_itemList);

            var cancelButton = new ButtonControl();
            cancelButton.Text = "Cancel";
            cancelButton.Pressed += (s, a) => { ItemCancelled.Invoke(); };
            cancelButton.Bounds = new UniRectangle(
                new UniScalar(0, 10), new UniScalar(1, -45),
                new UniScalar(1, -20), new UniScalar(35)
            );
            Children.Add(cancelButton);
        }
        private void InitializeComponent()
        {
            EnableDragging = false;

            Bounds = new UniRectangle(
                new UniScalar(0.0f, 0.0f), new UniScalar(0.0f, 0.0f),
                new UniScalar(0.0f, 170.0f), new UniScalar(0.0f, 125.0f) 
            );

            _roundLabel = new LabelControl();
            _roundNumber = new LabelControl();
            _faction = new LabelControl();
            _endTurn = new ButtonControl();

            Children.Add(_roundLabel);
            Children.Add(_roundNumber);
            Children.Add(_faction);
            Children.Add(_endTurn);

            _faction.Bounds = new UniRectangle(
                new UniScalar(0.0f, 15.0f), new UniScalar(0.0f, 10.0f),
                new UniScalar(1.0f, -20.0f), new UniScalar(0.0f, 30.0f) 
            );

            _roundLabel.Bounds = new UniRectangle(
                new UniScalar(0.0f, 15.0f), new UniScalar(0.0f, 40.0f),
                new UniScalar(0.5f, -10.0f), new UniScalar(0.0f, 30.0f)
            );
            _roundLabel.Text = "Round: ";

            _roundNumber.Bounds = new UniRectangle(
                new UniScalar(0.5f, 10.0f), new UniScalar(0.0f, 40.0f),
                new UniScalar(0.5f, -10.0f), new UniScalar(0.0f, 30.0f)
            );

            _endTurn.Bounds = new UniRectangle(
                new UniScalar(0.0f, 10.0f), new UniScalar(0.0f, 70.0f),
                new UniScalar(1.0f, -20.0f), new UniScalar(0.0f, 45.0f)
            );
            _endTurn.Text = "End Turn";
        }
        private void InitializeComponent()
        {
            Bounds = new Nuclex.UserInterface.UniRectangle(200, 200, 200, 400);

            _itemList        = new ListControl();
            _itemList.Bounds = new UniRectangle(
                new UniScalar(0, 10), new UniScalar(0, 10),
                new UniScalar(1, -20), new UniScalar(1, -65)
                );
            Children.Add(_itemList);

            var cancelButton = new ButtonControl();

            cancelButton.Text     = "Cancel";
            cancelButton.Pressed += (s, a) => { ItemCancelled.Invoke(); };
            cancelButton.Bounds   = new UniRectangle(
                new UniScalar(0, 10), new UniScalar(1, -45),
                new UniScalar(1, -20), new UniScalar(35)
                );
            Children.Add(cancelButton);
        }
        private void InitializeComponent()
        {
            Bounds = new UniRectangle(
                new UniScalar(0.0f, 0.0f), new UniScalar(0.0f, 105.0f),
                new UniScalar(0.2f, 0.0f), new UniScalar(1.0f, -105.0f)
            );
            EnableDragging = false;

            for (var i = 0; i < _party.Count; i++)
            {
                var combatant = _party[i];
                var partyButton = new ButtonControl();
                partyButton.Text = combatant.Name;
                partyButton.Bounds = new UniRectangle(
                    new UniScalar(0.0f, 15.0f), new UniScalar(0.0f, (75.0f * i) + 15.0f),
                    new UniScalar(1.0f, -30.0f), new UniScalar(0.0f, 65.0f)
                );
                partyButton.Pressed += (s, a) => ChangeCharacter(combatant);
                Children.Add(partyButton);
            }
        }
        private void InitializeComponent()
        {
            _startButton = new ButtonControl();
            _helpButton = new ButtonControl();
            _highscoresButton = new ButtonControl();
            _exitButton = new ButtonControl();

            Children.Add(_startButton);
            Children.Add(_helpButton);
            Children.Add(_highscoresButton);
            Children.Add(_exitButton);

            //
            // _startButton
            //
            _startButton.Bounds = new UniRectangle(25, 25, 150, 40);
            _startButton.Text = "Start";

            //
            // _helpButton
            //
            _helpButton.Bounds = new UniRectangle(25, 70, 150, 40);
            _helpButton.Text = "Help";

            //
            // _highscoresButton
            //
            _highscoresButton.Bounds = new UniRectangle(25, 115, 150, 40);
            _highscoresButton.Text = "High Scores";

            //
            // _exitButton
            //
            _exitButton.Bounds = new UniRectangle(25, 335, 150, 40);
            _exitButton.Text = "Exit";

            Bounds = new UniRectangle(0, 0, 200, 400);
            EnableDragging = false;
        }
        private void InitializeComponent()
        {
            EnableDragging = false;

            Bounds =  new UniRectangle(
                new UniScalar(1.0f, -210.0f), new UniScalar(1.0f, -48.0f),
                new UniScalar(0.0f, 210.0f), new UniScalar(0.0f, 48.0f)
            );

            _name = new LabelControl();
            _name.Bounds = new UniRectangle(
                new UniScalar(0.0f, 10.0f), new UniScalar(0.0f, 10.0f),
                new UniScalar(1.0f, -35.0f), new UniScalar(0.0f, 20.0f)
            );
            Children.Add(_name);

            _mana = new LabelControl();
            _mana.Bounds = new UniRectangle(
                new UniScalar(1.0f, -30.0f), new UniScalar(0.0f, 10.0f),
                new UniScalar(0.0f, 25.0f), new UniScalar(0.0f, 20.0f)
            );
            Children.Add(_mana);
        }
Exemple #37
0
        public void dialog(string text, string title)
        {
            float w = menuScreen.Width;
            float h = menuScreen.Height;
            UniRectangle bounds = new UniRectangle(w * 0.35f, h * 0.4f, w * 0.4f, h * 0.3f);

            if (gameDialog != null && gameDialog.IsOpen)
                gameDialog.Close();

            gameDialog = new GameDialog(text, title, bounds);
            baseGame.dialogOpen = true;
            gameDialog.proceedButton.Pressed += new EventHandler(proceedButton_Pressed);
            if (baseGame.menuOpen)
            {
                menuScreen.Desktop.Children.Add(gameDialog);
            }
            else if (baseGame.createOpen)
            {
                createScreen.Desktop.Children.Add(gameDialog);
            }
            else if (baseGame.startOpen)
            {
                startScreen.Desktop.Children.Add(gameDialog);
            }
            else
            {
                gameScreen.Desktop.Children.Add(gameDialog);
            }
        }
Exemple #38
0
 public GameButton(UniRectangle bounds, Texture2D spriteSheet, RectangleF sourceRect)
 {
     this.Bounds = bounds;
     this.imageTexture = spriteSheet;
     this.baseSourceRect = sourceRect;
     this.sourceRect = sourceRect;
 }
 /// <summary>Determines whether two unified rectangles are nearly equal</summary>
 /// <param name="left">Unified rectangle to compare on the left side</param>
 /// <param name="right">Unified rectangle to compare on the right side</param>
 /// <param name="deltaUlps">
 ///   Allowed deviation in representable floating point values for each of the
 ///   unified vector's fields
 /// </param>
 /// <returns>True if the provided unified rectangles are nearly equal</returns>
 private static bool areAlmostEqual(UniRectangle left, UniRectangle right, int deltaUlps)
 {
     return
         (areAlmostEqual(left.Location, right.Location, deltaUlps) &&
          areAlmostEqual(left.Size, right.Size, deltaUlps));
 }
 /// <summary>Checks whether another instance is equal to this instance</summary>
 /// <param name="other">Other instance to compare to this instance</param>
 /// <returns>True if the other instance is equal to this instance</returns>
 public bool Equals(UniRectangle other) {
   // For a struct, 'other' cannot be null
   return (this.Location == other.Location) && (this.Size == other.Size);
 }
        private void InitializeComponent()
        {
            EnableDragging = false;
            Bounds = new UniRectangle
                (
                new UniScalar(1.0f, -400.0f), new UniScalar(0.0f, 0.0f),
                new UniScalar(0.0f, 400.0f), new UniScalar(0.0f, 130.0f)
                );

            _name = new LabelControl();
            _class = new LabelControl();
            _health = new LabelControl();
            _mana = new LabelControl();
            _healthBar = new ProgressControl();
            _manaBar = new ProgressControl();

            _name.Bounds = new UniRectangle
                (
                new UniScalar(0.0f, 15.0f), new UniScalar(0.0f, 10.0f),
                new UniScalar(0.5f, -15.0f), new UniScalar(0.0f, 30.0f)
                );
            _name.Text = "Name";
            Children.Add(_name);

            _class.Bounds = new UniRectangle
                (
                new UniScalar(0.5f, 15.0f), new UniScalar(0.0f, 10.0f),
                new UniScalar(0.5f, -15.0f), new UniScalar(0.0f, 30.0f)
                );
            _class.Text = "Class";
            Children.Add(_class);

            _health.Bounds = new UniRectangle
                (
                new UniScalar(1.0f, -70f), new UniScalar(1.0f, -80.0f),
                new UniScalar(0.0f, 60f), new UniScalar(0.0f, 30.0f)
                );
            _health.Text = "50 HP";
            Children.Add(_health);

            _mana.Bounds = new UniRectangle
                (
                new UniScalar(1.0f, -70f), new UniScalar(1.0f, -40.0f),
                new UniScalar(0.0f, 60f), new UniScalar(0.0f, 30.0f)
                );
            _mana.Text = "20 SP";
            Children.Add(_mana);

            _healthBar.Bounds = new UniRectangle
                (
                new UniScalar(0.0f, 10.0f), new UniScalar(1.0f, -80.0f),
                new UniScalar(1.0f, -100.0f), new UniScalar(0.0f, 30.0f)
                );
            _healthBar.Progress = 1.0f;
            Children.Add(_healthBar);

            _manaBar.Bounds = new UniRectangle
                (
                new UniScalar(0.0f, 10.0f), new UniScalar(1.0f, -40.0f),
                new UniScalar(1.0f, -100.0f), new UniScalar(0.0f, 30.0f)
                );
            _manaBar.Progress = 1.0f;
            Children.Add(_manaBar);
        }
    public void TestMinProperty() {
      UniVector minVector = new UniVector(firstTestScalar, secondTestScalar);
      UniVector maxVector = new UniVector(thirdTestScalar, fourthTestScalar);
      UniRectangle testRectangle = new UniRectangle(UniVector.Zero, maxVector);

      // This doesn't move the rectangle, it resizes it!
      testRectangle.Min = minVector;

      Assert.AreEqual(minVector, testRectangle.Min);
      Assert.AreEqual(minVector, testRectangle.Location);

      UniAssertHelper.AreAlmostEqual(maxVector, testRectangle.Max, 4);
      UniAssertHelper.AreAlmostEqual(maxVector - minVector, testRectangle.Size, 4);
    }
    public void TestEqualityOperator() {
      UniRectangle testRectangle = new UniRectangle(
        firstTestScalar, secondTestScalar, thirdTestScalar, fourthTestScalar
      );
      UniRectangle equivalentRectangle = new UniRectangle(
        firstTestScalar, secondTestScalar, thirdTestScalar, fourthTestScalar
      );
      UniRectangle differingRectangle = new UniRectangle(
        fourthTestScalar, thirdTestScalar, secondTestScalar, firstTestScalar
      );

      Assert.IsTrue(testRectangle == equivalentRectangle);
      Assert.IsFalse(testRectangle == differingRectangle);
    }
Exemple #44
0
        private void CalculateBounds()
        {
            controlPanelBounds = new UniRectangle(0, 0, windowWidth, CONTROLS_AND_GRID_DIVISION);

            controlArrowLeftBounds = new UniRectangle(CONTROL_BUTTON_SPACING, (CONTROLS_AND_GRID_DIVISION - CONTROL_ARROW_HEIGHT) / 2, CONTROL_ARROW_WIDTH, CONTROL_ARROW_HEIGHT);
            controlArrowRightBounds = new UniRectangle(windowWidth - CONTROL_BUTTON_SPACING - CONTROL_ARROW_WIDTH, (CONTROLS_AND_GRID_DIVISION - CONTROL_ARROW_HEIGHT) / 2, CONTROL_ARROW_WIDTH, CONTROL_ARROW_HEIGHT);

            Rectangle outerRectangle = new Rectangle(0, CONTROLS_AND_GRID_DIVISION, windowWidth - RIGHT_SCROLLBAR_THICKNESS, windowHeight - CONTROLS_AND_GRID_DIVISION - BOTTOM_SCROLLBAR_THICKNESS - MEDIA_BUTTON_HEIGHT);
            Rectangle innerRectangle = new Rectangle(outerRectangle.X + LEFT_BORDER_THICKNESS, outerRectangle.Y + TOP_BORDER_THICKNESS, outerRectangle.Width - LEFT_BORDER_THICKNESS - RIGHT_BORDER_THICKNESS, outerRectangle.Height - TOP_BORDER_THICKNESS - BOTTOM_BORDER_THICKNESS);
            gridPanelLayout = new FrameLayout(outerRectangle, innerRectangle);
            RefreshGridCellsClickableArea();
            RefreshGridTopCursorsClickableArea();
            RefreshGridLeftCursorsClickableArea();

            navigatorPanelBounds = new UniRectangle(0, CONTROLS_AND_GRID_DIVISION, windowWidth, windowHeight);
            playPauseButtonBounds = new UniRectangle(gridPanelLayout.InnerRectangle.Left, gridPanelLayout.OuterRectangle.Height + BOTTOM_SCROLLBAR_THICKNESS, CONTROL_BUTTON_WIDTH, MEDIA_BUTTON_HEIGHT);
            stopButtonBounds = new UniRectangle(gridPanelLayout.InnerRectangle.Left + CONTROL_BUTTON_WIDTH + CONTROL_BUTTON_SPACING, gridPanelLayout.OuterRectangle.Height + BOTTOM_SCROLLBAR_THICKNESS, CONTROL_BUTTON_WIDTH, MEDIA_BUTTON_HEIGHT);
            horizontalScrollBarBounds = new UniRectangle(0, gridPanelLayout.OuterRectangle.Height, gridPanelLayout.OuterRectangle.Width, BOTTOM_SCROLLBAR_THICKNESS);
            verticalScrollBarBounds = new UniRectangle(gridPanelLayout.OuterRectangle.Width, gridPanelLayout.OuterRectangle.Top - CONTROLS_AND_GRID_DIVISION, RIGHT_SCROLLBAR_THICKNESS, gridPanelLayout.OuterRectangle.Height);
            tempoLabelBounds = new UniRectangle(gridPanelLayout.InnerRectangle.Left + 4 * (CONTROL_BUTTON_WIDTH + CONTROL_BUTTON_SPACING), gridPanelLayout.OuterRectangle.Height + BOTTOM_SCROLLBAR_THICKNESS + MISC_MUSIC_SETTINGS_PADDING, CONTROL_BUTTON_WIDTH, MEDIA_BUTTON_HEIGHT);
            timeSignatureNLabelBounds = new UniRectangle(gridPanelLayout.InnerRectangle.Left + 7 * (CONTROL_BUTTON_WIDTH + CONTROL_BUTTON_SPACING), gridPanelLayout.OuterRectangle.Height + BOTTOM_SCROLLBAR_THICKNESS + MISC_MUSIC_SETTINGS_PADDING, CONTROL_BUTTON_WIDTH, MEDIA_BUTTON_HEIGHT);
            timeSignatureDLabelBounds = new UniRectangle(gridPanelLayout.InnerRectangle.Left + 7 * (CONTROL_BUTTON_WIDTH + CONTROL_BUTTON_SPACING), gridPanelLayout.OuterRectangle.Height + BOTTOM_SCROLLBAR_THICKNESS + MISC_MUSIC_SETTINGS_PADDING + MISC_MUSIC_SETTINGS_LABEL_HEIGHT, CONTROL_BUTTON_WIDTH, MEDIA_BUTTON_HEIGHT);

            if (parametersPanelBounds.Top == 0)
                parametersPanelBounds = new UniRectangle(0, CONTROLS_AND_GRID_DIVISION - windowHeight, windowWidth, windowHeight - CONTROLS_AND_GRID_DIVISION - MEDIA_BUTTON_HEIGHT);
            else
                parametersPanelBounds = new UniRectangle(0, ParametersPanel.Instance.Bounds.Top, windowWidth, windowHeight - CONTROLS_AND_GRID_DIVISION - MEDIA_BUTTON_HEIGHT);

            globalRandomizeButtonBounds = new UniRectangle(new UniScalar(1, -PARAMETERS_BUTTON_SPACING * 3 - PARAMETERS_BUTTON_WIDTH * 3), new UniScalar(1, -PARAMETERS_BUTTON_SPACING - PARAMETERS_BUTTON_HEIGHT), PARAMETERS_BUTTON_WIDTH, PARAMETERS_BUTTON_HEIGHT);
            okButtonBounds = new UniRectangle(new UniScalar(1, -PARAMETERS_BUTTON_SPACING * 2 - PARAMETERS_BUTTON_WIDTH * 2), new UniScalar(1, -PARAMETERS_BUTTON_SPACING - PARAMETERS_BUTTON_HEIGHT), PARAMETERS_BUTTON_WIDTH, PARAMETERS_BUTTON_HEIGHT);
            cancelButtonBounds = new UniRectangle(new UniScalar(1, -PARAMETERS_BUTTON_SPACING - PARAMETERS_BUTTON_WIDTH), new UniScalar(1, -PARAMETERS_BUTTON_SPACING - PARAMETERS_BUTTON_HEIGHT), PARAMETERS_BUTTON_WIDTH, PARAMETERS_BUTTON_HEIGHT);

            for (int i = 0; i < parametersSliders.Count; i++)
            {
                parametersSliders.ElementAt<SkinNamedHorizontalSliderControl>(i).Bounds = GetParameterSliderBounds(i);
            }

            for (int i = 0; i < parametersLabels.Count; i++)
            {
                parametersLabels.ElementAt<LabelControl>(i).Bounds = GetParameterLabelBounds(i);
            }
        }
Exemple #45
0
            //public GameButton clearButton = new GameButton();
            public GameDialog(string text, string title, UniRectangle bounds)
            {
                nameLabel.Text = text;
                this.EnableDragging = false;
                this.Title = title;
                this.Bounds = bounds;

                nameLabel.Bounds = new UniRectangle(new UniScalar(0.0f, 10f), new UniScalar(0.0f, 50.0f), 80, 24);
                //nameLabel.Text = "Incredibly useful information\n remove this by commenting out:\n \"gameScreen.Desktop.Children.Add(gameDialog);\" in the user class";

                proceedButton.Bounds = new UniRectangle(new UniScalar(0.75f,0), new UniScalar(0.85f,0), 100, 24);
                proceedButton.Text = "Proceed";

                Children.Add(nameLabel);
                Children.Add(proceedButton);
            }
        /// <summary>
        ///   Calculates the absolute pixel position of a rectangle in unified coordinates
        /// </summary>
        /// <param name="bounds">Bounds of the drawing area in pixels</param>
        /// <param name="destination">Destination rectangle in unified coordinates</param>
        /// <returns>
        ///   The destination rectangle converted to absolute pixel coordinates
        /// </returns>
        private static Rectangle calculateDestinationRectangle(ref RectangleF bounds, ref UniRectangle destination)
        {
            int x = (int)(bounds.X + destination.Location.X.Offset);
            x += (int)(bounds.Width * destination.Location.X.Fraction);

            int y = (int)(bounds.Y + destination.Location.Y.Offset);
            y += (int)(bounds.Height * destination.Location.Y.Fraction);

            int width = (int)(destination.Size.X.Offset);
            width += (int)(bounds.Width * destination.Size.X.Fraction);

            int height = (int)(destination.Size.Y.Offset);
            height += (int)(bounds.Height * destination.Size.Y.Fraction);

            return new Rectangle(x, y, width, height);
        }
 private void InitializeComponent()
 {
     Bounds = new UniRectangle(0, 0, 300, 80);
     EnableDragging = false;
 }
    public void TestMaxProperty() {
      UniVector minVector = new UniVector(firstTestScalar, secondTestScalar);
      UniVector maxVector = new UniVector(thirdTestScalar, fourthTestScalar);
      UniRectangle testRectangle = new UniRectangle(UniVector.Zero, minVector);

      testRectangle.Max = maxVector;

      Assert.AreEqual(UniVector.Zero, testRectangle.Min);
      Assert.AreEqual(UniVector.Zero, testRectangle.Location);

      UniAssertHelper.AreAlmostEqual(maxVector, testRectangle.Max, 4);
      UniAssertHelper.AreAlmostEqual(maxVector, testRectangle.Size, 4);
    }
 /// <summary>Checks whether another instance is equal to this instance</summary>
 /// <param name="other">Other instance to compare to this instance</param>
 /// <returns>True if the other instance is equal to this instance</returns>
 public bool Equals(UniRectangle other)
 {
     // For a struct, 'other' cannot be null
     return((this.Location == other.Location) && (this.Size == other.Size));
 }