private void RevertButton_Click(object sender, RoutedEventArgs e)
        {
            Button  l1 = sender as Button;
            Grid    l2 = l1.Parent as Grid;
            ListBox l3 = l2.Parent as ListBox;

            if (!StatusSteps.Count.Equals(0))
            {
                myItem BackItem = StatusSteps[StatusSteps.Count - 1];
                OrderMenu.Items.Insert(OrderMenu.Items.Count - 1, BackItem);
                StatusSteps.RemoveAt(StatusSteps.Count - 1);

                if (GlobalInfo.isItemSpecial(BackItem.IName))
                {
                    return;
                }

                bool isContain = false;
                foreach (var cg in GlobalInfo.TotalOrderListBox.Items)
                {
                    try
                    {
                        if ((cg as CountGrid).linkItem.IName.Equals(BackItem.IName))
                        {
                            (cg as CountGrid).KindCount += BackItem.Count;
                            isContain = true;
                            break;
                        }
                    }
                    catch
                    {
                    }
                }

                if (!isContain)
                {
                    GlobalInfo.TotalOrderListBox.Items.Add(new CountGrid(BackItem));
                }
            }
            ;
        }
        private void previewMouseLeftButtonUP(object sender, object EventArgs)
        {
            myItem CastSender = ((sender as Viewbox).Parent as Grid).Parent as myItem;

            (CastSender.Parent as ListBox).Items.Remove(CastSender);

            StatusSteps.Add(CastSender);

            int t = GlobalInfo.TotalOrderListBox.Items.Count;

            for (int i = 0; i < t; i++)
            {
                var P = GlobalInfo.TotalOrderListBox.Items[i] as CountGrid;

                if (P.linkItem.IName.Equals(CastSender.IName))
                {
                    P.KindCount -= CastSender.Count;

                    if (P.KindCount == 0)
                    {
                        GlobalInfo.TotalOrderListBox.Items.Remove(P);
                    }
                    break;
                }
            }

            /*CountGrid countGrid = new CountGrid(CastSender);
             *
             * if (countGrid.ifContain(CastSender))
             * {
             *
             * }*/
            /*
             * var Castsender = sender as myItem;
             *
             * (Castsender.Parent as ListBox).Items.Remove(Castsender);
             *
             * TextBlock tb = (Castsender.Children[0] as Viewbox).Child as TextBlock;
             *
             * StatusSteps.Add(Castsender);
             *
             * int Cnt = GlobalInfo.TotalOrderListBox.Items.Count;
             *
             * for (int i = 0; i < Cnt; i++)
             * {
             *  Grid gd = GlobalInfo.TotalOrderListBox.Items[i] as Grid;
             *  TextBlock Nbk = gd.Children[1] as TextBlock;
             *  TextBlock Cbk = gd.Children[2] as TextBlock;
             *
             *  string tryc = tb.Text;
             *
             *  if (tryc.Contains("(招)")) tryc = tryc.Substring(3);
             *
             *  try
             *  {
             *      if (GlobalInfo.SpecialItem.Contains(tryc.Substring(0, Nbk.Text.Length - 4)) && tryc.Length > 4)
             *          continue;
             *  }
             *  catch
             *  {
             *      ;
             *  }
             *
             *  int Count = int.Parse(Cbk.Text);
             *
             *  if (Nbk.Text.Equals(tryc))
             *  {
             *      Count--;
             *      Cbk.Text = Count.ToString();
             *  }
             *
             *  if (Count <= 0)
             *  {
             *      GlobalInfo.TotalOrderListBox.Items.Remove(Cbk.Parent as Grid);
             *      break;
             *  }
             * }*/
        }
예제 #3
0
 public void AddItem(myItem item) => Items.Add(item);
예제 #4
0
 public void removeItem(myItem item) => Items.Remove(item);
예제 #5
0
        public CountGrid(myItem item)
        {
            string localpack = "pack://siteoforigin:,,,/";

            BorderThickness = new Thickness(0, 0, 0, 1);
            BorderBrush     = Brushes.Gray;

            Width        = 550;
            Picbk.Height = 58;

            linkItem = item;

            string hAndle   = item.IName;
            string PickBase = "";

            if (hAndle.Contains("(招)"))
            {
                hAndle = hAndle.Substring(3);
            }

            if (hAndle.Contains("*"))
            {
                hAndle = hAndle.Substring(0, hAndle.IndexOf("*"));
            }

            Picbk.Stretch = Stretch.Uniform;

            foreach (string k in GlobalInfo.ImageNameList)
            {
                string px = k.Substring(3);
                px = px.Substring(0, px.IndexOf("."));

                if (px.Equals(hAndle))
                {
                    PickBase = k;
                    break;
                }
            }

            //MessageBox.Show(PickBase);

            try
            {
                BitmapImage img = new BitmapImage();

                Uri uri = new Uri(localpack + PickBase);
                img.BeginInit();
                img.UriSource = uri;
                img.EndInit();

                Picbk.Source = img;
            }
            catch
            {
                //MessageBox.Show("error");
                Console.WriteLine("找不到圖片");
            }

            Grid R = new Grid();

            ColumnDefinition c1 = new ColumnDefinition();

            c1.Width = new GridLength(4, GridUnitType.Star);
            ColumnDefinition c2 = new ColumnDefinition();

            c2.Width = new GridLength(9, GridUnitType.Star);
            ColumnDefinition c3 = new ColumnDefinition();

            c3.Width = new GridLength(3, GridUnitType.Star);

            R.ColumnDefinitions.Add(c1);
            R.ColumnDefinitions.Add(c2);
            R.ColumnDefinitions.Add(c3);

            R.Children.Add(Picbk);
            R.Children.Add(Namebk);
            R.Children.Add(Countbk);

            Grid.SetColumn(Namebk, 1);
            Grid.SetColumn(Countbk, 2);

            Namebk.Text                = linkItem.IName;
            Namebk.FontSize            = 44;
            Namebk.HorizontalAlignment = HorizontalAlignment.Center;
            Namebk.VerticalAlignment   = VerticalAlignment.Center;

            if (linkItem.IName.Contains("(招)"))
            {
                Namebk.Text = Namebk.Text.Substring(3);
            }

            Countbk.Text                = linkItem.Count.ToString();
            Countbk.FontSize            = 44;
            Countbk.Foreground          = Brushes.RoyalBlue;
            Countbk.HorizontalAlignment = HorizontalAlignment.Center;
            Countbk.VerticalAlignment   = VerticalAlignment.Center;

            Child = R;

            /*if (!reverse)
             *  GlobalInfo.TotalOrderListBox.Items.Insert(GlobalInfo.TotalOrderListBox.Items.Count, this);
             * else
             *  GlobalInfo.TotalOrderListBox.Items.Insert(1, this);*/
        }