Esempio n. 1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
ask:
            MultiFieldInputView_Dialog mfiv = new MultiFieldInputView_Dialog(new string[4] {
                "", "1", "100", "1"
            });

            if (mfiv.ShowDialog(new string[4] {
                LocalizationManager.Current.Simulation["Inventory"]["Item_ID"], LocalizationManager.Current.Simulation["Inventory"]["Item_Amount"], LocalizationManager.Current.Simulation["Inventory"]["Item_Quality"], LocalizationManager.Current.Simulation["Inventory"]["Item_Count"]
            }, LocalizationManager.Current.Simulation["Inventory"]["Item_Add"]) == true)
            {
                string[] values = mfiv.Values;
                if (ushort.TryParse(values[0], out ushort itemID) &&
                    byte.TryParse(values[1], out byte itemAmount) &&
                    byte.TryParse(values[2], out byte itemQuality) &&
                    byte.TryParse(values[3], out byte itemCount))
                {
                    for (int k = 0; k < itemCount; k++)
                    {
                        Simulation.Item i = new Simulation.Item()
                        {
                            ID      = itemID,
                            Amount  = itemAmount,
                            Quality = itemQuality
                        };
                        Items.Add(i);
                        list.Items.Add(i);
                    }
                }
                else
                {
                    goto ask;
                }
            }
        }
Esempio n. 2
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
ask:
            MultiFieldInputView_Dialog mfiv = new MultiFieldInputView_Dialog();

            if (mfiv.ShowDialog(new string[2] {
                LocalizationManager.Current.Simulation["Inventory"]["Item_ID"], LocalizationManager.Current.Simulation["Inventory"]["Item_Remove_Count"]
            }, LocalizationManager.Current.Simulation["Inventory"]["Item_Remove"]) == true)
            {
                string[] values = mfiv.Values;
                if (ushort.TryParse(values[0], out ushort itemID) && byte.TryParse(values[1], out byte itemAmount))
                {
                    List <Simulation.Item> found = Items.Where(d => d.ID == itemID).Take(itemAmount).ToList();
                    for (int i = 0; i < found.Count; i++)
                    {
                        Items.Remove(found[i]);
                    }

                    list.Items.Clear();

                    foreach (var i in Items)
                    {
                        list.Items.Add(i);
                    }
                }
                else
                {
                    goto ask;
                }
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
ask:
            MultiFieldInputView_Dialog mfiv = new MultiFieldInputView_Dialog();

            if (mfiv.ShowDialog(new string[2] {
                LocalizationManager.Current.Simulation["Flags"]["Flag_ID"], LocalizationManager.Current.Simulation["Flags"]["Flag_Value"]
            }, LocalizationManager.Current.Simulation["Flags"]["Flag_Set"]) == true)
            {
                string[] values = mfiv.Values;
                if (ushort.TryParse(values[0], out ushort flagID) && short.TryParse(values[1], out short flagValue))
                {
                    Flags[flagID] = flagValue;
                    list.Items.Add(new KeyValuePair <ushort, short>(flagID, flagValue));
                }
                else
                {
                    goto ask;
                }
            }
        }