/// <summary>
        /// Initializes a progress view.
        /// </summary>
        /// <param name="_ir">The item recipe to have the progress view to track.</param>
        public ItemProgressView(ItemRecipe _ir)
        {
            ir = _ir;
            try
            {
                InitializeComponent();
            }
            catch (System.Windows.Markup.XamlParseException ex)
            {
                MessageBox.Show(ex.InnerException.Message);
            }
            update();
            t.Elapsed  += t_Elapsed;
            t.AutoReset = true;
            t.Start();
            if (ir.aquireIcons.Count == 1)
            {
                t.Stop();
                CraftingIcons.Source = getNextCraftingIcon();
            }

            costTimer.Elapsed  += cost_Elapsed;
            costTimer.AutoReset = true;
            costTimer.Start();
            EstimatedCost.Content = "";
        }
示例#2
0
        private ItemRecipe getSubItemsInRecipe(uint itemID, uint count, uint previousItemCount, TreeNode parentNode)
        {
            UInt64     randomized = random.NextUInt64();
            TreeNode   myNode     = new TreeNode();
            ItemRecipe ir         = new ItemRecipe();
            Recipe     r          = new Recipe();
            Item       i          = list.getItem(itemID);

            if (parentNode == null)
            {
                Invoke((MethodInvoker) delegate
                {
                    parentNode = myNode = itemList.Nodes.Add(i.name + randomized.ToString(), i.name);
                    addItemStatusLabel.Text = "Adding Item To List: " + i.name;
                });
            }
            else
            {
                Invoke((MethodInvoker) delegate
                {
                    myNode = parentNode.Nodes.Add(i.name + randomized.ToString(), i.name);
                    addItemStatusLabel.Text = "Adding Item: \"" + i.name + "\" To Parent: " + parentNode.Text;
                });
            }
            temporaryItemProject.Add(myNode.Name, ir);
            ir.name       = i.name;
            ir.itemID     = itemID;
            ir.itemIcon   = i.icon;
            ir.count      = count;
            ir.totalCount = previousItemCount * count;
            ir.current    = 0;

            // getTpCost

            var v = recipe.requestRecipe(itemID, false);

            if (v.Count != 0)
            {
                if (v.Count > 1)
                {
                    //show list and let user chose the recipe
                    //for now add the first one that pops up
                    ir.requiredItems = addItemsFromRecipe(v[0], false, ir.totalCount, ir, myNode);
                }
                else
                {
                    ir.requiredItems = addItemsFromRecipe(v[0], false, ir.totalCount, ir, myNode);
                }
            }
            else // check gw2profits for a recipe
            {
                ir.requiredItems = addItemsFromRecipe(ir.itemID, true, ir.totalCount, ir, myNode);
            }
            return(ir);
        }
示例#3
0
 private void itemList_AfterSelect(object sender, TreeViewEventArgs e)
 {
     if (e.Node.FullPath.Contains("\\"))
     {
         itemCount.Enabled = false;
     }
     else
     {
         itemCount.Enabled = true;
     }
     editItem            = temporaryItemProject[e.Node.Name];
     itemCount.Value     = editItem.count;
     itemCountTotal.Text = editItem.totalCount.ToString();
 }
        private Dictionary <string, ItemRecipe> getSubRecipes(ItemRecipe sub, ref TreeNode tn, Random random)
        {
            Dictionary <string, ItemRecipe> _items = new Dictionary <string, ItemRecipe>();
            string n = name + random.NextUInt64().ToString();

            _items.Add(n, sub);
            TreeNode subNode = tn.Nodes.Add(n, sub.name);

            foreach (ItemRecipe ir in sub.requiredItems)
            {
                var subs = getSubRecipes(ir, ref subNode, random);
                foreach (var v in subs)
                {
                    _items.Add(v.Key, v.Value);
                }
            }
            return(_items);
        }
示例#5
0
        private void AddItemWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;
            bool             isdone = false;

            while (!isdone)
            {
                Thread.Sleep(70);
                if (worker.CancellationPending)
                {
                    e.Cancel = true;
                    Logger.Logger.Log("Canceling adding items", Logger.Logger.MessageType.Info);
                    return;
                }
                if (additemStrings.Count != 0)
                {
                    ItemRecipe ir = getSubItemsInRecipe(uint.Parse(additemStrings[0]), 1, 1, null);
                    additemStrings.RemoveAt(0);
                }
                else
                {
                    try
                    {
                        Invoke((MethodInvoker) delegate
                        {
                            addItemStatusLabel.Text = "";
                        });
                    }
                    catch (InvalidOperationException)
                    {
                        Logger.Logger.Log("Invalid operation setting statusLabel", Logger.Logger.MessageType.Info);
                        return;
                    }
                }
            }
        }
示例#6
0
        private List <ItemRecipe> addItemsFromRecipe(uint recipeID, bool useGW2Profits, uint previousItemCount, ItemRecipe parentRecipe, TreeNode parent)
        {
            List <ItemRecipe> ir       = new List <ItemRecipe>();
            Recipe            myrecipe = new Recipe();

            if (!useGW2Profits)
            {
                myrecipe = recipe.requestRecipeInfo(recipeID);
            }
            else
            {
                var recipes = recipe.requestMysticForgeRecipe(recipeID);
                if (recipes.Count != 0)
                {
                    // make a recipe selector here.
                    if (recipes.Count > 1)
                    {
                        myrecipe = recipes[0];
                    }
                    else
                    {
                        myrecipe = recipes[0];
                    }
                }
            }
            if (myrecipe.disciplines != null)
            {
                parentRecipe.aquireIcons = myrecipe.disciplines;
            }
            // sets recipe to null if it contains the same id as parent
            if (myrecipe.ingredients != null)
            {
                if (myrecipe.ingredients.Select(x => x.ID).ToList().Contains((int)recipeID))
                {
                    myrecipe = null;
                    parentRecipe.aquireIcons.Clear();
                }
            }
            if (myrecipe != null && myrecipe.disciplines != null)
            {
                if (myrecipe.ingredients != null)
                {
                    foreach (Ingredient ingr in myrecipe.ingredients)
                    {
                        if (ingr.ID > 0)
                        {
                            ir.Add(getSubItemsInRecipe((uint)ingr.ID, ingr.count, previousItemCount, parent));
                        }
                    }
                }
            }
            return(ir);
        }