/// <summary>
 /// Constructor to initialise a new instance of the class
 /// </summary>
 /// <param name="numericUpDownControl">The numericUpDownControl object to map</param>
 /// <param name="propName">The property name</param>
 /// <param name="isReadOnly">Whether this control is read only</param>
 /// <param name="factory">the control factory to be used when creating the controlMapperStrategy</param>
 public NumericUpDownIntegerMapper(INumericUpDown numericUpDownControl, string propName, bool isReadOnly, IControlFactory factory)
     : base(numericUpDownControl, propName, isReadOnly, factory)
 {
     _numericUpDown.DecimalPlaces = 0;
     _numericUpDown.Maximum       = int.MaxValue;
     _numericUpDown.Minimum       = int.MinValue;
 }
 /// <summary>
 /// Constructor to initialise a new instance of the class
 /// </summary>
 /// <param name="numericUpDownControl">The numericUpDownControl object to map</param>
 /// <param name="propName">The property name</param>
 /// <param name="isReadOnly">Whether this control is read only</param>
 /// <param name="factory">the control factory to be used when creating the controlMapperStrategy</param>
 public NumericUpDownCurrencyMapper(INumericUpDown numericUpDownControl, string propName, bool isReadOnly, IControlFactory factory)
     : base(numericUpDownControl, propName, isReadOnly, factory)
 {
     _numericUpDown.DecimalPlaces = 2;
     _numericUpDown.Maximum = decimal.MaxValue;
     _numericUpDown.Minimum = decimal.MinValue;
 }
 /// <summary>
 /// Constructor to instantiate a new instance of the class
 /// </summary>
 /// <param name="ctl">The control object to map</param>
 /// <param name="propName">The property name</param>
 /// <param name="isReadOnly">Whether the control is read only.
 /// If so, it then becomes disabled.  If not,
 /// handlers are assigned to manage key presses, depending on the strategy assigned to this mapper.</param>
 /// <param name="factory">The control factory to be used when creating the controlMapperStrategy</param>
 protected NumericUpDownMapper(INumericUpDown ctl, string propName, bool isReadOnly, IControlFactory factory)
     : base(ctl, propName, isReadOnly, factory)
 {
     _numericUpDown = (INumericUpDown)ctl;
     _mapperStrategy = factory.CreateNumericUpDownMapperStrategy();
     _mapperStrategy.ValueChanged(this);
 }
 /// <summary>
 /// Constructor to instantiate a new instance of the class
 /// </summary>
 /// <param name="ctl">The control object to map</param>
 /// <param name="propName">The property name</param>
 /// <param name="isReadOnly">Whether the control is read only.
 /// If so, it then becomes disabled.  If not,
 /// handlers are assigned to manage key presses, depending on the strategy assigned to this mapper.</param>
 /// <param name="factory">The control factory to be used when creating the controlMapperStrategy</param>
 protected NumericUpDownMapper(INumericUpDown ctl, string propName, bool isReadOnly, IControlFactory factory)
     : base(ctl, propName, isReadOnly, factory)
 {
     _numericUpDown  = (INumericUpDown)ctl;
     _mapperStrategy = factory.CreateNumericUpDownMapperStrategy();
     _mapperStrategy.ValueChanged(this);
 }
Example #5
0
        public void Test_defaultTextAlignment()
        {
            //---------------Set up test pack-------------------

            //---------------Execute Test ----------------------
            INumericUpDown numericUpDown = GetControlFactory().CreateNumericUpDown();

            //---------------Test Result -----------------------
            Assert.AreEqual(HorizontalAlignment.Left, numericUpDown.TextAlign);
            //---------------Tear Down -------------------------
        }
Example #6
0
        public void Test_setTextAlignment_Right()
        {
            //---------------Set up test pack-------------------
            INumericUpDown textBox = GetControlFactory().CreateNumericUpDown();

            DisposeOnTearDown(textBox);
            //---------------Execute Test ----------------------
            textBox.TextAlign = HorizontalAlignment.Right;
            //---------------Test Result -----------------------
            Assert.AreEqual(HorizontalAlignment.Right, textBox.TextAlign);
            //---------------Tear Down -------------------------
        }
        public void TestSetBusinessObject()
        {
            //---------------Set up test pack-------------------
            INumericUpDown             numUpDown = GetControlFactory().CreateNumericUpDownInteger();
            NumericUpDownIntegerMapper mapper    = new NumericUpDownIntegerMapper(numUpDown, INT_PROP_NAME, false, GetControlFactory());
            Sample s = new Sample();

            s.SampleInt = 100;
            //---------------Execute Test ----------------------
            mapper.BusinessObject = s;
            //---------------Test Result -----------------------
            Assert.AreEqual(100, numUpDown.Value, "Value is not set.");

            //---------------Tear Down -------------------------
        }
        public void TestConstructor()
        {
            //---------------Set up test pack-------------------
            INumericUpDown numUpDown = GetControlFactory().CreateNumericUpDownInteger();
            //---------------Execute Test ----------------------
            NumericUpDownIntegerMapper mapper = new NumericUpDownIntegerMapper(numUpDown, INT_PROP_NAME, false, GetControlFactory());

            //---------------Test Result -----------------------
            Assert.AreSame(numUpDown, mapper.Control);
            Assert.AreSame(INT_PROP_NAME, mapper.PropertyName);
            Assert.AreEqual(0, numUpDown.DecimalPlaces);
            Assert.AreEqual(int.MinValue, numUpDown.Minimum);
            Assert.AreEqual(int.MaxValue, numUpDown.Maximum);

            //---------------Tear Down -------------------------
        }
