fix: компиляция под Windows с Linux
- добавил EnableWindowsTargeting для кросс-компиляции - добавил ImplicitUsings, убрал конфликтующие глобальные using - добавил недостающие using во всех файлах - пофиксил ambiguous references (Application, MessageBox, Button, KeyEventArgs, FontStyle) - пофиксил null-conditional assignment
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using JustABlocker.Services;
|
||||
using Forms = System.Windows.Forms;
|
||||
|
||||
namespace JustABlocker;
|
||||
|
||||
public partial class App : Application
|
||||
public partial class App : System.Windows.Application
|
||||
{
|
||||
private Mutex? _mutex;
|
||||
private WfpFilterService? _wfpService;
|
||||
private BlacklistManager? _blacklistManager;
|
||||
private NotifyIcon? _trayIcon;
|
||||
private Forms.NotifyIcon? _trayIcon;
|
||||
private MainWindow? _mainWindow;
|
||||
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
@@ -64,18 +65,18 @@ public partial class App : Application
|
||||
|
||||
private void SetupTray()
|
||||
{
|
||||
_trayIcon = new NotifyIcon
|
||||
_trayIcon = new Forms.NotifyIcon
|
||||
{
|
||||
Icon = CreateTrayIcon(),
|
||||
Text = "Just a Blocker",
|
||||
Visible = true,
|
||||
};
|
||||
|
||||
var menu = new ContextMenuStrip();
|
||||
var menu = new Forms.ContextMenuStrip();
|
||||
menu.Items.Add("Show / Hide", null, (_, _) => ToggleWindow());
|
||||
menu.Items.Add(new ToolStripSeparator());
|
||||
menu.Items.Add(new Forms.ToolStripSeparator());
|
||||
menu.Items.Add("Pause", null, (_, _) => TogglePause());
|
||||
menu.Items.Add(new ToolStripSeparator());
|
||||
menu.Items.Add(new Forms.ToolStripSeparator());
|
||||
menu.Items.Add("Exit", null, (_, _) => ExitApp());
|
||||
|
||||
_trayIcon.ContextMenuStrip = menu;
|
||||
@@ -90,8 +91,8 @@ public partial class App : Application
|
||||
using var brush = new SolidBrush(Color.Red);
|
||||
g.FillRectangle(brush, 3, 3, 10, 10);
|
||||
using var whiteBrush = new SolidBrush(Color.White);
|
||||
var font = new Font("Segoe UI", 8, FontStyle.Bold);
|
||||
g.DrawString("!", font, whiteBrush, 4, 2);
|
||||
using var font = new System.Drawing.Font("Segoe UI", 8, System.Drawing.FontStyle.Bold);
|
||||
g.DrawString("!", font, whiteBrush, 4.0f, 2.0f);
|
||||
var hicon = bitmap.GetHicon();
|
||||
return Icon.FromHandle(hicon);
|
||||
}
|
||||
@@ -162,8 +163,12 @@ public partial class App : Application
|
||||
|
||||
private void ExitApp()
|
||||
{
|
||||
_trayIcon?.Visible = false;
|
||||
_trayIcon?.Dispose();
|
||||
if (_trayIcon != null)
|
||||
{
|
||||
_trayIcon.Visible = false;
|
||||
_trayIcon.Dispose();
|
||||
_trayIcon = null;
|
||||
}
|
||||
Current.Shutdown();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,11 @@
|
||||
<AssemblyName>JustABlocker</AssemblyName>
|
||||
<RootNamespace>JustABlocker</RootNamespace>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<EnableWindowsTargeting>true</EnableWindowsTargeting>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Remove="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
@@ -93,7 +95,7 @@ public partial class MainWindow : Window
|
||||
InputBox.Focus();
|
||||
}
|
||||
|
||||
private void InputBox_OnKeyDown(object sender, KeyEventArgs e)
|
||||
private void InputBox_OnKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace JustABlocker.Models;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using JustABlocker.Models;
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using JustABlocker.Models;
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
|
||||
Reference in New Issue
Block a user