public void HudPlayerIconViewModelToolCanBeSerializedDeserializedWithProtobuf()
        {
            var hudLayoutToolExpected = new HudLayoutPlayerIconTool();

            var hudElement = new HudElementViewModel
            {
                Seat = 1,
            };

            var hudToolViewModelExpected = hudLayoutToolExpected.CreateViewModel(hudElement) as HudPlayerIconViewModel;

            hudToolViewModelExpected.Width    = 100;
            hudToolViewModelExpected.Height   = 75;
            hudToolViewModelExpected.Position = new System.Windows.Point(5, 5);
            hudToolViewModelExpected.Opacity  = 60;

            Assert.IsNotNull(hudToolViewModelExpected);

            var hudToolViewModelActual = SerializerHelper.GetSerializedDeserializedObject(hudToolViewModelExpected);

            Assert.That(hudToolViewModelActual.Id, Is.EqualTo(hudToolViewModelExpected.Id));
            Assert.That(hudToolViewModelActual.ToolType, Is.EqualTo(hudToolViewModelExpected.ToolType));
            Assert.That(hudToolViewModelActual.Width, Is.EqualTo(hudToolViewModelExpected.Width));
            Assert.That(hudToolViewModelActual.Height, Is.EqualTo(hudToolViewModelExpected.Height));
            Assert.That(hudToolViewModelActual.Position, Is.EqualTo(hudToolViewModelExpected.Position));
            Assert.That(hudToolViewModelActual.Opacity, Is.EqualTo(hudToolViewModelExpected.Opacity));
        }
Beispiel #2
0
        /// <summary>
        /// Creates player icon view model
        /// </summary>
        /// <param name="creationInfo"><see cref="HudToolCreationInfo"/></param>
        /// <returns>Player icon view model</returns>
        private HudBaseToolViewModel CreatePlayerIconTool(HudToolCreationInfo creationInfo)
        {
            Check.Require(creationInfo.Layout != null, "Layout isn't defined. 4-stat box has not been created.");

            var layoutTool = new HudLayoutPlayerIconTool
            {
                UIPositions = GetHudUIPositions(EnumTableType.HU, EnumTableType.HU, creationInfo.Position)
            };

            layoutTool.UIPositions.ForEach(x =>
            {
                x.Width  = HudDefaultSettings.PlayerIconWidth;
                x.Height = HudDefaultSettings.PlayerIconHeight;
            });

            var toolViewModel = layoutTool.CreateViewModel(creationInfo.HudElement);

            toolViewModel.InitializePositions();

            creationInfo.Layout.LayoutTools.Add(layoutTool);

            return(toolViewModel);
        }