private void CreateContextMenu() { var globalCapabities = new CapabilitiesCollection(); ContextManager = new ContextMenuManager(globalCapabities); ContextMenu = ContextManager.ContextMenu; }
public void CapabilityExportRelatedConcept() { var collection = new CapabilitiesCollection(); const string conceptName = "concept"; const string relatedConcept = "related"; const string relatedConcept2 = "related2"; const string relatedConcept3 = "related3"; var concept = collection.AddConcept(conceptName); var related = collection.AddConcept(relatedConcept); concept.AddRelatedConcept(related); collection.AddRelation(conceptName, relatedConcept2); collection.AddRelation(conceptName, relatedConcept3); concept.SetCapability("Color", "Red"); related.SetCapability("Icon", "image.png"); concept.AddBlacklistedCapability("Icon"); const string documentName = "related.xmlcaps"; const string capsFileName = "related.caps"; collection.SaveAsDocument(documentName); CapabilitiesDocumentImporter.LoadFileCapabilities(documentName, capsFileName); var exists = File.Exists(capsFileName); Assert.IsTrue(exists); collection = CapabilitiesLoader.LoadFileCapabilities(capsFileName); Assert.IsTrue(collection.HasConcept("concept")); }
/// <summary> /// Creates a new <see cref="Thread"/> /// </summary> /// <param name="name">The name of the thread.</param> /// <param name="capabilities">A collection of capabilities that the <see cref="Thread"/> has to run certain <see cref="ICommand"/> commands.</param> /// <param name="pointer">The <see cref="ThreadPointer"/> contains information about the <see cref="ICommand"/>s that will be run on the <see cref="Thread"/>.</param> /// <param name="context">Memory context, such as static type information, specific to the environment where the <see cref="Thread"/> is executing.</param> public Thread(string name, CapabilitiesCollection capabilities, ThreadPointer pointer, IMemoryGroup context) { Name = name; Capabilities = capabilities; Pointer = pointer; Context = context; }
public override void OnActivate() { base.OnActivate(); _collection = Inputs[InputNames.GlobalCapabilitiesInput].Get <CapabilitiesCollection>(); Inputs[InputNames.GeometricSolverPipe].Send(NotificationNames.DisableAll); Reset(); }
private ReferencedShapeConstraints() { Capabilities = new CapabilitiesCollection(); var face = Capabilities.AddConcept("Face"); var rectangle = Capabilities.AddConcept(FunctionNames.ThreePointsRectangle); var parallelogram = Capabilities.AddConcept(FunctionNames.Paralleogram); var circle = Capabilities.AddConcept(FunctionNames.Circle); var ellipse = Capabilities.AddConcept(FunctionNames.Ellipse); var makeFace = Capabilities.AddConcept(FunctionNames.Face); Capabilities.AddConcept(FunctionNames.Arc); var line = Capabilities.AddConcept(FunctionNames.LineTwoPoints); Capabilities.AddConcept(FunctionNames.WireTwoPoints); Capabilities.AddConcept(FunctionNames.VerticalLine); Capabilities.AddConcept(FunctionNames.HorizontalLine); var box = Capabilities.AddConcept(FunctionNames.Box); var cone = Capabilities.AddConcept(FunctionNames.Cone); var cylinder = Capabilities.AddConcept(FunctionNames.Cylinder); Capabilities.AddConcept(FunctionNames.Sphere); Capabilities.AddConcept(FunctionNames.Torus); var cut = Capabilities.AddConcept(FunctionNames.Cut); rectangle.AddRelatedConcept(face); circle.AddRelatedConcept(face); ellipse.AddRelatedConcept(face); makeFace.AddRelatedConcept(face); box.AddRelatedConcept(face); cone.AddRelatedConcept(face); cylinder.AddRelatedConcept(face); var extrude = Capabilities.AddConcept(FunctionNames.Extrude); AcceptOperation(face, ShapeOperations.Extrudable); AcceptOperation(extrude, ShapeOperations.Extrudable); AcceptOperation(cut, ShapeOperations.Extrudable); AcceptOperation(line, ShapeOperations.Dimensionable); AcceptOperation(cut, ShapeOperations.Dimensionable); AcceptOperation(extrude, ShapeOperations.Dimensionable); AcceptOperation(face, ShapeOperations.Dimensionable); AcceptOperation(parallelogram, ShapeOperations.Dimensionable); AcceptOperation(circle, ShapeOperations.CircleRadiusConstraint); AcceptOperation(line, ShapeOperations.LineLengthConstraint); AcceptOperation(rectangle, ShapeOperations.RectangleMeasurementConstraint); //Capabilities.SaveAsDocument("ReferencedShapeConstraints.xmlcaps"); //CapabilitiesDocumentImporter.LoadFileCapabilities("ReferencedShapeConstraints.xmlcaps", // "ReferencedShapeConstraints.caps"); //Capabilities = CapabilitiesLoader.LoadFileCapabilities("ReferencedShapeConstraints.caps"); }
public void TestAddCapability() { var collection = new CapabilitiesCollection(); const string shapeId = "shape"; var conceptBuilder = collection.AddConcept(shapeId); Assert.IsTrue(collection.HasConcept(shapeId)); var sameConceptBuilder = collection.GetConcept(shapeId); Assert.IsTrue(conceptBuilder.Node == sameConceptBuilder.Node); }
public void CapabilityExportEmptyConcept() { var collection = new CapabilitiesCollection(); collection.AddConcept("Empty concept"); const string documentName = "emtpy.xmlcaps"; const string capsFileName = "out.caps"; collection.SaveAsDocument(documentName); CapabilitiesDocumentImporter.LoadFileCapabilities(documentName, capsFileName); var exists = File.Exists(capsFileName); Assert.IsTrue(exists); }
public void TestRelateCapability() { var collection = new CapabilitiesCollection(); const string shapeId = "shape"; const string tranId = "transform"; var shapeConcept = collection.AddConcept(shapeId); shapeConcept.SetCapability("Color", "Red"); var tranConcept = collection.AddConcept(tranId); collection.AddRelation(tranId, shapeId); var colorValue = tranConcept.GetCapability("Color"); Assert.IsTrue(tranConcept.HasCapability("Color")); Assert.AreEqual(colorValue, "Red"); Assert.IsTrue(tranConcept.IsRelatedWith(shapeId)); }
public void TestConceptBuilder() { var collection = new CapabilitiesCollection(); const string shapeId = "shape"; const string circleId = "circle"; var shapeConcept = collection.AddConcept(shapeId); shapeConcept.SetCapability("Color", "Red"); var circleConcept = collection.AddConcept(circleId); collection.AddRelation(circleId, shapeId); Assert.IsTrue(circleConcept.HasCapability("Color")); Assert.IsTrue(circleConcept.IsRelatedWith(shapeId)); Assert.IsTrue(circleConcept.GetRelatedConcept(shapeId).Node == shapeConcept.Node); circleConcept.AddBlacklistedCapability("Color"); Assert.IsFalse(circleConcept.HasCapability("Color")); Assert.IsTrue(circleConcept.GetCapability("Color") == String.Empty); circleConcept.RemoveBlackistedCapability("Color"); Assert.IsTrue(circleConcept.HasCapability("Color")); Assert.IsTrue(circleConcept.GetCapability("Color") != String.Empty); }
/// <summary> /// Creates a script inside of its parent <see cref="DataObject"/>, starting at a specific <see cref="ICommand"/> and containing script information and documentation. /// </summary> /// <param name="parent">The owning object of the script. This <see cref="DataObject"/> provides the memory context for the <see cref="Script"/>'s <see cref="Thread"/>.</param> /// <param name="info">Contains information about the name and inputs of the script.</param> /// <param name="commands">A collection of <see cref="ICommand"/> objects that make up a <see cref="Script"/>. They are run in this order on the <see cref="Thread"/> when the <see cref="Script"/> is called.</param> /// <param name="addedCapabilities">A collection of any user-defined <see cref="Capability"/> values required to execute this <see cref="Script"/>.</param> public CommandScript(DataObject parent, ScriptInfo info, IEnumerable <ICommand> commands, CapabilitiesCollection addedCapabilities = null) : base(parent, info) { Commands = commands; AdditionalCapabilities = addedCapabilities; }
public MultiViewStub(CapabilitiesCollection globalCapabitities) { ContextManager = new ContextMenuManager(globalCapabitities); }
public void SetShapesCapabilities(CapabilitiesCollection capabilitiesCollection) { //TO DO: code review here _sketchPopulateLogic.SetShapesCapabilities(capabilitiesCollection, _imageBitmapCache); }
public ContextMenuManager(CapabilitiesCollection globalCapabilities) { ContextMenu = new ContextMenu(); _concepts = new DefaultShapeConcepts(globalCapabilities); ClearAllButtons(); }
public void SetShapesCapabilities(CapabilitiesCollection capabilitiesCollection, ImageBitmapCache imageBitmapCache) { _capabilties = capabilitiesCollection; _imageBitmapCache = imageBitmapCache; }
public GlobalCapabilitiesInput() : base(InputNames.GlobalCapabilitiesInput) { _globalCapabilities = new CapabilitiesCollection(); }
/// <summary> /// Internal - runs the <see cref="Script"/> with the provided memory context and returns a <see cref="DataObject"/> result. /// </summary> /// <param name="inputs">An <see cref="IWritableMemoryGroup"/> containing the named <see cref="Script"/> inputs.</param> /// <param name="capabilities">The <see cref="CapabilitiesCollection"/> from the <see cref="ICommand"/> or other source that called the <see cref="Script"/>.</param> protected abstract Task <DataObject> RunScriptInternalAsync(IWritableMemoryGroup inputs, CapabilitiesCollection capabilities);
public DefaultShapeConcepts(CapabilitiesCollection globalCapabilities) { Capabilities = globalCapabilities ?? new CapabilitiesCollection(); Setup(); }
/// <inheritdoc/> protected override async Task <DataObject> RunScriptInternalAsync(IWritableMemoryGroup inputs, CapabilitiesCollection capabilities) { var thread = new Thread( ScriptInfo.GetUniqueId(), capabilities, new ThreadPointer(Commands.ToArray()), null); var output = await thread.RunThreadAsync(ParentObject, inputs); //// TODO: Make sure that this is the correct way to get the output of a script; handle flags such as no return and exception. if (thread.Pointer.Flags.HasFlag(CommandPointerFlags.Returned)) { return(output); } else { return(null); } }
public override void OnActivate() { base.OnActivate(); _collection = Inputs[InputNames.GlobalCapabilitiesInput].Get <CapabilitiesCollection>(); }
/// <summary> /// Calls and executes a given <see cref="Script"/> and returns the <see cref="DataObject"/> result. /// </summary> /// <param name="inputs">A collection of <see cref="DataObject"/>s which will be checked and stored in an <see cref="IWritableMemoryGroup"/> to be sent to the <see cref="Thread"/>'s <see cref="IMemoryStack"/>.</param> /// <param name="inheritedcapabilities">The <see cref="CapabilitiesCollection"/> from the <see cref="ICommand"/> or other source that called the <see cref="Script"/>.</param> public async Task <DataObject> CallScriptAsync(IEnumerable <DataObject> inputs, CapabilitiesCollection inheritedcapabilities) { IWritableMemoryGroup inputMemory = ScriptInfo.CreateMemoryFromInputs(inputs.ToArray()); return(await RunScriptInternalAsync(inputMemory, inheritedcapabilities)); }