Exemplo n.º 1
0
        public void TestCopyTo()
        {
            UIGridColumn column1 = new UIGridColumn("heading", null, null, null, false,
                100, PropAlignment.left, null);
            UIGridColumn column2 = new UIGridColumn("heading", null, null, null, false,
                100, PropAlignment.left, null);
            UIGrid uiGrid = new UIGrid();
            uiGrid.Add(column1);
            uiGrid.Add(column2);

            UIGridColumn[] target = new UIGridColumn[2];
            uiGrid.CopyTo(target, 0);
            Assert.AreEqual(column1, target[0]);
            Assert.AreEqual(column2, target[1]);
        }
Exemplo n.º 2
0
        public void Open()
        {
            selectedItem   = null;
            selectedModule = null;

            gridItems.Clear();

            foreach (Item item in InventoryUtility.InvArmorEquips(Main.LocalPlayer))
            {
                if (item.IsAir)
                {
                    continue;
                }

                if (item.ModItem is ModularItem modularItem)
                {
                    UIModularItem uiModularItem = new UIModularItem(modularItem)
                    {
                        Width  = { Pixels = 48 },
                        Height = { Pixels = 48 }
                    };
                    uiModularItem.OnClick += args =>
                    {
                        args.Handled = true;

                        OpenItem(modularItem);
                    };

                    gridItems.Add(uiModularItem);
                }
            }
        }
Exemplo n.º 3
0
        public void PopulateGrid()
        {
            gridLocations.Clear();

            foreach (EntryPoint entryPoint in TerraFirma.Instance.TubeNetworkLayer[Container.Position].Network.GetEntryPoints())
            {
                if (entryPoint == Container)
                {
                    continue;
                }

                UIEntryPointItem entryPointItem = new UIEntryPointItem(entryPoint)
                {
                    Width  = (0, 1),
                    Height = (60, 0)
                };
                entryPointItem.OnClick += (evt, element) =>
                {
                    TubularNetwork  network = TerraFirma.Instance.TubeNetworkLayer[Container.Position].Network;
                    Stack <Point16> path    = Pathfinding.FindPath(network.Tiles, Container.Position, entryPoint.Position);

                    TransportingPlayer transfer = new TransportingPlayer(Main.LocalPlayer, path);

                    network.TransportingPlayers.Add(transfer);

                    BaseLibrary.BaseLibrary.PanelGUI.UI.CloseUI(Container);
                };
                gridLocations.Add(entryPointItem);
            }
        }
Exemplo n.º 4
0
        public GardenerSatchelPanel(GardenerSatchel bag) : base(bag)
        {
            Width.Pixels  = 12 + (SlotSize + SlotMargin) * 9;
            Height.Pixels = 44 + SlotSize;

            UIGrid <UIGardenerSatchelSlot> gridItems = new UIGrid <UIGardenerSatchelSlot>(9)
            {
                Width      = { Percent = 100 },
                Height     = { Pixels = -28, Percent = 100 },
                Y          = { Pixels = 28 },
                ItemMargin = SlotMargin
            };

            Add(gridItems);

            for (int i = 0; i < Container.Handler.Slots; i++)
            {
                UIGardenerSatchelSlot slot = new UIGardenerSatchelSlot(Container, i)
                {
                    Width  = { Pixels = SlotSize },
                    Height = { Pixels = SlotSize }
                };
                gridItems.Add(slot);
            }
        }
Exemplo n.º 5
0
        private void OpenItem(ModularItem item)
        {
            selectedItem = item;

            gridModules.Clear();

            foreach (int type in ModuleLoader.validModulesForItem[item.Type])
            {
                BaseModule module = ModuleLoader.GetModule(type);

                UIModule uiModule = new UIModule(module)
                {
                    Color  = item.IsInstalled(module.Type) ? Color.LimeGreen : Color.Red,
                    Width  = { Percent = 100 },
                    Height = { Pixels = 64 }
                };
                uiModule.OnClick += args =>
                {
                    args.Handled = true;

                    OpenModule(module);
                };
                gridModules.Add(uiModule);
            }
        }
