mirror of
https://github.com/4sval/FModel.git
synced 2026-03-21 17:24:26 -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;
|
||||
|
|
@ -580,4 +588,4 @@ public class AudioPlayerViewModel : ViewModel, ISource, IDisposable
|
|||
File.Delete(SelectedAudioFile.FilePath);
|
||||
return vgmProcess?.ExitCode == 0 && File.Exists(wavFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
@ -27,7 +28,7 @@
|
|||
<ColumnDefinition Width="350" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
|
||||
<GroupBox Grid.Column="0" Padding="{adonisUi:Space 0}" Background="Transparent">
|
||||
<DockPanel Margin="10">
|
||||
<Grid DockPanel.Dock="Top">
|
||||
|
|
@ -43,7 +44,7 @@
|
|||
<ColumnDefinition Width="10" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="Devices" VerticalAlignment="Center" Margin="0 0 0 10" />
|
||||
<ComboBox Grid.Row="0" Grid.Column="2" ItemsSource="{Binding AudioPlayer.AudioDevicesView, IsAsync=True}"
|
||||
SelectedItem="{Binding AudioPlayer.SelectedAudioDevice, Mode=TwoWay}" SelectionChanged="OnDeviceSwap">
|
||||
|
|
@ -53,18 +54,18 @@
|
|||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Text="Volume" VerticalAlignment="Center" Margin="0 0 0 10" />
|
||||
<Slider Grid.Row="1" Grid.Column="2" TickPlacement="None" Minimum="0" Maximum="100" TickFrequency="1"
|
||||
AutoToolTipPlacement="BottomRight" IsMoveToPointEnabled="True" ValueChanged="OnVolumeChange"
|
||||
Value="{Binding AudioPlayerVolume, Source={x:Static local:Settings.UserSettings.Default}, Mode=TwoWay}"/>
|
||||
|
||||
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" Text="Encoding" VerticalAlignment="Center" Margin="0 0 0 10" />
|
||||
<TextBlock Grid.Row="2" Grid.Column="2" Text="{Binding AudioPlayer.PlayedFile.Encoding, Converter={x:Static converters:EnumToStringConverter.Instance}}" VerticalAlignment="Center" HorizontalAlignment="Right" />
|
||||
|
||||
|
||||
<TextBlock Grid.Row="3" Grid.Column="0" Text="Length" VerticalAlignment="Center" Margin="0 0 0 10" />
|
||||
<TextBlock Grid.Row="3" Grid.Column="2" Text="{Binding AudioPlayer.PlayedFile.Duration}" VerticalAlignment="Center" HorizontalAlignment="Right" />
|
||||
|
||||
|
||||
<TextBlock Grid.Row="4" Grid.Column="0" Text="Bytes Per Second" VerticalAlignment="Center" />
|
||||
<TextBlock Grid.Row="4" Grid.Column="2" Text="{Binding AudioPlayer.PlayedFile.BytesPerSecond}" VerticalAlignment="Center" HorizontalAlignment="Right" />
|
||||
</Grid>
|
||||
|
|
@ -74,7 +75,7 @@
|
|||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
|
||||
<Grid Grid.Column="0" ZIndex="1" HorizontalAlignment="Left" Margin="5 2 0 0">
|
||||
<Viewbox Width="16" Height="16">
|
||||
<Canvas Width="24" Height="24">
|
||||
|
|
@ -130,14 +131,14 @@
|
|||
</ListBox>
|
||||
</DockPanel>
|
||||
</GroupBox>
|
||||
|
||||
|
||||
<Grid Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
|
||||
<audioControls:Timeclock Grid.Row="0" />
|
||||
<StackPanel Grid.Row="1" Margin="0 0 25 0"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Top" Orientation="Horizontal">
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
||||
TextRunProperties.SetForegroundBrush(Brushes.Plum);
|
||||
return base.CreateTextRun(startVisualColumn, 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 new TextCharacters(text.Text, text.Offset, text.Count, TextRunProperties);
|
||||
}
|
||||
|
||||
private bool GamePathIsClickable() => !string.IsNullOrEmpty(_gamePath) && Keyboard.Modifiers == ModifierKeys.None;
|
||||
|
|
@ -76,4 +81,4 @@ public class GamePathVisualLineText : VisualLineText
|
|||
};
|
||||
return a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,12 +19,17 @@ public class HexColorVisualLineText : VisualLineText
|
|||
if (context == null)
|
||||
throw new ArgumentNullException(nameof(context));
|
||||
|
||||
TextRunProperties.SetForegroundBrush(Brushes.PeachPuff);
|
||||
return base.CreateTextRun(startVisualColumn, 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 new TextCharacters(text.Text, text.Offset, text.Count, TextRunProperties);
|
||||
}
|
||||
|
||||
protected override VisualLineText CreateInstance(int length)
|
||||
{
|
||||
return new HexColorVisualLineText(_hexColor, ParentVisualLine, length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ public enum ESourceProperty
|
|||
{
|
||||
FftData,
|
||||
PlaybackState,
|
||||
HideToggle,
|
||||
Length,
|
||||
Position,
|
||||
WaveformData,
|
||||
|
|
@ -22,4 +23,4 @@ public class SourcePropertyChangedEventArgs : EventArgs
|
|||
Property = property;
|
||||
Value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
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++)
|
||||
{
|
||||
var borderBrush = FrequencyBarBorderBrush.Clone();
|
||||
var barBrush = FrequencyBarBrush.Clone();
|
||||
borderBrush.Freeze();
|
||||
barBrush.Freeze();
|
||||
|
||||
_bars[i] = new Border
|
||||
{
|
||||
CornerRadius = FrequencyBarCornerRadius,
|
||||
|
|
@ -440,4 +442,4 @@ public sealed class SpectrumAnalyzer : UserControl
|
|||
}
|
||||
}, DispatcherPriority.ApplicationIdle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
||||
|
|
@ -250,4 +252,4 @@ public partial class AvalonEditor
|
|||
{
|
||||
SaveCaretLoc(MyAvalonEditor.CaretOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
@ -67,7 +69,7 @@ public partial class PropertiesPopout
|
|||
_ => fontSize
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private void OnPreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
switch (e.Key)
|
||||
|
|
@ -96,4 +98,4 @@ public partial class PropertiesPopout
|
|||
c.Green * c.Green * .587 +
|
||||
c.Blue * c.Blue * .114);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user