我希望有一个C#应用程序实现Konami代码来显示复活节彩蛋. http://en.wikipedia.org/wiki/Konami_Code
做这个的最好方式是什么?
这是一个标准的C#windows窗体应用程序.
对于我的课,我必须创建一个类似于bash的基本shell,允许用户调用ls,sleep等命令.我正在寻找有关如何执行此操作的资源:教程,帮助文本,示例代码甚至只是一些关于如何入门的一般信息.有没有人有链接或信息来帮助我?
我们正在开发WPF中的UI控件,以便在现有的Windows Forms/MFC应用程序引擎(Rhino 3D)中使用.
应用程序引擎公开了创建"Dockbar"的能力,它实际上允许您将Windows窗体控件放在可以停靠到Engines接口的子窗口中.
我试图将一个简单的WPF TextBox放在一个ElementHost控件中,该控件被添加到Dockbar中.乍一看似乎工作得很好; 但在尝试输入TextBox后,只有某些序列实际显示在TextBox中.该DELETE,BACKSPACE,COPY,PASTE,并选择文本的工作.如果您键入AZ,1-9等,则这些键不会显示.
我有SCOURED网,并听说过,ElementHost.EnableModelessKeyboardInterop()但这仅适用于从表单创建的WPF Windows.我只创建WPF UserControls并在ElementHost控件中托管它们.
我看到一篇关于Dispatcher.Run()的帖子,它有点工作但是打破了表单的其余部分:
System.Windows.Threading.Dispatcher.Run();
Run Code Online (Sandbox Code Playgroud)
该PreviewKeyUp,PreviewKeyDown,KEYUP和的KeyDown事件的所有火上的文本框,但很可惜没有文字在文本框中显示出来.
我对Windows消息了解不多,但是使用WinSpector我注意到没有WM_GETTEXT消息来自TextBox(如果它们甚至应该是我不知道的话).
我还创建了一个新的Windows窗体项目,并在那里做了同样的事情,它工作正常,所以它必须是如何在Rhino 3D引擎中创建和停靠窗口的问题.
以下是不起作用的示例代码:
ElementHost el = new ElementHost();
System.Windows.Controls.TextBox t = new System.Windows.Controls.TextBox();
t.Width = 100;
t.Text = "TEST";
el.Child = t;
panel1.Controls.Add(el);
Run Code Online (Sandbox Code Playgroud) 我有以下结构
List<string[]> sList = new List<string[]>() {
new[] { "x", "xxx", "xxxx" }, //1,3,4
new[] { "x", "xx", "xx" }, //1,2,2
new[] { "xxxxxx", "xx", "xx" } //6,2,2
};
Run Code Online (Sandbox Code Playgroud)
我需要string.length按列确定项目的最大值
在此示例中,预期结果应为:
List<int> Result = new List<int>() { 6, 3, 4 };
Run Code Online (Sandbox Code Playgroud)
有一个简单的Linq方法吗?
我的努力(工作但不使用Linq):
List<int> Result = new List<int>();
foreach (string[] line in Table)
{
for (int i = 0; i < line.Length; i++)
{
if (Result.Count > i)
{
if (Result[i] < line[i].Length)
{
Result[i] …Run Code Online (Sandbox Code Playgroud) 我想找到今天的日期,但它应该是2年前.例如今天的日期是2010年6月12日,但我想要6/12/2008.我怎么能在SQL服务器上这样做?
我正在尝试使用以下命令将数据加载到AWS redshift中
copy venue from 's3://mybucket/venue'
credentials 'aws_access_key_id=<access-key-id>;aws_secret_access_key=<secret-access-key>'
delimiter '\t';
Run Code Online (Sandbox Code Playgroud)
但数据加载失败,当我检查查询部分的特定加载时,我发现它失败了,原因是"错误的UTF8十六进制序列:a4(错误3)"
有没有办法将数据加载中的错误记录跳转到redshift?
我下面的代码给了我一个NullReferenceException和堆栈跟踪告诉我问题在于Count方法,所以我很确定在某个时候foo,bar或者baz是null.
我的代码:
IQueryable<IGrouping<string, Referral>> queryable= ...;
var dict = queryable.ToDictionary(g => g.Key.ToString(),
g => g.Count(r => r.foo.bar.baz.dummy == "Success"));
Run Code Online (Sandbox Code Playgroud)
我想知道处理null案件的简洁方法是什么.我知道在C#6.0中我可以做到foo?.bar?.baz?.dummy,但我正在研究的项目不是C#6.0
你能解释一下这段奇怪的代码吗?
expression.Compile()();
Run Code Online (Sandbox Code Playgroud)
为什么这里有两对括号?我没有在谷歌找到任何东西.完整的方法是
public Validator NotEmpty(Expression<Func<IEnumerable<T>>> expression)
{
var member = (MemberExpression)expression.Body;
string propertyName = member.Member.Name;
IEnumerable<T> value = expression.Compile()();
if (value == null || !value.Any())
{
ValidationResult.AddError(propertyName, "Shouldn't be empty");
}
return this;
}
Run Code Online (Sandbox Code Playgroud)
它是这样使用的:
_validator.NotEmpty(() => request.PersonIds); // request.PersonIds is List<int>
Run Code Online (Sandbox Code Playgroud)
此方法检查集合是空还是空.一切正常,但我对该代码有点困惑.我以前从未见过在C#中使用过两对括号.这是什么意思?
我有一个ResourceDictionary,其中包含我的应用程序中使用的控件的样式定义.
所有样式都适用于窗口中的控件...但是不应用ResourceDictionary中窗口本身的样式.
这是我的ResourceDictionary中的XAML,其中包含我要应用于窗口的样式:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:primatives="clr-namespace:System.Windows.Controls.Primitives;assembly=PresentationFramework"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="{x:Type Window}">
<Setter Property="Background" Value="#FF121212"></Setter>
<Setter Property="Height" Value="768"></Setter>
<Setter Property="Width" Value="1024"></Setter>
</Style>
<!-- .... -->
</ResourceDictionary>
Run Code Online (Sandbox Code Playgroud)
这是我正在使用的窗口的XAML(尝试使用此样式):
<Window x:Class="TryingStyles"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="TryingStyles">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/StylesDictionary.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="Label" Height="28" HorizontalAlignment="Left" Margin="12,12,0,0" Name="Label1" VerticalAlignment="Top" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="56,14,0,0" Name="TextBox1" VerticalAlignment="Top" Width="120" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TabControl Height="206" HorizontalAlignment="Left" Margin="12,43,0,0" Name="TabControl1" VerticalAlignment="Top" Width="250">
<TabItem Header="TabItem1" Name="TabItem1">
<Grid></Grid>
</TabItem>
</TabControl>
<GroupBox Header="GroupBox1" Margin="268,43,12,12" Width="396"></GroupBox>
</StackPanel>
</StackPanel> …Run Code Online (Sandbox Code Playgroud) 我想关闭我正在使用的当前表单(MainForm),然后打开第二个表单(Form).
我试过了:
private void buttonStartQuiz_Click(object sender, EventArgs e)
{
this.Close();
Form2 form2 = new Form2();
form2.ShowDialog();
}
Run Code Online (Sandbox Code Playgroud)
或者添加this.Close();后form2.ShowDialog()也不起作用.
任何提示?
编辑:也可以通过this.Close()在form2.ShowDialog()关闭新表单后关闭它来添加它.如果我选择form2.Show()它会立即关闭两个表格.