/// <summary> /// Initializes a new instance of the <see cref="CaptionButton"/> class. /// </summary> /// <param name="hitTest">The hit test result of this button.</param> public CaptionButton(HitTest hitTest) { HitTest = hitTest; _hovered = false; _enabled = true; _pressed = false; }
void host_MouseDown(object sender, MouseButtonEventArgs e) { // Perform a hist test. HitTest hitTest = new HitTest(); hitTest.DoHitTest(host, e.GetPosition(host)); // Go through the hits, looking for a draggable object. foreach (var hit in hitTest.Hits) { // Is this a draggable object? FrameworkElement foundDragElement, foundDragSource; if (hit is FrameworkElement && IsInDraggableElement((FrameworkElement)hit, out foundDragElement, out foundDragSource)) { // We've found an object to drag - store its data. dragElement = foundDragElement; dragData = dragElement.DataContext; dragSource = foundDragSource; initialMousePosition = e.GetPosition(host); initialElementOffset = e.GetPosition(dragElement); break; } } }
public bool Filter(HitTest info) { switch (info.type) { case HitTest.Type.MeleeAttack: if ((flags & Flags.Melee) == 0) { return(false); } break; case HitTest.Type.ProjectileEffect: case HitTest.Type.Projectile: if ((flags & Flags.Shootable) == 0) { return(false); } break; case HitTest.Type.Use: if ((flags & Flags.Usable) == 0) { return(false); } break; } return(true); }
private void SetCursor(HitTest mode) { IntPtr handle = IntPtr.Zero; switch (mode) { case HitTest.HTTOP: case HitTest.HTBOTTOM: handle = User32.LoadCursor(IntPtr.Zero, (int)IdcStandardCursors.IDC_SIZENS); break; case HitTest.HTLEFT: case HitTest.HTRIGHT: handle = User32.LoadCursor(IntPtr.Zero, (int)IdcStandardCursors.IDC_SIZEWE); break; case HitTest.HTTOPLEFT: case HitTest.HTBOTTOMRIGHT: handle = User32.LoadCursor(IntPtr.Zero, (int)IdcStandardCursors.IDC_SIZENWSE); break; case HitTest.HTTOPRIGHT: case HitTest.HTBOTTOMLEFT: handle = User32.LoadCursor(IntPtr.Zero, (int)IdcStandardCursors.IDC_SIZENESW); break; } if (handle != IntPtr.Zero) { User32.SetCursor(handle); } }
/// LayoutEditImage: MouseMove /// @param sender 使用しない /// @param e Client座標系でのマウス座標(GetPosition(...))の取得が可能 private void LayoutEditImage_MouseMove(object sender, MouseEventArgs e) { // 前処理 var image = (IInputElement)sender; var relativeMousePoint = this.GetRelativeMousePoint(image, e); // 動作中でなければカーソルを変更するだけ if (!this.moveAndSize.IsRunning) { LayoutElement hitElement; HitModes hitMode; HitTest.TryHitTest(App.Profile, relativeMousePoint, out hitElement, out hitMode); this.Cursor = LayoutEdit.HitModesToCursors[hitMode]; return; } // Move or Size this.moveAndSize.MousePoint = relativeMousePoint; var nextLTRB = this.moveAndSize.Do(Keyboard.Modifiers == ModifierKeys.Shift); App.Profile.Current.BoundRelativeLeft = nextLTRB.Left; App.Profile.Current.BoundRelativeTop = nextLTRB.Top; App.Profile.Current.BoundRelativeRight = nextLTRB.Right; App.Profile.Current.BoundRelativeBottom = nextLTRB.Bottom; // 描画自体はCompositionTarget.Renderingで行う }
public bool Filter(HitTest info) { switch (info.type) { case HitTest.Type.ProjectileEffect: case HitTest.Type.Projectile: { if ((int)(this.flags & ColliderInfo.Flags.Shootable) != 0) { break; } return(false); } case HitTest.Type.MeleeAttack: { if ((int)(this.flags & ColliderInfo.Flags.Melee) != 0) { break; } return(false); } case HitTest.Type.Use: { if ((int)(this.flags & ColliderInfo.Flags.Usable) != 0) { break; } return(false); } } return(true); }
protected IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { switch (msg) { case HitTest.WM_NCHITTEST: handled = true; return(HitTest.Hit(lParam, this.Top, this.Left, this.ActualHeight, this.ActualWidth)); } return(IntPtr.Zero); }
private HitTest GetResizeMode() { HitTest mode = HitTest.HTNOWHERE; RECT rect = new RECT(); POINT point = GetRelativeMousePosition(); User32.GetWindowRect(Handle, ref rect); switch (_side) { case ShadowDockPositon.Top: int width = rect.right - rect.left; if (point.x < ShadowSize) { mode = HitTest.HTTOPLEFT; } else if (point.x > width - ShadowSize) { mode = HitTest.HTTOPRIGHT; } else { mode = HitTest.HTTOP; } break; case ShadowDockPositon.Bottom: width = rect.right - rect.left; if (point.x < ShadowSize) { mode = HitTest.HTBOTTOMLEFT; } else if (point.x > width - ShadowSize) { mode = HitTest.HTBOTTOMRIGHT; } else { mode = HitTest.HTBOTTOM; } break; case ShadowDockPositon.Left: mode = HitTest.HTLEFT; break; case ShadowDockPositon.Right: mode = HitTest.HTRIGHT; break; } return(mode); }
public virtual void Attack(Character target) { HitTest ht = new HitTest(); if (ht.CanHit(this, target)) { DamageCalculator dc = new DamageCalculator(); int damage = dc.GetDamage(this, target); target.TakeDamage(damage); } }
/// <summary> /// Gets the command button with the specified HitTest. /// </summary> /// <param name="hitTest">The hitTest.</param> /// <returns>the CaptionButton instance or null if no button was found.</returns> private CaptionButton CommandButtonByHitTest(HitTest hitTest) { foreach (CaptionButton button in _captionButtons) { if (button.HitTest == hitTest) { return(button); } } return(null); }
public override bool CanHit(HitTest info) { if (info.HitEntity == null) { return(false); } if (info.HitEntity is BasePlayer) { return(false); } return(info.HitEntity is BaseCombatEntity); }
/// <summary> /// Gets the command button with the specified HitTest. /// </summary> /// <param name="hitTest">The hitTest.</param> /// <returns>the CaptionButton instance or null if no button was found.</returns> protected internal virtual CaptionButton CommandButtonByHitTest(HitTest hitTest) { foreach (CaptionButton button in _captionButtons) { if (button.HitTest == hitTest) { return(button); } } return(null); }
/// <summary> /// Initializes the object and all control elements of the game. /// </summary> private GameObjectManager() { teamMgr = new TeamManager(); fightMgr = new FightManager(); objectCreator = new ObjectCreator(); moveMgr = new MoveManager(); groupMgr = new GroupManager(); propertyMgr = new PropertyManager(); hitTest = new HitTest(); solarSystemMgr = new SolarSystemManager(); gameSerializer = new GameSerializer(); }
public static void TraceAllTrampoline(HitTest test, List <TraceInfo> traces, int layerMask = -5) { int a = 12; int b = 9; int c = 12 * 9 - 4; int d = c * a - 15; int e = d + a; int f = b + c; a = b + 12; b = c - 4; d = a + b; e = a + c + d; }
private void CastMouseDown() { if (!ExternalResizeEnable) { return; } HitTest mode = GetResizeMode(); if (MouseDown != null) { SideGlowResizeArgs args = new SideGlowResizeArgs(_side, mode); MouseDown(this, args); } }
private void CastMouseDown(Point point) { if (!ExternalResizeEnable) { return; } HitTest mode = GetResizeMode(); if (MouseDown != null) { FormShadowResizeArgs args = new FormShadowResizeArgs(_side, mode, point); MouseDown(this, args); } }
protected HitTest GetSizeMode(POINT point) { HitTest mode = HitTest.HTNOWHERE; int x = point.x, y = point.y; if (WindowState == FormWindowState.Normal && CanResize) { if (x < CornerAreaSize & y < CornerAreaSize) { mode = HitTest.HTTOPLEFT; } else if (x <CornerAreaSize& y + CornerAreaSize> this.Height - CornerAreaSize) { mode = HitTest.HTBOTTOMLEFT; } else if (x + CornerAreaSize > this.Width - CornerAreaSize & y + CornerAreaSize > this.Height - CornerAreaSize) { mode = HitTest.HTBOTTOMRIGHT; } else if (x + CornerAreaSize > this.Width - CornerAreaSize & y < CornerAreaSize) { mode = HitTest.HTTOPRIGHT; } else if (x < CornerAreaSize) { mode = HitTest.HTLEFT; } else if (x + CornerAreaSize > this.Width - CornerAreaSize) { mode = HitTest.HTRIGHT; } else if (y < CornerAreaSize) { mode = HitTest.HTTOP; } else if (y + CornerAreaSize > this.Height - CornerAreaSize) { mode = HitTest.HTBOTTOM; } } return(mode); }
//internal static HitTest GetSizeMode(Form form, POINT point) //{ // HitTest mode = HitTest.HTCLIENT; // int x = point.x, y = point.y; // if (form.WindowState == FormWindowState.Normal && (form.FormBorderStyle == FormBorderStyle.SizableToolWindow || form.FormBorderStyle == FormBorderStyle.Sizable)) // { // var rect = new RECT(); // User32.GetWindowRect(form.Handle, ref rect); // mode = Win32.GetSizeMode(point, rect.Width, rect.Height); // } // return mode; //} internal static HitTest GetSizeMode(POINT point, int width, int height) { HitTest mode = HitTest.HTCLIENT; int x = point.x, y = point.y; if (x < CornerAreaSize & y < CornerAreaSize) { mode = HitTest.HTTOPLEFT; } else if (x <CornerAreaSize& y + CornerAreaSize> height - CornerAreaSize) { mode = HitTest.HTBOTTOMLEFT; } else if (x + CornerAreaSize > width - CornerAreaSize & y + CornerAreaSize > height - CornerAreaSize) { mode = HitTest.HTBOTTOMRIGHT; } else if (x + CornerAreaSize > width - CornerAreaSize & y < CornerAreaSize) { mode = HitTest.HTTOPRIGHT; } else if (x < CornerAreaSize) { mode = HitTest.HTLEFT; } else if (x + CornerAreaSize > width - CornerAreaSize) { mode = HitTest.HTRIGHT; } else if (y < CornerAreaSize) { mode = HitTest.HTTOP; } else if (y + CornerAreaSize > height - CornerAreaSize) { mode = HitTest.HTBOTTOM; } return(mode); }
/// <summary> /// Destroys the current game (mission) and sets a new empty control elements of the game. /// </summary> public void DestroyGame() { // Destroys targeted group (destroys pointers). groupMgr.UntargetGroup(); // Destroys all object in the game. foreach (var item in objectCreator.GetInicializedSolarSystems()) { item.Destroy(); } // Creates a new empty control elements of the game. teamMgr = new TeamManager(); fightMgr = new FightManager(); objectCreator = new ObjectCreator(); moveMgr = new MoveManager(); groupMgr = new GroupManager(); propertyMgr = new PropertyManager(); hitTest = new HitTest(); solarSystemMgr = new SolarSystemManager(); }
protected override void WndProc(ref Message m) { base.WndProc(ref m); switch (m.Msg) { case WM_NCHITTEST: IntPtr hNowhere = new IntPtr((int)HitTest.Nowhere); HitTest value = (HitTest)m.Result; switch (value) { case HitTest.Top: case HitTest.Bottom: if (!VerticalResizable) { m.Result = hNowhere; } break; case HitTest.Left: case HitTest.Right: if (!HorizontalResizable) { m.Result = hNowhere; } break; case HitTest.TopLeft: case HitTest.TopRight: case HitTest.BottomLeft: case HitTest.BottomRight: if (!VerticalResizable || !HorizontalResizable) { m.Result = hNowhere; } break; } break; } }
private void SetCursor() { if (!ExternalResizeEnable) { return; } IntPtr handle = IntPtr.Zero; //User32.LoadCursor(IntPtr.Zero, (int)IDC_STANDARD_CURSORS.IDC_HAND); HitTest mode = GetResizeMode(); switch (mode) { case HitTest.HTTOP: case HitTest.HTBOTTOM: handle = User32.LoadCursor(IntPtr.Zero, (int)IDC_STANDARD_CURSORS.IDC_SIZENS); break; case HitTest.HTLEFT: case HitTest.HTRIGHT: handle = User32.LoadCursor(IntPtr.Zero, (int)IDC_STANDARD_CURSORS.IDC_SIZEWE); break; case HitTest.HTTOPLEFT: case HitTest.HTBOTTOMRIGHT: handle = User32.LoadCursor(IntPtr.Zero, (int)IDC_STANDARD_CURSORS.IDC_SIZENWSE); break; case HitTest.HTTOPRIGHT: case HitTest.HTBOTTOMLEFT: handle = User32.LoadCursor(IntPtr.Zero, (int)IDC_STANDARD_CURSORS.IDC_SIZENESW); break; } if (handle != IntPtr.Zero) { User32.SetCursor(handle); } }
private int GetSizeMode(HitTest handles) { switch (handles) { case HitTest.HTNOWHERE: case HitTest.HTCAPTION: return(0); case HitTest.HTLEFT: return((int)ResizeDirection.Left); case HitTest.HTRIGHT: return((int)ResizeDirection.Right); case HitTest.HTTOP: return((int)ResizeDirection.Top); case HitTest.HTTOPLEFT: return((int)ResizeDirection.TopLeft); case HitTest.HTTOPRIGHT: return((int)ResizeDirection.TopRight); case HitTest.HTBOTTOM: return((int)ResizeDirection.Bottom); case HitTest.HTBOTTOMLEFT: return((int)ResizeDirection.BottomLeft); case HitTest.HTBOTTOMRIGHT: return((int)ResizeDirection.BottomRight); default: return(0); } }
public static int ToInt(this HitTest handles) { switch (handles) { case HitTest.HTNOWHERE: case HitTest.HTCAPTION: return(0); case HitTest.HTLEFT: return((int)ResizeDirection.Left); case HitTest.HTRIGHT: return((int)ResizeDirection.Right); case HitTest.HTTOP: return((int)ResizeDirection.Top); case HitTest.HTTOPLEFT: return((int)ResizeDirection.TopLeft); case HitTest.HTTOPRIGHT: return((int)ResizeDirection.TopRight); case HitTest.HTBOTTOM: return((int)ResizeDirection.Bottom); case HitTest.HTBOTTOMLEFT: return((int)ResizeDirection.BottomLeft); case HitTest.HTBOTTOMRIGHT: return((int)ResizeDirection.BottomRight); default: return(0); } }
// Handle a button release. protected void OnButtonRelease(int x, int y, int x_root, int y_root, ButtonName button, ModifierMask modifiers) { // Set the cursor and bail out if we aren't in a click mode. if(clickMode == HitTest.Outside) { SetCursor(x, y); return; } // Bail out if it wasn't the select button that was released. if(!IsSelect(button)) { return; } // Get the area currently occupied by the cursor. HitTest hitTest = PerformHitTest(x, y); // Process the button release according to the click mode. switch(clickMode) { case HitTest.Close: case HitTest.Maximize: case HitTest.Minimize: case HitTest.Restore: case HitTest.Help: { if(ChangeButtonState(clickMode, false) && clickMode == hitTest) { // A caption button has been clicked. switch(clickMode) { case HitTest.Close: child.Close(); break; case HitTest.Maximize: if(child.IsIconic) { child.Deiconify(); } child.Maximize(); break; case HitTest.Minimize: child.Iconify(); break; case HitTest.Restore: if(child.IsIconic) { child.Deiconify(); } else { child.Restore(); } break; case HitTest.Help: child.Help(); break; } } } break; } // Exit the click mode and return to normal. clickMode = HitTest.Outside; SetCursor(x, y); }
// Change the state of a caption button. Returns true if the // button was pressed before we changed its state. private bool ChangeButtonState(HitTest hitTest, bool pressed) { // Determine what change we need to apply. CaptionFlags buttonsToDraw = (CaptionFlags)0; CaptionFlags pressedState = (CaptionFlags)0; CaptionFlags origFlags = flags; switch(hitTest) { case HitTest.Close: { buttonsToDraw = CaptionFlags.HasClose; pressedState = CaptionFlags.ClosePressed; } break; case HitTest.Maximize: { buttonsToDraw = CaptionFlags.HasMaximize; pressedState = CaptionFlags.MaximizePressed; } break; case HitTest.Minimize: { buttonsToDraw = CaptionFlags.HasMinimize; pressedState = CaptionFlags.MinimizePressed; } break; case HitTest.Restore: { buttonsToDraw = CaptionFlags.HasRestore; pressedState = CaptionFlags.RestorePressed; } break; case HitTest.Help: { buttonsToDraw = CaptionFlags.HasHelp; pressedState = CaptionFlags.HelpPressed; } break; } if(pressed) { flags |= pressedState; } else { flags &= ~pressedState; } // Redraw the caption buttons to match the state change. if(flags != origFlags) { Rectangle rect = new Rectangle (FrameBorderSize, FrameBorderSize, width - FrameBorderSize * 2, captionHeight - FrameBorderSize); using(Graphics graphics = new Graphics(this)) { DrawCaptionButtons (graphics, rect, flags, buttonsToDraw); } } return ((origFlags & pressedState) != 0); }
// Construct a new caption widget underneath "parent", which // encapsulates the given "child" widget. public CaptionWidget(Widget parent, String name, int x, int y, int width, int height, Type type) : base(parent, x, y, width + FrameBorderSize * 2, height + GetCaptionHeight(parent) + FrameBorderSize, new Color(StandardColor.Foreground), new Color(StandardColor.Background)) { // Don't automatically map the child when it is created. AutoMapChildren = false; // Calculate the size of the caption, including the border. captionHeight = GetCaptionHeight(parent); // The caption widget is not focusable. Focusable = false; // Create the "top-level" window object for the child. ConstructorInfo ctor = type.GetConstructor (new Type [] {typeof(Widget), typeof(String), typeof(int), typeof(int), typeof(int), typeof(int)}); child = (TopLevelWindow)(ctor.Invoke (new Object[] {this, name, FrameBorderSize, captionHeight, width, height})); child.reparented = true; // Set the default flags. flags = CaptionFlags.HasClose | CaptionFlags.HasMaximize | CaptionFlags.HasMinimize; clickMode = HitTest.Outside; // Perform an initial move/resize to position the child // window properly within the MDI client area. MoveResize(this.x, this.y, this.width, this.height); // Make sure that we have the inactive grab. MakeInactive(); }
internal SideGlowResizeArgs(Dock side, HitTest mode) { _side = side; _mode = mode; }
//------------------------------------------------------------------- /// LayoutEditImage: MouseDown /// @param sender 使用しない /// @param e Client座標系でのマウス座標(GetPosition(...))の取得が可能 private void LayoutEditImage_MouseDown(object sender, MouseButtonEventArgs e) { // マウス操作中にアプリケーションからフォーカスが外れた場合に対応 if (this.moveAndSize.IsRunning) { return; } // 左/右クリック以外はすぐに戻る if (e.ChangedButton != MouseButton.Left && e.ChangedButton != MouseButton.Right) { return; } // 前処理 var image = (IInputElement)sender; var relativeMousePoint = this.GetRelativeMousePoint(image, e); // HitTest LayoutElement hitElement; HitModes hitMode; if (!HitTest.TryHitTest(App.Profile, relativeMousePoint, out hitElement, out hitMode)) { return; } // 現在選択中のIndexではない場合はそれに変更する if (hitElement != App.Profile.Current) { Debug.WriteLine("MouseDown: Changing Current ...", "LayoutEdit"); App.Profile.Current = hitElement; //--------------------------------------------------------------- // Notify self // Notify other controls Commands.ProfileStructureChanged.Execute(null, this); //--------------------------------------------------------------- this.BuildDrawingGroup(); } // 右クリックの場合はCurrentを変えただけで終了(残りはコンテキストメニューに任せる) if (e.ChangedButton == MouseButton.Right) { return; } // マウスを押した場所を記録してマウスキャプチャー開始 var snapGuide = App.Options.LayoutSnap ? new SnapGuide(App.Profile) : null; this.moveAndSize.Start(App.Profile.Current, hitMode, relativeMousePoint, snapGuide); // マウスキャプチャー開始 image.CaptureMouse(); // Profileを更新 App.Profile.Open(); // CompositionTarget.Renderingの実行はコストが高いのでここだけで使う CompositionTarget.Rendering += CompositionTarget_Rendering; }
/// <summary> /// Gets the command button with the specified HitTest. /// </summary> /// <param name="hitTest">The hitTest.</param> /// <returns>the CaptionButton instance or null if no button was found.</returns> private CaptionButton CommandButtonByHitTest(HitTest hitTest) { foreach (CaptionButton button in _captionButtons) if (button.HitTest == hitTest) return button; return null; }
// Handle a button press. protected void OnButtonPress(int x, int y, int x_root, int y_root, ButtonName button, ModifierMask modifiers) { // Ignore button presses in a click mode because they // will be for something other than the select button. if(clickMode != HitTest.Outside) { return; } // Adjust the cursor to match the current position. HitTest hitTest = SetCursor(x, y); // Bail out if we are not processing the select button. if(!IsSelect(button)) { return; } // Enter the appropriate click mode. if(hitTest != HitTest.Outside && hitTest != HitTest.Client) { clickMode = hitTest; startX = x; startY = y; startWidth = width; startHeight = height; startRootX = x_root; startRootY = y_root; } // Depress a button if one was pressed. switch(hitTest) { case HitTest.Close: case HitTest.Maximize: case HitTest.Minimize: case HitTest.Restore: case HitTest.Help: { ChangeButtonState(hitTest, true); } break; } }
/// <summary> /// Initializes a new instance of the <see cref="CaptionButton"/> class. /// </summary> /// <param name="hitTest">The hit test result of this button.</param> public CaptionButton(HitTest hitTest) { HitTest = hitTest; _hovered = false; _enabled = true; _pressed = false; }
internal FormShadowResizeArgs(ShadowDockPositon side, HitTest mode, Point point) { _side = side; _mode = mode; _point = point; }
public static extern int SetWindowHitTest(Window window, HitTest callback, void *data);
void host_MouseMove(object sender, MouseEventArgs e) { // We only care about mouse moves if we have a drag element. if (dragElement == null) { return; } // Update the current mouse position. currentMousePosition = e.GetPosition(host); // We have a drag element - are we dragging? if (dragging == false) { // We're not - have we moved enough to start a drag? // Apex.Consistency.SystemParamters returns drag distances // as SystemParameters doesn't have it in silverlight. if ( (Math.Abs(initialMousePosition.X - currentMousePosition.X) >= MinimumHorizontalDragDistance) && (Math.Abs(initialMousePosition.Y - currentMousePosition.Y) >= MinimumHorizontalDragDistance)) { // We'll try starting a drag and drop. DoDragAndDropStart(dragSource, dragElement, dragData); if (dragging) { host.CaptureMouse(); } } } // If we're still not dragging, we're done. if (dragging == false) { return; } // If we have an adorner, move it. if (dragAdorner != null) { dragAdorner.Translation.X = currentMousePosition.X - initialElementOffset.X; dragAdorner.Translation.Y = currentMousePosition.Y - initialElementOffset.Y; } // Are we over a drop target? FrameworkElement dropTargetOver = null; // Perform a hist test. HitTest hitTest = new HitTest(); hitTest.DoHitTest(host, e.GetPosition(host)); foreach (var dt in hitTest.Hits) { FrameworkElement foundDropTarget; if (dt is FrameworkElement && IsInDropTarget((FrameworkElement)dt, out foundDropTarget)) { dropTargetOver = foundDropTarget; break; } } // If we are not over a drop target, clear the drop over. if (dropTargetOver == null) { dropTarget = null; return; } // If we are over a drop target and it's a new one, check // for continuing. if (dropTargetOver != dropTarget) { DoContinueDragAndDrop(dropTargetOver); } }
// Handle pointer motion events. protected void OnPointerMotion (int x, int y, int x_root, int y_root, ModifierMask modifiers) { // Set the cursor and bail out if we aren't in a click mode. if(clickMode == HitTest.Outside) { SetCursor(x, y); return; } // Get the area currently occupied by the cursor. HitTest hitTest = PerformHitTest(x, y); // Get the root co-ordinates of the MDI client window // and restrict (x_root, y_root) to its boundaries. Widget mdiClient = Parent; int clientLeft = mdiClient.X; int clientTop = mdiClient.Y; Widget parent = mdiClient.Parent; while(parent != null) { clientLeft += parent.X; clientTop += parent.Y; parent = parent.Parent; } int clientRight = clientLeft + mdiClient.Width; int clientBottom = clientTop + mdiClient.Height; if(x_root < clientLeft) { x_root = clientLeft; } else if(x_root >= clientRight) { x_root = clientRight - 1; } if(y_root < clientTop) { y_root = clientTop; } else if(y_root >= clientBottom) { y_root = clientBottom - 1; } // Get the amount by which the mouse pointer has moved // since we started the drag operation. int diffx = x_root - startRootX; int diffy = y_root - startRootY; // Get the root co-ordinates of the window pre-drag. int left, top, right, bottom; left = startRootX - startX; top = startRootY - startY; right = left + startWidth; bottom = top + startHeight; // Process the pointer motion according to the click mode. switch(clickMode) { case HitTest.TopLeft: { left += diffx; top += diffy; if((right - left) < MinWidth) { left = right - MinWidth; } else if((right - left) > MaxWidth) { left = right - MaxWidth; } if((bottom - top) < MinHeight) { top = bottom - MinHeight; } else if((bottom - top) > MaxHeight) { top = bottom - MaxHeight; } } break; case HitTest.TopRight: { right += diffx; top += diffy; if((right - left) < MinWidth) { right = left + MinWidth; } else if((right - left) > MaxWidth) { right = left + MaxWidth; } if((bottom - top) < MinHeight) { top = bottom - MinHeight; } else if((bottom - top) > MaxHeight) { top = bottom - MaxHeight; } } break; case HitTest.BottomLeft: { left += diffx; bottom += diffy; if((right - left) < MinWidth) { left = right - MinWidth; } else if((right - left) > MaxWidth) { left = right - MaxWidth; } if((bottom - top) < MinHeight) { bottom = top + MinHeight; } else if((bottom - top) > MaxHeight) { bottom = top + MaxHeight; } } break; case HitTest.BottomRight: { right += diffx; bottom += diffy; if((right - left) < MinWidth) { right = left + MinWidth; } else if((right - left) > MaxWidth) { right = left + MaxWidth; } if((bottom - top) < MinHeight) { bottom = top + MinHeight; } else if((bottom - top) > MaxHeight) { bottom = top + MaxHeight; } } break; case HitTest.Top: { top += diffy; if((bottom - top) < MinHeight) { top = bottom - MinHeight; } else if((bottom - top) > MaxHeight) { top = bottom - MaxHeight; } } break; case HitTest.Bottom: { bottom += diffy; if((bottom - top) < MinHeight) { bottom = top + MinHeight; } else if((bottom - top) > MaxHeight) { bottom = top + MaxHeight; } } break; case HitTest.Left: { left += diffx; if((right - left) < MinWidth) { left = right - MinWidth; } else if((right - left) > MaxWidth) { left = right - MaxWidth; } } break; case HitTest.Right: { right += diffx; if((right - left) < MinWidth) { right = left + MinWidth; } else if((right - left) > MaxWidth) { right = left + MaxWidth; } } break; case HitTest.Close: case HitTest.Maximize: case HitTest.Minimize: case HitTest.Restore: case HitTest.Help: { // Change the button state if we have left or // re-entered the caption button we started with. ChangeButtonState(clickMode, clickMode == hitTest); } return; case HitTest.Caption: { // If the mouse has moved sufficiently away from // the starting position, then switch into move mode. if(diffx < -4 || diffx > 4 || diffy < -4 || diffy > 4) { // We cannot enter move mode if maximized. if(!(child.IsMaximized)) { clickMode = HitTest.Move; goto case HitTest.Move; } } } return; case HitTest.Move: { // Move the window to a new location. left += diffx; right += diffx; top += diffy; bottom += diffy; } break; } // Convert root co-ordinates back into normal co-ordinates. left -= clientLeft; right -= clientLeft; top -= clientTop; bottom -= clientTop; // Move the window to its new location. MoveResize(left, top, right - left, bottom - top); }
public SetCursorEventArgs(Point location, HitTest hitTest) { Location = location; HitTest = hitTest; }
public SetCursorEventArgs(Point location, HitTest hitTest) { Location = location; HitTest = hitTest; }
public override void Update(GameTime gameTime) { if (pulando) { subindo = false; } //Calcular a posicao do inimigo float posicaoX = posicao.X; if (direcao == Direcao.Esquerda) { posicaoX = posicao.X + medidas.X / 3; } else { posicaoX = Bordas.X - medidas.X / 3; } tileX = (int)Math.Floor(posicaoX / Tile.Dimensoes.X); tileY = (int)Math.Floor(Bordas.Y / Tile.Dimensoes.Y); //Se estiver numa altura diferente e não estiver numa escada ou pulando, passa a ter ai simples if (Math.Abs(principal.telaJogo.Personagem.Posicao.Y - posicao.Y) > HitTest.Height + 10 && !subindo && !pulando) { inteligencia = IA.Simples; } //Se o personagem tiver na tela da água e empurrar 3 ou mais itens na água, os seguranças ficam sempre alertas //Caso contrário... if (principal.telaJogo.Personagem.ItensUsados < 3 || !principal.telaJogo.mapa.Caminho.EndsWith("Agua")) { //Se estiver numa altura a 800 px de distância, passa a ter IA simples e deixa de ser perseguidor if (Math.Abs(principal.telaJogo.Personagem.Posicao.Y - posicao.Y) > 800 && !subindo && !pulando) { inteligencia = IA.Simples; perseguidor = false; } } if (inteligencia == IA.Simples) { AndarLados(tileX, tileY, gameTime); } else if (inteligencia == IA.Perseguir) { if (principal.telaJogo.Personagem.Posicao.X < posicao.X) { direcao = Direcao.Esquerda; flip = SpriteEffects.FlipHorizontally; } else { direcao = Direcao.Direita; flip = SpriteEffects.None; } PerseguirLados(tileX, tileY, gameTime); PerseguirAcima(tileX, tileY); } //Se encostar no persoangem, ele morre if (principal.telaJogo.Personagem.Animacao.AnimacaoAtual != "null" && !principal.telaJogo.Personagem.Morto && !principal.telaJogo.Derrota && !principal.telaJogo.Pausado) { if (HitTest.Intersects(principal.telaJogo.Personagem.HitTest) && !principal.telaJogo.Personagem.Passando) { principal.telaJogo.Personagem.morrer(); } } //Para de se mover se o jogador perdeu ou se está esperando if (principal.telaJogo.Derrota || principal.telaJogo.Personagem.Morto || tempoEspera > 0) { velocidade.X = 0; velocidade.Y = 0; if (!subindo && !pulando) { animacao.AnimacaoAtual = "parado"; animacao.iniciarAnimacao(); } else if (subindo) { animacao.pararAnimacao(); } if (principal.telaJogo.Personagem.Morto) { inteligencia = IA.Simples; perseguidor = false; } } else { //caso contrário, se não estiver pulando ou subindo, muda para andar if (!pulando && !subindo) { animacao.AnimacaoAtual = "andando"; animacao.iniciarAnimacao(); } } //Ajuste se permanecer parado por um tempo maior que a espera máxima if (posicaoAnterior == posicao) { if (subindo) { animacao.pararAnimacao(); } else { animacao.AnimacaoAtual = "parado"; animacao.iniciarAnimacao(); } tempoParado += (float)gameTime.ElapsedGameTime.TotalSeconds; if (tempoParado > tempoEsperaMax + 1 || (subindo && tempoParado > tempoEsperaMax / 2)) { pular(); tempoParado = 0; } } else { tempoParado = 0; } posicaoAnterior = posicao; base.Update(gameTime); }
static void Main(string[] args) { try { TestUtil.CheckSandbox(); // simple entry point for simple debugging of tests within VS HitTest hitTest = new HitTest(); XmlTest miscTest = new XmlTest(); QualificationTest qualTest = new QualificationTest(); MTurkClientTest clientTest = new MTurkClientTest(); SimpleClientTest simpleClientTest = new SimpleClientTest(); // clientTest.setup(); // clientTest.SendSingleRequestWithoutEnvelope(); // simpleClientTest.CreateHIT(); //simpleClientTest.CreateHITWithQuestionForm(); //simpleClientTest.CreateHITWithExternalQuestionForm(); //simpleClientTest.SerializeAndDeserializeHitToXML(); //simpleClientTest.SerializeAndDeserializeHitToProperties(); //simpleClientTest.CreateHitFromPropertyFile(); //simpleClientTest.CreateHitWithQual(); //simpleClientTest.CreateHitWithAutoGrantedQual(); //simpleClientTest.EnumerateAllHits(); //simpleClientTest.EnumerateAllQualificationTypes(); //hitTest.CreateHit(); //hitTest.CreateHitWithoutXmlQuestion(); //hitTest.CreateHitWithoutXmlQuestionWithImplicitWrappingDisabled(); //hitTest.CreateHitWithInvalidXmlFileAndImplicitValidation(); //hitTest.CreateHitFromQuestionFile(); //hitTest.CreateHitWithQualification(); //hitTest.DisposeHit(); //hitTest.GetReviewableHITs(); //hitTest.SetHITAsReviewing(); //hitTest.GetAssignmentsForHIT(); //hitTest.NotifyWorkers(); //hitTest.SearchHit(); //hitTest.CreateHitType(); //hitTest.CreateHitsForType(); //hitTest.SetHITTypeNotification(); // hitTest.CreateHITWithAssignmentReviewPolicy(); // hitTest.CreateHITWithHITReviewPolicy(); // hitTest.CreateHITWithIdempotency(); // hitTest.GetReviewResults(); hitTest.ExtendHITWithIdempotency(); //qualTest.CreateSimpleQualificationType(); //qualTest.CreateQualificationTypeWithTest(); //qualTest.GetQualificationType(); //qualTest.UpdateQualificationType(); //qualTest.SearchQualificationTypes(); //qualTest.GetQualificationsForQualificationType(); //clientTest.SendRequestToInvalidURL(); //clientTest.SendRequestToInvalidServiceEndpoint(); //clientTest.UseDifferentThrottler(); //clientTest.SendRequestsMultithreaded(); //miscTest.SerializeAndDeserializeObjectToXML(); //miscTest.SerializeAndDeserializeObjectToProperties(); //miscTest.ValidateQuestionFile(); //miscTest.ValidateInvalidQuestionFile(); //miscTest.LoadAnswersFile(); //miscTest.EscapeStrings(); } catch (ServiceException svcEx) { Debug.WriteLine(string.Format("Error '{0}': {1}", svcEx.ErrorCode, svcEx.Message)); Debug.WriteLine(svcEx.Message); } }