Esempio n. 1
0
        public DescribableTreeNode FindPrevious(bool select)
        {
            DescribableTreeNode previousMatch = FindPrevDescription(m_DescribableTreeNodes);

            if (previousMatch != null)
            {
                var listItem = VisualLogicalTreeWalkHelper.FindObjectInVisualTreeWithMatchingType <ListViewItem>(
                    m_view.ListView,
                    child =>
                {
                    object dc = child.GetValue(FrameworkElement.DataContextProperty);
                    return(dc != null && dc == previousMatch);
                });
                if (select)
                {
                    previousMatch.IsSelected = true;
                    if (listItem != null)
                    {
                        FocusHelper.FocusBeginInvoke(listItem); //m_view.m_LastListItemSelected
                    }
                }
                else
                {
                    if (listItem != null)
                    {
                        listItem.BringIntoView();
                    }
                }
            }
            else
            {
                AudioCues.PlayBeep();
            }
            return(previousMatch);
        }
Esempio n. 2
0
        public MarkedTreeNode FindNext(bool select)
        {
            MarkedTreeNode nextMatch = FindNextMarkers(m_MarkedTreeNodes);

            if (nextMatch != null)
            {
                var listItem = VisualLogicalTreeWalkHelper.FindObjectInVisualTreeWithMatchingType <ListViewItem>(
                    m_view.ListView,
                    child =>
                {
                    object dc = child.GetValue(FrameworkElement.DataContextProperty);
                    return(dc != null && dc == nextMatch);
                });
                if (select)
                {
                    nextMatch.IsSelected = true;
                    if (listItem != null)
                    {
                        FocusHelper.FocusBeginInvoke(listItem); //m_view.m_LastListItemSelected
                    }
                }
                else
                {
                    if (listItem != null)
                    {
                        listItem.BringIntoView();
                    }
                }
            }
            else
            {
                AudioCues.PlayBeep();
            }
            return(nextMatch);
        }
Esempio n. 3
0
        private RecentFileWrapper FindPrevious(bool select)
        {
            RecentFileWrapper previousMatch = FindPrevSetting();

            if (previousMatch != null)
            {
                if (select)
                {
                    previousMatch.IsSelected = true;
                }
                else
                {
                    var listItem = VisualLogicalTreeWalkHelper.FindObjectInVisualTreeWithMatchingType <ListViewItem>(
                        RecentFilesList,
                        child =>
                    {
                        object dc = child.GetValue(FrameworkElement.DataContextProperty);
                        return(dc != null && dc == previousMatch);
                    });
                    if (listItem != null)
                    {
                        listItem.BringIntoView();
                    }
                }
            }
            else
            {
                AudioCues.PlayBeep();
            }
            return(previousMatch);
        }
        public HeadingTreeNodeWrapper FindPrevious(bool select)
        {
            ExpandAll();

            HeadingTreeNodeWrapper prevMatch = FindPrevMatch(m_roots);

            if (prevMatch != null)
            {
                if (select)
                {
                    //prevMatch.IsSelected = true;
                    ViewModel.View.SelectTreeNodeWrapper(prevMatch, true);
                }
                else
                {
                    var treeViewItem = VisualLogicalTreeWalkHelper.FindObjectInVisualTreeWithMatchingType <TreeViewItem>(
                        ViewModel.View.TreeView,
                        child =>
                    {
                        object dc = child.GetValue(FrameworkElement.DataContextProperty);
                        return(dc != null && dc == prevMatch);
                    });
                    if (treeViewItem != null)
                    {
                        treeViewItem.BringIntoView();
                    }
                }
            }
            else
            {
                AudioCues.PlayBeep();
            }

            return(prevMatch);
        }
Esempio n. 5
0
        private SettingWrapper FindNext(bool select)
        {
            SettingWrapper nextMatch = FindNextSetting();

            if (nextMatch != null)
            {
                if (select)
                {
                    nextMatch.IsSelected = true;
                }
                else
                {
                    var listItem = VisualLogicalTreeWalkHelper.FindObjectInVisualTreeWithMatchingType <ListViewItem>(
                        SettingsList,
                        child =>
                    {
                        object dc = child.GetValue(FrameworkElement.DataContextProperty);
                        return(dc != null && dc == nextMatch);
                    });
                    if (listItem != null)
                    {
                        listItem.BringIntoView();
                    }
                }
            }
            else
            {
                AudioCues.PlayBeep();
            }
            return(nextMatch);
        }
Esempio n. 6
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);
        }
Esempio n. 7
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);
            //
        }
Esempio n. 8
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);
            //
        }