本文整理汇总了C#中System.Windows.Forms.Command类的典型用法代码示例。如果您正苦于以下问题:C# Command类的具体用法?C# Command怎么用?C# Command使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Command类属于System.Windows.Forms命名空间,在下文中一共展示了Command类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnExecute
protected override void OnExecute(Command command, ExecutionContext context, System.Drawing.Rectangle buttonRect)
{
double lengthConversion = ActiveWindow.Units.Length.ConversionFactor;
bool isImperial = Booleans[Resources.IsImperial].Value;
bool isInternal = Booleans[Resources.ThreadIsInternal].Value;
double pitch = isImperial ? (Const.inches / Values[Resources.ThreadPitch].Value) : (1E-3 * Values[Resources.ThreadPitch].Value);
double angle = Values[Resources.ThreadAngle].Value * Math.PI / 180;
Body[] bodies = SpaceClaimExtensions.GetAllSelectedIDesignFaces(Window.ActiveWindow)
.Where(f => f.Shape.Geometry is Cylinder)
.Select(f => f.Master.Parent.Shape.CopyFaces(new[] { f.Master.Shape }))
.Select(b => b.Faces.First())
.Select(f => CreateThreads(f, pitch, angle, isInternal))
.ToArray();
Part part = Window.ActiveWindow.Scene as Part;
foreach (Body body in bodies)
DesignBody.Create(part, Resources.ThreadStructureText, body);
Settings.Default.IsImperial = isImperial;
Settings.Default.IsInternal = isInternal;
Settings.Default.Pitch = isImperial ? 0.0254 / pitch : pitch / 1E3;
Settings.Default.Angle = angle * 180 / Math.PI;
Settings.Default.Save();
}
示例2: Parse
// Command cmd = Command.Parse("1,a->b,R/L/N,0");
public static Command Parse(string commandString)
{
Command command = new Command();
if (commandString == null)
{
throw new ArgumentNullException("commandString");
}
string[] commandParts = commandString.Split(new string[] { "->" }, StringSplitOptions.RemoveEmptyEntries);
if (commandParts.Length < 2)
{
throw new FormatException("Invalid command string format. Command parts separator not found.");
}
string[] leftParams = commandParts[0].Split(',');
if (leftParams.Length < 2)
{
throw new FormatException("Invalid command string format. Missing some command's left part parameters.");
}
string[] rightParams = commandParts[1].Split(',');
if (rightParams.Length < 3)
{
throw new FormatException("Invalid command string format. Missing some command's right part parameters.");
}
try
{
command.InitialState = int.Parse(leftParams[0]);
command.InitialValue = char.Parse(leftParams[1]);
command.FinalValue = char.Parse(rightParams[0]);
command.FinalState = int.Parse(rightParams[2]);
switch (char.Parse(rightParams[1]))
{
case 'R':
command.Move = Directions.Right;
break;
case 'L':
command.Move = Directions.Left;
break;
case 'N':
command.Move = Directions.NoMotion;
break;
default:
throw new FormatException("Invalid command string format. Invalid direction.");
}
}
catch (Exception e)
{
throw new FormatException("Invalid command string format.", e);
}
return command;
}
示例3: OnExecute
protected override void OnExecute(Command command, System.Drawing.Rectangle buttonRect)
{
base.OnExecute(command, buttonRect);
foreach (Point point in controlForm.CalibrationPoints) {
DesignBody desBody = ShapeHelper.CreateSphere(point, 0.1, part);
desBody.Layer = referenceLayer;
}
foreach (VideoForm videoForm in controlForm.VideoForms) {
Point point = videoForm.TrackingCamera.GetLine(PointUV.Origin).Evaluate(0.2).Point;
DesignBody desBody = ShapeHelper.CreateSphere(point, 0.1, part);
desBody.Layer = referenceLayer;
foreach (PointUV pointUV in videoForm.TrackingCamera.CalibrationPoints) {
point = videoForm.TrackingCamera.GetLine(pointUV).Evaluate(0.2).Point;
//desBody = ShapeHelper.CreateSphere(point, 0.1, part);
//desBody.Layer = referenceLayer;
var desCurve = DesignCurve.Create(part, CurveSegment.Create(PointCurve.Create(point)));
desCurve.Layer = referenceLayer;
}
for (int i = 0; i < videoForm.Size.Width; i += videoForm.Size.Width / 12) {
for (int j = 0; j < videoForm.Size.Height; j += videoForm.Size.Height / 12) {
Line line = videoForm.TrackingCamera.GetLine(PointUV.Create(i, j));
var curveSegment = CurveSegment.Create(line, Interval.Create(-3, 6));
var desCurve = DesignCurve.Create(part, curveSegment);
desCurve.Layer = referenceLayer;
}
}
}
}
示例4: AddCommand
private bool AddCommand(Command c)
{
if (c == null)
{
DebugLog("WARNING: Cannot use NULL command");
return false;
}
string cName = c.Name;
if (string.IsNullOrEmpty(cName))
{
DebugLog("WARNING: Cannot use no-name command " + c.GetType());
return false;
}
if (cName.StartsWith("!"))
{
//DebugLog("WARNING: Skipping command " + cName);
return false;
}
if (c.Parameters == null)
{
// DebugLog("WARNING: Skipping non-paramerized command " + cName);
return false;
}
int i = 0;
while (i < c.Parameters.Parameters.Length)
{
Type from = (Type)c.Parameters.Parameters[i].SourceType;
Type use = (Type)c.Parameters.Parameters[i].DestinationType;
AddCommand(c, from, use);
i++;
}
return true;
}
示例5: AddCommand
public void AddCommand(string commandName, Command cmd)
{
Button item = new Button();
item.Text = commandName;
item.Click += delegate { cmd(); };
theAmazingLayout.Controls.Add(item);
}
示例6: ButtonCommandBinding
public ButtonCommandBinding(Button button, Command command)
{
button.Click += (o, e) =>
{
command.run();
};
}
示例7: OnExecute
protected override void OnExecute(Command command, ExecutionContext context, System.Drawing.Rectangle buttonRect)
{
sweepAngle = Values[Resources.LenticularSweepAngle].Value * Math.PI / 180;
interlaceCount = (int) Values[Resources.LenticularInterlaceCount].Value;
interlaceWidth = (int) Values[Resources.LenticularInterlaceWidth].Value;
SaveFileDialog dialog = new SaveFileDialog();
dialog.Filter = "PNG Files (*.png)|*.png";
DialogResult result = dialog.ShowDialog();
if (result != DialogResult.OK)
return;
fileName = dialog.FileName;
activeWindow = Window.ActiveWindow;
originalWindowTrans = activeWindow.Projection;
screenY = Line.Create(Point.Origin, originalWindowTrans.Inverse * Direction.DirY);
string file = GetEnumeratedFileName(0);
activeWindow.Export(WindowExportFormat.Png, file);
Bitmap bitmap = (Bitmap) Bitmap.FromFile(file);
width = bitmap.Width;
height = bitmap.Height;
}
示例8: CommitEditCommand
protected void CommitEditCommand()
{
try {
if (incomingCommandTextBox.Text.Length == 0)
throw new Exception("Please enter an Incoming Command.");
if (_controller.Commands.Where(i => i.Key == incomingCommandTextBox.Text).Count() > 0)
throw new DuplicateNameException("There already exists a Command with that Incoming Command. Choose a different string.");
if (!File.Exists(targetTextBox.Text))
throw new FileNotFoundException("The Target cannot be found.");
Command command = new Command
{
IncomingCommand = incomingCommandTextBox.Text,
Target = targetTextBox.Text,
Arguments = argumentsTextBox.Text,
StartInDirectory = startInTextBox.Text
};
_controller.Commands.Add(command);
LoadCommandsListView();
DisableEditCommand();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
示例9: button1_Click
private void button1_Click(object sender, EventArgs e)
{
var c = new Command();
toReturn.Add(c);
prpInCreation.SelectedObject = toReturn.Last();
CommandList();
}
示例10: OnExecute
protected override void OnExecute(Command command, ExecutionContext context, System.Drawing.Rectangle buttonRect)
{
double surfaceDeviation = Values[Resources.TesselateSurfaceDeviationText].Value / ActiveWindow.Units.Length.ConversionFactor;
double angleDeviation = Values[Resources.TesselateAngleDeviationText].Value / ActiveWindow.Units.Angle.ConversionFactor;
ICollection<Face> faces = null;
IDesignBody iDesignBody = Window.ActiveWindow.ActiveContext.SingleSelection as IDesignBody;
if (iDesignBody != null)
faces = (iDesignBody.Master.Shape as Body).Faces;
else {
ICollection<IDesignFace> iDesignFaces = Window.ActiveWindow.ActiveContext.GetSelection<IDesignFace>();
foreach (IDesignFace iDesignFace in iDesignFaces) {
iDesignBody = iDesignFace.GetAncestor<DesignBody>();
continue; // TBD: handle multiple selection of faces across different DesignBodies
}
if (iDesignBody != null) {
List<Face> modelerFaces = new List<Face>();
foreach (DesignFace designFace in iDesignFaces) {
if (designFace.GetAncestor<DesignBody>() == iDesignBody)
modelerFaces.Add(designFace.Shape as Face);
}
if (modelerFaces.Count > 0)
faces = modelerFaces;
}
else
return;
}
iDesignBody.SetVisibility(null, false);
Body body = iDesignBody.Shape as Body;
IDictionary<Face, FaceTessellation> tessellationMap = body.GetTessellation(faces, FacetSense.RightHanded, new TessellationOptions(surfaceDeviation, angleDeviation));
Body testfacetBody = null;
List<Body> facetBodies = new List<Body>();
Point[] points = new Point[3];
foreach (FaceTessellation faceTessellation in tessellationMap.Values) {
IList<FacetVertex> vertices = faceTessellation.Vertices;
foreach (FacetStrip facetStrip in faceTessellation.FacetStrips) {
foreach (Facet facet in facetStrip.Facets) {
points[0] = vertices[facet.Vertex0].Position;
points[1] = vertices[facet.Vertex1].Position;
points[2] = vertices[facet.Vertex2].Position;
testfacetBody = ShapeHelper.CreatePolygon(points, null, 0);
if (testfacetBody != null)
facetBodies.Add(testfacetBody);
}
}
}
// when the topology has holes (e.g. an annulus made with one surface), non-manifold vertices can occur when merging triangles around the hole. The workaround is to merge the fragment lumps.
facetBodies = new List<Body>(facetBodies.TryUnionBodies());
facetBodies = new List<Body>(facetBodies.TryUnionBodies());
foreach (Body facetBody in facetBodies)
DesignBody.Create(iDesignBody.GetAncestor<Part>(), "Tesselation", facetBody);
}
示例11: UnicornConnectionViewModel
public UnicornConnectionViewModel(UnicornConnection connection)
{
_connection = connection;
TestConnection = new Command(ExecuteTestConnection, () => !ShowProgressBar);
Save = new Command(ExecuteSave, () => !ShowProgressBar);
Install = new Command(ExecuteInstall, () => !ShowProgressBar);
DownloadPackage = new Command(ExecuteDownloadPackage, () => !ShowProgressBar);
}
示例12: CategoryItem
public CategoryItem(string name, string description, Command command)
: this(name, description)
{
if (command == null)
throw new ArgumentNullException("command");
control = new CategoryItemCommandControl(this, command);
}
示例13: btn_Accept_Click
private void btn_Accept_Click(object sender, EventArgs e)
{
//using client controller to save the new Command into the db
clientController.insertCommandIntoDb(command);
command = null;
this.Close();
}
示例14: ReportCommand
public ReportCommand(Command command, ClientController clientController)
{
InitializeComponent();
this.command = command;
this.clientController = clientController;
init(command);
}
示例15: AssignID
protected static void AssignID(Command cmd) {
lock(internalSyncObject) {
int icmd;
if (null == cmds) {
cmds = new Command[20];
icmd = 0;
}
else {
Debug.Assert(cmds.Length > 0, "why is cmds.Length zero?");
Debug.Assert(icmdTry >= 0, "why is icmdTry negative?");
int icmdLim = cmds.Length;
if (icmdTry >= icmdLim)
icmdTry = 0;
// First look for an empty slot (starting at icmdTry).
for (icmd = icmdTry; icmd < icmdLim; icmd++)
if (null == cmds[icmd]) goto FindSlotComplete;
for (icmd = 0; icmd < icmdTry; icmd++)
if (null == cmds[icmd]) goto FindSlotComplete;
// All slots have Command objects in them. Look for a command
// with a null referent.
for (icmd = 0; icmd < icmdLim; icmd++)
if (null == cmds[icmd].Target) goto FindSlotComplete;
// Grow the array.
icmd = cmds.Length;
icmdLim = Math.Min(idLim - idMin, 2 * icmd);
if (icmdLim <= icmd) {
// Already at maximal size. Do a garbage collect and look again.
GC.Collect();
for (icmd = 0; icmd < icmdLim; icmd++) {
if (null == cmds[icmd] || null == cmds[icmd].Target)
goto FindSlotComplete;
}
throw new ArgumentException(SR.GetString(SR.CommandIdNotAllocated));
}
else {
Command[] newCmds = new Command[icmdLim];
Array.Copy(cmds, 0, newCmds, 0, icmd);
cmds = newCmds;
}
}
FindSlotComplete:
cmd.id = icmd + idMin;
Debug.Assert(cmd.id >= idMin && cmd.id < idLim, "generated command id out of range");
cmds[icmd] = cmd;
icmdTry = icmd + 1;
}
}