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 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); } } }
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); } }
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); } }
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); } }
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); } }
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)); } }
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); } }
public override void Load() { for (int i = 0; i < qeChest.GetItems().Count; i++) { UIContainerSlot slot = new UIContainerSlot(qeChest, i); gridItems.Add(slot); } }
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); } }
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); } }
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); } }
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); }
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); }
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); } }
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); } }
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)); }
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())); } }
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); }
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); } }
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); } }
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); }
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 ------------------------- }
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); } }
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); }
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); }
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); } } }
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)"); }
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(); }
public UIGrid GetUIGridProperties() { UIGrid col = new UIGrid(); col.Add( new UIGridColumn("Text:", "SampleText", "DataGridViewTextBoxColumn", null, true, 100, PropAlignment.left, null)); return col; }
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; }
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); }
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 ------------------------- }