示例#1
0
        public void RenameFileInProject(string project, LoadedFile file, string newFile)
        {
            if (System.IO.Path.GetFileNameWithoutExtension(LoadedFile) == file.Name)
            {
                LoadedFile = System.IO.Path.GetDirectoryName(LoadedFile) + "\\" + newFile + ".not";
            }
            int index = Notes[project].Files.FindIndex(item => item.Path == file.Path);

            if (index < 0)
            {
                return;
            }
            newFile = newFile + System.IO.Path.GetExtension(file.Path);
            File.Move(file.Path, System.IO.Path.GetDirectoryName(file.Path) + "\\" + newFile);
            if (System.IO.File.Exists(ProjectsPath + "\\" + project + "\\Files\\" + System.IO.Path.GetFileNameWithoutExtension(file.Name) + ".not"))
            {
                File.Move(ProjectsPath + "\\" + project + "\\Files\\" + System.IO.Path.GetFileNameWithoutExtension(file.Name) + ".not", ProjectsPath + "\\" + project + "\\Files\\" + System.IO.Path.GetFileNameWithoutExtension(newFile) + ".not");
                if (LoadedFile == ProjectsPath + "\\" + project + "\\Files\\" + System.IO.Path.GetFileNameWithoutExtension(file.Name) + ".not")
                {
                    LoadedFile = ProjectsPath + "\\" + project + "\\Files\\" + System.IO.Path.GetFileNameWithoutExtension(newFile) + ".not";
                }
            }
            Notes[project].Files[index] = new LoadedFile(System.IO.Path.GetDirectoryName(file.Path) + "\\" + newFile, ProjectsPath + "\\" + project);
            OnSave(project);
            ((ISettings)ParentControl.Parent).SaveSettings();
        }
示例#2
0
        public void DeleteProject(string project)
        {
            if (!Notes.ContainsKey(project))
            {
                return;
            }
            if (!string.IsNullOrEmpty(LoadedFile) && LoadedFile.StartsWith(ProjectsPath + "\\" + project))
            {
                LoadedFile = "";
            }
            if (!string.IsNullOrEmpty(CurentFile) && CurentFile.StartsWith(ProjectsPath + "\\" + project))
            {
                // CurentProject = No
                CurentFile = "";
            }

            Directory.Delete(ProjectsPath + "\\" + project, true);
            Notes.Remove(project);
        }
示例#3
0
        protected override void CloneTextBox_LostFocus(object sender, RoutedEventArgs e)
        {
            base.CloneTextBox_LostFocus(sender, e);
            if (!IsValid)
            {
                return;
            }
            var mouseEventArgs = e as MouseEventArgs;

            if (e != null && mouseEventArgs == null)
            {
                return;
            }
            if (e != null)
            {
                var clickPosition = mouseEventArgs.GetPosition(MainProjectList);
                if (CloneTextBoxLocation.Contains((int)clickPosition.X, (int)clickPosition.Y))
                {
                    return;
                }
            }
            if (CloneTextBox.Tag.ToString() != CloneTextBox.Text)
            {
                if (!ChangedFileName)
                {
                    RenameProject(CloneTextBox.Tag.ToString(), CloneTextBox.Text);
                }
                else
                {
                    LoadedFile file = Notes[CurentProject.Name].Files.Where(item => item.Path == CloneTextBox.Tag.ToString()).FirstOrDefault();
                    if (file == null)
                    {
                        return;
                    }
                    string directoryPath = Path.GetDirectoryName(file.Path) + "\\";
                    RenameFileInProject(Directory.GetParent(directoryPath).Parent.Name, file, CloneTextBox.Text);
                    IsChangeFileName = false;
                }
            }
            MainProjectList.Items.Refresh();
            EndChangingDynamicItem();
        }