//===================================================================== INITIALIZE public Window(SelectionMethod windowType) { if (windowType == SelectionMethod.ForegroundParent) _handle = GetForegroundWindow(); else if (windowType == SelectionMethod.MousePositionFrame) { Point pt; GetCursorPos(out pt); _handle = WindowFromPoint(pt.X, pt.Y); } }
internal ICollection<TypingGesture> ProcessGestures(Skeleton skeleton, double deltaTimeMilliseconds, Point3D cursor, Point3D secondaryCursor, SelectionMethod selectionM, Key highlightedKey, bool userClicked) { List<TypingGesture> gestures = null; if (selectionM == SelectionMethod.Push) gestures = ProcessGesturesPush(cursor); else if (selectionM == SelectionMethod.Swipe) gestures = ProcessGesturesSwipe(cursor); else if (selectionM == SelectionMethod.Timer) gestures = ProcessGesturesTimer(cursor, deltaTimeMilliseconds, highlightedKey); else if (selectionM == SelectionMethod.SecondHand) gestures = ProcessGesturesSecondHand(cursor, secondaryCursor, deltaTimeMilliseconds, highlightedKey); else if (selectionM == SelectionMethod.Click) gestures = ProcessGesturesClick(cursor, userClicked); return gestures; }
internal override Point3D FindCursorPosition(Skeleton skeleton, LayoutAnchoring anchoring, System.Windows.Size layoutSize, TypingDexterity dexterity, SelectionMethod selectionM, ArmStretch armStretch) { TypingDexterity opposite = TypingDexterity.Right; if (dexterity == TypingDexterity.Right) opposite = TypingDexterity.Left; SetJointsForDexterity(opposite); Joint shoulder = skeleton.Joints.SingleOrDefault(tmp => tmp.JointType == Shoulder); Joint hand = skeleton.Joints.SingleOrDefault(tmp => tmp.JointType == Hand); Joint wrist = skeleton.Joints.SingleOrDefault(tmp => tmp.JointType == Wrist); Joint hip = skeleton.Joints.SingleOrDefault(tmp => tmp.JointType == Hip); double pointerPosX = (hand.Position.X + wrist.Position.X) / 2; double pointerPosY = (hand.Position.Y + wrist.Position.Y) / 2; double pointerPosZ = (hand.Position.Z + wrist.Position.Z) / 2; //this positions are calculated from the hip double posX = Math.Abs(pointerPosX - hip.Position.X); double posY = Math.Abs(pointerPosY - hip.Position.Y); double posZ = Math.Abs(pointerPosZ - hip.Position.Z); return new Point3D(posX, posY, posZ); }
public static int SelectServer(int ArrivalTime,SelectionMethod SelectionMethod = SelectionMethod.Priority) { FreeSevers(ArrivalTime); //priority if (SelectionMethod == SelectionMethod.Priority) { if (Available.Count >= 1) { int highest = Available[0].Priority; int index = 0; for (int i = 1; i < Available.Count; i++) { if (Available[i].Priority < highest) { highest = Available[i].Priority; index = i; } } Server tmp = Available[index]; Available.RemoveAt(index); Occupied.Add(tmp); return tmp.Number; } else { throw new Exception("busy"); } } //Utilization time else if (SelectionMethod == SelectionMethod.UtilizationTime)//least utilization keda msh s7! { if (Available.Count >= 1) { int highest = Available[0].UtilizationTime; int index = 0; for (int i = 1; i < Available.Count; i++) { if (Available[i].UtilizationTime < highest) { highest = Available[i].UtilizationTime; index = i; } } Server tmp = Available[index]; Available.RemoveAt(index); Occupied.Add(tmp); return tmp.Number; } else { throw new Exception("busy"); } } //random else { if (Available.Count >= 1) { Random r = new Random(); int rnd = r.Next(0, Available.Count); Server tmp = Available[rnd]; Available.RemoveAt(rnd); Occupied.Add(tmp); return tmp.Number; } else { throw new Exception("busy"); } } }
/// <summary> /// Actualiza la lista de personajes seleccionados, utilizando un metodo de seleccion predefinido /// </summary> public void update() { var ui = CommandosUI.Instance; this.selectionMethod = (SelectionMethod)GuiController.Instance.Modifiers.getValue("Seleccion"); if (!this.selecting && ui.mouseDown(TgcD3dInput.MouseButtons.BUTTON_LEFT)) { //arranca a seleccionar if (this.selectionMethod.canBeginSelection()) { this.selectionMethod.updateSelection(); this.lastMousePos = ui.ViewportMousePos; this.initMousePos = ui.ViewportMousePos; this.selecting = true; } } else if (this.selecting && ui.mouseUp(TgcD3dInput.MouseButtons.BUTTON_LEFT)) { //termina de seleccionar this.deselectIfNotShift(); Vector2 actualMousePos = ui.ViewportMousePos; if (GeneralMethods.isCloseTo(actualMousePos, this.initMousePos, 1)) { //seleccion simple this.selectCharacterByRay(); } else { //seleccion multiple List<Character> newSelectedCharacters = this.selectionMethod.endAndRetSelection(); foreach (Character ch in newSelectedCharacters) this.addSelectedCharacter(ch); } this.selecting = false; } else if (this.selecting) { //esta seleccionando Vector2 actualMousePos = ui.ViewportMousePos; if(!GeneralMethods.isCloseTo(actualMousePos, this.lastMousePos, 1)) { this.lastMousePos = actualMousePos; this.selectionMethod.updateSelection(); } this.selectionMethod.renderSelection(); } }
private void OnGUI() { if (skin == null) { skin = Object.Instantiate(GUI.skin) as GUISkin; skin.font = font; skin.toggle.fontSize = 10; } GUI.skin = skin; if (selected) { DrawOutline(selectedRect, selectedTime / hoverTime, 4f, Color.yellow); } Rect fullScreenRect = new Rect(0, 0, Screen.width, Screen.height); GUILayout.FlexibleSpace(); Rect backgroundRect = fullScreenRect; backgroundRect.y = Screen.height - 50f; GUI.color = new Color(1f, 1f, 1f, 0.25f); GUI.DrawTexture(backgroundRect, whiteTex); GUI.color = Color.white; GUILayout.BeginArea(fullScreenRect); selectionMethod = (SelectionMethod)GUILayout.Toolbar((int)selectionMethod, selectionMethods); GUILayout.Label(selectionDescriptions[(int)selectionMethod]); // GUILayout.Label(pinchDistance.ToString()); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.Space(10f); GUILayout.Label("Experiment #4: Basic Selections"); GUILayout.FlexibleSpace(); GUILayout.Label(logo, GUIStyle.none); GUILayout.Space(10f); GUILayout.EndHorizontal(); GUILayout.Space(10f); GUILayout.EndArea(); if (snapshotCountdown > 0f) { GUIStyle s = new GUIStyle(); s.fontSize = 50; GUILayout.BeginArea(fullScreenRect); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label(Mathf.CeilToInt(snapshotCountdown).ToString(), s); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.EndArea(); } if (showInstructions) { GUI.color = new Color(0f, 0f, 0f, 0.5f); GUI.DrawTexture(fullScreenRect, whiteTex); GUI.color = Color.white; GUILayout.BeginArea(fullScreenRect); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("Draw a circle to take a picture\nAfterwards, swipe to scatter"); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.EndArea(); } }
internal virtual Point3D FindCursorPosition(Skeleton skeleton, LayoutAnchoring anchoring, Size layoutSize, TypingDexterity dexterity, SelectionMethod selectionM, ArmStretch armStretch) { SetJointsForDexterity(dexterity); Joint shoulder = skeleton.Joints.SingleOrDefault(tmp => tmp.JointType == Shoulder); Joint hand = skeleton.Joints.SingleOrDefault(tmp => tmp.JointType == Hand); Joint wrist = skeleton.Joints.SingleOrDefault(tmp => tmp.JointType == Wrist); Joint hip = skeleton.Joints.SingleOrDefault(tmp => tmp.JointType == Hip); double width = layoutSize.Width / 100; double height = layoutSize.Height / 100; if (anchoring == LayoutAnchoring.VerticalShoulderLevel) { planeCenter.X = shoulder.Position.X + width / 2; planeCenter.Y = shoulder.Position.Y; } else if (anchoring == LayoutAnchoring.VerticalBodyCenterLevel) { planeCenter.X = shoulder.Position.X + width / 2; planeCenter.Y = (shoulder.Position.Y + hip.Position.Y) / 2; } else if (anchoring == LayoutAnchoring.HorizontalBottomLevel) { planeCenter.X = shoulder.Position.X + width / 2 + 0.05; //because of the coordinate direction planeCenter.Z = shoulder.Position.Z - height / 2 - 0.05; } double pointerPosX = (hand.Position.X + wrist.Position.X) / 2; double distX = pointerPosX - planeCenter.X; double pointerPosY = (hand.Position.Y + wrist.Position.Y) / 2; double distY = pointerPosY - planeCenter.Y; double pointerPosZ = (hand.Position.Z + wrist.Position.Z) / 2; double distZ = pointerPosZ - planeCenter.Z; Point3D pointer = new Point3D(pointerPosX, pointerPosY, pointerPosZ); Point3D origin = new Point3D(shoulder.Position.X, shoulder.Position.Y, shoulder.Position.Z); System.Windows.Media.Media3D.Vector3D distanceFromOrigin = ToolBox.CalculateDisplacement( (System.Windows.Media.Media3D.Vector3D)pointer, (System.Windows.Media.Media3D.Vector3D)origin); Point3D cursorP = new Point3D(-1, -1, -1); if (armStretch == ArmStretch.Long && distanceFromOrigin.Length < LONG_ARM_CONSTRAIN) return lastPos = cursorP; if (armStretch == ArmStretch.Short) { if (anchoring == LayoutAnchoring.VerticalShoulderLevel || anchoring == LayoutAnchoring.VerticalBodyCenterLevel) { if (Math.Abs(distanceFromOrigin.Z) > SHORT_ARM_CONSTRAIN) return lastPos = cursorP; } else if (anchoring == LayoutAnchoring.HorizontalBottomLevel) { if (Math.Abs(distanceFromOrigin.Y) > SHORT_ARM_CONSTRAIN) return lastPos = cursorP; } } //if the pointer is close enough to plane if (anchoring == LayoutAnchoring.VerticalShoulderLevel || anchoring == LayoutAnchoring.VerticalBodyCenterLevel) { //out of width boundary if (Math.Abs(distX) > width / 2) return lastPos = cursorP; //out of height boundary if (Math.Abs(distY) > height / 2) return lastPos = cursorP; double absX = distX + width / 2; double absY = height - ((height / 2) + distY); cursorP.X = absX / width; cursorP.Y = absY / height; cursorP.Z = distZ; cursorP = FreezeMovementesForSelectionGesture(cursorP, selectionM); lastPos = cursorP; } else //if (anchoring == LayoutAnchoring.HorizontalBottomLevel) { //out of column boundary if (Math.Abs(distX) > width / 2) return lastPos = cursorP; //out of row boundary if (Math.Abs(distZ) > height / 2) return lastPos = cursorP; double absX = distX + width / 2; double absZ = ((height / 2) + distZ); cursorP.X = absX / width; cursorP.Y = absZ / height; cursorP.Z = distY; cursorP = FreezeMovementesForSelectionGesture(cursorP, selectionM); lastPos = cursorP; } //if not close to plane, return an invalid cursorP return lastPos = cursorP; }
private Point3D FreezeMovementesForSelectionGesture(Point3D cursorP, SelectionMethod selectionM) { cursorP.FrozenX = cursorP.X; cursorP.FrozenY = cursorP.Y; cursorP.FrozenZ = cursorP.Z; if (selectionM == SelectionMethod.Push) { //If the movement looks like a push (movement in Z), then it ignores the movements in the other two dimensions if (Math.Abs(lastPos.FrozenZ - cursorP.Z) >= TypingMethod.PUSH_AXIS_DISTANCE) { cursorP.IsFrozen = true; cursorP.X = lastPos.X; cursorP.Y = lastPos.Y; //cursorP.Z = lastPos.Z; } } else if (selectionM == SelectionMethod.Swipe) { //If the movement looks like a swipe (movement in X), then it ignores the movements in the other two dimensions if (Math.Abs(lastPos.X - cursorP.X) < TypingMethod.SWIPE_THRESHOLD) return cursorP; //if (Math.Abs(lastPos.Y - cursorP.Y) >= TypingMethod.SWIPE_THRESHOLD) // return cursorP; cursorP.IsFrozen = true; cursorP.FrozenX = lastPos.FrozenX; cursorP.FrozenY = lastPos.FrozenY; cursorP.FrozenZ = lastPos.FrozenZ; } return cursorP; }