コード例 #1
0
        public DescriptionsPlugin(
            ILoggerFacade logger,
            IUnityContainer container,
            IEventAggregator eventAggregator,
            [Import(typeof(IUrakawaSession), RequiredCreationPolicy = CreationPolicy.Shared, AllowDefault = false)]
            IUrakawaSession session,
            [Import(typeof(IShellView), RequiredCreationPolicy = CreationPolicy.Shared, AllowDefault = false)]
            IShellView shellView,
            [Import(typeof(IDescriptionsView), RequiredCreationPolicy = CreationPolicy.Shared, AllowDefault = false)]
            DescriptionsView view
            )
        {
            m_Logger           = logger;
            m_Container        = container;
            m_ShellView        = shellView;
            m_DescriptionsView = view;

            m_UrakawaSession  = session;
            m_EventAggregator = eventAggregator;

            CommandShowDescriptions = new RichDelegateCommand(
                Tobi_Plugin_Descriptions_Lang.CmdEditDescriptions_ShortDesc,
                Tobi_Plugin_Descriptions_Lang.CmdEditDescriptions_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon(@"edit-find-replace"),
                ShowDialog,
                CanShowDialog,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_EditDescriptions));

            m_ShellView.RegisterRichCommand(CommandShowDescriptions);

            //m_Logger.Log(@"DescriptionsPlugin init", Category.Debug, Priority.Medium);
        }
コード例 #2
0
        public RecentFileWrapper(Uri uri)
        {
            Uri = uri;

            m_PropertyChangeHandler = new PropertyChangedNotifyBase();
            m_PropertyChangeHandler.InitializeDependentProperties(this);
        }
コード例 #3
0
        public MetadataPanePlugin(
            ILoggerFacade logger,
            IEventAggregator eventAggregator,
            [Import(typeof(IUrakawaSession), RequiredCreationPolicy = CreationPolicy.Shared, AllowDefault = false)]
            IUrakawaSession session,
            [Import(typeof(IShellView), RequiredCreationPolicy = CreationPolicy.Shared, AllowDefault = false)]
            IShellView shellView,
            [Import(typeof(IMetadataPaneView), RequiredCreationPolicy = CreationPolicy.Shared, AllowDefault = false)]
            MetadataPaneView view)
        {
            m_Logger           = logger;
            m_UrakawaSession   = session;
            m_ShellView        = shellView;
            m_MetadataPaneView = view;
            m_EventAggregator  = eventAggregator;

            CommandShowMetadataPane = new RichDelegateCommand(
                Tobi_Plugin_MetadataPane_Lang.CmdShowMetadata_ShortDesc,
                Tobi_Plugin_MetadataPane_Lang.CmdShowMetadata_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadGnomeGionIcon(@"Gion_text-x-readme"),
                ShowDialog,
                CanShowDialog,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Metadata_Edit));

            m_ShellView.RegisterRichCommand(CommandShowMetadataPane);

            m_EventAggregator.GetEvent <LaunchMetadataEditorEvent>().Subscribe(OnLaunchMetadataEditor, LaunchMetadataEditorEvent.THREAD_OPTION);


            //m_Logger.Log(@"Metadata plugin initializing...", Category.Debug, Priority.Medium);
        }
コード例 #4
0
 public StateData(PropertyChangedNotifyBase notifier, AudioPaneViewModel vm)
 {
     m_notifier  = notifier;
     m_viewModel = vm;
     Audio       = new StreamStateData(m_notifier, vm);
     Selection   = new SelectionStateData(m_notifier, vm);
 }
コード例 #5
0
        public SettingsView(
            ILoggerFacade logger,
            [Import(typeof(IShellView), RequiredCreationPolicy = CreationPolicy.Shared, AllowDefault = false)]
            IShellView shellView,
            [Import(typeof(IUrakawaSession), RequiredCreationPolicy = CreationPolicy.Shared, AllowDefault = false)]
            IUrakawaSession session,
            [Import(typeof(ISettingsAggregator), RequiredCreationPolicy = CreationPolicy.Shared, AllowRecomposition = false)]
            ISettingsAggregator settingsAggregator)
        {
            m_PropertyChangeHandler = new PropertyChangedNotifyBase();
            m_PropertyChangeHandler.InitializeDependentProperties(this);

            m_Logger    = logger;
            m_ShellView = shellView;
            m_Session   = session;

            m_SettingsAggregator = settingsAggregator;

            resetList();

            InitializeComponent();

            intializeCommands();

            // NEEDS to be after InitializeComponent() in order for the DataContext bridge to work.
            DataContext = this;
        }
コード例 #6
0
        public SettingsPlugin(
            ILoggerFacade logger,
            IUnityContainer container,
            [Import(typeof(IShellView), RequiredCreationPolicy = CreationPolicy.Shared, AllowDefault = false)]
            IShellView shellView,
            //[Import(typeof(SettingsView), RequiredCreationPolicy = CreationPolicy.Shared, AllowDefault = false)]
            //SettingsView view,
            [Import(typeof(IUrakawaSession), RequiredCreationPolicy = CreationPolicy.Shared, AllowDefault = false)]
            IUrakawaSession session,
            [Import(typeof(ISettingsAggregator), RequiredCreationPolicy = CreationPolicy.Shared, AllowRecomposition = false)]
            ISettingsAggregator settingsAggregator)
        {
            m_Logger    = logger;
            m_Container = container;
            m_ShellView = shellView;

            //m_SettingsView = view;
            m_UrakawaSession = session;

            m_SettingsAggregator = settingsAggregator;

            CommandShowSettings = new RichDelegateCommand(
                Tobi_Plugin_Settings_Lang.Cmd_ApplicationPref,
                Tobi_Plugin_Settings_Lang.Cmd_DisplayEditor,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon(@"preferences-system"),
                ShowDialog,
                CanShowDialog,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_EditPreferences));

            m_ShellView.RegisterRichCommand(CommandShowSettings);

            //m_Logger.Log(@"SettingsPlugin init", Category.Debug, Priority.Medium);
        }
コード例 #7
0
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            if (item is RichDelegateCommand)
            {
                ConfigureMenuItemFromCommand((MenuItemRichCommand)element, (RichDelegateCommand)item);
            }
            else if (item is TwoStateMenuItemRichCommand_DataContextWrapper)
            {
                var data     = (TwoStateMenuItemRichCommand_DataContextWrapper)item;
                var menuItem = (TwoStateMenuItemRichCommand)element;

                menuItem.RichCommandOne      = data.RichCommandOne;
                menuItem.RichCommandTwo      = data.RichCommandTwo;
                menuItem.InputBindingManager = data.InputBindingManager;

                var binding = new Binding
                {
                    Mode   = BindingMode.OneWay,
                    Source = data.RichCommandActive_BindingSource,
                    Path   = new PropertyPath(PropertyChangedNotifyBase.GetMemberName(data.RichCommandActive_BindingPropertyPathLambdaExpr))
                };

                var expr = menuItem.SetBinding(TwoStateMenuItemRichCommand.RichCommandActiveProperty, binding);

                // NOT needed because OnRichCommandActiveChanged() is triggered by the above binding statement
                //TwoStateMenuItemRichCommand.ConfigureTwoStateMenuItemRichCommand(menuItem, data.RichCommandActive);
            }

            base.PrepareContainerForItemOverride(element, item);
        }
コード例 #8
0
 private void OnSettingsPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == PropertyChangedNotifyBase.GetMemberName(() => Tobi.Common.Settings.Default.ValidMissingAudioElements))
     {
         m_ValidNoAudioElements = null;
     }
 }
コード例 #9
0
        private void InitializeCommands()
        {
            CmdFindFocus = new RichDispatcherCommand(Tobi_Lang.CmdFocus_ShortDesc_Find,
                                                     Tobi_Lang.CmdFocus_LongDesc_Find,
                                                     null, // KeyGesture obtained from settings (see last parameters below)
                                                     m_ShellView.LoadTangoIcon("edit-find"),
                                                     Settings_KeyGestures.Default,
                                                     PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Find));

            m_ShellView.RegisterRichCommand(CmdFindFocus);

            CmdFindNext = new RichDispatcherCommand(Tobi_Lang.Cmd_ShortDesc_FindNext,
                                                    Tobi_Lang.Cmd_LongDesc_FindNext,
                                                    null, // KeyGesture obtained from settings (see last parameters below)
                                                    m_ShellView.LoadTangoIcon("format-indent-more"),
                                                    Settings_KeyGestures.Default,
                                                    PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_FindNext));

            m_ShellView.RegisterRichCommand(CmdFindNext);

            CmdFindPrevious = new RichDispatcherCommand(Tobi_Lang.Cmd_ShortDesc_FindPrevious,
                                                        Tobi_Lang.Cmd_LongDesc_FindPrevious,
                                                        null, // KeyGesture obtained from settings (see last parameters below)
                                                        m_ShellView.LoadTangoIcon("format-indent-less"),
                                                        Settings_KeyGestures.Default,
                                                        PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_FindPrevious));

            m_ShellView.RegisterRichCommand(CmdFindPrevious);
        }
コード例 #10
0
        private PopupModalWindow(IShellPresenter presenter)
        {
            ShellPresenter = presenter;

            ClickedDialogButton = DialogButton.ESC;

            m_PropertyChangeHandler = new PropertyChangedNotifyBase();
            m_PropertyChangeHandler.InitializeDependentProperties(this);

            InitializeComponent();

            CommandDetailsExpand = new RichDelegateCommand <object>(UserInterfaceStrings.DetailsExpand,
                                                                    UserInterfaceStrings.DetailsExpand_,
                                                                    UserInterfaceStrings.DetailsExpand_KEYS,
                                                                    ShellPresenter.LoadTangoIcon("go-down"),
                                                                    obj => IsDetailsExpanded = true,
                                                                    obj => CanDetailsExpand);

            AddInputBinding(CommandDetailsExpand.KeyBinding);

            CommandDetailsCollapse = new RichDelegateCommand <object>(UserInterfaceStrings.DetailsCollapse,
                                                                      UserInterfaceStrings.DetailsCollapse_,
                                                                      UserInterfaceStrings.DetailsCollapse_KEYS,
                                                                      ShellPresenter.LoadTangoIcon("go-up"),
                                                                      obj => IsDetailsExpanded = false,
                                                                      obj => CanDetailsCollapse);

            AddInputBinding(CommandDetailsCollapse.KeyBinding);

            m_IsDetailsExpanded = false;
        }
コード例 #11
0
        public XukSpineItemWrapper(XukSpineItemData data, int index, XukSpineView view)
        {
            Data = data;
            Index = index;
            View = view;

            m_PropertyChangeHandler = new PropertyChangedNotifyBase();
            m_PropertyChangeHandler.InitializeDependentProperties(this);
        }
コード例 #12
0
        public SettingWrapper(ApplicationSettingsBase settingBase, SettingsProperty settingProperty)
        {
            m_settingBase     = settingBase;
            m_settingProperty = settingProperty;

            m_PropertyChangeHandler = new PropertyChangedNotifyBase();
            m_PropertyChangeHandler.InitializeDependentProperties(this);

            m_OriginalValue = Value;

            IsValid = true;
        }
コード例 #13
0
ファイル: PopupModalWindow.xaml.cs プロジェクト: daisy/tobi
        private PopupModalWindow(IShellView shellView)
        {
            ShellView = shellView;

            //if (this != Application.Current.MainWindow)
            //{
            //    Owner = ShellView == null ? Application.Current.MainWindow : ShellView.View.Window;
            //}
            //else { Owner = null; }

            //#if NET_3_5

            //#else  // NET_4_0 || BOOTSTRAP_NET_4_0

            //#endif


            //DataContext = Owner;

            EnableEnterKeyDefault = false;


            PreviewKeyDown += new KeyEventHandler(OnThisKeyDown);


            ClickedDialogButton = DialogButton.ESC;

            m_PropertyChangeHandler = new PropertyChangedNotifyBase();
            m_PropertyChangeHandler.InitializeDependentProperties(this);

            ActiveAware = new FocusActiveAwareAdapter(this);
            ActiveAware.IsActiveChanged += (sender, e) =>
            {
                if (!ActiveAware.IsActive)
                {
                    Console.WriteLine("@@@@ popup lost focus");
                }
                else
                {
                    Console.WriteLine("@@@@ popup gained focus");
                }
                CommandManager.InvalidateRequerySuggested();
            };

            InitializeComponent();

            //RegionManager.SetRegionManager(this, m_Container.Resolve<IRegionManager>());
            //RegionManager.UpdateRegions();

            initCommands();

            m_IsDetailsExpanded = false;
        }