Exemplo n.º 6
0
        public void TestCopyTo()
        {
            UIGridColumn column1 = new UIGridColumn("heading", null, null, null, false,
                                                    100, PropAlignment.left, null);
            UIGridColumn column2 = new UIGridColumn("heading", null, null, null, false,
                                                    100, PropAlignment.left, null);
            UIGrid uiGrid = new UIGrid();

            uiGrid.Add(column1);
            uiGrid.Add(column2);

            UIGridColumn[] target = new UIGridColumn[2];
            uiGrid.CopyTo(target, 0);
            Assert.AreEqual(column1, target[0]);
            Assert.AreEqual(column2, target[1]);
        }
        public NinjaArsenalBeltPanel(NinjaArsenalBelt bag) : base(bag)
        {
            Width.Pixels  = 12 + (SlotSize + SlotMargin) * 9;
            Height.Pixels = 40 + (SlotSize + SlotMargin) * Container.Handler.Slots / 9;


            UIGrid <UIContainerSlot> gridItems = new UIGrid <UIContainerSlot>(9)
            {
                Width      = { Percent = 100 },
                Height     = { Pixels = -28, Percent = 100 },
                Y          = { Pixels = 28 },
                ItemMargin = SlotMargin
            };

            Add(gridItems);

            for (int i = 0; i < Container.Handler.Slots; i++)
            {
                UIContainerSlot slot = new UIContainerSlot(() => Container.Handler, i)
                {
                    Width = { Pixels = SlotSize }, Height = { Pixels = SlotSize }
                };
                gridItems.Add(slot);
            }
        }
        public BuilderReservePanel(BuilderReserve bag) : base(bag)
        {
            Width.Pixels  = 12 + (SlotSize + SlotMargin) * 9;
            Height.Pixels = 40 + (SlotSize + SlotMargin) * Container.Handler.Slots / 9;

            UIGrid <UIBuilderReserveSlot> gridItems = new UIGrid <UIBuilderReserveSlot>(9)
            {
                Width      = { Percent = 100 },
                Height     = { Pixels = -28, Percent = 100 },
                Y          = { Pixels = 28 },
                ItemMargin = SlotMargin
            };

            Add(gridItems);

            for (int i = 0; i < Container.Handler.Slots; i++)
            {
                UIBuilderReserveSlot slot = new UIBuilderReserveSlot(Container, i)
                {
                    Width  = { Pixels = SlotSize },
                    Height = { Pixels = SlotSize }
                };
                gridItems.Add(slot);
            }
        }
Exemplo n.º 9
0
        public override void OnInitialize()
        {
            Elements.Clear();
            grid.Clear();

            grid.Left.Set(-220, 0.5f);
            grid.Top.Set(-220, 0.5f);
            grid.Width.Set(440, 0);
            grid.Height.Set(440, 0);
            grid.ListPadding = 4;
            grid.MaxWidth.Set(440, 0);
            grid.MaxHeight.Set(440, 0);

            Append(grid);

            if (openBag is null)
            {
                return;
            }

            for (int k = 0; k < openBag.items.Count; k++)
            {
                grid.Add(new IngredientStorageSlot(openBag.items[k], k));
            }
        }
