private void ScrollVertically() { switch (this.verticalScroll) { case VerticalScroll.None: return; case VerticalScroll.Up: this.textView.ViewScroller.ScrollViewportVerticallyByLine(ScrollDirection.Up); this.processViewportScrolled(); if (this.AtTop()) { this.verticalScroll = VerticalScroll.None; return; } break; case VerticalScroll.Down: this.textView.ViewScroller.ScrollViewportVerticallyByLine(ScrollDirection.Down); this.processViewportScrolled(); if (this.AtBottom()) { this.verticalScroll = VerticalScroll.None; return; } break; } this.verticalTimer.Change(VerticalStepTime, Timeout.InfiniteTimeSpan); }
// // Vertical Scrollbar scroll event // private void vScrollBar_Scroll(object sender, ScrollEventArgs e) { offsetPoint.Y = e.NewValue; Invalidate(); VerticalScroll?.Invoke(this, e); }
void Start () { parentScript = transform.parent.parent.GetComponent<VerticalScroll>(); myTransform = transform; centerOfScreen = Camera.main.ViewportToWorldPoint(Vector3.one/2).y; startPosX = myTransform.position.x; Debug.Log("CenterOfScreen:" + centerOfScreen); }
public void StopScroll() { if (this.verticalScroll == VerticalScroll.None) { return; } this.verticalScroll = VerticalScroll.None; this.verticalTimer.Change(Timeout.InfiniteTimeSpan, Timeout.InfiniteTimeSpan); }
public void StartScrollUp() { if (this.verticalScroll == VerticalScroll.Up || this.AtTop()) { return; } this.verticalScroll = VerticalScroll.Up; this.verticalTimer.Change(VerticalStepTime, Timeout.InfiniteTimeSpan); }
public void StartScrollDown() { if (this.verticalScroll == VerticalScroll.Down || this.AtBottom()) { return; } this.verticalScroll = VerticalScroll.Down; this.verticalTimer.Change(VerticalStepTime, Timeout.InfiniteTimeSpan); }
// // Mouse Move event handler. Used to drag the viewport // protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (draggingViewport) { offsetPoint = new Point(-MousePosition.X + mouseOffset.X, -MousePosition.Y + mouseOffset.Y); // Fire scroll events HorizontalScroll?.Invoke(this, new ScrollEventArgs(ScrollEventType.ThumbPosition, offsetPoint.X)); VerticalScroll?.Invoke(this, new ScrollEventArgs(ScrollEventType.ThumbPosition, offsetPoint.Y)); ClipTransform(); Invalidate(); } }
protected override void WndProc(ref Message m) { try { if (m.Msg == WM_ERASEBKGND) { m.Result = IntPtr.Zero; return; } if (m.Msg == 0x0115) { if (VerticalScroll != null) { VerticalScroll.Invoke(this, EventArgs.Empty); } } base.WndProc(ref m); } catch (AccessViolationException) { } }
private void ApplyPreferedSize(Size preferedSize, Size panelSize) { _needBothScroll = false; var needHorizontalScroll = HorizontalScroll.HasScroll; var needVerticalScroll = VerticalScroll.UpdateLength(preferedSize.Height, null, panelSize.Height - (needHorizontalScroll ? HorizontalScroll.BarThickness : 0), panelSize.Width); HorizontalScroll.UpdateLength(preferedSize.Width, null, panelSize.Width - (needVerticalScroll ? VerticalScroll.BarThickness : 0), panelSize.Height); if (needHorizontalScroll != HorizontalScroll.HasScroll) { needHorizontalScroll = HorizontalScroll.HasScroll; needVerticalScroll = VerticalScroll.UpdateLength(preferedSize.Height, null, panelSize.Height - (needHorizontalScroll ? HorizontalScroll.BarThickness : 0), panelSize.Width); } _needBothScroll = needVerticalScroll && needHorizontalScroll; if (_needBothScroll) { _leftoverBar = new Rectangle(panelSize.Width - VerticalScroll.BarThickness, panelSize.Height - HorizontalScroll.BarThickness, VerticalScroll.BarThickness, HorizontalScroll.BarThickness); } }
protected virtual void PaintScrollBars(PaintEventArgs e, Region originalRegion) { if (VerticalScroll.HasScroll && VerticalScroll.BarRect.IntersectsWith(e.ClipRectangle)) { e.Graphics.SetClip(VerticalScroll.BarRect, CombineMode.Intersect); VerticalScroll.Paint(e.Graphics); e.Graphics.Clip = originalRegion; } if (_needBothScroll && _leftoverBar.IntersectsWith(e.ClipRectangle)) { e.Graphics.SetClip(_leftoverBar, CombineMode.Intersect); e.Graphics.PaintClipRegion(YamuiThemeManager.Current.ScrollNormalBack); e.Graphics.Clip = originalRegion; } if (HorizontalScroll.HasScroll && HorizontalScroll.BarRect.IntersectsWith(e.ClipRectangle)) { e.Graphics.SetClip(HorizontalScroll.BarRect, CombineMode.Intersect); HorizontalScroll.Paint(e.Graphics); e.Graphics.Clip = originalRegion; } }
protected void ComputeScrollbars(Size naturalSize, Size availableSize) { _needBothScroll = false; var needHorizontalScroll = HorizontalScroll.HasScroll; var needVerticalScroll = VerticalScroll.UpdateLength(naturalSize.Height, null, availableSize.Height - (needHorizontalScroll ? HorizontalScroll.BarThickness : 0), availableSize.Width); HorizontalScroll.UpdateLength(naturalSize.Width, null, availableSize.Width - (needVerticalScroll ? VerticalScroll.BarThickness : 0), availableSize.Height); if (needHorizontalScroll != HorizontalScroll.HasScroll) { needHorizontalScroll = HorizontalScroll.HasScroll; needVerticalScroll = VerticalScroll.UpdateLength(naturalSize.Height, null, availableSize.Height - (needHorizontalScroll ? HorizontalScroll.BarThickness : 0), availableSize.Width); } // compute the "left over" rectangle on the bottom right between the 2 scrolls _needBothScroll = needVerticalScroll && needHorizontalScroll; if (_needBothScroll) { _leftoverBar = new Rectangle(ContentSurfaceWithScrolls.X + ContentSurfaceWithScrolls.Width - VerticalScroll.BarThickness, ContentSurfaceWithScrolls.Y + ContentSurfaceWithScrolls.Height - HorizontalScroll.BarThickness, VerticalScroll.BarThickness, HorizontalScroll.BarThickness); } ContentSurface = new Rectangle(ContentSurfaceWithScrolls.X, ContentSurfaceWithScrolls.Y, ContentSurfaceWithScrolls.Width - (needVerticalScroll ? VerticalScroll.BarThickness : 0), ContentSurfaceWithScrolls.Height - (needHorizontalScroll ? HorizontalScroll.BarThickness : 0)); }
void SetRadioButtons() { Noktalar = new List <EngelleCustomRadioItem>(); WebService webService = new WebService(); var Donus = webService.OkuGetir("answers"); if (Donus != null) { OptionsDTOs = Newtonsoft.Json.JsonConvert.DeserializeObject <List <OptionsDTO> >(Donus.ToString()); OptionsDTOs = OptionsDTOs.FindAll(item => item.questionId == GelenSoru.id); SoruLabel.Text = GelenSoru.name; if (OptionsDTOs.Count > 0) { for (int i = 0; i < OptionsDTOs.Count; i++) { var NoktaItem = EngelleCustomRadioItem.Create(OptionsDTOs[i].option, RadioBUtonlarinTasarimlariniDuzenle, false); if (i == 0) { NoktaItem.Frame = new CoreGraphics.CGRect(0, 0, UIKit.UIScreen.MainScreen.Bounds.Width, 47f); } else { NoktaItem.Frame = new CoreGraphics.CGRect(0, Noktalar[i - 1].Frame.Bottom, UIKit.UIScreen.MainScreen.Bounds.Width, 47f); } var Durum = userAnswer.FindAll(item => item.id.ToString() == OptionsDTOs[i].id); if (Durum.Count > 0) { NoktaItem.isSelect = true; } NoktaItem.Tag = i; VerticalScroll.AddSubview(NoktaItem); Noktalar.Add(NoktaItem); } VerticalScroll.ContentSize = new CoreGraphics.CGSize(UIKit.UIScreen.MainScreen.Bounds.Width, Noktalar[Noktalar.Count - 1].Frame.Bottom); } } }
void Start() { // Get current level int level = UserData.Instance.Level; int mapCount = maps.Length; float mapWidth = maps[0].GetWidth(); int buttonCount = -1; float cloudY = -1; for (int zone = 0; zone < 2; zone++) { ZoneType zoneType = zone.ToZoneType(); if (level <= zoneType.MapCount()) { buttonCount = zoneType.MapCount() + 1; cloudY = clouds.GetChild(zone).position.y; break; } } Vector3 position = Vector3.zero; for (int i = 0; i < mapCount; i++) { GameObject bg = new GameObject(string.Format("Background {0}", i + 1)); bg.transform.SetParent(background); bg.transform.localPosition = position; SpriteRenderer renderer = bg.AddComponent <SpriteRenderer>(); renderer.sprite = maps[i]; renderer.sortingOrder = -3; float height = maps[i].GetHeight(); position.y += height; if (cloudY > 0 && position.y >= cloudY) { break; } } if (cloudY < 0) { cloudY = position.y; } // Set cloud position cloud.transform.SetPositionY(cloudY); // Set number of maps _mapCount = points.childCount; if (buttonCount < 0) { buttonCount = _mapCount; } // Create buttons _buttons = new MapButton[buttonCount]; bool isNewLevel = UserData.Instance.NewLevel; for (int i = 0; i < buttonCount; i++) { position = points.GetChild(i).position; int mapID = i + 1; GameObject map = buttonPrefab.Create(background, position); map.name = string.Format("Map {0}", mapID); bool unlocked = mapID < level || (mapID == level && !isNewLevel); MapButton mapButton = map.GetComponent <MapButton>(); mapButton.Construct(spriteLock, zones[ZoneTypeHelper.GetZoneType(mapID).ToInt()].mapIcon, mapID, unlocked); _buttons[i] = mapButton; } // Destroy points Destroy(points.gameObject); // Destroy clouds Destroy(clouds.gameObject); // Fixed width float scale = Camera.main.GetWidth() / mapWidth; background.SetScale(scale); float mapHeight = cloudY * scale; // _squareRadius = ButtonRadius * ButtonRadius * scale * scale; // Create vertical scroll _verticalScroll = new VerticalScroll(); _verticalScroll.Construct(-Camera.main.orthographicSize, mapHeight, Camera.main.GetHeight()); // Set map position // transform.SetPositionY(_verticalScroll.Position); // Get current map int mapIndex = Mathf.Clamp(UserData.Instance.Map - 1, 0, _buttons.Length - 1); if (animal != null) { // Set animal position animal.transform.position = _buttons[mapIndex].transform.position; // Set skin animal.idleDuration = 0; ZoneType zoneType = ZoneTypeHelper.GetZoneType(mapIndex + 1); if (!zoneType.IsDefault()) { ZoneSetting zone = zones[zoneType.ToInt()]; animal.SetClothes(zone.clothesLeft, zone.clothesUp, zone.clothesDown); animal.SetCap(zone.capLeft, zone.capUp, zone.capDown); } } MoveObjectToCenter(_buttons[mapIndex].gameObject); }
protected override void WndProc(ref Message m) { if (DesignMode) { base.WndProc(ref m); return; } switch ((Window.Msg)m.Msg) { case Window.Msg.WM_NCCALCSIZE: // Check WPARAM if (m.WParam != IntPtr.Zero) { // When TRUE, LPARAM Points to a NCCALCSIZE_PARAMS structure var nccsp = (WinApi.NCCALCSIZE_PARAMS)Marshal.PtrToStructure(m.LParam, typeof(WinApi.NCCALCSIZE_PARAMS)); ApplyPreferedSize(_preferedSize, nccsp.rectProposed.Size); AdjustClientArea(ref nccsp.rectProposed); Marshal.StructureToPtr(nccsp, m.LParam, true); } else { // When FALSE, LPARAM Points to a RECT structure var clnRect = (WinApi.RECT)Marshal.PtrToStructure(m.LParam, typeof(WinApi.RECT)); ApplyPreferedSize(_preferedSize, clnRect.Size); AdjustClientArea(ref clnRect); Marshal.StructureToPtr(clnRect, m.LParam, true); } //Return Zero m.Result = IntPtr.Zero; break; case Window.Msg.WM_NCPAINT: PaintScrollBars(null); // we handled everything m.Result = IntPtr.Zero; break; case Window.Msg.WM_NCHITTEST: // we need to correctly handle this if we want the non client area events (WM_NC*) to fire properly! var point = PointToClient(new Point(m.LParam.ToInt32())); if (!ClientRectangle.Contains(point)) { m.Result = (IntPtr)WinApi.HitTest.HTBORDER; } else { base.WndProc(ref m); } break; case Window.Msg.WM_MOUSEWHEEL: if (HasScroll) { // delta negative when scrolling up var delta = (short)(m.WParam.ToInt64() >> 16); var mouseEvent1 = new MouseEventArgs(MouseButtons.None, 0, 0, 0, delta); if (HorizontalScroll.IsHovered) { HorizontalScroll.HandleScroll(null, mouseEvent1); } else { VerticalScroll.HandleScroll(null, mouseEvent1); } } else { // propagate the event base.WndProc(ref m); } break; case Window.Msg.WM_MOUSEMOVE: if (VerticalScroll.IsThumbPressed) { VerticalScroll.HandleMouseMove(null, null); } if (HorizontalScroll.IsThumbPressed) { HorizontalScroll.HandleMouseMove(null, null); } base.WndProc(ref m); break; case Window.Msg.WM_NCMOUSEMOVE: // track mouse leaving (otherwise the WM_NCMOUSELEAVE message would not fire) WinApi.TRACKMOUSEEVENT tme = new WinApi.TRACKMOUSEEVENT(); tme.cbSize = (uint)Marshal.SizeOf(tme); tme.dwFlags = (uint)(WinApi.TMEFlags.TME_LEAVE | WinApi.TMEFlags.TME_NONCLIENT); tme.hwndTrack = Handle; WinApi.TrackMouseEvent(tme); // PointToClient(new Point(m.LParam.ToInt32())); VerticalScroll.HandleMouseMove(null, null); HorizontalScroll.HandleMouseMove(null, null); base.WndProc(ref m); break; case Window.Msg.WM_NCLBUTTONDOWN: VerticalScroll.HandleMouseDown(null, null); HorizontalScroll.HandleMouseDown(null, null); Focus(); // here we forward to base button down because it has a internal focus mecanism that we want to exploit // if we don't do that, the mouse MOVE events are not fired outside the bounds of this control! m.Msg = (int)Window.Msg.WM_LBUTTONDOWN; base.WndProc(ref m); break; case Window.Msg.WM_NCLBUTTONUP: case Window.Msg.WM_LBUTTONUP: VerticalScroll.HandleMouseUp(null, null); HorizontalScroll.HandleMouseUp(null, null); // here we forward this message to base WM_LBUTTONUP to release the internal focus on this control m.Msg = (int)Window.Msg.WM_LBUTTONUP; base.WndProc(ref m); break; case Window.Msg.WM_NCMOUSELEAVE: VerticalScroll.HandleMouseLeave(null, null); HorizontalScroll.HandleMouseLeave(null, null); base.WndProc(ref m); break; default: base.WndProc(ref m); break; } }
/// <summary> /// Programatically triggers the OnKeyDown event /// </summary> public bool PerformKeyDown(KeyEventArgs e) { e.Handled = HorizontalScroll.HandleKeyDown(null, e) || VerticalScroll.HandleKeyDown(null, e); return(e.Handled); }
private void PaintVerticalScroll(PaintEventArgs e) { VerticalScroll.Paint(e.Graphics); }
protected override void WndProc(ref Message m) { if (DesignMode) { base.WndProc(ref m); return; } switch ((Window.Msg)m.Msg) { case Window.Msg.WM_NCCALCSIZE: // Check WPARAM if (m.WParam != IntPtr.Zero) { // When TRUE, LPARAM Points to a NCCALCSIZE_PARAMS structure var nccsp = (WinApi.NCCALCSIZE_PARAMS)Marshal.PtrToStructure(m.LParam, typeof(WinApi.NCCALCSIZE_PARAMS)); if (!nccsp.rectProposed.Size.IsEmpty) { // we are not in this case when the form is minimized //OnSizeChanged(nccsp.rectProposed.Size); } AdjustClientArea(ref nccsp.rectProposed); Marshal.StructureToPtr(nccsp, m.LParam, true); } else { // When FALSE, LPARAM Points to a RECT structure var clnRect = (WinApi.RECT)Marshal.PtrToStructure(m.LParam, typeof(WinApi.RECT)); if (!clnRect.Size.IsEmpty) { // we are not in this case when the form is minimized //OnSizeChanged(clnRect.Size); } AdjustClientArea(ref clnRect); Marshal.StructureToPtr(clnRect, m.LParam, true); } //Return Zero m.Result = IntPtr.Zero; break; case Window.Msg.WM_MOUSEWHEEL: if (HasScroll) { // delta negative when scrolling up var delta = (short)(m.WParam.ToInt64() >> 16); var mouseEvent1 = new MouseEventArgs(MouseButtons.None, 0, 0, 0, delta); if (HorizontalScroll.IsHovered) { HorizontalScroll.HandleScroll(null, mouseEvent1); } else { VerticalScroll.HandleScroll(null, mouseEvent1); } } else { // propagate the event base.WndProc(ref m); } break; /* * case Window.Msg.WM_KEYDOWN: * // needto override OnPreviewKeyDown or IsInputKey to receive this * var key = (Keys) (m.WParam.ToInt64()); * long context = m.LParam.ToInt64(); * * // on key down * if (!context.IsBitSet(31)) { * var e = new KeyEventArgs(key); * e.Handled = PerformKeyDown(e); * if (!e.Handled) * base.WndProc(ref m); * } * * break; */ case Window.Msg.WM_NCPAINT: m.Result = IntPtr.Zero; break; case Window.Msg.WM_ERASEBKGND: m.Result = IntPtr.Zero; return; default: base.WndProc(ref m); break; } }
protected virtual void MouseLDownClientArea(MouseEventArgs mouseEventArgs) { Focus(); VerticalScroll.HandleMouseDown(null, null); HorizontalScroll.HandleMouseDown(null, null); }
protected virtual void MouseLUpClientArea(MouseEventArgs mouseEventArgs) { VerticalScroll.HandleMouseUp(null, null); HorizontalScroll.HandleMouseUp(null, null); }
protected virtual void MouseLeaveClientArea(EventArgs eventArgs) { VerticalScroll.HandleMouseLeave(null, null); HorizontalScroll.HandleMouseLeave(null, null); }