Skip to content

Commit 220501a

Browse files
committed
Implemented controls for viewing other users and their files
1 parent 1090105 commit 220501a

25 files changed

+54
-17
lines changed
3.5 KB
Binary file not shown.

SyncPlayWPF/SyncPlayWPF/Common/Methods.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,24 @@ public static Rect GetAbsolutePlacement(FrameworkElement container, FrameworkEle
105105
absolutePos = new System.Windows.Point(absolutePos.X - posMW.X, absolutePos.Y - posMW.Y);
106106
return new Rect(absolutePos.X, absolutePos.Y, element.ActualWidth, element.ActualHeight);
107107
}
108+
109+
public static string ConvertByteSize(int bytecount) {
110+
if (bytecount > 1073741824) { // Bigger than a giga byte
111+
112+
113+
114+
return (bytecount / (1024 * 1024 * 1024)).ToString() + " GB";
115+
}
116+
117+
if (bytecount > 1048576) { // Bigger than a megabyte
118+
return (bytecount / (1024 * 1024)).ToString() + " MB";
119+
}
120+
121+
return (bytecount / 1024).ToString() + " KB";
122+
123+
124+
125+
}
126+
108127
}
109128
}

SyncPlayWPF/SyncPlayWPF/Common/Settings.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ public class Settings {
6161
)
6262
);
6363

64+
public static void DefineSharedSettings() {
65+
Common.Shared.CurrentConfig = XDocument.Parse(System.IO.File.ReadAllText("SyncPlayConfig.xml"));
66+
}
67+
6468
public static void RestoreDefaultConfiguration() {
6569
if (System.IO.File.Exists("SyncPlayConfig.xml")) {
6670
XDocument doc = XDocument.Parse(System.IO.File.ReadAllText("SyncPlayConfig.xml"));
@@ -134,8 +138,6 @@ public static void WriteConfigurationToView(Pages.SettingsPage Page) {
134138
Page.EnableTLS.IsChecked = GetBooleanValue(doc, "Security", "EnableTLS");
135139
Page.HashFileNamesBeforeSending.IsChecked = GetBooleanValue(doc, "Security", "HashFileNamesBeforeSending");
136140
Page.HashPasswords.IsChecked = GetBooleanValue(doc, "Security", "HashPasswords");
137-
138-
139141
}
140142

141143
public static void ReadConfigurationFromView(Pages.SettingsPage Page) {

SyncPlayWPF/SyncPlayWPF/Common/Shared.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Windows;
88
using System.Windows.Controls;
99
using System.Windows.Threading;
10+
using System.Xml.Linq;
1011
using WpfPageTransitions;
1112

1213
namespace SyncPlayWPF.Common {
@@ -22,6 +23,7 @@ public class Shared {
2223
public static Window MasterWindow;
2324

2425
public static Common.LogFileDump MasterLogDump;
26+
public static XDocument CurrentConfig;
2527

2628
public static void ThrowException(Exception e) {
2729
MasterOverrideTransition.IsHitTestVisible = true;

SyncPlayWPF/SyncPlayWPF/MainWindow.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public MainWindow() {
2929
RootPageTransition.ShowPage(new Pages.NewSessionPage());
3030

3131
//Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;
32-
//Loaded += MainWindow_Loaded;
32+
Loaded += MainWindow_Loaded;
3333

3434
InitHeader();
3535
}

SyncPlayWPF/SyncPlayWPF/Pages/SessionPages/ChatSession.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
x:Name="UserListBorder"
7373
Background="{StaticResource DarkMode_AccentColorD}">
7474
<!--<ScrollViewer Style="{StaticResource FavsScrollViewer}">-->
75-
<StackPanel Margin="0,5,0,0" x:Name="UserStack" MaxHeight="0">
75+
<StackPanel Margin="0,5,0,0" x:Name="UserStack" MaxHeight="1000">
7676
<!--<custom:UserSessionView
7777
Username="Jimbo"
7878
FileDuration="1:45:02"

SyncPlayWPF/SyncPlayWPF/Pages/SessionPages/ChatSession.xaml.cs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ private void LoadUserName() {
7575
foreach (var u in Common.Shared.Wrapper.SyncPlayClient.UserDictionary.Values) {
7676
var newControl = new CustomControls.UserSessionView();
7777
newControl.Username = u.Username;
78-
newControl.FileDuration = "NA";
79-
newControl.FileName = "NA";
80-
newControl.FileSize = "NA";
78+
newControl.FileDuration = "";
79+
newControl.FileName = "";
80+
newControl.FileSize = "";
8181
UserStack.Children.Add(newControl);
8282
}
8383
}
@@ -87,9 +87,9 @@ private void SyncPlayClient_OnUserRoomEvent(SyncPlayClient sender, SyncPlay.SPEv
8787
Dispatcher.Invoke(() => {
8888
var newControl = new CustomControls.UserSessionView();
8989
newControl.Username = e.User.Username;
90-
newControl.FileDuration = "NA";
91-
newControl.FileName = "NA";
92-
newControl.FileSize = "NA";
90+
newControl.FileDuration = "";
91+
newControl.FileName = "";
92+
newControl.FileSize = "";
9393

9494
UserStack.Children.Add(newControl);
9595
});
@@ -105,7 +105,21 @@ private void SyncPlayClient_OnUserRoomEvent(SyncPlayClient sender, SyncPlay.SPEv
105105
}
106106
}
107107

108-
private void SyncPlayClient_OnFileSet(SyncPlay.SyncPlayClient sender, SyncPlay.SPEventArgs.RemoteSetFileEventArgs e) { }
108+
private void SyncPlayClient_OnFileSet(SyncPlay.SyncPlayClient sender, SyncPlay.SPEventArgs.RemoteSetFileEventArgs e) {
109+
110+
Dispatcher.Invoke(() => {
111+
Console.WriteLine("File loaded event");
112+
foreach (CustomControls.UserSessionView uc in UserStack.Children) {
113+
if (uc.Username == e.Agent.Username) {
114+
uc.FileDuration = SyncPlay.Misc.Common.ConvertSecondsToTimeStamp((int)e.File.Duration);
115+
uc.FileName = System.IO.Path.GetFileName(e.File.FilePath);
116+
uc.FileSize = Common.Methods.ConvertByteSize(e.File.Size);
117+
return;
118+
}
119+
}
120+
Console.WriteLine("Warning : Unknown user has loaded a file!");
121+
});
122+
}
109123

110124
private void NewChatEvent(SyncPlay.SyncPlayClient sender, SyncPlay.SPEventArgs.ChatInfoMessageArgs e) {
111125
Dispatcher.Invoke(() => {

SyncPlayWPF/SyncPlayWPF/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("2021.248.44.0")]
55-
[assembly: AssemblyFileVersion("2021.248.44.0")]
54+
[assembly: AssemblyVersion("2021.249.8.0")]
55+
[assembly: AssemblyFileVersion("2021.249.8.0")]

SyncPlayWPF/SyncPlayWPF/Themes/Generic.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,8 +1615,8 @@
16151615
Grid.Column="2"
16161616
Margin="0,0,0,0">
16171617
<!--<custom:StatusImage Image="{StaticResource HourGlass}"/>-->
1618-
<custom:StatusImage Image="{StaticResource Warning}"
1619-
ImageBackgroundBrush="{StaticResource WarningBrush}"/>
1618+
<!--<custom:StatusImage Image="{StaticResource Warning}"
1619+
ImageBackgroundBrush="{StaticResource WarningBrush}"/>-->
16201620
</StackPanel>
16211621

16221622
</Grid>
1 KB
Binary file not shown.

0 commit comments

Comments
 (0)