Example #9
0
        public MainPresenter(IMainWindow <T> view, INumericUpDown numericUpDown, IFileManager <T> manager, IMessageService messageService)
        {
            _view           = view;
            _manager        = manager;
            _messageService = messageService;
            _numericUpDown  = numericUpDown;

            _view.SetSymbolsCount(0);
            _view.ContentChanged += _view_ContentChanged;
            _view.FileOpenClick  += _view_FileOpenClick;
            _view.FileSaveClick  += _view_FileSaveClick;

            _numericUpDown.NumValue           = _numValue = _defaultNum;
            _numericUpDown.btnUpClick        += btnUp_Click;
            _numericUpDown.btnDownClick      += btnDown_Click;
            _numericUpDown.txtNumTextChanged += txtNum_TextChanged;
        }
Example #10
0
        public void TestSetBusinessObject()
        {
            //---------------Set up test pack-------------------
            INumericUpDown numUpDown           = GetControlFactory().CreateNumericUpDownCurrency();
            NumericUpDownCurrencyMapper mapper =
                new NumericUpDownCurrencyMapper(numUpDown, CURRENCY_PROP_NAME, false, GetControlFactory());
            Sample  s   = new Sample();
            decimal val = 100.5m;

            s.SampleMoney = val;
            //---------------Execute Test ----------------------
            mapper.BusinessObject = s;
            //---------------Test Result -----------------------
            Assert.AreEqual(val, numUpDown.Value, "Value is not set.");

            //---------------Tear Down -------------------------
        }
Example #11
0
        public void Test_BusinessObjectChanged_UpdatesControl()
        {
            //---------------Set up test pack-------------------
            INumericUpDown             numUpDown = GetControlFactory().CreateNumericUpDownInteger();
            NumericUpDownIntegerMapper mapper    = new NumericUpDownIntegerMapper(numUpDown, INT_PROP_NAME, false, GetControlFactory());
            Sample s = new Sample();

            s.SampleInt           = 100;
            mapper.BusinessObject = s;
            //---------------Execute Test ----------------------
            int newValue = 555;

            s.SampleInt = newValue;
            //---------------Test Result -----------------------
            Assert.AreEqual(newValue, numUpDown.Value);
            //---------------Tear down -------------------------
        }
Example #12
0
        public void Test_ValueChangedEvent_UpdatesBusinessObject()
        {
            //---------------Set up test pack-------------------
            INumericUpDown             numUpDown = GetControlFactory().CreateNumericUpDownInteger();
            NumericUpDownIntegerMapper mapper    = new NumericUpDownIntegerMapper(numUpDown, INT_PROP_NAME, false, GetControlFactory());
            Sample s = new Sample();

            s.SampleInt           = 100;
            mapper.BusinessObject = s;
            //---------------Execute Test ----------------------
            int newValue = 555;

            numUpDown.Value = newValue;
            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(NumericUpDownMapperStrategyWin), mapper.MapperStrategy);
            Assert.AreEqual(newValue, s.SampleInt);
            //---------------Tear down -------------------------
        }
Example #13
0
        public void Test_BusinessObjectChanged_UpdatesControl()
        {
            //---------------Set up test pack-------------------
            INumericUpDown numUpDown           = GetControlFactory().CreateNumericUpDownInteger();
            NumericUpDownCurrencyMapper mapper =
                new NumericUpDownCurrencyMapper(numUpDown, CURRENCY_PROP_NAME, false, GetControlFactory());
            Sample s = new Sample();

            s.SampleMoney         = 100.10m;
            mapper.BusinessObject = s;
            //---------------Execute Test ----------------------
            decimal newValue = 555.45m;

            s.SampleMoney = newValue;
            //---------------Test Result -----------------------
            Assert.AreEqual(newValue, numUpDown.Value);
            //---------------Tear down -------------------------
        }
