这可能是一个基本问题,但我必须承认,我从未真正理解Control.Enter和Control.GotFocus事件之间的区别.
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.enter.aspx http://msdn.microsoft.com/en-us/library/system.windows.forms.control .gotfocus.aspx
它是捕获键盘或鼠标输入或其他东西之间的区别?
我正在使用xsd.exe从.xsd文件生成一些c#类.我遇到了此处和其他网站上涉及的相同问题,其中xsd.exe生成Type []数组,而不是.xsd文件中类型的通用List集合.有些人建议如果将/ dataContractOnly参数传递给svcutil.exe,svcutil.exe可以用作xsd.exe的替代品.但是,似乎这些人都错了,因为svcutil.exe实际上生成了System.Xml.XmlNode []数组属性,而不是基于.xsd文件中的模式创建类型.
例如,给定这个简单的.xsd架构:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/XMLSchema.xsd"
xmlns:mstns="http://tempuri.org/XMLSchema.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xs:complexType name="Employee">
<xs:all>
<xs:element name="FirstName" type="xs:string"></xs:element>
<xs:element name="LastName" type="xs:string"></xs:element>
</xs:all>
</xs:complexType>
<xs:element name="Employees">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element name="Employee" type="Employee"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)
'xsd.exe/classes Example.xsd'生成:
public partial class Employees {
private Employee[] employeeField;
public Employee[] Employee {
get { return this.employeeField; }
set { this.employeeField = value; }
}
}
public partial class Employee {
private string firstNameField;
private string lastNameField;
public string FirstName { …Run Code Online (Sandbox Code Playgroud) 我试图在Windows上找到与stdout相关的数据限制的一些信息.我似乎无法在MSDN上找到相关信息.
可以将多少数据写入stdout是否有限制?如果是这样,如果达到限制会发生什么?数据丢失了吗?
如果重定向stdout(例如,通过从.Net启动进程并使用ProcessStartInfo.RedirectStandardOutput属性),这对可以写入多少数据有影响吗?当我从调用过程中的stdout流中读取时,这是否会影响限制?
这些限制是否与命名管道有关?
我有一个类,它包含对Hashtable的引用,并序列化/反序列化该Hashtable.在调用SerializationInfo.GetValue之后,Hashtable没有完全反序列化,因为反序列化在IDeserialization calback期间发生.
Hashtable hashtable = (Hashtable) info.GetValue("hash", typeof(Hashtable));
Run Code Online (Sandbox Code Playgroud)
我还在父类中实现了IDeserialization回调,但是Hashtable也没有完全反序列化.我预计如果反序列化是从内到外发生的话.
我的问题是,从我的父类的OnDeserialization方法中明确地调用Hashtable.OnDeserialization是否安全,以便我可以在那时枚举它?
public virtual void OnDeserialization(object sender)
{
hashtable.OnDeserialization(sender);
}
Run Code Online (Sandbox Code Playgroud) 如果我在PHP中定义一个接口,以及一个创建该接口实例的工厂类,有什么办法可以强制客户端代码只使用接口而不是底层的具体类?根据我的理解,客户端也能够实际使用底层类中的任何公共函数/字段.
这是一个例子:
<?php
interface IMyInterface
{
public function doSomething();
}
?>
<?php
class ConcreteImplOfMyInterface implements IMyInterface
{
const NotPartOfInterface = 'youcantseeme';
public function doSomething()
{
}
}
?>
<?php
class MyInterfaceFactory
{
public static function createMyInterface()
{
return new ConcreteImplOfMyInterface();
}
}
?>
<?php
function client()
{
$myInterface = MyInterfaceFactory::createMyInterface();
return $myInterface::NotPartOfInterface;
}
?>
Run Code Online (Sandbox Code Playgroud) 使用.Net 3.5中的System.Speech.Synthesis.SpeechSynthesizer类,SpeakProgressEventArgs的AudioPosition属性似乎不准确.
以下代码生成以下输出:
码:
using System;
using System.Speech.Synthesis;
using System.Threading;
namespace SpeechTest
{
class Program
{
static ManualResetEvent speechDoneEvent = new ManualResetEvent(false);
static void Main(string[] args)
{
SpeechSynthesizer synthesizer = new SpeechSynthesizer();
synthesizer.SpeakProgress += new EventHandler<SpeakProgressEventArgs>(synthesizer_SpeakProgress);
synthesizer.SpeakCompleted += new EventHandler<SpeakCompletedEventArgs>(synthesizer_SpeakCompleted);
synthesizer.SetOutputToWaveFile("Test.wav");
synthesizer.SpeakAsync("This holiday season, support the music you love by shopping at Made in Washington, online and at one of five local stores. Made in Washington chocolates, bountiful gift baskets and ornaments are the perfect holiday gifts for family, friends …Run Code Online (Sandbox Code Playgroud) 我在.NET 2.0上使用System.Windows.Forms.ListView控件.我知道我可以将ListView上的OwnerDraw属性设置为true,然后重写OnDrawItem以自定义绘制我的ListViewItems.我还可以重写OnDrawColumnHeader和OnDrawSubItem来绘制这些组件.
但是,如果我想自定义绘制ListViewGroups,则没有等效的"OnDrawGroup"方法来覆盖.
我简要地看了一下这个控件使用的消息,我看到有WM_CUSTOMDRAW和CDDS_ITEMPREPAINT通知,但我想知道如果我处理这些本机消息来自定义绘制我的ListViewGroups有一种方法吗?
我正在尝试使用System.Drawing.Drawing2D.GraphicsPath.AddArc绘制一个从0度开始并扫描到135度的椭圆弧.
我遇到的问题是,对于椭圆,绘制的弧与我期望的不匹配.
例如,以下代码生成下面的图像.绿色圆圈是我希望弧的终点使用椭圆点的公式.我的公式适用于圆圈,但不适用于椭圆.
这与极坐标与笛卡尔坐标有关吗?
private PointF GetPointOnEllipse(RectangleF bounds, float angleInDegrees)
{
float a = bounds.Width / 2.0F;
float b = bounds.Height / 2.0F;
float angleInRadians = (float)(Math.PI * angleInDegrees / 180.0F);
float x = (float)(( bounds.X + a ) + a * Math.Cos(angleInRadians));
float y = (float)(( bounds.Y + b ) + b * Math.Sin(angleInRadians));
return new PointF(x, y);
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Rectangle circleBounds = new Rectangle(250, 100, 500, 500);
e.Graphics.DrawRectangle(Pens.Red, circleBounds);
System.Drawing.Drawing2D.GraphicsPath circularPath = …Run Code Online (Sandbox Code Playgroud) 我试图在WinForms中使用MVP,并对如何最好地处理子视图之间的协调感到困惑.
例如,我有一个父视图,它有两个子视图.一个子视图上的事件需要导致第二个子视图执行操作.
父视图应该直接控制吗?这似乎是我绕过了MVP模式.
或者子视图是否应该将彼此作为构造函数参数?在这种情况下,当第一个子视图触发事件时,第二个子视图将收到该事件,然后通知其演示者发生了什么事情?然后,演示者需要从第一个子视图(它甚至不知道)获取数据,以便告诉第二个子视图要做什么.这似乎令人费解,所以我觉得我错过了一些东西.
这是针对这种情况的一些伪代码:
public class ParentView : UserControl, IParentView
{
private ChildViewOne childViewOne;
private ChildViewTwo childViewTwo;
private ParentViewPresenter presenter;
private RegisterEvents()
{
childViewOne.EventOccured += new EventHandler(HandleEvent);
}
private void HandleEvent()
{
childViewTwo.DoSomething();
}
}
Run Code Online (Sandbox Code Playgroud) 如果我有一个以30fps播放的视频,那么每帧的持续时间是1/30秒或33.333333 ......毫秒.
假设您正在实施视频播放器,您将如何处理每帧的持续时间由重复小数表示的事实?
例如,如果将前29帧的持续时间截断为33.33毫秒,则第30帧的持续时间必须略长,为33.43毫秒,以保持30fps的速率.
视频播放软件是否采用标准方式处理此问题?
我有一个具体的类,其中包含另一个具体类的集合.我想通过接口公开这两个类,但是我无法弄清楚如何将Collection <ConcreteType>成员公开为Collection <Interface>成员.
我目前正在使用.NET 2.0
下面的代码导致编译器错误:
无法将类型'System.Collections.ObjectModel.Collection <Nail>'隐式转换为'System.Collections.ObjectModel.Collection <INail>'
注释的演绎尝试给出了这个编译错误:
无法
通过引用转换,装箱转换,拆箱转换,换行转换或空类型转换将类型'System.Collections.ObjectModel.Collection <Nail>'转换为'System.Collections.ObjectModel.Collection <INail>'.
有没有办法将具体类型的集合公开为接口集合,还是需要在接口的getter方法中创建新集合?
using System.Collections.ObjectModel;
public interface IBucket
{
Collection<INail> Nails
{
get;
}
}
public interface INail
{
}
internal sealed class Nail : INail
{
}
internal sealed class Bucket : IBucket
{
private Collection<Nail> nails;
Collection<INail> IBucket.Nails
{
get
{
//return (nails as Collection<INail>);
return nails;
}
}
public Bucket()
{
this.nails = new Collection<Nail>();
}
}
Run Code Online (Sandbox Code Playgroud)