Ejemplo n.º 1
0
        protected internal override void CreateChildControls()
        {
            ControlCollection controls = this.Controls;

            controls.Clear();
            this._title         = new TextBox();
            this._title.Columns = 30;
            controls.Add(this._title);
            TypeConverter converter = TypeDescriptor.GetConverter(typeof(PartChromeType));

            this._chromeType = new DropDownList();
            this._chromeType.Items.Add(new ListItem(System.Web.SR.GetString("PartChromeType_Default"), converter.ConvertToString(PartChromeType.Default)));
            this._chromeType.Items.Add(new ListItem(System.Web.SR.GetString("PartChromeType_TitleAndBorder"), converter.ConvertToString(PartChromeType.TitleAndBorder)));
            this._chromeType.Items.Add(new ListItem(System.Web.SR.GetString("PartChromeType_TitleOnly"), converter.ConvertToString(PartChromeType.TitleOnly)));
            this._chromeType.Items.Add(new ListItem(System.Web.SR.GetString("PartChromeType_BorderOnly"), converter.ConvertToString(PartChromeType.BorderOnly)));
            this._chromeType.Items.Add(new ListItem(System.Web.SR.GetString("PartChromeType_None"), converter.ConvertToString(PartChromeType.None)));
            controls.Add(this._chromeType);
            TypeConverter converter2 = TypeDescriptor.GetConverter(typeof(ContentDirection));

            this._direction = new DropDownList();
            this._direction.Items.Add(new ListItem(System.Web.SR.GetString("ContentDirection_NotSet"), converter2.ConvertToString(ContentDirection.NotSet)));
            this._direction.Items.Add(new ListItem(System.Web.SR.GetString("ContentDirection_LeftToRight"), converter2.ConvertToString(ContentDirection.LeftToRight)));
            this._direction.Items.Add(new ListItem(System.Web.SR.GetString("ContentDirection_RightToLeft"), converter2.ConvertToString(ContentDirection.RightToLeft)));
            controls.Add(this._direction);
            this._height = new UnitInput();
            controls.Add(this._height);
            this._width = new UnitInput();
            controls.Add(this._width);
            this._hidden = new CheckBox();
            controls.Add(this._hidden);
            foreach (Control control in controls)
            {
                control.EnableViewState = false;
            }
        }
Ejemplo n.º 2
0
            public void WithUnitAndUnitInput(Type targetType, UnitInput inputOptions, object expected)
            {
                var converter = new SpeedConverter
                {
                    Unit      = SpeedUnit.MetresPerSecond,
                    UnitInput = inputOptions
                };

                var length = Speed.FromMetresPerSecond(1.2);
                var actual = converter.Convert(length, targetType, null, CultureInfo.InvariantCulture);

                Assert.AreEqual(expected, actual);
            }
Ejemplo n.º 3
0
        protected internal override void CreateChildControls()
        {
            ControlCollection controls = Controls;

            controls.Clear();

            _title         = new TextBox();
            _title.Columns = TextBoxColumns;
            controls.Add(_title);

            TypeConverter chromeTypeConverter = TypeDescriptor.GetConverter(typeof(PartChromeType));

            _chromeType = new DropDownList();
            _chromeType.Items.Add(new ListItem(SR.GetString(SR.PartChromeType_Default),
                                               chromeTypeConverter.ConvertToString(PartChromeType.Default)));
            _chromeType.Items.Add(new ListItem(SR.GetString(SR.PartChromeType_TitleAndBorder),
                                               chromeTypeConverter.ConvertToString(PartChromeType.TitleAndBorder)));
            _chromeType.Items.Add(new ListItem(SR.GetString(SR.PartChromeType_TitleOnly),
                                               chromeTypeConverter.ConvertToString(PartChromeType.TitleOnly)));
            _chromeType.Items.Add(new ListItem(SR.GetString(SR.PartChromeType_BorderOnly),
                                               chromeTypeConverter.ConvertToString(PartChromeType.BorderOnly)));
            _chromeType.Items.Add(new ListItem(SR.GetString(SR.PartChromeType_None),
                                               chromeTypeConverter.ConvertToString(PartChromeType.None)));
            controls.Add(_chromeType);

            TypeConverter directionConverter = TypeDescriptor.GetConverter(typeof(ContentDirection));

            _direction = new DropDownList();
            _direction.Items.Add(new ListItem(SR.GetString(SR.ContentDirection_NotSet),
                                              directionConverter.ConvertToString(ContentDirection.NotSet)));
            _direction.Items.Add(new ListItem(SR.GetString(SR.ContentDirection_LeftToRight),
                                              directionConverter.ConvertToString(ContentDirection.LeftToRight)));
            _direction.Items.Add(new ListItem(SR.GetString(SR.ContentDirection_RightToLeft),
                                              directionConverter.ConvertToString(ContentDirection.RightToLeft)));
            controls.Add(_direction);

            _height = new UnitInput();
            controls.Add(_height);

            _width = new UnitInput();
            controls.Add(_width);

            _hidden = new CheckBox();
            controls.Add(_hidden);

            // We don't need viewstate enabled on our child controls.  Disable for perf.
            foreach (Control c in controls)
            {
                c.EnableViewState = false;
            }
        }