コード例 #14
0
        public static void RefreshMenuItemFromItsRichCommand(MenuItem menuItem)
        {
            var command = menuItem.Command as RichDelegateCommand;

            if (command == null)
            {
#if DEBUG
                Debugger.Break();
#endif
                return;
            }


            menuItem.Header  = command.ShortDescription;
            menuItem.ToolTip = command.LongDescription + (command.KeyGesture != null ? " " + command.KeyGestureText + " " : "");

            menuItem.SetValue(AutomationProperties.NameProperty, UserInterfaceStrings.EscapeMnemonic(command.ShortDescription) + " / " + menuItem.ToolTip);
            //button.SetValue(AutomationProperties.HelpTextProperty, command.ShortDescription);

            menuItem.InputGestureText = command.KeyGestureText;

            //Image image = command.IconProvider.IconSmall;
            //image.Margin = new Thickness(0, 2, 0, 2);
            //image.VerticalAlignment = VerticalAlignment.Center;


            if (command.HasIcon)
            {
                var iconProvider = command.IconProviderNotShared;

                iconProvider.IconMargin_Small = new Thickness(0, 2, 0, 2);

                //menuItem.Icon = image;

                var binding = new Binding
                {
                    Mode   = BindingMode.OneWay,
                    Source = iconProvider,
                    Path   =
                        new PropertyPath(
                            PropertyChangedNotifyBase.GetMemberName(() => iconProvider.IconSmall))
                };

                var expr = menuItem.SetBinding(MenuItem.IconProperty, binding);
            }
        }
コード例 #15
0
        public ValidatorPlugin(
            ILoggerFacade logger,
            IEventAggregator eventAggregator,
            [Import(typeof(IShellView), RequiredCreationPolicy = CreationPolicy.Shared, AllowDefault = false)]
            IShellView shellView,
            [Import(typeof(IUrakawaSession), RequiredCreationPolicy = CreationPolicy.Shared, AllowDefault = false)]
            IUrakawaSession urakawaSession,
            [Import(typeof(ValidatorPaneView), RequiredCreationPolicy = CreationPolicy.Shared, AllowDefault = false)]
            ValidatorPaneView view)
        {
            m_Logger         = logger;
            m_ShellView      = shellView;
            m_UrakawaSession = urakawaSession;

            m_EventAggregator = eventAggregator;

            m_ValidatorPaneView = view;

            m_validatorClassToShow = null;

            m_EventAggregator.GetEvent <ValidationReportRequestEvent>().Subscribe(
                validatorClassName =>
            {
                m_validatorClassToShow = validatorClassName as String;
                CommandShowValidator.Execute();
            },
                ValidationReportRequestEvent.THREAD_OPTION);


            CommandShowValidator = new RichDelegateCommand(
                Tobi_Plugin_Validator_Lang.CmdValidationCheck_ShortDesc,
                Tobi_Plugin_Validator_Lang.CmdValidationCheck_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadGnomeGionIcon(@"Gion_application-certificate"),
                ShowDialog,
                CanShowDialog,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_DisplayValidator));

            m_ShellView.RegisterRichCommand(CommandShowValidator);

            //m_Logger.Log(@"ValidatorPlugin init", Category.Debug, Priority.Medium);
        }
コード例 #16
0
        private void initCommands_Save()
        {
            //
            SaveAsCommand = new RichDelegateCommand(
                Tobi_Plugin_Urakawa_Lang.CmdSaveAs_ShortDesc,
                Tobi_Plugin_Urakawa_Lang.CmdSaveAs_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon(@"document-save"),
                //ScalableGreyableImageProvider.ConvertIconFormat((DrawingImage)Application.Current.FindResource("Horizon_Image_Save_As")),
                () =>
            {
                if (DocumentProject == null)
                {
                    return;
                }

                m_Logger.Log(@"UrakawaSession.saveAs", Category.Debug, Priority.Medium);

                bool saved = saveAsCommand(null, false);

                //var fileDialog = Container.Resolve<IFileDialogService>();
                //return fileDialog.SaveAs();
            },
                () => DocumentProject != null && !IsXukSpine && !isAudioRecording,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_SaveAs));

            m_ShellView.RegisterRichCommand(SaveAsCommand);
            //
            SaveCommand = new RichDelegateCommand(
                Tobi_Plugin_Urakawa_Lang.CmdSave_ShortDesc,
                Tobi_Plugin_Urakawa_Lang.CmdSave_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon(@"drive-harddisk"),
                //ScalableGreyableImageProvider.ConvertIconFormat((DrawingImage)Application.Current.FindResource("Horizon_Image_Save")),
                () => save(false),
                () => DocumentProject != null && !isAudioRecording,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Save));

            m_ShellView.RegisterRichCommand(SaveCommand);
        }
コード例 #17
0
        public RecentFilesView(
            ILoggerFacade logger,
            [Import(typeof(IShellView), RequiredCreationPolicy = CreationPolicy.Shared, AllowDefault = false)]
            IShellView shellView,
            [Import(typeof(IUrakawaSession), RequiredCreationPolicy = CreationPolicy.Shared, AllowDefault = false)]
            IUrakawaSession session)
        {
            m_PropertyChangeHandler = new PropertyChangedNotifyBase();
            m_PropertyChangeHandler.InitializeDependentProperties(this);

            m_Logger    = logger;
            m_ShellView = shellView;
            m_Session   = session;

            resetList();

            DataContext = this;
            InitializeComponent();

            intializeCommands();
        }
コード例 #18
0
#pragma warning restore 1591
        private void initCommands()
        {
            CommandFocus = new RichDelegateCommand(
                Tobi_Plugin_ToolBars_Lang.CmdToolbarFocus_ShortDesc,
                null,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon("applications-other"),
                () =>
            {
                if (FocusCollapsed.IsVisible)
                {
                    FocusHelper.FocusBeginInvoke(FocusCollapsed);
                }
                else
                {
                    FocusHelper.FocusBeginInvoke(FocusExpanded);
                }
            },
                () => true,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Focus_Toolbar));
            m_ShellView.RegisterRichCommand(CommandFocus);
        }
