本文整理汇总了C#中RunMode类的典型用法代码示例。如果您正苦于以下问题:C# RunMode类的具体用法?C# RunMode怎么用?C# RunMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RunMode类属于命名空间,在下文中一共展示了RunMode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: RunCommand
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
m_doc = doc;
m_window = new Window {Title = "Object ID and Thread ID", Width = 500, Height = 75};
m_label = new Label();
m_window.Content = m_label;
new System.Windows.Interop.WindowInteropHelper(m_window).Owner = Rhino.RhinoApp.MainWindowHandle();
m_window.Show();
// register the rhinoObjectAdded method with the AddRhinoObject event
RhinoDoc.AddRhinoObject += RhinoObjectAdded;
// add a sphere from the main UI thread. All is good
AddSphere(new Point3d(0,0,0));
// add a sphere from a secondary thread. Not good: the rhinoObjectAdded method
// doesn't work well when called from another thread
var add_sphere_delegate = new Action<Point3d>(AddSphere);
add_sphere_delegate.BeginInvoke(new Point3d(0, 10, 0), null, null);
// handle the AddRhinoObject event with rhinoObjectAddedSafe which is
// desgined to work no matter which thread the call is comming from.
RhinoDoc.AddRhinoObject -= RhinoObjectAdded;
RhinoDoc.AddRhinoObject += RhinoObjectAddedSafe;
// try again adding a sphere from a secondary thread. All is good!
add_sphere_delegate.BeginInvoke(new Point3d(0, 20, 0), null, null);
doc.Views.Redraw();
return Result.Success;
}
开发者ID:jackieyin2015,项目名称:rhinocommon,代码行数:34,代码来源:ex_dotneteventwatcher.cs
示例2: RunCommand
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
List<Guid> geometryObjects_for_deletion = new List<Guid>();
foreach (Rhino.DocObjects.Layer layer in doc.Layers)
{
if (layer.Name.ToLower() == "lights") continue;
if (layer.Name.ToLower() == "objects")
{
RhinoApp.WriteLine("Giving up on Layer Objects");
continue;
}
if (layer.Name.ToLower().StartsWith("keep"))
{
RhinoApp.WriteLine("Giving up on Layer " + layer.Name);
continue;
}
RhinoApp.WriteLine(layer.LayerIndex.ToString() + ")(" + layer.Name + ":" + layer.ToString());
RhinoObject[] rhobjs = doc.Objects.FindByLayer(layer.Name);
foreach (RhinoObject robj in rhobjs)
{
if (robj.ObjectType == ObjectType.Light) continue;
geometryObjects_for_deletion.Add(robj.Id);
}
}
doc.Objects.Delete(geometryObjects_for_deletion,true);
doc.Views.Redraw();
return Result.Success;
}
开发者ID:tamirez3dco,项目名称:Rendering_Code,代码行数:31,代码来源:EZ3DDellAllCommand.cs
示例3: ConfigurationService
private RunMode runMode = RunMode.UNKNOWN; //not used anywhere for now but may come handy in the future
#endregion Fields
#region Constructors
internal ConfigurationService()
{
var appConfig = ConfigurationManager.OpenExeConfiguration(Assembly.GetEntryAssembly().Location);
var sparkMaster = Environment.GetEnvironmentVariable("spark.master"); //set by CSharpRunner when launching driver process
if (sparkMaster == null)
{
configuration = new SparkCLRDebugConfiguration(appConfig);
runMode = RunMode.DEBUG;
}
else if (sparkMaster.StartsWith("local"))
{
configuration = new SparkCLRLocalConfiguration(appConfig);
runMode = RunMode.LOCAL;
}
else if (sparkMaster.StartsWith("spark://"))
{
configuration = new SparkCLRConfiguration(appConfig);
runMode = RunMode.CLUSTER;
}
else if (sparkMaster.Equals("yarn-client", StringComparison.OrdinalIgnoreCase) || sparkMaster.Equals("yarn-cluster", StringComparison.OrdinalIgnoreCase))
{
configuration = new SparkCLRConfiguration(appConfig);
runMode = RunMode.YARN;
}
else
{
throw new NotSupportedException(string.Format("Spark master value {0} not recognized", sparkMaster));
}
logger.LogInfo(string.Format("ConfigurationService runMode is {0}", runMode));
}
开发者ID:hhland,项目名称:SparkCLR,代码行数:37,代码来源:ConfigurationService.cs
示例4: RunCommand
/// <summary>
/// Commmand.RunCommand override
/// </summary>
protected override Rhino.Commands.Result RunCommand(RhinoDoc doc, RunMode mode)
{
Rhino.Commands.Result rc = Rhino.Commands.Result.Success;
if (!_bIsLoaded)
{
string script = ScriptFromResources(ResourceName, Password);
if (!string.IsNullOrEmpty(script))
{
string macro = string.Format("_-RunScript ({0})", script);
if (RhinoApp.RunScript(macro, false))
_bIsLoaded = true;
else
rc = Result.Failure;
}
}
if (rc == Result.Success)
{
string macro = string.Format("_-RunScript ({0})", EnglishName);
RhinoApp.RunScript(macro, false);
}
return rc;
}
开发者ID:dalefugier,项目名称:RhinoScriptCommand,代码行数:28,代码来源:RhinoScriptCommand.cs
示例5: RunCommand
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
ObjRef[] obj_refs;
var rc = RhinoGet.GetMultipleObjects("Select hatches to replace", false, ObjectType.Hatch, out obj_refs);
if (rc != Result.Success || obj_refs == null)
return rc;
var gs = new GetString();
gs.SetCommandPrompt("Name of replacement hatch pattern");
gs.AcceptNothing(false);
gs.Get();
if (gs.CommandResult() != Result.Success)
return gs.CommandResult();
var hatch_name = gs.StringResult();
var pattern_index = doc.HatchPatterns.Find(hatch_name, true);
if (pattern_index < 0)
{
RhinoApp.WriteLine("The hatch pattern \"{0}\" not found in the document.", hatch_name);
return Result.Nothing;
}
foreach (var obj_ref in obj_refs)
{
var hatch_object = obj_ref.Object() as HatchObject;
if (hatch_object.HatchGeometry.PatternIndex != pattern_index)
{
hatch_object.HatchGeometry.PatternIndex = pattern_index;
hatch_object.CommitChanges();
}
}
doc.Views.Redraw();
return Result.Success;
}
开发者ID:jackieyin2015,项目名称:rhinocommon,代码行数:35,代码来源:ex_replacehatchpattern.cs
示例6: RunCommand
protected override Result RunCommand(Rhino.RhinoDoc doc, RunMode mode)
{
// TODO: start here modifying the behaviour of your command.
// ---
RhinoApp.WriteLine ("The {0} command will add a line right now.", EnglishName);
Point3d pt0;
using (GetPoint getPointAction = new GetPoint ()) {
getPointAction.SetCommandPrompt ("Please select the start point");
if (getPointAction.Get () != GetResult.Point) {
RhinoApp.WriteLine ("No start point was selected.");
return getPointAction.CommandResult ();
}
pt0 = getPointAction.Point ();
}
Point3d pt1;
using (GetPoint getPointAction = new GetPoint ()) {
getPointAction.SetCommandPrompt ("Please select the end point");
getPointAction.SetBasePoint (pt0, true);
getPointAction.DrawLineFromPoint (pt0, true);
if (getPointAction.Get () != GetResult.Point) {
RhinoApp.WriteLine ("No end point was selected.");
return getPointAction.CommandResult ();
}
pt1 = getPointAction.Point ();
}
doc.Objects.AddLine (pt0, pt1);
doc.Views.Redraw ();
RhinoApp.WriteLine ("The {0} command added one line to the document.", EnglishName);
return Result.Success;
}
开发者ID:acormier,项目名称:RhinoCommonExamples,代码行数:34,代码来源:RhinoCommonExamplesCommand.cs
示例7: Application
public Application(string name, string pathToApp, string executable, RunMode runMode = RunMode.AppDomain)
{
this.name = name;
this.runMode = runMode;
appCopy = new AppCopy(cachePath, pathToApp, executable);
watcher = new AppWatcher(pathToApp);
switch (runMode)
{
case RunMode.AppDomain:
runtime = new AppDomainRuntime(name, pathToApp, executable, appCopy.ShadowPath);
break;
case RunMode.Process:
runtime = new ProcessRuntime(name, pathToApp, executable, appCopy.ShadowPath);
break;
default:
throw new InvalidOperationException($"Unknown runmode, {runMode}");
}
watcher.AppChanged += (o, e) =>
{
Stop();
};
watcher.AfterQuietPeriod += (o, e) =>
{
Start();
};
}
开发者ID:danryd,项目名称:Tarro,代码行数:28,代码来源:Application.cs
示例8: Create
public override MetricCollector Create(RunMode runMode, WarmupData warmup, IBenchmarkSetting setting)
{
var timingSetting = setting as TimingBenchmarkSetting;
Contract.Assert(timingSetting != null);
return new TimingCollector(timingSetting.TimingMetricName);
}
开发者ID:petabridge,项目名称:NBench,代码行数:7,代码来源:TimingSelector.cs
示例9: RunCommand
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
// Get the name of the instance definition to rename
string instance_definition_name = "";
var rc = RhinoGet.GetString("Name of block to delete", true, ref instance_definition_name);
if (rc != Result.Success)
return rc;
if (string.IsNullOrWhiteSpace(instance_definition_name))
return Result.Nothing;
// Verify instance definition exists
var instance_definition = doc.InstanceDefinitions.Find(instance_definition_name, true);
if (instance_definition == null) {
RhinoApp.WriteLine("Block \"{0}\" not found.", instance_definition_name);
return Result.Nothing;
}
// Verify instance definition can be deleted
if (instance_definition.IsReference) {
RhinoApp.WriteLine("Unable to delete block \"{0}\".", instance_definition_name);
return Result.Nothing;
}
// delete block and all references
if (!doc.InstanceDefinitions.Delete(instance_definition.Index, true, true)) {
RhinoApp.WriteLine("Could not delete {0} block", instance_definition.Name);
return Result.Failure;
}
return Result.Success;
}
开发者ID:jackieyin2015,项目名称:rhinocommon,代码行数:31,代码来源:ex_deleteblock.cs
示例10: RunCommand
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
// view and view names
var active_view_name = doc.Views.ActiveView.ActiveViewport.Name;
var non_active_views =
doc.Views
.Where(v => v.ActiveViewport.Name != active_view_name)
.ToDictionary(v => v.ActiveViewport.Name, v => v);
// get name of view to set active
var gs = new GetString();
gs.SetCommandPrompt("Name of view to set active");
gs.AcceptNothing(true);
gs.SetDefaultString(active_view_name);
foreach (var view_name in non_active_views.Keys)
gs.AddOption(view_name);
var result = gs.Get();
if (gs.CommandResult() != Result.Success)
return gs.CommandResult();
var selected_view_name =
result == GetResult.Option ? gs.Option().EnglishName : gs.StringResult();
if (selected_view_name != active_view_name)
if (non_active_views.ContainsKey(selected_view_name))
doc.Views.ActiveView = non_active_views[selected_view_name];
else
RhinoApp.WriteLine("\"{0}\" is not a view name", selected_view_name);
return Rhino.Commands.Result.Success;
}
开发者ID:jackieyin2015,项目名称:rhinocommon,代码行数:32,代码来源:ex_setactiveview.cs
示例11: RunCommand
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
var gp = new GetPoint();
gp.SetCommandPrompt("Start:");
if (gp.Get() != GetResult.Point)
{
RhinoApp.WriteLine("No point selected.");
return gp.CommandResult();
}
var location = gp.Point();
var dialog = new BBTextDialog();
if (dialog.ShowDialog()!= true)
return Result.Cancel;
var typeWriter = dialog.Bold ? Typewriter.Bold : Typewriter.Regular;
var x = doc.Views.ActiveView.ActiveViewport.CameraX;
var y = doc.Views.ActiveView.ActiveViewport.CameraY;
var unitX = x * dialog.Size;
var unitY = y * dialog.Size;
var curves = typeWriter.Write(dialog.Text, location, unitX, unitY, dialog.HAlign, dialog.VAlign);
doc.Groups.Add(curves.Select(curve => doc.Objects.AddCurve(curve)));
doc.Views.Redraw();
return Result.Success;
}
开发者ID:olitur,项目名称:Bowerbird,代码行数:34,代码来源:BBTextCommand.cs
示例12: RunCommand
/// <summary>
/// Call by Rhino when the user wants to run this command
/// </summary>
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
if (null == m_grip_enabler)
{
// Register once and only once...
m_grip_enabler = new SampleCsRectangleGripsEnabler();
CustomObjectGrips.RegisterGripsEnabler(m_grip_enabler.TurnOnGrips, typeof(SampleCsRectangleGrips));
}
var go = new SampleCsGetRectangleCurve();
go.SetCommandPrompt("Select rectangles for point display");
go.GetMultiple(1, 0);
if (go.CommandResult() != Result.Success)
return go.CommandResult();
for (var i = 0; i < go.ObjectCount; i++)
{
var rh_object = go.Object(i).Object();
if (null != rh_object)
{
if (rh_object.GripsOn)
rh_object.GripsOn = false;
m_grip_enabler.TurnOnGrips(rh_object);
}
}
doc.Views.Redraw();
return Result.Success;
}
开发者ID:dalefugier,项目名称:SampleCsRectangleGrips,代码行数:34,代码来源:SampleCsRectangleGripsCommand.cs
示例13: RunCommand
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
ObjRef obj_ref;
var rs = RhinoGet.GetOneObject(
"Select object", false, ObjectType.AnyObject, out obj_ref);
if (rs != Result.Success)
return rs;
var rhino_object = obj_ref.Object();
if (rhino_object == null)
return Result.Failure;
var rhino_object_groups = rhino_object.Attributes.GetGroupList().DefaultIfEmpty(-1);
var selectable_objects= from obj in doc.Objects.GetObjectList(ObjectType.AnyObject)
where obj.IsSelectable(true, false, false, false)
select obj;
foreach (var selectable_object in selectable_objects)
{
foreach (var group in selectable_object.Attributes.GetGroupList())
{
if (rhino_object_groups.Contains(group))
{
selectable_object.Select(true);
continue;
}
}
}
doc.Views.Redraw();
return Result.Success;
}
开发者ID:jackieyin2015,项目名称:rhinocommon,代码行数:31,代码来源:ex_selectgroupobject.cs
示例14: RunCommand
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
var go = new Rhino.Input.Custom.GetObject();
go.SetCommandPrompt("Select objects to copy in place");
go.GroupSelect = true;
go.SubObjectSelect = false;
go.GetMultiple(1, 0);
if (go.CommandResult() != Result.Success)
return go.CommandResult();
var xform = Transform.Identity;
var group_map = new Dictionary<int, int>();
foreach (var obj_ref in go.Objects())
{
if (obj_ref != null)
{
var obj = obj_ref.Object();
var duplicate = doc.Objects.Transform(obj_ref.ObjectId, xform, false);
RhinoUpdateObjectGroups(ref obj, ref group_map);
}
}
doc.Views.Redraw();
return Result.Success;
}
开发者ID:jackieyin2015,项目名称:rhinocommon,代码行数:25,代码来源:ex_copygroups.cs
示例15: RunCommand
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
var gm = new GetObject();
gm.SetCommandPrompt("Select solid meshes for volume calculation");
gm.GeometryFilter = ObjectType.Mesh;
gm.GeometryAttributeFilter = GeometryAttributeFilter.ClosedMesh;
gm.SubObjectSelect = false;
gm.GroupSelect = true;
gm.GetMultiple(1, 0);
if (gm.CommandResult() != Result.Success)
return gm.CommandResult();
double volume = 0.0;
double volume_error = 0.0;
foreach (var obj_ref in gm.Objects())
{
if (obj_ref.Mesh() != null)
{
var mass_properties = VolumeMassProperties.Compute(obj_ref.Mesh());
if (mass_properties != null)
{
volume += mass_properties.Volume;
volume_error += mass_properties.VolumeError;
}
}
}
RhinoApp.WriteLine("Total volume = {0:f} (+/- {1:f})", volume, volume_error);
return Result.Success;
}
开发者ID:jackieyin2015,项目名称:rhinocommon,代码行数:30,代码来源:ex_meshvolume.cs
示例16: RunCommand
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
var go = new Rhino.Input.Custom.GetObject();
go.SetCommandPrompt("Select objects");
go.EnablePreSelect(true, true);
go.EnablePostSelect(true);
go.GetMultiple(0, 0);
if (go.CommandResult() != Result.Success)
return go.CommandResult();
var selected_objects = go.Objects().ToList();
if (go.ObjectsWerePreselected)
{
go.EnablePreSelect(false, true);
go.DeselectAllBeforePostSelect = false;
go.EnableUnselectObjectsOnExit(false);
go.GetMultiple(0, 0);
if (go.CommandResult() == Result.Success)
{
foreach (var obj in go.Objects())
{
selected_objects.Add(obj);
// The normal behavior of commands is that when they finish,
// objects that were pre-selected remain selected and objects
// that were post-selected will not be selected. Because we
// potentially could have both, we'll try to do something
// consistent and make sure post-selected objects also stay selected
obj.Object().Select(true);
}
}
}
return selected_objects.Count > 0 ? Result.Success : Result.Nothing;
}
开发者ID:jackieyin2015,项目名称:rhinocommon,代码行数:34,代码来源:ex_prepostpick.cs
示例17: Drive
/// <summary>
/// Initialisiert den Antrieb des Roboters
/// </summary>
///
/// <param name="runMode">der gewünschte Run-Mode (Real/Virtual)</param>
public Drive(RunMode runMode)
{
if (!Constants.IsWinCE) runMode = RunMode.Virtual;
this.runMode = runMode;
this.disposed = false;
// Antrieb initialisieren
if (this.runMode == RunMode.Real)
{
this.driveCtrl = new DriveCtrlHW(Constants.IODriveCtrl);
this.motorCtrlLeft = new MotorCtrlHW(Constants.IOMotorCtrlLeft);
this.motorCtrlRight = new MotorCtrlHW(Constants.IOMotorCtrlRight);
}
else
{
this.driveCtrl = new DriveCtrlSim();
this.motorCtrlLeft = new MotorCtrlSim();
this.motorCtrlRight = new MotorCtrlSim();
}
// Beschleunigung festlegen
this.motorCtrlLeft.Acceleration = 10f;
this.motorCtrlRight.Acceleration = 10f;
// Prozess-Thread erzeugen und starten
this.thread = new Thread(RunTracks);
this.thread.IsBackground = true;
this.thread.Priority = ThreadPriority.Highest;
this.thread.Start();
}
开发者ID:maesi,项目名称:prgsy,代码行数:36,代码来源:Drive.cs
示例18: RunCommand
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
Plugin.InitialiseCSycles();
if (doc.Views.ActiveView.ActiveViewport.DisplayMode.Id == Guid.Parse("69E0C7A5-1C6A-46C8-B98B-8779686CD181"))
{
var rvp = doc.Views.ActiveView.RealtimeDisplayMode as RenderedViewport;
if (rvp != null)
{
var getNumber = new GetInteger();
getNumber.SetLowerLimit(1, true);
getNumber.SetDefaultInteger(rvp.HudMaximumPasses()+100);
getNumber.SetCommandPrompt("Set new sample count");
var getRc = getNumber.Get();
if (getNumber.CommandResult() != Result.Success) return getNumber.CommandResult();
if (getRc == GetResult.Number)
{
var nr = getNumber.Number();
RhinoApp.WriteLine($"User changes samples to {nr}");
rvp.ChangeSamples(nr);
return Result.Success;
}
}
}
RhinoApp.WriteLine("Active view isn't rendering with Cycles");
return Result.Nothing;
}
开发者ID:mcneel,项目名称:RhinoCycles,代码行数:29,代码来源:ChangeSamples.cs
示例19: RunCommand
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
var file_name = "";
var bitmap = doc.Views.ActiveView.CaptureToBitmap(true, true, true);
bitmap.MakeTransparent();
// copy bitmap to clipboard
Clipboard.SetImage(bitmap);
// save bitmap to file
var save_file_dialog = new Rhino.UI.SaveFileDialog
{
Filter = "*.bmp",
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
};
if (save_file_dialog.ShowDialog() == DialogResult.OK)
{
file_name = save_file_dialog.FileName;
}
if (file_name != "")
bitmap.Save(file_name);
return Rhino.Commands.Result.Success;
}
开发者ID:jackieyin2015,项目名称:rhinocommon,代码行数:26,代码来源:ex_screencaptureview.cs
示例20: RunCommand
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
ObjRef obj_ref;
var rc = RhinoGet.GetOneObject("Select surface or polysurface to mesh", true, ObjectType.Surface | ObjectType.PolysrfFilter, out obj_ref);
if (rc != Result.Success)
return rc;
var brep = obj_ref.Brep();
if (null == brep)
return Result.Failure;
// you could choose anyone of these for example
var jagged_and_faster = MeshingParameters.Coarse;
var smooth_and_slower = MeshingParameters.Smooth;
var default_mesh_params = MeshingParameters.Default;
var minimal = MeshingParameters.Minimal;
var meshes = Mesh.CreateFromBrep(brep, smooth_and_slower);
if (meshes == null || meshes.Length == 0)
return Result.Failure;
var brep_mesh = new Mesh();
foreach (var mesh in meshes)
brep_mesh.Append(mesh);
doc.Objects.AddMesh(brep_mesh);
doc.Views.Redraw();
return Result.Success;
}
开发者ID:jackieyin2015,项目名称:rhinocommon,代码行数:28,代码来源:ex_createmeshfrombrep.cs
注:本文中的RunMode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论