18 Star 99 Fork 30

chenhongjin / GTKSystem.Windows.Forms

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
LGPL-3.0

GTKSystem.Windows.Forms

介绍

Visual Studio原生开发,无需学习,一次编译,跨平台运行. C#桌面应用程序跨平台(windows、linux、macos)界面开发组件,基于GTK组件开发,该组件的核心优势是使用C#的原生winform表单控件窗体设计器,相同的属性方法,C#原生开发即可,无需学习。一次编译,跨平台运行。 便于开发跨平台winform软件,便于将C#升级为跨平台软件。

作者博客请看 https://www.cnblogs.com/easywebfactory/p/17803567.html

目前功能持续更新中,将优先完善常用功能。

软件架构

使用GTK3.24.24.95作为表单UI重写C#的System.Windows.Forms组件,在应用时,兼容原生C#程序组件。

安装教程

  1. 项目工程框架选择“window应用程序”改配置UseWindowsForms为false或“控制台应用程序”,框架.netcore3.1或.net6及以上版本
  2. NulGet安装GtkSharp(3.24.24.95)、GTKSystem.Windows.Forms、GTKSystem.Windows.FormsDesigner
  3. 检查form表单是否有使用图像资源,如使用需新建System.Resources.ResourceManager和System.ComponentModel.ComponentResourceManager,具体请看下面内容。
  4. 按默认配置编译发布测试运行
  5. linux和macos上执行命令:dotnet demo_app.dll
  6. 编译工程,执行本项目的开发插件菜单“修复窗体设计器”,或者手动在obj目录下创建.designer.runtimeconfig.json,请看下面第5点。

注意:安装GtkSharp后,编译你的工程项目时,会自动下载$(LOCALAPPDATA)\Gtk\3.24.24\gtk.zip配置Gtk环境,目前国内网络限制,可能会出现无法下载的错误,可以尝试安装fastgithub软件解决,或者其它vpn软件。 如果无法自动下载,本项目提供下载 /Dependencies/gtk-3.24.24.zip。 也可以下载https://github.com/GtkSharp/Dependencies,把文件解压后放到$(LOCALAPPDATA)\Gtk\3.24.24\gtk.zip目录即可。

ps:$(LOCALAPPDATA)为电脑的AppData\Local文件夹,如:C:\Users\chj\AppData\Local\Gtk\3.24.24

linux安装gtk环境:

 sudo apt install libgtk-3-dev

 sudo apt-get install libgtk3*

linux安装dotnet环境:

  安装方法可以查看微软官网教程:https://learn.microsoft.com/zh-cn/dotnet/core/install/linux-scripted-manual

VisualStudio插件安装

工具一、从NuGet上安装GTKSystem.Windows.FormsDesigner类库,此类库可以在编译工程时修正窗体设计器。

工具二、下载本插件工具,关闭visual studio,直接双击GTKWinformVSIXProject.vsix文件安装(本框架下的工程,Studio没有添加Form模板项,需要安装此插件)

插件会安装两个功能:

1、新建项的Form窗体模板、用户控件模板。

2、工程右键菜单。

输入图片说明

使用说明

以下配置在你的项目工程里操作:

1、新建System.Resources.ResourceManager类
在项目下新建System.Resources.ResourceManager类,继承GTKSystem.Resources.ResourceManager,用于覆盖原生System.Resources.ResourceManager类。 GTKSystem.Resources.ResourceManager实现了项目资源文件和图像文件读取。 如果项目里没有使用资源图像文件,可以不用新建此文件。

2、新建System.ComponentModel.ComponentResourceManager类
在项目下新建System.ComponentModel.ComponentResourceManager类,继承GTKSystem.ComponentModel.ComponentResourceManager,用于覆盖原生System.ComponentModel.ComponentResourceManager类。
GTKSystem.ComponentModel.ComponentResourceManager实现了项目资源文件和图像文件读取(调用GTKSystem.Resources.ResourceManager)。 如果项目里没有使用资源图像文件,可以不用新建此文件。

3、GTKWinFormsApp.csproj
配置UseWindowsForms为false,目标OS设置为“(空)”,或者使用控制台应用程序(在控制台框架下会显示控制台窗口,不建议这种方式)

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <UseWindowsForms>false</UseWindowsForms>

4、引用GTKSystem.Windows.Forms、System.Resources.Extensions
GTKSystem.Windows.Forms是必须引用
System.Resources.Extensions是空程序dll,不是必须引用,只有VS在窗体设计器出现相关异常提示时使用