コード例 #19
0
        private void initializeCommands_View()
        {
            CommandStopPlayMonitorRecord = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioStopRecord_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioStopRecord_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                //null, //ScalableGreyableImageProvider.ConvertIconFormat((DrawingImage)Application.Current.FindResource("Horizon_Image_Refresh")),
                null,
                () =>
                {
                    //Logger.Log("AudioPaneViewModel.CommandRefresh", Category.Debug, Priority.Medium);

                    OnStopPlayMonitorRecord();
                },
                () => true,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_StopPlayMonitorRecord));

            m_ShellView.RegisterRichCommand(CommandStopPlayMonitorRecord);
            //
            CommandRefresh = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioReload_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioReload_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                //null, //ScalableGreyableImageProvider.ConvertIconFormat((DrawingImage)Application.Current.FindResource("Horizon_Image_Refresh")),
                m_ShellView.LoadTangoIcon("view-refresh"),
                () =>
                {
                    //Logger.Log("AudioPaneViewModel.CommandRefresh", Category.Debug, Priority.Medium);

                    //StartWaveFormLoadTimer(0);

                    AudioPlayer_LoadWaveForm(false);
                },
                () => CanManipulateWaveForm,
                //!IsWaveFormLoading,
                null, null); //IsAudioLoaded

            m_ShellView.RegisterRichCommand(CommandRefresh);
            //
            CommandZoomSelection = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioZoomSelection_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioZoomSelection_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                ScalableGreyableImageProvider.ConvertIconFormat((DrawingImage)Application.Current.FindResource("Horizon_Image_Search")),
                //shellView.LoadTangoIcon("system-search"),
                () =>
                {
                    Logger.Log("AudioPaneViewModel.CommandZoomSelection", Category.Debug, Priority.Medium);

                    View.ZoomSelection();
                },
                () => View != null
                    && State.Audio.HasContent
                    && CanManipulateWaveForm
                    //&&!IsWaveFormLoading
                    && IsSelectionSet,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_ZoomSelection));

            m_ShellView.RegisterRichCommand(CommandZoomSelection);
            //
            CommandZoomFitFull = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioFitFull_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioFitFull_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadGnomeNeuIcon("Neu_utilities-system-monitor"),
                () =>
                {
                    Logger.Log("AudioPaneViewModel.CommandZoomFitFull", Category.Debug, Priority.Medium);

                    View.ZoomFitFull();
                },
                () => View != null
                    && State.Audio.HasContent
                    && CanManipulateWaveForm,
                //&& !IsWaveFormLoading,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_ZoomFitFull));
            //Settings_KeyGestures.Default.Keyboard_Audio_Zoom_0

            m_ShellView.RegisterRichCommand(CommandZoomFitFull);
            //
            CommandZoom_0 = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioFitFull_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioFitFull_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                null, //m_ShellView.LoadGnomeNeuIcon("Neu_utilities-system-monitor"),
                () =>
                {
                    //Logger.Log("AudioPaneViewModel.CommandZoom_0", Category.Debug, Priority.Medium);
                    //View.ZoomFitFull();

                    CommandZoomFitFull.Execute();
                },
                () => CommandZoomFitFull.CanExecute(),
                //&& !IsWaveFormLoading,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_Zoom_0));

            m_ShellView.RegisterRichCommand(CommandZoom_0);
            //
            CommandZoom_1 = new RichDelegateCommand(
                "Zoom 1",
                "Zoom 1",
                null, // KeyGesture obtained from settings (see last parameters below)
                null, //m_ShellView.LoadGnomeNeuIcon("Neu_utilities-system-monitor"),
                () =>
                {
                    Logger.Log("AudioPaneViewModel.CommandZoom_1", Category.Debug, Priority.Medium);

                    View.Zoom_1();
                },
                () => CommandZoomFitFull.CanExecute(),
                //&& !IsWaveFormLoading,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_Zoom_1));

            m_ShellView.RegisterRichCommand(CommandZoom_1);
            //
            CommandZoom_2 = new RichDelegateCommand(
                "Zoom 2",
                "Zoom 2",
                null, // KeyGesture obtained from settings (see last parameters below)
                null, //m_ShellView.LoadGnomeNeuIcon("Neu_utilities-system-monitor"),
                () =>
                {
                    Logger.Log("AudioPaneViewModel.CommandZoom_2", Category.Debug, Priority.Medium);

                    View.Zoom_2();
                },
                () => CommandZoomFitFull.CanExecute(),
                //&& !IsWaveFormLoading,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_Zoom_2));

            m_ShellView.RegisterRichCommand(CommandZoom_2);
            //
            CommandZoom_3 = new RichDelegateCommand(
                "Zoom 3",
                "Zoom 3",
                null, // KeyGesture obtained from settings (see last parameters below)
                null, //m_ShellView.LoadGnomeNeuIcon("Neu_utilities-system-monitor"),
                () =>
                {
                    Logger.Log("AudioPaneViewModel.CommandZoom_3", Category.Debug, Priority.Medium);

                    View.Zoom_3();
                },
                () => CommandZoomFitFull.CanExecute(),
                //&& !IsWaveFormLoading,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_Zoom_3));

            m_ShellView.RegisterRichCommand(CommandZoom_3);
            //
            CommandZoom_4 = new RichDelegateCommand(
                "Zoom 4",
                "Zoom 4",
                null, // KeyGesture obtained from settings (see last parameters below)
                null, //m_ShellView.LoadGnomeNeuIcon("Neu_utilities-system-monitor"),
                () =>
                {
                    Logger.Log("AudioPaneViewModel.CommandZoom_4", Category.Debug, Priority.Medium);

                    View.Zoom_4();
                },
                () => CommandZoomFitFull.CanExecute(),
                //&& !IsWaveFormLoading,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_Zoom_4));

            m_ShellView.RegisterRichCommand(CommandZoom_4);
            //
            CommandZoom_5 = new RichDelegateCommand(
                "Zoom 5",
                "Zoom 5",
                null, // KeyGesture obtained from settings (see last parameters below)
                null, //m_ShellView.LoadGnomeNeuIcon("Neu_utilities-system-monitor"),
                () =>
                {
                    Logger.Log("AudioPaneViewModel.CommandZoom_5", Category.Debug, Priority.Medium);

                    View.Zoom_5();
                },
                () => CommandZoomFitFull.CanExecute(),
                //&& !IsWaveFormLoading,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_Zoom_5));

            m_ShellView.RegisterRichCommand(CommandZoom_5);
            //
            CommandZoom_6 = new RichDelegateCommand(
                "Zoom 6",
                "Zoom 6",
                null, // KeyGesture obtained from settings (see last parameters below)
                null, //m_ShellView.LoadGnomeNeuIcon("Neu_utilities-system-monitor"),
                () =>
                {
                    Logger.Log("AudioPaneViewModel.CommandZoom_6", Category.Debug, Priority.Medium);

                    View.Zoom_6();
                },
                () => CommandZoomFitFull.CanExecute(),
                //&& !IsWaveFormLoading,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_Zoom_6));

            m_ShellView.RegisterRichCommand(CommandZoom_6);
            //
            CommandZoom_7 = new RichDelegateCommand(
                "Zoom 7",
                "Zoom 7",
                null, // KeyGesture obtained from settings (see last parameters below)
                null, //m_ShellView.LoadGnomeNeuIcon("Neu_utilities-system-monitor"),
                () =>
                {
                    Logger.Log("AudioPaneViewModel.CommandZoom_7", Category.Debug, Priority.Medium);

                    View.Zoom_7();
                },
                () => CommandZoomFitFull.CanExecute(),
                //&& !IsWaveFormLoading,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_Zoom_7));

            m_ShellView.RegisterRichCommand(CommandZoom_7);
            //
            CommandZoom_8 = new RichDelegateCommand(
                "Zoom 8",
                "Zoom 8",
                null, // KeyGesture obtained from settings (see last parameters below)
                null, //m_ShellView.LoadGnomeNeuIcon("Neu_utilities-system-monitor"),
                () =>
                {
                    Logger.Log("AudioPaneViewModel.CommandZoom_8", Category.Debug, Priority.Medium);

                    View.Zoom_8();
                },
                () => CommandZoomFitFull.CanExecute(),
                //&& !IsWaveFormLoading,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_Zoom_8));

            m_ShellView.RegisterRichCommand(CommandZoom_8);
            //
            CommandZoom_9 = new RichDelegateCommand(
                "Zoom 9",
                "Zoom 9",
                null, // KeyGesture obtained from settings (see last parameters below)
                null, //m_ShellView.LoadGnomeNeuIcon("Neu_utilities-system-monitor"),
                () =>
                {
                    Logger.Log("AudioPaneViewModel.CommandZoom_9", Category.Debug, Priority.Medium);

                    View.Zoom_9();
                },
                () => CommandZoomFitFull.CanExecute(),
                //&& !IsWaveFormLoading,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_Zoom_9));

            m_ShellView.RegisterRichCommand(CommandZoom_9);
            //
            CommandAudioSettings = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioSettings_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioSettings_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadGnomeNeuIcon("Neu_audio-x-generic"),
                () =>
                {
                    Logger.Log("AudioPaneViewModel.CommandAudioSettings", Category.Debug, Priority.Medium);

                    var windowPopup = new PopupModalWindow(m_ShellView,
                                                           UserInterfaceStrings.EscapeMnemonic(Tobi_Plugin_AudioPane_Lang.CmdAudioSettings_ShortDesc),
                                                           new AudioSettings(this),
                                                           PopupModalWindow.DialogButtonsSet.Close,
                                                           PopupModalWindow.DialogButton.Close,
                                                           true, 420, 220, null, 0,null);
                    windowPopup.EnableEnterKeyDefault = true;
                    windowPopup.ShowFloating(()=>
                        {
                            m_SpeechSynthesizer.SpeakAsyncCancelAll();
                        });
                },
                () => !IsRecording,
                Settings_KeyGestures.Default,
                null //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_ShowOptions)
                );

            m_ShellView.RegisterRichCommand(CommandAudioSettings);
            //
#if DEBUG
            CommandShowAudioOptionsDialog = new RichDelegateCommand(
                @"Show audio options",
                null,
                null, // KeyGesture obtained from settings (see last parameters below)
                null,
                ()=>
                {
                    Logger.Log("AudioPaneViewModel.CommandShowOptionsDialog", Category.Debug, Priority.Medium);

                    //var window = shellView.View as Window;

                    var pane = new AudioOptions { DataContext = this };

                    var windowPopup = new PopupModalWindow(m_ShellView,
                                                           UserInterfaceStrings.EscapeMnemonic(@"Show audio options"),
                                                           pane,
                                                           PopupModalWindow.DialogButtonsSet.Close,
                                                           PopupModalWindow.DialogButton.Close,
                                                           true, 400, 500, null, 0,null);
                    windowPopup.EnableEnterKeyDefault = true;
                    windowPopup.Show();
                },
                () => true,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_ExpertOptions)
                );

            m_ShellView.RegisterRichCommand(CommandShowAudioOptionsDialog);
#endif //DEBUG
            //
            CommandFocus = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioFocus_ShortDesc,
                null,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon("audio-volume-low"),
                () =>
                {
                    Logger.Log("AudioPaneViewModel.CommandFocus", Category.Debug, Priority.Medium);

                    View.BringIntoFocus();
                },
                () => View != null,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Focus_Audio));

            m_ShellView.RegisterRichCommand(CommandFocus);
            //
            CommandFocusStatusBar = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioFocusStatusBar_ShortDesc,
                null,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadGnomeNeuIcon("Neu_utilities-terminal"),
                () =>
                {
                    Logger.Log("AudioPaneViewModel.CommandFocusStatusBar", Category.Debug, Priority.Medium);

                    View.BringIntoFocusStatusBar();
                },
                () => View != null,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Focus_StatusBar));

            m_ShellView.RegisterRichCommand(CommandFocusStatusBar);
            //
        }
コード例 #20
0
        public StructureTrailPaneView(
            IEventAggregator eventAggregator,
            ILoggerFacade logger,
            [Import(typeof(IUrakawaSession), RequiredCreationPolicy = CreationPolicy.Shared, AllowDefault = false)]
            IUrakawaSession urakawaSession,
            [Import(typeof(IShellView), RequiredCreationPolicy = CreationPolicy.Shared, AllowDefault = false)]
            IShellView shellView)
        {
            m_UrakawaSession  = urakawaSession;
            m_EventAggregator = eventAggregator;
            m_Logger          = logger;
            m_ShellView       = shellView;

            DataContext = this;

            //
            CommandFocus = new RichDelegateCommand(
                Tobi_Plugin_StructureTrailPane_Lang.CmdDocumentFocus_ShortDesc,
                null,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadGnomeNeuIcon("Neu_format-indent-more"),
                () => FocusHelper.FocusBeginInvoke(m_FocusStartElement),
                () => true,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Focus_Doc));

            m_ShellView.RegisterRichCommand(CommandFocus);
            //

            InitializeComponent();

            var arrow = (Path)Application.Current.FindResource("Arrow");

            m_FocusStartElement = new TextBlockWithAutomationPeer
            {
                Text = " ",
                //Content = arrow,
                //BorderBrush = null,
                //BorderThickness = new Thickness(0.0),
                Background = Brushes.Transparent,
                //Foreground = Brushes.Black,
                Cursor     = Cursors.Cross,
                FontWeight = FontWeights.ExtraBold,
                //Style = m_ButtonStyle,
                Focusable = true,
                //IsTabStop = true
            };
            m_FocusStartElement2 = new TextBlockWithAutomationPeer
            {
                Text = " ",
                //Content = arrow,
                //BorderBrush = null,
                //BorderThickness = new Thickness(0.0),
                Background = Brushes.Transparent,
                //Foreground = Brushes.Black,
                Cursor     = Cursors.Cross,
                FontWeight = FontWeights.ExtraBold,
                //Style = m_ButtonStyle,
                Focusable = true,
                //IsTabStop = true
            };

            OnProjectUnLoaded(null);

            //m_EventAggregator.GetEvent<TreeNodeSelectedEvent>().Subscribe(OnTreeNodeSelected, TreeNodeSelectedEvent.THREAD_OPTION);
            //m_EventAggregator.GetEvent<SubTreeNodeSelectedEvent>().Subscribe(OnSubTreeNodeSelected, SubTreeNodeSelectedEvent.THREAD_OPTION);

            m_EventAggregator.GetEvent <TreeNodeSelectionChangedEvent>().Subscribe(OnTreeNodeSelectionChanged, TreeNodeSelectionChangedEvent.THREAD_OPTION);

            m_EventAggregator.GetEvent <ProjectLoadedEvent>().Subscribe(OnProjectLoaded, ProjectLoadedEvent.THREAD_OPTION);
            m_EventAggregator.GetEvent <ProjectUnLoadedEvent>().Subscribe(OnProjectUnLoaded, ProjectUnLoadedEvent.THREAD_OPTION);

            //m_EventAggregator.GetEvent<EscapeEvent>().Subscribe(obj => CommandFocus.Execute(), EscapeEvent.THREAD_OPTION);
        }
コード例 #21
0
        public static void RefreshButtonFromItsRichCommand(ButtonBase button, bool showTextLabel)
        {
            var command = button.Command as RichDelegateCommand;

            if (command == null)
            {
#if DEBUG
                Debugger.Break();
#endif
                return;
            }

            button.ToolTip = command.LongDescription +
                             (!String.IsNullOrEmpty(command.KeyGestureText) ? " " + command.KeyGestureText + " " : "");

            button.SetValue(AutomationProperties.NameProperty, UserInterfaceStrings.EscapeMnemonic(command.ShortDescription) + " / " + button.ToolTip);
            //button.SetValue(AutomationProperties.HelpTextProperty, command.ShortDescription);

            if (command.HasIcon && (!showTextLabel || String.IsNullOrEmpty(command.ShortDescription)))
            {
                var iconProvider = command.IconProviderNotShared;

                //button.Content = image;
                iconProvider.IconMargin_Medium = new Thickness(2, 2, 2, 2);

                var richButt = button as ButtonRichCommand;

                var binding = new Binding
                {
                    Mode   = BindingMode.OneWay,
                    Source = iconProvider,
                    Path   = new PropertyPath(
                        richButt != null && richButt.UseSmallerIcon ? PropertyChangedNotifyBase.GetMemberName(() => iconProvider.IconSmall) : PropertyChangedNotifyBase.GetMemberName(() => iconProvider.IconMedium)
                        )
                };

                var expr = button.SetBinding(Button.ContentProperty, binding);
            }
            else
            {
                if (button.Tag is ImageAndTextPlaceholder)
                {
                    object currentImageContent = ((ImageAndTextPlaceholder)button.Tag).m_ImageHost.Content;
                    if (currentImageContent is Image)
                    {
                        var image = currentImageContent as Image;
                        ((ImageAndTextPlaceholder)button.Tag).m_Command.IconProviderDispose(image);
                    }

                    if (command.HasIcon)
                    {
                        var iconProvider = command.IconProviderNotShared;

                        var binding = new Binding
                        {
                            Mode   = BindingMode.OneWay,
                            Source = iconProvider,
                            Path   =
                                new PropertyPath(
                                    PropertyChangedNotifyBase.GetMemberName(
                                        () => iconProvider.IconMedium))
                        };
                        var bindingExpressionBase_ =
                            ((ImageAndTextPlaceholder)button.Tag).m_ImageHost.SetBinding(
                                ContentControl.ContentProperty, binding);
                    }

                    ((ImageAndTextPlaceholder)button.Tag).m_TextHost.Content = command.ShortDescription;
                    button.ToolTip = command.LongDescription;

                    button.SetValue(AutomationProperties.NameProperty, UserInterfaceStrings.EscapeMnemonic(command.ShortDescription) + " / " + button.ToolTip);
                    //button.SetValue(AutomationProperties.HelpTextProperty, command.ShortDescription);

                    ((ImageAndTextPlaceholder)button.Tag).m_Command = command;
                }
                else
                {
                    button.Content = null;

                    var panel = new StackPanel
                    {
                        Orientation = Orientation.Horizontal
                    };

                    var imageHost = new ContentControl {
                        Focusable = false
                    };

                    if (command.HasIcon)
                    {
                        var iconProvider = command.IconProviderNotShared;

                        //Image image = command.IconProvider.IconMedium;
                        iconProvider.IconMargin_Medium = new Thickness(2, 2, 2, 2);

                        var binding = new Binding
                        {
                            Mode   = BindingMode.OneWay,
                            Source = iconProvider,
                            Path   =
                                new PropertyPath(
                                    PropertyChangedNotifyBase.GetMemberName(
                                        () => iconProvider.IconMedium))
                        };

                        var bindingExpressionBase = imageHost.SetBinding(ContentControl.ContentProperty, binding);
                    }

                    panel.Children.Add(imageHost);

                    var tb = new Label
                    {
                        VerticalAlignment = VerticalAlignment.Center,
                        Content           = command.ShortDescription,
                        //Margin = new Thickness(8, 0, 0, 0)
                    };

                    //tb.Content = new Run(UserInterfaceStrings.EscapeMnemonic(command.ShortDescription));

                    panel.Children.Add(tb);
                    button.Content = panel;

                    button.ToolTip = command.LongDescription;

                    button.SetValue(AutomationProperties.NameProperty, UserInterfaceStrings.EscapeMnemonic(command.ShortDescription) + " / " + button.ToolTip);
                    //button.SetValue(AutomationProperties.HelpTextProperty, command.ShortDescription);

                    button.Tag = new ImageAndTextPlaceholder(imageHost, tb)
                    {
                        m_Command = command
                    };
                }
            }
        }
コード例 #22
0
        private void initializeCommands_Player()
        {
            CommandPlaybackRateReset = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioPlayRateReset_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioPlayRateReset_LongDesc,
                null,   // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadGnomeGionIcon("Gion_go-previous"),
                () =>
            {
                Logger.Log("AudioPaneViewModel.CommandPlaybackRateReset", Category.Debug, Priority.Medium);

                PlaybackRate = PLAYBACK_RATE_MIN;
            },
                () => true
                //&& !IsWaveFormLoading
                ,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_ResetPlaybackRate));

            m_ShellView.RegisterRichCommand(CommandPlaybackRateReset);
            //
            CommandPlaybackRateDown = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioPlayRateDown_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioPlayRateDown_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadGnomeGionIcon("Gion_go-down"),
                () =>
            {
                Logger.Log("AudioPaneViewModel.CommandPlaybackRateDown", Category.Debug, Priority.Medium);

                if ((PlaybackRate - PLAYBACK_RATE_STEP) >= PLAYBACK_RATE_MIN)
                {
                    PlaybackRate -= PLAYBACK_RATE_STEP;
                }
                else
                {
                    PlaybackRate = PLAYBACK_RATE_MIN;
                    Debug.Fail("This should never happen !");
                }
            },
                () => (PlaybackRate - PLAYBACK_RATE_STEP) >= PLAYBACK_RATE_MIN
                //&& !IsWaveFormLoading
                ,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_PlaybackRateDown));

            m_ShellView.RegisterRichCommand(CommandPlaybackRateDown);
            //
            CommandPlaybackRateUp = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioPlayRateUp_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioPlayRateUp_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadGnomeGionIcon("Gion_go-up"),
                () =>
            {
                Logger.Log("AudioPaneViewModel.CommandPlaybackRateUp", Category.Debug, Priority.Medium);

                if ((PlaybackRate + PLAYBACK_RATE_STEP) <= PLAYBACK_RATE_MAX)
                {
                    PlaybackRate += PLAYBACK_RATE_STEP;
                }
                else
                {
                    PlaybackRate = PLAYBACK_RATE_MAX;
                    Debug.Fail("This should never happen !");
                }
            },
                () => (PlaybackRate + PLAYBACK_RATE_STEP) <= PLAYBACK_RATE_MAX
                //&& !IsWaveFormLoading
                ,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_PlaybackRateUp));

            m_ShellView.RegisterRichCommand(CommandPlaybackRateUp);
            //
            CommandAutoPlay = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioAutoPlay_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioAutoPlay_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon("applications-multimedia"),
                () =>
            {
                Logger.Log("AudioPaneViewModel.CommandAutoPlay", Category.Debug, Priority.Medium);

                //if (IsAutoPlay)
                //{
                //    AudioCues.PlayTock();
                //}
                //else
                //{
                //    AudioCues.PlayTockTock();
                //}

                IsAutoPlay = !IsAutoPlay;
            },
                () => true
                //&& !IsWaveFormLoading
                ,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_ToggleAutoPlayMode));

            m_ShellView.RegisterRichCommand(CommandAutoPlay);
            //
            //
            CommandPause = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioPause_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioPause_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon("media-playback-pause"),
                () =>
            {
                Logger.Log("AudioPaneViewModel.CommandPause", Category.Debug, Priority.Medium);

                m_PlayAutoAdvance = false;

                SetRecordAfterPlayOverwriteSelection(-1);

                long playBytePosition = PlayBytePosition;

                m_Player.Stop();

                SetPlayHeadTimeBypassAutoPlay(playBytePosition);

                if (EventAggregator != null)
                {
                    EventAggregator.GetEvent <StatusBarMessageUpdateEvent>().Publish(Tobi_Plugin_AudioPane_Lang.PlaybackStopped);
                }

                if (IsMonitoringAlways)
                {
                    CommandStartMonitor.Execute();
                }
            },
                () => State.Audio.HasContent && IsPlaying
                //&& !IsWaveFormLoading
                ,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_PlayPause));

            m_ShellView.RegisterRichCommand(CommandPause);
            //
            CommandPlay = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioPlay_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioPlay_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon("media-playback-start"),
                () =>
            {
                Logger.Log("AudioPaneViewModel.CommandPlay", Category.Debug, Priority.Medium);
                CommandPause.Execute();

                if (IsMonitoring)
                {
                    CommandStopMonitor.Execute();
                }

                //#if DEBUG
                //                    Logger.Log("AudioPaneViewModel.CommandPlay (called PAUSE)", Category.Debug, Priority.Medium);
                //#endif


                if (PlayBytePosition < 0)
                {
                    m_LastSetPlayBytePosition = 0;
                }

                if (!IsSelectionSet)
                {
                    //if (LastPlayHeadTime >= State.Audio.ConvertBytesToMilliseconds(State.Audio.DataLength))
                    if (PlayBytePosition >= State.Audio.DataLength)
                    {
                        if (Settings.Default.Audio_DisableAutoJumpToBegin_AtEndOfPlayback)
                        {
                            //m_LastSetPlayBytePosition = State.Audio.DataLength;
                            //PlayBytePosition = State.Audio.DataLength;
                            AudioCues.PlayBeep();
                        }
                        else
                        {
                            //LastPlayHeadTime = 0; infinite loop !
                            AudioPlayer_PlayFromTo(0, -1);
                        }
                    }
                    else
                    {
                        AudioPlayer_PlayFromTo(PlayBytePosition, -1);
                    }
                }
                else
                {
                    if (false &&
                        PlayBytePosition >= State.Selection.SelectionBeginBytePosition &&
                        PlayBytePosition < State.Selection.SelectionEndBytePosition)
                    {
                        //if (verifyBeginEndPlayerValues(byteLastPlayHeadTime, byteSelectionRight))
                        //{
                        //}
                        AudioPlayer_PlayFromTo(PlayBytePosition, State.Selection.SelectionEndBytePosition);
                    }
                    else
                    {
                        //if (verifyBeginEndPlayerValues(byteSelectionLeft, byteSelectionRight))
                        //{
                        //}
                        AudioPlayer_PlayFromTo(State.Selection.SelectionBeginBytePosition, State.Selection.SelectionEndBytePosition);
                    }
                }
            },
                () => State.Audio.HasContent &&
                !IsPlaying &&
                (!IsMonitoring || IsMonitoringAlways) &&
                !IsRecording
                //&& !IsWaveFormLoading
                ,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_PlayPause));

            m_ShellView.RegisterRichCommand(CommandPlay);
            //
            CommandPlayAutoAdvance = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioPlayAutoAdvance_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioPlayAutoAdvance_LongDesc,
                null,                                                     // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadGnomeGionIcon("applications-multimedia"), //emblem-system
                () =>
            {
                Logger.Log("AudioPaneViewModel.CommandPlayAutoAdvance", Category.Debug, Priority.Medium);

                m_PlayAutoAdvance = true;
                CommandPlay.Execute();
            },
                () => CommandPlay.CanExecute(),
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_PlayAutoAdvance));

            m_ShellView.RegisterRichCommand(CommandPlayAutoAdvance);
            //
            CommandPlayPreviewLeft = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioPlayPreviewLeft_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioPlayPreviewLeft_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                ScalableGreyableImageProvider.ConvertIconFormat((DrawingImage)Application.Current.FindResource("Horizon_Image_Left")),
                () => PlayPreviewLeftRight(true),
                () => CommandPlay.CanExecute(),
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_PlayLeftPreview));

            m_ShellView.RegisterRichCommand(CommandPlayPreviewLeft);
            //
            CommandPlayPreviewRight = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioPlayPreviewRight_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioPlayPreviewRight_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                ScalableGreyableImageProvider.ConvertIconFormat((DrawingImage)Application.Current.FindResource("Horizon_Image_Right")),
                () => PlayPreviewLeftRight(false),
                () => CommandPlay.CanExecute(),
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_PlayRightPreview));

            m_ShellView.RegisterRichCommand(CommandPlayPreviewRight);
            //
        }
