示例#1
0
        // This is used to update the variable appearance of the items.
        // Ex: name, icon, user-configurable sizes, etc...
        private void UpdateItemAppearance(ItemDisplayInfo itemInfo, int number, int totalItems)
        {
            itemInfo.ItemButton.Width   = Config.PieItemSize;
            itemInfo.ItemButton.Height  = Config.PieItemSize;
            itemInfo.ItemButton.Opacity = Config.PieItemNormalOpacity;

            // To be spread evenly in a circle.
            var buttonMargin = new Thickness();

            buttonMargin.Left          = Config.PieItemRadiusFromCenter * Math.Cos(number * 2 * Math.PI / totalItems);
            buttonMargin.Top           = Config.PieItemRadiusFromCenter * Math.Sin(number * 2 * Math.PI / totalItems);
            itemInfo.ItemButton.Margin = buttonMargin;

            // This was initialized as an Image() during CreateDisplayInfo().
            ((System.Windows.Controls.Image)itemInfo.ItemButton.Content).Source = itemInfo.Item.Icon.ImageBitmapSource;



            var labelMargin = new Thickness();

            labelMargin.Left          = itemInfo.ItemButton.Margin.Left;
            labelMargin.Top           = itemInfo.ItemButton.Margin.Top + Config.PieItemSize + Config.PieItemLabelPadding; // TODO: Figure out proper padding.
            itemInfo.ItemLabel.Margin = labelMargin;

            itemInfo.ItemLabel.FontSize = Config.PieItemLabelSize;

            itemInfo.ItemLabel.Content = (itemInfo.Item.Name == null) ? "" : itemInfo.Item.Name;
        }
示例#2
0
 private void POSItemClickExecute(ItemDisplayInfo item)
 {
     if (item.IsMenu)
     {
         CurrentMenu = item.Menus.FirstOrDefault();
     }
     else
     {
         Product   prod = item.Products.FirstOrDefault();
         OrderLine line = CurrentOrder.OrderLines.Where(c => c.prodId == prod.ID).FirstOrDefault();
         if (line == null)
         {
             line = AddItemToOrder(prod);
         }
         else
         {
             line = UpdateItemInOrder(prod);
         }
         CollectionViewSource.GetDefaultView(CurrentOrder.OrderLines).Refresh();
         decimal addedAmount = prod.salePrice * (decimal)getQuantity();
         CurrentOrder.TotalPayment += addedAmount;
         LeftToPay    += addedAmount;
         CalcVM.TBText = String.Empty;
     }
 }
示例#3
0
 internal void FreeItemPosition(ItemDisplayInfo item)
 {
     for (int row = item.IndexRow; row < item.IndexRow + item.NumberOfRows; row++)
     {
         for (int col = item.IndexColumn; col < item.IndexColumn + item.NumberOfColumns; col++)
         {
             FreePositions[row, col] = true;
         }
     }
 }
示例#4
0
        private void SelectItemExecute()
        {
            SelectDiaplyableItemDialog dialog = new SelectDiaplyableItemDialog();

            if (dialog.ShowDialog() == true)
            {
                CurrentItemInDesign = ((IDisplayableModel)dialog.SelectedItem).GetNewDiplayInfo();
                CanEditItem         = true;
            }
            //CustomDialog = new CustomDialogView() { DataContext = new CustomDialogViewModel() };
            // dialogCoordinator.ShowMetroDialogAsync(this, CustomDialog);
        }
示例#5
0
 public bool isPositionFree(ItemDisplayInfo item)
 {
     for (int row = item.IndexRow; row < item.IndexRow + item.NumberOfRows; row++)
     {
         for (int col = item.IndexColumn; col < item.IndexColumn + item.NumberOfColumns; col++)
         {
             if (!FreePositions[row, col])
             {
                 return(false);
             }
         }
     }
     return(true);
 }