5、GTKWinFormsApp\obj\Debug\net8.0\GTKWinFormsApp.designer.runtimeconfig.json GTKWinFormsApp\obj\Debug\net8.0\GTKWinFormsApp.runtimeconfig.json 将name设置为Microsoft.WindowsDesktop.App, 用于VS支持可视化窗体设计器,重新加载工程或重启VS 如以下配置: GTKWinFormsApp.designer.runtimeconfig.json

{
  "runtimeOptions": {
    "tfm": "net8.0",
    "framework": {
      "name":"Microsoft.WindowsDesktop.App",
      "version": "8.0.0"
    },
    "additionalProbingPaths": [
      "C:\\Users\\chj\\.dotnet\\store\\|arch|\\|tfm|", 
      "C:\\Users\\chj\\.nuget\\packages",
      "C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages",
      "C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
    ],
    "configProperties": {
      "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false,
      "Microsoft.NETCore.DotNetHostPolicy.SetAppPaths": true
    }
  }
}

GTKWinFormsApp.runtimeconfig.json

{
  "runtimeOptions": {
    "tfm": "net8.0",
    "framework": {
      "name": "Microsoft.WindowsDesktop.App",
      "version": "8.0.0"
    },
    "configProperties": {
      "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
    }
  }
}

demo效果

输入图片说明

工具栏菜单

输入图片说明

图文窗口

输入图片说明

支持作者,获取技术服务

支持作者

添加作者微信,更多服务帮助

联系作者

交流/合作/商务/赞助

QQ群:236066073 邮箱:438865652@qq.com

常见问题

1、为什么Form窗体设计器打不开? 答:检查runtimeconfig的确保配置正确,NuGet安装GTKSystem.Windows.FormsDesigner,然后按以下流程操作: 1、编译一下 3、打开Form窗体 (如果不能打开窗体,执行下面流程) 4、关闭Form窗体,编译一下 5、重启vs 6、打开Form窗体设计器

参与贡献

  1. https://gitee.com/easywebfactory
  2. https://github.com/easywebfactory

更新日志

2024/5/28

  1. 修正和增加了控件的一些方法。
  2. 添加GTK多线程UI更新程序

2024/5/21

  1. combobox\listbox功能
  2. ToolStripSeparator修正

2024/5/17

  1. datetimepicker增加时间数据和format模式

2024/5/16

  1. 修正form窗口有透明边线的问题
  2. 增加了几个控件常用属性
  3. combobox控件增加DropDown或DropDownList可选模式
  4. 修改了VisualStudio开发插件的功能错误,提高了安装适配兼容性

2024/5/11

  1. 修正form启动时窗口大小异常
  2. button增加image属性图片
  3. 修正控件背景位置

2024/5/6

  1. 完善treeview、listview功能
  2. 新增开发工具GTKSystem.Windows.FormsDesigner.dll(NuGet安装),编译时自动检查并修正窗体设计器配置
  3. 修正datagridview的取数错误

2024/5/1

  1. 重大更新!重构控件的结构程序,优化了很多控件功能和性能,修正一些错误
  2. 优化了绘图、控件背景功能程序,绘制背景图不再覆盖子控件
  3. 特别优化Form界面程序和性能

2024/4/20

  1. 修正graphic绘图的位置
  2. 实现graphicpath绘图、渐变色
  3. 实现控件的BeginInvoke和EndInvoke方法
  4. 修改DataGridView、ListBox的数据加载程序,修正不能在窗口启动加载数据的问题

2024/3/27

  1. 改正usercontrol在窗体设计器上打开出现异常的问题(还无法显示控件)
  2. 实现graphics上的椭圆绘画

2024/3/19

  1. panel内容溢出显示滚动条,窗口缩放程序优化

2024/3/14

  1. 修正TreeView数据程序加载

2024/3/6

  1. 修正一些窗口配置问题、binding

2024/3/2

  1. 修正label文本的字体大小问题、增加对齐属性
  2. 实现imagelist兼容使用窗体设计器

2024/2/29

  1. grahpics增加曲线和多边形绘图,优化文字绘图程序
  2. 修正一些隐性异常

2024/2/23

  1. 实现和修正DataGridView单元控件数据编辑、取数功能
GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.

简介

C#桌面应用程序跨平台(windows、linux、macos)界面开发组件,基于GTK组件开发,该组件的核心优势是使用C#的原生winform表单控件窗体设计器,相同的属性方法,C#原生开发即可,无需学习。一次编译,跨平台运行。 便于开发跨平台winform软件,便于将C#升级为跨平台软件。 展开 收起
C#
LGPL-3.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C#
1
https://gitee.com/easywebfactory/gtksystem-windows-forms.git
git@gitee.com:easywebfactory/gtksystem-windows-forms.git
easywebfactory
gtksystem-windows-forms
GTKSystem.Windows.Forms
master

搜索帮助