Skip to content

Commit 267ec6e

Browse files
committed
Quality Fixes + Bug fixes Batch A
UI : Chat messages followed by Chat Status messages doesn't add buffers SyncPlay : Handle thread upon exit + exception SyncPlay : Share VLC file name with wrapper
1 parent a16297f commit 267ec6e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+354
-43
lines changed
-72.5 KB
Binary file not shown.
149 KB
Binary file not shown.
249 Bytes
Loading
66.8 KB
Loading

SyncPlayWPF/SyncPlayWPF/MainWindow.xaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
</Grid.RowDefinitions>
4646

4747
<!-- Title bar -->
48-
<Grid Grid.Row="0" UIElement.MouseDown="WindowDrag" Background="{StaticResource DarkMode_AccentColorA}">
48+
<Grid Grid.Row="0" x:Name="TitleBar" UIElement.MouseDown="WindowDrag" Background="{StaticResource DarkMode_AccentColorA}">
4949
<Grid.ColumnDefinitions>
5050
<ColumnDefinition Width="*"/>
5151
<ColumnDefinition Width="35"/>
@@ -61,16 +61,22 @@
6161
FontWeight="DemiBold">SyncPlay.NET</Label>
6262
<custom:ImageButton
6363
Grid.Column="1"
64+
x:Name="WindowMinimiseButton"
65+
Click="WindowMinimiseButton_Click"
6466
Image="{StaticResource MinimizeButton}"
6567
Style="{StaticResource TitleBarButtons}"/>
6668
<custom:ImageButton
6769
Grid.Column="2"
70+
x:Name="WindowRestoreButton"
71+
Click="WindowRestoreButton_Click"
6872
Image="{StaticResource RestoreWindowButton}"
6973
Style="{StaticResource TitleBarButtons}"/>
7074
<custom:ImageButton
7175
Grid.Column="3"
76+
Click="WindowCloseButton_Click"
7277
ImageBackgroundClickBrush="#FFABAB"
7378
BackgroundClickBrush="#FC4B4B"
79+
x:Name="WindowCloseButton"
7480
Image="{StaticResource CloseWindowButton}"
7581
Style="{StaticResource TitleBarButtons}"/>
7682
</Grid>

SyncPlayWPF/SyncPlayWPF/MainWindow.xaml.cs

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public MainWindow() {
2828
RootPageTransition.ShowPage(new Pages.NewSessionPage());
2929

3030
Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;
31+
32+
InitHeader();
3133
}
3234

3335
private void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) {
@@ -38,8 +40,93 @@ private void Current_DispatcherUnhandledException(object sender, System.Windows.
3840

3941
private void WindowDrag(object sender, MouseButtonEventArgs e) {
4042
if (System.Windows.Input.Mouse.LeftButton == MouseButtonState.Pressed) {
43+
44+
//if (WindowState == WindowState.Maximized) {
45+
// var point = PointToScreen(e.MouseDevice.GetPosition(this));
46+
47+
// if (point.X <= RestoreBounds.Width / 2)
48+
// Left = 0;
49+
50+
// else if (point.X >= RestoreBounds.Width)
51+
// Left = point.X - (RestoreBounds.Width - (this.ActualWidth - point.X));
52+
53+
// else
54+
// Left = point.X - (RestoreBounds.Width / 2);
55+
56+
// Top = point.Y - (((FrameworkElement)sender).ActualHeight / 2);
57+
// WindowState = WindowState.Normal;
58+
//}
59+
4160
App.Current.MainWindow.DragMove();
4261
}
4362
}
63+
64+
private void WindowMinimiseButton_Click(object sender, RoutedEventArgs e) {
65+
this.WindowState = WindowState.Minimized;
66+
}
67+
68+
private void WindowRestoreButton_Click(object sender, RoutedEventArgs e) {
69+
if (this.WindowState == WindowState.Maximized)
70+
this.WindowState = WindowState.Normal;
71+
else
72+
this.WindowState = WindowState.Maximized;
73+
}
74+
75+
private void WindowCloseButton_Click(object sender, RoutedEventArgs e) {
76+
System.Windows.Application.Current.Shutdown();
77+
}
78+
79+
80+
private void InitHeader() {
81+
var border = TitleBar;
82+
var restoreIfMove = false;
83+
84+
border.MouseLeftButtonDown += (s, e) => {
85+
if (e.ClickCount == 2) {
86+
if ((ResizeMode == ResizeMode.CanResize) ||
87+
(ResizeMode == ResizeMode.CanResizeWithGrip)) {
88+
SwitchState();
89+
}
90+
} else {
91+
if (WindowState == WindowState.Maximized) {
92+
restoreIfMove = true;
93+
}
94+
DragMove();
95+
}
96+
};
97+
border.MouseLeftButtonUp += (s, e) => { restoreIfMove = false; };
98+
border.MouseMove += (s, e) => {
99+
if (restoreIfMove) {
100+
restoreIfMove = false;
101+
var mouseX = e.GetPosition(this).X;
102+
var width = RestoreBounds.Width;
103+
var x = mouseX - width / 2;
104+
105+
if (x < 0) {
106+
x = 0;
107+
} else if (x + width > System.Windows.SystemParameters.PrimaryScreenWidth) {
108+
x = System.Windows.SystemParameters.PrimaryScreenWidth - width;
109+
}
110+
111+
WindowState = WindowState.Normal;
112+
Left = x;
113+
Top = 0;
114+
DragMove();
115+
}
116+
};
117+
}
118+
119+
private void SwitchState() {
120+
switch (WindowState) {
121+
case WindowState.Normal: {
122+
WindowState = WindowState.Maximized;
123+
break;
124+
}
125+
case WindowState.Maximized: {
126+
WindowState = WindowState.Normal;
127+
break;
128+
}
129+
}
130+
}
44131
}
45132
}

