本文整理汇总了C#中RunMode类的典型用法代码示例。如果您正苦于以下问题:C# RunMode类的具体用法?C# RunMode怎么用?C# RunMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RunMode类属于命名空间,在下文中一共展示了RunMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}
示例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();
};
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}