Exemplo n.º 10
0
    public AmmoBagPanel(BaseAmmoBag bag) : base(bag)
    {
        Width.Pixels  = 12 + (SlotSize + SlotMargin) * 9;
        Height.Pixels = 40 + (SlotSize + SlotMargin) * Container.GetItemStorage().Count / 9;

        UIGrid <UIContainerSlot> gridItems = new UIGrid <UIContainerSlot>(9)
        {
            Width    = { Percent = 100 },
            Height   = { Pixels = -28, Percent = 100 },
            Y        = { Pixels = 28 },
            Settings = { ItemMargin = SlotMargin }
        };

        Add(gridItems);

        for (int i = 0; i < Container.GetItemStorage().Count; i++)
        {
            UIContainerSlot slot = new UIContainerSlot(Container.GetItemStorage(), i)
            {
                Width  = { Pixels = SlotSize },
                Height = { Pixels = SlotSize }
            };
            gridItems.Add(slot);
        }
    }
    public AlchemistBagPanel(AlchemistBag bag) : base(bag)
    {
        Width.Pixels  = 12 + (SlotSize + SlotMargin) * 9;
        Height.Pixels = 100 + (SlotSize + SlotMargin) * Container.GetItemStorage().Count / 9;

        UIText textPotions = new UIText("Potions")
        {
            Y = { Pixels = 28 }
        };

        Add(textPotions);

        UIGrid <UIContainerSlot> gridItems = new UIGrid <UIContainerSlot>(9)
        {
            Width    = { Percent = 100 },
            Height   = { Pixels = SlotSize * 2 + SlotMargin },
            Y        = { Pixels = 56 },
            Settings = { ItemMargin = SlotMargin }
        };

        Add(gridItems);

        for (int i = 0; i < AlchemistBag.PotionSlots; i++)
        {
            UIContainerSlot slot = new UIContainerSlot(Container.GetItemStorage(), i)
            {
                Width  = { Pixels = SlotSize },
                Height = { Pixels = SlotSize }
            };
            gridItems.Add(slot);
        }

        UIText textIngredients = new UIText("Ingredients")
        {
            Y = { Pixels = 56 + 8 + SlotSize * 2 + SlotMargin }
        };

        Add(textIngredients);

        UIGrid <UIContainerSlot> gridIngredients = new UIGrid <UIContainerSlot>(9)
        {
            Width    = { Percent = 100 },
            Height   = { Pixels = (SlotSize + SlotMargin) * 7 - SlotMargin },
            Y        = { Pixels = 56 + 8 + 20 + 8 + SlotSize * 2 + SlotMargin },
            Settings = { ItemMargin = SlotMargin }
        };

        Add(gridIngredients);

        for (int i = AlchemistBag.PotionSlots; i < AlchemistBag.PotionSlots + AlchemistBag.IngredientSlots; i++)
        {
            UIContainerSlot slot = new UIContainerSlot(Container.GetItemStorage(), i)
            {
                Width  = { Pixels = SlotSize },
                Height = { Pixels = SlotSize }
            };
            gridIngredients.Add(slot);
        }
    }
Exemplo n.º 12
0
 public override void Load()
 {
     for (int i = 0; i < qeChest.GetItems().Count; i++)
     {
         UIContainerSlot slot = new UIContainerSlot(qeChest, i);
         gridItems.Add(slot);
     }
 }
Exemplo n.º 13
0
 public override void Load()
 {
     for (int i = 1; i < barrel.Items.Count; i++)
     {
         UIContainerSlot slot = new UIContainerSlot(barrel, i);
         slot.CanInteract += (item, mouseItem) => (mouseItem.IsAir || mouseItem.modItem is BaseUpgrade) && (!(item.modItem is StackUpgrade) || barrel.Items[0].stack <= barrel.maxStoredItems - ((StackUpgrade)item.modItem).stackInc * TEBarrel.BaseMax);
         items.Add(slot);
     }
 }
Exemplo n.º 14
0
        public AlchemistBagPanel(AlchemistBag bag) : base(bag)
        {
            Width.Pixels  = 12 + (SlotSize + SlotMargin) * 9;
            Height.Pixels = 100 + (SlotSize + SlotMargin) * Container.Handler.Slots / 9;

            UIText textPotions = new UIText("Potions")
            {
                Y = { Pixels = 28 }
            };

            Add(textPotions);

            UIGrid <UIContainerSlot> gridItems = new UIGrid <UIContainerSlot>(9)
            {
                Width      = { Percent = 100 },
                Height     = { Pixels = SlotSize * 2 + SlotMargin },
                Y          = { Pixels = 56 },
                ItemMargin = SlotMargin
            };

            Add(gridItems);

            for (int i = 0; i < 18; i++)
            {
                UIContainerSlot slot = new UIContainerSlot(() => Container.Handler, i)
                {
                    Width = { Pixels = SlotSize }, Height = { Pixels = SlotSize }
                };
                gridItems.Add(slot);
            }

            UIText textIngredients = new UIText("Ingredients")
            {
                Y = { Pixels = 56 + 8 + SlotSize * 2 + SlotMargin }
            };

            Add(textIngredients);

            UIGrid <UIContainerSlot> gridIngredients = new UIGrid <UIContainerSlot>(9)
            {
                Width      = { Percent = 100 },
                Height     = { Pixels = (SlotSize + SlotMargin) * 7 - SlotMargin },
                Y          = { Pixels = 56 + 8 + 20 + 8 + SlotSize * 2 + SlotMargin },
                ItemMargin = SlotMargin
            };

            Add(gridIngredients);

            for (int i = 18; i < 81; i++)
            {
                UIContainerSlot slot = new UIContainerSlot(() => Container.Handler, i)
                {
                    Width = { Pixels = SlotSize }, Height = { Pixels = SlotSize }
                };
                gridIngredients.Add(slot);
            }
        }
