示例#1
0
        public static string GetVolumeInformation(Volume volume)
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendFormat("Volume size: {0} bytes\n", volume.Size.ToString("###,###,###,###,##0"));
            builder.AppendFormat("Volume type: {0}\n", VolumeHelper.GetVolumeTypeString(volume));
            if (volume is GPTPartition)
            {
                builder.AppendFormat("Partition name: {0}\n", ((GPTPartition)volume).PartitionName);
            }
            else if (volume is DynamicVolume)
            {
                builder.AppendFormat("Volume name: {0}\n", ((DynamicVolume)volume).Name);
                builder.AppendFormat("Volume status: {0}\n", VolumeHelper.GetVolumeStatusString(volume));
            }

            Guid?windowsVolumeGuid = WindowsVolumeHelper.GetWindowsVolumeGuid(volume);

            if (windowsVolumeGuid.HasValue)
            {
                List <string> mountPoints = WindowsVolumeManager.GetMountPoints(windowsVolumeGuid.Value);
                foreach (string volumePath in mountPoints)
                {
                    builder.AppendFormat("Volume path: {0}\n", volumePath);
                }
                bool isMounted = WindowsVolumeManager.IsMounted(windowsVolumeGuid.Value);
                builder.AppendFormat("Mounted: {0}\n", isMounted);
            }
            builder.AppendLine();

            if (volume is MirroredVolume)
            {
                builder.AppendLine("Extents:");
                List <DynamicVolume> components = ((MirroredVolume)volume).Components;
                for (int componentIndex = 0; componentIndex < components.Count; componentIndex++)
                {
                    if (componentIndex != 0)
                    {
                        builder.AppendLine();
                    }
                    DynamicVolume component = components[componentIndex];
                    builder.AppendFormat("Component {0}:\n", componentIndex);
                    builder.Append(GetExtentsInformation(component));
                }
            }
            else if (volume is DynamicVolume)
            {
                builder.AppendLine("Extents:");
                builder.Append(GetExtentsInformation((DynamicVolume)volume));
            }
            else if (volume is Partition)
            {
                Partition partition             = (Partition)volume;
                long      partitionOffset       = partition.FirstSector * partition.BytesPerSector;
                string    partitionOffsetString = FormattingHelper.GetStandardSizeString(partitionOffset);
                builder.AppendFormat("Partiton Offset: {0}, Start Sector: {1}\n", partitionOffsetString, partition.FirstSector);
            }

            return(builder.ToString());
        }
        private void SelectPhysicalDiskForm_Load(object sender, EventArgs e)
        {
            List <Volume> volumes = WindowsVolumeHelper.GetVolumes();

            for (int index = 0; index < volumes.Count; index++)
            {
                Volume volume = volumes[index];
                string title  = String.Format("Volume {0}", index);
                string type   = VolumeHelper.GetVolumeTypeString(volume);
                string status = VolumeHelper.GetVolumeStatusString(volume);

                ulong  volumeID = 0;
                string name     = String.Empty;
                if (volume is DynamicVolume)
                {
                    volumeID = ((DynamicVolume)volume).VolumeID;
                    name     = ((DynamicVolume)volume).Name;
                }
                else if (volume is GPTPartition)
                {
                    name = ((GPTPartition)volume).PartitionName;
                }
                ListViewItem item = new ListViewItem(title);
                item.SubItems.Add(name);
                item.SubItems.Add(type);
                item.SubItems.Add(status);
                item.SubItems.Add(FormattingHelper.GetStandardSizeString(volume.Size));
                item.Tag = volume;
                listVolumes.Items.Add(item);
            }
        }
        public async Task <IActionResult> UploadFileAsync(string fileHash)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(fileHash))
                {
                    return(BadRequest());
                }

                var fullPath = VolumeHelper.GetFullPathFromHash(fileHash, true);

                using var readStream = Request.Body;

                if (System.IO.File.Exists(fullPath))
                {
                    System.IO.File.Delete(fullPath);
                }

                using var writeStream = System.IO.File.OpenWrite(fullPath);
                await readStream.CopyToAsync(writeStream);

                return(Ok());
            }
            catch
            {
                return(BadRequest());
            }
        }
