private void BitmapDrawing(PInvokeDefragLibrary.TVolume vvolume) { lbResult.Children.Clear(); int bloksperline = 58; int row = 1; int column = 1; foreach (var item in PInvokeDefragLibrary.PInvoke.GetColouredBlocks(vvolume, blocksAmount)) { RectangleGeometry myRectangleGeometry = new RectangleGeometry { Rect = new Rect(10 + column * 13, row * 13, 10, 10) }; Path myPath = new Path { Fill = (item.State == 2)? Brushes.Coral: (item.State == 0)?Brushes.LemonChiffon: (item.State == 3) ? Brushes.Blue: Brushes.LightGreen, Stroke = Brushes.Black, StrokeThickness = 1, Data = myRectangleGeometry }; lbResult.Children.Add(myPath); if ((column % bloksperline) == 0) { row++; column = 1; } else { column++; } } }
private void BtnDefrag_Click(object sender, RoutedEventArgs e) { StopDefrProc = false; var volumeWithGUID = GetNameFromPath(this.comboBox.SelectedItem.ToString()); defragmentingVolume = volumeWithGUID; UInt64 i = 0; BitmapDrawing(volumeWithGUID); Thread thread = new Thread(() => { //Do somthing and set your value PInvokeDefragLibrary.PInvoke.DefragmentFirstStage(volumeWithGUID, i); /*while (true) * { * /*if (StopDefrProc) { * while (StopDefrProc) * { * * } * //pause procedure * }* * if (Class1.PInvoke.DefragmentFirstStage(volumeWithGUID, i) == 0) break; * /*if (StopDefrProc) * { * while (StopDefrProc) * { * * } * //pause procedure * }* * i = Class1.PInvoke.DefragmentSecondStage(volumeWithGUID, i); * * }*/ }); thread.Start(); dispatcherTimer.Start(); //Class1.PInvoke.DefragmentFirstStage(volumeWithGUID, i); /*while (true) * { * if (Class1.PInvoke.DefragmentFirstStage(volumeWithGUID, i) == 0) break; * //Class1.PInvoke.DefragmentFirstStage(volumeWithGUID, i); * //BitmapDrawing(volumeWithGUID); * i=Class1.PInvoke.DefragmentSecondStage(volumeWithGUID, i); * //BitmapDrawing(volumeWithGUID); * * }*/ //BitmapDrawing(volumeWithGUID); // dispatcherTimer.Stop(); }