mirror of
https://github.com/4sval/FModel.git
synced 2026-04-26 16:17:17 -05:00
new link color + VisualLineTexts are weird + hide audio spectrum
This commit is contained in:
parent
0be44a37b2
commit
a108efbddf
|
|
@ -163,6 +163,7 @@ public class AudioPlayerViewModel : ViewModel, ISource, IDisposable
|
|||
private TimeSpan _length => _waveSource?.GetLength() ?? TimeSpan.Zero;
|
||||
private TimeSpan _position => _waveSource?.GetPosition() ?? TimeSpan.Zero;
|
||||
private PlaybackState _playbackState => _soundOut?.PlaybackState ?? PlaybackState.Stopped;
|
||||
private bool _hideToggle = false;
|
||||
|
||||
public SpectrumProvider Spectrum { get; private set; }
|
||||
public float[] FftData { get; private set; }
|
||||
|
|
@ -409,6 +410,13 @@ public class AudioPlayerViewModel : ViewModel, ISource, IDisposable
|
|||
_soundOut.Stop();
|
||||
}
|
||||
|
||||
public void HideToggle()
|
||||
{
|
||||
if (!IsPlaying) return;
|
||||
_hideToggle = !_hideToggle;
|
||||
RaiseSourcePropertyChangedEvent(ESourceProperty.HideToggle, _hideToggle);
|
||||
}
|
||||
|
||||
public void SkipTo(double percentage)
|
||||
{
|
||||
if (_soundOut == null || _waveSource == null) return;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@
|
|||
xmlns:adonisUi="clr-namespace:AdonisUI;assembly=AdonisUI"
|
||||
xmlns:adonisControls="clr-namespace:AdonisUI.Controls;assembly=AdonisUI"
|
||||
xmlns:adonisExtensions="clr-namespace:AdonisUI.Extensions;assembly=AdonisUI"
|
||||
WindowStartupLocation="CenterScreen" IconVisibility="Collapsed" Closing="OnClosing" PreviewKeyDown="OnPreviewKeyDown"
|
||||
WindowStartupLocation="CenterScreen" IconVisibility="Collapsed"
|
||||
Closing="OnClosing" PreviewKeyDown="OnPreviewKeyDown" Activated="OnActivatedDeactivated" Deactivated="OnActivatedDeactivated"
|
||||
Height="{Binding Source={x:Static SystemParameters.MaximizedPrimaryScreenHeight}, Converter={converters:RatioConverter}, ConverterParameter='0.50'}"
|
||||
Width="{Binding Source={x:Static SystemParameters.MaximizedPrimaryScreenWidth}, Converter={converters:RatioConverter}, ConverterParameter='0.55'}">
|
||||
<adonisControls:AdonisWindow.Style>
|
||||
|
|
|
|||
|
|
@ -90,4 +90,9 @@ public partial class AudioPlayer
|
|||
var filters = textBox.Text.Trim().Split(' ');
|
||||
_applicationView.AudioPlayer.AudioFilesView.Filter = o => { return o is AudioFile audio && filters.All(x => audio.FileName.Contains(x, StringComparison.OrdinalIgnoreCase)); };
|
||||
}
|
||||
|
||||
private void OnActivatedDeactivated(object sender, EventArgs e)
|
||||
{
|
||||
_applicationView.AudioPlayer.HideToggle();
|
||||
}
|
||||
}
|
||||
|
|
@ -29,8 +29,13 @@ public class GamePathVisualLineText : VisualLineText
|
|||
if (context == null)
|
||||
throw new ArgumentNullException(nameof(context));
|
||||
|
||||
var relativeOffset = startVisualColumn - VisualColumn;
|
||||
var text = context.GetText(context.VisualLine.FirstDocumentLine.Offset + RelativeTextOffset + relativeOffset, DocumentLength - relativeOffset);
|
||||
|
||||
if (text.Count != 2) // ": "
|
||||
TextRunProperties.SetForegroundBrush(Brushes.Plum);
|
||||
return base.CreateTextRun(startVisualColumn, context);
|
||||
|
||||
return new TextCharacters(text.Text, text.Offset, text.Count, TextRunProperties);
|
||||
}
|
||||
|
||||
private bool GamePathIsClickable() => !string.IsNullOrEmpty(_gamePath) && Keyboard.Modifiers == ModifierKeys.None;
|
||||
|
|
|
|||
|
|
@ -19,8 +19,13 @@ public class HexColorVisualLineText : VisualLineText
|
|||
if (context == null)
|
||||
throw new ArgumentNullException(nameof(context));
|
||||
|
||||
var relativeOffset = startVisualColumn - VisualColumn;
|
||||
var text = context.GetText(context.VisualLine.FirstDocumentLine.Offset + RelativeTextOffset + relativeOffset, DocumentLength - relativeOffset);
|
||||
|
||||
if (text.Count != 2) // ": "
|
||||
TextRunProperties.SetForegroundBrush(Brushes.PeachPuff);
|
||||
return base.CreateTextRun(startVisualColumn, context);
|
||||
|
||||
return new TextCharacters(text.Text, text.Offset, text.Count, TextRunProperties);
|
||||
}
|
||||
|
||||
protected override VisualLineText CreateInstance(int length)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ public enum ESourceProperty
|
|||
{
|
||||
FftData,
|
||||
PlaybackState,
|
||||
HideToggle,
|
||||
Length,
|
||||
Position,
|
||||
WaveformData,
|
||||
|
|
|
|||
|
|
@ -133,10 +133,12 @@ public sealed class SpectrumAnalyzer : UserControl
|
|||
case ESourceProperty.FftData:
|
||||
UpdateSpectrum(SpectrumResolution, _source.FftData);
|
||||
break;
|
||||
case ESourceProperty.HideToggle when (bool) e.Value == false:
|
||||
case ESourceProperty.PlaybackState when (PlaybackState) e.Value == PlaybackState.Playing:
|
||||
case ESourceProperty.RecordingState when (RecordingState) e.Value == RecordingState.Recording:
|
||||
CreateBars();
|
||||
break;
|
||||
case ESourceProperty.HideToggle when (bool) e.Value:
|
||||
case ESourceProperty.RecordingState when (RecordingState) e.Value == RecordingState.Stopped:
|
||||
SilenceBars();
|
||||
break;
|
||||
|
|
@ -332,15 +334,15 @@ public sealed class SpectrumAnalyzer : UserControl
|
|||
{
|
||||
if (_spectrumGrid == null) return;
|
||||
|
||||
_spectrumGrid.Children.Clear();
|
||||
_bars = new Border[FrequencyBarCount];
|
||||
for (var i = 0; i < _bars.Length; i++)
|
||||
{
|
||||
var borderBrush = FrequencyBarBorderBrush.Clone();
|
||||
var barBrush = FrequencyBarBrush.Clone();
|
||||
borderBrush.Freeze();
|
||||
barBrush.Freeze();
|
||||
|
||||
_spectrumGrid.Children.Clear();
|
||||
_bars = new Border[FrequencyBarCount];
|
||||
for (var i = 0; i < _bars.Length; i++)
|
||||
{
|
||||
_bars[i] = new Border
|
||||
{
|
||||
CornerRadius = FrequencyBarCornerRadius,
|
||||
|
|
|
|||
|
|
@ -322,7 +322,15 @@ public sealed class Timeclock : UserControl
|
|||
}
|
||||
else
|
||||
{
|
||||
Dispatcher.BeginInvoke((Action) delegate { _timeText.Text = TimeSpan.Zero.ToString(TimeFormat); });
|
||||
ZeroTime();
|
||||
}
|
||||
}
|
||||
|
||||
private void ZeroTime()
|
||||
{
|
||||
Dispatcher.BeginInvoke((Action) delegate
|
||||
{
|
||||
_timeText.Text = TimeSpan.Zero.ToString(TimeFormat);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -40,6 +40,8 @@ public partial class AvalonEditor
|
|||
|
||||
YesWeEditor = MyAvalonEditor;
|
||||
YesWeSearch = WpfSuckMyDick;
|
||||
MyAvalonEditor.TextArea.TextView.LinkTextBackgroundBrush = null;
|
||||
MyAvalonEditor.TextArea.TextView.LinkTextForegroundBrush = Brushes.Cornsilk;
|
||||
MyAvalonEditor.TextArea.TextView.ElementGenerators.Add(new GamePathElementGenerator());
|
||||
MyAvalonEditor.TextArea.TextView.ElementGenerators.Add(new HexColorElementGenerator());
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ public partial class PropertiesPopout
|
|||
MyAvalonEditor.FontSize = contextViewModel.FontSize;
|
||||
MyAvalonEditor.SyntaxHighlighting = contextViewModel.Highlighter;
|
||||
MyAvalonEditor.ScrollToVerticalOffset(contextViewModel.ScrollPosition);
|
||||
MyAvalonEditor.TextArea.TextView.LinkTextBackgroundBrush = null;
|
||||
MyAvalonEditor.TextArea.TextView.LinkTextForegroundBrush = Brushes.Cornsilk;
|
||||
MyAvalonEditor.TextArea.TextView.ElementGenerators.Add(new GamePathElementGenerator());
|
||||
MyAvalonEditor.TextArea.TextView.ElementGenerators.Add(new HexColorElementGenerator());
|
||||
_manager = new JsonFoldingStrategies(MyAvalonEditor);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user