Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="INTV.LtoFlash.View.DeviceInformation"/> class.
 /// </summary>
 /// <param name="viewModel">The view model to use.</param>
 private DeviceInformation(LtoFlashViewModel viewModel)
 {
     DataContext = viewModel;
     viewModel.PropertyChanged += HandleViewModelPropertyChanged;
     this.Build();
     _informationPages.Page = (int)SelectedPageIndex;
     UpdateDisplay();
 }
Ejemplo n.º 2
0
        private static void OnTogglePower(object parameter)
        {
            var viewModel       = parameter as LtoFlashViewModel;
            var deviceViewModel = viewModel.ActiveLtoFlashDevice;
            var hardwareFlags   = deviceViewModel.Device.HardwareStatus ^ HardwareStatusFlags.ConsolePowerOn;

            LtoFlashViewModel.SetHardwareStatus(deviceViewModel.Device, hardwareFlags);
        }
Ejemplo n.º 3
0
        private static void SyncDeviceToHost(LtoFlashViewModel ltoFlashViewModel, bool ignoreInconsistentFileSystem)
        {
            var device        = ltoFlashViewModel.ActiveLtoFlashDevice.Device;
            var configuration = INTV.Shared.Utility.SingleInstanceApplication.Instance.GetConfiguration <Configuration>();
            var menuLayout    = ltoFlashViewModel.HostPCMenuLayout.MenuLayout;

            ltoFlashViewModel.HostPCMenuLayout.OverlayText = Resources.Strings.SyncDeviceToHostCommand_OverlayText;
            ltoFlashViewModel.HostPCMenuLayout.ShowOverlay = true;
            device.SyncDeviceToHost(menuLayout, ignoreInconsistentFileSystem, (c, p, r) => SyncDeviceToHostCompleteHandler(c, p, (FileSystemSyncErrors)r, configuration, ltoFlashViewModel), (m, e) => SyncDeviceToHostErrorHandler(m, e, ltoFlashViewModel));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Helper method to check if a command can execute.
        /// </summary>
        /// <param name="ltoFlash">The top-level view model whose active device will be used to test command availability.</param>
        /// <param name="command">The command whose availability is being tested.</param>
        /// <returns><c>true</c> if the command can execute, otherwise <c>false</c>.</returns>
        internal static bool CanExecuteCommand(this LtoFlashViewModel ltoFlash, VisualDeviceCommand command)
        {
            bool canExecute = (ltoFlash != null) && (ltoFlash.ActiveLtoFlashDevice != null) && (ltoFlash.ActiveLtoFlashDevice.Device != null);

            if (canExecute)
            {
                canExecute = ltoFlash.ActiveLtoFlashDevice.Device.CanExecuteCommand(command);
            }
            return(canExecute);
        }
Ejemplo n.º 5
0
        internal MenuLayoutView(LtoFlashViewModel viewModel)
        {
            // TODO: Show/Hide power icon based on state
            // TODO: Show/Hide dirty icon based on state
            DataContext = viewModel;
            this.Build();

            _menuLayoutTitle.Text = MenuLayoutViewModel.Title;

            _dirtyIcon.NoShowAll   = true;
            _dirtyIcon.Visible     = viewModel.ShowFileSystemsDifferIcon;
            _dirtyIcon.Pixbuf      = DirtyIconImage;
            _dirtyIcon.TooltipText = LtoFlashViewModel.ContentsNotInSyncToolTip;
            _powerIcon.Pixbuf      = PowerIconImage.CreateNewWithOpacity(0.5); // initialize to the "power off" image
            _powerIcon.TooltipText = Resources.Strings.ConsolePowerState_Unknown;

            ((Gtk.Image)_newFolder.Image).Pixbuf = MenuLayoutCommandGroup.NewDirectoryCommand.SmallIcon;
            _newFolder.TooltipText = MenuLayoutViewModel.NewFolderTip;

            ((Gtk.Image)_deleteSelectedItems.Image).Pixbuf = MenuLayoutCommandGroup.DeleteItemsCommand.SmallIcon;

            InitializeColorComboBox(_colorChooser, viewModel.HostPCMenuLayout.AvailableColors, viewModel.HostPCMenuLayout);
            InitializeMenuLayout(_menuLayout, viewModel.HostPCMenuLayout);

            // Cheesy way to initialize some properties
            var initializePropertyNames = new[]
            {
                MenuLayoutViewModel.StatusPropertyName,
                MenuLayoutViewModel.CurrentSelectionPropertyName,
                "DeleteSelectedItemTip",
                MenuLayoutViewModel.OverallUsageDetailsPropertyName,
            };

            foreach (var propertyName in initializePropertyNames)
            {
                HandleMenuLayoutPropertyChanged(viewModel.HostPCMenuLayout, new PropertyChangedEventArgs(propertyName));
            }

            MenuLayoutCommandGroup.NewDirectoryCommand.CanExecuteChanged += HandleCanExecuteCreateNewDirectoryChanged;
            MenuLayoutCommandGroup.DeleteItemsCommand.CanExecuteChanged  += HandleCanExecuteDeleteItemsChanged;

            _activeDevice = viewModel.ActiveLtoFlashDevice;

            initializePropertyNames = new[]
            {
                LtoFlashViewModel.ActiveLtoFlashDevicePropertyName,
                LtoFlashViewModel.ShowFileSystemsDifferIconPropertyName,
            };
            foreach (var propertyName in initializePropertyNames)
            {
                HandleLtoFlashPropertyChanged(viewModel, new PropertyChangedEventArgs(propertyName));
            }

            viewModel.PropertyChanged += HandleLtoFlashPropertyChanged;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Populates the submenu used to select a serial port that may be connected to LTO Flash! hardware.
        /// </summary>
        /// <param name="viewModel">Data context for the menu.</param>
        public void InitializeConnectionMenu(LtoFlashViewModel viewModel)
        {
            var menuItem = ConnectToDeviceSubmenuCommand.MenuItem;

            if (menuItem.NativeMenuItem.Submenu == null)
            {
                var menu = new NSMenu();
                MenuDelegate          = new ConnectionMenuDelegate(viewModel, this);
                menu.Delegate         = MenuDelegate;
                menu.AutoEnablesItems = false;
                MenuDelegate.InitializeMenu(menu);
                menuItem.NativeMenuItem.Submenu = menu;
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Creates a new instance of DeviceInformation.
        /// </summary>
        /// <param name="viewModel">The ViewModel to monitor for device information.</param>
        /// <returns>A new instance of the dialog.</returns>
        public static DeviceInformation Create(LtoFlashViewModel viewModel)
        {
            var dialog = new DeviceInformation(viewModel);

            return(dialog);
        }
Ejemplo n.º 8
0
        private static void SyncDeviceToHostPreviewCompleteHandler(LtoFlashViewModel ltoFlashViewModel)
        {
            var fileSystem = ltoFlashViewModel.ActiveLtoFlashDevice.Device.FileSystem;

            ltoFlashViewModel.HostPCMenuLayout.HighlightDifferencesFromDeviceFileSystem(fileSystem, MenuLayoutSynchronizationMode.FromLtoFlash);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the type OutlineViewDelegate.
 /// </summary>
 /// <param name="treeData">The tree data.</param>
 /// <param name="viewModel">The view model for the menu layout.</param>
 internal OutlineViewDelegate(NSTreeController treeData, LtoFlashViewModel viewModel)
 {
     TreeData  = treeData;
     ViewModel = viewModel;
 }
Ejemplo n.º 10
0
        private static void SyncDeviceToHostCompleteDialog(bool cancelled, bool didShowProgress, LtoFlashViewModel ltoFlashViewModel, FileSystemSyncErrors syncErrors)
        {
            ltoFlashViewModel.HostPCMenuLayout.ShowOverlay = ltoFlashViewModel.HostPCMenuLayout.Items.Count == 0;
            bool showDialog = true;
            var  title      = string.Empty;
            var  message    = string.Empty;
            var  icon       = OSMessageBoxIcon.None;

            if (syncErrors.Any)
            {
                icon  = OSMessageBoxIcon.Information;
                title = Resources.Strings.SyncDeviceToHostCommandComplete_WarningTitle;
                var briefReport = new System.Text.StringBuilder().AppendLine(Resources.Strings.SyncDeviceToHostCommandComplete_WarningsMessage);
                if (syncErrors.FailedToCreateEntries.Any())
                {
                    briefReport.AppendFormat("  " + Resources.Strings.SyncErrors_MissingEntriesFormat, syncErrors.FailedToCreateEntries.Count).AppendLine();
                }
                if (syncErrors.UnableToRetrieveForks.Any())
                {
                    briefReport.Append("  ").AppendFormat(Resources.Strings.SyncErrors_UnableToRetrieveForksFormat, syncErrors.UnableToRetrieveForks.Count).AppendLine();
                }
                if (syncErrors.OrphanedForks.Any())
                {
                    briefReport.Append("  ").AppendFormat(Resources.Strings.SyncErrors_OrphanedForksFormat, syncErrors.OrphanedForks.Count).AppendLine();
                }
                if (syncErrors.UnsupportedForks.Any())
                {
                    briefReport.Append("  ").AppendFormat(Resources.Strings.SyncErrors_UnsupportedForksFormat, syncErrors.UnsupportedForks.Count).AppendLine();
                    briefReport.AppendLine().AppendLine(Resources.Strings.SyncErrors_UnsupportedForksInfo);
                }
                briefReport.AppendLine().AppendLine(Resources.Strings.SyncDeviceToHostCommandComplete_DireWarning);
                message = briefReport.ToString();
                syncErrors.RecordErrors(Configuration.Instance.ErrorLogDirectory, "SYNC_LTOFLASH_TO_COMPUTER", "SyncDeviceToHost" + PathUtils.GetTimeString() + ".txt");
            }
            else
            {
                if (cancelled && (ltoFlashViewModel.ActiveLtoFlashDevice.Device.FileSystem.Status == LfsDirtyFlags.None))
                {
                    showDialog = false;
                }
                else if (!cancelled && !didShowProgress)
                {
                    showDialog = false;
                }
                if (showDialog)
                {
                    title = cancelled ? Resources.Strings.SyncDeviceToHostCommandCancelled_Title : Resources.Strings.SyncDeviceToHostCommandComplete_Title;
                    if (cancelled)
                    {
                        message = Resources.Strings.SyncDeviceToHostCommandCancelled_Message;
                    }
                    else
                    {
                        message = Resources.Strings.SyncDeviceToHostCommandComplete_Message;
                    }
                }
            }
            if (showDialog)
            {
                OSMessageBox.Show(message, title, OSMessageBoxButton.OK, icon);
            }
            ltoFlashViewModel.ActiveLtoFlashDevice.Device.GetFileSystemStatistics(GetFileSystemStatisticsErrorHandler);
        }
Ejemplo n.º 11
0
 private static void SyncDeviceToHostCompleteHandler(bool cancelled, bool didShowProgress, FileSystemSyncErrors syncErrors, Configuration configuration, LtoFlashViewModel ltoFlashViewModel)
 {
     if (!cancelled && (syncErrors.Data != null))
     {
         ltoFlashViewModel.ResetCachedFileSystemsCompareResult();
         var menuLayout = (MenuLayout)syncErrors.Data;
         ltoFlashViewModel.HostPCMenuLayout.MenuLayout = menuLayout;
         var device = ltoFlashViewModel.ActiveLtoFlashDevice.Device;
         menuLayout.Save(configuration.GetMenuLayoutPath(device.UniqueId), true);
         ltoFlashViewModel.HostPCMenuLayout.ClearItemStates(ltoFlashViewModel.AttachedPeripherals);
     }
     SingleInstanceApplication.MainThreadDispatcher.BeginInvoke(new System.Action(() => SyncDeviceToHostCompleteDialog(cancelled, didShowProgress, ltoFlashViewModel, syncErrors)));
 }
Ejemplo n.º 12
0
        private static bool SyncHostToDeviceErrorHandler(string errorMessage, System.Exception exception, LtoFlashViewModel ltoFlashViewModel)
        {
            ltoFlashViewModel.HostPCMenuLayout.ShowOverlay = false;
            var message = string.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.Strings.SyncHostToDeviceCommand_Failed_Message_Format, errorMessage);
            ////OSMessageBox.Show(message, Resources.Strings.SyncHostToDeviceCommand_Failed_Title, (r) => { });
            var reportCompleteDialog = INTV.Shared.View.ReportDialog.Create(Resources.Strings.SyncHostToDeviceCommand_Failed_Title, message);

            if (SingleInstanceApplication.SharedSettings.ShowDetailedErrors)
            {
                reportCompleteDialog.Exception = exception;
            }
            var reportText = new System.Text.StringBuilder(errorMessage);

            reportCompleteDialog.ReportText   = reportText.AppendLine().AppendLine().Append(Resources.Strings.SyncHostToDeviceCommand_Failed_Resolution).ToString();
            reportCompleteDialog.TextWrapping = OSTextWrapping.Wrap;
            reportCompleteDialog.BeginInvokeDialog(Resources.Strings.OK, null);
            ltoFlashViewModel.ClearItemStates(ltoFlashViewModel.AttachedPeripherals);
            return(true);
        }
Ejemplo n.º 13
0
        private static void SyncHostToDeviceCompleteDialog(bool cancelled, bool didShowProgress, LtoFlashViewModel ltoFlashViewModel, IDictionary <string, FailedOperationException> warnings)
        {
            ltoFlashViewModel.HostPCMenuLayout.ShowOverlay = false;
            bool showDialog = true;

            if (cancelled && (ltoFlashViewModel.ActiveLtoFlashDevice.Device.FileSystem.Status == LfsDirtyFlags.None))
            {
                showDialog = false;
            }
            if (showDialog)
            {
                var title   = cancelled ? Resources.Strings.SyncHostToDeviceCommandCancelled_Title : Resources.Strings.SyncHostToDeviceCommandComplete_Title;
                var message = string.Empty;
                if (cancelled)
                {
                    if (ltoFlashViewModel.ActiveLtoFlashDevice.Device.FileSystem.Status == LfsDirtyFlags.None)
                    {
                        message = Resources.Strings.SyncHostToDeviceCommandCancelledNoChanges_Message;
                    }
                    else
                    {
                        message = Resources.Strings.SyncHostToDeviceCommandCancelled_Message;
                    }
                }
                else
                {
                    message = Resources.Strings.SyncHostToDeviceCommandComplete_Message;
                }
                var result = OSMessageBoxResult.Yes;
                if ((warnings != null) && warnings.Any())
                {
                    var reportDialog = ReportDialog.Create(title, message);
                    reportDialog.ShowSendEmailButton = false;
                    var warningsBuilder = new System.Text.StringBuilder(Resources.Strings.SyncHostToDeviceCommand_WarningMessage).AppendLine().AppendLine();
                    foreach (var warning in warnings)
                    {
                        warningsBuilder.AppendFormat(Resources.Strings.SyncHostToDeviceCommand_WarningFormat, warning.Key, warning.Value.Message).AppendLine().AppendLine();
                    }
                    if (SingleInstanceApplication.SharedSettings.ShowDetailedErrors)
                    {
                        warningsBuilder.AppendLine(Resources.Strings.SyncHostToDeviceCommand_WarningDetailHeader).AppendLine("------------------------------------------------");
                        foreach (var exception in warnings.Values)
                        {
                            warningsBuilder.AppendLine(exception.ToString()).AppendLine();
                        }
                    }
                    reportDialog.ReportText   = warningsBuilder.ToString();
                    reportDialog.TextWrapping = OSTextWrapping.Wrap;
                    reportDialog.ShowDialog(Resources.Strings.OK);
                }
                else
                {
                    var buttons = cancelled ? OSMessageBoxButton.YesNo : OSMessageBoxButton.OK;
                    result = OSMessageBox.Show(message, title, buttons);
                }
                if (cancelled && (result == OSMessageBoxResult.Yes) && CanSyncHostToDevicePreview(ltoFlashViewModel))
                {
                    SyncHostToDevicePreview(ltoFlashViewModel);
                }
            }
            ltoFlashViewModel.ActiveLtoFlashDevice.Device.GetFileSystemStatistics(GetFileSystemStatisticsErrorHandler);
        }
Ejemplo n.º 14
0
 private static void SyncHostToDeviceCompleteHandler(bool cancelled, bool didShowProgress, Tuple <FileSystem, IDictionary <string, FailedOperationException> > result, Configuration configuration, LtoFlashViewModel ltoFlashViewModel)
 {
     if (!cancelled)
     {
         ltoFlashViewModel.ResetCachedFileSystemsCompareResult();
         var menuLayout = ltoFlashViewModel.HostPCMenuLayout.MenuLayout;
         var device     = ltoFlashViewModel.ActiveLtoFlashDevice.Device;
         device.FileSystem = result.Item1;
         menuLayout.Save(configuration.GetMenuLayoutPath(device.UniqueId), true);
         ltoFlashViewModel.HostPCMenuLayout.ClearItemStates(ltoFlashViewModel.AttachedPeripherals);
     }
     SingleInstanceApplication.MainThreadDispatcher.BeginInvoke(new System.Action(() => SyncHostToDeviceCompleteDialog(cancelled, didShowProgress, ltoFlashViewModel, result == null ? null : result.Item2)));
 }
Ejemplo n.º 15
0
 public ConnectionMenuDelegate(LtoFlashViewModel ltoFlash, DeviceCommandGroup commandGroup)
 {
     _group    = commandGroup;
     _ltoFlash = ltoFlash;
     CommandManager.RequerySuggested += HandleRequerySuggested;
 }
Ejemplo n.º 16
0
        private static bool SyncDeviceToHostErrorHandler(string errorMessage, System.Exception exception, LtoFlashViewModel viewModel)
        {
            viewModel.HostPCMenuLayout.ShowOverlay = false;
            var showInconsistentFileInfo = ((exception != null) && (exception is InconsistentFileSystemException)) || (exception.InnerException is InconsistentFileSystemException);

            if (showInconsistentFileInfo)
            {
                OSMessageBox.Show(
                    Resources.Strings.DeviceMultistageCommand_UpdatingMenuLayout_InconsistentStateErrorMessage,
                    Resources.Strings.FileSystem_Inconsistent_Title,
                    null,
                    OSMessageBoxButton.YesNo,
                    OSMessageBoxIcon.Exclamation,
                    (result) =>
                {
                    if (result == OSMessageBoxResult.Yes)
                    {
                        SingleInstanceApplication.MainThreadDispatcher.BeginInvoke(new System.Action(() => SyncDeviceToHost(viewModel, true)));
                    }
                });
            }
            else
            {
                var message = string.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.Strings.SyncDeviceToHostCommand_Failed_Message_Format, errorMessage);
                OSMessageBox.Show(message, Resources.Strings.SyncDeviceToHostCommand_Failed_Title, SingleInstanceApplication.SharedSettings.ShowDetailedErrors ? exception : null, (r) => { });
            }
            return(true);
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Mac-specific implementation.
 /// </summary>
 /// <param name="viewModel">View model.</param>
 static partial void RestoreMenuLayoutComplete(LtoFlashViewModel viewModel)
 {
     RomListCommandGroup.SortRoms();
 }