コード例 #23
0
        //#endif

        private void initializeCommands_Recorder()
        {
            Stopwatch stopWatchRecorder = null;

            CommandStopRecordAndContinue = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioStopRecordAndContinue_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioStopRecordAndContinue_LongDesc,
                null,                                    // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon("start-here"), //weather-clear-night -- emblem-symbolic-link
                () =>
            {
                Logger.Log("AudioPaneViewModel.CommandStopRecordAndContinue", Category.Debug, Priority.Medium);

                if (stopWatchRecorder != null)
                {
                    stopWatchRecorder.Stop();
                    if (stopWatchRecorder.ElapsedMilliseconds <= 100)
                    {
                        Console.WriteLine("stopWatchRecorder.ElapsedMilliseconds<=100, skipping stop record");
                        stopWatchRecorder.Start();
                        return;
                    }
                    Console.WriteLine("stopWatchRecorder.ElapsedMilliseconds, elapsed record :" + stopWatchRecorder.ElapsedMilliseconds);
                }
                stopWatchRecorder = null;

                IsAutoPlay           = false;
                m_RecordAndContinue  = true;
                m_InterruptRecording = false;

                if (!Settings.Default.Audio_DisableSingleWavFileRecord)
                {
                    m_RecordAndContinue_StopBytePos = (long)m_Recorder.CurrentDurationBytePosition_BufferLookAhead;
                    OnAudioRecordingFinished(null,
                                             new AudioRecorder.AudioRecordingFinishEventArgs(
                                                 m_Recorder.RecordedFilePath));
                }
                else
                {
                    m_Recorder.StopRecording();

                    if (EventAggregator != null)
                    {
                        EventAggregator.GetEvent <StatusBarMessageUpdateEvent>().Publish(Tobi_Plugin_AudioPane_Lang.RecordingStopped);
                    }
                }
                //ENABLE_SINGLE_RECORD_FILE
            },
                () =>
            {
                //Tuple<TreeNode, TreeNode> treeNodeSelection = m_UrakawaSession.GetTreeNodeSelection();

                return(!IsWaveFormLoading && IsRecording &&
                       m_UrakawaSession.DocumentProject != null);
            },
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_StopRecordAndContinue));

            m_ShellView.RegisterRichCommand(CommandStopRecordAndContinue);
            //
            CommandStopRecord = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioStopRecord_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioStopRecord_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon("media-playback-stop"),
                () =>
            {
                Logger.Log("AudioPaneViewModel.CommandStopRecord", Category.Debug, Priority.Medium);

                if (stopWatchRecorder != null)
                {
                    stopWatchRecorder.Stop();
                    if (stopWatchRecorder.ElapsedMilliseconds <= 50)
                    {
                        Console.WriteLine("stopWatchRecorder.ElapsedMilliseconds<=50, skipping stop record");
                        stopWatchRecorder.Start();
                        return;
                    }
                    Console.WriteLine("stopWatchRecorder.ElapsedMilliseconds, elapsed record :" + stopWatchRecorder.ElapsedMilliseconds);
                }
                stopWatchRecorder = null;

                m_RecordAndContinue = false;
                m_Recorder.StopRecording();

                if (EventAggregator != null)
                {
                    EventAggregator.GetEvent <StatusBarMessageUpdateEvent>().Publish(Tobi_Plugin_AudioPane_Lang.RecordingStopped);
                }

                if (IsMonitoringAlways)
                {
                    CommandStartMonitor.Execute();
                }
            },
                () => !IsWaveFormLoading && IsRecording,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_StartStopRecord));

            m_ShellView.RegisterRichCommand(CommandStopRecord);
            //
            CommandStartRecord = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioStartRecord_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioStartRecord_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon("media-record"),
                () =>
            {
                Logger.Log("AudioPaneViewModel.CommandStartRecord", Category.Debug, Priority.Medium);

                m_RecordAndContinue_StopBytePos = -1;

                if (stopWatchRecorder != null)
                {
                    Console.WriteLine("stopWatchRecorder != null, skipping start record");
                    return;
                }

                if (IsMonitoring)
                {
                    CommandStopMonitor.Execute();
                }

                IsAutoPlay = false;

                bool allowPlayPreview = false;

                m_punchInRecordOverSelection = false;
                if (IsPlaying)     // Punch-in recording
                {
                    SetRecordAfterPlayOverwriteSelection(-1);

                    m_punchInRecordOverSelection = true;

                    CommandPause.Execute();

                    CommandSelectRight.Execute();
                }
                else if (Settings.Default.Audio_Record_OverwriteFollowingAudio &&
                         !IsSelectionSet)
                {
                    SetRecordAfterPlayOverwriteSelection(-1);

                    m_punchInRecordOverSelection = true;

                    if (PlayBytePosition >= 0)
                    {
                        allowPlayPreview = true;

                        CommandSelectRight.Execute();
                    }
                    else
                    {
                        CommandSelectAll.Execute();
                    }
                }

                if (IsWaveFormLoading && View != null)
                {
                    View.CancelWaveFormLoad(true);
                }

                m_RecordAndContinue = false;

                if (m_UrakawaSession.DocumentProject == null)
                {
                    SetRecordAfterPlayOverwriteSelection(-1);

                    State.ResetAll();

                    State.Audio.PcmFormatRecordingMonitoring = new PCMFormatInfo();
                }
                else
                {
                    Tuple <TreeNode, TreeNode> treeNodeSelection = m_UrakawaSession.GetTreeNodeSelection();
                    if (treeNodeSelection.Item1 == null)
                    {
                        SetRecordAfterPlayOverwriteSelection(-1);

                        return;
                    }

                    if (!m_punchInRecordOverSelection || allowPlayPreview)     // let's check auto punch in/out based on audio selection
                    {
                        var bytesForRequiredOffsetTime =
                            m_UrakawaSession.DocumentProject.Presentations.Get(0).MediaDataManager.DefaultPCMFormat.
                            Data.ConvertTimeToBytes(150 * AudioLibPCMFormat.TIME_UNIT);
                        if (State.Selection.SelectionBeginBytePosition > 0 &&
                            PlayBytePosition >= 0 &&
                            PlayBytePosition < State.Selection.SelectionBeginBytePosition - bytesForRequiredOffsetTime)
                        {
                            AudioPlayer_PlayFromTo(PlayBytePosition, State.Selection.SelectionBeginBytePosition);
                            SetRecordAfterPlayOverwriteSelection(State.Selection.SelectionBeginBytePosition);
                            return;
                        }
                        else if (Settings.Default.Audio_EnablePlayPreviewBeforeRecord && m_RecordAfterPlayOverwriteSelection < 0 && PlayBytePosition > 0)
                        {
                            var playbackStartBytePos =
                                m_UrakawaSession.DocumentProject.Presentations.Get(0).MediaDataManager.DefaultPCMFormat.
                                Data.ConvertTimeToBytes((long)Settings.Default.AudioWaveForm_PlayPreviewTimeStep * 2 * AudioLibPCMFormat.TIME_UNIT);
                            playbackStartBytePos = PlayBytePosition - playbackStartBytePos;
                            if (playbackStartBytePos < 0)
                            {
                                playbackStartBytePos = 0;
                            }

                            SetRecordAfterPlayOverwriteSelection(State.Selection.SelectionBeginBytePosition > 0 ? State.Selection.SelectionBeginBytePosition : PlayBytePosition);
                            AudioPlayer_PlayFromTo(playbackStartBytePos, PlayBytePosition);
                            return;
                        }

                        SetRecordAfterPlayOverwriteSelection(-1);
                    }

                    DebugFix.Assert(m_UrakawaSession.DocumentProject.Presentations.Get(0).MediaDataManager.EnforceSinglePCMFormat);
                    State.Audio.PcmFormatRecordingMonitoring = m_UrakawaSession.DocumentProject.Presentations.Get(0).MediaDataManager.DefaultPCMFormat;
                }

                OnSettingsPropertyChanged(this, new PropertyChangedEventArgs(GetMemberName(() => Settings.Default.Audio_InputDevice)));

                stopWatchRecorder = Stopwatch.StartNew();
                m_Recorder.StartRecording(State.Audio.PcmFormatRecordingMonitoring.Copy().Data);

                RaisePropertyChanged(() => State.Audio.PcmFormatRecordingMonitoring);

                if (EventAggregator != null)
                {
                    EventAggregator.GetEvent <StatusBarMessageUpdateEvent>().Publish(Tobi_Plugin_AudioPane_Lang.Recording);
                }
            },
                () =>
            {
                return((!IsMonitoring || IsMonitoringAlways) &&
                       !IsRecording &&
                       !IsWaveFormLoading &&  //!IsPlaying &&
                       canDeleteInsertReplaceAudio());
            },
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_StartStopRecord));

            m_ShellView.RegisterRichCommand(CommandStartRecord);

            //
            //
            CommandStopMonitor = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioStopMonitor_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioStopMonitor_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon("media-playback-stop"),
                () =>
            {
                Logger.Log("AudioPaneViewModel.CommandStopMonitor", Category.Debug, Priority.Medium);

                m_Recorder.StopRecording();

                //AudioCues.PlayTockTock();

                if (EventAggregator != null)
                {
                    EventAggregator.GetEvent <StatusBarMessageUpdateEvent>().Publish(Tobi_Plugin_AudioPane_Lang.MonitoringStopped);
                }

                State.Audio.PcmFormatRecordingMonitoring = null;
            },
                () => !IsWaveFormLoading &&
                IsMonitoring,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_StartStopMonitor));

            m_ShellView.RegisterRichCommand(CommandStopMonitor);
            //

            CommandStartMonitor = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioStartMonitor_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioStartMonitor_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon("audio-input-microphone"),
                () =>
            {
                Logger.Log("AudioPaneViewModel.CommandStartMonitor", Category.Debug, Priority.Medium);

                m_RecordAndContinue_StopBytePos = -1;     // to avoid display of m_RecordAndContinue time stamp

                IsAutoPlay = false;

                if (m_UrakawaSession.DocumentProject == null)
                {
                    State.ResetAll();

                    State.Audio.PcmFormatRecordingMonitoring = new PCMFormatInfo();

                    //m_PcmFormatOfAudioToInsert = IsAudioLoaded ? State.Audio.PcmFormat : new PCMFormatInfo();
                    //m_Recorder.InputDevice.Capture.Caps.Format44KhzMono16Bit
                }
                else
                {
                    DebugFix.Assert(m_UrakawaSession.DocumentProject.Presentations.Get(0).MediaDataManager.EnforceSinglePCMFormat);
                    State.Audio.PcmFormatRecordingMonitoring = m_UrakawaSession.DocumentProject.Presentations.Get(0).MediaDataManager.DefaultPCMFormat;
                }

                OnSettingsPropertyChanged(this, new PropertyChangedEventArgs(GetMemberName(() => Settings.Default.Audio_InputDevice)));

                //AudioCues.PlayTock();

                m_Recorder.StartMonitoring(State.Audio.PcmFormatRecordingMonitoring.Copy().Data);

                RaisePropertyChanged(() => State.Audio.PcmFormatRecordingMonitoring);

                if (EventAggregator != null)
                {
                    EventAggregator.GetEvent <StatusBarMessageUpdateEvent>().Publish(Tobi_Plugin_AudioPane_Lang.Monitoring);
                }
            },
                () => !IsWaveFormLoading &&
                !IsPlaying &&
                !IsRecording &&
                !IsMonitoring,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_StartStopMonitor));

            m_ShellView.RegisterRichCommand(CommandStartMonitor);
            //

            CommandTogglePlayPreviewBeforeRecord = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioTogglePlayPreviewBeforeRecord_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioTogglePlayPreviewBeforeRecord_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadGnomeGionIcon("Gion_music-player"),
                () =>
            {
                Settings.Default.Audio_EnablePlayPreviewBeforeRecord =
                    !Settings.Default.Audio_EnablePlayPreviewBeforeRecord;

                RaisePropertyChanged(() => RecordPlayPreviewString);

                if (EventAggregator != null)
                {
                    EventAggregator.GetEvent <StatusBarMessageUpdateEvent>().Publish(RecordPlayPreviewString
                                                                                     //Tobi_Plugin_AudioPane_Lang.AudioRecordPlayPreview + (Settings.Default.Audio_EnablePlayPreviewBeforeRecord ? " [ON]" : " [OFF]")
                                                                                     );
                }
            },
                () => true,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_TogglePlayPreviewBeforeRecord));

            m_ShellView.RegisterRichCommand(CommandTogglePlayPreviewBeforeRecord);
            //
            CommandToggleRecordOverwrite = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioToggleRecordOverwrite_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioToggleRecordOverwrite_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                null, //m_ShellView.LoadGnomeGionIcon("Gion_music-player"),
                () =>
            {
                Settings.Default.Audio_Record_OverwriteFollowingAudio =
                    !Settings.Default.Audio_Record_OverwriteFollowingAudio;

                RaisePropertyChanged(() => RecordOverwriteString);

                if (EventAggregator != null)
                {
                    EventAggregator.GetEvent <StatusBarMessageUpdateEvent>().Publish(RecordOverwriteString
                                                                                     //Tobi_Plugin_AudioPane_Lang.AudioRecordOverwrite + (Settings.Default.Audio_Record_OverwriteFollowingAudio ? " [ON]" : " [OFF]")
                                                                                     );
                }
            },
                () => true,
                Settings_KeyGestures.Default,
                null //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_TogglePlayPreviewBeforeRecord)
                );

            m_ShellView.RegisterRichCommand(CommandToggleRecordOverwrite);
            //
            CommandToggleSelectAfterRecord = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioToggleSelectAfterRecord_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioToggleSelectAfterRecord_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                null, //m_ShellView.LoadGnomeGionIcon("Gion_music-player"),
                () =>
            {
                Settings.Default.Audio_DisableAfterRecordSelection =
                    !Settings.Default.Audio_DisableAfterRecordSelection;

                RaisePropertyChanged(() => SelectAfterRecordString);

                if (EventAggregator != null)
                {
                    EventAggregator.GetEvent <StatusBarMessageUpdateEvent>().Publish(SelectAfterRecordString
                                                                                     //Tobi_Plugin_AudioPane_Lang.AudioSelectAfterRecord + (Settings.Default.Audio_DisableSelectAfterRecord ? " [OFF]" : " [ON]")
                                                                                     );
                }
            },
                () => true,
                Settings_KeyGestures.Default,
                null //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_TogglePlayPreviewBeforeRecord)
                );

            m_ShellView.RegisterRichCommand(CommandToggleSelectAfterRecord);
        }