Exemplo n.º 15
0
        public void Load(VacuumBag bag)
        {
            guid = bag.guid;

            for (int i = 0; i < bag.GetItems().Count; i++)
            {
                UIContainerSlot slot = new UIContainerSlot(bag, i);
                gridItems.Add(slot);
            }
        }
Exemplo n.º 16
0
        public void Test_Indexer_FindBy_PropertyName_DoesntExistReturnsNull()
        {
            //---------------Set up test pack-------------------
            UIGrid       uiGrid       = new UIGrid();
            UIGridColumn uiGridColumn = GetUiGridColumn();

            uiGrid.Add(uiGridColumn);
            UIGridColumn uiGridColumn2 = GetUiGridColumn("Diff Prop Name");

            uiGrid.Add(uiGridColumn2);

            //--------------Assert PreConditions----------------
            Assert.AreEqual(2, uiGrid.Count);
            //---------------Execute Test ----------------------
            IUIGridColumn column = uiGrid["nonexistent property"];

            //---------------Test Result -----------------------
            Assert.IsNull(column);
        }
Exemplo n.º 17
0
        public void Test_Indexer_FindBy_PropertyName()
        {
            //---------------Set up test pack-------------------
            UIGrid       uiGrid       = new UIGrid();
            UIGridColumn uiGridColumn = GetUiGridColumn();

            uiGrid.Add(uiGridColumn);
            UIGridColumn uiGridColumn2 = GetUiGridColumn("Diff Prop Name");

            uiGrid.Add(uiGridColumn2);

            //--------------Assert PreConditions----------------
            Assert.AreEqual(2, uiGrid.Count);
            //---------------Execute Test ----------------------
            IUIGridColumn column = uiGrid[uiGridColumn2.PropertyName];

            //---------------Test Result -----------------------
            Assert.AreEqual(uiGridColumn2, column);
        }
Exemplo n.º 18
0
        public void Load(Bag bag)
        {
            this.bag = bag;

            for (int i = 0; i < bag.GetItems().Count; i++)
            {
                UIContainerSlot slot = new UIContainerSlot(bag, i);
                gridItems.Add(slot);
            }
        }
Exemplo n.º 19
0
        public void Load(QEBag bag)
        {
            guid = bag.guid;

            for (int i = 0; i < PortableStorage.Instance.GetModWorld <PSWorld>().enderItems[bag.frequency].Count; i++)
            {
                UIContainerSlot slot = new UIContainerSlot(bag, i);
                gridItems.Add(slot);
            }
        }
Exemplo n.º 20
0
        public void TestRemove()
        {
            UIGridColumn column = new UIGridColumn("heading", null, null, null, false,
                100, PropAlignment.left, null);
            UIGrid uiGrid = new UIGrid();
            uiGrid.Add(column);

            Assert.IsTrue(uiGrid.Contains(column));
            uiGrid.Remove(column);
            Assert.IsFalse(uiGrid.Contains(column));
        }
Exemplo n.º 21
0
        public void PopulateGrid()
        {
            gridItems.Clear();

            foreach (Item item in Network.Items)
            {
                if (item.maxStack > 1 && gridItems.items.Any(gridSlot => gridSlot.Item.type == item.type))
                {
                    continue;
                }

                UIGridSlot slot = new UIGridSlot(Network, item);
                gridItems.Add(slot);
            }

            while (gridItems.Count < 54 || gridItems.Count % 9 != 0)
            {
                gridItems.Add(new UIGridSlot(Network, new Item()));
            }
        }
Exemplo n.º 22
0
        private static UIGrid GetUiGrid()
        {
            UIGridColumn uiGridCol =
                new UIGridColumn
                    ("Head", "Prop", "control", "Assembly", true, 100, PropAlignment.centre, null);
            UIGrid uiGrid = new UIGrid();

            uiGrid.SortColumn = "Prop";
            uiGrid.Add(uiGridCol);
            return(uiGrid);
        }
