예제 #1
0
        public static void AddSearchItemList(this MainForm form, ListView listview, Control label, List <ItemClassInfo> items)
        {
            int count = items.Count;

//			form.Info("count="+count);
            listview.BeginUpdate();
            listview.Items.Clear();
            if (label != null)
            {
                label.Text = label.Text.Split(' ')[0] + " (" + count + ")";
            }
            if (count >= 0)
            {
                var vitems = new ListViewItem[count];
                for (int i = 0; i < count; i++)
                {
                    ItemClassInfo t = items[i];
                    vitems[i]             = new ListViewItem();
                    vitems[i].Text        = t.Name ?? t.ItemClass;
                    vitems[i].ToolTipText = t.ToString();
                    vitems[i].Tag         = t;
                    if (i % 2 == 0)
                    {
                        vitems[i].BackColor = Color.GhostWhite;
                    }
                    else
                    {
                        vitems[i].BackColor = Color.White;
                    }
                }
                listview.Items.AddRange(vitems);
            }
            listview.EndUpdate();
//			listview.GoToRow(0);
        }
예제 #2
0
        /// <summary>
        /// 附魔
        /// </summary>
        public static bool ItemEnchant(this MainForm main, Item item, EnchantInfo attribute)
        {
            if (attribute == null || item == null)
            {
                return(false);
            }
            ItemClassInfo info = main.DataHelper.getItemClassInfo(item.ItemClass);

            if (info != null)
            {
                if (!(info.MainCategory == MainCategory.WEAPON ||
                      info.SubCategory == SubCategory.INNERARMOR ||
                      info.MainCategory == MainCategory.CLOTH ||
                      info.MainCategory == MainCategory.LIGHTARMOR ||
                      info.MainCategory == MainCategory.HEAVYARMOR ||
                      info.MainCategory == MainCategory.PLATEARMOR ||
                      info.MainCategory == MainCategory.ACCESSORY))
                {
                    if (!main.Question("该类型[" + info.MainCategory.Name() + "]不适合附魔,确定强制附魔?"))
                    {
                        return(false);
                    }
                }
            }

            ItemAttributeType type = attribute.IsPrefix ? ItemAttributeType.PREFIX : ItemAttributeType.SUFFIX;

            return(ModItemAttr(main, new ItemAttribute(type, attribute.Class).SetArg(attribute.MaxArg), item));
        }
예제 #3
0
        private void AddSearchItemList(List <ItemClassInfo> items)
        {
            int count = items.Count;

            //TODO
            this.list_search.BeginUpdate();
            this.list_search.Items.Clear();
            this.lb_search.Text = this.lb_search.Text.Split(' ')[0] + " (" + count + ")";
            int index = -1;

            if (count >= 0)
            {
                ListViewItem[] vitems = new ListViewItem[count];
                for (int i = 0; i < count; i++)
                {
                    ItemClassInfo t = items[i];
                    vitems[i]             = new ListViewItem();
                    vitems[i].Text        = t.Name == null ? t.ItemClass : t.Name;
                    vitems[i].ToolTipText = t.ToString();
                    vitems[i].Tag         = t;
                    if (i % 2 == 0)
                    {
                        vitems[i].BackColor = Color.GhostWhite;
                    }
                    else
                    {
                        vitems[i].BackColor = Color.White;
                    }
                }
                this.list_search.Items.AddRange(vitems);
            }
            this.list_search.EndUpdate();
            this.list_search.GoToRow(index);
        }
예제 #4
0
 public void Add(ItemClassInfo info)
 {
     if (!Items.TryGetValue(info.ItemClass, out tmp))
     {
         Infos.Add(info);
         Items.Add(info.ItemClass, info);
     }
 }
예제 #5
0
 private void SetCurItems(ItemClassInfo item)
 {
     if (item != null)
     {
         this.tb_senditem_name.Text  = item.Name;
         this.tb_senditem_class.Text = item.ItemClass;
     }
 }
예제 #6
0
        public ItemClassInfo GetItemInfo(string itemclass)
        {
            if (itemclass == null)
            {
                return(null);
            }
            itemclass = itemclass.ToLower();
            ItemClassInfo info = new ItemClassInfo();

            Searcher.Items.TryGetValue(itemclass, out info);
            return(info);
        }