コード例 #24
0
        //private readonly List<Uri> m_RecentFiles = new List<Uri>();
        //public IEnumerable<Uri> RecentFiles
        //{
        //    get
        //    {
        //        foreach (var fileUrl in m_RecentFiles)
        //        {
        //            yield return fileUrl;
        //        }
        //    }
        //}


        private void InitializeRecentFiles()
        {
            OpenRecentCommand = new RichDelegateCommand(
                Tobi_Plugin_Urakawa_Lang.CmdOpenRecent_ShortDesc,
                Tobi_Plugin_Urakawa_Lang.CmdOpenRecent_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon(@"folder-saved-search"),
                () =>
            {
                m_Logger.Log("UrakawaSession.OpenRecentCommand", Category.Debug, Priority.Medium);

                var view = m_Container.Resolve <RecentFilesView>();

                var windowPopup = new PopupModalWindow(m_ShellView,
                                                       UserInterfaceStrings.EscapeMnemonic(
                                                           Tobi_Plugin_Urakawa_Lang.Menu_OpenRecent
                                                           //Tobi_Plugin_Urakawa_Lang.CmdOpenRecent_ShortDesc
                                                           ),
                                                       view,
                                                       PopupModalWindow.DialogButtonsSet.OkCancel,
                                                       PopupModalWindow.DialogButton.Ok,
                                                       true, 800, 500, null, 0, null);
                //view.OwnerWindow = windowPopup;

                windowPopup.EnableEnterKeyDefault = true;

                windowPopup.ShowModal();

                if (windowPopup.ClickedDialogButton == PopupModalWindow.DialogButton.Ok)
                {
                    if (view.RecentFilesList.SelectedItem != null)
                    {
                        try
                        {
                            OpenFile(((RecentFileWrapper)view.RecentFilesList.SelectedItem).Uri.ToString());
                        }
                        catch (Exception ex)
                        {
                            ExceptionHandler.Handle(ex, false, m_ShellView);
                        }
                    }
                }
            },
                () => !isAudioRecording,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_OpenRecent));

            m_ShellView.RegisterRichCommand(OpenRecentCommand);
            //
            ClearRecentFilesCommand = new RichDelegateCommand(Tobi_Plugin_Urakawa_Lang.CmdMenuClearRecentFiles_ShortDesc,
                                                              Tobi_Plugin_Urakawa_Lang.CmdMenuClearRecentFiles_LongDesc,
                                                              null,
                                                              m_ShellView.LoadGnomeNeuIcon(@"Neu_view-refresh"),
                                                              ClearRecentFiles,
                                                              () => !isAudioRecording,
                                                              null, null);
            m_ShellView.RegisterRichCommand(ClearRecentFilesCommand);
            //
            RecentFiles = new ObservableCollection <Uri>();

            if (!File.Exists(m_RecentFiles_FilePath))
            {
                return;
            }

            StreamReader streamReader = new StreamReader(m_RecentFiles_FilePath, Encoding.UTF8);

            try
            {
                string recentFileUriString;
                while ((recentFileUriString = streamReader.ReadLine()) != null)
                {
                    Uri recentFileUri;
                    Uri.TryCreate(recentFileUriString, UriKind.Absolute, out recentFileUri);

                    if (recentFileUri == null
                        //||    //TODO: should we filter the URI scheme at this stage?
                        //recentFileUri.Scheme.ToLower() != "file"
                        //&& recentFileUri.Scheme.ToLower() != "http"
                        )
                    {
                        continue;
                    }

                    if (!RecentFiles.Contains(recentFileUri))
                    {
                        RecentFiles.Add(recentFileUri);
                    }
                }
            }
            finally
            {
                streamReader.Close();
            }
        }
