/// <summary> /// Initializes a new instance of the ActionButton class. /// </summary> /// <param name="width">Width of the panel</param> /// <param name="height">Height of the panel</param> /// <param name="dragInfo">Info for dragged item</param> public ActionButton(int width, int height, ItemDragInfo dragInfo) { this.dragInfo = dragInfo; this.dragLocation.X = -1; this.dragLocation.Y = -1; Width = width; Height = height; this.CreateDoors(); this.CreateBrushes(); this.InitializeAnimationParams(); this.InitializeTimer(); BackColor = ((SolidBrush)this.normalBackground).Color; // set up event handlers this.Paint += new PaintEventHandler(this.PaintCallback); this.MouseMove += new MouseEventHandler(this.MouseMoveCallback); this.MouseLeave += new EventHandler(this.MouseLeaveCallback); this.MouseEnter += new EventHandler(this.MouseEnterCallback); this.MouseDown += new MouseEventHandler(this.MouseDownCallback); // Da_FileServer: Some small paint optimizations. this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); }
/// <summary> /// Initializes a new instance of the VaultPanel class. /// </summary> /// <param name="dragInfo">Instance of the ItemDragInfo</param> /// <param name="numberOfBags">Number of bags in this panel</param> /// <param name="panelSize">Main panel size</param> /// <param name="numberOfAutosortButtons">The number of AutoSort buttons associated with this panel.,</param> /// <param name="autoMoveLocation">The automovelocation for this panel.</param> public VaultPanel(ItemDragInfo dragInfo, int numberOfBags, Size panelSize, int numberOfAutosortButtons, AutoMoveLocation autoMoveLocation) { this.DragInfo = dragInfo; this.AutoMoveLocation = autoMoveLocation; this.Text = Resources.PlayerPanelNoVault; this.NoPlayerString = Resources.PlayerPanelNoVault; this.BackColor = Color.Transparent; this.DrawAsGroupBox = false; // Setup the offset to make room for the autosort button int autosortOffset = 0; if (numberOfAutosortButtons > 0) { autosortOffset = Convert.ToInt32(27.0F * UIService.UI.Scale); } this.Size = new Size( (panelSize.Width * UIService.UI.ItemUnitSize) + Convert.ToInt32(10.0F * UIService.UI.Scale) + autosortOffset + BorderPad, (panelSize.Height * UIService.UI.ItemUnitSize) + Convert.ToInt32(56.0F * UIService.UI.Scale) + BorderPad); this.TabStop = false; this.Font = new Font(this.Font.FontFamily, this.Font.SizeInPoints * UIService.UI.Scale, this.Font.Style); this.BagPanelOffset = 0; // bag panel starts with bag #0 this.BagSackPanel = new SackPanel(panelSize.Width, panelSize.Height, this.DragInfo, autoMoveLocation); this.BagSackPanel.SetLocation(new Point(autosortOffset + BorderPad, this.Size.Height - (this.BagSackPanel.Size.Height + BorderPad))); this.BagSackPanel.OnNewItemHighlighted += new EventHandler <SackPanelEventArgs>(this.NewItemHighlightedCallback); this.BagSackPanel.OnAutoMoveItem += new EventHandler <SackPanelEventArgs>(this.AutoMoveItemCallback); this.BagSackPanel.OnActivateSearch += new EventHandler <SackPanelEventArgs>(this.ActivateSearchCallback); this.BagSackPanel.OnItemSelected += new EventHandler <SackPanelEventArgs>(this.ItemSelectedCallback); this.BagSackPanel.OnClearAllItemsSelected += new EventHandler <SackPanelEventArgs>(this.ClearAllItemsSelectedCallback); this.BagSackPanel.OnResizeForm += new EventHandler <ResizeEventArgs>(this.ResizeFormCallback); this.Controls.Add(this.BagSackPanel); this.BagSackPanel.IsPlayerBagPanel = false; this.BagSackPanel.MaxSacks = numberOfBags; // Create the buttons this.bagButtons = new Collection <BagButtonBase>(); this.CreateBagButtons(numberOfBags); // Assume it's the trash panel if we are not autosorting it. if (numberOfAutosortButtons == 0) { this.BagSackPanel.SackType = SackType.Trash; } else { this.autoSortButtons = new Collection <AutoSortButton>(); for (int i = 0; i < numberOfAutosortButtons; ++i) { this.autoSortButtons.Insert(i, this.CreateAutoSortButton(i)); this.Controls.Add(this.autoSortButtons[i]); } this.BagSackPanel.SackType = SackType.Vault; } this.contextMenu = new ContextMenuStrip(); this.contextMenu.BackColor = Color.FromArgb(46, 41, 31); this.contextMenu.DropShadowEnabled = true; this.contextMenu.Font = FontHelper.GetFontAlbertusMT(9.0F * UIService.UI.Scale); this.contextMenu.ForeColor = Color.FromArgb(200, 200, 200); this.contextMenu.Opacity = 0.80; this.contextMenu.ShowImageMargin = false; this.contextMenu.ItemClicked += new ToolStripItemClickedEventHandler(this.ContextMenuItemClicked); this.contextMenu.Renderer = new CustomProfessionalRenderer(); this.PropertyChanged += new PropertyChangedEventHandler(this.PropertyChangedCallback); this.Paint += new PaintEventHandler(this.PaintCallback); // to avoid flickering use double buffer and to force control to use OnPaint this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true); }
/// <summary> /// Initializes a new instance of the PlayerPanel class. /// </summary> /// <param name="dragInfo">Instance of the ItemDragInfo</param> /// <param name="numberOfBags">Number of bags in this panel</param> /// <param name="panel1Size">Main panel size</param> /// <param name="panel2Size">Secondary panel size for players who have the additional game sacks</param> /// <param name="tooltip">Tooltip instance</param> public PlayerPanel(ItemDragInfo dragInfo, int numberOfBags, Size panel1Size, Size panel2Size) : base(dragInfo, numberOfBags, panel2Size, 2, AutoMoveLocation.Player) { this.Text = Resources.PlayerPanelNoPlayer; this.NoPlayerString = Resources.PlayerPanelNoPlayer; this.Size = new Size( ((panel1Size.Width + panel2Size.Width) * UIService.UI.ItemUnitSize) + Convert.ToInt32(24.0F * UIService.UI.Scale), (Math.Max(panel1Size.Height, panel2Size.Height) * UIService.UI.ItemUnitSize) + Convert.ToInt32(58.0F * UIService.UI.Scale)); this.TabStop = false; this.Font = new Font(this.Font.FontFamily, this.Font.SizeInPoints * UIService.UI.Scale, this.Font.Style); int borderPad = Convert.ToInt32(2.0F * UIService.UI.Scale); this.BagPanelOffset = 1; // bag panel starts with bag #1 this.mainSackPanel = new SackPanel(panel1Size.Width, panel1Size.Height, this.DragInfo, AutoMoveLocation.Player); this.mainSackPanel.SetLocation(new Point(borderPad, this.Size.Height - this.mainSackPanel.Size.Height - borderPad)); this.mainSackPanel.OnNewItemHighlighted += new EventHandler <SackPanelEventArgs>(this.NewItemHighlightedCallback); this.mainSackPanel.OnAutoMoveItem += new EventHandler <SackPanelEventArgs>(this.AutoMoveItemCallback); this.mainSackPanel.OnActivateSearch += new EventHandler <SackPanelEventArgs>(this.ActivateSearchCallback); this.mainSackPanel.OnClearAllItemsSelected += new EventHandler <SackPanelEventArgs>(this.ClearAllItemsSelectedCallback); this.mainSackPanel.OnItemSelected += new EventHandler <SackPanelEventArgs>(this.ItemSelectedCallback); this.mainSackPanel.OnResizeForm += new EventHandler <ResizeEventArgs>(this.ResizeFormCallback); this.Controls.Add(this.mainSackPanel); this.mainSackPanel.MaxSacks = 1; this.mainSackPanel.SackType = SackType.Player; this.mainSackPanel.IsMainPlayerPanel = true; this.BagSackPanel.SetLocation(new Point(this.mainSackPanel.Right + borderPad, this.Size.Height - this.BagSackPanel.Size.Height - borderPad)); this.BagSackPanel.IsPlayerBagPanel = true; // Recalculate the button sizing and placement since we moved the BagSackPanel. if (this.BagButtons != null && this.BagButtons.Count > 0) { float buttonWidth = (float)Resources.inventorybagup01.Width; float buttonHeight = (float)Resources.inventorybagup01.Height; float pad = 2.0F; float slotWidth = buttonWidth + (2.0F * pad); // we need to scale down the bag size depending on the # we have // but keep room for the autosort button so the buttons only use half of the panel size. float scale = this.GetBagButtonScale(slotWidth, (this.BagButtons.Count * 2)); float bagSlotWidth = scale * slotWidth; int index = 0; foreach (BagButtonBase button in this.BagButtons) { button.Size = new Size((int)Math.Round(scale * buttonWidth), (int)Math.Round(scale * buttonHeight)); float offset = (bagSlotWidth * index) + ((bagSlotWidth - button.Width) / 2.0F); button.Location = new Point(this.BagSackPanel.Location.X + (int)Math.Round(offset), this.BagSackPanel.Location.Y - button.Height); index++; } } // Move the autosort buttons to their place since the panels got moved. AutoSortButtons[0].Location = new Point(this.mainSackPanel.Location.X, this.mainSackPanel.Location.Y - AutoSortButtons[0].Height); AutoSortButtons[1].Location = new Point( this.BagSackPanel.Location.X + this.BagSackPanel.Width - AutoSortButtons[1].Width, this.BagSackPanel.Location.Y - AutoSortButtons[1].Height); this.BagSackPanel.SackType = SackType.Sack; }
/// <summary> /// Initializes a new instance of the StashPanel class. Hard coded to 4 stash buttons and no autosort buttons. /// </summary> /// <param name="dragInfo">ItemDragInfo instance</param> /// <param name="panelSize">Size of the panel in cells</param> /// <param name="tooltip">ToolTip instance</param> public StashPanel(ItemDragInfo dragInfo, Size panelSize, IServiceProvider serviceProvider) : base(dragInfo, 4, panelSize, 0, AutoMoveLocation.Stash, serviceProvider) { this.TranslationService = this.ServiceProvider.GetService <ITranslationService>(); this.Database = this.ServiceProvider.GetService <IDatabase>(); this.ItemProvider = this.ServiceProvider.GetService <IItemProvider>(); SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); this.equipmentPanel = new EquipmentPanel(16, 14, dragInfo, AutoMoveLocation.Stash, serviceProvider); this.Controls.Add(this.equipmentPanel); this.equipmentPanel.OnNewItemHighlighted += new EventHandler <SackPanelEventArgs>(this.NewItemHighlightedCallback); this.equipmentPanel.OnAutoMoveItem += new EventHandler <SackPanelEventArgs>(this.AutoMoveItemCallback); this.equipmentPanel.OnActivateSearch += new EventHandler <SackPanelEventArgs>(this.ActivateSearchCallback); this.equipmentPanel.OnItemSelected += new EventHandler <SackPanelEventArgs>(this.ItemSelectedCallback); this.equipmentPanel.OnClearAllItemsSelected += new EventHandler <SackPanelEventArgs>(this.ClearAllItemsSelectedCallback); this.equipmentPanel.OnResizeForm += new EventHandler <ResizeEventArgs>(this.ResizeFormCallback); this.equipmentPanel.OnEquipmentChanged += new EventHandler <SackPanelEventArgs>(this.EquipmentChangedCallback); this.Text = Resources.StashPanelText; this.NoPlayerString = Resources.StashPanelText; this.Size = new Size( (panelSize.Width * UIService.ItemUnitSize) + Convert.ToInt32(10.0F * UIService.Scale) + BorderPad, (panelSize.Height * UIService.ItemUnitSize) + Convert.ToInt32(60.0F * UIService.Scale) + BorderPad); this.Paint += new PaintEventHandler(this.PaintCallback); this.BagSackPanel.SetLocation(new Point(BorderPad, this.Size.Height - (this.BagSackPanel.Size.Height + BorderPad))); this.BagSackPanel.MaxSacks = 1; this.BagSackPanel.Anchor = AnchorStyles.None; //this.EquipmentBackground = Resources.Equipment_bg_new; this.background = this.EquipmentBackground = Resources.equipment_bg_and_char; this.StashBackground = Resources.caravan_bg; // Set up the inital font size if (UIService.Scale != 1.0F) { this.Font = new Font(this.Font.FontFamily, this.Font.SizeInPoints * UIService.Scale, this.Font.Style); } // Now that the buttons are set we can move the panel this.BagSackPanel.SetLocation(new Point( BorderPad, this.BagButtons[0].Location.Y + this.BagButtons[0].Size.Height + UIService.HalfUnitSize)); int offsetX = (panelSize.Width - this.equipmentPanel.SackSize.Width) * UIService.HalfUnitSize; if (offsetX < 0) { offsetX = 0; } int offsetY = (panelSize.Height - this.equipmentPanel.SackSize.Height) * UIService.HalfUnitSize; if (offsetY < 0) { offsetY = 0; } this.equipmentPanel.SetLocation(new Point( offsetX, this.BagButtons[0].Location.Y + this.BagButtons[0].Size.Height + offsetY)); this.maxPanelSize = panelSize; this.BagSackPanel.Visible = false; this.BagSackPanel.Enabled = false; #region Init Player Panel // Based on testing at scale 1 var table = new BufferedTableLayoutPanel() { Location = new Point( PLAYERINFO_TOPRIGHT - PLAYERINFO_WIDTH , PLAYERINFO_TOPHEIGHT ), Size = new Size(PLAYERINFO_WIDTH, PLAYERINFO_HEIGHT), //CellBorderStyle = TableLayoutPanelCellBorderStyle.Single, Margin = new Padding(0), Padding = new Padding(1), BackColor = Color.Transparent, }; table.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 60F)); table.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 40F)); this.Controls.Add(table); this.PlayerPanel = table; table.BringToFront(); this.equipmentPanel.VisibleChanged += EquipmentPanel_VisibleChanged; #endregion }
/// <summary> /// Initializes a new instance of the StashPanel class. Hard coded to 4 stash buttons and no autosort buttons. /// </summary> /// <param name="dragInfo">ItemDragInfo instance</param> /// <param name="panelSize">Size of the panel in cells</param> /// <param name="tooltip">ToolTip instance</param> public StashPanel(ItemDragInfo dragInfo, Size panelSize) : base(dragInfo, 4, panelSize, 0, AutoMoveLocation.Stash) { this.equipmentPanel = new EquipmentPanel(16, 14, dragInfo, AutoMoveLocation.Stash); this.Controls.Add(this.equipmentPanel); this.equipmentPanel.OnNewItemHighlighted += new EventHandler <SackPanelEventArgs>(this.NewItemHighlightedCallback); this.equipmentPanel.OnAutoMoveItem += new EventHandler <SackPanelEventArgs>(this.AutoMoveItemCallback); this.equipmentPanel.OnActivateSearch += new EventHandler <SackPanelEventArgs>(this.ActivateSearchCallback); this.equipmentPanel.OnItemSelected += new EventHandler <SackPanelEventArgs>(this.ItemSelectedCallback); this.equipmentPanel.OnClearAllItemsSelected += new EventHandler <SackPanelEventArgs>(this.ClearAllItemsSelectedCallback); this.equipmentPanel.OnResizeForm += new EventHandler <ResizeEventArgs>(this.ResizeFormCallback); this.equipmentPanel.MouseMove += new MouseEventHandler(this.StashPanelMouseMove); this.equipmentPanel.MouseLeave += new EventHandler(this.StashPanelMouseLeave); this.equipmentPanel.MouseClick += new MouseEventHandler(this.StashPanelMouseClick); //this.MouseMove += new MouseEventHandler(this.StashPanelMouseMove); //this.MouseHover += new MouseEventHandler(this.StashPanelMouseMove); this.Text = Resources.StashPanelText; this.NoPlayerString = Resources.StashPanelText; this.Size = new Size( (panelSize.Width * UIService.UI.ItemUnitSize) + Convert.ToInt32(10.0F * UIService.UI.Scale) + BorderPad, (panelSize.Height * UIService.UI.ItemUnitSize) + Convert.ToInt32(60.0F * UIService.UI.Scale) + BorderPad); this.Paint += new PaintEventHandler(this.PaintCallback); this.BagSackPanel.SetLocation(new Point(BorderPad, this.Size.Height - (this.BagSackPanel.Size.Height + BorderPad))); this.BagSackPanel.MaxSacks = 1; this.BagSackPanel.Anchor = AnchorStyles.None; //this.EquipmentBackground = Resources.Equipment_bg_new; this.background = this.EquipmentBackground = Resources.equipment_bg_and_char; this.StashBackground = Resources.caravan_bg; // Set up the inital font size if (UIService.UI.Scale != 1.0F) { this.Font = new Font(this.Font.FontFamily, this.Font.SizeInPoints * UIService.UI.Scale, this.Font.Style); } //x and y coordinates passed are normalized values between 0 and 1.0. playerInfoDisplay = new PlayerInfoDisplay(Config.Settings.Default, this, this.Font, .83, .14); // Now that the buttons are set we can move the panel this.BagSackPanel.SetLocation(new Point( BorderPad, this.BagButtons[0].Location.Y + this.BagButtons[0].Size.Height + UIService.UI.HalfUnitSize)); int offsetX = (panelSize.Width - this.equipmentPanel.SackSize.Width) * UIService.UI.HalfUnitSize; if (offsetX < 0) { offsetX = 0; } int offsetY = (panelSize.Height - this.equipmentPanel.SackSize.Height) * UIService.UI.HalfUnitSize; if (offsetY < 0) { offsetY = 0; } this.equipmentPanel.SetLocation(new Point( offsetX, this.BagButtons[0].Location.Y + this.BagButtons[0].Size.Height + offsetY)); this.maxPanelSize = panelSize; this.BagSackPanel.Visible = false; this.BagSackPanel.Enabled = false; }
/// <summary> /// Initializes a new instance of the VaultPanel class. /// </summary> /// <param name="dragInfo">Instance of the ItemDragInfo</param> /// <param name="numberOfBags">Number of bags in this panel</param> /// <param name="panelSize">Main panel size</param> /// <param name="numberOfAutosortButtons">The number of AutoSort buttons associated with this panel.,</param> /// <param name="autoMoveLocation">The automovelocation for this panel.</param> public VaultPanel(ItemDragInfo dragInfo, int numberOfBags, Size panelSize, int numberOfAutosortButtons, AutoMoveLocation autoMoveLocation, IServiceProvider serviceProvider) { InitializeComponent(); this.ServiceProvider = serviceProvider; this.FontService = this.ServiceProvider.GetService <IFontService>(); this.UIService = this.ServiceProvider.GetService <IUIService>(); this.DragInfo = dragInfo; this.AutoMoveLocation = autoMoveLocation; this.Text = Resources.PlayerPanelNoVault; this.NoPlayerString = Resources.PlayerPanelNoVault; this.DrawAsGroupBox = false; // Setup the offset to make room for the autosort button int autosortOffset = 0; if (numberOfAutosortButtons > 0) { autosortOffset = Convert.ToInt32(27.0F * UIService.Scale); } this.Size = new Size( (panelSize.Width * UIService.ItemUnitSize) + Convert.ToInt32(10.0F * UIService.Scale) + autosortOffset + BorderPad, (panelSize.Height * UIService.ItemUnitSize) + Convert.ToInt32(56.0F * UIService.Scale) + BorderPad); this.Font = new Font(this.Font.FontFamily, this.Font.SizeInPoints * UIService.Scale, this.Font.Style); this.BagPanelOffset = 0; // bag panel starts with bag #0 this.BagSackPanel = new SackPanel(panelSize.Width, panelSize.Height, this.DragInfo, autoMoveLocation, this.ServiceProvider); this.BagSackPanel.SetLocation(new Point(autosortOffset + BorderPad, this.Size.Height - (this.BagSackPanel.Size.Height + BorderPad))); this.BagSackPanel.OnNewItemHighlighted += new EventHandler <SackPanelEventArgs>(this.NewItemHighlightedCallback); this.BagSackPanel.OnAutoMoveItem += new EventHandler <SackPanelEventArgs>(this.AutoMoveItemCallback); this.BagSackPanel.OnActivateSearch += new EventHandler <SackPanelEventArgs>(this.ActivateSearchCallback); this.BagSackPanel.OnItemSelected += new EventHandler <SackPanelEventArgs>(this.ItemSelectedCallback); this.BagSackPanel.OnClearAllItemsSelected += new EventHandler <SackPanelEventArgs>(this.ClearAllItemsSelectedCallback); this.BagSackPanel.OnResizeForm += new EventHandler <ResizeEventArgs>(this.ResizeFormCallback); this.Controls.Add(this.BagSackPanel); this.BagSackPanel.IsPlayerBagPanel = false; this.BagSackPanel.MaxSacks = numberOfBags; // Create the buttons this.bagButtons = new Collection <BagButtonBase>(); this.CreateBagButtons(numberOfBags); // Assume it's the trash panel if we are not autosorting it. if (numberOfAutosortButtons == 0) { this.BagSackPanel.SackType = SackType.Trash; } else { this.autoSortButtons = new Collection <AutoSortButton>(); for (int i = 0; i < numberOfAutosortButtons; ++i) { this.autoSortButtons.Insert(i, this.CreateAutoSortButton(i)); this.Controls.Add(this.autoSortButtons[i]); } this.BagSackPanel.SackType = SackType.Vault; } this.contextMenu.Font = FontService.GetFont(9.0F * UIService.Scale); this.PropertyChanged += new PropertyChangedEventHandler(this.PropertyChangedCallback); // to avoid flickering use double buffer and to force control to use OnPaint this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true); }