コード例 #1
0
 /// <summary>
 /// Creates a new category, first prompting the user for the name to use. If the name is not valid or in use, displays a notification.
 /// Also updates the UI, and selects the new category in the category combobox.
 /// </summary>
 /// <returns>The category that was added, or null if the operation was canceled or failed.</returns>
 Category CreateCategory()
 {
     GetStringDlg dlg = new GetStringDlg( string.Empty, GlobalStrings.MainForm_CreateCategory, GlobalStrings.MainForm_EnterNewCategoryName, GlobalStrings.MainForm_Create );
     if( dlg.ShowDialog() == DialogResult.OK && CatUtil.ValidateCategoryName( dlg.Value ) ) {
         Category newCat = gameData.AddCategory( dlg.Value );
         if( newCat != null ) {
             OnCategoryChange();
             MakeChange( true );
             AddStatus( string.Format( GlobalStrings.MainForm_CategoryAdded, newCat.Name ) );
             return newCat;
         } else {
             MessageBox.Show( String.Format( GlobalStrings.MainForm_CouldNotAddCategory, dlg.Value ), GlobalStrings.DBEditDlg_Warning, MessageBoxButtons.OK, MessageBoxIcon.Exclamation );
         }
     }
     return null;
 }
コード例 #2
0
        private void RenameAutoCat( AutoCat ac ) {
            if( ac == null ) return;

            bool good = true;
            DialogResult res;
            string name;

            do {
                GetStringDlg dlg = new GetStringDlg( ac.Name, GlobalStrings.DlgAutoCat_RenameBoxTitle, GlobalStrings.DlgAutoCat_RenameBoxLabel, GlobalStrings.DlgAutoCat_RenameBoxButton );
                res = dlg.ShowDialog();
                name = dlg.Value;
                if( string.IsNullOrEmpty( name ) ) {
                    MessageBox.Show( GlobalStrings.DlgAutoCat_MustHaveName );
                    good = false;
                } else if( NameExists( name ) ) {
                    MessageBox.Show( GlobalStrings.DlgAutoCat_NameInUse );
                    good = false;
                }
            } while( res == DialogResult.OK && !good );
            if( res == System.Windows.Forms.DialogResult.OK ) {
                ac.Name = name;
            }
            AutoCatList.Sort();
            FillAutocatList();
        }
コード例 #3
0
 /// <summary>
 /// Renames the given category. Prompts user for a new name. Updates UI. Will display an error if the rename fails.
 /// </summary>
 /// <param name="c">Category to rename</param>
 /// <returns>True if category was renamed, false otherwise.</returns>
 bool RenameCategory()
 {
     if( lstCategories.SelectedItems.Count > 0 ) {
         Category c = lstCategories.SelectedItem as Category;
         if( c != null ) {
             GetStringDlg dlg = new GetStringDlg( c.Name, string.Format( GlobalStrings.MainForm_RenameCategory, c.Name ), GlobalStrings.MainForm_EnterNewName, GlobalStrings.MainForm_Rename );
             if( dlg.ShowDialog() == DialogResult.OK ) {
                 return RenameCategoryHelper( c, dlg.Value );
             }
         }
     }
     return false;
 }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: caballinger/depressurizer
 /// <summary>
 /// Renames the given category. Prompts user for a new name. Updates UI. Will display an error if the rename fails.
 /// </summary>
 /// <param name="c">Category to rename</param>
 /// <returns>True if category was renamed, false otherwise.</returns>
 bool RenameCategory() {
     if( lstCategories.SelectedItems.Count > 0 ) {
         Category c = lstCategories.SelectedItems[0].Tag as Category;
         if( c != null && c != currentProfile.GameData.FavoriteCategory ) {
             GetStringDlg dlg = new GetStringDlg( c.Name, string.Format( GlobalStrings.MainForm_RenameCategory, c.Name ), GlobalStrings.MainForm_EnterNewName, GlobalStrings.MainForm_Rename );
             if( dlg.ShowDialog() == DialogResult.OK ) {
                 string newName = dlg.Value;
                 if( newName == c.Name ) return true;
                 if( ValidateCategoryName( newName ) ) {
                     Category newCat = currentProfile.GameData.RenameCategory( c, newName );
                     if( newCat != null ) {
                         OnCategoryChange();
                         MakeChange( true );
                         for( int index = 2; index < lstCategories.Items.Count; index++ ) {
                             if( lstCategories.Items[index].Tag == newCat ) {
                                 lstCategories.SelectedIndices.Add( index );
                                 break;
                             }
                         }
                         AddStatus( string.Format( GlobalStrings.MainForm_CategoryRenamed, c.Name ) );
                         return true;
                     }
                 }
                 MessageBox.Show( string.Format( GlobalStrings.MainForm_NameIsInUse, newName ), GlobalStrings.Gen_Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning );
                 return false;
             }
         }
     }
     return false;
 }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: caballinger/depressurizer
        /// <summary>
        /// Creates a new category, first prompting the user for the name to use. If the name is not valid or in use, displays a notification.
        /// </summary>
        /// <returns>The category that was added, or null if the operation was canceled or failed.</returns>
        Category CreateCategory() {
            if( !ProfileLoaded ) return null;

            GetStringDlg dlg = new GetStringDlg( string.Empty, GlobalStrings.MainForm_CreateCategory, GlobalStrings.MainForm_EnterNewCategoryName, GlobalStrings.MainForm_Create );
            if( dlg.ShowDialog() == DialogResult.OK && ValidateCategoryName( dlg.Value ) ) {
                Category newCat = currentProfile.GameData.AddCategory( dlg.Value );
                if( newCat != null ) {
                    OnCategoryChange();
                    MakeChange( true );
                    AddStatus( string.Format( GlobalStrings.MainForm_CategoryAdded, newCat.Name ) );
                    return newCat;
                } else {
                    MessageBox.Show( String.Format( GlobalStrings.MainForm_CouldNotAddCategory, dlg.Value ), GlobalStrings.Gen_Error, MessageBoxButtons.OK, MessageBoxIcon.Exclamation );
                }
            }
            return null;
        }
