static void Restore(CSSToolbar toolbar) { try { if (toolbar.IsIdeInstalled && toolbar.IsInstalled && toolbar.IsRestoreAvailable) { toolbar.RestoreOldSettings(); } } catch (Exception e) { Console.WriteLine("VS toolbar cannot be created:\n" + e.Message); } }
static void Install(CSSToolbar toolbar) { try { if (toolbar.IsIdeInstalled && !toolbar.IsInstalled) { toolbar.Install(); } } catch (Exception e) { Console.WriteLine("VS toolbar cannot be created:\n" + e.Message); } }
void RefreshLayout() { CSSToolbar[] toolbars = new CSSToolbar[] { vsToolbar, vsExpressToolbar, vs9Toolbar, vsExpress9Toolbar, vs10Toolbar, vsExpress10Toolbar, vs12Toolbar, vsExpress12Toolbar }; IVSCodeSnippet[] snippets = new IVSCodeSnippet[] { vsCodeSnippet, vsExpressCodeSnippet, vs9CodeSnippet, vsExpress9CodeSnippet, vs10CodeSnippet, vsExpress10CodeSnippet, vs12CodeSnippet, vsExpress12CodeSnippet }; for (int i = 0; i < 8; i++) { CSSToolbar toolbar = toolbars[i]; IVSCodeSnippet snippet = snippets[i]; bool installed = toolbar.IsInstalled; dataGridView1.Rows[i].Cells[toolbarInstalledCol].Value = installed; (dataGridView1.Rows[i].Cells[toolbarInsertActionCol] as DataGridViewDisableButtonCell).Enabled = toolbar.IsIdeInstalled && !installed; (dataGridView1.Rows[i].Cells[toolbarImportActiondCol] as DataGridViewDisableButtonCell).Enabled = toolbar.IsIdeInstalled && !installed; (dataGridView1.Rows[i].Cells[toolbarRemoveActiondCol] as DataGridViewDisableButtonCell).Enabled = toolbar.IsIdeInstalled && installed && toolbar.IsRestoreAvailable; //(dataGridView1.Rows[i].Cells[7] as DataGridViewDisableButtonCell).Enabled = toolbar.IsIdeInstalled; //if (!(dataGridView1.Rows[i].Cells[7] as DataGridViewDisableButtonCell).Enabled) // dataGridView1.Rows[i].Cells[7].Value = ""; //else // dataGridView1.Rows[i].Cells[7].Value = snippet.IsInstalled ? removeCaption : installCaption; for (int j = 0; j < 7; j++) { if (dataGridView1.Rows[i].Cells[j].Value.ToString() == naCaption && dataGridView1.Rows[i].Cells[j] is DataGridViewDisableButtonCell) { (dataGridView1.Rows[i].Cells[j] as DataGridViewDisableButtonCell).Enabled = false; } } dataGridView1.Rows[i].Cells[toolbarInsertActionCol].ToolTipText = "Insert CS-Script toolbar by modifying IDE settings (.vssettings file) directly.\nYou will be able to undo this action by pressing Remove button."; dataGridView1.Rows[i].Cells[toolbarImportActiondCol].ToolTipText = "Insert CS-Script toolbar by importing (custom .vssettings file). Safer but less reliable option.\nYou will be able to undo this action by pressing Remove button"; //dataGridView1.Rows[i].Cells[6].ToolTipText = "Install CS-Script Code Snippet"; } Refresh(); }
static void Restore(CSSToolbar toolbar) { try { if (toolbar.IsIdeInstalled && toolbar.IsInstalled && toolbar.IsRestoreAvailable) toolbar.RestoreOldSettings(); } catch (Exception e) { Console.WriteLine("VS toolbar cannot be created:\n" + e.Message); } }
static void Install(CSSToolbar toolbar) { try { if (toolbar.IsIdeInstalled && !toolbar.IsInstalled) toolbar.Install(); } catch (Exception e) { Console.WriteLine("VS toolbar cannot be created:\n" + e.Message); } }
void RefreshLayout() { CSSToolbar[] toolbars = new CSSToolbar[] { vsToolbar, vsExpressToolbar, vs9Toolbar, vsExpress9Toolbar, vs10Toolbar, vsExpress10Toolbar }; IVSCodeSnippet[] snippets = new IVSCodeSnippet[] { vsCodeSnippet, vsExpressCodeSnippet, vs9CodeSnippet, vsExpress9CodeSnippet, vs10CodeSnippet, vsExpress10CodeSnippet }; for (int i = 0; i < 6; i++) { CSSToolbar toolbar = toolbars[i]; IVSCodeSnippet snippet = snippets[i]; bool installed = toolbar.IsInstalled; dataGridView1.Rows[i].Cells[toolbarInstalledCol].Value = installed; (dataGridView1.Rows[i].Cells[toolbarInsertActionCol] as DataGridViewDisableButtonCell).Enabled = toolbar.IsIdeInstalled && !installed; (dataGridView1.Rows[i].Cells[toolbarImportActiondCol] as DataGridViewDisableButtonCell).Enabled = toolbar.IsIdeInstalled && !installed; (dataGridView1.Rows[i].Cells[toolbarRemoveActiondCol] as DataGridViewDisableButtonCell).Enabled = toolbar.IsIdeInstalled && installed && toolbar.IsRestoreAvailable; //(dataGridView1.Rows[i].Cells[7] as DataGridViewDisableButtonCell).Enabled = toolbar.IsIdeInstalled; //if (!(dataGridView1.Rows[i].Cells[7] as DataGridViewDisableButtonCell).Enabled) // dataGridView1.Rows[i].Cells[7].Value = ""; //else // dataGridView1.Rows[i].Cells[7].Value = snippet.IsInstalled ? removeCaption : installCaption; for (int j = 0; j < 7; j++) if (dataGridView1.Rows[i].Cells[j].Value.ToString() == naCaption && dataGridView1.Rows[i].Cells[j] is DataGridViewDisableButtonCell) (dataGridView1.Rows[i].Cells[j] as DataGridViewDisableButtonCell).Enabled = false; dataGridView1.Rows[i].Cells[toolbarInsertActionCol].ToolTipText = "Insert CS-Script toolbar by modifying IDE settings (.vssettings file) directly.\nYou will be able to undo this action by pressing Remove button."; dataGridView1.Rows[i].Cells[toolbarImportActiondCol].ToolTipText = "Insert CS-Script toolbar by importing (custom .vssettings file). Safer but less reliable option.\nYou will be able to undo this action by pressing Remove button"; //dataGridView1.Rows[i].Cells[6].ToolTipText = "Install CS-Script Code Snippet"; } Refresh(); }