initial commit
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace Crysome.Server.View;
|
||||
|
||||
public class WhatsAppSessionWindow : Window, IComponentConnector
|
||||
{
|
||||
private readonly string _zipPath;
|
||||
|
||||
internal TextBlock SubtitleText;
|
||||
|
||||
internal TextBlock ClientLabel;
|
||||
|
||||
internal TextBlock SizeLabel;
|
||||
|
||||
internal TextBlock PathLabel;
|
||||
|
||||
internal Button OpenFolderBtn;
|
||||
|
||||
private bool _contentLoaded;
|
||||
|
||||
public WhatsAppSessionWindow(string zipPath, string clientName, long sizeBytes)
|
||||
{
|
||||
InitializeComponent();
|
||||
_zipPath = zipPath;
|
||||
SubtitleText.Text = "From " + clientName;
|
||||
ClientLabel.Text = clientName;
|
||||
SizeLabel.Text = $"{(double)sizeBytes / 1024.0 / 1024.0:F2} MB ({sizeBytes:N0} bytes)";
|
||||
PathLabel.Text = zipPath;
|
||||
PathLabel.ToolTip = zipPath;
|
||||
}
|
||||
|
||||
private void OpenFolderBtn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
string directoryName = Path.GetDirectoryName(_zipPath);
|
||||
if (Directory.Exists(directoryName))
|
||||
{
|
||||
Process.Start("explorer.exe", directoryName);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Cannot open folder: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void CloseBtn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
[DebuggerNonUserCode]
|
||||
[GeneratedCode("PresentationBuildTasks", "9.0.14.0")]
|
||||
public void InitializeComponent()
|
||||
{
|
||||
if (!_contentLoaded)
|
||||
{
|
||||
_contentLoaded = true;
|
||||
Uri resourceLocator = new Uri("/Crysome.Server;component/view/whatsappsessionwindow.xaml", UriKind.Relative);
|
||||
Application.LoadComponent(this, resourceLocator);
|
||||
}
|
||||
}
|
||||
|
||||
[DebuggerNonUserCode]
|
||||
[GeneratedCode("PresentationBuildTasks", "9.0.14.0")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
void IComponentConnector.Connect(int connectionId, object target)
|
||||
{
|
||||
switch (connectionId)
|
||||
{
|
||||
case 1:
|
||||
SubtitleText = (TextBlock)target;
|
||||
break;
|
||||
case 2:
|
||||
ClientLabel = (TextBlock)target;
|
||||
break;
|
||||
case 3:
|
||||
SizeLabel = (TextBlock)target;
|
||||
break;
|
||||
case 4:
|
||||
PathLabel = (TextBlock)target;
|
||||
break;
|
||||
case 5:
|
||||
OpenFolderBtn = (Button)target;
|
||||
OpenFolderBtn.Click += OpenFolderBtn_Click;
|
||||
break;
|
||||
case 6:
|
||||
((Button)target).Click += CloseBtn_Click;
|
||||
break;
|
||||
default:
|
||||
_contentLoaded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user