Skip to content

Commit 350653c

Browse files
authored
Add files via upload
1 parent c890142 commit 350653c

17 files changed

+3810
-0
lines changed

App.config

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
5+
</startup>
6+
<runtime>
7+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
8+
<probing privatePath="x86"/>
9+
</assemblyBinding>
10+
</runtime>
11+
</configuration>

Form1.Designer.cs

Lines changed: 52 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Form1.cs

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Data;
5+
using System.Drawing;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
using System.Windows.Forms;
10+
using CefSharp;
11+
using CefSharp.WinForms;
12+
13+
namespace Jstris_Client
14+
{
15+
public partial class Jstris : Form
16+
{
17+
public ChromiumWebBrowser browser;
18+
public Jstris()
19+
{
20+
InitializeComponent();
21+
this.FormBorderStyle = FormBorderStyle.Sizable;
22+
this.WindowState = FormWindowState.Maximized;
23+
InitializeChromium();
24+
25+
}
26+
27+
public void InitializeChromium()
28+
{
29+
CefSettings settings = new CefSettings();
30+
settings.CachePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\CEF";
31+
Cef.Initialize(settings);
32+
browser = new ChromiumWebBrowser("https://jstris.jezevec10.com");
33+
browser.KeyboardHandler = new KeyboardHandler();
34+
this.Controls.Add(browser);
35+
browser.Dock = DockStyle.Fill;
36+
37+
}
38+
39+
private void Jstris_KeyDown(object sender, KeyEventArgs e)
40+
{
41+
if (e.KeyCode == Keys.Escape)
42+
{
43+
MessageBox.Show("SheesH");
44+
}
45+
}
46+
}
47+
48+
49+
//KeyboardHandler by tobre => https://stackoverflow.com/questions/60740328/keyboard-shortcut-does-not-make-it-to-cefsharp-browser-control
50+
public class KeyboardHandler : IKeyboardHandler
51+
{
52+
private bool _cefAltKeyPressed;
53+
public bool OnPreKeyEvent(IWebBrowser chromiumWebBrowser, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey, ref bool isKeyboardShortcut)
54+
{
55+
return false;
56+
}
57+
58+
public bool OnKeyEvent(IWebBrowser chromiumWebBrowser, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey)
59+
{
60+
if (windowsKeyCode == 18)
61+
{
62+
_cefAltKeyPressed = true;
63+
}
64+
const int KEY_F4 = 115;
65+
//Console.WriteLine("Key Pressed " + windowsKeyCode); .> To Debug and analyse other Shortcut Combinations
66+
if (_cefAltKeyPressed)
67+
{
68+
if (windowsKeyCode == KEY_F4)
69+
{
70+
71+
Application.Exit();
72+
}
73+
74+
_cefAltKeyPressed = false;
75+
76+
}
77+
return true;
78+
}
79+
}
80+
}

0 commit comments

Comments
 (0)