所以当点击"添加播放器"按钮时,我有以下代码
private void addPlayerBtn_Click_1(object sender, EventArgs e)
{
//Do some code
}
Run Code Online (Sandbox Code Playgroud)
我想从我的SDK中触发此代码.这是我尝试过的
private void command()
{
addPlayerBtn_Click_1(object sender, EventArgs e);
}
Run Code Online (Sandbox Code Playgroud)
一旦我放入线路,我就会收到很多错误
addPlayerBtn_Click_1(object sender, EventArgs e)
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我如何编写代码,以便我可以通过在代码中写入来触发事件吗?
作为编程新手我刚刚发现你可以专门捕获某些类型的错误并将代码绑定到那种类型的错误.
我一直在研究这个主题,我不太明白语法,例如
catch (InvalidCastException e)
{
}
Run Code Online (Sandbox Code Playgroud)
我理解InvalidCastException正在处理的错误类型,但我不确定是什么e.
有人可以解释一下吗?
我正在创建一个win8应用程序,我需要更改网格的布局,以便当用户在方向之间切换时一切都适合在屏幕上。我知道我需要使用,VisualStateManager但我听不懂任何教程。如果我有此代码:
<Grid>
<Button x:Name="button1" Margin="188,73,286,0" VerticalAlignment="Top"/>
<Button x:Name="button2" Margin="236,73,238,0" VerticalAlignment="Top"/>
<Button x:Name="button3" Margin="284,73,190,0" VerticalAlignment="Top"/>
</Grid>
Run Code Online (Sandbox Code Playgroud)
当方向从横向更改为纵向时,我将如何使用可视状态管理器来更改按钮,使其现在以一列(一个在另一个之上)而不是在行中定向?
谢谢
我必须使用C#打开最大化的Internet Explorer.我尝试过以下方法:
try
{
var IE = new SHDocVw.InternetExplorer();
object URL = "http://localhost/client.html";
IE.ToolBar = 0;
IE.StatusBar = true;
IE.MenuBar = true;
IE.AddressBar = true;
IE.Width = System.Windows.Forms.SystemInformation.VirtualScreen.Width;
IE.Height = System.Windows.Forms.SystemInformation.VirtualScreen.Height;
IE.Visible = true;
IE.Navigate2(ref URL);
ieOpened = true;
break;
}
catch (Exception)
{
}
Run Code Online (Sandbox Code Playgroud)
我可以打开不同的大小,但我找不到如何打开最大化的IE.我检查了msdn,没有属性可以最大化.
请给我一些建议.
PS:我正在开发C#控制台应用程序,.Net4.5和VS2012
我想将double转换为科学记数法,如下所示:
-0.00752382528 => -.752383E-1
Run Code Online (Sandbox Code Playgroud)
我可以用.ToString()或Regex做到这一点吗?
我试图从xml文件中读取值,然后使用bulkcopy将数据插入到我的数据库中.
我正在使用一个自定义类:
class Customer
{
public int CustomerID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public int ShowsNumber { get; set; }
public int VisitNumber { get; set; }
public int Cancellation { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我读了这样的数据:
List<Customer> customersList =
(
from e in XDocument.Load(file).Root.Elements("cust")
select new Customer
{
CustomerID = (int)e.Attribute("custid"),
FirstName = (string)e.Attribute("fname"),
LastName = (string)e.Attribute("lname"),
ShowsNumber = (int)e.Attribute("count_noshow"),
VisitNumber = (int)e.Attribute("count_resos"),
Cancellation = (int)e.Attribute("count_cancel"),
}).ToList(); …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Chartist.js框架为我的网站创建图表。但是由于某些原因,我不断收到错误“未定义Chartist”
我不知道如何解决此错误。请参见下面的代码:
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/chartist.js/latest/chartist.min.js"></script>
<link href="https//cdn.jsdelivr.net/chartist.js/latest/chartist.min.css" rel="stylesheet" type="text/css" />
<link href='http://fonts.googleapis.com/css?family=Oxygen:300' rel='stylesheet' type='text/css'>
<meta charset="utf-8">
<title>Chartist.js - Simple line chart</title>
<script>
// THIS IS WHERE THE ERROR OCCURS
new Chartist.Line('.ct-chart', {
labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
series: [
[2, 3, 2, 4, 5],
[0, 2.5, 3, 2, 3],
[1, 2, 2.5, 3.5, 4]
]
}, {
width: 500,
height: 300
});
</script>
</head>
<body>
<div class="ct-chart"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
有人知道我在做什么错吗?提前致谢。
我有一个bool叫attack我Q按下按钮时设置为true (Q是攻击)
我用断点试图自己解决问题.设置attack为true 的代码行正在运行,但实际上并没有设置attack为true ...我是XNA的新手,很抱歉,如果这是一个明显的解决方案.这是代码.. :( ps我遗漏了很多与问题无关的代码)
public class Player
{
Animation playerAnimation = new Animation();
public void Update(GameTime gameTime)
{
keyState = Keyboard.GetState()
if (keyState.IsKeyDown(Keys.Q))
{
tempCurrentFrame.Y = 0;
*** playerAnimation.Attack = true; *** This line of code runs yet doesn't actually work
}
public class Animation
{
bool attack;
public bool Attack
{
get { return attack; }
set { value = attack; }
}
public void Update(GameTime …Run Code Online (Sandbox Code Playgroud) 我试图用两个按钮创建一个自定义控件(例如)。我有一个Generic.Xaml文件,看起来像这样
<Style TargetType="local:DoubleButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:DoubleButton">
<Grid>
<Button x:Name="leftButton" Click="leftButtonClick" />
<Button x:Name="rightButton" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
DoubleButton类如下所示:
public sealed class DoubleButton : Control
{
public DoubleButton()
{
this.DefaultStyleKey = typeof(DoubleButton);
}
public void leftButtonClick(object sender, RoutedEventArgs e)
{
MessageDialog dlg = new MessageDialog("message");
}
}
Run Code Online (Sandbox Code Playgroud)
但是这种方法永远不会被调用。如果有人对如何为自定义控件引发事件有个好主意。
谢谢
我知道很少Xaml/WPF.我正在尝试Style在Windows 8 metro应用程序中设计一个Button具有洋红色背景的自定义,并且在按下时,具有蓝色背景.我知道我需要使用VisualStateManager但我找不到任何在线对任何人有意义的东西对这个问题知之甚少.有很多假设的知识.这是我到目前为止所得到的:
<Style x:Name="test" TargetType="Button">
<Setter Property="Background" Value="Magenta"/>
<Setter Property="Content" Value="Test style" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Pressed">
<Storyboard>
<turn the background blue>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
这段代码可能是非常错误的,但正如我所说,我一直试图修补一些我不理解的信息以创造结果.
感谢您的时间
c# ×8
windows-8 ×3
xaml ×3
wpf ×2
angularjs ×1
chartist.js ×1
double ×1
events ×1
javascript ×1
linq ×1
linq-to-xml ×1
shdocvw ×1
sqlbulkcopy ×1
try-catch ×1
winrt-xaml ×1
xna ×1