/// <summary> /// Called by framework. Do not call directly. /// </summary> public void OnUpdate() { if (Mouse.LeftDown && ParentCanvas.CursorInside(Icon)) { Icon.RectTransform.Angle = 0; Collapsed = !Collapsed; } if (Collapsed && Icon.Background.Source == _arrDn) { Icon.RectTransform.Angle -= 30; } if (Icon.RectTransform.Angle <= -90) { Icon.Background.Source = _arrRt; Icon.RectTransform.Angle = 0; } if (!Collapsed && Icon.Background.Source == _arrRt) { Icon.RectTransform.Angle += 30; } if (Icon.RectTransform.Angle >= 90) { Icon.Background.Source = _arrDn; Icon.RectTransform.Angle = 0; } }
public void OnTriggerThis() { Debug.Log(toggle1.isOn); Debug.Log(MyNumber); ParentCanvas.ChangePlayerType(MyNumber); }
public override void ProcessMouseEvent(Vector2 location, InputManager.LogicalButtonState buttons) { if (!buttons.PrimaryClick) { return; } ParentCanvas.SetFocusedTextArea(this); }
void Start() { GetComponent <CanvasGroup>().alpha = 0; RectTransform canvasTransform = ParentCanvas.GetComponent <RectTransform>(); Overlay.GetComponent <RectTransform>().sizeDelta = new Vector2(canvasTransform.rect.width, canvasTransform.rect.height * 1.25f); Overlay.GetComponent <RectTransform>().anchoredPosition = Vector2.zero; }
public override void PlotToParentStandalone(Point point, EventMessage @event) { if (!VisualData.TryTransformVisualData <ContextData>(out var visual_data)) { return; } if (!IsCrossShow) { X.Visibility = Visibility.Collapsed; Y.Visibility = Visibility.Collapsed; return; } var coms = DataSources.ElementAt(0).Value as ChartDataSource; var axisxs = coms.AxisXCollection; var axisys = coms.AxisYCollection; var series = coms.SeriesCollection; var plotArea = coms.ConnectVisual.PlotArea; if (LastPlotArea != plotArea) { X.X1 = Y.X1 = 0; X.Y1 = Y.X1 = 0; X.X2 = plotArea.Width; X.Y2 = 0; Y.X2 = 0; Y.Y2 = plotArea.Height; Canvas.SetLeft(X, plotArea.Location.X); Canvas.SetTop(X, plotArea.Location.Y); Canvas.SetTop(Y, plotArea.Location.Y); Canvas.SetLeft(Y, plotArea.Location.X); } if (!visual_data.Current.Items.ContainsKey(ContextDataItem.HitPointer)) { return; } var hitPointer = (Point)visual_data.Current.Items[ContextDataItem.HitPointer]; //优化 bool isXInvariant = false; bool isYInvariant = false; if (hitPointer.X == LastPoint.X) { isXInvariant = true; } if (hitPointer.Y == LastPoint.Y) { isYInvariant = true; } LastPoint = hitPointer; if (plotArea.Contains(point)) { if (IsLabelShow) { var nearestX = point.X; var nearestY = point.Y; //var nearestY = point.Y; //找最小距离 var axisLabelList = new List <ElementPosition>(); if (!isXInvariant) { foreach (DiscreteAxis axis in axisxs) { var value = axis.GetValue(axis.OffsetPostion(point.X)); if (!value.IsBad() && axis.IsAxisLabelShow) { if (!CurrentAll.ContainsKey(axis.Id)) { ParentCanvas.AddElement(axis.AxisLabel); CurrentAll[axis.Id] = axis; } axis.AxisLabel.Text = axis.GetStringValue(value); var labelData = axis.GetAxisLabelData(value); if (labelData.IsBad) { continue; } axisLabelList.Add(new ElementPosition(axis.AxisLabel, true, labelData.Left, labelData.Top, axis.AxisLabel.ZIndex)); } else { axisLabelList.Add(new ElementPosition(axis.AxisLabel)); } } } if (!isYInvariant) { foreach (ContinuousAxis axis in axisys) { var value = axis.GetValue(axis.OffsetPostion(nearestY)); if (axis.IsAxisLabelShow) { if (!CurrentAll.ContainsKey(axis.Id)) { ParentCanvas.Children.Add(axis.AxisLabel); CurrentAll[axis.Id] = axis; } axis.AxisLabel.Text = $"{axis.GetStringValue(value)}{axis.Unit}"; var labelData = axis.GetAxisLabelData(value); axisLabelList.Add(new ElementPosition(axis.AxisLabel, true, labelData.Left, labelData.Top)); } else { axisLabelList.Add(new ElementPosition(axis.AxisLabel)); } } } foreach (var item in axisLabelList) { item.Render(); } } LastPlotArea = plotArea; if (!isYInvariant) { if (IsXShow) { X.Visibility = Visibility.Visible; } else { X.Visibility = Visibility.Collapsed; } Canvas.SetTop(X, hitPointer.Y); } if (!isXInvariant) { if (IsYShow) { Y.Visibility = Visibility.Visible; } else { Y.Visibility = Visibility.Collapsed; } Canvas.SetLeft(Y, hitPointer.X); } } else { foreach (var item in CurrentAll) { item.Value.AxisLabel.Visibility = Visibility.Collapsed; } X.Visibility = Visibility.Collapsed; Y.Visibility = Visibility.Collapsed; } }
/// <summary> /// Update timer for the game, this should run 120 times a second (default). /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void UpdateTimer_Tick(object sender, object e) { if (!IsUpdating) { IsUpdating = true; //find delta t TimeSpan dt = DateTime.Now - LastUpdateTime; //Update LastUpdateTime LastUpdateTime = DateTime.Now; //Update the total app time TotalAppTime += dt; //get the current input from the input manager GenericInput gi = InputManager.Update(); GenericMessage gm = MessageManager.Update(); if (StoryBoard.Update(dt, gm)) { } else { if (null != StoryBoard.CurrentScene) { StoryBoard.CurrentScene.Update(dt, gi); StoryBoard.CurrentScene.Update(dt, gm); gi = InputManager.PeekAndTake(typeof(MouseGenericInput)); while (gi is MouseGenericInput) { StoryBoard.CurrentScene.Update(TimeSpan.Zero, gi); gi = InputManager.PeekAndTake(typeof(MouseGenericInput)); } gm = MessageManager.PeekAndTake(typeof(Message_Attack)); while (gm is Message_Attack) { StoryBoard.CurrentScene.Update(TimeSpan.Zero, gm); gm = MessageManager.PeekAndTake(typeof(Message_Attack)); } gi = InputManager.PeekAndTake(typeof(Message_Collision)); while (gm is Message_Collision) { StoryBoard.CurrentScene.Update(TimeSpan.Zero, gm); gm = MessageManager.PeekAndTake(typeof(Message_Collision)); } } } //Figure out if we need to refresh the screen TimeSpan dt_Draw = DateTime.Now - LastDrawTime; if (dt_Draw.Milliseconds > TimeBetweenDraw.Milliseconds) { //call refresh if (null != ParentCanvas) { ParentCanvas.Invalidate(); LastDrawTime = DateTime.Now; } } IsUpdating = false; } }
private void PopupButton_Clicked(object sender, UIButton e) { SetSelectedIndex(IndexFromText(e.Tag as string)); ParentCanvas.SetPopupElement(null); }
public override void ProcessMouseEvent(Vector2 location, InputManager.LogicalButtonState buttons) { if (Math.Abs(buttons.WheelTick) > 0 && TextLabels.Count > 1) { SetSelectedIndex(SelectedIndex + buttons.WheelTick); } if (!buttons.PrimaryClick || ParentCanvas == null || ParentCanvas.PopupEnabled() || TextLabels.Count < 2) { return; } float width = Rect.GetPixelSize().X; float height = Rect.GetPixelSize().Y; Vector2 origin = Rect.GetPixelOrigin(); float availableDist = width - (height * 2); if (location.X < origin.X + height || location.X > origin.X + availableDist + height) { return; } Vector2 thisOrigin = GetScreenOrigin(); float thisCenterY = thisOrigin.Y + (height * 0.5f); float totalheight = (MenuCommon.ButtonSpacing.Paramater + (height * 1)) * TextLabels.Count; totalheight += MenuCommon.ButtonSpacing.Paramater * 1; float halfHeight = totalheight * 0.5f; float screenHeight = ParentCanvas.BoundWindow.Height; // see where the popup will land on the screen. OriginLocation originAllignment = OriginLocation.LowerLeft; if (totalheight > screenHeight) // it won't fit, center it { originAllignment = OriginLocation.MiddleLeft; } else { if (thisCenterY - halfHeight > 0 && thisCenterY + halfHeight <= screenHeight) { originAllignment = OriginLocation.MiddleLeft; // it'll fit centered, that looks better } else { // it won't fit centered, so put it on the other side of the screen from where the button is if (thisCenterY > halfHeight) { originAllignment = OriginLocation.UpperLeft; } else { originAllignment = OriginLocation.LowerLeft; } } } if (originAllignment == OriginLocation.UpperLeft) { thisOrigin.Y += height; } else if (originAllignment == OriginLocation.MiddleLeft) { thisOrigin.Y += height * 0.5f; } RelativeRect rect = new RelativeRect(new RelativeLoc(thisOrigin.X, RelativeLoc.Edge.Raw), new RelativeLoc(thisOrigin.Y, RelativeLoc.Edge.Raw), RelativeSize.FixedPixelSize(width), RelativeSize.FixedPixelSize(totalheight), originAllignment); var popup = new UIPanel(rect, ThemeManager.GetThemeAsset("ui/SelectorPopupBackground.png")); popup.FillMode = UIFillModes.SmartStprite; popup.IgnoreMouse = false; VerticalLayoutGroup vertgroup = MenuCommon.SetupCommonColumn(new RelativeRect(RelativeLoc.XCenter, RelativeLoc.YCenter, RelativeSize.ThreeQuarterWidth, rect.Height, OriginLocation.Center)); vertgroup.FirstElementHasSpacing = true; foreach (var label in TextLabels) { MenuButton button = new MenuButton(new RelativeRect(), label); button.Tag = label; button.Clicked += PopupButton_Clicked; if (label == GetText()) { button.Check(); } vertgroup.AddChild(button); } popup.AddChild(vertgroup); ParentCanvas.SetPopupElement(popup); }