diff --git a/ServiceBus98.sln b/ServiceBus95.sln similarity index 90% rename from ServiceBus98.sln rename to ServiceBus95.sln index 5250d86..f30e415 100644 --- a/ServiceBus98.sln +++ b/ServiceBus95.sln @@ -1,9 +1,9 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 -VisualStudioVersion = 17.13.35825.156 d17.13 +VisualStudioVersion = 17.13.35825.156 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceBus98", "ServiceBus98\ServiceBus98.csproj", "{70EC8B33-8F08-4B6D-B386-2C2747AF61F0}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceBus95", "ServiceBus98\ServiceBus95.csproj", "{70EC8B33-8F08-4B6D-B386-2C2747AF61F0}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/ServiceBus98/App.xaml b/ServiceBus98/App.xaml index 7286576..d23badf 100644 --- a/ServiceBus98/App.xaml +++ b/ServiceBus98/App.xaml @@ -1,67 +1,775 @@ - - - + + + + + #008080 + #1084D0 + #000080 + #DFDFDF + #FFFFE3 + #C0C0C0 + #B5B5B5 + #808080 + + #1084D0 + #000080 + #B5B5B5 + #808080 + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - diff --git a/ServiceBus98/App.xaml.cs b/ServiceBus98/App.xaml.cs index 1630536..60e24d9 100644 --- a/ServiceBus98/App.xaml.cs +++ b/ServiceBus98/App.xaml.cs @@ -1,13 +1,63 @@ using System.Configuration; using System.Data; using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; -namespace ServiceBus98; +namespace ServiceBus95; /// /// Interaction logic for App.xaml /// public partial class App : Application { + private void TitlebarMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) + { + Window parent = Window.GetWindow((DockPanel)sender); + if (e.ChangedButton == System.Windows.Input.MouseButton.Left) + { + parent.DragMove(); + } + } + + private void CloseButtonClick(object sender, RoutedEventArgs e) + { + Window parent = Window.GetWindow((Button)sender); + parent.Close(); + } + + private void MinimizeButtonClick(object sender, RoutedEventArgs e) + { + Window parent = Window.GetWindow((Button)sender); + parent.WindowState = WindowState.Minimized; + } + + private void MaximizeButtonClick(object sender, RoutedEventArgs e) + { + Window parent = Window.GetWindow((Button)sender); + + + if (parent.WindowState == WindowState.Normal) + { + // TODO: This actually goes fullscreen. Manually setting width and height to fixed values just as an indication that it is working. + parent.WindowState = WindowState.Maximized; + parent.Width = 1280; + parent.Height = 720; + + } + + else + { + parent.WindowState = WindowState.Normal; + parent.Width = 800; + parent.Height = 600; + + } + } + + private void TabCloseButton_Click(object sender, RoutedEventArgs e) + { + MessageBox.Show("You close the tab"); + } } diff --git a/ServiceBus98/Controls/ServiceBusMessageControl.xaml b/ServiceBus98/Controls/ServiceBusMessageControl.xaml new file mode 100644 index 0000000..9f1ea41 --- /dev/null +++ b/ServiceBus98/Controls/ServiceBusMessageControl.xaml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + application/json + text/plain + text/xml + + + + + + + + + + + + + + diff --git a/ServiceBus98/Controls/ServiceBusMessageControl.xaml.cs b/ServiceBus98/Controls/ServiceBusMessageControl.xaml.cs new file mode 100644 index 0000000..3df16d9 --- /dev/null +++ b/ServiceBus98/Controls/ServiceBusMessageControl.xaml.cs @@ -0,0 +1,77 @@ +using System.Windows; +using System.Windows.Controls; +using Azure.Messaging.ServiceBus; + +namespace ServiceBus95.Controls +{ + /// + /// Interaction logic for ServiceBusMessage.xaml + /// + public partial class ServiceBusMessageControl : UserControl + { + public ServiceBusMessageControl() + { + InitializeComponent(); + } + + private async void Send_Click(object sender, RoutedEventArgs e) + { + if (string.IsNullOrEmpty(ConnectionString.Text)) + { + MessageBox.Show("Enter a connection string.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); + return; + } + + if (string.IsNullOrEmpty(QueueName.Text)) + { + MessageBox.Show("Enter a queue name.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); + return; + } + + if (string.IsNullOrEmpty(Message.Text)) + { + MessageBoxResult result = MessageBox.Show("You did not enter a message. Do you want to send an empty message?", "Empty Message", MessageBoxButton.YesNo, MessageBoxImage.Question); + if (result == MessageBoxResult.Cancel) + { + return; + } + } + + try + { + //StatusText.Text = "Status: Sending"; + + await using ServiceBusClient serviceBusClient = new ServiceBusClient(ConnectionString.Text); + await using ServiceBusSender serviceBusSender = serviceBusClient.CreateSender(QueueName.Text); + using ServiceBusMessageBatch messageBatch = await serviceBusSender.CreateMessageBatchAsync(); + + ServiceBusMessage serviceBusMessage = new ServiceBusMessage(Message.Text ?? string.Empty) + { + ContentType = ContentType.Text ?? "text/plain" + }; + + messageBatch.TryAddMessage(serviceBusMessage); + + await serviceBusSender.SendMessagesAsync(messageBatch); + + MessageBox.Show("Message sent successfully.", "Success", MessageBoxButton.OK, MessageBoxImage.Information); + } + + catch (Exception ex) + { + string errorMessage = ex.Message; + if (ex is ServiceBusException) + { + errorMessage = $"Service Bus returned an error. Ensure that the connection string is valid and the queue exists.\n\nAdditional Details:\n{errorMessage}"; + } + + MessageBox.Show(errorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Error); + } + + finally + { + //StatusText.Text = "Status: Idle"; + } + } + } +} diff --git a/ServiceBus98/Controls/XMLFile1.xml b/ServiceBus98/Controls/XMLFile1.xml new file mode 100644 index 0000000..7dde50e --- /dev/null +++ b/ServiceBus98/Controls/XMLFile1.xml @@ -0,0 +1 @@ + diff --git a/ServiceBus98/MainWindow.xaml b/ServiceBus98/MainWindow.xaml index 4edbfeb..1d51794 100644 --- a/ServiceBus98/MainWindow.xaml +++ b/ServiceBus98/MainWindow.xaml @@ -1,60 +1,89 @@ - - + + + + + + + - - - - - + + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + + - - - - + + + + - - - - + + + + - - - - - - - - - - - - + + Status: Idle - - + - + diff --git a/ServiceBus98/MainWindow.xaml.cs b/ServiceBus98/MainWindow.xaml.cs index beae5d9..5ec2733 100644 --- a/ServiceBus98/MainWindow.xaml.cs +++ b/ServiceBus98/MainWindow.xaml.cs @@ -1,7 +1,8 @@ using System.Windows; using Azure.Messaging.ServiceBus; +using Microsoft.Win32; -namespace ServiceBus98; +namespace ServiceBus95; /// /// Interaction logic for MainWindow.xaml @@ -13,63 +14,60 @@ public partial class MainWindow : Window InitializeComponent(); } - private async void Send_Click(object sender, RoutedEventArgs e) + private void NewCommandExecuted(object sender, System.Windows.Input.ExecutedRoutedEventArgs e) { - if (string.IsNullOrEmpty(ConnectionString.Text)) + MessageBox.Show("New command executed"); + } + + private void OpenCommandExecuted(object sender, System.Windows.Input.ExecutedRoutedEventArgs e) + { + OpenFileDialog openFileDialog = new OpenFileDialog(); + openFileDialog.ShowDialog(this); + } + + private void SaveCommandExecuted(object sender, System.Windows.Input.ExecutedRoutedEventArgs e) + { + if (!WarnOnSave()) { - MessageBox.Show("Enter a connection string.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } - if (string.IsNullOrEmpty(QueueName.Text)) + SaveFileDialog saveFileDialog = new SaveFileDialog(); + saveFileDialog.ShowDialog(this); + } + + private void SaveAsCommandExecuted(object sender, System.Windows.Input.ExecutedRoutedEventArgs e) + { + if (!WarnOnSave()) { - MessageBox.Show("Enter a queue name.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } - if (string.IsNullOrEmpty(Message.Text)) - { - MessageBoxResult result = MessageBox.Show("You did not enter a message. Do you want to send an empty message?", "Empty Message", MessageBoxButton.YesNo, MessageBoxImage.Question); - if (result == MessageBoxResult.Cancel) - { - return; - } - } + SaveFileDialog saveFileDialog = new SaveFileDialog(); + saveFileDialog.ShowDialog(this); + } - try - { - StatusText.Text = "Status: Sending"; + private void CloseCommandExecuted(object sender, System.Windows.Input.ExecutedRoutedEventArgs e) + { + // TODO: prompt to save + Close(); + } - await using ServiceBusClient serviceBusClient = new ServiceBusClient(ConnectionString.Text); - await using ServiceBusSender serviceBusSender = serviceBusClient.CreateSender(QueueName.Text); - using ServiceBusMessageBatch messageBatch = await serviceBusSender.CreateMessageBatchAsync(); + private void CheckIfDirty(object sender, System.Windows.Input.ExecutedRoutedEventArgs e) + { + + } - ServiceBusMessage serviceBusMessage = new ServiceBusMessage(Message.Text ?? string.Empty) - { - ContentType = ContentType.Text ?? "text/plain" - }; + private bool WarnOnSave() + { + return MessageBoxWindow.Show(this, "All data will be saved in plain text. Do not save this request if it contains sensitive data.", "Sensitive Data Warning") == MessageBoxResult.OK; + } - messageBatch.TryAddMessage(serviceBusMessage); + private void HelpAboutClick(object sender, RoutedEventArgs e) + { + AboutWindow aboutWindow = new AboutWindow(); + aboutWindow.Owner = this; - await serviceBusSender.SendMessagesAsync(messageBatch); - - MessageBox.Show("Message sent successfully.", "Success", MessageBoxButton.OK, MessageBoxImage.Information); - } - - catch (Exception ex) - { - string errorMessage = ex.Message; - if (ex is ServiceBusException) - { - errorMessage = $"Service Bus returned an error. Ensure that the connection string is valid and the queue exists.\n\nAdditional Details:\n{errorMessage}"; - } - - MessageBox.Show(errorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Error); - } - - finally - { - StatusText.Text = "Status: Idle"; - } + aboutWindow.ShowDialog(); } } \ No newline at end of file diff --git a/ServiceBus98/MultilineTextBox9x.xaml b/ServiceBus98/MultilineTextBox9x.xaml index 598486c..c62e1c3 100644 --- a/ServiceBus98/MultilineTextBox9x.xaml +++ b/ServiceBus98/MultilineTextBox9x.xaml @@ -1,14 +1,14 @@ - - + - + diff --git a/ServiceBus98/MultilineTextBox9x.xaml.cs b/ServiceBus98/MultilineTextBox9x.xaml.cs index 9315bd5..279928b 100644 --- a/ServiceBus98/MultilineTextBox9x.xaml.cs +++ b/ServiceBus98/MultilineTextBox9x.xaml.cs @@ -13,7 +13,7 @@ using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; -namespace ServiceBus98 +namespace ServiceBus95 { /// /// Interaction logic for MultilineTextBox9x.xaml diff --git a/ServiceBus98/Resources/BlankSheet.ico b/ServiceBus98/Resources/BlankSheet.ico new file mode 100644 index 0000000..35b0faf Binary files /dev/null and b/ServiceBus98/Resources/BlankSheet.ico differ diff --git a/ServiceBus98/Resources/Chord.wav b/ServiceBus98/Resources/Chord.wav new file mode 100644 index 0000000..0193a11 Binary files /dev/null and b/ServiceBus98/Resources/Chord.wav differ diff --git a/ServiceBus98/Resources/NewLetter.ico b/ServiceBus98/Resources/NewLetter.ico new file mode 100644 index 0000000..ada5257 Binary files /dev/null and b/ServiceBus98/Resources/NewLetter.ico differ diff --git a/ServiceBus98/Resources/OpenedFolder.ico b/ServiceBus98/Resources/OpenedFolder.ico new file mode 100644 index 0000000..e3c40c0 Binary files /dev/null and b/ServiceBus98/Resources/OpenedFolder.ico differ diff --git a/ServiceBus98/Resources/ScrollBarTrack.png b/ServiceBus98/Resources/ScrollBarTrack.png new file mode 100644 index 0000000..c9b4343 Binary files /dev/null and b/ServiceBus98/Resources/ScrollBarTrack.png differ diff --git a/ServiceBus98/Resources/Warning.ico b/ServiceBus98/Resources/Warning.ico new file mode 100644 index 0000000..968a41d Binary files /dev/null and b/ServiceBus98/Resources/Warning.ico differ diff --git a/ServiceBus98/ServiceBus95.csproj b/ServiceBus98/ServiceBus95.csproj new file mode 100644 index 0000000..73d7bf5 --- /dev/null +++ b/ServiceBus98/ServiceBus95.csproj @@ -0,0 +1,36 @@ + + + + WinExe + net8.0-windows + enable + enable + true + Resources\NewLetter.ico + + + + + + + + + + + + Always + + + + + + + + + + + + + + + diff --git a/ServiceBus98/ServiceBus98.csproj b/ServiceBus98/ServiceBus98.csproj deleted file mode 100644 index 6ad54a6..0000000 --- a/ServiceBus98/ServiceBus98.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - - WinExe - net8.0-windows - enable - enable - true - - - - - - - diff --git a/ServiceBus98/TextBox9x.xaml b/ServiceBus98/TextBox9x.xaml index 92e3aeb..14f715a 100644 --- a/ServiceBus98/TextBox9x.xaml +++ b/ServiceBus98/TextBox9x.xaml @@ -1,9 +1,9 @@ - diff --git a/ServiceBus98/TextBox9x.xaml.cs b/ServiceBus98/TextBox9x.xaml.cs index 6131ddf..d23c557 100644 --- a/ServiceBus98/TextBox9x.xaml.cs +++ b/ServiceBus98/TextBox9x.xaml.cs @@ -13,7 +13,7 @@ using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; -namespace ServiceBus98 +namespace ServiceBus95 { /// /// Interaction logic for TextBox9x.xaml diff --git a/ServiceBus98/Windows/AboutWindow.xaml b/ServiceBus98/Windows/AboutWindow.xaml new file mode 100644 index 0000000..cea69dd --- /dev/null +++ b/ServiceBus98/Windows/AboutWindow.xaml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + Copyright (C) 1995-2025 Tommy + + + + + + + + + + + diff --git a/ServiceBus98/Windows/AboutWindow.xaml.cs b/ServiceBus98/Windows/AboutWindow.xaml.cs new file mode 100644 index 0000000..d6238b9 --- /dev/null +++ b/ServiceBus98/Windows/AboutWindow.xaml.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +namespace ServiceBus95 +{ + /// + /// Interaction logic for About.xaml + /// + public partial class AboutWindow : Window + { + public AboutWindow() + { + InitializeComponent(); + } + + private void CloseCanExecute(object sender, CanExecuteRoutedEventArgs e) + { + e.CanExecute = true; + } + + private void CloseExecuted(object sender, ExecutedRoutedEventArgs e) + { + this.Close(); + } + + private void HyperlinkClick(object sender, RoutedEventArgs e) + { + Hyperlink hyperlink = (Hyperlink)sender; + Process.Start(new ProcessStartInfo + { + FileName = hyperlink.NavigateUri.ToString(), + UseShellExecute = true + }); + } + } +} diff --git a/ServiceBus98/Windows/MessageBoxWindow.xaml b/ServiceBus98/Windows/MessageBoxWindow.xaml new file mode 100644 index 0000000..49492f0 --- /dev/null +++ b/ServiceBus98/Windows/MessageBoxWindow.xaml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + diff --git a/ServiceBus98/Windows/MessageBoxWindow.xaml.cs b/ServiceBus98/Windows/MessageBoxWindow.xaml.cs new file mode 100644 index 0000000..ea48170 --- /dev/null +++ b/ServiceBus98/Windows/MessageBoxWindow.xaml.cs @@ -0,0 +1,48 @@ +using System.Media; +using System.Windows; + +namespace ServiceBus95 +{ + /// + /// Interaction logic for About.xaml + /// + public partial class MessageBoxWindow : Window + { + public MessageBoxWindow() + { + InitializeComponent(); + + SoundPlayer player = new SoundPlayer("Resources/Chord.wav"); + player.Play(); + } + + public MessageBoxResult MessageBoxResult { get; set; } + + public static MessageBoxResult Show(Window owner, string messageBoxText, string caption) + { + MessageBoxWindow window = new MessageBoxWindow + { + Owner = owner, + Title = caption, + WindowStartupLocation = WindowStartupLocation.CenterOwner + }; + + window.MessageBoxText.Text = messageBoxText; + window.ShowDialog(); + + return window.MessageBoxResult; + } + + private void OkButton_Click(object sender, RoutedEventArgs e) + { + MessageBoxResult = MessageBoxResult.OK; + Close(); + } + + private void CancelButton_Click(object sender, RoutedEventArgs e) + { + MessageBoxResult = MessageBoxResult.Cancel; + Close(); + } + } +}