Example #14
0
        public void Test_ValueChangedEvent_UpdatesBusinessObject()
        {
            //---------------Set up test pack-------------------
            INumericUpDown numUpDown           = GetControlFactory().CreateNumericUpDownCurrency();
            NumericUpDownCurrencyMapper mapper =
                new NumericUpDownCurrencyMapper(numUpDown, CURRENCY_PROP_NAME, false, GetControlFactory());
            Sample s = new Sample();

            s.SampleMoney         = 100.10m;
            mapper.BusinessObject = s;
            //---------------Execute Test ----------------------
            decimal newValue = 555.45m;

            numUpDown.Value = newValue;
            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(NumericUpDownMapperStrategyWin), mapper.MapperStrategy);
            Assert.AreEqual(newValue, s.SampleMoney);
            //---------------Tear down -------------------------
        }
        public void Test_BuildPanelForTab_Parameter_SetAlignment_NumericUpDown()
        {
            //---------------Set up test pack-------------------
            Sample.SampleUserInterfaceMapper interfaceMapper = GetSampleUserInterfaceMapper();
            UIFormTab singleFieldTab = interfaceMapper.GetFormTabOneFieldsWithNumericUpDown();

            Habanero.Faces.Base.PanelBuilder panelBuilder = CreatePanelBuilder();
            //---------------Assert Precondition----------------
            Assert.AreEqual("right", ((UIFormField)singleFieldTab[0][0]).Alignment);

            //---------------Execute Test ----------------------
            IPanel panel = panelBuilder.BuildPanelForTab(singleFieldTab).Panel;

            //---------------Test Result -----------------------

            Assert.IsInstanceOf(typeof(INumericUpDown), panel.Controls[1]);
            INumericUpDown control = (INumericUpDown)panel.Controls[1];

            Assert.AreEqual(HorizontalAlignment.Right, control.TextAlign);
        }
        public void Test_BuildPanelForTab_Parameter_SetNumericUpDownAlignment()
        {
            //---------------Set up test pack-------------------
            Sample.SampleUserInterfaceMapper interfaceMapper = GetSampleUserInterfaceMapper();
            UIFormTab singleFieldTab = interfaceMapper.GetFormTabOneFieldsWithAlignment_NumericUpDown();

            Habanero.Faces.Base.PanelBuilder panelBuilder = CreatePanelBuilder();
            //---------------Assert Precondition----------------
            Assert.AreEqual("left", ((UIFormField)singleFieldTab[0][0]).Alignment);
            Assert.AreEqual("right", ((UIFormField)singleFieldTab[0][1]).Alignment);
            Assert.AreEqual("center", ((UIFormField)singleFieldTab[0][2]).Alignment);
            Assert.AreEqual("centre", ((UIFormField)singleFieldTab[0][3]).Alignment);
            //---------------Execute Test ----------------------
            IPanel panel = panelBuilder.BuildPanelForTab(singleFieldTab).Panel;

            //---------------Test Result -----------------------

            Assert.IsInstanceOf(typeof(INumericUpDown), panel.Controls[1]);
            INumericUpDown control1 = (INumericUpDown)panel.Controls[1];

            Assert.AreEqual(HorizontalAlignment.Left, control1.TextAlign);

            Assert.IsInstanceOf(typeof(INumericUpDown), panel.Controls[Habanero.Faces.Base.PanelBuilder.CONTROLS_PER_COLUMN + 1]);
            INumericUpDown control2 = (INumericUpDown)panel.Controls[Habanero.Faces.Base.PanelBuilder.CONTROLS_PER_COLUMN + 1];

            Assert.AreEqual(HorizontalAlignment.Right, control2.TextAlign);

            Assert.IsInstanceOf(typeof(INumericUpDown), panel.Controls[Habanero.Faces.Base.PanelBuilder.CONTROLS_PER_COLUMN * 2 + 1]);
            INumericUpDown control3 = (INumericUpDown)panel.Controls[Habanero.Faces.Base.PanelBuilder.CONTROLS_PER_COLUMN * 2 + 1];

            Assert.AreEqual(HorizontalAlignment.Center, control3.TextAlign);

            Assert.IsInstanceOf(typeof(INumericUpDown), panel.Controls[Habanero.Faces.Base.PanelBuilder.CONTROLS_PER_COLUMN * 3 + 1]);
            INumericUpDown control4 = (INumericUpDown)panel.Controls[Habanero.Faces.Base.PanelBuilder.CONTROLS_PER_COLUMN * 3 + 1];

            Assert.AreEqual(HorizontalAlignment.Center, control4.TextAlign);
        }
Example #17
0
		protected NumericUpDown (Generator generator, Type type, bool initialize = true)
			: base (generator, type, initialize)
		{
			handler = (INumericUpDown)base.Handler;
		}
Example #18
0
 public NumericUpDownMapperStub(INumericUpDown ctl)
     : base(ctl, "Fdaf", false, new ControlFactoryWin())
 {
 }
 public NumericUpDownMapperStub(INumericUpDown ctl) 
     : base(ctl, "Fdaf", false, new ControlFactoryWin())
 {
 }
Example #20
0
 protected NumericUpDown(Generator generator, Type type, bool initialize = true)
     : base(generator, type, initialize)
 {
     handler = (INumericUpDown)base.Handler;
 }
Example #21
0
 public NumericUpDown(Generator g)
     : base(g, typeof(INumericUpDown))
 {
     inner = (INumericUpDown)base.Handler;
 }