Ejemplo n.º 1
0
        /// <summary>
        /// Override this method to define the async command body te execute on the
        /// background thread
        /// </summary>
        protected override Task ExecuteAsync()
        {
            var currentProtection = VirtualFloppyFile.CheckWriteProtection(ItemPath);

            VirtualFloppyFile.SetWriteProtection(ItemPath, !currentProtection);
            return(Task.FromResult(0));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Override this method to define the status query action
        /// </summary>
        /// <param name="mc"></param>
        protected override void OnQueryStatus(OleMenuCommand mc)
        {
            base.OnQueryStatus(mc);
            if (!mc.Visible)
            {
                return;
            }

            if (!(Package.MachineViewModel.SpectrumVm.FloppyDevice is FloppyDevice floppyDevice))
            {
                mc.Visible = false;
                return;
            }

            mc.Visible = string.Compare(floppyDevice.DriveAFloppy?.Filename, ItemPath,
                                        StringComparison.InvariantCultureIgnoreCase) != 0 &&
                         string.Compare(floppyDevice.DriveBFloppy?.Filename, ItemPath,
                                        StringComparison.InvariantCultureIgnoreCase) != 0;
            if (!mc.Visible)
            {
                return;
            }

            mc.Text = VirtualFloppyFile.CheckWriteProtection(ItemPath)
                ? "Remove write protection"
                : "Make write protected";
        }