コード例 #1
0
        private void btnSelect_Click(object sender, EventArgs e)
        {
            DbBrowser db = new DbBrowser();

            using (ItemSelector poetSeletor = new ItemSelector("انتخاب شاعر", db.Poets.ToArray(), null))
            {
                if (poetSeletor.ShowDialog(this) == DialogResult.OK)
                {
                    GanjoorPoet poet = poetSeletor.SelectedItem as GanjoorPoet;
                    PoetId = poet._ID;
                    txtSelectedPoetOrCategory.Text = poet._Name;
                    if (MessageBox.Show(
                            $"آیا تمایل دارید خوانش‌های بخش خاصی از آثار {poet._Name} را دریافت کنید؟",
                            "تأییدیه", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2,
                            MessageBoxOptions.RtlReading | MessageBoxOptions.RightAlign) == System.Windows.Forms.DialogResult.No)
                    {
                        db.CloseDb();

                        return;
                    }
                    using (CategorySelector catSelector = new CategorySelector(poet._ID, db))
                    {
                        if (catSelector.ShowDialog(this) == DialogResult.OK)
                        {
                            CatId = catSelector.SelectedCatID;
                            txtSelectedPoetOrCategory.Text = $"{poet._Name} » {db.GetCategory(CatId)._Text}";
                            db.CloseDb();
                        }
                    }
                }
            }
        }
コード例 #2
0
        private void btnAddWeapon_Click(object sender, EventArgs e)
        {
            ItemSelectionChoice = ItemSelectionChoices.AddWeapon;
            IEnumerable <ItemContainer> Items = GetItemsByRoot(GUIRootPathTripleThunderWeapons);
            MenuFilter OutMenu = new MenuFilter();

            OutMenu.ListItem = new Dictionary <string, string>();

            foreach (ItemContainer ActiveItemContainer in Items)
            {
                foreach (KeyValuePair <string, string> ActiveItem in ActiveItemContainer.ListItem)
                {
                    string Name = FilePath.Substring(29);
                    Name = Name.Substring(0, Name.Length - 4);

                    if (ActiveItem.Key.StartsWith(Name))
                    {
                        if (ActiveItem.Key.StartsWith(Name + "/Weapons"))
                        {
                            string WeaponName = ActiveItem.Key.Substring(24);
                            OutMenu.ListItem.Add(WeaponName, WeaponName);
                        }
                        else if (ActiveItem.Key.StartsWith(Name + "/Grenades"))
                        {
                            string WeaponName = ActiveItem.Key.Substring(25);
                            OutMenu.ListItem.Add(WeaponName, WeaponName);
                        }
                    }
                }
            }

            ItemSelector ItemSelectorMenu = new ItemSelector(OutMenu, true);

            ItemSelectorMenu.TopMost = true;
            ItemSelectorMenu.ShowDialog();
            //Item selected, call the ItemsSelected method.
            if (ItemSelectorMenu.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                ListMenuItemsSelected(ItemSelectorMenu.GetResult());
            }
        }