Exemplo n.º 23
0
        public void Load(AmmoBelt belt)
        {
            guid = belt.guid;

            for (int i = 0; i < belt.GetItems().Count; i++)
            {
                UIContainerSlot slot = new UIContainerSlot(belt, i);
                slot.CanInteract += (item, mouse) => mouse.IsAir || mouse.ammo > 0;
                gridItems.Add(slot);
            }
        }
Exemplo n.º 24
0
        public void Load(QEBag bag)
        {
            this.bag = bag;

            for (int i = 0; i < PortableStorage.Instance.GetModWorld <PSWorld>().GetItemStorage(bag.frequency).Count; i++)
            {
                UIContainerSlot slot = new UIContainerSlot(bag, i);
                slot.OnInteract += Net.SyncQE;
                gridItems.Add(slot);
            }
        }
Exemplo n.º 25
0
        public void TestRemove()
        {
            UIGridColumn column = new UIGridColumn("heading", null, null, null, false,
                                                   100, PropAlignment.left, null);
            UIGrid uiGrid = new UIGrid();

            uiGrid.Add(column);

            Assert.IsTrue(uiGrid.Contains(column));
            uiGrid.Remove(column);
            Assert.IsFalse(uiGrid.Contains(column));
        }
Exemplo n.º 26
0
        public void Test_AddColumn_ShouldSetColumnsUIGrid()
        {
            //---------------Set up test pack-------------------
            IUIGrid uiGrid = new UIGrid();
            var     column = MockRepository.GenerateStub <IUIGridColumn>();

            //---------------Assert Precondition----------------
            Assert.IsNull(column.UIGrid);
            //---------------Execute Test ----------------------
            uiGrid.Add(column);
            //---------------Test Result -----------------------
            Assert.AreSame(uiGrid, column.UIGrid);
        }
Exemplo n.º 27
0
        public void Test_NotEqual_HasDifferentNumbersOfColumns()
        {
            //---------------Set up test pack-------------------
            UIGrid       uiGrid       = new UIGrid();
            UIGridColumn uiGridColumn = GetUiGridColumn();

            uiGrid.Add(uiGridColumn);
            uiGrid.Add(GetUiGridColumn());

            UIGrid uiGrid2 = new UIGrid();

            uiGrid2.Add(uiGridColumn);
            //--------------Assert PreConditions----------------
            Assert.AreEqual(2, uiGrid.Count);
            Assert.AreEqual(1, uiGrid2.Count);
            //---------------Execute Test ----------------------

            //---------------Test Result -----------------------
            Assert.IsFalse(uiGrid.Equals(uiGrid2));
            Assert.IsFalse(uiGrid == uiGrid2);
            Assert.IsTrue(uiGrid != uiGrid2);
            //---------------Tear Down -------------------------
        }
Exemplo n.º 28
0
        public void UpdateGrid()
        {
            gridLocations.Clear();

            foreach (TileEntities.Teleporter teleporter in Container.GetConnections())
            {
                UITeleporterItem teleporterItem = new UITeleporterItem(teleporter, this)
                {
                    Width  = { Percent = 100 },
                    Height = { Pixels = 60 }
                };
                gridLocations.Add(teleporterItem);
            }
        }
Exemplo n.º 29
0
        public void Test_EqualHasTheSameGridColumn()
        {
            UIGrid       uiGrid       = new UIGrid();
            UIGridColumn uiGridColumn = GetUiGridColumn();

            uiGrid.Add(uiGridColumn);

            UIGrid uiGrid2 = new UIGrid();

            //UIGridColumn uiGridColumn2 = GetUiGridColumn();
            uiGrid2.Add(uiGridColumn);

            Assert.IsTrue(uiGrid.Equals(uiGrid2));
            Assert.IsTrue(uiGrid == uiGrid2);
            Assert.IsFalse(uiGrid != uiGrid2);
        }
Exemplo n.º 30
0
        public void Test_NotEqualHasTheDifferentPropName_GridColumn()
        {
            UIGrid       uiGrid       = new UIGrid();
            UIGridColumn uiGridColumn = GetUiGridColumn();

            uiGrid.Add(uiGridColumn);

            UIGrid       uiGrid2       = new UIGrid();
            UIGridColumn uiGridColumn2 = GetUiGridColumn("Diff Prop Name");

            uiGrid2.Add(uiGridColumn2);

            Assert.IsFalse(uiGrid.Equals(uiGrid2));
            Assert.IsFalse(uiGrid == uiGrid2);
            Assert.IsTrue(uiGrid != uiGrid2);
        }
