Ejemplo n.º 1
0
        public void EditValue_WithCurrentItemInAvailableItems_ReturnsCurrentItem()
        {
            // Setup
            var simpleStructure = new TestStructure();
            var properties      = new ObjectPropertiesWithStructure(simpleStructure, new[]
            {
                simpleStructure
            });
            var propertyBag       = new DynamicPropertyBag(properties);
            var editor            = new StructureEditor <TestStructure>();
            var someValue         = new object();
            var serviceProvider   = mockRepository.Stub <IServiceProvider>();
            var service           = mockRepository.Stub <IWindowsFormsEditorService>();
            var descriptorContext = mockRepository.Stub <ITypeDescriptorContext>();

            serviceProvider.Stub(p => p.GetService(null)).IgnoreArguments().Return(service);
            descriptorContext.Stub(c => c.Instance).Return(propertyBag);
            mockRepository.ReplayAll();

            // Call
            object result = editor.EditValue(descriptorContext, serviceProvider, someValue);

            // Assert
            Assert.AreSame(simpleStructure, result);
            mockRepository.VerifyAll();
        }
Ejemplo n.º 2
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            Rectangle effectiveBounds = GetEffectiveBounds();

            if (effectiveBounds.IsEmpty)
            {
                return;
            }

            if (selected)
            {
                Rectangle effectiveOutline = Rectangle.Intersect(outlineRect, parent.GetEffectiveBounds());
                spriteBatch.Draw(pixel, effectiveOutline, effectiveOutline, outlineColor);
                spriteBatch.Draw(pixel, effectiveBounds, backgroundColor);
            }

            Rectangle effectiveBlock = new Rectangle(effectiveBounds.Location - bounds.Location, effectiveBounds.Size);

            block.DrawSimple(spriteBatch, ConvertUtils.PointToVector2(bounds.Location), scale, effectiveBlock);


            if (hovered)
            {
                StructureEditor.SetTooltip(block.displayName);
            }
        }
Ejemplo n.º 3
0
        public void DefaultConstructor_ReturnsNewInstance()
        {
            // Call
            var editor = new StructureEditor <TestStructure>();

            // Assert
            Assert.IsInstanceOf <SelectionEditor <IHasStructureProperty <TestStructure>, TestStructure> >(editor);
        }