SyncPlayWPF/SyncPlayWPF/Pages/SessionLandingPage.xaml.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Text;
5+
using System.Threading;
56
using System.Threading.Tasks;
67
using System.Windows;
78
using System.Windows.Controls;
@@ -23,6 +24,22 @@ public SessionLandingPage() {
2324

2425
Common.Shared.ChatPageSingleton = new Pages.SessionPages.ChatSession();
2526
ShowChatWindow();
27+
this.Loaded += PageLoaded;
28+
}
29+
30+
private void PageLoaded(object sender, RoutedEventArgs e) {
31+
32+
Common.Shared.Wrapper.Player.OnPlayerClosed += delegate {
33+
ThreadStart ts = delegate () {
34+
Dispatcher.BeginInvoke((Action)delegate () {
35+
Application.Current.Shutdown();
36+
});
37+
};
38+
Thread t = new Thread(ts);
39+
t.Start();
40+
};
41+
42+
2643
}
2744

2845
private void ShowChatWindow() {

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
using System.Windows.Shapes;
1515

1616
namespace SyncPlayWPF.Pages.SessionPages {
17-
/// <summary>
18-
/// Interaction logic for ChatSession.xaml
19-
/// </summary>
17+
2018
public partial class ChatSession : UserControl {
2119
public ChatSession() {
2220
InitializeComponent();
@@ -36,13 +34,14 @@ private void NewChatEvent(SyncPlay.SyncPlayClient sender, SyncPlay.EventArgs.Cha
3634
if (!LastAdditionWasChatInfo) {
3735
var spacer = new Border();
3836
spacer.Style = (Style)this.FindResource("ChatInfoSpacer");
39-
LastAdditionWasChatInfo = true;
4037
MessageStack.Children.Add(spacer);
4138
}
4239
var msgblock = new TextBlock();
4340
msgblock.Text = e.Message;
4441
msgblock.Style = (Style)this.FindResource("ChatInfo");
4542
MessageStack.Children.Add(msgblock);
43+
LastAdditionWasChatInfo = true;
44+
this.LastSender = null;
4645
});
4746
}
4847

@@ -51,6 +50,7 @@ private void NewChatMessage(SyncPlay.SyncPlayClient sender, SyncPlay.EventArgs.C
5150
if (LastAdditionWasChatInfo) {
5251
var spacer = new Border();
5352
spacer.Style = (Style)this.FindResource("ChatInfoSpacer");
53+
MessageStack.Children.Add(spacer);
5454
LastAdditionWasChatInfo = false;
5555
}
5656
var msgballoon = new CustomControls.ChatMessage();
@@ -59,12 +59,9 @@ private void NewChatMessage(SyncPlay.SyncPlayClient sender, SyncPlay.EventArgs.C
5959
msgballoon.MessageContent = e.Message;
6060
msgballoon.IsInitialMessage = LastSender == null || LastSender != e.Sender;
6161
msgballoon.MessageTime = DateTime.Now.ToString("hh:mm tt");
62-
6362
LastSender = e.Sender;
64-
6563
var text = new TextBlock();
6664
text.Text = e.Message;
67-
6865
MessageStack.Children.Add(msgballoon);
6966
});
7067
}
@@ -76,8 +73,6 @@ private void SendMessageButtonClick(object sender, RoutedEventArgs e) {
7673
private void SendMessage() {
7774
if (!String.IsNullOrWhiteSpace(MessageBlockField.Text)) {
7875
Common.Shared.Wrapper.SyncPlayClient.SendChatMessage(MessageBlockField.Text);
79-
} else {
80-
Console.WriteLine("Ignored Blank Message");
8176
}
8277
MessageBlockField.Text = "";
8378
}

SyncPlayWPF/SyncPlayWPF/Properties/AssemblyInfo.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
// General Information about an assembly is controlled through the following
88
// set of attributes. Change these attribute values to modify the information
99
// associated with an assembly.
10-
[assembly: AssemblyTitle("SyncPlayWPF")]
10+
[assembly: AssemblyTitle("SyncPlay.NET")]
1111
[assembly: AssemblyDescription("")]
1212
[assembly: AssemblyConfiguration("")]
1313
[assembly: AssemblyCompany("")]
1414
[assembly: AssemblyProduct("SyncPlayWPF")]
15-
[assembly: AssemblyCopyright("Copyright © 2021")]
15+
[assembly: AssemblyCopyright("Arkangel © 2021")]
1616
[assembly: AssemblyTrademark("")]
1717
[assembly: AssemblyCulture("")]
1818

@@ -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.202.19.0")]
55-
[assembly: AssemblyFileVersion("2021.202.19.0")]
54+
[assembly: AssemblyVersion("2021.203.9.0")]
55+
[assembly: AssemblyFileVersion("2021.203.9.0")]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace SyncPlay.EventArgs {
8+
public class NewFileLoadEventArgs {
9+
public string FileName;
10+
public string AbsoluteFilePath;
11+
12+
public NewFileLoadEventArgs(string fname, string afilepath) {
13+
this.FileName = fname;
14+
this.AbsoluteFilePath = afilepath;
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)