Exemplo n.º 31
0
        internal void UpdateHuntList()
        {
            if (!needUpdate)
            {
                return;
            }
            needUpdate = false;
            huntGrid.Clear();

            foreach (HuntInfo hunt in JoostMod.instance.hunts)
            {
                if (hunt.showQuest())
                {
                    HuntUIButton bill = new HuntUIButton(hunt);
                    huntGrid.Add(bill);
                }
            }
        }
Exemplo n.º 32
0
        public void TestCloneUIGrid()
        {
            UIGridColumn uiGridCol = new UIGridColumn("Head", "Prop", "control", "Assembly",true,100, PropAlignment.centre, null);
            UIGrid uiGrid = new UIGrid();
            uiGrid.SortColumn = "Prop";
            uiGrid.Add(uiGridCol);

            //---------------Execute Test ----------------------
            IUIGrid clonedGrid = uiGrid.Clone();

            //---------------Test Result -----------------------
            Assert.IsTrue(uiGrid.Equals(clonedGrid));
            Assert.IsTrue(uiGrid == (UIGrid) clonedGrid);
            Assert.IsFalse(uiGrid != (UIGrid) clonedGrid);
            Assert.AreEqual(uiGrid[0], clonedGrid[0],
                              "Should be a deep copy and the columns should be equal but copied");
            Assert.AreNotSame(uiGrid[0], clonedGrid[0], "Should be a deep copy and the columns should be equal but copied (not same)");
        }
Exemplo n.º 33
0
            internal void RefreshGrid()
            {
                Point currSelection = grid.SelectionIndex;

                GetSortedGridElements(refreshGrid_scratch);

                for (int i = 0; i < grid.ActualDimensions.Y; ++i)
                {
                    UIGridShareHubElement elem = grid.Get(0, i) as UIGridShareHubElement;

                    elem.Selected = false;

                    if (!refreshGrid_scratch.Contains(elem))
                    {
                        BokuGame.Unload(elem);
                    }
                }

                grid.Clear();

                for (int i = 0; i < refreshGrid_scratch.Count; ++i)
                {
                    grid.Add(refreshGrid_scratch[i], 0, grid.ActualDimensions.Y);
                    BokuGame.Load(refreshGrid_scratch[i]);
                }

                grid.Dirty = true;

                // Try to preserve selection index.
                // We might want to try to relocate the selected element if it moved instead.
                if (grid.ActualDimensions.Y > currSelection.Y)
                {
                    grid.SelectionIndex = new Point(0, currSelection.Y);
                }
                else if (grid.ActualDimensions.Y > 0)
                {
                    grid.SelectionIndex = new Point(0, grid.ActualDimensions.Y - 1);
                }

                Matrix parentMatrix = Matrix.Identity;

                grid.Update(ref parentMatrix);
            }
        public void Test_AddRow_WhenVirtualProp_ShouldAddBOWithRelatedVirtualPropSet()
        {
            //---------------Set up test pack-------------------
            RecordingExceptionNotifier recordingExceptionNotifier = new RecordingExceptionNotifier();
            GlobalRegistry.UIExceptionNotifier = recordingExceptionNotifier;
            AddressTestBO.LoadDefaultClassDef();
            var contactPersonClassDef = ContactPersonTestBO.LoadClassDefWithOrganisationAndAddressRelationships();
            OrganisationTestBO.LoadDefaultClassDef();
            BusinessObjectCollection<ContactPersonTestBO> contactPersonTestBOS = new BusinessObjectCollection<ContactPersonTestBO>();

            OrganisationTestBO organisation = new OrganisationTestBO();

            UIGrid uiGrid = new UIGrid();
            new UIDef("fdafdas", new UIForm(), uiGrid) {ClassDef = contactPersonClassDef};
            const string propertyName = "-Organisation-";
            uiGrid.Add(new UIGridColumn("Contact Organisation", propertyName, typeof(DataGridViewTextBoxColumn), true, 100, PropAlignment.left, new Hashtable()));

            IDataSetProvider dataSetProvider = CreateDataSetProvider(contactPersonTestBOS);
            DataTable table = dataSetProvider.GetDataTable(uiGrid);

            //---------------Assert Precondition----------------
            Assert.IsTrue(dataSetProvider is EditableDataSetProvider);
            Assert.AreEqual(0, table.Rows.Count);
            Assert.AreEqual(0, contactPersonTestBOS.Count);
            //---------------Execute Test ----------------------
            table.Rows.Add(new object[] { null, organisation });
            //---------------Test Result -----------------------
            Assert.AreEqual(1, table.Rows.Count);
            Assert.AreEqual(1, contactPersonTestBOS.Count);
            Assert.AreSame(organisation, table.Rows[0][propertyName]);
            Assert.AreSame(organisation, contactPersonTestBOS[0].Organisation);
        }
        public void Test_AddRow_WhenMultipleLevelProp_ShouldAddBOWithRelatedPropSet()
        {
            //---------------Set up test pack-------------------
            RecordingExceptionNotifier recordingExceptionNotifier = new RecordingExceptionNotifier();
            GlobalRegistry.UIExceptionNotifier = recordingExceptionNotifier;
            ClassDef.ClassDefs.Clear();
            AddressTestBO.LoadDefaultClassDef();
            ContactPersonTestBO.LoadClassDefWithOrganisationAndAddressRelationships();
            OrganisationTestBO.LoadDefaultClassDef();
            ContactPersonTestBO contactPersonTestBO = ContactPersonTestBO.CreateSavedContactPerson();
            BusinessObjectCollection<AddressTestBO> addresses = contactPersonTestBO.Addresses;

            OrganisationTestBO organisation = new OrganisationTestBO();

            UIGrid uiGrid = new UIGrid();
            const string propertyName = "ContactPersonTestBO.OrganisationID";
            uiGrid.Add(new UIGridColumn("Contact Organisation", propertyName, typeof(DataGridViewTextBoxColumn), true, 100, PropAlignment.left, new Hashtable()));

            IDataSetProvider dataSetProvider = CreateDataSetProvider(addresses);
            DataTable table = dataSetProvider.GetDataTable(uiGrid);

            //---------------Assert Precondition----------------
            Assert.IsTrue(dataSetProvider is EditableDataSetProvider);
            Assert.AreEqual(0, table.Rows.Count);
            Assert.AreEqual(0, addresses.Count);
            //---------------Execute Test ----------------------
            table.Rows.Add(new object[] { null, organisation.OrganisationID });
            //---------------Test Result -----------------------
            Assert.AreEqual(1, table.Rows.Count);
            Assert.AreEqual(1, addresses.Count);
            Assert.AreEqual(organisation.OrganisationID.ToString(), table.Rows[0][propertyName].ToString());
            Assert.AreEqual(organisation.OrganisationID, contactPersonTestBO.OrganisationID);
            recordingExceptionNotifier.RethrowRecordedException();
        }
