Example #1
0
        /// <summary>
        /// Marks the item as placed removing it from the original container.
        /// </summary>
        /// <param name="slot">slot if an equipment placement.</param>
        public void MarkPlaced(int slot)
        {
            // Remove the item from the old sack
            if (this.IsModifiedItem)
            {
                // modified items do not have a source sack.
                // so no one needs to be notified of the placement.
            }
            else
            {
                if (this.sack.SackType == SackType.Equipment && slot != -1)
                {
                    // Remove the item out of the equipment slot
                    this.sack.RemoveAtItem(slot);

                    // Put a dummy item in it's place
                    Item newItem = this.item.MakeEmptyItem();
                    newItem.PositionX = SackCollection.GetEquipmentLocationOffset(slot).X;
                    newItem.PositionY = SackCollection.GetEquipmentLocationOffset(slot).Y;
                    this.sack.InsertItem(slot, newItem);
                }
                else
                {
                    this.sack.RemoveItem(this.item);
                }
            }

            // finally clear things out
            this.item             = null;
            this.sack             = null;
            this.sackPanel        = null;
            this.original         = null;
            this.autoMove         = AutoMoveLocation.NotSet;
            this.isBeingCancelled = false;
        }
Example #2
0
 /// <summary>
 /// Sets a drag.  Initializes the ItemDragInfo
 /// </summary>
 /// <param name="sackPanel">sack panel which contains the item</param>
 /// <param name="sack">sack which contains the item</param>
 /// <param name="item">the item being dragged</param>
 /// <param name="mouseOffset">offset of the mouse pointer to the top left corner of the item bitmap</param>
 public void Set(SackPanel sackPanel, SackCollection sack, Item item, Point mouseOffset)
 {
     this.item             = item;
     this.sack             = sack;
     this.sackPanel        = sackPanel;
     this.mouseOffset      = mouseOffset;
     this.original         = null;
     this.autoMove         = AutoMoveLocation.NotSet;
     this.isBeingCancelled = false;
 }
Example #3
0
        /// <summary>
        /// Cancels a drag
        /// </summary>
        public void Cancel()
        {
            this.isBeingCancelled = true;

            // let the owner know.
            this.sackPanel.CancelDrag(this);

            // now clear things out
            this.item             = null;
            this.sack             = null;
            this.sackPanel        = null;
            this.autoMove         = AutoMoveLocation.NotSet;
            this.isBeingCancelled = false;
        }
Example #4
0
        /// <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);
        }
Example #5
0
 /// <summary>
 /// Adds an automovelocation to the list
 /// </summary>
 /// <param name="autoMoveLocation">AutoMoveLocation to add to the list.</param>
 public void AddAutoMoveLocationToList(AutoMoveLocation autoMoveLocation)
 => this.autoMoveLocationsList.Add(autoMoveLocation);
Example #6
0
 /// <summary>
 /// Initializes a new instance of the ItemDragInfo class.
 /// </summary>
 public ItemDragInfo()
 {
     this.autoMove = AutoMoveLocation.NotSet;
     this.autoMoveLocationsList = new List <AutoMoveLocation>();
 }
Example #7
0
        /// <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);
        }