Exemplo n.º 1
0
        private void NewFolder()
        {
            if (treeViewMachinesAndTasksHandler.GetNodePath().Contains(LockPath))
            {
                MessageBox.Show("Cannot create new folder in lock folder", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            var addFolderDialog = new EditItem();

            if (listViewMachineGroups.Visibility == Visibility.Visible)
            {
                foreach (ComputerDetailsData item in listViewMachineGroups.Items)
                {
                    addFolderDialog.Names.Add(item.Name);
                }
            }
            else
            {
                foreach (TaskData item in listViewTasks.Items)
                {
                    addFolderDialog.Names.Add(item.Name);
                }
            }
            addFolderDialog.ShowDialog();
            if (!addFolderDialog.cancel)
            {
                string path = treeViewMachinesAndTasksHandler.GetNodePath() + "\\" + addFolderDialog.textBoxNewName.Text;
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                    treeViewMachinesAndTasksHandler.AddItem(addFolderDialog.textBoxNewName.Text);
                    listViewMachinesAndTasksHandler.Refresh();
                }
            }
        }
Exemplo n.º 2
0
        private void buttonVHDNameAdd_Click(object sender, RoutedEventArgs e)
        {
            var addVHDNameDialog = new EditItem();

            foreach (string name in listBoxVHDNames.Items)
            {
                addVHDNameDialog.Names.Add(name);
            }
            addVHDNameDialog.ShowDialog();
            listBoxVHDNames.Items.Add(addVHDNameDialog.textBoxNewName.Text);
        }
Exemplo n.º 3
0
 private void RenameItem(ComputerDetailsData oldItem)
 {
     if (oldItem != null)
     {
         string oldPath = treeViewMachinesAndTasksHandler.GetNodePath() + "\\" + oldItem.Name;
         if (oldPath == LockPath || oldPath == DefaultPath)
         {
             MessageBox.Show("Cannot rename this folder", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
             return;
         }
         var renameItemDialog = new EditItem();
         renameItemDialog.textBoxNewName.Text  = oldItem.Name;
         renameItemDialog.labelOldName.Content = oldItem.Name;
         foreach (ComputerDetailsData item in listViewMachineGroups.Items)
         {
             if (item.ImageSource == oldItem.ImageSource)
             {
                 renameItemDialog.Names.Add(item.Name);
             }
         }
         renameItemDialog.ShowDialog();
         if (!renameItemDialog.cancel)
         {
             string path = treeViewMachinesAndTasksHandler.GetNodePath() + "\\" + renameItemDialog.textBoxNewName.Text;
             if (oldItem.ImageSource.Contains("Folder"))
             {
                 if (Directory.Exists(path))
                 {
                     Directory.Move(oldPath, path);
                 }
                 treeViewMachinesAndTasksHandler.RenameItem(oldItem.Name, renameItemDialog.textBoxNewName.Text);
             }
             else
             {
                 oldPath += ".my";
                 path    += ".my";
                 ComputerDetailsData machineData = FileHandler.Load <ComputerDetailsData>(oldPath);
                 machineData.Name = renameItemDialog.textBoxNewName.Text;
                 if (File.Exists(oldPath))
                 {
                     File.Move(oldPath, path);
                 }
                 if (File.Exists(oldPath.Replace(".my", ".cfg")))
                 {
                     File.Move(oldPath.Replace(".my", ".cfg"), path.Replace(".my", ".cfg"));
                 }
                 FileHandler.Save <ComputerDetailsData>(machineData, path);
             }
             listViewMachinesAndTasksHandler.Refresh();
         }
     }
 }
Exemplo n.º 4
0
        private void button_New_Folder_Click(object sender, RoutedEventArgs e)
        {
            var newFolderDialog = new EditItem();

            foreach (ImageData item in listView.Items)
            {
                newFolderDialog.Names.Add(item.Name);
            }
            newFolderDialog.ShowDialog();
            if (!newFolderDialog.cancel)
            {
                string path = treeViewMachinesAndTasksHandler.GetNodePath() + "\\" + newFolderDialog.textBoxNewName.Text;
                Directory.CreateDirectory(path);
                treeViewMachinesAndTasksHandler.AddItem(newFolderDialog.textBoxNewName.Text);
                listViewBrowseImagesHandler.Refresh();
            }
        }
Exemplo n.º 5
0
        private void RenameItem()
        {
            var oldItem = (ImageData)listView.SelectedItem;

            if (oldItem != null)
            {
                string oldPath          = treeViewMachinesAndTasksHandler.GetNodePath() + "\\" + oldItem.Name;
                var    renameItemDialog = new EditItem();
                renameItemDialog.textBoxNewText.Text  = oldItem.Name;
                renameItemDialog.labelOldText.Content = oldItem.Name;
                foreach (ImageData item in listView.Items)
                {
                    if (item.ImageSource == oldItem.ImageSource)
                    {
                        renameItemDialog.Names.Add(item.Name);
                    }
                }
                renameItemDialog.ShowDialog();
                if (!renameItemDialog.cancel)
                {
                    string path = treeViewMachinesAndTasksHandler.GetNodePath() + "\\" + renameItemDialog.textBoxNewText.Text;
                    if (oldItem.ImageSource.Contains("Folder"))
                    {
                        if (Directory.Exists(oldPath))
                        {
                            Directory.Move(oldPath, path);
                        }
                        treeViewMachinesAndTasksHandler.RenameItem(oldItem.Name, renameItemDialog.textBoxNewText.Text);
                    }
                    else
                    {
                        oldPath += ".my";
                        path    += ".my";
                        ImageData imageData = FileHandler.Load <ImageData>(oldPath);
                        imageData.Name = renameItemDialog.textBoxNewText.Text;
                        if (File.Exists(oldPath))
                        {
                            File.Delete(oldPath);
                        }
                        FileHandler.Save <ImageData>(imageData, path);
                    }
                    listViewBrowseImagesHandler.Refresh();
                }
            }
        }
Exemplo n.º 6
0
        private void NewFolder()
        {
            var addFolderDialog = new EditItem();

            foreach (ImageData item in listView.Items)
            {
                addFolderDialog.Names.Add(item.Name);
            }
            addFolderDialog.ShowDialog();
            if (!addFolderDialog.cancel)
            {
                string path = treeViewMachinesAndTasksHandler.GetNodePath() + "\\" + addFolderDialog.textBoxNewText.Text;
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                    treeViewMachinesAndTasksHandler.AddItem(addFolderDialog.textBoxNewText.Text);
                    listViewBrowseImagesHandler.Refresh();
                }
            }
        }