예제 #7
0
        void SetItemClassToolStripMenuItemClick(object sender, EventArgs e)
        {
            if (!CheckUser())
            {
                return;
            }
            ListView listview = GetListView();

            if (listview == null)
            {
                return;
            }
            if (isMailListView())
            {
                Mail mail = listview.GetSelectItem <Mail>();
                if (mail == null)
                {
                    return;
                }
                using (var dlg = new ItemClassDialog(this)){
                    dlg.SetItem(CurUser, null);
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        ItemClassInfo info = dlg.ItemInfo;
                    }
                }
            }
            else
            {
                Item item = listview.GetSelectItem <Item>();
                if (item == null)
                {
                    return;
                }
                using (var dlg = new ItemClassDialog(this)){
                    dlg.SetItem(CurUser, item);
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        ItemClassInfo info = dlg.ItemInfo;
                        if (this.ModItemAttr(new ItemAttribute(ItemAttributeType.LOOK, info.ItemClass), item))
                        {
                            log("修改[" + item.Name + "]外观为[" + info.Name + "]成功");
                        }
                        else
                        {
                            log("修改[" + item.Name + "]外观为[" + info.Name + "]失败");
                        }
                    }
                }
            }
        }
예제 #8
0
 public void SetUserAndItem(User user, ItemClassInfo item)
 {
     if (user == null)
     {
         return;
     }
     this.user = user;
     if (item != null)
     {
         this.item        = item;
         this.ContentText = "";
         this.InputText   = "1";
     }
 }
예제 #9
0
 private void ReadItems(SQLiteHelper db, HeroesTextHelper HeroesText)
 {
     using (DbDataReader reader = db.GetReader("SELECT * FROM ItemClassInfo left join equipiteminfo on ItemClassInfo.itemclass = equipiteminfo.itemclass order by RequiredLevel;"))
     {
         while (reader != null && reader.Read())
         {
             var info = new ItemClassInfo(reader, HeroesText);
             if (!Items.ContainsKey(info.ItemClass))
             {
                 Items.Add(info.ItemClass, info);
             }
         }
     }
 }
예제 #10
0
 private void SendSItem(ItemClassInfo item, int count)
 {
     if (item == null)
     {
         return;
     }
     MessageBox.Show(item.Name);
     using (SendItemDialog dlg = new SendItemDialog(this)){
         dlg.Title = "请输入一个数字(将替换" + item.Name + "的{0})";
         if (dlg.ShowDialog() == DialogResult.OK)
         {
             int var = dlg.Count;
             if (this.SendItem(CurUser, count, item.ItemClass, item.Name, "" + var) > 0)
             {
                 log("发送" + item.Name + "成功");
             }
         }
     }
 }
예제 #11
0
        /// <summary>
        /// 附魔
        /// </summary>
        public static bool ItemEnchant(this MainForm main, Item item, EnchantInfo attribute)
        {
            if (attribute == null || item == null)
            {
                return(false);
            }
            ItemClassInfo info = main.DataHelper.GetItemInfo(item.ItemClass);

            if (info != null)
            {
                if (!(info.MainCategory == MainCategory.WEAPON ||
                      info.SubCategory == SubCategory.INNERARMOR ||
                      info.MainCategory == MainCategory.CLOTH ||
                      info.MainCategory == MainCategory.LIGHTARMOR ||
                      info.MainCategory == MainCategory.HEAVYARMOR ||
                      info.MainCategory == MainCategory.PLATEARMOR ||
                      info.MainCategory == MainCategory.ACCESSORY))
                {
                    if (!main.Question("该类型[" + info.MainCategory.Name() + "]不适合附魔,确定强制附魔?"))
                    {
                        return(false);
                    }
                }
            }

            ItemAttributeType type = attribute.IsPrefix ? ItemAttributeType.PREFIX : ItemAttributeType.SUFFIX;

            return(ModItemAttr(main, new ItemAttribute(type, attribute.Class).SetArg(attribute.MaxArg), item));
//
//			if (db.ExcuteScalarSQL("SELECT COUNT(*) FROM ItemAttribute ia LEFT JOIN Item i ON i.ID = ia.ItemID"
//			                       + " WHERE (ia.Attribute = '" + name + "') AND i.ID =" + item.ItemID) == 0)
//			{
//				return db.ExcuteSQL(string.Concat(new object[] {
//				                                    "INSERT INTO ItemAttribute ([ItemID], [Attribute], [Value], [Arg], [Arg2]) VALUES (",
//				                                    item.ItemID, ", '"+name+"','", attribute.Class, "', '"+attribute.MaxArg+"', '0')" })) > 0;
//			}
//			else if (db.ExcuteSQL("UPDATE ItemAttribute SET [Value] ='"+ attribute.Class+ "',[Arg]='"+ attribute.MaxArg +
//			                      "' WHERE ItemID =" + item.ItemID+ " AND Attribute = '"+name+"'") > 0)
//			{
//				return true;
//			}
//			return false;
        }