示例#6
0
 public void DeleteItem(ItemDisplayInfo item)
 {
     CurrentMenu.ContainItemDisplayInfoes.Remove(item);
     if (item.IsMenu)
     {
         UnitOfWork.get().Menus.Get(item.ItemID).ItemDisplayInfoes.Remove(item);
     }
     else
     {
         UnitOfWork.get().Products.Get(item.ItemID).ItemDisplayInfoes.Remove(item);
     }
     UnitOfWork.get().ItemDisplayInfoes.Remove(item);
     UpdateItem();
 }
        private ItemDisplayInfo getItem(object sender)
        {
            MenuItem menuItem = sender as MenuItem;

            if (menuItem != null)
            {
                ContextMenu parentContextMenu = menuItem.CommandParameter as ContextMenu;
                if (parentContextMenu != null)
                {
                    Button button = parentContextMenu.PlacementTarget as Button;
                    if (button != null)
                    {
                        ItemDisplayInfo item = button.DataContext as ItemDisplayInfo;
                        return(item);
                    }
                }
            }
            return(null);
        }
示例#8
0
        private void CurrentItem_Click(object sender, RoutedEventArgs e)
        {
            ItemDisplayInfo item = ((Button)sender).DataContext as ItemDisplayInfo;

            Globals.get().EventAggregator.GetEvent <POSItemClick>().Publish(item);
        }
示例#9
0
 public static ObservableCollection<ItemDisplayInfo> LoadItemDisplayInfo()
 {
     ObservableCollection<ItemDisplayInfo> ItemDisplayInfoList = new ObservableCollection<ItemDisplayInfo>();
     using (FileStream stream = File.OpenRead(DATA_PATH + "DBC/ItemDisplayInfo.dbc"))
     {
         BinaryReader r = new BinaryReader(stream);
         stream.Position = 4;
         int records = r.ReadInt32();
         int fields = r.ReadInt32();
         int rowSize = r.ReadInt32();
         int stringBlockSize = r.ReadInt32();
         int dataSize = rowSize * records + 20;
         for (int i = 0; i != records; ++i)
         {
             ItemDisplayInfo info = new ItemDisplayInfo();
             info.ID = r.ReadInt32();
             info.LeftModel = DBC.ReadString(r, dataSize);
             info.RightModel = DBC.ReadString(r, dataSize);
             info.LeftModelTexture = DBC.ReadString(r, dataSize);
             info.RightModelTexture = DBC.ReadString(r, dataSize);
             info.Icon1 = DBC.ReadString(r, dataSize);
             info.Icon2 = DBC.ReadString(r, dataSize);
             info.GeosetGroup1 = r.ReadInt32();
             info.GeosetGroup2 = r.ReadInt32();
             info.GeosetGroup3 = r.ReadInt32();
             info.Flags = r.ReadInt32();
             info.SpellVisualID = r.ReadInt32();
             info.GroupSoundIndex = r.ReadInt32();
             info.HelmetGeosetMale = r.ReadInt32();
             info.HelmetGeosetFemale = r.ReadInt32();
             info.UpperArmTexture = DBC.ReadString(r, dataSize);
             info.LowerArmTexture = DBC.ReadString(r, dataSize);
             info.HandsTexture = DBC.ReadString(r, dataSize);
             info.UpperTorsoTexture = DBC.ReadString(r, dataSize);
             info.LowerTorsoTexture = DBC.ReadString(r, dataSize);
             info.UpperLegTexture = DBC.ReadString(r, dataSize);
             info.LowerLegTexture = DBC.ReadString(r, dataSize);
             info.FootTexture = DBC.ReadString(r, dataSize);
             info.ItemVisual = r.ReadInt32();
             info.ParticleColorID = r.ReadInt32();
             ItemDisplayInfoList.Add(info);
         }
         r.Close();
     }
     return ItemDisplayInfoList;
 }