コード例 #25
0
ファイル: Shell_Commands.cs プロジェクト: daisy/tobi
        //public RichDelegateCommand OpenImageDescriptionsManualCommand { get; private set; }

        private void initCommands()
        {
            m_Logger.Log(@"ShellView.initCommands", Category.Debug, Priority.Medium);

            OpenOnlineDocCommand = new RichDelegateCommand(
                Tobi_Lang.CmdDocOnline_ShortDesc,
                Tobi_Lang.CmdDocOnline_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                null,
                () =>
            {
                m_Logger.Log(@"ShellView.OpenOnlineDocCommand", Category.Debug, Priority.Medium);

                ExecuteShellProcess("http://www.daisy.org/tobi/doc");
            },
                () => !m_UrakawaSession.isAudioRecording,
                Settings_KeyGestures.Default,
                null //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Help)
                );

            RegisterRichCommand(OpenOnlineDocCommand);


            OpenLocalDocCommand = new RichDelegateCommand(
                Tobi_Lang.CmdDocLocal_ShortDesc,
                Tobi_Lang.CmdDocLocal_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                null,
                () =>
            {
                m_Logger.Log(@"ShellView.OpenLocalDocCommand", Category.Debug, Priority.Medium);

                string appFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                string chmPath   = Path.Combine(appFolder, "TobiHelp.chm");

                ExecuteShellProcess(chmPath);
            },
                () => !m_UrakawaSession.isAudioRecording,
                Settings_KeyGestures.Default,
                null //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Help)
                );

            RegisterRichCommand(OpenLocalDocCommand);

            //OpenImageDescriptionsManualCommand = new RichDelegateCommand(
            //    Tobi_Lang.CmdOpenImageDescriptionsManual_ShortDesc,
            //    Tobi_Lang.CmdOpenImageDescriptionsManual_LongDesc,
            //    null, // KeyGesture obtained from settings (see last parameters below)
            //    null,
            //    () =>
            //    {
            //        m_Logger.Log(@"ShellView.OpenImageDescriptionsManualCommand", Category.Debug, Priority.Medium);

            //        ExecuteShellProcess("http://www.daisy.org/tobi/image-description-manual");
            //    },
            //     () => true,
            //    Settings_KeyGestures.Default,
            //    null //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_ShowTobiFolder)
            //    );

            //RegisterRichCommand(OpenImageDescriptionsManualCommand);
            //
            ExitCommand = new RichDelegateCommand(
                Tobi_Lang.CmdMenuExit_ShortDesc,
                Tobi_Lang.CmdMenuExit_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                //UserInterfaceStrings.Menu_Exit_KEYS,
                LoadTangoIcon(@"system-log-out"),
                //ScalableGreyableImageProvider.ConvertIconFormat((DrawingImage)Application.Current.FindResource("Horizon_Image_Exit")),
                //LoadTangoIcon("document-save"),
                () =>
            {
                m_Logger.Log(@"ShellView.ExitCommand", Category.Debug, Priority.Medium);

                if (askUserConfirmExit())
                {
                    exit();
                }
            },
                () => {
                m_Logger.Log(@"Application.Current.Windows.Count: " + Application.Current.Windows.Count + " -- " + Debugger.IsAttached, Category.Debug, Priority.Medium);
                return(Application.Current.Windows.Count ==
#if NET40
                       (Debugger.IsAttached ? 2 : 1)
#else
                       1
#endif
                       && !m_UrakawaSession.isAudioRecording);
            },
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_AppExit));

            RegisterRichCommand(ExitCommand);
            //

            MagnifyUiResetCommand = new RichDelegateCommand(
                Tobi_Lang.CmdUIResetMagnification_ShortDesc,
                Tobi_Lang.CmdUIResetMagnification_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                LoadTangoIcon(@"weather-clear"),
                () =>
            {
                m_Logger.Log(@"ShellView.MagnifyUiResetCommand", Category.Debug, Priority.Medium);

                MagnificationLevel = 1;
            },
                () => !m_UrakawaSession.isAudioRecording,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_UI_Zoom_Reset));

            RegisterRichCommand(MagnifyUiResetCommand);
            //
            MagnifyUiIncreaseCommand = new RichDelegateCommand(
                Tobi_Lang.CmdUIIncreaseMagnification_ShortDesc,
                Tobi_Lang.CmdUIIncreaseMagnification_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                //LoadTangoIcon("mail-forward"),
                ScalableGreyableImageProvider.ConvertIconFormat((DrawingImage)Application.Current.FindResource(@"Horizon_Image_Zoom_In")),
                () =>
            {
                m_Logger.Log(@"ShellView.MagnifyUiIncreaseCommand", Category.Debug, Priority.Medium);

                MagnificationLevel += 0.15;
            },
                () => !m_UrakawaSession.isAudioRecording,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_UI_Zoom_Increase));

            RegisterRichCommand(MagnifyUiIncreaseCommand);
            //

            MagnifyUiDecreaseCommand = new RichDelegateCommand(
                Tobi_Lang.CmdUIDecreaseMagnification_ShortDesc,
                Tobi_Lang.CmdUIDecreaseMagnification_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                ScalableGreyableImageProvider.ConvertIconFormat((DrawingImage)Application.Current.FindResource(@"Horizon_Image_Zoom_out")),
                () =>
            {
                m_Logger.Log(@"ShellView.MagnifyUiDecreaseCommand", Category.Debug, Priority.Medium);

                MagnificationLevel -= 0.15;
            },
                () => !m_UrakawaSession.isAudioRecording,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_UI_Zoom_Decrease));

            RegisterRichCommand(MagnifyUiDecreaseCommand);
            //
#if ICONS
            DisplayPreviewIconsDebugCommand = new RichDelegateCommand(
                UserInterfaceStrings.IconsDebug,
                null,
                UserInterfaceStrings.IconsDebug_KEYS,
                null,
                DisplayPreviewIconsDebugCommand_Executed,
                () => true);

            RegisterRichCommand(DisplayPreviewIconsDebugCommand);
#endif

#if DEBUG
            ManageShortcutsCommand = new RichDelegateCommand(
                Tobi_Lang.CmdManageShortcuts_ShortDesc,
                Tobi_Lang.CmdManageShortcuts_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                LoadTangoIcon(@"preferences-desktop-keyboard-shortcuts"),
                () =>
            {
                m_Logger.Log(@"ShellView.ManageShortcutsCommand_Executed", Category.Debug, Priority.Medium);

                var windowPopup = new PopupModalWindow(this,
                                                       UserInterfaceStrings.EscapeMnemonic(Tobi_Lang.CmdManageShortcuts_ShortDesc),
                                                       new KeyboardShortcuts(this),
                                                       PopupModalWindow.DialogButtonsSet.Ok,
                                                       PopupModalWindow.DialogButton.Ok,
                                                       true, 500, 600, null, 0, null);

                windowPopup.ShowFloating(null);
            },
                () => true,
                Settings_KeyGestures.Default,
                null //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_DisplayShortcuts)
                );

            RegisterRichCommand(ManageShortcutsCommand);
#endif

            //#if DEBUG
            //            ShowLogFilePathCommand = new RichDelegateCommand(
            //                UserInterfaceStrings.ShowLogFilePath,
            //                UserInterfaceStrings.ShowLogFilePath_,
            //                null, // KeyGesture obtained from settings (see last parameters below)
            //                null, //LoadTangoIcon(@"help-browser"),
            //                () =>
            //                {
            //                    m_Logger.Log(@"ShellView.ShowLogFilePathCommand", Category.Debug, Priority.Medium);


            //                    var label = new TextBlock
            //                    {
            //                        Text = UserInterfaceStrings.ShowLogFilePath_,
            //                        Margin = new Thickness(8, 0, 8, 0),
            //                        HorizontalAlignment = HorizontalAlignment.Center,
            //                        VerticalAlignment = VerticalAlignment.Center,
            //                        Focusable = true,
            //                        TextWrapping = TextWrapping.Wrap
            //                    };

            //                    var iconProvider = new ScalableGreyableImageProvider(LoadTangoIcon("edit-find"), MagnificationLevel);

            //                    var panel = new StackPanel
            //                    {
            //                        Orientation = Orientation.Horizontal,
            //                        HorizontalAlignment = HorizontalAlignment.Center,
            //                        VerticalAlignment = VerticalAlignment.Stretch,
            //                    };
            //                    panel.Children.Add(iconProvider.IconLarge);
            //                    panel.Children.Add(label);
            //                    //panel.Margin = new Thickness(8, 8, 8, 0);


            //                    var details = new TextBoxReadOnlyCaretVisible(ApplicationConstants.LOG_FILE_PATH)
            //                    {
            //                    };

            //                    var windowPopup = new PopupModalWindow(this,
            //                                                           UserInterfaceStrings.EscapeMnemonic(
            //                                                               UserInterfaceStrings.ShowLogFilePath),
            //                                                           panel,
            //                                                           PopupModalWindow.DialogButtonsSet.Close,
            //                                                           PopupModalWindow.DialogButton.Close,
            //                                                           true, 300, 160, details, 40);

            //                    windowPopup.ShowModal();

            //                },
            //                 () => true,
            //                Settings_KeyGestures.Default,
            //                null //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_DisplayLogFilePath)
            //                );

            //            RegisterRichCommand(ShowLogFilePathCommand);
            //            //
            //#endif //DEBUG
            //

            OpenTobiIsolatedStorageCommand = new RichDelegateCommand(
                Tobi_Lang.CmdOpenTobiIsolatedStorage_ShortDesc,
                Tobi_Lang.CmdOpenTobiIsolatedStorage_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                LoadGnomeNeuIcon(@"Neu_applications-office"),
                () =>
            {
                m_Logger.Log(@"ShellView.OpenTobiIsolatedStorageCommand", Category.Debug, Priority.Medium);

                ExecuteShellProcess(ExternalFilesDataManager.STORAGE_FOLDER_PATH);
            },
                () => !m_UrakawaSession.isAudioRecording,
                Settings_KeyGestures.Default,
                null //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_ShowTobiFolder)
                );

            RegisterRichCommand(OpenTobiIsolatedStorageCommand);
            //
            OpenTobiFolderCommand = new RichDelegateCommand(
                Tobi_Lang.CmdOpenTobiFolder_ShortDesc,
                Tobi_Lang.CmdOpenTobiFolder_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                LoadGnomeNeuIcon(@"Neu_user-home"),
                () =>
            {
                m_Logger.Log(@"ShellView.OpenTobiFolderCommand", Category.Debug, Priority.Medium);

                ExecuteShellProcess(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
            },
                () => !m_UrakawaSession.isAudioRecording,
                Settings_KeyGestures.Default,
                null //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_ShowTobiFolder)
                );

            RegisterRichCommand(OpenTobiFolderCommand);
            //
            OpenTobiSettingsFolderCommand = new RichDelegateCommand(
                Tobi_Lang.CmdOpenTobiSettingsFolder_ShortDesc,
                Tobi_Lang.CmdOpenTobiSettingsFolder_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                LoadGnomeFoxtrotIcon(@"Foxtrot_folder"),
                () =>
            {
                m_Logger.Log(@"ShellView.OpenTobiSettingsFolderCommand", Category.Debug, Priority.Medium);

                Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
                string settingsPath  = Path.GetDirectoryName(config.FilePath);
                ExecuteShellProcess(settingsPath);
            },
                () => !m_UrakawaSession.isAudioRecording,
                Settings_KeyGestures.Default,
                null //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_ShowTobiSettingsFolder)
                );

            RegisterRichCommand(OpenTobiSettingsFolderCommand);
            //
#if DEBUG
            HelpCommand = new RichDelegateCommand(
                Tobi_Lang.CmdHelp_ShortDesc,
                Tobi_Lang.CmdHelp_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                LoadTangoIcon("help-browser"),
                () =>
            {
                m_Logger.Log("ShellView.HelpCommand", Category.Debug, Priority.Medium);

                throw new NotImplementedException("Functionality not implemented, sorry :(",
                                                  new ArgumentOutOfRangeException("First Inner exception",
                                                                                  new FileNotFoundException("Second inner exception !")));
                //    try
                //    { }
                //catch (Exception ex)
                //{
                //    ExceptionHandler.Handle(ex, false, this);
                //}
            },
                () => true,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Help));

            RegisterRichCommand(HelpCommand);
