Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mono #225

Open
wants to merge 23 commits into
base: development
Choose a base branch
from
Open

Mono #225

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2271aa1
[ci] Add build by Ubuntu using Mono
ila-embsys May 1, 2024
f32558a
[project] Change TargetFramework from 'net481' to 'net48'
ila-embsys May 1, 2024
c6fff23
[project] XenAdmin: Add 'System.Windows.Forms' reference
ila-embsys May 1, 2024
e8b0882
[project] Change letter cases of files to match string values in reso…
ila-embsys May 1, 2024
c4d6750
XenAdmin: Drawing: Change QuickDraw function implementation to crossp…
ila-embsys May 1, 2024
9636527
[mono] XenAdmin: AddServerDialog: Disable setting focus on a field if…
ila-embsys May 1, 2024
ae2d84d
[mono] XenAdmin: Snapshots: Disable code that produce exceptions
ila-embsys May 1, 2024
09f1c13
[resource] XenAdmin: AddServerDialog: Fix cutting a part of credentia…
ila-embsys May 1, 2024
f02b5a9
[mono] XenAdmin: DataGridViewEx: Add explicit font settings on cell s…
ila-embsys May 1, 2024
27274a7
[mono] XenAdmin: VNCGraphicsClient: Disable cursor image change
ila-embsys May 1, 2024
7e2a0e6
[mono] XenAdmin: VNCGraphicsClient: Disable ScanCodes handling
ila-embsys May 1, 2024
4db9c2f
[mono] XenAdmin: XSVNCScreen: Fix call loop
ila-embsys May 1, 2024
7fab817
[mono] XenAdmin: FlickerFreeListBox: Fix exception on call GetScrollInfo
ila-embsys May 1, 2024
3340640
[mono] XenAdmin: VNCScream: Use stopwatch for measuring time to updat…
ila-embsys May 1, 2024
b2a615f
[resource] Use PNG formatted splash screen
ila-embsys May 1, 2024
26e40e3
[mono] XenAdmin: MainWindow: Disable adding HomePage tab content
ila-embsys May 1, 2024
c71c63f
[mono] XenAdmin: MainWindow: Disable registering the ClipboardViewer
ila-embsys May 1, 2024
c58803b
[mono] XenAdmin: MainWindow: Disable RestartManager
ila-embsys May 1, 2024
08b91f6
[mono] XenAdmin: Page_HomeServer: Fix New VM Wizard crashes due to ca…
ila-embsys May 1, 2024
267b7ff
[mono] XenAdmin: Program: Skip logging GUI resources at boot
ila-embsys May 1, 2024
0676739
[mono] XenAdmin: Program: Disable NamedPipe creation
ila-embsys May 1, 2024
91ac3b9
XenAdmin: Program: Fix possibly unhandled exception on calling Exists…
ila-embsys May 1, 2024
296e729
[mono] XenAdmin: MultiSelectTreeView: Disable HScroll manipulation
ila-embsys May 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions .github/workflows/test-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,24 @@ on:

jobs:
build:
runs-on: windows-latest
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
if: matrix.os == 'windows-latest'
- name: Setup Mono repository
if: matrix.os == 'ubuntu-latest'
run: >
gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
&& echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
&& sudo apt-get update
- name: Setup Mono
run: sudo apt-get install -y mono-devel
if: matrix.os == 'ubuntu-latest'
- name: Restore Packages
run: msbuild XenAdmin.sln -t:restore
- name: Build Release solution
Expand All @@ -22,10 +35,10 @@ jobs:
- name: Upload Release Artifacts
uses: actions/upload-artifact@v4
with:
name: drop-release
path: XenAdmin/bin/Release/net481
name: drop-release-${{ matrix.os }}
path: XenAdmin/bin/Release/net48
- name: Upload Debug Artifacts
uses: actions/upload-artifact@v4
with:
name: drop-debug
path: XenAdmin/bin/Debug/net481
name: drop-debug-${{ matrix.os }}
path: XenAdmin/bin/Debug/net48
2 changes: 1 addition & 1 deletion CommandLib/CommandLib.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net481</TargetFramework>
<TargetFramework>net48</TargetFramework>
<Title>CommandLib</Title>
<Description>XCP-ng Center library</Description>
</PropertyGroup>
Expand Down
File renamed without changes.
50 changes: 44 additions & 6 deletions XenAdmin/ConsoleView/VNCGraphicsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,14 @@ internal CustomCursor(Bitmap bitmap, int x, int y)
hbmColor = bitmap.GetHbitmap()
};