コード例 #6
0
ファイル: MainForm.cs プロジェクト: Theo47/depressurizer
        private void SaveFilter()
        {
            if ((!ProfileLoaded) || (!AdvancedCategoryFilter)) return;

            GetStringDlg dlg = new GetStringDlg(cboFilter.Text, GlobalStrings.MainForm_SaveFilter, GlobalStrings.MainForm_EnterNewFilterName, GlobalStrings.MainForm_Save);
            if (dlg.ShowDialog() == DialogResult.OK && ValidateFilterName(dlg.Value))
            {

                Filter f;
                bool refresh = true;
                if (currentProfile.GameData.FilterExists(dlg.Value))
                {
                    DialogResult res = MessageBox.Show(String.Format(GlobalStrings.MainForm_OverwriteFilterName, dlg.Value), GlobalStrings.MainForm_Overwrite, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

                    if (res == DialogResult.Yes)
                    {
                        f = currentProfile.GameData.GetFilter(dlg.Value);
                        refresh = false;
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    f = currentProfile.GameData.AddFilter(dlg.Value);
                }
                if (f != null)
                {
                    f.Uncategorized = advFilter.Uncategorized;
                    f.Hidden = advFilter.Hidden;
                    f.Allow = advFilter.Allow;
                    f.Require = advFilter.Require;
                    f.Exclude = advFilter.Exclude;
                    if (refresh)
                    {
                        AddStatus(string.Format(GlobalStrings.MainForm_FilterAdded, f.Name));
                        RefreshFilters();
                        cboFilter.SelectedItem = f;
                    }
                }
                else
                {
                    MessageBox.Show(String.Format(GlobalStrings.MainForm_CouldNotAddFilter, dlg.Value), GlobalStrings.Gen_Error, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
コード例 #7
0
ファイル: MainForm.cs プロジェクト: Theo47/depressurizer
 private void RenameFilter(Filter f)
 {
     if (AdvancedCategoryFilter)
     {
         GetStringDlg dlg = new GetStringDlg(f.Name, string.Format(GlobalStrings.MainForm_RenameFilter, f.Name), GlobalStrings.MainForm_EnterNewName, GlobalStrings.MainForm_Rename);
         if (dlg.ShowDialog() == DialogResult.OK && f.Name != dlg.Value)
         {
             if (currentProfile.GameData.FilterExists(dlg.Value))
             {
                 MessageBox.Show(GlobalStrings.MainForm_FilterExists, GlobalStrings.Gen_Warning, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 return;
             }
             f.Name = dlg.Value;
             RefreshFilters();
             cboFilter.SelectedItem = f;
             cboFilter.Text = f.Name;
         }
     }
 }