我最近遇到了为我的wpf应用程序创建添加和编辑对话框的问题.
我想在代码中做的就是这样.(我主要使用viewmodel第一种方法与mvvm)
调用对话框窗口的ViewModel:
var result = this.uiDialogService.ShowDialog("Dialogwindow Title", dialogwindowVM);
// Do anything with the dialog result
Run Code Online (Sandbox Code Playgroud)
它是如何工作的?
首先,我创建了一个对话服务:
public interface IUIWindowDialogService
{
bool? ShowDialog(string title, object datacontext);
}
public class WpfUIWindowDialogService : IUIWindowDialogService
{
public bool? ShowDialog(string title, object datacontext)
{
var win = new WindowDialog();
win.Title = title;
win.DataContext = datacontext;
return win.ShowDialog();
}
}
Run Code Online (Sandbox Code Playgroud)
WindowDialog是一个特殊而简单的窗口.我需要它来保留我的内容:
<Window x:Class="WindowDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Title="WindowDialog"
WindowStyle="SingleBorderWindow"
WindowStartupLocation="CenterOwner" SizeToContent="WidthAndHeight">
<ContentPresenter x:Name="DialogPresenter" Content="{Binding .}">
</ContentPresenter>
</Window>
Run Code Online (Sandbox Code Playgroud)
wpf中对话框的问题是dialogresult = true只能在代码中实现.这就是为什么我为我dialogviewmodel实现它的界面.
public class …Run Code Online (Sandbox Code Playgroud) 我编写了一个应用程序及其WiX安装程序,并使用subversion将其置于版本控制之下.当WiX安装程序构建时,我希望其版本号是应用程序的当前构建版本.我该如何做到这一点?我使用c#来编写应用程序代码.
NB我正在使用ccnet来构建这个项目
我正在使用Inno Setup生成我的应用程序的安装程序.如何设置VersionInfoVersionInno生成的setup.exe()的版本号自动匹配我的应用程序的版本号?现在,每次部署新版本的应用程序时,我都需要手动更新版本号.
现在我这样做:
[Setup]
VersionInfoVersion=1.2.2.0 //writing the value manually
Run Code Online (Sandbox Code Playgroud)
我想要这样的东西:
[Setup]
VersionInfoVersion={Get the version of my app}
Run Code Online (Sandbox Code Playgroud) 有没有人知道确定字符串值是否"合格"为浮点数的便捷方法?
bool IsFloat( string MyString )
{
... etc ...
return ... // true if float; false otherwise
}
Run Code Online (Sandbox Code Playgroud) 我希望在共享软件的基础上实现我的软件,以便为用户提供最长的试用期(比方说)30天,以便试用该软件.在购买时,我打算给用户一个随机生成的密钥,输入时再次启用该软件.
我以前从来没有走过这条路,所以任何建议或反馈或指向"标准"方法的指示都将非常感激.
我不期望用户通过更改系统日期或类似的东西来作弊,尽管这可能值得考虑.如果此话题出现过,请道歉.
任何人都可以建议一种从字符串中剥离制表符("\ t")的方法吗?CString或std :: string.
例如,"1E10"变为"1E10".
谢谢你的期待.
我想知道是否有办法克服精确度问题,这似乎是我的机器内部表示浮点数的结果:
为清楚起见,问题归纳为:
// str is "4.600"; atof( str ) is 4.5999999999999996
double mw = atof( str )
// The variables used in the columns calculation below are:
//
// mw = 4.5999999999999996
// p = 0.2
// g = 0.2
// h = 1 (integer)
int columns = (int) ( ( mw - ( h * 11 * p ) ) / ( ( h * 11 * p ) + g ) ) + 1;
Run Code Online (Sandbox Code Playgroud)
在转换为整数类型之前,列计算的结果是1.9999999999999996; 距离2.0的理想结果还差不多.
任何建议最受欢迎.
我正在使用XAML创建一个对象树,其中一个节点如下所示:
public class ExecuteMethod : INode
{
#region Implementation of INode
public bool Evaluate()
{
return Function != null && Function();
}
public string Name { get; set; }
private string _type;
public string Type
{
get
{
if (string.IsNullOrEmpty(_type))
{
_type = GetType().Name;
}
return _type;
}
}
#endregion
public Func<bool> Function { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我的目标是使XAML和代码尽可能干净是必不可少的,现在我不是在为每个函数创建包装器属性:
public static Func<bool> Func1 { get { return Method1; } }
public static bool Method1()
{
//Do stuff here
return true; …Run Code Online (Sandbox Code Playgroud) 我做递归以在List中找到一个具有多个子节点的长值,这些子节点也可以有子节点.
以下方法:
public TaxonomyData getTaxonomyData(long taxId, List<TaxonomyData> TaxonomyTree, TaxonomyData output)
{
//find taxid in the taxonomy tree list and return the taxonomydata
foreach (TaxonomyData td in TaxonomyTree)
{
if (td.TaxonomyId == taxId)
{
output = td;
//return td; => when doing a return here means I already found a match so it is not necessary to do all the recursion.
}
else if (td.Taxonomy.Length > 0)
{
getTaxonomyData(taxId, td.Taxonomy.ToList(), output);
}
}
return output;
}
Run Code Online (Sandbox Code Playgroud)
有可能当我这样做return td;(见注释行)我的整个递归停止了吗?
谢谢
我想找到在C++中实现三维整数数组的安全方法,使用指针算术/动态内存分配,或者使用STL矢量等技术.
基本上我希望我的整数数组维度看起来像:
[ x ][ y ][ z ]
Run Code Online (Sandbox Code Playgroud)
x和y在20-6000范围内是已知的并且等于4.