public NavigationPane(
            IRegionManager regionManager,
            [Import(typeof(IShellView), RequiredCreationPolicy = CreationPolicy.Shared, AllowDefault = false)]
            IShellView shellView,
            [Import(typeof(HeadingPanelView), RequiredCreationPolicy = CreationPolicy.Shared, AllowDefault = false)]
            HeadingPanelView tocView,
            [Import(typeof(PagePanelView), RequiredCreationPolicy = CreationPolicy.Shared, AllowDefault = false)]
            PagePanelView pagesView,
            [Import(typeof(MarkersPanelView), RequiredCreationPolicy = CreationPolicy.Shared, AllowDefault = false)]
            MarkersPanelView markersView)
        {
            m_RegionManager   = regionManager;
            m_ShellView       = shellView;
            m_PagePaneView    = pagesView;
            m_HeadingPaneView = tocView;
            m_MarkersPaneView = markersView;

            InitializeComponent();

            RegionManager.SetRegionManager(this, m_RegionManager);
            RegionManager.UpdateRegions();

            CommandFocus = new RichDelegateCommand(
                Tobi_Plugin_NavigationPane_Lang.CmdNavigationFocus_ShortDesc,
                null,
                null,                     // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon("start-here"),
                () =>
            {
                IRegion tabRegion = m_RegionManager.Regions[RegionNames.NavigationPaneTabs];

                UIElement ui = null;

                foreach (var view in tabRegion.ActiveViews)                         // should be just only one
                {
                    if (view is ITobiViewFocusable)
                    {
                        ui = ((ITobiViewFocusable)view).FocusableItem;
                        break;
                    }
                    else
                    {
                        //if (view == m_PagePaneView.ViewControl)
                        //{
                        //    ui = m_PagePaneView.ViewFocusStart;
                        //    if (ui.Focusable)
                        //        break;
                        //}
                        //if (view == m_HeadingPaneView.ViewControl)
                        //{
                        //    ui = m_HeadingPaneView.ViewFocusStart;
                        //    if (ui.Focusable)
                        //        break;
                        //}
                        //if (view == m_MarkersPaneView.ViewControl)
                        //{
                        //    ui = m_MarkersPaneView.ViewFocusStart;
                        //    if (ui.Focusable)
                        //        break;
                        //}

#if DEBUG
                        Debugger.Break();
#endif

                        ui = FocusHelper.GetLeafFocusableChild((UIElement)view);
                    }
                }

                if (ui != null && ui.Focusable)
                {
                    FocusHelper.FocusBeginInvoke(ui);
                }
            },
                () => true,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Focus_Nav));

            m_ShellView.RegisterRichCommand(CommandFocus);
        }
        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));

            m_ShellView.RegisterRichCommand(CommandZoomFitFull);
            //
            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);
            //
        }
Beispiel #3
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_PlaybackRateReset));

            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)
                    {
                        //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);
            //
        }
Beispiel #4
0
 public void SetRichCommand(RichDelegateCommand command)
 {
     SetRichCommand(command, this, OnCommandDataChanged);
 }