implementation of playlist logic(favorits or costum) item class is mvvm and normal due to it double usage. playlist are a filterd data grid with check box
This commit is contained in:
@@ -146,10 +146,11 @@
|
||||
<Button Grid.Column="0" Grid.Row="2"
|
||||
Content="Settings"
|
||||
Margin="10"
|
||||
HorizontalAlignment="Left"/>
|
||||
HorizontalAlignment="Left"
|
||||
Click="PlayListButton_Click"/>
|
||||
|
||||
<!-- PLAYER CONTROLS -->
|
||||
<Slider Name="itemProgress" Panel.ZIndex="2" VerticalAlignment="Top" ValueChanged="ItemProgress_OnValueChanged" Grid.Row="2" Grid.Column="1" Padding="10"></Slider>
|
||||
<Slider Name="itemProgress" PreviewMouseDown="ItemProgress_OnPreviewMouseDown" Panel.ZIndex="2" VerticalAlignment="Top" ValueChanged="ItemProgress_OnValueChanged" Grid.Row="2" Grid.Column="1" Padding="10"></Slider>
|
||||
<ProgressBar Name="itemProgressVisual" Panel.ZIndex="1" Height="20" VerticalAlignment="Top" Grid.Row="2" Grid.Column="1" Padding="10"></ProgressBar>
|
||||
<StackPanel Grid.Column="1" Grid.Row="2"
|
||||
Orientation="Horizontal"
|
||||
|
@@ -1,33 +1,26 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using file_finder__test;
|
||||
using ShadowStream;
|
||||
using ShadowStream.LogHelper;
|
||||
using ShadowStream.Obejeckte;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using ShadowStream.ObjecktForJason;
|
||||
using TagLib;
|
||||
using ShadowStream.Modules;
|
||||
using ShadowStream.ObjecktForJason;
|
||||
using LibVLCSharp.Shared;
|
||||
using ModuleManager.Modules;
|
||||
using Brushes = System.Windows.Media.Brushes;
|
||||
using Color = System.Windows.Media.Color;
|
||||
using File = System.IO.File;
|
||||
using Image = System.Drawing.Image;
|
||||
using Path = System.IO.Path;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Threading;
|
||||
using ShadowStream.Views;
|
||||
using Point = System.Windows.Point;
|
||||
|
||||
|
||||
namespace ModuleManager;
|
||||
@@ -41,11 +34,13 @@ public partial class MainWindow : Window
|
||||
#region no dont cahnge
|
||||
|
||||
//adding base components used threw out the code
|
||||
private static LogHelper loghelper = new LogHelper();
|
||||
LogWindow logWin = new LogWindow(loghelper.GetEntries());
|
||||
LogHelper log = new LogHelper();
|
||||
LogWindow logWin = new LogWindow(log.GetEntries());
|
||||
static LogHelper log = new LogHelper();
|
||||
|
||||
Favorites favorites = new Favorites();
|
||||
PlaylistEditor popupWindow;
|
||||
|
||||
ObjListBP _favorites = new ObjListBP();
|
||||
ObjListBP _playlists = new ObjListBP();
|
||||
|
||||
private Catagory Muvie = new Catagory("Muvie");
|
||||
private Catagory Serie = new Catagory("Serie");
|
||||
@@ -70,7 +65,9 @@ public partial class MainWindow : Window
|
||||
public string _category;
|
||||
|
||||
StringConversions stringConversions = new StringConversions();
|
||||
|
||||
|
||||
private DispatcherTimer _progressTimer;
|
||||
|
||||
#endregion
|
||||
|
||||
//Quinn
|
||||
@@ -86,16 +83,14 @@ public partial class MainWindow : Window
|
||||
#region Init wpf
|
||||
InitializeComponent();
|
||||
//Initialise but Hide
|
||||
logWin.Hide();
|
||||
logWin.Show();
|
||||
//logWin.Hide();
|
||||
//this.Hide();
|
||||
|
||||
|
||||
//Begin Login Process
|
||||
var login = new LogIn();
|
||||
login.Show();
|
||||
|
||||
#endregion
|
||||
|
||||
//Quinn Dont change or remuve!!!
|
||||
#region vlc init
|
||||
|
||||
@@ -107,6 +102,12 @@ public partial class MainWindow : Window
|
||||
VideoView.MediaPlayer = _mediaPlayer;
|
||||
|
||||
_mediaPlayer.Volume = Convert.ToInt32(vol.Value);
|
||||
|
||||
_progressTimer = new DispatcherTimer
|
||||
{
|
||||
Interval = TimeSpan.FromSeconds(1)
|
||||
};
|
||||
_progressTimer.Tick += ProgressTimer_Tick;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -134,7 +135,7 @@ public partial class MainWindow : Window
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
LoadSavedData();
|
||||
|
||||
}
|
||||
@@ -376,7 +377,18 @@ public partial class MainWindow : Window
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void PlayListButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ObservableCollection<Catagory> tmpBP= new ObservableCollection<Catagory>();
|
||||
tmpBP.Add(Muvie);
|
||||
tmpBP.Add(Serie);
|
||||
tmpBP.Add(Photo);
|
||||
tmpBP.Add(Music);
|
||||
popupWindow = new PlaylistEditor(tmpBP);
|
||||
popupWindow.Owner = this;
|
||||
popupWindow.ShowInTaskbar = false;
|
||||
popupWindow.Show();
|
||||
}
|
||||
|
||||
#region Catagory btns
|
||||
private void Home_OnClick(object sender, RoutedEventArgs e)
|
||||
@@ -459,8 +471,6 @@ public partial class MainWindow : Window
|
||||
|
||||
return (await Task.WhenAll(tasks)).ToList();
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<Item>> ItemCreater(List<string> paths, string type, bool isFoto, bool isMusic = false)
|
||||
{
|
||||
var itemsBag = new ConcurrentBag<Item>();
|
||||
@@ -567,7 +577,7 @@ public partial class MainWindow : Window
|
||||
#region Comunication
|
||||
public void addFavorit(ref Item item)
|
||||
{
|
||||
favorites.SharedRefs.Add(item);
|
||||
_favorites.SharedRefs.Add(item);
|
||||
}
|
||||
public void ReciveErrorLog(string logMessage)
|
||||
{
|
||||
@@ -578,8 +588,21 @@ public partial class MainWindow : Window
|
||||
if(suportedVidioFiles.Contains(Path.GetExtension(filePath))||suportedPhotoFiles.Contains(Path.GetExtension(filePath)))
|
||||
VideoView.Visibility = Visibility.Visible;
|
||||
var media = new Media(_libVLC, filePath, FromType.FromPath);
|
||||
|
||||
media.ParsedChanged += (sender, args) =>
|
||||
{
|
||||
if (args.ParsedStatus == MediaParsedStatus.Done)
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
var duration = media.Duration;
|
||||
videoSliderInit(duration / 1000);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
media.Parse(MediaParseOptions.ParseLocal);
|
||||
_mediaPlayer.Play(media);
|
||||
videoSliderInit(media.Duration/1000);
|
||||
}
|
||||
|
||||
public void setStrings()
|
||||
@@ -675,6 +698,16 @@ public partial class MainWindow : Window
|
||||
_mediaPlayer.Stop();
|
||||
VideoView.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
public void RecivePlaylist(ObjListBP items)
|
||||
{
|
||||
_playlists.SharedRefs.Add(items);
|
||||
RecivePlaylist();
|
||||
}
|
||||
public void RecivePlaylist()
|
||||
{
|
||||
popupWindow.Close();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
@@ -793,9 +826,6 @@ public partial class MainWindow : Window
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region load saved data
|
||||
@@ -892,10 +922,6 @@ public partial class MainWindow : Window
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region sliders
|
||||
@@ -913,7 +939,7 @@ public partial class MainWindow : Window
|
||||
|
||||
#endregion
|
||||
|
||||
#region progress slider
|
||||
#region progress slider
|
||||
private void ItemProgress_OnValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
|
||||
{
|
||||
if (itemProgress.IsMouseOver)
|
||||
@@ -921,17 +947,17 @@ public partial class MainWindow : Window
|
||||
ProgressBarValueChange();
|
||||
}
|
||||
}
|
||||
private void ItemProgress_OnValueChanged(long timeStap)
|
||||
private void ItemProgress_OnValueChangedMil(long timeStap)
|
||||
{
|
||||
itemProgress.Value = timeStap;
|
||||
ProgressBarValueChange();
|
||||
itemProgress.Value = timeStap/1000;
|
||||
itemProgressVisual.Value = itemProgress.Value;
|
||||
|
||||
}
|
||||
private void ProgressBarValueChange()
|
||||
{
|
||||
itemProgressVisual.Value = itemProgress.Value;
|
||||
_mediaPlayer.Time = Convert.ToInt64(itemProgress.Value) * 1000; // convert to milliseconds
|
||||
|
||||
if(itemProgress.IsMouseOver)
|
||||
_mediaPlayer.Time = Convert.ToInt64(itemProgress.Value) * 1000; // convert to milliseconds
|
||||
}
|
||||
private void videoSliderInit(long timeStap)
|
||||
{
|
||||
@@ -939,8 +965,47 @@ public partial class MainWindow : Window
|
||||
itemProgressVisual.Maximum = timeStap;
|
||||
itemProgress.Minimum = 0;
|
||||
itemProgressVisual.Minimum = 0;
|
||||
StartProgressTimer();
|
||||
Console.WriteLine(timeStap);
|
||||
}
|
||||
|
||||
private void ItemProgress_OnPreviewMouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
var slider = sender as Slider;
|
||||
if (slider == null) return;
|
||||
Point position = e.GetPosition(slider);
|
||||
double relativePosition = position.X / slider.ActualWidth;
|
||||
relativePosition = Math.Max(0, Math.Min(1, relativePosition));
|
||||
double newValue = slider.Minimum + (relativePosition * (slider.Maximum - slider.Minimum));
|
||||
slider.Value = newValue;
|
||||
|
||||
ProgressBarValueChange();
|
||||
|
||||
}
|
||||
private void ProgressTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
if (!_mediaPlayer.IsPlaying)
|
||||
{
|
||||
StopProgressTimer();
|
||||
}
|
||||
// Get current timestamp from media player in seconds
|
||||
long currentTimeInSeconds = _mediaPlayer.Time;
|
||||
|
||||
// Update progress bar value
|
||||
ItemProgress_OnValueChangedMil(currentTimeInSeconds);
|
||||
}
|
||||
private void StartProgressTimer()
|
||||
{
|
||||
if (!_progressTimer.IsEnabled)
|
||||
_progressTimer.Start();
|
||||
}
|
||||
private void StopProgressTimer()
|
||||
{
|
||||
if (_progressTimer.IsEnabled)
|
||||
_progressTimer.Stop();
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
57
ShadowStream/Views/PlaylistEditor.xaml
Normal file
57
ShadowStream/Views/PlaylistEditor.xaml
Normal file
@@ -0,0 +1,57 @@
|
||||
<Window x:Class="ShadowStream.Views.PlaylistEditor"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="PlaylistEditor"
|
||||
ResizeMode="NoResize"
|
||||
SizeToContent="WidthAndHeight"
|
||||
Background="DarkGray"
|
||||
Topmost="True">
|
||||
<Grid Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/> <!-- Playlist Name -->
|
||||
<RowDefinition Height="Auto"/> <!-- Buttons -->
|
||||
<RowDefinition Height="*"/> <!-- DataGrid -->
|
||||
<RowDefinition Height="Auto"/> <!-- Return Button -->
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Playlist Name Input -->
|
||||
<TextBox x:Name="PlaylistNameBox"
|
||||
Grid.Row="0"
|
||||
Height="30"
|
||||
Margin="0,0,0,10"
|
||||
FontSize="16"
|
||||
Text="playlist name here"
|
||||
Visibility="Collapsed"/>
|
||||
|
||||
<!-- Category Buttons -->
|
||||
<StackPanel Name="btn" Visibility="Visible" Grid.Row="1" Orientation="Vertical" HorizontalAlignment="Center" Margin="0,0,0,10">
|
||||
<Button Content="Muvie" Click="Muvie_Click" Margin="5"/>
|
||||
<Button Content="Serie" Click="Serie_Click" Margin="5"/>
|
||||
<Button Content="Photo" Click="Photo_Click" Margin="5"/>
|
||||
<Button Content="Music" Click="Music_Click" Margin="5"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- DataGrid for SubList -->
|
||||
<DataGrid x:Name="ItemDataGrid" Grid.Row="2" AutoGenerateColumns="False" Visibility="Collapsed" Height="300" MaxWidth="600" >
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn IsReadOnly="True" Header="Name" Binding="{Binding Name}" Width="*"/>
|
||||
<DataGridTextColumn IsReadOnly="True" Header="Type" Binding="{Binding Type}" Width="*" MaxWidth="50"/>
|
||||
<DataGridCheckBoxColumn IsReadOnly="False" Header="Add" Binding="{Binding IsAdded, Mode=TwoWay}" Width="60" />
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<Grid Grid.Row="3">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
</ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<!-- Return Button -->
|
||||
<Button Content="Return" Grid.Column="0" Width="100" HorizontalAlignment="Right" Margin="0,10,0,0"
|
||||
Click="Return_Click"/>
|
||||
<Button Content="Add" Grid.Column="1" Width="100" HorizontalAlignment="Left" Margin="0,10,0,0"
|
||||
Click="Add_Click" Visibility="Collapsed" Name="add_btn"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
89
ShadowStream/Views/PlaylistEditor.xaml.cs
Normal file
89
ShadowStream/Views/PlaylistEditor.xaml.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using FFmpeg.AutoGen;
|
||||
using ModuleManager;
|
||||
using ShadowStream.Obejeckte;
|
||||
|
||||
namespace ShadowStream.Views
|
||||
{
|
||||
public partial class PlaylistEditor : Window
|
||||
{
|
||||
private ObservableCollection<Catagory> _sharedList;
|
||||
//pointer
|
||||
//private unsafe Catagory* _sharedListLock;
|
||||
|
||||
Catagory _selectedCatagory;
|
||||
|
||||
public PlaylistEditor(ObservableCollection<Catagory> sharedList)
|
||||
{
|
||||
InitializeComponent();
|
||||
_sharedList = sharedList;
|
||||
}
|
||||
|
||||
private void ShowSublist(string categoryName)
|
||||
{
|
||||
var selected = _sharedList.FirstOrDefault(c => c.name == categoryName);
|
||||
_selectedCatagory = selected;
|
||||
if (selected != null)
|
||||
{
|
||||
PlaylistNameBox.Visibility = Visibility.Visible;
|
||||
btn.Visibility = Visibility.Collapsed;
|
||||
ItemDataGrid.Visibility = Visibility.Visible;
|
||||
add_btn.Visibility = Visibility.Visible;
|
||||
ItemDataGrid.ItemsSource = selected.getAllItems();
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemDataGrid.ItemsSource = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void Muvie_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowSublist("Muvie");
|
||||
}
|
||||
|
||||
private void Serie_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowSublist("Serie");
|
||||
}
|
||||
|
||||
private void Photo_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowSublist("Photo");
|
||||
}
|
||||
|
||||
private void Music_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowSublist("Music");
|
||||
}
|
||||
|
||||
private void Return_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (this.Owner is MainWindow mainWin)
|
||||
{
|
||||
mainWin.RecivePlaylist();
|
||||
}
|
||||
}
|
||||
|
||||
private void Add_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ObjListBP tmp = new ObjListBP(PlaylistNameBox.Text);
|
||||
foreach (var VARIABLE in _selectedCatagory.getAllItems())
|
||||
{
|
||||
if (VARIABLE.IsAdded)
|
||||
{
|
||||
tmp.SharedRefs.Add(VARIABLE);
|
||||
Console.WriteLine(VARIABLE.Name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (this.Owner is MainWindow mainWin)
|
||||
{
|
||||
mainWin.RecivePlaylist(tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user