before restrucktur
This commit is contained in:
26
ShadowStream/Modules/JasonToString.cs
Normal file
26
ShadowStream/Modules/JasonToString.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
|
||||
namespace ShadowStream.Modules;
|
||||
|
||||
|
||||
public class JasonToString
|
||||
{
|
||||
public Bitmap Base64StringToBitmap(string base64String)
|
||||
{
|
||||
byte[] imageBytes = Convert.FromBase64String(base64String);
|
||||
using (MemoryStream ms = new MemoryStream(imageBytes))
|
||||
{
|
||||
return new Bitmap(ms);
|
||||
}
|
||||
}
|
||||
public string BitmapToBase64String(Bitmap bitmap)
|
||||
{
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png); // Save as PNG to MemoryStream
|
||||
byte[] imageBytes = ms.ToArray();
|
||||
return Convert.ToBase64String(imageBytes);
|
||||
}
|
||||
}
|
||||
}
|
23
ShadowStream/Modules/Obejeckte/Catagory.cs
Normal file
23
ShadowStream/Modules/Obejeckte/Catagory.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
namespace ShadowStream.Obejeckte;
|
||||
//Quinn
|
||||
public class Catagory
|
||||
{
|
||||
//basic code for catatgorys next
|
||||
public readonly string name;
|
||||
List<Item> items = new List<Item>();
|
||||
|
||||
public Catagory(string name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void addItem(Item item)
|
||||
{
|
||||
items.Add(item);
|
||||
}
|
||||
|
||||
public void removeAllItems()
|
||||
{
|
||||
items.Clear();
|
||||
}
|
||||
}
|
66
ShadowStream/Modules/Obejeckte/Item.cs
Normal file
66
ShadowStream/Modules/Obejeckte/Item.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace ShadowStream.Obejeckte;
|
||||
//Quinn
|
||||
public class Item
|
||||
{
|
||||
//public data
|
||||
Label name;
|
||||
string path;
|
||||
string type;
|
||||
BitmapImage image;
|
||||
Button playButton;
|
||||
bool isFoto;
|
||||
|
||||
//initilise the item
|
||||
public Item(string path, string type,BitmapImage image,bool isFoto)
|
||||
{
|
||||
this.path = path;
|
||||
this.type = type;
|
||||
this.name = new Label(){Name="name",Content = name};
|
||||
this.image = image;
|
||||
this.playButton = new Button();
|
||||
playButton.Content = "Play";
|
||||
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()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
public string getFormat()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
public string getName()
|
||||
{
|
||||
return name.Content.ToString();
|
||||
}
|
||||
|
||||
public BitmapImage getImage()
|
||||
{
|
||||
return image;
|
||||
}
|
||||
|
||||
public string getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
10
ShadowStream/Modules/ObjecktForJason/DBJason.cs
Normal file
10
ShadowStream/Modules/ObjecktForJason/DBJason.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace ShadowStream.ObjecktForJason;
|
||||
|
||||
public class DBJason
|
||||
{
|
||||
public string name;
|
||||
public string path;
|
||||
public string type;
|
||||
public string format;
|
||||
public double duration;
|
||||
}
|
46
ShadowStream/Modules/ObjecktForJason/Jason Writer.cs
Normal file
46
ShadowStream/Modules/ObjecktForJason/Jason Writer.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ShadowStream.ObjecktForJason;
|
||||
|
||||
public class Jason_Writer
|
||||
{
|
||||
private readonly string _folderPath;
|
||||
|
||||
public Jason_Writer(string folderName = "Temp Data")
|
||||
{
|
||||
_folderPath = Path.Combine(Environment.CurrentDirectory, folderName);
|
||||
|
||||
if (!Directory.Exists(_folderPath))
|
||||
Directory.CreateDirectory(_folderPath);
|
||||
}
|
||||
|
||||
// Save one list of locJason objects to JSON file with given name
|
||||
public async Task SaveList(string listName, List<locJason> list)
|
||||
{
|
||||
string filePath = Path.Combine(_folderPath, $"{listName}.json");
|
||||
string jsonString = JsonConvert.SerializeObject(list, Formatting.Indented);
|
||||
File.WriteAllText(filePath, jsonString);
|
||||
}
|
||||
|
||||
// Load one list of locJason objects from JSON file with given name
|
||||
public List<locJason> LoadList(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
|
||||
|
||||
string jsonString = File.ReadAllText(filePath);
|
||||
return JsonConvert.DeserializeObject<List<locJason>>(jsonString) ?? new List<locJason>();
|
||||
}
|
||||
|
||||
// Check if list file exists
|
||||
public bool ListExists(string listName)
|
||||
{
|
||||
string filePath = Path.Combine(_folderPath, $"{listName}.json");
|
||||
return File.Exists(filePath);
|
||||
}
|
||||
}
|
8
ShadowStream/Modules/ObjecktForJason/locJason.cs
Normal file
8
ShadowStream/Modules/ObjecktForJason/locJason.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace ShadowStream.ObjecktForJason;
|
||||
|
||||
public class locJason
|
||||
{
|
||||
public string path;
|
||||
public string imageData;
|
||||
public string type;
|
||||
}
|
Reference in New Issue
Block a user