Exemplo n.º 1
0
        private void EditSelectedScriptItem(ListView focusedListView)
        {
            var datasource = (ArrangeableList <INamed>)focusedListView.Tag;

            var editForm = new frmAddEditScript();

            editForm.MethodToGetErrorsOnItemInformation = _scriptsAppData.CheckForErrorsOnName;
            editForm.ItemInformation = (Script)focusedListView.SelectedItems[0].Tag;

            var dialogResult = editForm.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                var selectedIndices = focusedListView.SelectedIndices.Cast <int>().ToList();
                datasource.ReplaceAt(focusedListView.SelectedIndices[0], editForm.ItemInformation);
                PopulateListView(datasource, focusedListView, selectedIndices);
            }
        }
Exemplo n.º 2
0
        private void AddNewScriptItem(ListView focusedListView)
        {
            var addForm = new frmAddEditScript();

            addForm.MethodToGetErrorsOnItemInformation = _scriptsAppData.CheckForErrorsOnName;
            var dialogResult = addForm.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                var scriptList = ((ArrangeableList <INamed>)_scriptsAppData.Instances);
                if (scriptList == null)
                {
                    scriptList = new ArrangeableList <INamed>();
                    _scriptsAppData.Instances = scriptList;
                }
                scriptList.Add(addForm.ItemInformation);

                var selectedIndices = focusedListView.SelectedIndices.Cast <int>().ToList();
                PopulateListView(scriptList, focusedListView, selectedIndices);
            }
        }