Ejemplo n.º 1
0
        private void btnMoveDown_Click(object sender, System.EventArgs e)
        {
            //Move script down
            var rows = dataGridView1.SelectedRows;

            if (rows != null && rows.Count == 1)
            {
                if (CurrentConfig.AutoRunScripts.Count > 1)
                {
                    AutorunScriptConfigItem item = (AutorunScriptConfigItem)rows[0].DataBoundItem;
                    int ind   = CurrentConfig.AutoRunScripts.IndexOf(item);
                    int count = CurrentConfig.AutoRunScripts.Count;
                    if (ind < count - 1)
                    {
                        dataGridView1.DataSource = null;
                        item.Order = item.Order + 1;
                        CurrentConfig.AutoRunScripts[ind + 1].Order = CurrentConfig.AutoRunScripts[ind + 1].Order - 1;

                        CurrentConfig.AutoRunScripts.Sort((a, b) => a.Order.CompareTo(b.Order));

                        dataGridView1.DataSource = CurrentConfig.AutoRunScripts;
                        dataGridView1.Refresh();
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private void btnView_Click(object sender, System.EventArgs e)
 {
     //Open the Config file in the New Script window on main Form
     if (dataGridView1.SelectedCells.Count > 0)
     {
         var rowIndex = dataGridView1.SelectedCells[0].RowIndex;
         //Get the row, calculate absolute path of the script and open it in main window
         AutorunScriptConfigItem item = (AutorunScriptConfigItem)dataGridView1.Rows[rowIndex].DataBoundItem;
         string fullPath = ConfigUtils.GetFullPathToConfigFile(item.Path);
         SPCoderForm.MainForm.GenerateNewSourceTab(item.Title, item.Source, fullPath);
     }
 }
Ejemplo n.º 3
0
        private void btnDelete_Click(object sender, System.EventArgs e)
        {
            var rows = dataGridView1.SelectedRows;

            if (rows != null && rows.Count == 1)
            {
                AutorunScriptConfigItem item = (AutorunScriptConfigItem)rows[0].DataBoundItem;
                var result = MessageBox.Show(string.Format("Are you sure that you want to delete '{0}' autorun script?", item.Title)
                                             , "Delete autorun script", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    dataGridView1.DataSource = null;
                    CurrentConfig.AutoRunScripts.Remove(item);
                    ReorderItems();

                    //Refresh data in grid
                    dataGridView1.DataSource = CurrentConfig.AutoRunScripts;
                    dataGridView1.Refresh();
                }
            }
        }