#endif
            //
            //PreferencesCommand = new RichDelegateCommand(
            //    UserInterfaceStrings.Preferences,
            //    UserInterfaceStrings.Preferences_,
            //    null, // KeyGesture obtained from settings (see last parameters below)
            //    LoadTangoIcon("preferences-system"),
            //    () => Debug.Fail("Functionality not implemented yet."),
            //    () => true,
            //    Settings_KeyGestures.Default,
            //    PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Preferences));

            //RegisterRichCommand(PreferencesCommand);
            //
            //WebHomeCommand = new RichDelegateCommand(UserInterfaceStrings.WebHome,
            //    UserInterfaceStrings.WebHome_,
            //    UserInterfaceStrings.WebHome_KEYS,
            //    //ScalableGreyableImageProvider.ConvertIconFormat((DrawingImage)Application.Current.FindResource("Home_icon")),
            //    LoadTangoIcon("go-home"),
            //    ()=> { throw new NotImplementedException("Functionality not implemented, sorry :("); }, ()=> true);

            //RegisterRichCommand(WebHomeCommand);
            ////
            //NavNextCommand = new RichDelegateCommand(UserInterfaceStrings.NavNext,
            //    UserInterfaceStrings.NavNext_,
            //    UserInterfaceStrings.NavNext_KEYS,
            //    ScalableGreyableImageProvider.ConvertIconFormat((DrawingImage)Application.Current.FindResource("Horizon_Image_Forward")),
            //    ()=> { throw new NotImplementedException("Functionality not implemented, sorry :("); }, ()=> true);

            //RegisterRichCommand(NavNextCommand);
            ////
            //NavPreviousCommand = new RichDelegateCommand(UserInterfaceStrings.NavPrevious,
            //    UserInterfaceStrings.NavPrevious_,
            //    UserInterfaceStrings.NavPrevious_KEYS,
            //    ScalableGreyableImageProvider.ConvertIconFormat((DrawingImage)Application.Current.FindResource("Horizon_Image_Back")),
            //    ()=> { throw new NotImplementedException("Functionality not implemented, sorry :("); }, ()=> true);

            //RegisterRichCommand(NavPreviousCommand);
        }
コード例 #26
0
        private void initializeCommands_Navigation()
        {
            CommandGotoBegining = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioGotoBegin_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioGotoBegin_LongDesc,
                null,    // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon("go-first"),
                () =>
            {
                Logger.Log("AudioPaneViewModel.CommandGotoBegining", Category.Debug, Priority.Medium);

                CommandPause.Execute();

                if (PlayBytePosition == 0)
                {
                    AudioCues.PlayBeep();
                }
                else
                {
                    if (IsAutoPlay)
                    {
                        State.Selection.ClearSelection();
                    }

                    PlayBytePosition = 0;
                }
            },
                () => !IsWaveFormLoading &&
                State.Audio.HasContent &&
                !IsRecording &&
                (!IsMonitoring || IsMonitoringAlways),
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_GotoBegin));

            m_ShellView.RegisterRichCommand(CommandGotoBegining);
            //
            CommandGotoEnd = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioGotoEnd_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioGotoEnd_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon("go-last"),
                () =>
            {
                Logger.Log("AudioPaneViewModel.CommandGotoEnd", Category.Debug, Priority.Medium);

                CommandPause.Execute();

                if (PlayBytePosition == State.Audio.DataLength)
                {
                    AudioCues.PlayBeep();
                }
                else
                {
                    if (IsAutoPlay)
                    {
                        State.Selection.ClearSelection();
                    }

                    PlayBytePosition = State.Audio.DataLength;
                }
            },
                () => !IsWaveFormLoading &&
                State.Audio.HasContent &&
                !IsRecording &&
                (!IsMonitoring || IsMonitoringAlways),
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_GotoEnd));

            m_ShellView.RegisterRichCommand(CommandGotoEnd);
            //
            CommandStepBack = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioStepBack_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioStepBack_LongDesc,
                null,  // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon("media-skip-backward"),
                () =>
            {
                Logger.Log("AudioPaneViewModel.CommandStepBack", Category.Debug, Priority.Medium);

                CommandPause.Execute();

                long bytesLeftPrevious = -1;

                State.Audio.FindInPlayStreamMarkersAndDo(PlayBytePosition,
                                                         (bytesLeft, bytesRight, markerTreeNode, index)
                                                         =>
                {
                    if (bytesLeftPrevious == -1)
                    {
                        if (IsAutoPlay)
                        {
                            State.Selection.ClearSelection();
                        }

                        PlayBytePosition = bytesLeft;
                        AudioCues.PlayBeep();
                        return(-1);
                    }

                    if (IsAutoPlay)
                    {
                        State.Selection.ClearSelection();
                    }

                    PlayBytePosition = bytesLeftPrevious;

                    return(-1);
                }
                                                         ,
                                                         (bytesToMatch_, bytesLeft, bytesRight, markerTreeNode)
                                                         =>
                {
                    bytesLeftPrevious = bytesLeft;
                    return(bytesToMatch_);
                }
                                                         );
            },
                () => !IsWaveFormLoading &&
                !IsRecording &&
                (!IsMonitoring || IsMonitoringAlways) &&
                State.Audio.HasContent && State.Audio.PlayStreamMarkers != null && State.Audio.PlayStreamMarkers.Count > 1,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_StepBack));

            m_ShellView.RegisterRichCommand(CommandStepBack);
            //
            CommandStepForward = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioStepForward_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioStepForward_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon("media-skip-forward"),
                () =>
            {
                Logger.Log("AudioPaneViewModel.CommandStepForward", Category.Debug, Priority.Medium);

                CommandPause.Execute();

                long bytesRight;
                long bytesLeft;
                int index;
                TreeNode subTreeNode;
                bool match = State.Audio.FindInPlayStreamMarkers(PlayBytePosition, out subTreeNode, out index, out bytesLeft, out bytesRight);

                if (match)
                {
                    if (index == State.Audio.PlayStreamMarkers.Count - 1)
                    {
                        AudioCues.PlayBeep();
                        return;
                    }

                    if (IsAutoPlay)
                    {
                        State.Selection.ClearSelection();
                    }

                    PlayBytePosition = bytesRight;
                }
                else
                {
                    Debug.Fail("audio chunk not found ??");

                    AudioCues.PlayBeep();
                }
            },
                () => CommandStepBack.CanExecute(),
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_StepForward));

            m_ShellView.RegisterRichCommand(CommandStepForward);
            //
            CommandFastForward = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioFastForward_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioFastForward_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon("media-seek-forward"),
                () =>
            {
                Logger.Log("AudioPaneViewModel.CommandFastForward", Category.Debug, Priority.Medium);

                CommandPause.Execute();

                long newBytesPosition = PlayBytePosition + State.Audio.GetCurrentPcmFormat().Data.ConvertTimeToBytes((long)Settings.Default.AudioWaveForm_JumpTimeStep * AudioLibPCMFormat.TIME_UNIT);
                if (newBytesPosition > State.Audio.DataLength)
                {
                    newBytesPosition = State.Audio.DataLength;
                    AudioCues.PlayBeep();
                }

                if (IsAutoPlay)
                {
                    State.Selection.ClearSelection();
                }

                PlayBytePosition = newBytesPosition;
            },
                () => !IsWaveFormLoading &&
                State.Audio.HasContent &&
                (!IsMonitoring || IsMonitoringAlways) &&
                !IsRecording,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_GoForward));

            m_ShellView.RegisterRichCommand(CommandFastForward);
            //
            CommandRewind = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioRewind_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioRewind_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon("media-seek-backward"),
                () =>
            {
                Logger.Log("AudioPaneViewModel.CommandRewind", Category.Debug, Priority.Medium);

                CommandPause.Execute();

                long newTimeBytePosition = PlayBytePosition - State.Audio.GetCurrentPcmFormat().Data.ConvertTimeToBytes((long)Settings.Default.AudioWaveForm_JumpTimeStep * AudioLibPCMFormat.TIME_UNIT);
                if (newTimeBytePosition < 0)
                {
                    newTimeBytePosition = 0;
                    AudioCues.PlayBeep();
                }

                if (IsAutoPlay)
                {
                    State.Selection.ClearSelection();
                }

                PlayBytePosition = newTimeBytePosition;
            },
                () => !IsWaveFormLoading &&
                State.Audio.HasContent &&
                !IsRecording &&
                (!IsMonitoring || IsMonitoringAlways),
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_GoBack));

            m_ShellView.RegisterRichCommand(CommandRewind);
            //
            CommandFastForwardX = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioFastForwardX_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioFastForwardX_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon("media-seek-forward"),
                () =>
            {
                Logger.Log("AudioPaneViewModel.CommandFastForwardX", Category.Debug, Priority.Medium);

                CommandPause.Execute();

                long newBytesPosition = PlayBytePosition + State.Audio.GetCurrentPcmFormat().Data.ConvertTimeToBytes((long)Settings.Default.AudioWaveForm_JumpTimeStepX * AudioLibPCMFormat.TIME_UNIT);
                if (newBytesPosition > State.Audio.DataLength)
                {
                    newBytesPosition = State.Audio.DataLength;
                    AudioCues.PlayBeep();
                }

                if (IsAutoPlay)
                {
                    State.Selection.ClearSelection();
                }

                PlayBytePosition = newBytesPosition;
            },
                () => CommandFastForward.CanExecute(),
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_GoForwardX));

            m_ShellView.RegisterRichCommand(CommandFastForwardX);
            //
            CommandRewindX = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioRewindX_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioRewindX_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon("media-seek-backward"),
                () =>
            {
                Logger.Log("AudioPaneViewModel.CommandRewindX", Category.Debug, Priority.Medium);

                CommandPause.Execute();

                long newTimeBytePosition = PlayBytePosition - State.Audio.GetCurrentPcmFormat().Data.ConvertTimeToBytes((long)Settings.Default.AudioWaveForm_JumpTimeStepX * AudioLibPCMFormat.TIME_UNIT);
                if (newTimeBytePosition < 0)
                {
                    newTimeBytePosition = 0;
                    AudioCues.PlayBeep();
                }

                if (IsAutoPlay)
                {
                    State.Selection.ClearSelection();
                }

                PlayBytePosition = newTimeBytePosition;
            },
                () => CommandRewind.CanExecute(),
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_GoBackX));

            m_ShellView.RegisterRichCommand(CommandRewindX);
        }
