/// <summary> /// Scroll to the start of the ScrollBar. /// <param name="mode"></param> public static void ScrollToStart(this DataGrid grid, ScrollMode mode) { switch (mode) { case ScrollMode.Vertical: grid.ScrollToPercent(ScrollMode.Vertical, 0); break; case ScrollMode.Horizontal: grid.ScrollToPercent(ScrollMode.Horizontal, 0); break; } }
// スワイプ終了 public void OnEndDrag(PointerEventData data) { if (m_currentScrollMode == ScrollMode.Horizontal) { OnGoBackToDefaultPosition(); } m_currentScrollMode = ScrollMode.Non; //ヘッダがリターンを示せば、元のコンテンツである地図に戻る if (m_Header.isReturn) { uiManager.SwitchContentToWorldMap(); } }
/// <summary> /// Save the current scroll position. /// </summary> /// <param name="mode"></param> public void SaveScrollPosition(ScrollMode mode) { switch (mode) { case ScrollMode.Vertical: this.savedVerticalScrollPosition = verticalScrollBar.Value; break; case ScrollMode.Horizontal: this.savedHorizontalScrollPosition = horizontalScrollBar.Value; break; default: break; } }
// スワイプ中 public void OnDrag(PointerEventData data) { if (!m_CurrentCard) { return; } switch (m_currentScrollMode) { // まだScrollMode.Nonの場合(つまり指を置いたばかりの場合)、最初のフレームの移動値で縦のスクロールか横のスクロールかを決める case ScrollMode.Non: // 上下スクロール if ((Mathf.Abs(data.delta.x) < Mathf.Abs(data.delta.y))) { // 上下スクロールの場合は、ScrollRectによるスクロール m_currentScrollMode = ScrollMode.Vertical; m_ScrollRect.vertical = true; // 左右スクロール } else if ((Mathf.Abs(data.delta.x) > Mathf.Abs(data.delta.y))) { // 左右スクロールの場合は自前実装したスクロールを使うため、ScrollRectを使用不可に(でないと左右同時スクロールが可能になってしまってユーザビリティが下がる) m_currentScrollMode = ScrollMode.Horizontal; m_ScrollRect.vertical = false; m_CurrentCard.StartDragHorizontal(m_CurrentCard.currentState); } break; // 左右スクロールの処理 case ScrollMode.Horizontal: Vector2 localPositionAfter; Vector2 localPositionBefor; RectTransformUtility.ScreenPointToLocalPointInRectangle(GetComponent <RectTransform>(), data.position, m_UICamera, out localPositionAfter); RectTransformUtility.ScreenPointToLocalPointInRectangle(GetComponent <RectTransform>(), data.position - data.delta, m_UICamera, out localPositionBefor); if (m_CurrentCard != null) { m_CurrentCard.DragHorizontal(new Vector2((localPositionAfter - localPositionBefor).x, 0), isMemberMax); } break; } }
/// <summary> /// /// </summary> /// <param name="address0">0x31</param> /// <param name="messageIndex">0-1</param> /// <param name="speed"></param> /// <param name="unknown">0x31</param> /// <param name="scrollMode"></param> /// <param name="bitmap">A 12 height monochrome image (currently only up to 12px wide are supported)</param> /// <returns></returns> public static List<byte> GenerateImagePacket(byte address0, int messageIndex, Speed speed, byte unknown, ScrollMode scrollMode, Bitmap bitmap) { List<byte> result = new List<byte>(); List<byte> buffer = new List<byte>(); //Scroll mode etc buffer.Add((byte)speed); buffer.Add(unknown); buffer.Add((byte)scrollMode); //Say how wide the image is in blocks of 12 pixels int bitmap12PxCount = 1 + (bitmap.Width - 1) / 12; buffer.Add((byte)bitmap12PxCount); //Length byte (how many image banks below will be mentioned for (int i = 0; i < bitmap12PxCount; i++) { buffer.Add(0x80); //Image buffer.Add((byte)i); //Index } //Pad the buffer out to be 4 packets long (Desktop programmer does this, but it doesn't appear to be required) //while (buffer.Count < 4 * 64) // buffer.Add(0); result.AddRange(GenerateMultiplePackets(address0, messageIndex, buffer)); //Next packets (image) are special, messageIndex 8! buffer.Clear(); buffer.AddRange(PackBitmapToBytes(bitmap)); result.AddRange(GenerateMultiplePackets(address0, 8, buffer)); return result; }
public static void SetScrollMode(DependencyObject o, ScrollMode value) { o.SetValue(ScrollModeProperty, value); }
/// <summary> /// Get the maximum position of a scrollbar. /// </summary> /// <param name="mode"></param> /// <returns></returns> public static double GetScrollMaximum(this DataGrid grid, ScrollMode mode) { var scrollBar = grid.GetScrollbar(mode); return(scrollBar.Maximum); }
public void ScrollTo(ScrollMode mode) { if (mode <= ScrollMode.EndScroll) { SendMessage(this.Handle, WM_HSCROLL, (IntPtr)mode, IntPtr.Zero); } else { mode -= WM_USER; SendMessage(this.Handle, WM_VSCROLL, (IntPtr)mode, IntPtr.Zero); } }
/// <summary> /// Selects a single node and makes it the active node. /// </summary> /// <param name="node">The node. Pass null to deselect any nodes</param> /// <param name="scroll">Set to a specific mode to scroll the node into view</param> public void SelectNode(KTreeNode node, ScrollMode scroll = ScrollMode.None) { DoSelectNode(node, SelectAction.Set, scroll); }
/// <summary> /// Get the current position of the scrollbar. /// </summary> /// <param name="mode"></param> /// <returns></returns> public static double GetScrollPosition(this DataGrid grid, ScrollMode mode) { var scrollBar = grid.GetScrollbar(mode); return(scrollBar.Value); }
public static void SetVerticalScrollMode(DependencyObject obj, ScrollMode value) { obj.SetValue(VerticalScrollModeProperty, value); }
PanVelocity ComputeEdgeScrollVelocity( Point dragPoint) { bool isHorizontalScrollAllowed = false; bool isVerticalScrollAllowed = false; var velocity = new PanVelocity(); // See in which directions we've enabled panning. if (m_tpScrollViewer != null) { ScrollMode verticalScrollMode = ScrollMode.Disabled; ScrollMode horizontalScrollMode = ScrollMode.Disabled; verticalScrollMode = (m_tpScrollViewer.VerticalScrollMode); horizontalScrollMode = (m_tpScrollViewer.HorizontalScrollMode); isVerticalScrollAllowed = verticalScrollMode != ScrollMode.Disabled; isHorizontalScrollAllowed = horizontalScrollMode != ScrollMode.Disabled; if (isHorizontalScrollAllowed) { double offset = 0.0; double bound = 0.0; offset = (m_tpScrollViewer.HorizontalOffset); // Try scrolling left. velocity.HorizontalVelocity = ComputeEdgeScrollVelocityFromEdgeDistance(dragPoint.X); if (velocity.IsStationary()) { // Try scrolling right. double width = ActualWidth; velocity.HorizontalVelocity = -ComputeEdgeScrollVelocityFromEdgeDistance(width - dragPoint.X); bound = (m_tpScrollViewer.ScrollableWidth); } else { // We're scrolling to the left. // The minimum horizontal offset obtained here accounts for the presence of the // sentinel offset values in the left padding and/or header case. For instance, // with no header or padding this will return exactly 2.0. bound = (m_tpScrollViewer.MinHorizontalOffset); } // Disallow edge scrolling if we're right up against the edge. if (DoubleUtil.AreWithinTolerance(bound, offset, /*ScrollViewerScrollRoundingTolerance*/ 0.05)) { velocity.Clear(); } } if (isVerticalScrollAllowed && velocity.IsStationary() /* only allow vertical edge scrolling if there is no horizontal edge scrolling */) { double offset = 0.0; double bound = 0.0; offset = m_tpScrollViewer.VerticalOffset; // Try scrolling up. velocity.VerticalVelocity = ComputeEdgeScrollVelocityFromEdgeDistance(dragPoint.Y); if (velocity.IsStationary()) { // Try scrolling down. double height = ActualHeight; velocity.VerticalVelocity = -ComputeEdgeScrollVelocityFromEdgeDistance(height - dragPoint.Y); bound = (m_tpScrollViewer.ScrollableHeight); } else { // We're scrolling up. // The minimum vertical offset obtained here accounts for the presence of the // sentinel offset values in the top padding and/or header case. For instance, // with no header or padding this will return exactly 2.0. bound = m_tpScrollViewer.MinVerticalOffset; } // Disallow edge scrolling if we're right up against the edge. if (DoubleUtil.AreWithinTolerance(bound, offset, /*ScrollViewerScrollRoundingTolerance*/ 0.05)) { velocity.Clear(); } } } return(velocity); }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(1)) { scrollMode = scrollMode == ScrollMode.BULBS ? ScrollMode.LENSES : ScrollMode.BULBS; GetComponent <AudioSource>().PlayOneShot(switchSound); hasSwitched = true; } if (Input.GetKeyDown("f")) { hasTurnedOff = true; on = !on; setBeam(on); GetComponent <AudioSource>().PlayOneShot(switchSound); } foreach (char c in Input.inputString) { if (c == 'n') { if (cheatcode == "kelvi") { infiniteBattery = !infiniteBattery; } cheatcode = ""; } else { cheatcode += c; } } if (on) { battery = Math.Max(0, battery - Time.deltaTime * bulbs.item.batteryDrainRate); } else { battery = Math.Min(maxBattery, battery + Time.deltaTime * batteryChargeRate); if (battery == maxBattery) { GetComponent <AudioSource>().Stop(); } else if (!GetComponent <AudioSource>().isPlaying) { GetComponent <AudioSource>().Play(); } } if (infiniteBattery) { battery = maxBattery; } if (battery <= 0) { if (on) { GetComponent <AudioSource>().PlayOneShot(batteryDrained, 0.5f); } on = false; setBeam(false); } if (on && battery <= flickerThreshold) { flickerTimeDelta -= Time.deltaTime; if (flickerTimeDelta < 0) { flickerTimeDelta = UnityEngine.Random.Range(0.00f, 1.0f); //flickerTimeDelta *= flickerTimeDelta; //flickerTimeDelta = 1 - flickerTimeDelta; flickerTimeDelta = flickerTimeDelta * (maxFlickerTimeDelta - minFlickerTimeDelta) + minFlickerTimeDelta; setBeam(flickerOnNext); flickerOnNext = !flickerOnNext; } } else { flickerOnNext = !on; } float radiusFactor = battery / maxBattery; //radiusFactor = (float)Math.Pow(1 - radiusFactor, radiusFactorPower); //fov.radiusFactor = (1- minRadiusFactor) * (1 - radiusFactor) + minRadiusFactor; fov.radiusFactor = radiusFactor; float scroll = Input.GetAxis("Mouse ScrollWheel"); if (scroll != 0) { hasScrolled = true; bool scrollBackwards = scroll < 0; switch (scrollMode) { case ScrollMode.BULBS: if (bulbs.count > 1) { GetComponent <AudioSource>().PlayOneShot(switchSound); } bulbs.rotate(scrollBackwards); beamHandler.bulb = bulbs.item; fov.bulb = bulbs.item; break; case ScrollMode.LENSES: if (lenses.count > 1) { GetComponent <AudioSource>().PlayOneShot(switchSound); } lenses.rotate(scrollBackwards); fov.lens = lenses.item; if (lenses.item.name == "Long") { fov.showMesh = false; beamHandler.active = on; beamEnabled = true; } else { beamEnabled = false; fov.showMesh = on; beamHandler.active = false; } break; } } if (Input.GetKeyDown("e")) { hasScrolled = true; switch (scrollMode) { case ScrollMode.BULBS: if (bulbs.count > 1) { GetComponent <AudioSource>().PlayOneShot(switchSound); } bulbs.rotate(false); beamHandler.bulb = bulbs.item; fov.bulb = bulbs.item; break; case ScrollMode.LENSES: if (lenses.count > 1) { GetComponent <AudioSource>().PlayOneShot(switchSound); } lenses.rotate(false); fov.lens = lenses.item; if (lenses.item.name == "Long") { fov.showMesh = false; beamHandler.active = on; beamEnabled = true; } else { beamEnabled = false; fov.showMesh = on; beamHandler.active = false; } break; } } if (Input.GetKeyDown("q")) { hasScrolled = true; switch (scrollMode) { case ScrollMode.BULBS: if (bulbs.count > 1) { GetComponent <AudioSource>().PlayOneShot(switchSound); } bulbs.rotate(true); beamHandler.bulb = bulbs.item; fov.bulb = bulbs.item; break; case ScrollMode.LENSES: if (lenses.count > 1) { GetComponent <AudioSource>().PlayOneShot(switchSound); } lenses.rotate(true); fov.lens = lenses.item; if (lenses.item.name == "Long") { fov.showMesh = false; beamHandler.active = on; beamEnabled = true; } else { beamEnabled = false; fov.showMesh = on; beamHandler.active = false; } break; } } }
/// <summary> /// /// </summary> /// <param name="address0">0x31</param> /// <param name="messageIndex">0+</param> /// <param name="speed"></param> /// <param name="unknown">0x31</param> /// <param name="scrollMode"></param> /// <param name="text"></param> /// <returns></returns> public static List<byte> GenerateTextPacket(byte address0, int messageIndex, Speed speed, byte unknown, ScrollMode scrollMode, string text) { List<byte> buffer = new List<byte>(); buffer.Add((byte)speed); buffer.Add(unknown); buffer.Add((byte)scrollMode); buffer.Add((byte)text.Length); buffer.AddRange(text.Select(c => (byte)c)); return GenerateMultiplePackets(address0, messageIndex, buffer); }
private void ScrollToItem(AsmListBoxItem scrollItem, ScrollMode scrollMode) { if (scrollMode == ScrollMode.Default) { scrollMode = _defaultScrollMode; } switch (scrollMode) { case ScrollMode.ScrollIntoView: listBox.ScrollIntoView(scrollItem); break; case ScrollMode.ScrollToCenterOfView: listBox.ScrollToCenterOfView(scrollItem); break; case ScrollMode.Smooth: try { SuspendKeyboardShortcuts(); var scrollViewer = UIHelpers.GetScrollViewer(listBox) as ScrollViewer; AsmListBoxItem firstItem = listBox.FirstVisibleItem() as AsmListBoxItem; int firstItemIndex = firstItem.ItemIndex; int lastItemIndex = firstItemIndex + (int)scrollViewer.ViewportHeight; AsmListBoxItem lastItem = _items[lastItemIndex]; int scrollIndex = scrollItem.ItemIndex; bool alreadyVisible = scrollIndex >= firstItemIndex && scrollIndex <= lastItemIndex; if (!alreadyVisible) { int offsets = scrollIndex - firstItemIndex; int count = Math.Abs(offsets); int originalStep; if (count < 20) { originalStep = 1; } else if (count < 100) { originalStep = 2; } else if (count < 200) { originalStep = 3; } else if (count < 500) { originalStep = 5; } else if (count < 1000) { originalStep = 10; } else { originalStep = 20; } originalStep = offsets > 0 ? originalStep : -originalStep; int step = originalStep; for (int offset = 0; Math.Abs(offset) < Math.Abs(offsets); offset += step) { if (Math.Abs(step) > 1) { double share = 1 - (double)offset / (double)offsets; step = (int)(share * originalStep); // make sure we always have a valid step if (step == 0) { step = originalStep / Math.Abs(originalStep); } //Console.WriteLine( step ); } scrollViewer.ScrollToVerticalOffset(scrollViewer.VerticalOffset + step); this.DoEvents(); } listBox.ScrollIntoView(scrollItem); /* * // TODO: remove "flicker" * for (int offset = 0; offset < 10; offset++) { * scrollViewer.ScrollToVerticalOffset( scrollViewer.VerticalOffset - 1 ); * this.DoEvents(); * } */ } } finally { ResumeKeyboardShortcuts(); } break; } listBox.FocusListBoxItem(scrollItem); }
public static ScrollViewer VerticalScrollMode(this ScrollViewer scrollViewer, ScrollMode mode) { scrollViewer.VerticalScrollMode = mode; return(scrollViewer); }
public static ScrollViewer HorizontalScrollMode(this ScrollViewer scrollViewer, ScrollMode mode) { scrollViewer.HorizontalScrollMode = mode; return(scrollViewer); }
public static void UpdateFlyoutVerticalScrollMode(this MauiNavigationView navigationView, ScrollMode scrollMode) { var scrollViewer = navigationView.MenuItemsScrollViewer; if (scrollViewer != null) { switch (scrollMode) { case ScrollMode.Disabled: scrollViewer.VerticalScrollMode = WScrollMode.Disabled; scrollViewer.VerticalScrollBarVisibility = Microsoft.UI.Xaml.Controls.ScrollBarVisibility.Hidden; break; case ScrollMode.Enabled: scrollViewer.VerticalScrollMode = WScrollMode.Enabled; scrollViewer.VerticalScrollBarVisibility = Microsoft.UI.Xaml.Controls.ScrollBarVisibility.Visible; break; default: scrollViewer.VerticalScrollMode = WScrollMode.Auto; scrollViewer.VerticalScrollBarVisibility = Microsoft.UI.Xaml.Controls.ScrollBarVisibility.Auto; break; } } }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); if (ArchiveMaintainer == null || ArchiveMaintainer.LoadingInitialData) return; // Do the same thing for everything here for consistency DataTimeRange everything = CurrentArchiveRange; if (MouseDragging == DragMode.New && e.X == MouseDragStart) { LongPoint virtualclicked = LongPoint.DeTranslateFromScreen(new LongPoint(e.Location), everything, DataRange.UnitRange, new LongRectangle(ScrollViewRectangle)); long proposedoffset = ArchiveMaintainer.GraphNow.Ticks - (virtualclicked.X + (GraphWidth.Ticks / 2)); GraphOffset = TimeSpan.FromTicks(proposedoffset > 0 ? proposedoffset : 0); } TimerScroll = ScrollMode.None; Scroller.Stop(); AutoScaleGraph(); GridSpacing = BodgeSpacing(GraphWidth); RefreshXRange(false); MouseDragging = DragMode.None; MouseResizing = ResizeMode.None; }
public static T FlyoutVerticalScrollMode <T>(this T shell, ScrollMode flyoutVerticalScrollMode) where T : IRxShell { shell.FlyoutVerticalScrollMode = flyoutVerticalScrollMode; return(shell); }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (ArchiveMaintainer == null || ArchiveMaintainer.LoadingInitialData) return; DataTimeRange everything = CurrentArchiveRange; LongPoint virtualclicked = LongPoint.DeTranslateFromScreen(new LongPoint(e.Location), everything, DataRange.UnitRange, new LongRectangle(ScrollViewRectangle)); long selectedleft = LongPoint.TranslateToScreen(new LongPoint(GraphLeft.Ticks, 1), everything, DataRange.UnitRange, new LongRectangle(ScrollViewRectangle)).X; long selectedright = LongPoint.TranslateToScreen(new LongPoint(GraphRight.Ticks, 1), everything, DataRange.UnitRange, new LongRectangle(ScrollViewRectangle)).X; if (MouseDragging == DragMode.Existing) { long proposedoffset = ArchiveMaintainer.GraphNow.Ticks - (virtualclicked.X + (GraphWidth.Ticks / 2)); if (proposedoffset + GraphWidth.Ticks > ScrollViewOffset.Ticks + ScrollViewWidth.Ticks) { // ------------------------- // | _______________________|____________________________________ // | | ------------- | _______-------- | // | | / \___|__________/ \ | // | |---- | ---- -| // | |_______________________|_______________________________\__/_| // ------------------------- // // we have scrolled too far left (off the scroll view) GraphOffset = TimeSpan.FromTicks(ScrollViewWidth.Ticks + ScrollViewOffset.Ticks - GraphWidth.Ticks); } else if (proposedoffset < ScrollViewOffset.Ticks) { // ------------------------- // ___________________________________|_______________________ | // | ------------- _|_____-------- | | // | / \______________/ | \ | | // |---- | ---- -| | // |____________________________________|__________________\__/_| | // ------------------------- // // we have scrolled too far right (off the scroll view) if (GraphOffset == ScrollViewOffset) return; GraphOffset = ScrollViewOffset; } else { // ------------------------- // ___________|_________________________|______________________ // | -----|------- __|____-------- | // | / | \______________/ | \ | // |---- | | ---- -| // |___________|_________________________|_________________\__/_| // ------------------------- // // everything is fine, we are in the middle GraphOffset = TimeSpan.FromTicks(proposedoffset > 0 ? proposedoffset : 0); } if (GraphOffset.Ticks + GraphWidth.Ticks - ScrollViewOffset.Ticks > 0.90 * ScrollViewWidth.Ticks) { ScrollStrength = TimeSpan.FromTicks(GraphOffset.Ticks + GraphWidth.Ticks - (ScrollViewOffset.Ticks + (long)(0.90 * ScrollViewWidth.Ticks))); TimerScroll = ScrollMode.Left; Scroller.Start(); } else if (GraphOffset.Ticks - ScrollViewOffset.Ticks < 0.1 * ScrollViewWidth.Ticks) { ScrollStrength = TimeSpan.FromTicks((long)(0.1 * ScrollViewWidth.Ticks) - (GraphOffset.Ticks - ScrollViewOffset.Ticks)); TimerScroll = ScrollMode.Right; Scroller.Start(); } else { TimerScroll = ScrollMode.None; } } else if (MouseDragging == DragMode.New) { LongPoint virtualstart = LongPoint.DeTranslateFromScreen(new LongPoint(MouseDragStart, 1), everything, DataRange.UnitRange, new LongRectangle(ScrollViewRectangle)); if (e.X > MouseDragStart && e.X < ScrollViewRectangle.Width) { GraphOffset = new TimeSpan(ArchiveMaintainer.GraphNow.Ticks - virtualclicked.X); GraphWidth = new TimeSpan(virtualclicked.X - virtualstart.X); } else if (e.X < MouseDragStart && e.X > 0) { GraphOffset = new TimeSpan(ArchiveMaintainer.GraphNow.Ticks - virtualstart.X); GraphWidth = new TimeSpan(virtualstart.X - virtualclicked.X); } else if (e.X < MouseDragStart) { GraphOffset = new TimeSpan(ArchiveMaintainer.GraphNow.Ticks - virtualstart.X); GraphWidth = ScrollViewOffset + ScrollViewWidth - GraphOffset; } else if (e.X > MouseDragStart) { GraphOffset = ScrollViewOffset; GraphWidth = new TimeSpan(ScrollViewRight.Ticks - virtualstart.X); } } else if (MouseResizing == ResizeMode.Left) { long proposedwidth = ArchiveMaintainer.GraphNow.Ticks - (virtualclicked.X + GraphOffset.Ticks); if (((proposedwidth * ScrollViewRectangle.Width) / ScrollViewWidth.Ticks) > 2) GraphWidth = proposedwidth + GraphOffset.Ticks < ScrollViewWidth.Ticks + ScrollViewOffset.Ticks ? TimeSpan.FromTicks(proposedwidth) : ScrollViewWidth + ScrollViewOffset - GraphOffset; else GraphWidth = TimeSpan.FromTicks((2 * ScrollViewWidth.Ticks) / ScrollViewRectangle.Width); } else if (MouseResizing == ResizeMode.Right) { long proposedwidth = virtualclicked.X - GraphRight.Ticks; if (ArchiveMaintainer.GraphNow.Ticks - virtualclicked.X < ScrollViewOffset.Ticks) { GraphWidth += GraphOffset - ScrollViewOffset; GraphOffset = ScrollViewOffset; } else if ((((GraphWidth.Ticks + proposedwidth) * ScrollViewRectangle.Width) / ScrollViewWidth.Ticks) > 2) { GraphWidth += TimeSpan.FromTicks(virtualclicked.X - GraphRight.Ticks); GraphOffset = TimeSpan.FromTicks(ArchiveMaintainer.GraphNow.Ticks - virtualclicked.X); } else { long oldwidth = GraphWidth.Ticks; GraphWidth = TimeSpan.FromTicks((2 * ScrollViewWidth.Ticks) / ScrollViewRectangle.Width); GraphOffset += TimeSpan.FromTicks(oldwidth - GraphWidth.Ticks); } } else if (e.Location.X > selectedleft - 3 && e.Location.X < selectedleft + 3) { Cursor = Cursors.SizeWE; return; } else if (e.Location.X > selectedright - 3 && e.Location.X < selectedright + 3) { Cursor = Cursors.SizeWE; return; } else if (e.Location.X > selectedleft - 3 && e.Location.X < selectedright + 3) { Cursor = Cursors.SizeAll; return; } else { Cursor = Cursors.Cross; return; } GridSpacing = BodgeSpacing(GraphWidth); RefreshXRange(false); }
/// <summary> /// Scrollers configuration. Valid values are 'both', 'horizontal', 'vertical' or 'none'. Defaults to Both. /// </summary> public virtual TBuilder Scroll(ScrollMode scroll) { this.ToComponent().Scroll = scroll; return(this as TBuilder); }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (ArchiveMaintainer == null || ArchiveMaintainer.LoadingInitialData) { return; } DataTimeRange everything = CurrentArchiveRange; LongPoint virtualclicked = LongPoint.DeTranslateFromScreen(new LongPoint(e.Location), everything, DataRange.UnitRange, new LongRectangle(ScrollViewRectangle)); long selectedleft = LongPoint.TranslateToScreen(new LongPoint(GraphLeft.Ticks, 1), everything, DataRange.UnitRange, new LongRectangle(ScrollViewRectangle)).X; long selectedright = LongPoint.TranslateToScreen(new LongPoint(GraphRight.Ticks, 1), everything, DataRange.UnitRange, new LongRectangle(ScrollViewRectangle)).X; if (MouseDragging == DragMode.Existing) { long proposedoffset = ArchiveMaintainer.GraphNow.Ticks - (virtualclicked.X + (GraphWidth.Ticks / 2)); if (proposedoffset + GraphWidth.Ticks > ScrollViewOffset.Ticks + ScrollViewWidth.Ticks) { // ------------------------- // | _______________________|____________________________________ // | | ------------- | _______-------- | // | | / \___|__________/ \ | // | |---- | ---- -| // | |_______________________|_______________________________\__/_| // ------------------------- // // we have scrolled too far left (off the scroll view) GraphOffset = TimeSpan.FromTicks(ScrollViewWidth.Ticks + ScrollViewOffset.Ticks - GraphWidth.Ticks); } else if (proposedoffset < ScrollViewOffset.Ticks) { // ------------------------- // ___________________________________|_______________________ | // | ------------- _|_____-------- | | // | / \______________/ | \ | | // |---- | ---- -| | // |____________________________________|__________________\__/_| | // ------------------------- // // we have scrolled too far right (off the scroll view) if (GraphOffset == ScrollViewOffset) { return; } GraphOffset = ScrollViewOffset; } else { // ------------------------- // ___________|_________________________|______________________ // | -----|------- __|____-------- | // | / | \______________/ | \ | // |---- | | ---- -| // |___________|_________________________|_________________\__/_| // ------------------------- // // everything is fine, we are in the middle GraphOffset = TimeSpan.FromTicks(proposedoffset > 0 ? proposedoffset : 0); } if (GraphOffset.Ticks + GraphWidth.Ticks - ScrollViewOffset.Ticks > 0.90 * ScrollViewWidth.Ticks) { ScrollStrength = TimeSpan.FromTicks(GraphOffset.Ticks + GraphWidth.Ticks - (ScrollViewOffset.Ticks + (long)(0.90 * ScrollViewWidth.Ticks))); TimerScroll = ScrollMode.Left; Scroller.Start(); } else if (GraphOffset.Ticks - ScrollViewOffset.Ticks < 0.1 * ScrollViewWidth.Ticks) { ScrollStrength = TimeSpan.FromTicks((long)(0.1 * ScrollViewWidth.Ticks) - (GraphOffset.Ticks - ScrollViewOffset.Ticks)); TimerScroll = ScrollMode.Right; Scroller.Start(); } else { TimerScroll = ScrollMode.None; } } else if (MouseDragging == DragMode.New) { LongPoint virtualstart = LongPoint.DeTranslateFromScreen(new LongPoint(MouseDragStart, 1), everything, DataRange.UnitRange, new LongRectangle(ScrollViewRectangle)); if (e.X > MouseDragStart && e.X < ScrollViewRectangle.Width) { GraphOffset = new TimeSpan(ArchiveMaintainer.GraphNow.Ticks - virtualclicked.X); GraphWidth = new TimeSpan(virtualclicked.X - virtualstart.X); } else if (e.X < MouseDragStart && e.X > 0) { GraphOffset = new TimeSpan(ArchiveMaintainer.GraphNow.Ticks - virtualstart.X); GraphWidth = new TimeSpan(virtualstart.X - virtualclicked.X); } else if (e.X < MouseDragStart) { GraphOffset = new TimeSpan(ArchiveMaintainer.GraphNow.Ticks - virtualstart.X); GraphWidth = ScrollViewOffset + ScrollViewWidth - GraphOffset; } else if (e.X > MouseDragStart) { GraphOffset = ScrollViewOffset; GraphWidth = new TimeSpan(ScrollViewRight.Ticks - virtualstart.X); } } else if (MouseResizing == ResizeMode.Left) { long proposedwidth = ArchiveMaintainer.GraphNow.Ticks - (virtualclicked.X + GraphOffset.Ticks); if (((proposedwidth * ScrollViewRectangle.Width) / ScrollViewWidth.Ticks) > 2) { GraphWidth = proposedwidth + GraphOffset.Ticks < ScrollViewWidth.Ticks + ScrollViewOffset.Ticks ? TimeSpan.FromTicks(proposedwidth) : ScrollViewWidth + ScrollViewOffset - GraphOffset; } else { GraphWidth = TimeSpan.FromTicks((2 * ScrollViewWidth.Ticks) / ScrollViewRectangle.Width); } } else if (MouseResizing == ResizeMode.Right) { long proposedwidth = virtualclicked.X - GraphRight.Ticks; if (ArchiveMaintainer.GraphNow.Ticks - virtualclicked.X < ScrollViewOffset.Ticks) { GraphWidth += GraphOffset - ScrollViewOffset; GraphOffset = ScrollViewOffset; } else if ((((GraphWidth.Ticks + proposedwidth) * ScrollViewRectangle.Width) / ScrollViewWidth.Ticks) > 2) { GraphWidth += TimeSpan.FromTicks(virtualclicked.X - GraphRight.Ticks); GraphOffset = TimeSpan.FromTicks(ArchiveMaintainer.GraphNow.Ticks - virtualclicked.X); } else { long oldwidth = GraphWidth.Ticks; GraphWidth = TimeSpan.FromTicks((2 * ScrollViewWidth.Ticks) / ScrollViewRectangle.Width); GraphOffset += TimeSpan.FromTicks(oldwidth - GraphWidth.Ticks); } } else if (e.Location.X > selectedleft - 3 && e.Location.X < selectedleft + 3) { Cursor = Cursors.SizeWE; return; } else if (e.Location.X > selectedright - 3 && e.Location.X < selectedright + 3) { Cursor = Cursors.SizeWE; return; } else if (e.Location.X > selectedleft - 3 && e.Location.X < selectedright + 3) { Cursor = Cursors.SizeAll; return; } else { Cursor = Cursors.Cross; return; } GridSpacing = BodgeSpacing(GraphWidth); RefreshXRange(false); }
public void ScrollIntoView(KTreeNode node, ScrollMode mode) { if (mode == ScrollMode.None) { return; } if (!node.IsVisible) { //return; foreach (KTreeNode parent in node.Ancestors) { if (!parent.IsExpanded) { parent.IsExpanded = true; } else { break; } } } // Number of pixels from edge to keep node in Y direction. // TODO: this assumes all nodes are the same height int scrollBorderY = node.EffectiveDimension.NodeRect.Height; // Vertical // Do nothing if the node is already fully visible if (!ScrolledRectangle.ContainsY(node.EffectiveDimension.NodeRect.Top - scrollBorderY) || !ScrolledRectangle.ContainsY(node.EffectiveDimension.NodeRect.Bottom + scrollBorderY)) { if (mode == ScrollMode.Auto) { if (node.EffectiveDimension.NodeRect.Top + scrollBorderY < ScrolledRectangle.Y) { mode = ScrollMode.Top; } else { mode = ScrollMode.Bottom; } } switch (mode) { case ScrollMode.Top: SetVScroll(node.EffectiveDimension.NodeRect.Top - ViewRectangle.Top - scrollBorderY); break; case ScrollMode.Middle: SetVScroll((node.EffectiveDimension.NodeRect.Top + node.EffectiveDimension.NodeRect.Height / 2) - (ViewRectangle.Top + ViewRectangle.Height / 2)); break; case ScrollMode.Bottom: SetVScroll(node.EffectiveDimension.NodeRect.Bottom - ViewRectangle.Bottom + scrollBorderY); break; } } // Horizontal if (!ScrolledRectangle.ContainsX(node.EffectiveDimension.NodeRect.Left) || !ScrolledRectangle.ContainsX(node.EffectiveDimension.NodeRect.Right)) { // Align left or right, depending on which is the smallest change int alignLeft = node.EffectiveDimension.NodeRect.Left - ViewRectangle.Left; int alignRight = node.EffectiveDimension.NodeRect.Right - ViewRectangle.Right; if (Math.Abs(alignLeft - _horizontalScrollBar.Value) < Math.Abs(alignRight - _horizontalScrollBar.Value)) { SetHScroll(alignLeft); } else { SetHScroll(alignRight); } } // Check current highlight CheckMouseHighlight(); }
//カード情報をウィンドウに反映させる void WriteWindow(Card _card) { text_name.text = _card.GetName(); text_user.text = ""; for (int i = 0; i < _card.GetUser().Length; ++i) { text_user.text += i == 0 ? "" : " " + _card.GetUser()[i]; } // //書き換えタイミング // if (view_frame == view_period - 1 && !isClearing) { // //if (!isClearing) { // Card cs = card; //GetByteCountは使えない //nm_size = nm_char_size * System.Text.Encoding.GetEncoding(932) // .GetByteCount(nm.text.ToString()) / 2; var gui = new GUIStyle() { font = font_name }; nameSize = gui.CalcSize(new GUIContent(text_name.text)).x; text_name.rectTransform.offsetMin.Set(0, text_name.rectTransform.offsetMin.y); nameMode = ScrollMode.size - 1; nameFrame = -1; //nmMode = NameModeType.size - 1; //nm_frame = -1; //テキストの決定 //テキストで使えるのは //\n : 改行 //\h : ぶら下げ float textLength = 0; //1行に入るテキスト長さ float textLine = 0; //縦の長さ int lineStart = 0; //一行の開始地点 int lineFromFirst = 0; //段落から何行目か bool yen = false; //直前が\のときに真 bool breakFlag = false; //改行フラグ string hungFirst = ""; //段落冒頭の左側 string hungSecond = ""; //段落冒頭以外の左側 string buffer = ""; //これを最終的にtxt.textに流す gui = new GUIStyle() { font = font_text }; for (int i = 0; i < _card.text.Length; ++i) { if (_card.text[i] == '\\') { yen = true; continue; } if (yen) { yen = false; switch (_card.text[i]) { case 'n': breakFlag = true; hungFirst = ""; hungSecond = ""; continue; case 'h': breakFlag = true; hungFirst = ""; hungSecond = " "; continue; } } textLength += gui.CalcSize(new GUIContent(_card.text[i].ToString())).x; if (textLength > textLengthBorder || breakFlag || i == _card.text.Length - 1) { string line = _card.text.Substring(lineStart, i - lineStart); line = line.Replace("\\n", ""); line = line.Replace("\\h", ""); buffer += lineFromFirst == 0 ? hungFirst : hungSecond + line + "\n"; lineStart = i; if (breakFlag) { lineFromFirst = 0; } else { ++lineFromFirst; } textLine += gui.CalcSize(new GUIContent(_card.text[i].ToString())).y; textLength = gui.CalcSize(new GUIContent( (lineFromFirst == 0 ? hungFirst : hungSecond))).x; breakFlag = false; } } text_text.text = buffer; //offsetMin = new Vector2 (left,top); //offsetMax = new Vector2 (right,bottom); var hoge = new Vector2(0, textLineBorder - textLine); text_text.rectTransform.offsetMin = hoge; if (textLine < textLineBorder) { text_text.rectTransform.offsetMax = hoge; obj_textScroll.GetComponent <ScrollRect>().vertical = false; } else { text_text.rectTransform.offsetMax = new Vector2(0, 0); obj_textScroll.GetComponent <ScrollRect>().vertical = true; } obj_textScroll.GetComponent <ScrollRect>().verticalNormalizedPosition = 1f; //コスト火力耐久の反映 for (int i = 0; i < obj_stateView.Length; ++i) { int state = 0; switch ((Card.State)i) { case Card.State.cost: state = _card.GetCost(); break; case Card.State.power: state = _card.GetPower(); break; case Card.State.toughness: state = _card.GetToughness(); break; } stateNum[i].GetComponent <Number>().num = state; stateNum[i].transform.localScale = new Vector3(1, 1, 0) * numScale; } stateNum[(int)Card.State.cost].GetComponent <Number>().isVisible = _card.type != Card.Type.character; for (int i = 0; i < (int)Card.CharacterState.size; ++i) { var isTypeChar = _card.type == Card.Type.character; obj_characterStateView[i].SetActive(isTypeChar); characterStateNum[i].GetComponent <Number>().isVisible = isTypeChar; characterStateNum[i].transform.localScale = new Vector3(1, 1, 0) * numScale; int state = 0; switch ((Card.CharacterState)i) { case Card.CharacterState.mana: state = _card.mana; break; case Card.CharacterState.manaCapacity: state = _card.manaCapacity; break; case Card.CharacterState.od: state = _card.od; break; } characterStateNum[i].GetComponent <Number>().num = state; } //彩度の決定 foreach (var i in chromas) { Destroy(i); } foreach (var i in chromaNums) { Destroy(i); } chromas.Clear(); chromaNums.Clear(); //スタート地点を見つける Card.Color start = CardObj.GetStartColor(_card); //シンボルの種類を数える int colorHave = 0; for (int i = 0; i < (int)Card.Color.size; ++i) { if (_card.color[i] > 0) { ++colorHave; } } //配置する for (int i = 0, a = 0; i < (int)Card.Color.size; ++i) { int b = ((int)start + i) % (int)Card.Color.size; if (0 < _card.color[b]) { var obj = Utility.InstantiateWithTransform(orig_chroma, orig_chroma.transform); obj.transform.localPosition += new Vector3(chromaBlank * a++, 0, 0); obj.transform.localScale = new Vector3(1, 1, 1) * chromaScale; obj.GetComponent <Image>().sprite = chromaPic[b]; chromas.Add(obj); if (1 < _card.color[b]) { var num = Instantiate(orig_num, obj.transform.position + chromaNumPos, obj.transform.rotation, obj.transform); num.GetComponent <Number>().num = _card.color[b]; num.transform.localScale = new Vector3(1, 1, 0) * chromaNumScale; chromaNums.Add(num); } } } }
private void DoSelectNode(KTreeNode node, SelectAction action, ScrollMode scroll) { if (action == SelectAction.Set || action == SelectAction.Range) { _selectionManager.Clear(); } if (node != null) { switch (action) { case SelectAction.Range: case SelectAction.AddRange: if (_selectRangeAnchor == null) { _selectRangeAnchor = node; _selectionManager.Add(node); break; } // Select any nodes from the anchor to the current node int activeIndex = Math.Max(0, _presentNodes.IndexOf(_selectRangeAnchor)); int nodeIndex = _presentNodes.IndexOf(node); // Keep to order just in case the selection manager wants it if (activeIndex > nodeIndex) { for (int i = nodeIndex; i <= activeIndex; ++i) { if (_presentNodes[i].IsSelectable) { _selectionManager.Add(_presentNodes[i]); } } } else { for (int i = activeIndex; i <= nodeIndex; ++i) { if (_presentNodes[i].IsSelectable) { _selectionManager.Add(_presentNodes[i]); } } } break; case SelectAction.Set: _selectRangeAnchor = node; _selectionManager.Add(node); break; case SelectAction.Toggle: _selectRangeAnchor = node; _selectionManager.Toggle(node); break; } if (scroll != ScrollMode.None) { ScrollIntoView(node, scroll); } } ActiveNode = node; // Must rerender // TODO: affected nodes only Rerender(); // Raise event if needed CheckSelectionChanged(); }
public void BeginScrolling(ScrollMode mode) { scrollMode = mode; isScrolling = true; }