示例#4
0
        public void SetVolume(Context context, Result result)
        {
            var number = result.Entities.OfType(Sys.Text).Value;

            VolumeHelper.Set((int)NumbersHelper.ParseNumber(number));
            result.SendResponse($"как вам угодно");
        }
示例#5
0
        public bool AddStock(IStockData sd)
        {
            if (sd == null)
            {
                return(false);
            }
            prevStock_    = currentStock_;
            currentStock_ = sd;

            if ((prevStock_ == null) || (currentStock_ == null))
            {
                return(false);
            }

            if (ShapeJudger.IsT2(currentStock_, DeltaRatio_) && VolumeHelper.IsLargerThan(currentStock_, prevStock_, 0.3))
            {
                TodayOper_ = OperType.Buy;
            }
            else if (ShapeJudger.IsReverseT2(currentStock_, DeltaRatio_))
            {
                TodayOper_ = OperType.Sell;
            }
            else
            {
                TodayOper_ = OperType.NoOper;
            }

            return(true);
        }
        public IActionResult DeleteFile(string fileHash)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(fileHash))
                {
                    return(BadRequest());
                }

                var fullPath = VolumeHelper.GetFullPathFromHash(fileHash, true);

                if (fullPath == null)
                {
                    return(BadRequest());
                }

                System.IO.File.Delete(fullPath);

                return(Ok());
            }
            catch
            {
                return(BadRequest());
            }
        }
示例#7
0
        private void Extent_Paint(object sender, PaintEventArgs e)
        {
            CheckBox         chkExtent = (CheckBox)sender;
            VisualDiskExtent extent    = (VisualDiskExtent)chkExtent.Tag;
            Brush            brush     = DiskStyling.GetVolumeBrush(extent.Volume);
            int bannerLocationX        = 1;
            int bannerLocationY        = 2;
            int bannerWidth            = chkExtent.Width - bannerLocationX - 2;
            int bannerTextLocationX    = 2;
            int bannerTextLocationY    = 0;

            if (chkExtent.Checked)
            {
                bannerLocationX++;
                bannerLocationY++;
                bannerTextLocationX++;
                bannerTextLocationY++;
            }
            e.Graphics.FillRectangle(brush, bannerLocationX, bannerLocationY, bannerWidth, ExtentBannerHeight);
            string typeString = VolumeHelper.GetVolumeTypeString(extent.Volume);

            if (extent.Volume == null)
            {
                typeString = "Free";
            }
            Font  font            = new Font(chkExtent.Font.FontFamily, 7);
            Brush bannerTextBrush = Brushes.White;

            if (extent.Volume is Raid5Volume)
            {
                bannerTextBrush = Brushes.Black;
            }
            e.Graphics.DrawString(typeString, font, bannerTextBrush, bannerTextLocationX, bannerTextLocationY);
        }
示例#8
0
        public static string GetExtentLabel(Volume volume, DiskExtent extent, int width)
        {
            StringBuilder builder = new StringBuilder();

            if (volume != null)
            {
                Guid?volumeGuid = WindowsVolumeHelper.GetWindowsVolumeGuid(volume);
                if (volumeGuid.HasValue)
                {
                    List <string> mountPoints = WindowsVolumeManager.GetMountPoints(volumeGuid.Value);
                    if (mountPoints.Count > 0)
                    {
                        builder.AppendLine(mountPoints[0]);
                    }
                }
            }
            long size = extent.Size;

            if (width <= 60)
            {
                builder.AppendLine(FormattingHelper.GetCompactSizeString(extent.Size));
            }
            else
            {
                builder.AppendLine(FormattingHelper.GetStandardSizeString(extent.Size));
            }
            if (volume != null)
            {
                string statusString = VolumeHelper.GetVolumeStatusString(volume);
                builder.AppendLine(statusString);
            }

            return(builder.ToString());
        }
示例#9
0
 private void FinishListening(bool wasMuted)
 {
     if (!wasMuted)
     {
         VolumeHelper.UnMute();
     }
     _commandInProgress = false;
 }
