/// <summary> /// Handler for clicking on a bag button /// </summary> /// <param name="sender">sender object</param> /// <param name="e">EventArgs data</param> protected override void BagButtonClick(object sender, MouseEventArgs e) { BagButtonBase button = (BagButtonBase)sender; int bagID = button.ButtonNumber; // filter the bagID if (bagID < 0) { bagID = 0; } if (bagID >= 3) { bagID = 2; } if (bagID != this.currentBag) { // turn off the current bag and turn on the new bag this.BagButtons[this.currentBag].IsOn = false; this.BagButtons[bagID].IsOn = true; // set the current bag to the selected bag this.CurrentBag = bagID; this.SackPanel.ClearSelectedItems(); } }
/// <summary> /// Handler for clicking a bag button /// </summary> /// <remarks> /// Changed by VillageIdiot to support right and left mouse clicking. /// </remarks> /// <param name="sender">sender object</param> /// <param name="e">MouseEventArgs data</param> protected virtual void BagButtonClick(object sender, MouseEventArgs e) { BagButtonBase b = (BagButtonBase)sender; int bagID = b.ButtonNumber; if (bagID != this.CurrentBag) { // turn off the current bag and turn on the new bag this.BagButtons[this.CurrentBag].IsOn = false; this.BagButtons[bagID].IsOn = true; this.CurrentBag = bagID; this.BagSackPanel.ClearSelectedItems(); this.BagSackPanel.Sack = this.Player.GetSack(this.CurrentBag + this.BagPanelOffset); this.BagSackPanel.CurrentSack = this.CurrentBag; } if (e.Button == MouseButtons.Right) { // Only process vault bags with something in them. if (this.BagSackPanel.SackType == SackType.Vault && this.BagButtons[this.CurrentBag].ButtonText != null) { this.contextMenu.Items.Clear(); // Add the move submenu this.AddSubMenu(Resources.PlayerPanelMenuMove, this.MoveBagClicked); // Only show Copy, Merge and Empty if something is in the bag. if (!this.BagSackPanel.Sack.IsEmpty) { if (Settings.Default.AllowItemCopy) { // Add the copy submenu this.AddSubMenu(Resources.PlayerPanelMenuCopy, this.CopyBagClicked); } // Add the merge submenu this.AddSubMenu(Resources.PlayerPanelMenuMerge, this.MergeBagClicked); this.contextMenu.Items.Add("-"); this.contextMenu.Items.Add(Resources.PlayerPanelMenuEmpty); } this.contextMenu.Show(this.BagButtons[this.CurrentBag], new Point(e.X, e.Y)); } } }
/// <summary> /// Gets the tooltip for the sack contents. /// </summary> /// <param name="button">Button number of the sack</param> /// <returns>string listing the sack's contents.</returns> private string GetSackToolTip(BagButtonBase button) { // Get the list of items and return them as a string SackCollection sack = this.Player.GetSack(button.ButtonNumber + this.BagPanelOffset); if (sack == null) { return(null); } if (sack.IsEmpty) { return(string.Format(CultureInfo.CurrentCulture, "{0}<b>{1}</b>", Database.DB.TooltipTitleTag, Database.MakeSafeForHtml(Resources.VaultGroupBoxEmpty))); } StringBuilder toolTipStringBuilder = new StringBuilder(); toolTipStringBuilder.Append(Database.DB.TooltipTitleTag); bool first = true; foreach (Item item in sack) { if (this.DragInfo.IsActive && item == this.DragInfo.Item) { // skip the item being dragged continue; } if (!first) { toolTipStringBuilder.Append("<br>"); } first = false; string itemString = Database.MakeSafeForHtml(item.ToString()); Color color = item.GetColorTag(itemString); itemString = Item.ClipColorTag(itemString); string htmlcolor = Database.HtmlColor(color); string htmlLine = string.Format(CultureInfo.CurrentCulture, "<font color={0}><b>{1}</b></font>", htmlcolor, itemString); toolTipStringBuilder.Append(htmlLine); } return(toolTipStringBuilder.ToString()); }
/// <summary> /// Gets the tooltip for a sack. Summarizes the items within the sack /// </summary> /// <param name="button">button the mouse is over. Corresponds to a sack</param> /// <returns>string to be displayed in the tooltip</returns> private string GetSackToolTip(BagButtonBase button) { // Get the list of items and return them as a string int bagID = button.ButtonNumber; SackCollection sack; if (bagID == 0) { if (this.Player == null) { sack = null; } else { sack = this.Player.EquipmentSack; } } else if (bagID == 1) { sack = this.transferStash.Sack; } else { sack = this.stash.Sack; } if (sack == null || sack.IsEmpty) { return(null); } StringBuilder answer = new StringBuilder(); answer.Append(Database.DB.TooltipTitleTag); bool first = true; foreach (Item item in sack) { if (this.DragInfo.IsActive && item == this.DragInfo.Item) { // skip the item being dragged continue; } if (item.BaseItemId.Length == 0) { // skip empty items continue; } if (!first) { answer.Append("<br>"); } first = false; string text = Database.MakeSafeForHtml(item.ToString()); Color color = item.GetColorTag(text); text = Item.ClipColorTag(text); string htmlcolor = Database.HtmlColor(color); string htmlLine = string.Format(CultureInfo.CurrentCulture, "<font color={0}><b>{1}</b></font>", htmlcolor, text); answer.Append(htmlLine); } return(answer.ToString()); }