public static void outputDirListBox_Drop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent("myFormat")) { modSourceFolder data = e.Data.GetData("myFormat") as modSourceFolder; DataGrid dataGrid = sender as DataGrid; bool exists = false; for (int i = 0; i < dataGrid.Items.Count; i++) { if ((dataGrid.Items.GetItemAt(i) as modSourceFolder).modFolderName == data.modFolderName) { exists = true; } } if (!exists) { DataGrid inputDir = WindowManager.mainWindow.inputDirListBox; List <modSourceFolder> modSource = inputDir.ItemsSource as List <modSourceFolder>; List <modSourceFolder> outputSource = dataGrid.ItemsSource as List <modSourceFolder>; outputSource.Add(data); modSource.Remove(data); dataGrid.ItemsSource = outputSource; dataGrid.Items.Refresh(); inputDir.Items.Refresh(); } } }
public static void outputDirListBox_PreviewMouseMove(object sender, MouseEventArgs e) { Point mousePos = e.GetPosition(null); Vector diff = startPoint - mousePos; if (e.LeftButton == MouseButtonState.Pressed && (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)) { DataGrid dataGrid = sender as DataGrid; object item = dataGrid.CurrentItem; if (item != null) { modSourceFolder data = (modSourceFolder)item; DataObject dragData = new DataObject("myFormat", data); DragDrop.DoDragDrop(dataGrid, dragData, DragDropEffects.Move); } } }
public static void inputDirListBox_PreviewMouseMove(object sender, MouseEventArgs e) { Point mousePos = e.GetPosition(null); Vector diff = startPoint - mousePos; //Little to no f*****g idea how this works... need to do some research... if (e.LeftButton == MouseButtonState.Pressed && (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)) { // Get the Dragged ListViewItem DataGrid dataGrid = sender as DataGrid; object item = dataGrid.CurrentItem; if (item != null) { // Find the data behind the ListViewItem modSourceFolder data = (modSourceFolder)item; //Initialize the drag & drop operation DataObject dragData = new DataObject("myFormat", data); DragDrop.DoDragDrop(dataGrid, dragData, DragDropEffects.Move); } } }
private static void generate(object sender, DoWorkEventArgs e) { bw1.DoWork -= generate; BitmapImage modRed = new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/Slick Updater Beta;component/Resources/modGreen.png")); DataGrid listView = WindowManager.mainWindow.outputDirListBox; string outputDir = ConfigManager.fetch("repoGen", "outputDir"); DirectoryInfo outputDirInfo = new DirectoryInfo(outputDir); if (!Directory.Exists(outputDir)) { Directory.CreateDirectory(outputDir); } outputDirInfo.Delete(true); Directory.CreateDirectory(outputDir); using (StreamWriter modsw = new StreamWriter(outputDir + "\\modlist.cfg", true)) { for (int i = 0; i < listView.Items.Count; i++) { modSourceFolder modSource = listView.Items.GetItemAt(i) as modSourceFolder; string modFolderName = modSource.modFolderName; string modVersionNumber = modSource.modVersion; string inputDir = ConfigManager.fetch("repoGen", "inputDir"); if (Directory.Exists(inputDir)) { string inputModDir = inputDir + "\\" + modFolderName; //genFile(inputModDir); DirectoryInfo dir = new DirectoryInfo(inputModDir); if (dir.Exists) { modsw.WriteLine(modFolderName); //Create output Directory if it doesn't exist. //Create modfolder in outputdir if it doesn't exits if (!Directory.Exists(outputDir + "\\" + modFolderName)) { Directory.CreateDirectory(outputDir + "\\" + modFolderName); } string fileCfgPath = outputDir + "\\" + modFolderName + "\\files.cfg"; using (StreamWriter sw = new StreamWriter(fileCfgPath, true)) { foreach (FileInfo fileInfo in dir.GetFiles()) { if (fileInfo.Name != "SU.version") { string name = fileInfo.Name; string path = fileInfo.FullName; string zipName = name + ".7z"; string zipPath = outputDir + "\\" + modFolderName + "\\" + zipName; string hashPath = outputDir + "\\" + modFolderName + "\\" + name + ".hash"; File.WriteAllText(hashPath, md5Calc(path)); //string[] temp = {path, zipPath}; //queue.Enqueue(temp); Zippy.compress(path, zipPath); sw.WriteLine(name); } } } string dirCfgPath = outputDir + "\\" + modFolderName + "\\dirs.cfg"; using (StreamWriter sw = new StreamWriter(dirCfgPath, true)) { foreach (DirectoryInfo directory in dir.GetDirectories()) { string sourcePath = directory.FullName; string sourceName = directory.Name; string outDir = outputDir + "\\" + modFolderName + "\\" + sourceName; genFile(sourcePath, outDir); genDir(sourcePath, outDir); sw.WriteLine(sourceName); } } File.WriteAllText(outputDir + "\\" + modFolderName + "\\SU.version", modVersionNumber); DirectoryInfo source = new DirectoryInfo(inputDir + "\\" + modFolderName); FileInfo[] sourceFiles = source.GetFiles("*", SearchOption.AllDirectories); File.WriteAllText(outputDir + "\\" + modFolderName + "\\count.txt", sourceFiles.Length.ToString()); } } } } }