예제 #12
0
 protected bool OnCheckName(string text)
 {
     if (mainForm == null)
     {
         mainForm.Error(R.NoUser);
         DialogResult = DialogResult.Cancel;
     }
     else
     {
         info = mainForm.DataHelper.getItemClassInfo(text);
         if (info == null)
         {
             mainForm.Error(R.NoItem);
             return(false);
         }
         if (!Class.IsEnable(info.ClassRestriction))
         {
             mainForm.Error(R.ClassDontUse);
             return(false);
         }
         if (item == null)
         {
             return(!string.IsNullOrEmpty(text));
         }
         if (item.MainCategory == MainCategory.WEAPON)
         {
             if (info.MainCategory != MainCategory.WEAPON)
             {
                 mainForm.Error(string.Format(R.ItemNotIs, info.MainCategory.Name() + "," + info.SubCategory.Name(), MainCategory.WEAPON.Name()));
                 return(false);
             }
             if (item.SubCategory != info.SubCategory)
             {
                 mainForm.Error(string.Format(R.WeaponNotSame, info.MainCategory.Name() + "," + info.SubCategory.Name()));
                 return(false);
             }
         }
         else
         {
             //衣服
             if ((item.SubCategory == SubCategory.BOOTS || item.SubCategory == SubCategory.BOOTS) &&
                 !(info.SubCategory == SubCategory.AVATAR_BOOTS || info.SubCategory == SubCategory.AVATAR_BOOTS))
             {
                 //鞋子
                 mainForm.Error(string.Format(R.ItemNotIs, info.MainCategory.Name() + "," + info.SubCategory.Name(), SubCategory.BOOTS.Name()));
                 return(false);
             }
             if ((item.SubCategory == SubCategory.PANTS || item.SubCategory == SubCategory.PANTS) &&
                 !(info.SubCategory == SubCategory.AVATAR_PANTS || info.SubCategory == SubCategory.AVATAR_PANTS))
             {
                 //鞋子
                 mainForm.Error(string.Format(R.ItemNotIs, info.MainCategory.Name() + "," + info.SubCategory.Name(), SubCategory.PANTS.Name()));
                 return(false);
             }
             if ((item.SubCategory == SubCategory.GLOVES || item.SubCategory == SubCategory.GLOVES) &&
                 !(info.SubCategory == SubCategory.AVATAR_GLOVES || info.SubCategory == SubCategory.AVATAR_GLOVES))
             {
                 //鞋子
                 mainForm.Error(string.Format(R.ItemNotIs, info.MainCategory.Name() + "," + info.SubCategory.Name(), SubCategory.GLOVES.Name()));
                 return(false);
             }
             if ((item.SubCategory == SubCategory.HELM || item.SubCategory == SubCategory.HELM) &&
                 !(info.SubCategory == SubCategory.AVATAR_HELM || info.SubCategory == SubCategory.AVATAR_HELM))
             {
                 //鞋子
                 mainForm.Error(string.Format(R.ItemNotIs, info.MainCategory.Name() + "," + info.SubCategory.Name(), SubCategory.HELM.Name()));
                 return(false);
             }
             if ((item.SubCategory == SubCategory.TUNIC || item.SubCategory == SubCategory.TUNIC) &&
                 !(info.SubCategory == SubCategory.AVATAR_TUNIC || info.SubCategory == SubCategory.AVATAR_TUNIC))
             {
                 //鞋子
                 mainForm.Error(string.Format(R.ItemNotIs, info.MainCategory.Name() + "," + info.SubCategory.Name(), SubCategory.TUNIC.Name()));
                 return(false);
             }
         }
         if (mainForm.Question(string.Format(R.SetLookTip, info.Name)))
         {
             return(true);
         }
     }
     return(false);
 }
예제 #13
0
 void SearchListViewSelectedIndexChanged(object sender, EventArgs e)
 {
     ItemClassInfo item = this.SearchListView.GetSelectItem <ItemClassInfo>();
     //SetCurItems(item);
 }