示例#10
0
 private void StartListening(out bool wasMuted)
 {
     _commandInProgress = true;
     wasMuted           = VolumeHelper.IsMuted();
     if (!wasMuted)
     {
         VolumeHelper.Mute();
     }
 }
 private void buttonONAll_Click(object sender, RoutedEventArgs e)
 {
     if (VolumeHelper.IsMute())
     {
         buttonONAll.Background = ONBrush;
         buttonONAll.Foreground = BlackBrush;
         VolumeHelper.SetMute(false);
         SliderAll.IsEnabled = true;
     }
     else
     {
         buttonONAll.Background = TranBrush;
         buttonONAll.Foreground = WhiteBrush;
         VolumeHelper.SetMute(true);
         SliderAll.IsEnabled = false;
     }
 }
示例#12
0
 private void VolumeIcon_Tick()
 {
     if (VolumeHelper.IsVolumeMuted())
     {
         imgOpenVolume.Source = FindResource("VolumeMuteIcon") as ImageSource;
     }
     else if (VolumeHelper.GetMasterVolume() <= 0)
     {
         imgOpenVolume.Source = FindResource("VolumeOffIcon") as ImageSource;
     }
     else if (VolumeHelper.GetMasterVolume() < 0.5)
     {
         imgOpenVolume.Source = FindResource("VolumeLowIcon") as ImageSource;
     }
     else
     {
         imgOpenVolume.Source = FindResource("VolumeIcon") as ImageSource;
     }
 }
示例#13
0
        public static List <VisualDiskExtent> GetVisualExtents(List <Disk> disks)
        {
            List <Volume>           volumes = VolumeHelper.GetVolumes(disks);
            List <VisualDiskExtent> extents = new List <VisualDiskExtent>();

            foreach (Volume volume in volumes)
            {
                if (volume is MirroredVolume)
                {
                    List <DynamicVolume> components = ((MirroredVolume)volume).Components;
                    foreach (Volume component in components)
                    {
                        foreach (DiskExtent extent in component.Extents)
                        {
                            int diskIndex = disks.IndexOf(extent.Disk);
                            extents.Add(new VisualDiskExtent(diskIndex, extent, volume));
                        }
                    }
                }
                else
                {
                    foreach (DiskExtent extent in volume.Extents)
                    {
                        int diskIndex = disks.IndexOf(extent.Disk);
                        extents.Add(new VisualDiskExtent(diskIndex, extent, volume));
                    }
                }
            }

            List <DiskExtent> unallocatedExtents = DiskHelper.GetUnallocatedExtents(disks);

            foreach (DiskExtent extent in unallocatedExtents)
            {
                int diskIndex = disks.IndexOf(extent.Disk);
                extents.Add(new VisualDiskExtent(diskIndex, extent, null));
            }

            return(extents);
        }
示例#14
0
        public IActionResult DownloadFileAsync(string fileHash)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(fileHash))
                {
                    return(BadRequest());
                }

                var fullPath = VolumeHelper.GetFullPathFromHash(fileHash, true);

                if (fullPath == null)
                {
                    return(BadRequest());
                }

                return(File(fullPath, GetContentType(fullPath)));
            }
            catch
            {
                return(BadRequest());
            }
        }
示例#15
0
 public void ToggleMute()
 {
     VolumeHelper.ToggleMute();
 }
示例#16
0
 public void VolumeDown()
 {
     VolumeHelper.DecrementVolume(Settings.Current.WindowsVolumeMixerIncrement);
 }