_handle = CreateIconIndirect(ref iconInfo);
Cursor = new Cursor(_handle);
if (Type.GetType("Mono.Runtime") == null){
_handle = CreateIconIndirect(ref iconInfo);
Cursor = new Cursor(_handle);
}
else
{
// Doesn't work under Mono
}
}

~CustomCursor()
Expand Down Expand Up @@ -866,7 +872,15 @@ protected override void OnGotFocus(EventArgs e)

if (_sendScanCodes)
{
InterceptKeys.grabKeys(KeyScan, false);
if (Type.GetType("Mono.Runtime") == null)
{
InterceptKeys.grabKeys(KeyScan, false);
}
else
{
// TODO: The code in `XenAdmin/VNC/KeyMap.cs`
// must be crossplatform to enable this feature
}
}

if (_updateClipboardOnFocus)
Expand All @@ -880,7 +894,15 @@ protected override void OnLostFocus(EventArgs e)

EnableMenuShortcuts();

InterceptKeys.releaseKeys();
if (Type.GetType("Mono.Runtime") == null)
{
InterceptKeys.releaseKeys();
}
else
{
// TODO: The code in `XenAdmin/VNC/KeyMap.cs`
// must be crossplatform to enable this feature
}

_cursorOver = false;

Expand Down Expand Up @@ -1259,11 +1281,27 @@ public bool SendScanCodes

if (!value)
{
InterceptKeys.releaseKeys();
if (Type.GetType("Mono.Runtime") == null)
{
InterceptKeys.releaseKeys();
}
else
{
// TODO: The code in `XenAdmin/VNC/KeyMap.cs`
// must be crossplatform to enable this feature
}
}
else if (Focused)
{
InterceptKeys.grabKeys(KeyScan, false);
if (Type.GetType("Mono.Runtime") == null)
{
InterceptKeys.grabKeys(KeyScan, false);
}
else
{
// TODO: The code in `XenAdmin/VNC/KeyMap.cs`
// must be crossplatform to enable this feature
}
}

_sendScanCodes = value;
Expand Down
9 changes: 8 additions & 1 deletion XenAdmin/ConsoleView/XSVNCScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,14 @@ protected override void OnEnter(EventArgs e)
Program.AssertOnEventThread();
base.OnEnter(e);

CaptureKeyboardAndMouse();
if (Type.GetType("Mono.Runtime") == null)
{
CaptureKeyboardAndMouse();
}
else
{
// TODO: It is a cause of a call loop under Mono
}
RefreshScreen();
}

Expand Down
16 changes: 16 additions & 0 deletions XenAdmin/Controls/DataGridViewEx/DataGridViewEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,22 @@ private void SetUpDataGridViewExCellStyles()
DisabledHiddenStyle = new DataGridViewCellStyle();
DisabledRowStyle = new DataGridViewCellStyle();

if (Type.GetType("Mono.Runtime") != null)
{
// These fonts are null by default
// Under Mono some functions produce exceptions due to that
// So set them to some value

var CellFont = new Font(Program.DefaultFont.FontFamily, Program.DefaultFont.Size - 1f);

EnabledStyle.Font = CellFont;
EnabledHiddenStyle.Font = CellFont;
DisabledStyle.Font = CellFont;
DisabledHiddenStyle.Font = CellFont;
DisabledRowStyle.Font = CellFont;
EnabledUnfocusedStyle.Font = CellFont;
}

EnabledStyle.BackColor = ThemeBackgroundColor;
EnabledStyle.ForeColor = SystemColors.ControlText;
EnabledStyle.SelectionBackColor = SystemColors.Highlight;
Expand Down
16 changes: 15 additions & 1 deletion XenAdmin/Controls/FlickerFreeListBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,21 @@ protected override void WndProc(ref Message msg)
Win32.ScrollInfo si = new Win32.ScrollInfo();
si.fMask = (int)Win32.ScrollInfoMask.SIF_ALL;
si.cbSize = (uint)Marshal.SizeOf(si);
Win32.GetScrollInfo(msg.HWnd, 0, ref si);

