Skip to content

Commit

Permalink
More winforms work - about dialog testing
Browse files Browse the repository at this point in the history
  • Loading branch information
TauAkiou committed Oct 5, 2020
1 parent dd90625 commit 752a678
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 16 deletions.
1 change: 1 addition & 0 deletions AmongUsCapture/AmongUsCapture.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

<ItemGroup>
<EmbeddedResource Include="icon.ico" />
<EmbeddedResource Include="version.txt" />
</ItemGroup>

<ItemGroup>
Expand Down
13 changes: 4 additions & 9 deletions AmongUsCapture/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@ static void Main()
var appstate = new Application("org.AmongUsCapture.AmongUsCaptureUtil", GLib.ApplicationFlags.None);
appstate.Register(GLib.Cancellable.Current);
Application.Init();
if(doConsole)

// This particular line is a Win32 system call and should only ever be run there
if(doConsole && RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
AllocConsole(); // needs to be the first call in the program to prevent weird bugs
}
/* This is winforms stuff and doesn't apply to GTK.
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
*/


ClientSocket socket = new ClientSocket();

var windowbuilder = new Builder();
Expand All @@ -52,7 +49,5 @@ static void Main()
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool AllocConsole();


}
}
38 changes: 38 additions & 0 deletions AmongUsCapture/UserForm.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Reflection.Metadata;
using System.Runtime.CompilerServices;
Expand Down Expand Up @@ -79,6 +80,43 @@ public UserForm(Builder builder, ClientSocket sock) : base("Among Us Capture - G

}

private void _primaryWindowMenuQuitItem_Activated(object o, EventArgs e)
{
this.Close();
}

private void _primaryWindowMenuItemAbout_Activated(object o, EventArgs e)
{
var abouticon = new Pixbuf(Assembly.GetExecutingAssembly().GetManifestResourceStream("amonguscapture_gtk.icon.ico"));
AboutDialog about = new AboutDialog();

about.Name = "_amonguscaptureGtkAboutDialog";
about.ProgramName = "Among Us Capture (GTK)";
string version = String.Empty;
using(Stream stream = Assembly.GetExecutingAssembly()
.GetManifestResourceStream("amonguscapture_gtk.version.txt"))
if (stream == null)
version = "Unknown";
else
{
using (StreamReader sreader = new StreamReader(stream))
{
version = sreader.ReadToEnd();
}
}

about.Version = version;
about.Comments = "amonguscapture_gtk is a GTK version of the Among Us Capture utility made by denverquane.";
about.Website = "https://github.com/TauAkiou/amonguscapture-gtk";
about.Logo = abouticon;

about.Run();

about.Dispose();


}

