Beispiel #1
0
        public RawDiskStream CreateDiskStream()
        {
            SafeFileHandle diskHandle = PlatformShim.CreateDeviceHandle(DosDeviceName, _access);
            FileStream     diskFs     = new FileStream(diskHandle, _access);

            return(new RawDiskStream(diskFs, SectorSize, SizeBytes));
        }
        public YouTubeTimestampLinkerViewModel()
        {
            YTTimestampLinker = new YTTimestampLinker(AppLogger);

            GetLinkCommand = new RelayCommand(() => YTTimestampLinker.GetLink());
            PreviewCommand = new RelayCommand(async() => await PreviewAsync());
            CopyCommand    = new RelayCommand(() => PlatformShim.CopyToClipboard(YTTimestampLinker.NewURL));
        }
Beispiel #3
0
        public UUIDGeneratorViewModel()
        {
            UUIDGenerator   = new UUIDGenerator(AppLogger);
            CopyUUIDCommand = new RelayCommand(() => PlatformShim.CopyToClipboard(UUIDGenerator.UUID));

            bool uuidGenerateFunction() => UUIDGenerator.Initiate();

            ExecuteTaskCommand = new RelayCommand(async() => await InitiateProcessAsync(uuidGenerateFunction, ExecuteTaskCommand), () => !IsBusy);
        }
Beispiel #4
0
        private void InitateVolume(char driveLetter)
        {
            Debug.WriteLine("Initiating type Volume");

            uint sectorsPerCluster, bytesPerSector, numberOfFreeClusters, numberOfClusters;
            bool success = PlatformShim.GetDiskFreeSpace(driveLetter + ":", out sectorsPerCluster, out bytesPerSector, out numberOfFreeClusters, out numberOfClusters);

            if (success)
            {
                _clusterSize      = (int)(bytesPerSector * sectorsPerCluster);
                _sectorsPrCluster = (int)sectorsPerCluster;
            }
        }
Beispiel #5
0
        private void InitiateCommon(string dosName, FileAccess access)
        {
            Debug.WriteLine("Initiating with " + dosName);

            DiskHandle    = PlatformShim.CreateDeviceHandle(dosName, access);
            DosDeviceName = dosName;

            if (DiskHandle.IsInvalid)
            {
                throw new ArgumentException("Invalid diskName: " + dosName);
            }

            _access = access;

            _deviceIo = new DiskDeviceWrapper(DiskHandle);
            _diskFs   = new FileStream(DiskHandle, _access);

            _diskInfo     = _deviceIo.DiskGetDriveGeometry();
            _deviceLength = _deviceIo.DiskGetLengthInfo();
        }
        private void BuildDynamicColorGrid()
        {
            FlatUIColorPickerViewModel flatUIColorPickerViewModel = (FlatUIColorPickerViewModel)DataContext;

            int numberOfRows    = GetNumberOfRows(flatUIColorPickerViewModel.FlatUIColorPicker.FlatColors.Count);
            int numberOfColumns = Convert.ToInt32(Math.Ceiling((decimal)flatUIColorPickerViewModel.FlatUIColorPicker.FlatColors.Count / numberOfRows));

            Grid flatColorGrid = new Grid();

            for (int i = 0; i < numberOfRows; i++)
            {
                flatColorGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(1, GridUnitType.Star)
                });
            }

            for (int i = 0; i < numberOfColumns; i++)
            {
                flatColorGrid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(1, GridUnitType.Star)
                });
            }

            int flatColorIndex = 0;

            for (int row = 0; row < numberOfRows; row++)
            {
                for (int column = 0; column < numberOfColumns; column++)
                {
                    if (flatColorIndex < flatUIColorPickerViewModel.FlatUIColorPicker.FlatColors.Count)
                    {
                        string colorHex = flatUIColorPickerViewModel.FlatUIColorPicker.FlatColors[flatColorIndex].Hex;

                        // Using Rectangle instead of Button because in UWP the hardcoded Button OnHover changes make this tool difficult to use.
                        Windows.UI.Xaml.Shapes.Rectangle colorTile = new Windows.UI.Xaml.Shapes.Rectangle
                        {
                            Fill   = PlatformShim.BrushConverterConvertFrom(colorHex),
                            Margin = new Thickness(1, 1, 1, 1),
                            HorizontalAlignment = HorizontalAlignment.Stretch,
                            VerticalAlignment   = VerticalAlignment.Stretch,
                            Tag             = colorHex,
                            Stroke          = Application.Current.Resources["ButtonBorderThemeBrush"] as Windows.UI.Xaml.Media.Brush,
                            StrokeThickness = string.Equals(ViewModelLocator.Current.FlatUIColorPickerViewModel.SelectedHex, colorHex)
                                ? SELECTED_TILE_STROKE_THICKNESS
                                : 0D
                        };

                        colorTile.PointerPressed += new PointerEventHandler(ColorTile_OnClick);

                        Grid.SetRow(colorTile, row);
                        Grid.SetColumn(colorTile, column);
                        flatColorGrid.Children.Add(colorTile);

                        flatColorIndex++;
                    }
                }
            }

            // "MainGrid" is set in the name attribute of the root grid in XAML.
            // We want to add this dynamic grid to the second row of the root grid so it can take up all the remaining space available.
            Grid.SetRow(flatColorGrid, 1);
            MainGrid.Children.Add(flatColorGrid);
        }