Ejemplo n.º 4
0
        public Unit MapToUnit(UnitInput input)
        {
            var output = new Unit()
            {
                Id         = input.Id,
                Damage     = input.Damage,
                Energy     = input.Energy,
                Health     = input.Health,
                Initiative = input.Initiative,
                Strategy   = _strategySelector.Get(input.MOVEMENT_STRATEGY),
                Speed      = input.Speed
            };

            return(output);
        }
Ejemplo n.º 5
0
    protected override void OnAwake()
    {
        UnitInput input = GetComponent <UnitInput> ();

        if (input == null)
        {
            input = gameObject.AddComponent <UnitInput> ();
        }
        input.motor = GetComponent <UnitMotor> ();
        CameraController cc = Camera.main.GetComponent <CameraController> ();

        if (cc != null)
        {
            cc.targetObject = this.gameObject;
        }
    }
Ejemplo n.º 6
0
        public static void WithSymbolSettings(string value, UnitInput unitInput, bool expectSuccess, string expected)
        {
            var converter = new LengthConverter
            {
                Unit      = LengthUnit.Centimetres,
                UnitInput = unitInput,
            };

            var actual = converter.ConvertBack(value, typeof(Length), null, CultureInfo.InvariantCulture);

            if (expectSuccess)
            {
                var expectedValue = Length.Parse(expected, CultureInfo.InvariantCulture);
                Assert.AreEqual(expectedValue, actual);
            }
            else
            {
                Assert.AreEqual(expected, actual);
            }
        }
