//初始化 public override void Init() { _playerLayer = GameObject.Find("PlayerLayer").transform; _cameraManager = Camera.main.GetComponent <CameraFollow>(); _charaDic = new Dictionary <uint, CharaActorInfo>(); _charaViewDic = new Dictionary <uint, GameObject>(); _charaList = new List <CharaActorInfo>(); SceneFrame = 0; _playerPrefab = new Dictionary <uint, GameObject>(); //操作集合初始化 CommandDic = new Dictionary <uint, List <FightCommandBase> >(); OwnerControl.GetInstance().Init(); //技能解析管理器初始化 SkillActionManager.GetInstance().Init(); //特效管理器 EffectManager.GetInstance().Init(); //战斗ui ZTSceneUI.GetInstance().Init(); InitEvent(); }
private void OnHoverInfoChanged(ColorLabelHitInfo prevInfo, ColorLabelHitInfo hoverInfo) { if (OwnerControl != null) { OwnerControl.Invalidate(); OwnerControl.Update(); } }
public override bool HandleInput() { bool captured = false; if (!Visible || !CanScroll()) { return(captured); } var absolutePosition = OwnerControl.GetPositionAbsoluteCenter() + Position; bool mouseOverThis = MyGuiControlBase.CheckMouseOver(Size, absolutePosition, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); bool mouseOverOwner = OwnerControl.IsMouseOver; IsOverCaret = MyGuiControlBase.CheckMouseOver(CaretSize, absolutePosition + GetCarretPosition(), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); switch (State) { case StateEnum.Ready: if (MyInput.Static.IsNewPrimaryButtonPressed() && IsOverCaret) { captured = true; State = StateEnum.Drag; m_dragClick = MyGuiManager.MouseCursorPosition; } break; case StateEnum.Drag: if (!MyInput.Static.IsPrimaryButtonPressed()) { State = StateEnum.Ready; } else { ChangeValue((MyGuiManager.MouseCursorPosition.Y - m_dragClick.Y) * (Max - Page) / (Size.Y - CaretSize.Y)); m_dragClick = MyGuiManager.MouseCursorPosition; } captured = true; break; } if (mouseOverThis || mouseOverOwner) { var scrolled = MyInput.Static.DeltaMouseScrollWheelValue(); if (scrolled != 0 && scrolled != -MyInput.Static.PreviousMouseScrollWheelValue()) { captured = true; ChangeValue((scrolled / -120f) * Page * 0.25f); } } return(captured); }
public override void Destroy() { RemoveEvent(); ClearChara(); OwnerControl.GetInstance().Destroy(); //地图移除 MapManager.GetInstance().Destroy(); //技能解析管理器移除 SkillActionManager.GetInstance().Destroy(); //特效管理器 EffectManager.GetInstance().Destroy(); //战斗ui ZTSceneUI.GetInstance().Destroy(); }
//刷新对象( 场景相关计算 唯一更新接口) public void Update() { if (SceneFrame > FightDefine.MaxFrame) { SceneFrame = 0; } SceneFrame++; //刷新玩家虚拟摇杆 OwnerControl.GetInstance().Update(); UpdateCommand(); UpdatePlayer(); UpdateMap(); SkillActionManager.GetInstance().Update(); //战斗ui ZTSceneUI.GetInstance().Update(); }
public void SetItemCheckState(object item, CheckBoxState newCheckState) { CheckBoxEventArgs args = new CheckBoxEventArgs(item, GetItemCheckState(item), newCheckState); if (BeforeCheck != null) { BeforeCheck(this, args); } _checkStates [item] = args.NewState; if (args.OldState != args.NewState) { OnAfterCheck(args); OwnerControl.InvalidateItem(item); } }
private void btnRestoreFactoryDefault_Click(object sender, EventArgs e) { try { //MessageBox.Show("Load Layout Button"); //base.OnLoadLayoutButtonClick(sender, e); DB.SYS_Layout sys_layout = DataContext.EntitySystemContext.SYS_Layout.FirstOrDefault(n => n.Screen == ScreenName && n.UserId == SelectedUser); System.Xml.XmlDocument XmlDoc = new System.Xml.XmlDocument(); XmlDoc.LoadXml(sys_layout.Custom); System.IO.Stream Layout = new System.IO.MemoryStream(); XmlDoc.Save(Layout); Layout.Seek(0, System.IO.SeekOrigin.Begin); OwnerControl.RestoreLayoutFromStream(Layout); //OwnerControl.CustomizationForm.Close(); sys_layout.Custom = sys_layout.SystemOriginal; sys_layout.Original = sys_layout.SystemOriginal; try { using (TransactionScope transaction = DataContext.GetTransactionScope()) { BL.EntityController.SaveSYS_Layout(sys_layout, DataContext); DataContext.SaveChangesEntitySystemContext(); DataContext.CompleteTransaction(transaction); } DataContext.EntitySystemContext.AcceptAllChanges(); } catch (Exception ex) { DataContext.EntitySystemContext.RejectChanges(); if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex)) { throw ex; } } } catch (Exception ex) { //DataContext.EntitySystemContext.RollBackTransaction(); if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex)) { throw ex; } } }
/// <summary> /// Override of <see cref="DragThumb.AdjustDrag" /> aligns dragged point to the borders of its <see cref="OwnerControl"/> /// </summary> /// <param name="deltaEventArgs"></param> protected override void AdjustDrag(ref DragDeltaEventArgs deltaEventArgs) { base.AdjustDrag(ref deltaEventArgs); if (OwnerControl != null) { Rect bounds = OwnerControl.GetBounds(); Point p = new Point(CanvasPosition.X + deltaEventArgs.HorizontalChange, CanvasPosition.Y + deltaEventArgs.VerticalChange); Point snapped = bounds.SnapPointToRectangle(p); deltaEventArgs = new DragDeltaEventArgs(snapped.X - CanvasPosition.X, snapped.Y - CanvasPosition.Y); } else { JunctionPoint rightNeighbour = Junction.Points.ElementAtOrDefault(OrderInJunction + 1); JunctionPoint leftNeighbour = Junction.Points.ElementAtOrDefault(OrderInJunction - 1); const double SNAP_RATIO = 14; foreach (JunctionPoint neighbour in new[] { leftNeighbour, rightNeighbour }) { bool isEndPoint = neighbour == Junction.StartPoint || neighbour == Junction.EndPoint; if (neighbour != null && (!isEndPoint || neighbour.Placement == EPlacementKind.AbsoluteSubCanvas)) { double nx = neighbour.CanvasPosition.X; double ny = neighbour.CanvasPosition.Y; double deltax = deltaEventArgs.HorizontalChange; double deltay = deltaEventArgs.VerticalChange; double diff; if (ShouldSnap(MousePoint.Y, ny, SNAP_RATIO, out diff)) { ShouldSnap(CanvasPosition.Y + deltaEventArgs.VerticalChange, ny, SNAP_RATIO, out diff); deltay += diff; deltaEventArgs = new DragDeltaEventArgs(deltax, deltay); } else if (ShouldSnap(MousePoint.X, nx, SNAP_RATIO, out diff)) { ShouldSnap(CanvasPosition.X + deltaEventArgs.HorizontalChange, nx, SNAP_RATIO, out diff); deltax += diff; deltaEventArgs = new DragDeltaEventArgs(deltax, deltay); } } } } }
public override void Draw(Color colorMask) { if (!Visible) { return; } var leftTopPosition = OwnerControl.GetPositionAbsoluteCenter() + Position; m_backgroundTexture.Draw(leftTopPosition, Size, colorMask); if (CanScroll()) { var carretPosition = GetCarretPosition(); Texture.Draw(leftTopPosition + carretPosition, CaretSize, colorMask); } }
/// <summary> Creates a <see cref="CommandInfo"/> for the <see cref="HrefCommand"/>. </summary> /// <param name="parameters"> /// The strings inserted into the href attribute using <c>string.Format</c>. /// </param> /// <param name="onClick"> /// The string always rendered in the <c>onClick</c> tag of the anchor element. /// </param> /// <param name="additionalUrlParameters"> /// The <see cref="NameValueCollection"/> containing additional url parameters. /// Must not be <see langword="null"/>. /// </param> /// <param name="includeNavigationUrlParameters"> /// <see langword="true"/> to include URL parameters provided by <see cref="ISmartNavigablePage"/>. /// Defaults to <see langword="true"/>. /// </param> /// <exception cref="InvalidOperationException"> /// If called while the <see cref="Type"/> is not set to <see cref="CommandType.Href"/>. /// </exception> protected virtual CommandInfo GetCommandInfoForHrefCommand( string[] parameters, string onClick, NameValueCollection additionalUrlParameters, bool includeNavigationUrlParameters) { ArgumentUtility.CheckNotNull("parameters", parameters); ArgumentUtility.CheckNotNull("additionalUrlParameters", additionalUrlParameters); if (Type != CommandType.Href) { throw new InvalidOperationException("Call to GetCommandInfoForHrefCommand not allowed unless Type is set to CommandType.Href."); } string href = HrefCommand.FormatHref(parameters); if (includeNavigationUrlParameters) { ISmartNavigablePage page = null; if (OwnerControl != null) { page = OwnerControl.Page as ISmartNavigablePage; } if (page != null) { additionalUrlParameters = additionalUrlParameters.Clone(); NameValueCollectionUtility.Append(additionalUrlParameters, page.GetNavigationUrlParameters()); } } href = UrlUtility.AddParameters(href, additionalUrlParameters); if (OwnerControl != null) { href = OwnerControl.ResolveClientUrl(href); } return(CommandInfo.CreateForLink( StringUtility.EmptyToNull(_toolTip), StringUtility.EmptyToNull(_accessKey), href, StringUtility.EmptyToNull(HrefCommand.Target), StringUtility.EmptyToNull(onClick))); }
protected virtual void ShowInfoAnimated() { Point location = Point.Empty; if (OwnerControl != null) { Rectangle rect = OwnerControl.RectangleToScreen(OwnerControl.ClientRectangle); DestinationBounds = new Rectangle(rect.Right - Width, rect.Bottom - Height, Width, Height); } else { Screen screen = Screen.FromControl(OwnerForm); DestinationBounds = new Rectangle(screen.WorkingArea.Right - Width, screen.WorkingArea.Bottom - Height, Width, Height); } StartBounds = new Rectangle(DestinationBounds.X + Offset, DestinationBounds.Y, DestinationBounds.Width, DestinationBounds.Height); Opacity = 0.0f; Visible = true; Bounds = StartBounds; FloatAnimationInfo info = new FloatAnimationInfo(this, this, 1000, 0.0f, 1.0f, true); XtraAnimator.Current.AddAnimation(info); }
protected override void UpdateTokenState(TokenEditTokenInfo tokenInfo) { base.UpdateTokenState(tokenInfo); if (!Item.ReadOnly) { Point pt = OwnerControl != null?OwnerControl.PointToClient(Control.MousePosition) : MousePosition; CustomTokenEditTokenInfo info = tokenInfo as CustomTokenEditTokenInfo; if (info.CheckBoxGlyphBounds.Contains(pt)) { info.CheckBoxState = ObjectState.Hot; if ((Control.MouseButtons & MouseButtons.Left) != 0) { info.CheckBoxState |= ObjectState.Pressed; } } else { info.CheckBoxState = ObjectState.Normal; } } }
internal void MarkItem(int targetIndex, int sourceIndex) { DropLine(); DragDropLineColor = Color.Red; if (targetIndex == sourceIndex || targetIndex == sourceIndex + 1 || sourceIndex == ItemCount - 1 && targetIndex == -1 || targetIndex == 0) { DragDropLineColor = Color.LightGray; } if (targetIndex == -1) { UnderlineItem(ItemCount - 1); } else { OverlineItem(targetIndex); } if (targetIndex > 0) { UnderlineItem(targetIndex - 1); } OwnerControl.Invalidate(); }
protected internal virtual void MarkItem(int targetIndex, int sourceIndex) { DropLine(); dragDropLineColor = Color.Red; if ((targetIndex == sourceIndex) || (targetIndex == sourceIndex + 1) || (sourceIndex == ItemCount - 1 && targetIndex == -1)) { dragDropLineColor = Color.LightGray; } if (targetIndex == -1) { UnderlineItem(ItemCount - 1); } else { OverlineItem(targetIndex); } if (targetIndex > 0) { UnderlineItem(targetIndex - 1); } OwnerControl.Invalidate(); }
void InputWindow_Loaded(object sender, RoutedEventArgs e) { if (TextBox_Value != null) { var bindExp = TextBox_Value.GetBindingExpression(TextBox.TextProperty); if (bindExp != null) { if (bindExp.ParentBinding.ValidationRules.Count > 0) { var rule = bindExp.ParentBinding.ValidationRules[0] as RequiredRule; if (rule != null) { rule.OnValidateCheck = mOnValidateCheck; } } } } mWinEffects.Clear(); foreach (var win in DockControl.DockManager.Instance.DockableWindows) { mWinEffects[win] = Effect; win.Effect = new BlurEffect() { Radius = 2, KernelType = KernelType.Gaussian }; } if (OwnerControl != null) { var oriPt = OwnerControl.PointToScreen(new Point(0, 0)); this.Left = oriPt.X + OwnerControl.ActualWidth * 0.5 - this.ActualWidth * 0.5; this.Top = oriPt.Y + OwnerControl.ActualHeight * 0.5 - this.ActualHeight * 0.5; } }
protected override string GetItemText(object item, int width) { IResource res = (IResource)item; if (Core.State == CoreState.ShuttingDown) { return(""); } string result = null; if (_propIds != null) { for (int i = 0; i < _propIds.Length; i++) { int propID = _propIds [i]; if (_propToTextConverters != null && _propToTextConverters [i] != null) { if (res.HasProp(propID)) { int widthInChars = 0; if (OwnerControl != null && width > 0) { using (Graphics g = OwnerControl.CreateGraphics()) { widthInChars = width / OwnerControl.ControlPainter.MeasureText(g, "a", OwnerControl.Font).Width; } } result = _propToTextConverters [i].GetPropertyText(res, propID, widthInChars); } else { result = null; } } else if (propID == ResourceProps.DisplayName) { result = res.DisplayName; } else if (propID == ResourceProps.Type) { result = ""; } else { if (_ownerList != null) { if (_ownerList.HasProp(res, propID)) { result = _ownerList.GetPropText(res, propID); } else { result = null; } } else { if (res.HasProp(propID)) { result = res.GetPropText(propID); } else { result = null; } } } if (result != null) { break; } } } if (result != null) { if (result.IndexOf('\n') >= 0) { result = result.Replace('\n', ' '); } return(result); } return(String.Empty); }
private void UpdateDecoration(IResource res) { OwnerControl.UpdateItemSafe(res); }
protected override void OnPostChanges( EventArgs e) { base.OnPostChanges(e); OwnerControl.SetEditorValue(Value); }
protected override void OnSaveLayoutButtonClick(object sender, EventArgs e) { try { System.IO.Stream Layout = new System.IO.MemoryStream(); OwnerControl.SaveLayoutToStream(Layout); System.Xml.XmlDocument XmlDoc = new System.Xml.XmlDocument(); Layout.Seek(0, System.IO.SeekOrigin.Begin); using (System.IO.StreamReader reader = new System.IO.StreamReader(Layout)) XmlDoc.InnerXml = reader.ReadToEnd(); try { using (TransactionScope transaction = DataContext.GetTransactionScope()) { foreach (Int64 user in SelectedUsers) { DB.SYS_Layout sys_layout = DataContext.EntitySystemContext.SYS_Layout.FirstOrDefault(n => n.Screen == ScreenName && n.UserId == user); if (sys_layout == null) { //Form Layout sys_layout = BL.SYS.SYS_Layout.New; if (sys_layout.Original == null) { sys_layout.Screen = ScreenName; sys_layout.Original = XmlDoc.InnerXml; sys_layout.SystemOriginal = XmlDoc.InnerXml; sys_layout.Custom = XmlDoc.InnerXml; } //Grids Layouts foreach (var control in OwnerControl.Control.Controls) { if (control is DevExpress.XtraGrid.GridControl) { foreach (DevExpress.XtraGrid.Views.Grid.GridView view in (control as DevExpress.XtraGrid.GridControl).Views) { System.IO.Stream gridViewLayout = new System.IO.MemoryStream(); view.SaveLayoutToStream(gridViewLayout); gridViewLayout.Seek(0, System.IO.SeekOrigin.Begin); System.Xml.XmlDocument gridViewXmlDoc = new System.Xml.XmlDocument(); using (System.IO.StreamReader gridViewReader = new System.IO.StreamReader(gridViewLayout)) gridViewXmlDoc.InnerXml = gridViewReader.ReadToEnd(); DB.SYS_Layout sys_layout_grid = BL.SYS.SYS_Layout.New; sys_layout_grid.Screen = ScreenName + "+" + view.Name; sys_layout_grid.Original = gridViewXmlDoc.InnerXml; sys_layout_grid.SystemOriginal = gridViewXmlDoc.InnerXml; sys_layout_grid.Custom = gridViewXmlDoc.InnerXml; sys_layout_grid.UserId = user; BL.EntityController.SaveSYS_Layout(sys_layout_grid, DataContext); } } } //Ribbon Layout string ribbonQuickAccessToolbarName = ScreenName + "+" + "QuickAccessToolbar"; foreach (var control in OwnerControl.Parent.Controls) { if (control is DevExpress.XtraBars.Ribbon.RibbonControl) { foreach (DevExpress.XtraBars.BarItem item in (control as DevExpress.XtraBars.Ribbon.RibbonControl).Items) { (item as DevExpress.XtraBars.BarItem).Id = (control as DevExpress.XtraBars.Ribbon.RibbonControl).Manager.GetNewItemId(); } System.IO.Stream ribbonQuickAccessLayout = new System.IO.MemoryStream(); (control as DevExpress.XtraBars.Ribbon.RibbonControl).Toolbar.SaveLayoutToStream(ribbonQuickAccessLayout); ribbonQuickAccessLayout.Seek(0, System.IO.SeekOrigin.Begin); System.Xml.XmlDocument ribbonQuickAccessXmlDoc = new System.Xml.XmlDocument(); using (System.IO.StreamReader ribbonQuickAccessReader = new System.IO.StreamReader(ribbonQuickAccessLayout)) ribbonQuickAccessXmlDoc.InnerXml = ribbonQuickAccessReader.ReadToEnd(); DB.SYS_Layout sys_layout_quick_access = BL.SYS.SYS_Layout.New; sys_layout_quick_access.Screen = ribbonQuickAccessToolbarName; sys_layout_quick_access.Original = ribbonQuickAccessXmlDoc.InnerXml; sys_layout_quick_access.SystemOriginal = ribbonQuickAccessXmlDoc.InnerXml; sys_layout_quick_access.Custom = ribbonQuickAccessXmlDoc.InnerXml; sys_layout_quick_access.UserId = user; BL.EntityController.SaveSYS_Layout(sys_layout_quick_access, DataContext); } } } else { sys_layout.Custom = XmlDoc.InnerXml; foreach (var control in OwnerControl.Control.Controls) { if (control is DevExpress.XtraGrid.GridControl) { foreach (DevExpress.XtraGrid.Views.Grid.GridView view in (control as DevExpress.XtraGrid.GridControl).Views) { System.IO.Stream gridViewLayout = new System.IO.MemoryStream(); view.SaveLayoutToStream(gridViewLayout);//, DevExpress.Utils.OptionsLayoutBase.FullLayout); gridViewLayout.Seek(0, System.IO.SeekOrigin.Begin); System.Xml.XmlDocument gridViewXmlDoc = new System.Xml.XmlDocument(); using (System.IO.StreamReader gridViewReader = new System.IO.StreamReader(gridViewLayout)) gridViewXmlDoc.InnerXml = gridViewReader.ReadToEnd(); string gridName = ScreenName + "+" + view.Name; DB.SYS_Layout sys_layout_grid = DataContext.EntitySystemContext.SYS_Layout.FirstOrDefault(n => n.Screen == gridName && n.UserId == user); sys_layout_grid.Custom = gridViewXmlDoc.InnerXml; BL.EntityController.SaveSYS_Layout(sys_layout_grid, DataContext); } } } //Ribbon Layout string ribbonQuickAccessToolbarName = ScreenName + "+" + "QuickAccessToolbar"; foreach (var control in OwnerControl.Parent.Controls) { if (control is DevExpress.XtraBars.Ribbon.RibbonControl) { System.IO.Stream ribbonQuickAccessLayout = new System.IO.MemoryStream(); (control as DevExpress.XtraBars.Ribbon.RibbonControl).Toolbar.SaveLayoutToStream(ribbonQuickAccessLayout); ribbonQuickAccessLayout.Seek(0, System.IO.SeekOrigin.Begin); System.Xml.XmlDocument ribbonQuickAccessXmlDoc = new System.Xml.XmlDocument(); using (System.IO.StreamReader ribbonQuickAccessReader = new System.IO.StreamReader(ribbonQuickAccessLayout)) ribbonQuickAccessXmlDoc.InnerXml = ribbonQuickAccessReader.ReadToEnd(); DB.SYS_Layout sys_layout_quick_access = DataContext.EntitySystemContext.SYS_Layout.FirstOrDefault(n => n.Screen == ribbonQuickAccessToolbarName && n.UserId == user); sys_layout_quick_access.Custom = ribbonQuickAccessXmlDoc.InnerXml; BL.EntityController.SaveSYS_Layout(sys_layout_quick_access, DataContext); } } } sys_layout.UserId = user; BL.EntityController.SaveSYS_Layout(sys_layout, DataContext); } DataContext.SaveChangesEntitySystemContext(); DataContext.CompleteTransaction(transaction); } DataContext.EntitySystemContext.AcceptAllChanges(); } catch (Exception ex) { DataContext.EntitySystemContext.RejectChanges(); if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex)) { throw ex; } } OwnerControl.CustomizationForm.Close(); } catch (Exception ex) { //dataContext.EntitySystemContext.RollBackTransaction(); if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex)) { throw ex; } } }