コード例 #27
0
        public MarkersPaneViewModel(
            IEventAggregator eventAggregator,
            ILoggerFacade logger,
            [Import(typeof(IShellView), RequiredCreationPolicy = CreationPolicy.Shared, AllowDefault = false)]
            IShellView view,
            [Import(typeof(IUrakawaSession), RequiredCreationPolicy = CreationPolicy.Shared, AllowDefault = false)]
            IUrakawaSession urakawaSession)
        {
            m_EventAggregator = eventAggregator;
            m_Logger          = logger;
            m_UrakawaSession  = urakawaSession;
            m_ShellView       = view;


            m_Logger.Log("MarkersPaneViewModel.initializeCommands", Category.Debug, Priority.Medium);

            CommandToggleMark = new RichDelegateCommand(
                Tobi_Plugin_NavigationPane_Lang.CmdNavigationToggleMark_ShortDesc,
                Tobi_Plugin_NavigationPane_Lang.CmdNavigationToggleMark_LongDesc,
                null,                     // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon("bookmark-new"),
                () =>
            {
                var cmd = SelectedTreeNode.Presentation.CommandFactory.CreateTreeNodeSetIsMarkedCommand(SelectedTreeNode, !SelectedTreeNode.IsMarked);
                SelectedTreeNode.Presentation.UndoRedoManager.Execute(cmd);
            },
                () => SelectedTreeNode != null && !m_UrakawaSession.isAudioRecording &&
                !m_UrakawaSession.IsXukSpine,         //!m_UrakawaSession.IsSplitMaster &&
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_ToggleDocMark));

            m_ShellView.RegisterRichCommand(CommandToggleMark);

            CommandRemoveAllMarks = new RichDelegateCommand(
                Tobi_Plugin_NavigationPane_Lang.CmdNavigationRemoveAllMarks_ShortDesc,
                Tobi_Plugin_NavigationPane_Lang.CmdNavigationRemoveAllMarks_LongDesc,
                null,                     // KeyGesture obtained from settings (see last parameters below)
                null,                     //m_ShellView.LoadTangoIcon("bookmark-new"),
                () =>
            {
                if (MarkersNavigator_MarkedTreeNodes.Count <= 0)
                {
                    return;
                }
                var treeNodes = new List <TreeNode>(MarkersNavigator_MarkedTreeNodes.Count);
                foreach (MarkedTreeNode marked in MarkersNavigator_MarkedTreeNodes)
                {
                    treeNodes.Add(marked.TreeNode);
                }

                m_UrakawaSession.DocumentProject.Presentations.Get(0).UndoRedoManager.StartTransaction(Tobi_Plugin_NavigationPane_Lang.CmdNavigationRemoveAllMarks_ShortDesc, Tobi_Plugin_NavigationPane_Lang.CmdNavigationRemoveAllMarks_LongDesc, "MARKS_REMOVE_ALL");
                foreach (TreeNode treeNode in treeNodes)
                {
                    var cmd = treeNode.Presentation.CommandFactory.CreateTreeNodeSetIsMarkedCommand(treeNode, !treeNode.IsMarked);
                    treeNode.Presentation.UndoRedoManager.Execute(cmd);
                }
                m_UrakawaSession.DocumentProject.Presentations.Get(0).UndoRedoManager.EndTransaction();
            },
                () => m_UrakawaSession.DocumentProject != null && !m_UrakawaSession.isAudioRecording &&
                !m_UrakawaSession.IsXukSpine,         //SelectedTreeNode != null, //!m_UrakawaSession.IsSplitMaster &&
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_RemoveAllDocMarks));

            m_ShellView.RegisterRichCommand(CommandRemoveAllMarks);

            CommandFindFocusMarkers = new RichDelegateCommand(
                @"MARKERS CommandFindFocus DUMMY TXT",
                @"MARKERS CommandFindFocus DUMMY TXT",
                null, // KeyGesture set only for the top-level CompositeCommand
                null,
                () =>
            {
                m_ShellView.RaiseEscapeEvent();

                if (View != null)
                {
                    IsSearchVisible = true;
                    FocusHelper.Focus(View.SearchBox);
                    View.SearchBox.SelectAll();
                }
            },
                () => View != null
                //&& View.SearchBox.Visibility == Visibility.Visible
                && View.SearchBox.IsEnabled,
                null, //Settings_KeyGestures.Default,
                null  //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Nav_TOCFindNext)
                );

            CommandFindNextMarkers = new RichDelegateCommand(
                @"MARKERS CommandFindNext DUMMY TXT", //UserInterfaceStrings.MarkersFindNext,
                @"MARKERS CommandFindNext DUMMY TXT", //UserInterfaceStrings.MarkersFindNext_,
                null,                                 // KeyGesture set only for the top-level CompositeCommand
                null, () =>
            {
                m_ShellView.RaiseEscapeEvent();

                MarkersNavigator.FindNext(true);
            },
                () => MarkersNavigator != null && !string.IsNullOrEmpty(MarkersNavigator.SearchTerm),
                null, //Settings_KeyGestures.Default,
                null  //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Nav_MarkersFindNext)
                );

            CommandFindPrevMarkers = new RichDelegateCommand(
                @"MARKERS CommandFindPrevious DUMMY TXT", //UserInterfaceStrings.MarkersFindPrev,
                @"MARKERS CommandFindPrevious DUMMY TXT", //UserInterfaceStrings.MarkersFindPrev_,
                null,                                     // KeyGesture set only for the top-level CompositeCommand
                null, () =>
            {
                m_ShellView.RaiseEscapeEvent();

                MarkersNavigator.FindPrevious(true);
            },
                () => MarkersNavigator != null && !string.IsNullOrEmpty(MarkersNavigator.SearchTerm),
                null, //Settings_KeyGestures.Default,
                null  //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Nav_MarkersFindPrev)
                );

            m_EventAggregator.GetEvent <ProjectLoadedEvent>().Subscribe(onProjectLoaded, ProjectLoadedEvent.THREAD_OPTION);
            m_EventAggregator.GetEvent <ProjectUnLoadedEvent>().Subscribe(onProjectUnLoaded, ProjectUnLoadedEvent.THREAD_OPTION);

            m_EventAggregator.GetEvent <MarkedTreeNodeFoundByFlowDocumentParserEvent>().Subscribe(onMarkedTreeNodeFoundByFlowDocumentParser, MarkedTreeNodeFoundByFlowDocumentParserEvent.THREAD_OPTION);

            m_EventAggregator.GetEvent <TreeNodeSelectionChangedEvent>().Subscribe(OnTreeNodeSelectionChanged, TreeNodeSelectionChangedEvent.THREAD_OPTION);
        }
コード例 #28
0
 public StreamStateData(PropertyChangedNotifyBase notifier, AudioPaneViewModel vm)
 {
     m_viewModel = vm;
     m_notifier  = notifier;
 }
コード例 #29
0
 public SelectionStateData(PropertyChangedNotifyBase notifier, AudioPaneViewModel vm)
 {
     m_notifier  = notifier;
     m_viewModel = vm;
 }
コード例 #30
0
        private void initializeCommands_Selection()
        {
            CommandSelectPreviousChunk = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioSelectPreviousChunk_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioSelectPreviousChunk_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon("go-previous"),
                () =>
            {
                Logger.Log("AudioPaneViewModel.CommandSelectPreviousChunk", Category.Debug, Priority.Medium);

                CommandStepBack.Execute();

                SelectChunk(PlayBytePosition);
            },
                () => CommandStepBack.CanExecute(),
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_SelectPreviousChunk));

            m_ShellView.RegisterRichCommand(CommandSelectPreviousChunk);
            //
            CommandSelectNextChunk = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioSelectNextChunk_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioSelectNextChunk_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon("go-next"),
                () =>
            {
                Logger.Log("AudioPaneViewModel.CommandSelectNextChunk", Category.Debug, Priority.Medium);

                CommandStepForward.Execute();

                SelectChunk(PlayBytePosition);
            },
                () => CommandStepForward.CanExecute(),
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_SelectNextChunk));

            m_ShellView.RegisterRichCommand(CommandSelectNextChunk);
            //
            //
            CommandEndSelection = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioEndSelection_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioEndSelection_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                ScalableGreyableImageProvider.ConvertIconFormat((DrawingImage)Application.Current.FindResource("Horizon_Image_Right1")),
                () =>
            {
                Logger.Log("AudioPaneViewModel.CommandEndSelection", Category.Debug, Priority.Medium);

                if (m_SelectionBeginTmpBytePosition < 0)
                {
                    return;
                }

                CommandPause.Execute();

                long begin = m_SelectionBeginTmpBytePosition;
                long end   = PlayBytePosition;

                AudioCues.PlayTockTock();

                if (begin == end)
                {
                    CommandClearSelection.Execute();
                    return;
                }

                if (begin > end)
                {
                    long tmp = begin;
                    begin    = end;
                    end      = tmp;
                }

                State.Selection.SetSelectionBytes(begin, end);

                if (IsAutoPlay)
                {
                    CommandPlay.Execute();
                }

                //if (IsAutoPlay)
                //{
                //    //if (!State.Audio.HasContent)
                //    //{
                //    //    return;
                //    //}

                //    //IsAutoPlay = false;
                //    //LastPlayHeadTime = begin;
                //    //IsAutoPlay = true;

                //    //long bytesFrom = State.Audio.ConvertMillisecondsToBytes(begin);
                //    //long bytesTo = State.Audio.ConvertMillisecondsToBytes(end);

                //    //AudioPlayer_PlayFromTo(bytesFrom, bytesTo);
                //}
            },
                () => CommandSelectAll.CanExecute()
                //CanManipulateWaveForm
                // //&& !IsWaveFormLoading && !IsRecording && !IsMonitoring
                // && State.Audio.HasContent
                && m_SelectionBeginTmpBytePosition >= 0,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_EndSelection));

            m_ShellView.RegisterRichCommand(CommandEndSelection);
            //
            CommandBeginSelection = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioBeginSelection_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioBeginSelection_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                ScalableGreyableImageProvider.ConvertIconFormat((DrawingImage)Application.Current.FindResource("Horizon_Image_Left1")),
                () =>
            {
                Logger.Log("AudioPaneViewModel.CommandBeginSelection", Category.Debug, Priority.Medium);

                //CommandPause.Execute();
                CommandClearSelection.Execute();

                m_SelectionBeginTmpBytePosition = PlayBytePosition;

                AudioCues.PlayTock();
            },
                () => CommandSelectLeft.CanExecute(),
                //CommandSelectAll.CanExecute()
                //         //CanManipulateWaveForm
                //         ////&& !IsWaveFormLoading && !IsRecording && !IsMonitorin
                //         //&& State.Audio.HasContent,
                //         && PlayBytePosition >= 0,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_BeginSelection));

            m_ShellView.RegisterRichCommand(CommandBeginSelection);
            //
            CommandSelectLeft = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioSelectLeft_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioSelectLeft_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon("format-indent-less"),
                () =>
            {
                Logger.Log("AudioPaneViewModel.CommandSelectLeft", Category.Debug, Priority.Medium);

                if (PlayBytePosition <= 0)
                {
                    AudioCues.PlayBeep();
                    return;
                }

                State.Selection.SetSelectionBytes(0, PlayBytePosition);

                PlayBytePosition = State.Selection.SelectionEndBytePosition;

                //AudioCues.PlayTock();
            },
                () => CommandSelectAll.CanExecute()
                //CanManipulateWaveForm
                // //&& !IsWaveFormLoading && !IsRecording && !IsMonitoring
                // && State.Audio.HasContent
                && PlayBytePosition >= 0,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_SelectLeft));

            m_ShellView.RegisterRichCommand(CommandSelectLeft);
            //
            CommandSelectRight = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdAudioSelectRight_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdAudioSelectRight_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon("format-indent-more"),
                () =>
            {
                Logger.Log("AudioPaneViewModel.CommandSelectRight", Category.Debug, Priority.Medium);

                if (PlayBytePosition >= State.Audio.DataLength)
                {
                    AudioCues.PlayBeep();
                    return;
                }

                State.Selection.SetSelectionBytes(PlayBytePosition, State.Audio.DataLength);
                //AudioCues.PlayTock();
            },
                () => CommandSelectLeft.CanExecute(),
                //CanManipulateWaveForm
                // //&& !IsWaveFormLoading && !IsRecording && !IsMonitoring
                // && State.Audio.HasContent && PlayBytePosition >= 0,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_SelectRight));

            m_ShellView.RegisterRichCommand(CommandSelectRight);
            //
            CommandSelectAll = new RichDelegateCommand(
                Tobi_Plugin_AudioPane_Lang.CmdSelectAll_ShortDesc,
                Tobi_Plugin_AudioPane_Lang.CmdSelectAll_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon("view-fullscreen"),
                () =>
            {
                Logger.Log("AudioPaneViewModel.CommandSelectAll", Category.Debug, Priority.Medium);

                //if (!State.Audio.HasContent)
                //{
                //    if (View != null)
                //    {
                //        View.SelectAll();
                //    }
                //    return;
                //}

                State.Selection.SetSelectionBytes(0, State.Audio.DataLength);

                //AudioCues.PlayTockTock();
            },
                () => CanManipulateWaveForm
                //&& !IsWaveFormLoading && !IsRecording && !IsMonitoring
                && State.Audio.HasContent,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_SelectAll));

            m_ShellView.RegisterRichCommand(CommandSelectAll);
            //
            CommandClearSelection = new RichDelegateCommand(Tobi_Plugin_AudioPane_Lang.CmdAudioClearSelection_ShortDesc,
                                                            Tobi_Plugin_AudioPane_Lang.CmdAudioClearSelection_LongDesc,
                                                            null, // KeyGesture obtained from settings (see last parameters below)
                                                            m_ShellView.LoadTangoIcon("edit-clear"),
                                                            () =>
            {
                //Logger.Log("AudioPaneViewModel.CommandClearSelection", Category.Debug, Priority.Medium);

                State.Selection.ClearSelection();
            },
                                                            () => CommandSelectAll.CanExecute()
                                                            //CanManipulateWaveForm
                                                            // //&& !IsWaveFormLoading && !IsRecording && !IsMonitoring
                                                            // && State.Audio.HasContent
                                                            && IsSelectionSet,
                                                            Settings_KeyGestures.Default,
                                                            PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_ClearSelection));

            m_ShellView.RegisterRichCommand(CommandClearSelection);
            //
        }