applying new struckture and working vlc
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace ShadowStream.Obejeckte;
|
||||
//Quinn
|
||||
@@ -27,4 +28,14 @@ public class Catagory
|
||||
{
|
||||
return items;
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
items.Clear();
|
||||
}
|
||||
|
||||
public void addItems(List<Item> items)
|
||||
{
|
||||
this.items.AddRange(items);
|
||||
}
|
||||
}
|
@@ -1,5 +1,8 @@
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace ShadowStream.Obejeckte;
|
||||
//Quinn
|
||||
@@ -14,28 +17,32 @@ public class Item
|
||||
bool isFoto;
|
||||
|
||||
//initilise the item
|
||||
public Item(string path, string type,BitmapImage image,bool isFoto)
|
||||
public Item(string path, string type, BitmapImage image, bool isFoto, RoutedEventHandler clickHandler = null)
|
||||
{
|
||||
this.path = path;
|
||||
this.type = type;
|
||||
this.name = new Label(){Name="name",Content = name};
|
||||
this.name = new Label()
|
||||
{
|
||||
Name = "name",
|
||||
Content = System.IO.Path.GetFileName(path),
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
Foreground = Brushes.White
|
||||
};
|
||||
this.image = image;
|
||||
this.playButton = new Button();
|
||||
playButton.Content = "Play";
|
||||
this.playButton = new Button
|
||||
{
|
||||
Content = isFoto ? "Show" : "Play",
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
Tag = path // Store path or any identifier
|
||||
};
|
||||
|
||||
if (clickHandler != null)
|
||||
playButton.Click += clickHandler;
|
||||
|
||||
this.isFoto = isFoto;
|
||||
}
|
||||
//return the entire item so it can be displaid direckly
|
||||
public (Label ,string,Button,BitmapImage,DockPanel) CreateLable(int[] gridPosition, Grid grid)
|
||||
{
|
||||
DockPanel dockPanel = new DockPanel();
|
||||
DockPanel.SetDock(name, Dock.Top);
|
||||
dockPanel.Children.Add(name);
|
||||
dockPanel.Children.Add(playButton);
|
||||
if (isFoto){
|
||||
playButton.Content = "Show";
|
||||
}
|
||||
return (name,path,playButton,image,dockPanel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//return individual data
|
||||
public string getLink()
|
||||
|
42
ShadowStream/Modules/ObjecktForJason/BitmapConversions.cs
Normal file
42
ShadowStream/Modules/ObjecktForJason/BitmapConversions.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace ShadowStream.Modules;
|
||||
|
||||
public class BitmapConversions
|
||||
{
|
||||
public static BitmapImage BitmapToBitmapImage(System.Drawing.Bitmap bitmap)
|
||||
{
|
||||
using (var memory = new System.IO.MemoryStream())
|
||||
{
|
||||
bitmap.Save(memory, System.Drawing.Imaging.ImageFormat.Png);
|
||||
memory.Position = 0;
|
||||
|
||||
var bitmapImage = new BitmapImage();
|
||||
bitmapImage.BeginInit();
|
||||
bitmapImage.StreamSource = memory;
|
||||
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
|
||||
bitmapImage.EndInit();
|
||||
bitmapImage.Freeze(); // Optional: for thread safety
|
||||
|
||||
return bitmapImage;
|
||||
}
|
||||
}
|
||||
public static Bitmap BitmapImageToBitmap(BitmapImage bitmapImage)
|
||||
{
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
// Encode BitmapImage to stream (e.g., PNG)
|
||||
BitmapEncoder encoder = new PngBitmapEncoder();
|
||||
encoder.Frames.Add(BitmapFrame.Create(bitmapImage));
|
||||
encoder.Save(ms);
|
||||
|
||||
ms.Seek(0, SeekOrigin.Begin); // Reset stream position
|
||||
|
||||
// Create Bitmap from stream
|
||||
return new Bitmap(ms);
|
||||
}
|
||||
}
|
||||
}
|
@@ -37,14 +37,14 @@ public class Jason_Writer
|
||||
|
||||
|
||||
// Load one list of locJason objects from JSON file with given name
|
||||
public List<locJason> LoadList(string listName)
|
||||
public async Task<List<locJason>> LoadListAsync(string listName)
|
||||
{
|
||||
string filePath = Path.Combine(_folderPath, $"{listName}.json");
|
||||
|
||||
if (!File.Exists(filePath))
|
||||
return new List<locJason>(); // Return empty list if file doesn't exist
|
||||
return new List<locJason>();
|
||||
|
||||
string jsonString = File.ReadAllText(filePath);
|
||||
string jsonString = await File.ReadAllTextAsync(filePath);
|
||||
return JsonConvert.DeserializeObject<List<locJason>>(jsonString) ?? new List<locJason>();
|
||||
}
|
||||
|
||||
|
@@ -4,6 +4,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media.Imaging;
|
||||
using LibVLCSharp.Shared;
|
||||
using ModuleManager;
|
||||
|
||||
public static class VideoFrameExtractor
|
||||
{
|
||||
@@ -71,10 +72,19 @@ public static class VideoFrameExtractor
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Error loading snapshot image from {path}: {ex}");
|
||||
foreach (System.Windows.Window window in System.Windows.Application.Current.Windows)
|
||||
{
|
||||
if (window.IsActive && window is MainWindow mainWindow)
|
||||
{
|
||||
mainWindow.ReciveErrorLog($"Error loading snapshot image from {path}: {ex}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception("Failed to load snapshot image.", ex);
|
||||
}
|
||||
|
||||
|
||||
// Async delayed delete of temp snapshot file (after 1 minute)
|
||||
DeleteFileLaterAsync(path);
|
||||
|
||||
|
Reference in New Issue
Block a user