예제 #14
0
        private void list_search_SelectedIndexChanged(object sender, EventArgs e)
        {
            ItemClassInfo item = this.list_search.GetSelectItem <ItemClassInfo>();

            SetCurItems(item);
        }
예제 #15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="main"></param>
        /// <param name="t"></param>
        /// <param name="info"></param>
        /// <param name="i">位置</param>
        /// <param name="listview"></param>
        /// <param name="selectindex">选择索引</param>
        /// <returns></returns>
        public static ListViewItem GetItemView(this MainForm main, Item t, int i, ListView listview, bool fullname, bool hascolor, bool has2category)
        {
            ListViewItem  vitem = new ListViewItem();
            ItemClassInfo info  = main.DataHelper.GetItemInfo(t.ItemClass);

            t.Attach(info);
            vitem.Tag  = t;
            vitem.Text = (t.ItemName == null ? t.ItemClass : t.ItemName);
            if (fullname && t.Attributes != null)
            {
                string head = "";
                foreach (ItemAttribute attr in t.Attributes)
                {
                    if (attr.Type == ItemAttributeType.ENHANCE)
                    {
                        head = "+" + attr.Value + " ";
                        break;
                    }
                }
                foreach (ItemAttribute attr in t.Attributes)
                {
                    if (attr.Type == ItemAttributeType.SYNTHESISGRADE)
                    {
                        head = "【" + attr.Value.Split('/')[0] + "】";
                        break;
                    }
                }
                foreach (ItemAttribute attr in t.Attributes)
                {
                    if (attr.Type == ItemAttributeType.PREFIX)
                    {
                        EnchantInfo einfo = main.DataHelper.GetEnchant(attr.Value);
                        head += "【" + (einfo == null ? attr.Value : einfo.Name) + "】";
                        break;
                    }
                }
                foreach (ItemAttribute attr in t.Attributes)
                {
                    if (attr.Type == ItemAttributeType.SUFFIX)
                    {
                        EnchantInfo einfo = main.DataHelper.GetEnchant(attr.Value);
                        head += "【" + (einfo == null ? attr.Value : einfo.Name) + "】";
                        break;
                    }
                }
                foreach (ItemAttribute attr in t.Attributes)
                {
                    if (attr.Type == ItemAttributeType.QUALITY)
                    {
                        head += "★" + attr.Arg + " ";
                        break;
                    }
                    else if (attr.Type == ItemAttributeType.VALUE)
                    {
                        vitem.Text = vitem.Text.Replace("{0}", attr.Value);
                    }
                }
                if (!string.IsNullOrEmpty(head))
                {
                    vitem.Text = head + vitem.Text;
                }
            }
            if (i % 2 == 0)
            {
                vitem.BackColor = Color.GhostWhite;
            }
            else
            {
                vitem.BackColor = Color.White;
            }
            vitem.SubItems.Add("" + t.Count);
            if (has2category)
            {
                vitem.SubItems.Add("" + t.MainCategory);
            }
            vitem.SubItems.Add("" + t.SubCategory);
            if (hascolor)
            {
                vitem.UseItemStyleForSubItems = false;
                int colorIndex = vitem.SubItems.Count;
                vitem.SubItems.Add(""); // + (t.Color1 == 0 ? "" : t.Color1.ToString("x")));
                vitem.SubItems.Add(""); // + (t.Color1 == 0 || t.Color2 == 0 ? "" : t.Color2.ToString("x")));
                vitem.SubItems.Add(""); // + (t.Color1 == 0 || t.Color3 == 0 ? "" : t.Color3.ToString("x")));
                vitem.SubItems[colorIndex].BackColor     = t.Color1.GetColor();
                vitem.SubItems[colorIndex + 1].BackColor = t.Color2.GetColor();
                vitem.SubItems[colorIndex + 2].BackColor = t.Color3.GetColor();
                vitem.SubItems[colorIndex].ForeColor     = vitem.SubItems[colorIndex].BackColor;
                vitem.SubItems[colorIndex + 1].ForeColor = vitem.SubItems[colorIndex + 1].BackColor;
                vitem.SubItems[colorIndex + 2].ForeColor = vitem.SubItems[colorIndex + 2].BackColor;
            }
            vitem.SubItems.Add("" + t.Time);
            vitem.ToolTipText = t.ToString();
            return(vitem);
        }