Exemplo n.º 36
0
 public UIGrid GetUIGridProperties()
 {
     UIGrid col = new UIGrid();
     col.Add(
         new UIGridColumn("Text:", "SampleText", "DataGridViewTextBoxColumn", null, true, 100,
                            PropAlignment.left, null));
     return col;
 }
Exemplo n.º 37
0
 private static UIGrid GetUiGrid()
 {
     UIGridColumn uiGridCol =
         new UIGridColumn
             ("Head", "Prop", "control", "Assembly", true, 100, PropAlignment.centre, null);
     UIGrid uiGrid = new UIGrid();
     uiGrid.SortColumn = "Prop";
     uiGrid.Add(uiGridCol);
     return uiGrid;
 }
Exemplo n.º 38
0
        public void Test_EqualHasTheSameGridColumn()
        {
            UIGrid uiGrid = new UIGrid();
            UIGridColumn uiGridColumn = GetUiGridColumn();
            uiGrid.Add(uiGridColumn);

            UIGrid uiGrid2 = new UIGrid();
            //UIGridColumn uiGridColumn2 = GetUiGridColumn();
            uiGrid2.Add(uiGridColumn);

            Assert.IsTrue(uiGrid.Equals(uiGrid2));
            Assert.IsTrue(uiGrid == uiGrid2);
            Assert.IsFalse(uiGrid != uiGrid2);
        }