if (Type.GetType("Mono.Runtime") == null)
{
Win32.GetScrollInfo(msg.HWnd, 0, ref si);
}
else
{
//
// TODO: Exception under Mono
//

// System.DllNotFoundException: user32.dll assembly:<unknown assembly> type:<unknown type> member:(null)
// at (wrapper managed-to-native) XenCenterLib.Win32.GetScrollInfo(intptr,int,XenCenterLib.Win32/ScrollInfo&)
// at XenAdmin.Controls.FlickerFreeListBox.WndProc (System.Windows.Forms.Message& msg)
}

if ((msg.WParam.ToInt32() & 0xFF) == Win32.SB_THUMBTRACK)
{
Expand Down
14 changes: 13 additions & 1 deletion XenAdmin/Controls/SnapshotTreeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,19 @@ protected override void OnLayout(LayoutEventArgs levent)
{
//This is needed to maximize and minimize properly, there is some issue in the ListView Control
Win32.POINT pt = new Win32.POINT();
IntPtr hResult = SendMessage(Handle, LVM_GETORIGIN, IntPtr.Zero, ref pt);

if (Type.GetType("Mono.Runtime") == null)
{
IntPtr hResult = SendMessage(Handle, LVM_GETORIGIN, IntPtr.Zero, ref pt);
}
else
{
// TODO: There is an exception under Mono

// System.DllNotFoundException: user32.dll assembly:<unknown assembly> type:<unknown type> member:(null)
// at (wrapper managed-to-native) XenAdmin.Controls.SnapshotTreeView.SendMessage(intptr,int,intptr,XenCenterLib.Win32/POINT&)
// at XenAdmin.Controls.SnapshotTreeView.OnLayout (System.Windows.Forms.LayoutEventArgs levent)
}

origin = pt;
root.InvalidateAll();
Expand Down
14 changes: 12 additions & 2 deletions XenAdmin/Controls/TreeViews/MultiSelectTreeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1088,11 +1088,21 @@ public int HScrollPos
{
get
{
return ScrollInfo(Win32.ScrollBarConstants.SB_HORZ);
if (System.Type.GetType("Mono.Runtime") == null)
{
return ScrollInfo(Win32.ScrollBarConstants.SB_HORZ);
}
else
{
return 0;
}
}
set
{
Win32.SendMessage(Handle, Win32.WM_HSCROLL, (IntPtr)(((int)Win32.ScrollBarCommands.SB_THUMBPOSITION) | (value << 16)), (IntPtr)0);
if (System.Type.GetType("Mono.Runtime") == null)
{
Win32.SendMessage(Handle, Win32.WM_HSCROLL, (IntPtr)(((int)Win32.ScrollBarCommands.SB_THUMBPOSITION) | (value << 16)), (IntPtr)0);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion XenAdmin/Core/Drawing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static Drawing()
/// </summary>
public static void QuickDraw(Graphics gTarget, Bitmap buffer)
{
QuickDraw(gTarget, buffer, new Point(0, 0), new Rectangle(0, 0, buffer.Width, buffer.Height));
gTarget.DrawImage(buffer, new Rectangle(0, 0, buffer.Width, buffer.Height));
}

/// <summary>
Expand Down
16 changes: 15 additions & 1 deletion XenAdmin/Dialogs/AddServerDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,21 @@ private void AddServerDialog_Shown(object sender, EventArgs e)

if (!ServerNameComboBox.Enabled && connection != null && !string.IsNullOrEmpty(connection.Username))
{
Win32.SetFocus(PasswordTextBox.Handle);
if (Type.GetType("Mono.Runtime") == null)
{
Win32.SetFocus(PasswordTextBox.Handle);
}
else
{
//
// TODO: The app crashes under Mono if password is wrong
//

// System.DllNotFoundException: user32.dll assembly:<unknown assembly> type:<unknown type> member:(null)
// at (wrapper managed-to-native) XenCenterLib.Win32.SetFocus(intptr)

// So just skip setting focus
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion XenAdmin/Dialogs/AddServerDialog.resx
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@
<value>3</value>
</data>
<data name="groupBox1.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
<value>False</value>
</data>
<data name="groupBox1.AutoSizeMode" type="System.Windows.Forms.AutoSizeMode, System.Windows.Forms">
<value>GrowAndShrink</value>
Expand Down
20 changes: 17 additions & 3 deletions XenAdmin/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ public MainWindow(string[] args)
Icon = Properties.Resources.AppIcon;

//CA-270999: Add registration to RestartManager
RegisterApplicationRestart(null, 0);
if (Type.GetType("Mono.Runtime") == null) {
RegisterApplicationRestart(null, 0);
}

#region Add Tab pages

Expand Down Expand Up @@ -187,7 +189,13 @@ public MainWindow(string[] args)
AddTabContents(CvmConsolePanel, TabPageCvmConsole);
AddTabContents(NetworkPage, TabPageNetwork);
AddTabContents(HAPage, TabPageHA);
AddTabContents(HomePage, TabPageHome);
if (Type.GetType("Mono.Runtime") == null) {
AddTabContents(HomePage, TabPageHome);
}
else
{
// TODO: Cause of connection lost
}
AddTabContents(WlbPage, TabPageWLB);
AddTabContents(PhysicalStoragePage, TabPagePhysicalStorage);
AddTabContents(AdPage, TabPageAD);
Expand Down Expand Up @@ -385,7 +393,13 @@ protected override void OnShown(EventArgs e)
protected override void OnHandleCreated(EventArgs e)
{
base.OnHandleCreated(e);
Clip.RegisterClipboardViewer();
if (Type.GetType("Mono.Runtime") == null) {
Clip.RegisterClipboardViewer();
}
else
{
// TODO: Clipboard doesn't work under Mono
}
}

protected override void WndProc(ref System.Windows.Forms.Message e)
Expand Down
26 changes: 19 additions & 7 deletions XenAdmin/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,16 @@ public static void Main(string[] args)
Environment.UserName,
Assembly.GetExecutingAssembly().Location.Replace('\\', '-'));

if (NamedPipes.Pipe.ExistsPipe(_pipePath))
{
NamedPipes.Pipe.SendMessageToPipe(_pipePath, string.Join(" ", args));
return;
try {
if (NamedPipes.Pipe.ExistsPipe(_pipePath))
{
NamedPipes.Pipe.SendMessageToPipe(_pipePath, string.Join(" ", args));
return;
}
}
catch (System.IO.IOException) {
// For example, Mono throws the exception on calling ExistsPipe
// Since if the pipe doesn't exist the code does nothing too.
}

log.Info("Application started");
Expand Down Expand Up @@ -200,7 +206,10 @@ public static void Main(string[] args)
/// </summary>
private static void ConnectPipe()
{
_pipe = new NamedPipes.Pipe(_pipePath);
if (System.Type.GetType("Mono.Runtime") == null)
{
_pipe = new NamedPipes.Pipe(_pipePath);
}

if (_pipe != null)
{
Expand Down Expand Up @@ -251,8 +260,11 @@ private static void LogApplicationStats()
log.InfoFormat("Time since process started: {0}", (DateTime.Now - Process.GetCurrentProcess().StartTime).ToString());

log.InfoFormat("Handles open: {0}", p.HandleCount.ToString());
log.InfoFormat("USER handles open: {0}", Win32.GetGuiResourcesUserCount(p.Handle));
log.InfoFormat("GDI handles open: {0}", Win32.GetGuiResourcesGDICount(p.Handle));
if (System.Type.GetType("Mono.Runtime") == null)
{
log.InfoFormat("USER handles open: {0}", Win32.GetGuiResourcesUserCount(p.Handle));
log.InfoFormat("GDI handles open: {0}", Win32.GetGuiResourcesGDICount(p.Handle));
}
log.InfoFormat("Thread count: {0}", p.Threads.Count);

log.InfoFormat("Virtual memory size: {0} B({1})", p.VirtualMemorySize64, Util.MemorySizeStringSuitableUnits(p.VirtualMemorySize64, false));
Expand Down
8 changes: 4 additions & 4 deletions XenAdmin/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1118,13 +1118,13 @@
<value>..\Images\000_VMPausedDisabled_h32bit_16_green.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_000_UserAndGroup_h32bit_16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\images\000_userandgroup_h32bit_16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<value>..\Images\000_UserAndGroup_h32bit_16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="_000_User_h32bit_32" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\images\000_user_h32bit_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<value>..\Images\000_User_h32bit_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="queued" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\images\queued.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<value>..\Images\queued.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="gooroom_16x" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Images\gooroom_16x.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
Expand Down Expand Up @@ -1163,6 +1163,6 @@
<value>..\Images\rpm_package.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="splash" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\splash.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<value>..\Resources\splash.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Binary file modified XenAdmin/Resources/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading