-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
162 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Remotely.Shared.Models; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.IO.Pipes; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Remotely.Desktop.Core.Interfaces | ||
{ | ||
public interface IChatUiService | ||
{ | ||
event EventHandler ChatWindowClosed; | ||
|
||
void ShowChatWindow(string organizationName, StreamWriter writer); | ||
void ReceiveChat(ChatMessage chatMessage); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using Avalonia.Controls; | ||
using Avalonia.Threading; | ||
using Remotely.Desktop.Core.Interfaces; | ||
using Remotely.Desktop.Linux.Controls; | ||
using Remotely.Desktop.Linux.ViewModels; | ||
using Remotely.Desktop.Linux.Views; | ||
using Remotely.Shared.Models; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.IO; | ||
using System.IO.Pipes; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Remotely.Desktop.Linux.Services | ||
{ | ||
public class ChatUiServiceLinux : IChatUiService | ||
{ | ||
private ChatWindowViewModel ChatViewModel { get; set; } | ||
|
||
public event EventHandler ChatWindowClosed; | ||
|
||
public void ReceiveChat(ChatMessage chatMessage) | ||
{ | ||
Dispatcher.UIThread.InvokeAsync(async () => | ||
{ | ||
if (chatMessage.Disconnected) | ||
{ | ||
await MessageBox.Show("The partner has disconnected.", "Partner Disconnected", MessageBoxType.OK); | ||
Environment.Exit(0); | ||
return; | ||
} | ||
|
||
if (ChatViewModel != null) | ||
{ | ||
ChatViewModel.SenderName = chatMessage.SenderName; | ||
ChatViewModel.ChatMessages.Add(chatMessage); | ||
} | ||
}); | ||
} | ||
|
||
public void ShowChatWindow(string organizationName, StreamWriter writer) | ||
{ | ||
Dispatcher.UIThread.Post(() => | ||
{ | ||
var chatWindow = new ChatWindow(); | ||
chatWindow.Closing += ChatWindow_Closing; ; | ||
ChatViewModel = chatWindow.DataContext as ChatWindowViewModel; | ||
ChatViewModel.PipeStreamWriter = writer; | ||
ChatViewModel.OrganizationName = organizationName; | ||
App.Current.Run(chatWindow); | ||
}); | ||
} | ||
|
||
private void ChatWindow_Closing(object sender, CancelEventArgs e) | ||
{ | ||
ChatWindowClosed?.Invoke(this, null); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using Remotely.Desktop.Core.Interfaces; | ||
using Remotely.Desktop.Win.ViewModels; | ||
using Remotely.Desktop.Win.Views; | ||
using Remotely.Shared.Models; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
|
||
namespace Remotely.Desktop.Win.Services | ||
{ | ||
public class ChatUiServiceWin : IChatUiService | ||
{ | ||
private ChatWindowViewModel ChatViewModel { get; set; } | ||
|
||
public event EventHandler ChatWindowClosed; | ||
|
||
public void ReceiveChat(ChatMessage chatMessage) | ||
{ | ||
App.Current.Dispatcher.Invoke(() => | ||
{ | ||
if (chatMessage.Disconnected) | ||
{ | ||
MessageBox.Show("Your partner has disconnected.", "Partner Disconnected", MessageBoxButton.OK, MessageBoxImage.Information); | ||
App.Current.Shutdown(); | ||
return; | ||
} | ||
|
||
if (ChatViewModel != null) | ||
{ | ||
ChatViewModel.SenderName = chatMessage.SenderName; | ||
ChatViewModel.ChatMessages.Add(chatMessage); | ||
} | ||
}); | ||
} | ||
|
||
public void ShowChatWindow(string organizationName, StreamWriter writer) | ||
{ | ||
App.Current.Dispatcher.Invoke(() => | ||
{ | ||
var chatWindow = new ChatWindow(); | ||
chatWindow.Closing += ChatWindow_Closing; | ||
ChatViewModel = chatWindow.DataContext as ChatWindowViewModel; | ||
ChatViewModel.PipeStreamWriter = writer; | ||
ChatViewModel.OrganizationName = organizationName; | ||
chatWindow.Show(); | ||
}); | ||
} | ||
|
||
private void ChatWindow_Closing(object sender, CancelEventArgs e) | ||
{ | ||
ChatWindowClosed?.Invoke(this, null); | ||
} | ||
} | ||
} |