private void _consoleTextView_OnPopulateContextMenu(object o, PopulatePopupArgs e)
{
Menu textViewContextMenu = (Menu)e.Args[0];
Expand Down
73 changes: 66 additions & 7 deletions AmongUsCapture/Userform.Gtk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,27 @@ namespace AmongUsCapture
{
public partial class UserForm
{
// Menubar
private VBox _primaryWindowContainer;
private MenuBar _primaryWindowMenuBar;
private MenuItem _primaryMenuItemFile;
private MenuItem _primaryMenuItemAbout;

// Menu
private Menu _primaryWindowMenuFile;
private MenuItem _primaryWindowMenuQuitItem;


// Top level windows
private HPaned _primaryWindowPane;
private VBox _primaryWindowLeftContainer;

// UserSettings (Left Side)
private VBox _userSettingsParentContainer;
private Frame _userSettingsParentFrame;

private Frame _gameInfoParentFrame;
private VBox _gameInfoParentContainer;

// GameCode objects
private Frame _gameCodeParentFrame;
Expand All @@ -23,8 +37,7 @@ public partial class UserForm
// Websocket/Host Control
private Frame _hostControlFrame;
private VBox _hostControlLayoutContainer;



private Frame _urlHostEntryFrame;
private HBox _urlHostEntryLayoutContainer;
private Entry _urlHostEntryField;
Expand Down Expand Up @@ -54,13 +67,26 @@ public partial class UserForm

public void InitializeWindow()
{
// Menubar
_primaryWindowContainer = new VBox();
_primaryWindowMenuBar = new MenuBar();

_primaryMenuItemFile = new MenuItem();

_primaryWindowMenuFile = new Menu();
_primaryWindowMenuQuitItem = new MenuItem();


// Top level window pane.
_primaryWindowPane = new HPaned();
_primaryWindowLeftContainer = new VBox();

// Left side User Settings Pane
_userSettingsParentFrame = new Frame();
_userSettingsParentContainer = new VBox();

_gameInfoParentFrame = new Frame();
_gameInfoParentContainer = new VBox();

// Left Side Current State Field
_currentStateFrame = new Frame();
Expand Down Expand Up @@ -96,6 +122,30 @@ public void InitializeWindow()

_consoleTextView = new TextView();

//

_primaryWindowContainer.Name = "_primaryWindowContainer";
_primaryWindowContainer.PackStart(_primaryWindowMenuBar, false, false, 2);
_primaryWindowContainer.PackStart(_primaryWindowPane, true, true, 0);

_primaryWindowMenuBar.Name = "_primaryWindowMenuBar";
_primaryWindowMenuBar.Append(_primaryMenuItemFile);

_primaryMenuItemFile.Name = "_primaryMenuItemFile";
_primaryMenuItemFile.Label = "File";
_primaryMenuItemFile.Submenu = _primaryWindowMenuFile;

_primaryMenuItemAbout.Name = "_primaryMenuItemAbout";
_primaryMenuItemAbout.Label = "About";
_primaryMenuItemAbout.Activated += _primaryWindowMenuItemAbout_Activated;

_primaryWindowMenuFile.Name = "_primaryWindowMenu";
_primaryWindowMenuFile.Append(_primaryWindowMenuQuitItem);

_primaryWindowMenuQuitItem.Name = "_primaryWindowMenuQuitItem";
_primaryWindowMenuQuitItem.Label = "Quit";
_primaryWindowMenuQuitItem.Activated += _primaryWindowMenuQuitItem_Activated;

// _primaryWindowPane definition (splitContainer1)
_primaryWindowPane.Name = "_primaryWindowPane";
_primaryWindowPane.SetSizeRequest(824, 476);
Expand All @@ -117,10 +167,19 @@ public void InitializeWindow()
_userSettingsParentFrame.Add(_userSettingsParentContainer);

_userSettingsParentContainer.Margin = 5;
_userSettingsParentContainer.PackStart(_currentStateFrame, true, false, 10);
_userSettingsParentContainer.PackStart(_gameInfoParentFrame, true, false, 10);
_userSettingsParentContainer.PackStart(_hostControlFrame, true, false, 10);
_userSettingsParentContainer.PackStart(_gameCodeParentFrame, true, false, 5);
_userSettingsParentContainer.Name = "_userSettingsParentContainer";

_gameInfoParentFrame.Name = "_gameInfoParentFrame";
_gameInfoParentFrame.Label = "Game Information";
_gameInfoParentFrame.SetSizeRequest(55, 40);
_gameInfoParentFrame.Add(_gameInfoParentContainer);

_gameInfoParentContainer.Name = "_gameInfoParentContainer";
_gameInfoParentContainer.PackStart(_currentStateFrame, true, false, 10);
_gameInfoParentContainer.PackStart(_gameCodeParentFrame, true, false, 10);
_gameInfoParentContainer.Margin = 5;

// CurrentStateFrame
_currentStateFrame.Add(_currentStateContainer);
Expand Down Expand Up @@ -183,7 +242,7 @@ public void InitializeWindow()
_urlHostEntryFrame.Add(_urlHostEntryLayoutContainer);

_urlHostEntryLayoutContainer.Name = "_urlHostEntryLayoutContainer";
_urlHostEntryLayoutContainer.SetSizeRequest(25, 20);
_urlHostEntryLayoutContainer.SetSizeRequest(70, 20);
_urlHostEntryLayoutContainer.PackStart(_urlHostEntryField, true, false, 5);
_urlHostEntryLayoutContainer.MarginBottom = 5;

Expand All @@ -199,7 +258,7 @@ public void InitializeWindow()

_connectCodeEntryField.Name = "_connectCodeEntryField";
_connectCodeEntryField.Xalign = (float)0.5;
_connectCodeEntryField.SetSizeRequest(50, 20);
_connectCodeEntryField.SetSizeRequest(70, 20);
_connectCodeEntryField.MaxLength = 6;

_connectCodeSubmitButton.Name = "_connectCodeSubmitButton";
Expand Down Expand Up @@ -231,7 +290,7 @@ public void InitializeWindow()
_consoleTextView.Buffer.Changed += _consoleTextView_BufferChanged;

SetDefaultSize(824, 476);
Add(_primaryWindowPane);
Add(_primaryWindowContainer);

}

Expand Down

0 comments on commit 752a678

Please sign in to comment.