示例#17
0
        public void SendAction(ToastifyActionEnum action)
        {
            if (!this.IsRunning)
            {
                return;
            }

            bool sendAppCommandMessage = false;
            bool sendMediaKey          = false;

            switch (action)
            {
#if DEBUG
            case ToastifyActionEnum.ShowDebugView:
#endif
            case ToastifyActionEnum.None:
            case ToastifyActionEnum.CopyTrackInfo:
            case ToastifyActionEnum.PasteTrackInfo:
            case ToastifyActionEnum.ThumbsUp:
            case ToastifyActionEnum.ThumbsDown:
            case ToastifyActionEnum.ShowToast:
            case ToastifyActionEnum.SettingsSaved:
            case ToastifyActionEnum.Exit:
                break;

            case ToastifyActionEnum.ShowSpotify:
                Analytics.TrackEvent(Analytics.ToastifyEventCategory.Action, Analytics.ToastifyEvent.Action.ShowSpotify);
                if (this.IsMinimized)
                {
                    this.ShowSpotify();
                }
                else
                {
                    this.Minimize();
                }
                break;

            case ToastifyActionEnum.VolumeUp:
                Analytics.TrackEvent(Analytics.ToastifyEventCategory.Action, Analytics.ToastifyEvent.Action.VolumeUp);
                switch ((ToastifyVolumeControlMode)Settings.Current.VolumeControlMode)
                {
                // The Spotify volume control mode has been dropped since Spotify version 1.0.75.483.g7ff4a0dc due to issue #31
                //case ToastifyVolumeControlMode.Spotify:
                //    this.SendShortcut(action);
                //    break;

                case ToastifyVolumeControlMode.SystemSpotifyOnly:
                    VolumeHelper.IncrementVolume(Settings.Current.WindowsVolumeMixerIncrement);
                    break;

                case ToastifyVolumeControlMode.SystemGlobal:
                    sendMediaKey = true;
                    break;

                default:
                    sendMediaKey = true;
                    break;
                }

                break;

            case ToastifyActionEnum.VolumeDown:
                Analytics.TrackEvent(Analytics.ToastifyEventCategory.Action, Analytics.ToastifyEvent.Action.VolumeDown);
                switch ((ToastifyVolumeControlMode)Settings.Current.VolumeControlMode)
                {
                // The Spotify volume control mode has been dropped since Spotify version 1.0.75.483.g7ff4a0dc due to issue #31
                //case ToastifyVolumeControlMode.Spotify:
                //    this.SendShortcut(action);
                //    break;

                case ToastifyVolumeControlMode.SystemSpotifyOnly:
                    VolumeHelper.DecrementVolume(Settings.Current.WindowsVolumeMixerIncrement);
                    break;

                case ToastifyVolumeControlMode.SystemGlobal:
                default:
                    sendMediaKey = true;
                    break;
                }

                break;

            case ToastifyActionEnum.Mute:
                Analytics.TrackEvent(Analytics.ToastifyEventCategory.Action, Analytics.ToastifyEvent.Action.Mute);
                switch ((ToastifyVolumeControlMode)Settings.Current.VolumeControlMode)
                {
                case ToastifyVolumeControlMode.SystemSpotifyOnly:
                    VolumeHelper.ToggleMute();
                    break;

                // The Spotify volume control mode has been dropped since Spotify version 1.0.75.483.g7ff4a0dc due to issue #31
                //case ToastifyVolumeControlMode.Spotify:
                case ToastifyVolumeControlMode.SystemGlobal:
                default:
                    sendMediaKey = true;
                    break;
                }

                break;

            case ToastifyActionEnum.FastForward:
            case ToastifyActionEnum.Rewind:
            case ToastifyActionEnum.Stop:
            case ToastifyActionEnum.PlayPause:
            case ToastifyActionEnum.PreviousTrack:
            case ToastifyActionEnum.NextTrack:
                goto default;

            default:
                Analytics.TrackEvent(Analytics.ToastifyEventCategory.Action, $"{Analytics.ToastifyEvent.Action.Default}{action}");
                sendAppCommandMessage = true;
                break;
            }

            if (sendAppCommandMessage)
            {
                Windows.SendAppCommandMessage(this.GetMainWindowHandle(), (IntPtr)action, true);
            }
            if (sendMediaKey)
            {
                Win32API.SendMediaKey(action);
            }
        }
示例#18
0
 public void VolumeDown(Context context, Result result)
 {
     VolumeHelper.Down();
     result.SendResponse("как вам угодно");
 }
示例#19
0
 public void VolumeMuteOff(Context context, Result result)
 {
     VolumeHelper.UnMute();
     result.SendResponse("как вам угодно");
 }