示例#10
0
        // This is a bit more complicated.
        // We have to account for all the stuff that hovering over/pressing/etc... on an item does.
        private void CreateDisplayInfo(PieItem pieItem, int number, int totalItems)
        {
            ItemDisplayInfo itemInfo = new ItemDisplayInfo();

            // The PieItem
            itemInfo.Item = pieItem;


            // The Button control to be used in the main window.
            // Here, we set the non-user-configurable options.
            itemInfo.ItemButton = new Button();

            itemInfo.ItemButton.HorizontalAlignment = HorizontalAlignment.Center;
            itemInfo.ItemButton.VerticalAlignment   = VerticalAlignment.Center;

            itemInfo.ItemButton.Background  = System.Windows.Media.Brushes.Transparent;
            itemInfo.ItemButton.BorderBrush = System.Windows.Media.Brushes.Transparent;

            // Currently just a blank image, will actually be set to something later on.
            var itemImage = new System.Windows.Controls.Image();

            itemInfo.ItemButton.Content = itemImage;


            // The Label control to be used in the main window.
            itemInfo.ItemLabel = new Label();

            itemInfo.ItemLabel.HorizontalAlignment = HorizontalAlignment.Center;
            itemInfo.ItemLabel.VerticalAlignment   = VerticalAlignment.Center;

            // This fixes the flashing button issue if the mouse is on top of both the button and the label.
            itemInfo.ItemLabel.IsHitTestVisible = false;

            // Invisible by default. Will activate only on mouse hover on button.
            itemInfo.ItemLabel.Visibility = Visibility.Hidden;


            UpdateItemAppearance(itemInfo, number, totalItems);


            itemInfo.ItemButton.MouseEnter +=
                (s, e) =>
            {
                itemInfo.ItemLabel.Visibility = Visibility.Visible;
            };

            itemInfo.ItemButton.MouseLeave +=
                (s, e) =>
            {
                itemInfo.ItemLabel.Visibility = Visibility.Hidden;
            };

            // Handle custom clicking and dragging in these next three functions.
            // MouseDown just means the mouse has been pressed down on the button.
            // Dragging means the mouse has moved past the given threshold while MouseDown and we started visually dragging.
            itemInfo.ItemButton.PreviewMouseLeftButtonDown +=
                (s, e) =>
            {
                itemInfo.MouseDown = true;

                itemInfo.InitialMousePosition = Mouse.GetPosition(mainGrid);
            };

            itemInfo.ItemButton.PreviewMouseLeftButtonUp +=
                (s, e) =>
            {
                if (itemInfo.Dragging)
                {
                    RefreshFolder();
                    Config.SaveItems(RootFolder);
                }
                else
                {
                    itemInfo.Item.LeftClick(this);
                }

                itemInfo.MouseDown = false;
                itemInfo.Dragging  = false;

                itemInfo.ItemButton.RenderTransform = Transform.Identity;
                itemInfo.ItemLabel.RenderTransform  = Transform.Identity;
            };

            itemInfo.ItemButton.PreviewMouseMove +=
                (s, e) =>
            {
                if (!itemInfo.MouseDown)
                {
                    return;
                }

                var currentMousePoint = Mouse.GetPosition(mainGrid);

                if (itemInfo.Dragging)
                {
                    // TODO: Constantly creating a bunch of new objects here feels inefficient.
                    var offset = new TranslateTransform(currentMousePoint.X - itemInfo.InitialMousePosition.X, currentMousePoint.Y - itemInfo.InitialMousePosition.Y);

                    itemInfo.ItemButton.RenderTransform = offset;
                    itemInfo.ItemLabel.RenderTransform  = offset;


                    // TODO: Handle item swapping here.
                    System.Windows.Point centerPoint = new System.Windows.Point(mainGrid.Width / 2, mainGrid.Height / 2);
                    double angle = Math.Atan2(currentMousePoint.Y - centerPoint.Y, currentMousePoint.X - centerPoint.X);

                    // Make between $0$ and $2\pi$
                    if (angle < 0)
                    {
                        angle += 2 * Math.PI;
                    }

                    // itemInfo.ItemLabel.Content = angle.ToString();

                    // You're gonna need to draw a picture for this.
                    // Sorry ahead of time.
                    int oldPosition = CurrentFolder.Items.IndexOf(itemInfo.Item);
                    int halfSpaces  = (int)(2 * angle / (2 * Math.PI / CurrentFolder.Items.Count));

                    int newPosition;

                    // Probably will never get strict inequality, but safety for roundoff nonsense.
                    if (halfSpaces <= 0 || halfSpaces >= 2 * CurrentFolder.Items.Count - 1)
                    {
                        newPosition = 0;
                    }
                    else
                    {
                        newPosition = (halfSpaces + 1) / 2;
                    }

                    //itemInfo.ItemLabel.Content = oldPosition.ToString();

                    // Swap oldPosition and newPosition
                    if (newPosition != oldPosition)
                    {
                        if (oldPosition < newPosition)
                        {
                            CurrentFolder.Items.Insert(newPosition + 1, itemInfo.Item);
                            CurrentFolder.Items.RemoveAt(oldPosition);
                        }
                        else     // newPosition < oldPosition
                        {
                            CurrentFolder.Items.Insert(newPosition, itemInfo.Item);
                            CurrentFolder.Items.RemoveAt(oldPosition + 1);
                        }

                        // TODO: The behaviour when "swapping" the last and first items might not be
                        //       exactly what the user expects. Investigate making this more intuitive?

                        RefreshFolder();

                        // Start dragging the new Button that was generated during RefreshFolder().
                        // Here's a cheap way to pull this off. Just replace the new one with the old one.
                        int newInfoIndex = ItemDisplayInfos.FindIndex((s) => { return(s.Item == itemInfo.Item); });

                        mainGrid.Children.Remove(ItemDisplayInfos[newInfoIndex].ItemButton);
                        mainGrid.Children.Remove(ItemDisplayInfos[newInfoIndex].ItemLabel);

                        ItemDisplayInfos[newInfoIndex] = itemInfo;

                        mainGrid.Children.Add(itemInfo.ItemButton);
                        mainGrid.Children.Add(itemInfo.ItemLabel);
                    }
                }
                else
                {
                    if (System.Windows.Point.Subtract(currentMousePoint, itemInfo.InitialMousePosition).Length >= Config.PieItemDragSensitivity)    // TODO: Implement custom tolerances
                    {
                        itemInfo.Dragging = true;
                    }
                }
            };

            // Create the context menu
            MenuItem settingsMenuItem = new MenuItem();

            settingsMenuItem.Header = "Item settings";
            settingsMenuItem.Click +=
                (s, e) =>
            {
                PieItemSettingsWindow pieItemSettingsWindow = new PieItemSettingsWindow(pieItem, CurrentFolder);
                pieItemSettingsWindow.ShowDialog();

                // Replace the old pieItem with the new one
                if (pieItemSettingsWindow.Saved)
                {
                    int i = CurrentFolder.Items.IndexOf(pieItem);

                    // You know, I feel like this should never happen
                    if (i == -1)
                    {
                        return;
                    }

                    CurrentFolder.Items[i] = pieItemSettingsWindow.NewPieItem;
                    RefreshFolder();
                    Config.SaveItems(RootFolder);
                }
            };

            MenuItem removeMenuItem = new MenuItem();

            removeMenuItem.Header = "Remove";
            removeMenuItem.Click +=
                (s, e) =>
            {
                CurrentFolder.Items.Remove(pieItem);
                RefreshFolder();
                Config.SaveItems(RootFolder);
            };

            itemInfo.ItemButton.ContextMenu = new ContextMenu();
            itemInfo.ItemButton.ContextMenu.Items.Add(settingsMenuItem);
            itemInfo.ItemButton.ContextMenu.Items.Add(removeMenuItem);


            //TODO: Figure out transparency of background/border on hover.

            ItemDisplayInfos.Add(itemInfo);
        }
示例#11
0
 public void EditItem(ItemDisplayInfo item)
 {
     CurrentMenu.ContainItemDisplayInfoes.Remove(item);
     UpdateItem();
     eventAggregator.GetEvent <DisplayItemEditClick>().Publish(item);
 }
示例#12
0
 public void EnterToMenu(ItemDisplayInfo item)
 {
     CurrentMenu = item.Menus.ToList <Menu>().FirstOrDefault();
     UpdateItem();
 }
示例#13
0
 public void AddItem(ItemDisplayInfo item)
 {
     item.MenuID = CurrentMenu.ID;
     CurrentMenu.ContainItemDisplayInfoes.Add(item);
     UpdateItem();
 }
示例#14
0
 private void DisplayItemEditClickExecute(ItemDisplayInfo item)
 {
     this.CurrentItemInDesign = item;
     CanEditItem = true;
 }