WPF Snipping Tool Implementation
Last week I needed to write a snipping tool on the product. I found that the articles on the blog only had the step of capturing the screen, or required following an official account for marketing, so I wrote one myself. I found an open source framework on github today. If you are ready to start writing, you can refer to that framework. https://github.com/WPFDevelopersOrg/WPFDevelopers I just finished writing it and recorded the problems I encountered to prevent forgetting them later. @[toc...
WPF 截图工具
上周需要再产品上编写一个截图工具,发现博客上的文章都是只有截取屏幕这一步,或是需要关注公众号之类的营销,便自己撸了一个,今天在github上发现了一个开源的框架,如果准备开始写的可以参照那个框架。 https://github.com/WPFDevelopersOrg/WPFDevelopers 刚刚写完便记录一下自己遇到的问题,防止后面忘掉。 @[toc] 在渲染canvas的时候报错:System.ArgumentException:“值不在预期的范围内。”12345678910var renderTargetBitmap = new RenderTargetBitmap(Convert.ToInt32(_AllScreenWidth), Convert.ToInt32(_AllScreenHeight), 96d, 96d, PixelFormats.Default); renderTargetBitmap.Render(Capture_Canvas); var targetRec = new Int3...
QT release MYSQL an instance of QCoreApplication is required for loading driver plugins
做了一个局域网验证与注册的工具,使用debug下可以正常使用,准备release打包的时候出错,报错 ()QSqlDatabase: QMYSQL driver not loadedQSqlDatabase: available drivers:QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins 因为在debug的情况下可以加载mysql驱动所以应该是第三条错误引发的问题,需要先排除前面两个的嫌疑 1 首先在pro文件中添加release调试的功能 QT 设置release调试 12QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFOQMAKE_LFLAGS_RELEASE = $$QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO 发现是connection的时候报错,应该是第三条报错导致的问题,在连接Mysql数据库前添加plugins文件夹的位置 解决方案:QS...
QT release MYSQL an instance of QCoreApplication is required for loading driver plugins
做了一个局域网验证与注册的工具,使用debug下可以正常使用,准备release打包的时候出错,报错 ()QSqlDatabase: QMYSQL driver not loadedQSqlDatabase: available drivers:QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins 因为在debug的情况下可以加载mysql驱动所以应该是第三条错误引发的问题,需要先排除前面两个的嫌疑 1 首先在pro文件中添加release调试的功能 QT 设置release调试 12QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFOQMAKE_LFLAGS_RELEASE = $$QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO 发现是connection的时候报错,应该是第三条报错导致的问题,在连接Mysql数据库前添加plugins文件夹的位置 解决方案:QS...
Creating WPF Window in Revit Multi-Version Library Project
WPF based on .Net Core First of all, I would like to recommend our Revit secondary development open source project RevitApiWrapper  In the open source framework, a multi-version generation framework is provided. Instead of using the original .netframework framework, it is changed to .net core framework. You can directly modify it. If you need custom modifications, you can refer to jimmy’s blog which provi...
Revit 多版本类库项目创建WPF窗体
WPF基于.Net Core 首先向大家安利一下我们的Reivt二次开发开源项目RevitApiWrapper  在开源的框架中,提供了一个多版本生成的框架,不再使用原有的.netframework框架改为.net core框架,可以直接拿过来修改一下,如果有需要自定义修改的可以参照jimmy的博客里面提供了基本的讲解和配置 .net core 项目 如何在类库项目中添加WPF窗体网络上有很多办法,添加WPF的typeid或者创建组件的形式,但是使用的时候发现都不可以在此框架使用,附上链接有需要的也可以参照博客修改尝试一下 设置C#类库项目中可以添加WPF元素在普通的”类库”项目中添加 WPF 的 Window 对象 通过项目创建一个类库项目,右键添加发现没有WPF窗口,可以打开csproj文件新建group,将下面的话添加进去。 12345678<Project Sdk="Microsoft.NET...
Using HOF Pattern for Transactions in Revit API
When reading the book “Functional Programming in C#”, I saw the concept of HOF. I felt that this method could be used to organize an extension method in the daily development process to achieve rapid calling of the program. Transaction function inherits from IDisposable We usually need to use using internal to operate Revit during development. Achieve automatic disassembly We need to create a generic function MTransaction and constrain it to the IDisposable interface Implement using keyword ...
Revit 二次开发 HOF 方式调用transaction
再看《C#函数式编程》一书的时候看到HOF的概念,感觉在日常开发的过程中可以使用此方式整理一个拓展方法,实现程序的快速调用。 Transaction函数继承自IDisposable 我们平时开发需要使用using内部对Revit进行操作。实现自动拆卸 我们需要创建一个泛型函数MTransaction并约束在IDisposable接口 在上述函数内部实现using关键词减少其他函数内部的反复调用,减少代码量降低耦合性 创建函数TransactionHelper对此放大引用封装,通过第三方调用中间函数即可完成调用 函数结构 123456789101112131415161718192021public static class MTransaction{ public static void Using<TDisp>(TDisp disposable, Action<TDisp> f) where TDisp : IDisposable { using (disposable) { ...
C++ Check if Process is Running
References: Find process ID by name and inject to it. Simple C++ example.C++ Get process handle by process name The function is mainly for the auto-update service, executing subsequent functions after detecting that the program has exited. When using the second reference, an error occurred. I found it was a stack overflow in the for loop, likely due to the field determination function, causing every program name to be judged correct. I recommend adopting the content from the first URL. code...
C++ 检测程序是否在运行
参考材料: Find process ID by name and inject to it. Simple C++ example.C++通过进程名获取进程句柄 函数原因主要是为了服务自动更新的函数,在检测到程序退出后执行后续函数。 使用第二个引用的时候报错,发现是for循环堆栈溢出,应该是字段判定函数的问题,导致每个程序的名称都判定正确,建议采取第一个网址中的内容。 code: 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667#pragma once#include <TlHelp32.h>class CheckApplication{public: CheckApplication();private: HANDLE getProcessHandle();public: int IsExit();private: const char* _Name ...
MFC Reference tinyxml, x64
I wanted to make a module that uses ftp for automatic updates. I needed to read xml documents and check against server data and then download. I thought I could solve it by following online tutorials, but I still encountered many problems in the middle. Here I record the steps. Configuration Visual Studio 2022 tinyxml, download link: TinyXML Steps Downloading the tinyxml package directly using nuget will eventually report an error, because the package is compiled for Win32, so an error will ...
MFC 引用tinyxml,x64
想做一个使用ftp自动更新的模块,需要读取xml文档并于服务器的数据核对然后下载,本以为按照网上的教程可以解决但是中间还是遇到了许多问题,这里就记录一下步骤。 配置 Visual Studio 2022 tinyxml,下载链接:TinyXML 步骤 直接使用nuget下载tinyxml包最后会报错,原因是包里面是Win32编译的,所以最后会出现错误 根据下载的包,使用visual studio打开,并新建配置管理器,在里面创建x64配置,之后编译tinyxml项目文件,可以一次性将Debug,Release版本编译 生成后将以下几个文件放到文件夹中方便后期引用 4. 完成这两步之后,进入项目->属性->C\C++->附加包含目录,将.cpp,.h文件夹添加进去5. 我们还需要再头文件中引用lib文件不然将会报错 1#pragma comment(lib,"D:\\C++ Programming\\MFCAutoUpdateApplication\\src\\tinyxml\\lib\\debug\\tinyxml.lib") 下面是...
Revit Auto Update - C++ FtpGetFiles()
For detailed explanation of FtpGetFiles() function see official documentation https://docs.microsoft.com/en-us/windows/win32/api/wininet/nf-wininet-ftpgetfilea Searching this function online found that introduction to this function is a bit scarce, so I put my successful execution code here hoping to help people learning together. Implementation method: Connect to server Get ftp connection handle Retrieve whether this file name exists in the project, if exists then download Use c++ to ...
Revit自动更新 - C++ FtpGetFiles()
FtpGetFiles()函数详细解释详见官方文档 https://docs.microsoft.com/en-us/windows/win32/api/wininet/nf-wininet-ftpgetfilea 网上搜这个函数发现这个函数介绍的有点少,所以将自己运行成功的代码放上来希望能够帮到一起学习的人。 实现方式: 链接服务器 获取ftp连接句柄 检索在项目中是否有此文件名称,如果存在则下载 使用c++ 操作ftp按照文档说法我们应当首先创建InternetOpen获取句柄,并将句柄传入函数InternetConnect函数,这一步与链接Mysql类似,获取了Connection句柄我们就可以使用Ftp的相关函数 123456789HINTERNET hint; HINTERNET hFtp; hint = InternetOpen(0, INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, 0); if (hint == NULL) return -1; hFtp = InternetConnect(hint, ftpSvrIp.c_...
git 推送发现远程仓库地址错误
问题:项目上传时总是首先上传一个错误的仓库地址然后才是当前仓库地址问题原因: 由于不懂git导致设置了git的globalconfig在全局设置中添加了默认路径,导致每次上传都会上传一次全局路径导致出现错误。 解决办法使用命令git remote -v 可以看到一直有一个origin存在,使用git remote rm origin 删除发现始终删除不掉这个路径调用命令git config --global --list,可以发现global的配置与local的配置中出现了两个origin的地址看来是我们在全局变量中设置了一个仓库地址,导致每次上传都会首先上传这个地址,所以需要将这个地址删除输入命令~/.gitconfig,在弹出的编辑器中将[remote 'origin']删除即可删除全部路径,再次上传即可按照本地当前remote地址上传
git push found remote repository address error
Issue: Project upload always uploads to a wrong repository address first and then to the current repository addressReason: Due to not understanding git, set git’s globalconfig adding a default path in global settings, causing every upload to upload to the global path first, resulting in an error. SolutionUse command git remote -v to see that there is always an origin existing. Use git remote rm origin to delete but found that this path cannot be deleted.Call command git config --global --list...
Creating Multi-Version Revit Projects (Part 2)
https://www.cnblogs.com/ponus/p/11046624.html#!comments You can visit the original author’s blog and github by following the link above. Here, the problems encountered during project migration were recorded according to my own situation. Multi-version Project Construction After creating a new project, open the configuration manager to create compilation managers for multiple versions  Unload the original...
Revit二次开发 创建适配多版本项目(2)
https://www.cnblogs.com/ponus/p/11046624.html#!comments 可以按照上方链接地址访问原作者博客和github 此处按照自己的情况记录了一下项目迁移时遇到的问题 多版本项目搭建 创建新项目后,打开配置管理器创建多个版本的编译管理器  卸载原有项目,打开*.csproj文件,按照版本号添加节点,此处可以限定编译的framwork版本,此处的编译可以将’Any CPU’修改为x64 12<PlatformTarget>x64</PlatformTarget><TargetFrameworkVersion>v4.6</TargetFrameworkVersion> 依次将所有版本设置好之后可以继续在<ItemGroup>添加项目初始时需要添加的引用,此处我将Revit的ManagedMC3文件一起放进去了,因为会...
Solved - Newly Created Elements Cannot Join Geometry in Revit API
Problem Scenario:Implement the function of blocking walls between beams. After I create a wall, I hope to connect the upper beam with the wall to present a better visual effect, but when I directly use joinGeometry after creating the wall, an error will be reported indicating that connection is not possible. Solution:Regenerate the document. Code: 123456789101112131415161718using (Transaction trans = new Transaction(doc,"Create Close Wall")) { trans.St...
Revit二次开发 新创建构件无法使用JoinGeometry等问题
问题场景:实现梁间墙封堵的功能,在我创建墙后希望将上部梁与墙连接处理,呈现更好的视觉效果,但是在我创建墙体后直接使用joinGeometry将会报错无法连接。解决办法:刷新一下文档 代码: 123456789101112131415161718using (Transaction trans = new Transaction(doc,"Create Close Wall")) { trans.Start(); //Wall Type var duplicate = CreateWallType(doc,wallWidth, $"FBQ - {Math.Round(wallWidth * 304.8)}"); var nWall = Wall.Create(doc, locationCurve, duplicate.Id, tLevel, value, 0, false,...








