public void Invoke(Manipulator manip) { foreach (Instruction instr in Instrs) { if (instr.Operand is Instruction target) { instr.Operand = new ILLabel(this, target); } else if (instr.Operand is Instruction[] targets) { instr.Operand = targets.Select(t => new ILLabel(this, t)).ToArray(); } } manip(this); foreach (Instruction instr in Instrs) { if (instr.Operand is ILLabel label) { instr.Operand = label.Target; } else if (instr.Operand is ILLabel[] targets) { instr.Operand = targets.Select(l => l.Target).ToArray(); } } Method.ConvertShortLongOps(); }
public PageCompletionViewModel() { try { var Image = Manipulator.GetResourceImage("Image", "CompletionBanner"); if (Image != null) { completionImage = Image; } var HeadlineText = Manipulator.GetResourceString("Text", "Page5_Headline"); if (HeadlineText != null) { headline = HeadlineText; } var Text = Manipulator.GetResourceString("Text", "Page5_Text"); if (Text != null) { text = Text; } } catch { } this.PropertyChanged += Page5ViewModel_PropertyChanged; }
private string AddImagePartFromFile(string absoluteImageFilePath) { using (var stream = new FileStream(absoluteImageFilePath, FileMode.Open, FileAccess.Read, FileShare.Read)) { return(Manipulator.AddImagePart(stream)); } }
public PageTargetDirectoryViewModel() { try { var Image = Manipulator.GetResourceImage("Image", "TargetDirectoryBanner"); if (Image != null) { targetDirectoryImage = Image; } var HeadlineText = Manipulator.GetResourceString("Text", "Page3_Headline"); if (HeadlineText != null) { headline = HeadlineText; } var Text = Manipulator.GetResourceString("Text", "Page3_Text"); if (Text != null) { text = Text; } } catch { } this.PropertyChanged += ViewModel_PropertyChanged; }
public PageIntroViewModel() { try { var Image = Manipulator.GetResourceImage("Image", "WelcomeBanner"); if (Image != null) { welcomeImage = Image; } var HeadlineText = Manipulator.GetResourceString("Text", "Page0_Headline"); if (HeadlineText != null) { headline = HeadlineText; } var SubHeadlineText = Manipulator.GetResourceString("Text", "Page0_SubHeadline"); if (SubHeadlineText != null) { subHeadline = SubHeadlineText; } var Text = Manipulator.GetResourceString("Text", "Page0_Text"); if (Text != null) { text = Text; } } catch { } this.PropertyChanged += ViewModel_PropertyChanged; }
void SwitchTool(MouseUpEvent e) { var toggle = e.target as Toggle; Type toolType = Type.GetType(toggle.name); if (m_Tool != null && m_Tool.GetType() == toolType) { return; } foreach (var tool in m_ToolButtons) { tool.value = tool == toggle; } if (m_Tool != null) { m_Root.RemoveManipulator(m_Tool); } toggle.value = true; toggle.Focus(); // toggle.Blur(); if (toolType != null) { Manipulator tool; if (m_Tools.TryGetValue(toolType, out tool)) { m_Tool = m_Tools[toolType]; } else { m_Tool = System.Activator.CreateInstanceFrom(toolType.Assembly.CodeBase, toolType.FullName).Unwrap() as Manipulator; m_Tools.Add(toolType, m_Tool); } m_Root.Q(name: "canvas").AddManipulator(m_Tool); } }
public AssociativeTable(Manipulator Agent, int entries) { Table = new Dictionary <double, double[]>(); double[] q_init = new double[IKP.ParamNum]; Array.Copy(Agent.q, q_init, IKP.ParamNum); Random rng = new Random(); IKP Solver = new IKP(0.02, Agent.Links.Length, 10, 0.2, 50); for (int i = 0; i < 3600; i++) { double d = 0.04, a = i; //a = Math.Round(-Math.PI + 2 * Math.PI * rng.NextDouble(), 2); Vector v = new Vector(d * Math.Cos(a / 10), d * Math.Sin(a / 10)); var res = Solver.Execute(Agent.GripperPos + v); Array.Copy(q_init, Agent.q, IKP.ParamNum); while (!res.Item1) { res = Solver.Execute(Agent.GripperPos + v); Array.Copy(q_init, Agent.q, IKP.ParamNum); } Table.Add(a, res.Item3); } }
public void Trim(Manipulator manipulator, InverseKinematicsSolver solver) { switch (Mode) { case TreeBehaviour.Cyclic: var source = new Queue <Node>(); source.Enqueue(Root); while (source.Count != 0) { var childs = new List <Node>(source.Dequeue().Childs); foreach (var child in childs) { manipulator.q = child.q; if (manipulator.CollisionTest().Contains(true)) { RemoveNode(child); } else { source.Enqueue(child); } } } break; case TreeBehaviour.Recursive: foreach (var child in Root.Childs) { TrimRecursive(manipulator, solver, child); } break; } }
public static Signal Transform(Signal signal, Context context, MathIdentifier transformationTypeId, bool ignoreHold) { TransformationTypeTable transTable = context.Library.LookupTransformationTheoremType(transformationTypeId); TransformationManipulationVisitor visitor = new TransformationManipulationVisitor(transTable); return(Manipulator.Manipulate(signal, visitor, ignoreHold)); }
public static void Initialize(Manipulator agent, Obstacle[] obstacles) { Rng = new Random(); Agent = new Manipulator(agent); Obstacles = obstacles; }
/// <summary> /// Connections the specified object. /// </summary> /// <param name="obj">The object.</param> private void Connection(object obj) { if (null != obj) { var state = (bool)obj; if (!state) { Manipulator?.Disconnect(); } else { if (string.IsNullOrEmpty(SelectedCOMPort)) { BadgeText = "!"; ConnectionToggleIsChecked = false; return; } ConnectionToggleIsChecked = true; Manipulator = new E3JManipulator(Settings); Manipulator.Port.ConnectionStatusChanged += Port_ConnectionStatusChanged; Manipulator.Connect(SelectedCOMPort); Manipulator.Port.DataReceived += Port_DataReceived; KinectHandler?.StartKinect(Manipulator); } } }
void OnKeyDown(KeyDownEvent e) { bool pressed; if (keyPressed.TryGetValue(e.keyCode, out pressed)) { if (!pressed) { keyPressed[e.keyCode] = true; } } else { keyPressed.Add(e.keyCode, true); } if (!pressed && keyPressed[e.keyCode]) { if (e.keyCode == KeyCode.LeftControl || e.keyCode == KeyCode.RightControl) { if (m_Tool != null) { m_Root.Q(name: "canvas").RemoveManipulator(m_Tool); } m_Manipulator = new EyedropperTool(); m_Root.Q(name: "canvas").AddManipulator(m_Manipulator); } } }
public async Task StartGameResetsGameData() { AddPlayers(Constants.MaxPlayerCount); await StateMachine.Start(); Manipulator.Verify(_ => _.ResetGame()); }
public void Control(Manipulator agent, Vector3 goal, List <List <Vector3> > paths) { var contestant = new Manipulator(agent); var gripperPos = 0; while (gripperPos < agent.Configs.Count) { for (int i = gripperPos + 1; i < agent.Path.Count; i++) { for (int j = paths[i].Count - 1; j > 0; j--) { foreach (var obst in Obstacles) { if (obst.Contains(paths[i][j])) { Deform(agent, obst, paths, i, j); break; } } } } // wait for window to draw current config so that we can update it Dispatcher.UpdateConfig.WaitOne(); agent.q = agent.Configs[gripperPos < agent.Configs.Count - 1 ? gripperPos++ : gripperPos]; Dispatcher.UpdateConfig.Reset(); } }
/// <summary> /// 创建ç®å¤´ /// </summary> /// <param name="swN"></param> /// <param name="swPickPt"></param> /// <param name="length"></param> /// <returns></returns> private Manipulator CreateNewDrag(MathVector swN, MathPoint swPickPt, double length) { var swModel = (ModelDoc2)swApp.ActiveDoc; var swModViewMgr = swModel.ModelViewManager; SwManHandler2 swDragHdlr = new SwManHandler2(); Manipulator swManip = swModViewMgr.CreateManipulator((int)swManipulatorType_e.swDragArrowManipulator, swDragHdlr); DragArrowManipulator swDrag = (DragArrowManipulator)swManip.GetSpecificManipulator(); swDrag.AllowFlip = false; swDrag.ShowRuler = false; swDrag.ShowOppositeDirection = false; swDrag.Length = length; swDrag.Direction = swN; //swDrag.LengthOppositeDirection = 0.01; swDrag.Origin = swPickPt; swManip.Show(swModel); swDrag.Update(); return(swManip); }
public PageInstallViewModel() { try { var Image = Manipulator.GetResourceImage("Image", "InstallBanner"); if (Image != null) { installImage = Image; } var HeadlineText = Manipulator.GetResourceString("Text", "Page4_Headline"); if (HeadlineText != null) { headline = HeadlineText; } var Text = Manipulator.GetResourceString("Text", "Page4_Text"); if (Text != null) { text = Text; } var Text2 = Manipulator.GetResourceString("Text2", "Page4_Text2"); if (Text2 != null) { text2 = Text2; } } catch { } this.PropertyChanged += ViewModel_PropertyChanged; }
void OnManipulatorRightUpdated(SteamVR_Controller.Device state) { if (state.GetPressDown(EVRButtonId.k_EButton_Grip)) { /*Utils.Log("OnManipulatorRightUpdated: " + * "attached = " + (attachedManipulator == null ? "null" : attachedManipulator.ToString()) + * ", isManipulatorRightInsideStickCollider = " + (isManipulatorRightInsideCollider ? "yes" : "no") + * ", state.GetPressDown = " + (state.GetPressDown(EVRButtonId.k_EButton_Grip) ? "yes" : "no"));*/ if (isInteractable && (attachedManipulator == null) && isManipulatorRightInsideCollider) { attachedManipulator = DeviceManager.Instance.ManipulatorRight; DeviceManager.Instance.ManipulatorRight.isGripping = true; // cool-down for button de-bounce isInteractable = false; StartCoroutine(ButtonCooldown()); } else if (DeviceManager.IsManipulatorRight(attachedManipulator)) { attachedManipulator = null; DeviceManager.Instance.ManipulatorRight.isGripping = false; } } }
public static SignalSet Transform(IEnumerable <Signal> signals, Context context, MathIdentifier transformationTypeId, ConfigureTransformation configure, bool ignoreHold) { TransformationTypeTable transTable = context.Library.LookupTransformationTheoremType(transformationTypeId); TransformationManipulationVisitor visitor = new TransformationManipulationVisitor(transTable, configure); return(Manipulator.Manipulate(signals, visitor, ignoreHold)); }
private OpenXmlElement ConvertLinkInline(LinkInline linkInline, bool isBoldInherited = false, bool isItalicInherited = false) { if (linkInline.IsImage) { var explicitAbsoluteImagePath = GetExplicitAbsoluteImagePath(linkInline.Url, BaseFolderPathForRelativePath); var relationshipId = AddImagePartFromFile(explicitAbsoluteImagePath); // At this time, temporary uses the original image dimension. // In later, adjust the image dimension using the page settings and inherited indentation. (var originalImageWidthInch, var originalImageHeightInch) = Manipulator.GetImageDimensionInInch(relationshipId); var originalImageWidthEmu = WordDocumentManipulator.UnitConverter.InchToEmu(originalImageWidthInch); var originalImageHeightEmu = WordDocumentManipulator.UnitConverter.InchToEmu(originalImageHeightInch); var fileName = Path.GetFileName(explicitAbsoluteImagePath); var altText = GetLinkText(linkInline); return(Manipulator.ElementCreator.CreateImageElement(relationshipId, (long)originalImageWidthEmu, (long)originalImageHeightEmu, fileName, altText)); } else { var linkText = GetLinkText(linkInline); var hyperlinkUri = GetLinkTargetUri(linkInline.Url); var hyperlinkRelationshipId = Manipulator.AddHyperlinkRelationship(hyperlinkUri); var styleId = UserSettingStyleMap.GetStyleId(UserSettingStyleMap.StyleMapKeyType.Hyperlink, null); return(Manipulator.ElementCreator.CreateHyperlinkElement(linkText, hyperlinkRelationshipId, isBoldInherited, isItalicInherited, styleId)); } }
public void WrongFileExtensionThrowsException() { //Arrange var manipulator = new Manipulator(@"C:\thisFileDoesntExist.txt"); //Act manipulator.Reverse(); }
public void TooSmallFileThrowsException() { //Arrange var manipulator = new Manipulator(@"C:\Users\David'\Desktop\WavFiles\16BitPCM\tooSmall.wav"); //Act manipulator.Reverse(); }
public void NonWaveFileContentFormatThrowsException() { //Arrange var manipulator = new Manipulator(@"C:\Users\David'\Desktop\WavFiles\16BitPCM\notWavFormat.wav"); //Act manipulator.Reverse(); }
public void EmptyStringThrowsException() { //Arrange var manipulator = new Manipulator(""); //Act manipulator.Reverse(); }
public void NonExistentFileThrowsException() { //Arrange var manipulator = new Manipulator(@"C:\thisFileDoesntExist.wav"); //Act manipulator.Reverse(); }
//Recreatee drag handler based on mouse void CheckMouse() { if (Input.GetMouseButtonDown(0)) { coll = Physics2D.OverlapPoint(Camera.main.ScreenToWorldPoint(Input.mousePosition)); if (coll == null) { return; } if (coll.CompareTag("Manipulator")) { curr_selected_obj = coll.GetComponent <Manipulator>(); } touch_timer = buffer_time; isSelected = false; } if (Input.GetMouseButton(0)) { if (curr_selected_obj == null) { return; } touch_timer -= Time.deltaTime; //Start the drag mechanic if (touch_timer <= 0 && !isSelected) { isSelected = true; curr_selected_obj.StartDrag(); } else if (touch_timer <= 0 && isSelected) { curr_selected_obj.Drag(); } } if (Input.GetMouseButtonUp(0)) { if (curr_selected_obj == null) { return; } //Case 1 : Tap if (touch_timer >= 0) { curr_selected_obj.Rotate_Right(); } //Case 2 : Drag and release if (touch_timer <= 0) { curr_selected_obj.EndDrag(); } curr_selected_obj = null; } }
public void TestReverse() { Assert.Equal(54321, Manipulator.Reverse(12345)); Assert.Equal(1337, Manipulator.Reverse(7331)); Assert.Equal(0, Manipulator.Reverse(0)); Assert.Equal(1, Manipulator.Reverse(1)); Assert.Equal(8, Manipulator.Reverse(8000)); Assert.Equal(111111, Manipulator.Reverse(111111)); }
public void NullStringThrowsException() { //Arrange string array = null; var manipulator = new Manipulator(array); //Act manipulator.Reverse(); }
public void TestComplement() { Assert.Equal(87654, Manipulator.Complement(12345)); Assert.Equal(2668, Manipulator.Complement(7331)); Assert.Equal(8, Manipulator.Complement(1)); Assert.Equal(1999, Manipulator.Complement(8000)); Assert.Equal(8000, Manipulator.Complement(1999)); Assert.Equal(888888, Manipulator.Complement(111111)); }
public void NullArrayThrowsException() { //Arrange IEnumerable <byte> array = null; var manipulator = new Manipulator(array); //Act manipulator.Reverse(); }
public void MoveFrameOnNewPlayfield_UpAndLeft_ReturnsTrue(Direction direction) { // arrange // act bool testResult = Manipulator.GetInstance().MakeMove(_playfieldStub.Object, direction, false); // assert Assert.IsTrue(testResult); }
public void HideProperty() { swManip = null; triadManip = null; GC.Collect(); }
/// <summary> /// Toggles custom value textboxes when checkbox changes /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CustomMassValCheckbox_CheckedChanged(object sender, EventArgs e) { currentLink.UseCustomInertial = CustomMassValCheckbox.Checked; PhysicalButton.Enabled = !CustomMassValCheckbox.Checked; toggleCOMTextboxes(); if (CustomMassValCheckbox.Checked) { swManip = currentLink.modelDoc.ModelViewManager.CreateManipulator((int)swManipulatorType_e.swTriadManipulator, this); triadManip = swManip.GetSpecificManipulator(); triadManip.DoNotShow = (int)swTriadManipulatorDoNotShow_e.swTriadManipulatorDoNotShowXYRING | (int)swTriadManipulatorDoNotShow_e.swTriadManipulatorDoNotShowYZRING | (int)swTriadManipulatorDoNotShow_e.swTriadManipulatorDoNotShowZXRING | (int)swTriadManipulatorDoNotShow_e.swTriadManipulatorDoNotShowXYPlane | (int)swTriadManipulatorDoNotShow_e.swTriadManipulatorDoNotShowYZPlane | (int)swTriadManipulatorDoNotShow_e.swTriadManipulatorDoNotShowZXPlane; triadManip.Origin = currentLink.swApp.GetMathUtility().CreatePoint(new double[] { currentLink.ComX, currentLink.ComY, currentLink.ComZ }); startOrigin = triadManip.Origin; triadManip.UpdatePosition(); swManip.Show(currentLink.modelDoc); } else { InertiaButton_Click(null, null); HideProperty(); } }
/// <summary> /// Updates manipulators to reflect the contact change. /// </summary> /// <param name="contactEvent">The new ContactTargetEvent</param> /// <param name="details">The contacEvent.HitTestDetails as ScrollViewerHitTestDetails</param> private void UpdateCurrentManipulators(ContactTargetEvent contactEvent, ScrollViewerHitTestDetails details) { // Try to find the changed contact in the manipulators list. bool foundManipulator = false; for (int i = 0; i < manipulations.Count; i++) { Manipulator manipulator = manipulations[i]; if (manipulator.ManipulatorId == contactEvent.Contact.Id) { manipulations.Remove(manipulator); Manipulator manipulatorToAdd = new Manipulator(contactEvent.Contact.Id, ConvertFromHorizontalValueToScreenSpace(details.HorizontalPosition), ConvertFromVerticalValueToScreenSpace(details.VerticalPosition)); // Performance: It doesn't matter where we insert, but if all the contacts are being updated, // then putting the most recent change at the end will mean that there is one less contact // to go through the next time this loop is executed. if (manipulations.Count == 0) { manipulations.Add(manipulatorToAdd); } else { manipulations.Insert(manipulations.Count - 1, manipulatorToAdd); } foundManipulator = true; break; } } // The manipulator isn't in the list so add it. if (!foundManipulator) { manipulations.Add(new Manipulator(contactEvent.Contact.Id, ConvertFromHorizontalValueToScreenSpace(details.HorizontalPosition), ConvertFromVerticalValueToScreenSpace(details.VerticalPosition))); } }
/// <summary> /// Clears the origin previews /// </summary> public void ClearOriginPreview() { if (swManip != null) { swManip.Visible = false; swManip.Remove(); swManip = null; originTriad = null; } }
/// <summary> /// Draws the preview triad for the origin /// </summary> private void DrawOriginPreview() { if (!inPropertyPage || groupBox.Expanded == false) return; MathVector xAxisVector = RobotInfo.mathUtil.CreateVector(new double[]{1,0,0}); MathVector yAxisVector = RobotInfo.mathUtil.CreateVector(new double[]{0,1,0}); MathVector zAxisVector = RobotInfo.mathUtil.CreateVector(new double[]{0,0,1}); if (swManip == null) { swManip = modelDoc.ModelViewManager.CreateManipulator((int)swManipulatorType_e.swTriadManipulator, this); originTriad = swManip.GetSpecificManipulator(); } if (xVector != null) { originTriad.XAxis = xVector; if (yVector != null) { originTriad.YAxis = yVector; originTriad.ZAxis = xVector.Cross(yVector).Normalise(); } else { MathVector tempAxis = zAxisVector.Cross(xVector); if(tempAxis.GetLength() < VectorCalcs.errorVal) tempAxis = yAxisVector; else tempAxis = tempAxis.Normalise(); originTriad.YAxis = tempAxis; originTriad.ZAxis = xVector.Cross(tempAxis).Normalise(); } } else { originTriad.XAxis = xAxisVector; originTriad.YAxis = yAxisVector; originTriad.ZAxis = zAxisVector; } originTriad.Origin = RobotInfo.mathUtil.CreatePoint(OriginValues.Point); originTriad.UpdateScale(80); originTriad.DoNotShow = (int)swTriadManipulatorDoNotShow_e.swTriadManipulatorDoNotShowXYPlane | (int)swTriadManipulatorDoNotShow_e.swTriadManipulatorDoNotShowXYRING | (int)swTriadManipulatorDoNotShow_e.swTriadManipulatorDoNotShowYZPlane | (int)swTriadManipulatorDoNotShow_e.swTriadManipulatorDoNotShowYZRING | (int)swTriadManipulatorDoNotShow_e.swTriadManipulatorDoNotShowZXPlane | (int)swTriadManipulatorDoNotShow_e.swTriadManipulatorDoNotShowZXRING; originTriad.UpdatePosition(); if (!swManip.Visible) { swManip.Show(modelDoc); } }
/// <summary> /// Returns the average of the captured contacts in the ThumbList. /// </summary> /// <returns></returns> private float AverageCapturedContactsInThumbList() { float average = 0; int count = 0; if (manipulationProcessor == null) { manipulationProcessor = new Affine2DManipulationProcessor(Affine2DManipulations.TranslateX); // The coordinate doesn't matter we always deal in 1 dimension. manipulationProcessor.Affine2DManipulationCompleted += new EventHandler<Affine2DOperationCompletedEventArgs>(OnAffine2DManipulationCompleted); } List<Manipulator> currentManipulators = new List<Manipulator>(); List<Manipulator> removedManipulators = new List<Manipulator>(); // Go through the contacts which are captured on the thumb and average them. for (int i = 0; i < thumbCapturedContactsList.Count; i++) { int id = thumbCapturedContactsList[i]; // Make sure the contact is captured. if (ContactsCaptured.Contains(id)) { // Make sure we have hit test details for this contact. if (captureContactsHitTestDetails.ContainsKey(id)) { Debug.Assert(distanceOffset.ContainsKey(id), "Offset wasn't calculated for this contact."); float offset = distanceOffset[id]; ScrollBarHitTestDetails details = captureContactsHitTestDetails[id]; // The Manipulations should all run in screen space. Manipulator manipulator = new Manipulator(id, ToScreenSpace(details.Position - offset), 0); // Make sure the value of each contact accounts for offset. average += captureContactsHitTestDetails[id].Position - offset; count++; currentManipulators.Add(manipulator); } else { Debug.Fail("The contact was captured, but wasn't in the hit test details dictionary."); } } else { float offset = distanceOffset[id]; ScrollBarHitTestDetails details = captureContactsHitTestDetails[id]; // The Manipulations should all run in screen space. Manipulator manipulator = new Manipulator(id, ToScreenSpace(details.Position - offset), 0); removedManipulators.Add(manipulator); // The contact was released so we need to remove it. thumbCapturedContactsList.Remove(id); i--; } } manipulationProcessor.ProcessManipulators(stopwatch.ElapsedTicks, currentManipulators, removedManipulators); // Don't divide by zero. if (count != 0) average = average / count; return average; }
public Manipulator addManipulator(Manipulator manipulator) { listManipulators.Add(manipulator); return manipulator; }