我正在寻找一个existign路径截断算法(类似于Win32静态控件所做的SS_PATHELLIPSIS),用于一组应该关注不同元素的路径.
例如,如果我的路径是这样的:
Unit with X/Test 3V/
Unit with X/Test 4V/
Unit with X/Test 5V/
Unit without X/Test 3V/
Unit without X/Test 6V/
Unit without X/2nd Test 6V/
Run Code Online (Sandbox Code Playgroud)
当没有足够的显示空间可用时,应将它们截断为如下所示:
...with X/...3V/
...with X/...4V/
...with X/...5V/
...without X/...3V/
...without X/...6V/
...without X/2nd ...6V/
Run Code Online (Sandbox Code Playgroud)
(假设省略号通常比三个字母短).
这只是一个相当简单,理想情况的例子(例如,它们现在都以不同的长度结束,当一条路径"Thingie/Long Test /"被添加到路径时,我不知道如何创建一个好的建议游泳池).
路径元素没有给定的结构,它们由用户分配,但是项目通常具有相似的段.它应该适用于比例字体,因此算法应采用度量函数(而不是大量调用)或生成建议列表.
在数据方面,典型的用例将包含2..4个路径段和每个段20个元素.
我正在寻找以前尝试这个方向,如果这是可以解决的合理数量的代码或依赖.
与C#中的PathCanonicalize相同的是什么?
使用:我需要好好猜测两个文件路径是否引用同一个文件(没有磁盘访问).我的典型方法是通过一些过滤器(如MakeAbsolute和PathCanonicalize)抛出它,然后进行不区分大小写的比较.
对于静态Win32库,如何检测是否设置了任何"使用MFC"选项?
即
#ifdef ---BuildingForMFC---
....
#else
...
#endif
Run Code Online (Sandbox Code Playgroud) 我有一个包含两个表,产品和许可证的数据库.Licences.ProductID有外键引用Products.ProductID(即该产品的许可证).
如何在WinForms DataGridView中表示该关系?
在向DataGridView(SQL Metal和通过LINQ to SQL)提供ProductLicences.ProductID时,它会自动生成一个包含文本字段的列,该字段需要"Product"(当然我无法输入...).
如何更改此列以包含列出可用产品的组合框?
我有一个连接(继承自Linq.DataContext),分配给DataGridView的数据源是a Link.IQueryable,生成如下:
var ds = from c in m_connection.Licences
select c;
Run Code Online (Sandbox Code Playgroud) 当使用CreateWindow动态创建控件(例如编辑控件)时,它通常以丑陋(粗体无衬线字体)字体开始.
通常我通过抓住父对话框的字体并将其设置为控件来解决这个问题 - 我甚至不能说这是不是一个好主意.
我如何"合法"获取正确的字体?
我试过的查询:ExpandEnvironmentStrings("%COMMONPROGRAMFILES%"), GetSpecialPath(CSIDL_PROGRAM_FILES_COMMON).
所有解析(通常)c:\\Program Files (x86)\\Common Files来自我的32位应用程序.我需要检查c:\\Program Files\\Common Files64位应用程序下安装的文件版本(通常).
以下代码给出了一个错误:
// GetDirectoryList() returns Dictionary<string, DirectoryInfo>
Dictionary<string, DirectoryInfo> myDirectoryList = GetDirectoryList();
// The following line gives a compile error
foreach (Dictionary<string, DirectoryInfo> eachItem in myDirectoryList)
Run Code Online (Sandbox Code Playgroud)
它给出的错误如下:
Cannot convert type 'System.Collections.Generic.KeyValuePair<string,System.IO.DirectoryInfo>' to 'System.Collections.Generic.Dictionary<string,System.IO.DirectoryInfo>’
Run Code Online (Sandbox Code Playgroud)
我的问题是:为什么要尝试执行此转换?我可以不在这种类型的对象上使用foreach循环吗?
为什么需要两种形式?谢谢
explicit auto_ptr (T* ptr = 0) throw()
auto_ptr (auto_ptr& rhs) throw()
template<class Y>
auto_ptr (auto_ptr<Y>& rhs) throw()
auto_ptr& operator= (auto_ptr& rhs) throw()
template<class Y>
auto_ptr& operator= (auto_ptr<Y>& rhs) throw()
Run Code Online (Sandbox Code Playgroud) https://www.godbolt.org/z/_4aqsF:
template <typename T> struct Container
{
template <typename TPred> T find_if(TPred pred); // the culprit
};
template <typename T> Container<T> MakeContainer(T const &)
{
return Container<T>();
}
int main()
{
auto x = MakeContainer("Hello!");
}
Run Code Online (Sandbox Code Playgroud)
gcc,clang和msvc显然同意这不能编译,因为find_if将返回一个数组.
(我会假设成员模板没有实例化,因为它没有被使用 - 显然,这种简单化的观点是错误的.)
为什么SFINAE不适用于此?
有没有办法排除T不是可退回类型的类型的成员模板?
在XML文档中对C#的注释中,有没有办法将两个或多个函数标记为彼此重载,以便它们自动引用?理想情况下,它们也会以某种方式分组在沙堡生成的文档中.
目的:通常,我想链接到这组功能,例如在效用函数列表中,只提一个重载,并使其他功能很容易从那里发现.
目前我正在添加链接,但这很乏味.
c# ×4
c++ ×4
winapi ×2
algorithm ×1
datagridview ×1
dictionary ×1
filenames ×1
fonts ×1
generics ×1
linq ×1
mfc ×1
overloading ×1
path ×1
sandcastle ×1
sfinae ×1
stl ×1
string ×1
template-argument-deduction ×1
templates ×1
windows ×1
winforms ×1
wow64 ×1
xml-comments ×1