Exemplo n.º 39
0
        public void Test_NotEqual_HasDifferentNumbersOfColumns()
        {
            //---------------Set up test pack-------------------
            UIGrid uiGrid = new UIGrid();
            UIGridColumn uiGridColumn = GetUiGridColumn();
            uiGrid.Add(uiGridColumn);
            uiGrid.Add(GetUiGridColumn());

            UIGrid uiGrid2 = new UIGrid();
            uiGrid2.Add(uiGridColumn);
            //--------------Assert PreConditions----------------            
            Assert.AreEqual(2, uiGrid.Count);
            Assert.AreEqual(1, uiGrid2.Count);
            //---------------Execute Test ----------------------

            //---------------Test Result -----------------------
            Assert.IsFalse(uiGrid.Equals(uiGrid2));
            Assert.IsFalse(uiGrid == uiGrid2);
            Assert.IsTrue(uiGrid != uiGrid2);
            //---------------Tear Down -------------------------          
        }
Exemplo n.º 40
0
        public void Test_NotEqualHasTheDifferentPropName_GridColumn()
        {
            UIGrid uiGrid = new UIGrid();
            UIGridColumn uiGridColumn = GetUiGridColumn();
            uiGrid.Add(uiGridColumn);

            UIGrid uiGrid2 = new UIGrid();
            UIGridColumn uiGridColumn2 = GetUiGridColumn("Diff Prop Name");
            uiGrid2.Add(uiGridColumn2);

            Assert.IsFalse(uiGrid.Equals(uiGrid2));
            Assert.IsFalse(uiGrid == uiGrid2);
            Assert.IsTrue(uiGrid != uiGrid2);
        }
Exemplo n.º 41
0
 public void Test_AddColumn_ShouldSetColumnsUIGrid()
 {
     //---------------Set up test pack-------------------
     IUIGrid uiGrid = new UIGrid();
     var column = MockRepository.GenerateStub<IUIGridColumn>();
     //---------------Assert Precondition----------------
     Assert.IsNull(column.UIGrid);
     //---------------Execute Test ----------------------
     uiGrid.Add(column);
     //---------------Test Result -----------------------
     Assert.AreSame(uiGrid, column.UIGrid);
 }
Exemplo n.º 42
0
        public void Test_EqualHasCopyOfGridColumn()
        {
            //---------------Set up test pack-------------------
            UIGrid uiGrid = new UIGrid();
            UIGridColumn uiGridColumn = GetUiGridColumn();
            uiGrid.Add(uiGridColumn);
            //--------------Assert PreConditions----------------            

            //---------------Execute Test ----------------------
            UIGrid uiGrid2 = new UIGrid();
            uiGrid2.Add(uiGridColumn.Clone());
            //---------------Test Result -----------------------
            Assert.IsTrue(uiGrid.Equals(uiGrid2));
            Assert.IsTrue(uiGrid == uiGrid2);
            Assert.IsFalse(uiGrid != uiGrid2);
            //---------------Tear Down -------------------------          
        }
Exemplo n.º 43
0
        public void Test_Indexer_FindBy_PropertyName_DoesntExistReturnsNull()
        {
            //---------------Set up test pack-------------------
            UIGrid uiGrid = new UIGrid();
            UIGridColumn uiGridColumn = GetUiGridColumn();
            uiGrid.Add(uiGridColumn);
            UIGridColumn uiGridColumn2 = GetUiGridColumn("Diff Prop Name");
            uiGrid.Add(uiGridColumn2);

            //--------------Assert PreConditions----------------            
            Assert.AreEqual(2, uiGrid.Count);
            //---------------Execute Test ----------------------
            IUIGridColumn column = uiGrid["nonexistent property"];
            //---------------Test Result -----------------------
            Assert.IsNull(column);
        }
Exemplo n.º 44
0
        public void Test_Indexer_FindBy_PropertyName()
        {
            //---------------Set up test pack-------------------
            UIGrid uiGrid = new UIGrid();
            UIGridColumn uiGridColumn = GetUiGridColumn();
            uiGrid.Add(uiGridColumn);
            UIGridColumn uiGridColumn2 = GetUiGridColumn("Diff Prop Name");
            uiGrid.Add(uiGridColumn2);

            //--------------Assert PreConditions----------------            
            Assert.AreEqual(2, uiGrid.Count);
            //---------------Execute Test ----------------------
            IUIGridColumn column = uiGrid[uiGridColumn2.PropertyName];
            //---------------Test Result -----------------------
            Assert.AreEqual(uiGridColumn2, column);
        }