private void Delete()
        {
            if (_projectControl.SelectedProjectItem.Type == ProjectItemType.Root)
            {
                return;
            }

            if (TaskDialogEx.Show(this, "Are you sure you want to delete this item?", Text, TaskDialogCommonButtons.Yes | TaskDialogCommonButtons.No, TaskDialogIcon.Warning) != DialogResult.Yes)
            {
                return;
            }

            string path = _projectControl.SelectedProjectItem.Path;

            FindEditor(path)?.Close();

            if (File.Exists(path))
            {
                File.Delete(path);
            }
            else if (Directory.Exists(path))
            {
                Directory.Delete(path, true);
            }
        }
        private void _acceptButton_Click(object sender, EventArgs e)
        {
            if (_name.Text.Length == 0)
            {
                TaskDialogEx.Show(this, "Please enter a name", Text, TaskDialogCommonButtons.OK, TaskDialogIcon.Warning);
            }
            else if (!Directory.Exists(_location.Text))
            {
                TaskDialogEx.Show(this, "Please select a valid location", Text, TaskDialogCommonButtons.OK, TaskDialogIcon.Warning);
            }
            else
            {
                var fullPath = Path.Combine(_location.Text, _name.Text);
                if (Directory.Exists(fullPath))
                {
                    TaskDialogEx.Show(this, $"The directory {fullPath} already exists", Text, TaskDialogCommonButtons.OK, TaskDialogIcon.Warning);
                }
                else
                {
                    using (var key = Program.BaseKey)
                    {
                        key.SetValue("Last Project Location", _location.Text);
                    }

                    DialogResult = DialogResult.OK;
                }
            }
        }
        private bool CloseProject()
        {
            if (Editors.Any(p => p.IsDirty))
            {
                var result = TaskDialogEx.Show(this, "Do you want to save your changes?", Text, TaskDialogCommonButtons.Yes | TaskDialogCommonButtons.No | TaskDialogCommonButtons.Cancel, TaskDialogIcon.Warning);

                switch (result)
                {
                case DialogResult.Yes:
                    if (Editors.Any(p => !p.Save()))
                    {
                        return(false);
                    }
                    break;

                case DialogResult.Cancel:
                    return(false);
                }
            }

            foreach (var editor in Editors.ToList())
            {
                editor.Close(true);
            }

            Project = null;

            return(true);
        }
Example #4
0
 private void _acceptButton_Click(object sender, EventArgs e)
 {
     if (_nameTextBox.Text.Equals(_fileName, StringComparison.OrdinalIgnoreCase))
     {
         DialogResult = DialogResult.OK;
     }
     else if (_nameTextBox.Text.Length == 0)
     {
         TaskDialogEx.Show(this, "Please enter a name", Text, TaskDialogCommonButtons.OK, TaskDialogIcon.Error);
     }
     else if (File.Exists(Path))
     {
         TaskDialogEx.Show(this, "File name already exists", Text, TaskDialogCommonButtons.OK, TaskDialogIcon.Error);
     }
     else if (Directory.Exists(Path))
     {
         TaskDialogEx.Show(this, "Directory already exists", Text, TaskDialogCommonButtons.OK, TaskDialogIcon.Error);
     }
     else
     {
         DialogResult = DialogResult.OK;
     }
 }