Ejemplo n.º 7
0
        private void Default_SettingsLoaded(object sender, EventArgs e)
        {
            UnitInput.SetWorldUnits(true);
            UnitInput.Combobox.SelectedIndex = WorldUnits.Default[UnitTypes.Ram].Position + 1; // +1: First Image is null in the Combobox.ImageList
            World.Default.Map.Manipulators.AttackManipulator.DefaultSpeed = UnitTypes.Ram;

            VillageTypeInput.Combobox.ImageList = VillageTypeHelper.GetImageList();

            _plans.Clear();
            AttackDropDown.DropDownItems.Clear();
            ActivePlan = null;
            AllPlans.Controls.Clear();

            var plansFromXml = World.Default.Map.Manipulators.AttackManipulator.GetPlans();

            foreach (AttackPlan plan in plansFromXml)
            {
                AddPlan(plan);
            }
            if (_plans.Any())
            {
                World.Default.Map.EventPublisher.AttackSelect(this, _plans.Select(x => x.Key).First());
            }
            else
            {
                ShowHelp();
            }

            toolStrip2.Visible = _plans.Any();
            foreach (var toolbarItem in toolStrip1.Items.OfType <ToolStripItem>().Where(x => x.Tag == null || x.Tag.ToString() != "OWN_VISIBILITY"))
            {
                if (_plans.Any())
                {
                    toolbarItem.Visible = true;
                }
                else
                {
                    toolbarItem.Visible = _visibleWhenNoPlans.Contains(toolbarItem);
                }
            }
        }
 protected internal override void CreateChildControls()
 {
     ControlCollection controls = this.Controls;
     controls.Clear();
     this._title = new TextBox();
     this._title.Columns = 30;
     controls.Add(this._title);
     TypeConverter converter = TypeDescriptor.GetConverter(typeof(PartChromeType));
     this._chromeType = new DropDownList();
     this._chromeType.Items.Add(new ListItem(System.Web.SR.GetString("PartChromeType_Default"), converter.ConvertToString(PartChromeType.Default)));
     this._chromeType.Items.Add(new ListItem(System.Web.SR.GetString("PartChromeType_TitleAndBorder"), converter.ConvertToString(PartChromeType.TitleAndBorder)));
     this._chromeType.Items.Add(new ListItem(System.Web.SR.GetString("PartChromeType_TitleOnly"), converter.ConvertToString(PartChromeType.TitleOnly)));
     this._chromeType.Items.Add(new ListItem(System.Web.SR.GetString("PartChromeType_BorderOnly"), converter.ConvertToString(PartChromeType.BorderOnly)));
     this._chromeType.Items.Add(new ListItem(System.Web.SR.GetString("PartChromeType_None"), converter.ConvertToString(PartChromeType.None)));
     controls.Add(this._chromeType);
     TypeConverter converter2 = TypeDescriptor.GetConverter(typeof(ContentDirection));
     this._direction = new DropDownList();
     this._direction.Items.Add(new ListItem(System.Web.SR.GetString("ContentDirection_NotSet"), converter2.ConvertToString(ContentDirection.NotSet)));
     this._direction.Items.Add(new ListItem(System.Web.SR.GetString("ContentDirection_LeftToRight"), converter2.ConvertToString(ContentDirection.LeftToRight)));
     this._direction.Items.Add(new ListItem(System.Web.SR.GetString("ContentDirection_RightToLeft"), converter2.ConvertToString(ContentDirection.RightToLeft)));
     controls.Add(this._direction);
     this._height = new UnitInput();
     controls.Add(this._height);
     this._width = new UnitInput();
     controls.Add(this._width);
     this._hidden = new CheckBox();
     controls.Add(this._hidden);
     foreach (Control control in controls)
     {
         control.EnableViewState = false;
     }
 }
        protected internal override void CreateChildControls() {
            ControlCollection controls = Controls;
            controls.Clear();

            _title = new TextBox();
            _title.Columns = TextBoxColumns;
            controls.Add(_title);

            TypeConverter chromeTypeConverter = TypeDescriptor.GetConverter(typeof(PartChromeType));
            _chromeType = new DropDownList();
            _chromeType.Items.Add(new ListItem(SR.GetString(SR.PartChromeType_Default),
                                              chromeTypeConverter.ConvertToString(PartChromeType.Default)));
            _chromeType.Items.Add(new ListItem(SR.GetString(SR.PartChromeType_TitleAndBorder),
                                              chromeTypeConverter.ConvertToString(PartChromeType.TitleAndBorder)));
            _chromeType.Items.Add(new ListItem(SR.GetString(SR.PartChromeType_TitleOnly),
                                              chromeTypeConverter.ConvertToString(PartChromeType.TitleOnly)));
            _chromeType.Items.Add(new ListItem(SR.GetString(SR.PartChromeType_BorderOnly),
                                              chromeTypeConverter.ConvertToString(PartChromeType.BorderOnly)));
            _chromeType.Items.Add(new ListItem(SR.GetString(SR.PartChromeType_None),
                                              chromeTypeConverter.ConvertToString(PartChromeType.None)));
            controls.Add(_chromeType);

            TypeConverter directionConverter = TypeDescriptor.GetConverter(typeof(ContentDirection));
            _direction = new DropDownList();
            _direction.Items.Add(new ListItem(SR.GetString(SR.ContentDirection_NotSet),
                                              directionConverter.ConvertToString(ContentDirection.NotSet)));
            _direction.Items.Add(new ListItem(SR.GetString(SR.ContentDirection_LeftToRight),
                                              directionConverter.ConvertToString(ContentDirection.LeftToRight)));
            _direction.Items.Add(new ListItem(SR.GetString(SR.ContentDirection_RightToLeft),
                                              directionConverter.ConvertToString(ContentDirection.RightToLeft)));
            controls.Add(_direction);

            _height = new UnitInput();
            controls.Add(_height);

            _width = new UnitInput();
            controls.Add(_width);

            _hidden = new CheckBox();
            controls.Add(_hidden);

            // We don't need viewstate enabled on our child controls.  Disable for perf.
            foreach (Control c in controls) {
                c.EnableViewState = false;
            }
        }