protected async Task ShowWindowAsync(IUIView view, object rootModel) { Window? window = null; if (view is Window window1) { window = window1; BeforeLoadingWindow(window); Application!.MainWindow = window; //do work with the titles. if (view is IUISetting ui) { OurContainer!.RegisterSingleton(ui); } window.Show(); } if (rootModel is IScreen screen) await screen.ActivateAsync(view); //i think that after activate will it set the display bindings. that way we have every chance possible of doing the bindings. if (window != null) { if (string.IsNullOrEmpty(window.Title) && rootModel is IHaveDisplayName && !ViewModelBinder.HasBinding(window, Window.TitleProperty)) { //if you don't implement the idisplay, then this will not run. so you have flexibility of what to pass in for view model. //this allows you to use as little or as much as you want for the windows. var binding = new Binding("DisplayName") { Mode = BindingMode.OneWay }; //i like this way better. window.SetBinding(Window.TitleProperty, binding); } //ViewModelBinder.Bind(childViewModel, childui, (DependencyObject)item); GamePackageViewModelBinder.Bind(rootModel, window, (DependencyObject)window.Content); } }
protected virtual void OnEnable() { this.view = this.GetComponent <IUIView>(); switch (this.AnimationType) { case AnimationType.EnterAnimation: this.view.EnterAnimation = this; break; case AnimationType.ExitAnimation: this.view.ExitAnimation = this; break; case AnimationType.ActivationAnimation: if (this.view is IWindowView) { (this.view as IWindowView).ActivationAnimation = this; } break; case AnimationType.PassivationAnimation: if (this.view is IWindowView) { (this.view as IWindowView).PassivationAnimation = this; } break; } }
void OnEnable() { this.view = this.GetComponent <IUIView> (); switch (this.AnimationType) { case AnimationType.EnterAnimation: this.view.EnterAnimation = this; break; case AnimationType.ExitAnimation: this.view.ExitAnimation = this; break; case AnimationType.ActivationAnimation: if (this.view is IWindowView) { (this.view as IWindowView).ActivationAnimation = this; } break; case AnimationType.PassivationAnimation: if (this.view is IWindowView) { (this.view as IWindowView).PassivationAnimation = this; } break; } if (this.AnimationType == AnimationType.ActivationAnimation || this.AnimationType == AnimationType.EnterAnimation) { this.view.CanvasGroup.alpha = from; } }
public virtual void AddView(IUIView view, UILayout layout) { if (view == null) { return; } Transform t = view.Transform; if (t == null) { return; } if (t.parent == this.transform) { if (layout != null) { layout(view.RectTransform); } return; } view.Owner.layer = this.gameObject.layer; t.SetParent(this.transform, false); if (layout != null) { layout(view.RectTransform); } }
IUIView instantiateView(string assetName, IUIView parent = null) { var prefab = Resources.Load <GameObject>(assetName); var gameObject = Object.Instantiate(prefab, parent?.rectTransform); return(gameObject.GetComponent <IUIView>()); }
public static async Task RefreshBindingsAsync(this IUIView view, IEventAggregator aggregator) { if (aggregator.HandlerExistsFor(typeof(IUIView), action: EnumActionCategory.Async) == false) { throw new BasicBlankException("No Event Handler For Refresh The Bindings. Rethink"); } await aggregator.PublishAsync(view); }
public Game(IUIView view) { settings = Resources.Load <GameSettings>("Settings/Game"); ui = view; ui.OnStartGame += OnStartGame; ui.OnUpdate += OnUpdate; }
public void Push(IUIView view) { if (view != null) { mUIStack.Push(view.PanelInfo); CloseUI(view.PanelInfo.PanelName); } }
/// <summary> /// Displays information to the user. /// </summary> /// <param name="viewName">The view name of the dialog box,if it is null, use the default view name</param> /// <param name="contentViewName">The custom content view name to be shown to the user.</param> /// <param name="viewModel">The view model of the dialog box</param> /// <returns>A AlertDialog.</returns> public static AlertDialog ShowMessage(string viewName, string contentViewName, AlertDialogViewModel viewModel) { AlertDialogWindow window = null; IUIView contentView = null; try { ApplicationContext context = Context.GetApplicationContext(); IUIViewLocator locator = context.GetService <IUIViewLocator>(); if (locator == null) { if (log.IsWarnEnabled) { log.Warn("Not found the \"IUIViewLocator\"."); } throw new NotFoundException("Not found the \"IUIViewLocator\"."); } if (string.IsNullOrEmpty(viewName)) { viewName = ViewName; } window = locator.LoadView <AlertDialogWindow>(viewName); if (window == null) { if (log.IsWarnEnabled) { log.WarnFormat("Not found the dialog window named \"{0}\".", viewName); } throw new NotFoundException(string.Format("Not found the dialog window named \"{0}\".", viewName)); } if (!string.IsNullOrEmpty(contentViewName)) { contentView = locator.LoadView <IUIView>(contentViewName); } AlertDialog dialog = new AlertDialog(window, contentView, viewModel); dialog.Show(); return(dialog); } catch (Exception e) { if (window != null) { window.Dismiss(); } if (contentView != null) { GameObject.Destroy(contentView.Owner); } throw e; } }
/// <summary> /// 隐藏UI /// </summary> /// <param name="uiBehaviourName"></param> public void HideUI(string uiBehaviourName) { IUIView iuiView = null; if (mAllUI.TryGetValue(uiBehaviourName, out iuiView)) { iuiView.Hide(); } }
/// <summary> /// 获取UIBehaviour /// </summary> /// <param name="uiBehaviourName"></param> /// <returns></returns> public UIView GetUI(string uiBehaviourName) { IUIView retIuiView = null; if (mAllUI.TryGetValue(uiBehaviourName, out retIuiView)) { return(retIuiView as UIView); } return(null); }
public UIViewport(int x, int y, int width, int height, IUIView view, LegatusGame game) : base(x, y, width, height) { View = view; GraphicsDevice = game.GraphicsDevice; RenderTarget = new RenderTarget2D(game.GraphicsDevice, width, height); game.Disposed += OnGameDisposed; TakesFocusOnMouseAction = true; TakesFocusOnMouseAction = true; }
protected override async Task ActivateAsync(IUIView view) { _data = await _procs.OpenAsync(); MainNickName = _data.MainNickName; SecondaryNickName = _data.SecondaryNickName; ServerMode = _data.ServerMode; HostIPAddress = _data.HostIPAddress; AzureEndPointAddress = _data.AzureEndPointAddress; await base.ActivateAsync(view); }
public void Push(IUIView view, bool animated = true) { if (stack.Count > 0) { var topView = stack.Peek(); topView.Hide(animated); } stack.Push(view); view.Show(animated); }
protected virtual void RemoveView(IUIView view, bool worldPositionStays = false) { if (view == null) return; Transform t = view.Transform; if (t == null || !this.transform.Equals(t.parent)) return; t.SetParent(null, worldPositionStays); }
private void SetCanvasReferences() { mainCanvas = GameObject.FindObjectOfType <UIView>().gameObject; uiView = mainCanvas.GetComponent <UIView>(); mainCanvas.GetComponentInChildren <LobbyController>().SetMultiplayerServiceRef(multiplayerService); mainCanvas.GetComponentInChildren <LobbyController>().SetUIServiceRef(this); mainCanvas.GetComponentInChildren <GameUIController>().SetMultiplayerServiceRef(multiplayerService); mainCanvas.GetComponentInChildren <GameOverUIController>().SetMultiplayerServiceRef(multiplayerService); gameUIController = mainCanvas.GetComponentInChildren <GameUIController>(); gameOverUIController = mainCanvas.GetComponentInChildren <GameOverUIController>(); }
public void Push <T>(bool allowMulti = false, params object[] parameters) where T : UIView { string assetPath = CheckAssetPath(typeof(T)); if (string.IsNullOrEmpty(assetPath)) { return; } int hashCode = typeof(T).GetHashCode(); if (_stackUiAsset.Count > 0) { UiAsset uiAsset = _stackUiAsset.Peek(); //如果界面已经打开 则不在执行 if (uiAsset.AssetPath == assetPath && !allowMulti) { return; } IUIView uiView = GetUiView(uiAsset); //触发暂停事件 _uiPauseArgs.UIView = uiView; _event.Trigger(this, _uiPauseArgs); uiView.OnPause(); } UiAsset newUiAsset = null; if (!allowMulti) { if (!_allUiAssets.TryGetValue(hashCode, out newUiAsset)) { newUiAsset = new UiAsset(assetPath); _allUiAssets[hashCode] = newUiAsset; } } else { newUiAsset = new UiAsset(assetPath); } _stackUiAsset.Push(newUiAsset); UIView newUiView = GetUiView(newUiAsset); newUiView.OnEnter(parameters); //触发打开事件 _uiEnterArgs.UIView = newUiView; _event.Trigger(this, _uiEnterArgs); }
protected virtual void AddView(IUIView view, bool worldPositionStays = false) { if (view == null) return; Transform t = view.Transform; if (t == null || this.transform.Equals(t.parent)) return; view.Owner.layer = this.gameObject.layer; t.SetParent(this.transform, worldPositionStays); t.SetAsFirstSibling(); }
public Harness( string candidate, IRepository repository, ITaskPlanner taskPlanner, IEnumerable <TaskDataset> datasetChoices, IUIView view) { _candidate = candidate; _repository = repository; _taskPlanner = taskPlanner; _datasetChoices = datasetChoices; _view = view; }
Task ILoadScreen.LoadScreenAsync(object parentViewModel, IUIView parentViewScreen, object childViewModel, IUIView childViewScreen) { if (childViewModel is IScreen childScreen && childViewScreen is UserControl childui && parentViewScreen is UIElement parentui) { var item = childui.Content; GamePackageViewModelBinder.Bind(childViewModel, childui, (DependencyObject)item); GamePackageViewModelBinder.HookParentContainers(parentViewModel, parentui, childScreen, childViewScreen); } return Task.CompletedTask; }
/// <summary> /// 关闭并卸载UI /// </summary> /// <param name="behaviourName"></param> public void CloseUI(string behaviourName) { IUIView behaviour = null; mAllUI.TryGetValue(behaviourName, out behaviour); if (null != behaviour) { OnPanelClose.InvokeGracefully(behaviour.PanelInfo); behaviour.Close(); mAllUI.Remove(behaviourName); } }
/// <summary> /// 处理当子表删除时,孙表没有删除的bug /// </summary> private void ProcessWhenChildRecDel(IUIView view) { for (int i = view.RecordCount - 1; i >= 0; i--) { if (view[i].DataRecordState != DataRowState.Added) { continue; } if (view[i].GetParentRecord() == null) { view.Records.Remove(view[i]); } } }
void InitDailyTaskView <T>(T[] resources) { m_DailyTaskUIPanel = AssetCacheMgr.SynGetInstance("DailyTaskUI.prefab") as GameObject; m_MogoMainUIPanel = GameObject.FindGameObjectWithTag("NormalMainUI"); m_DailyTaskUIPanel.transform.parent = GameObject.FindGameObjectWithTag("MogoMainUIPanel").transform; m_DailyTaskUIPanel.transform.localScale = new Vector3(1, 1, 1); m_DailyTaskUIPanel.transform.localPosition = new Vector3(0, 0, 0); GameObject.FindGameObjectWithTag("DailyTaskContainerCamera").GetComponent <UIViewport>().sourceCamera = GameObject.Find("MogoMainUI/Camera").GetComponent <Camera>(); m_DailyTaskFXRoot = GameObject.FindGameObjectWithTag("DailyTaskFXRoot").AddComponent <DailyTaskFXRoot>(); GameObject.FindGameObjectWithTag("DailyTaskFXCamera").GetComponent <UIViewport>().sourceCamera = GameObject.Find("MogoMainUI/Camera").GetComponent <Camera>(); GameObject.FindGameObjectWithTag("DailyTaskPanelCloseButton").AddComponent <DailyTaskCloseButton>(); m_DailyTaskView = GameObject.FindGameObjectWithTag("DailyTaskLists").AddComponent <DailyTaskView>(); AllPanelIsReady(); }
/// <summary> /// Displays information to the user. /// </summary> /// <param name="contentView">The custom view to be shown to the user.</param> /// <param name="title">The title of the dialog box. This may be null.</param> /// <param name="confirmButtonText">The text shown in the "confirm" button /// in the dialog box. If left null, the button will be invisible.</param> /// <param name="neutralButtonText">The text shown in the "neutral" button /// in the dialog box. If left null, the button will be invisible.</param> /// <param name="cancelButtonText">The text shown in the "cancel" button /// in the dialog box. If left null, the button will be invisible.</param> /// <param name="canceledOnTouchOutside">Whether the dialog box is canceled when /// touched outside the window's bounds. </param> /// <param name="afterHideCallback">A callback that should be executed after /// the dialog box is closed by the user. The callback method will get a boolean /// parameter indicating if the "confirm" button (true) or the "cancel" button /// (false) was pressed by the user.</param> /// <returns>A AlertDialog.</returns> public static AlertDialog ShowMessage( IUIView contentView, string title, string confirmButtonText, string neutralButtonText, string cancelButtonText, bool canceledOnTouchOutside, Action <int> afterHideCallback) { AlertDialogViewModel viewModel = new AlertDialogViewModel(); viewModel.ContentView = contentView; viewModel.Title = title; viewModel.ConfirmButtonText = confirmButtonText; viewModel.NeutralButtonText = neutralButtonText; viewModel.CancelButtonText = cancelButtonText; viewModel.CanceledOnTouchOutside = canceledOnTouchOutside; viewModel.Click = afterHideCallback; viewModel.Closed = false; ApplicationContext context = Context.GetApplicationContext(); IUIViewLocator locator = context.GetService <IUIViewLocator>(); if (locator == null) { if (log.IsWarnEnabled) { log.Warn("Not found the \"IUIViewLocator\"."); } throw new NotFoundException("Not found the \"IUIViewLocator\"."); } AlertDialogWindow window = locator.LoadView <AlertDialogWindow>(ViewName); if (window == null) { if (log.IsWarnEnabled) { log.WarnFormat("Not found the \"{0}\".", typeof(AlertDialogWindow).Name); } throw new NotFoundException("Not found the \"AlertDialogWindow\"."); } AlertDialog dialog = new AlertDialog(window, viewModel); dialog.Show(); return(dialog); }
async Task IHandleAsync<IUIView>.HandleAsync(IUIView message) { await Task.CompletedTask; //await Task.Delay(50); if (!(message is UserControl control)) { return; } //GamePackageViewModelBinder.StepThrough = false; //if (!(message )) //childViewScreen is UserControl childui //var item = (DependencyObject) control.Content; //VisualTreeHelper.GetChildrenCount(depObj) //var count = VisualTreeHelper.GetChildrenCount(item); //well see how iffy this is. DependencyObject nextItem; if (control.Content is ContentControl content) { nextItem = (DependencyObject)content.Content; } else if (control.Content is Grid grid) { //int count = VisualTreeHelper.GetChildrenCount(grid); //var xx = control.FindName("ChangeFlag"); //GamePackageViewModelBinder.StepThrough = true; nextItem = grid; //VisualTreeHelper.GetChildrenCount(depObj); i++) //throw new NotImplementedException(); } else { nextItem = (DependencyObject)control.Content; } //ContentControl content = (ContentControl)control.Content; //var //count = VisualTreeHelper.GetChildrenCount(nextItem); //needs more complex when its rebinding. GamePackageViewModelBinder.Bind(message.DataContext, control, nextItem); //this can rescan the bindings. hopefully no problem. GamePackageViewModelBinder.ManuelElements.Clear(); //hopefully won't hurt anything if i clear out. }
IUIView getViewFromObjectPool(string assetName, IUIView parent = null) { var e = _contexts.ui.GetEntityWithUiObjectPool(assetName); if (e == null) { e = _contexts.ui.CreateEntity(); e.AddUiObjectPool(assetName, new ObjectPool <IUIView>(() => instantiateView(assetName, parent))); } var view = e.uiObjectPool.value.Get(); view.rectTransform.SetParent(parent?.rectTransform); return(view); }
Task ILoadScreen.LoadScreenAsync(object parentViewModel, IUIView parentViewScreen, object childViewModel, IUIView childViewScreen) { //if (GamePackageViewModelBinder.StopRun) //{ // return Task.CompletedTask; //} if (childViewModel is IScreen childScreen && childViewScreen is ContentView childui && parentViewScreen is VisualElement parentui) { var item = childui.Content; GamePackageViewModelBinder.Bind(childViewModel, childui, item); GamePackageViewModelBinder.HookParentContainers(parentViewModel, parentui, childScreen, childViewScreen); } return(Task.CompletedTask); }
public virtual void RemoveView(IUIView view, bool worldPositionStays = false) { if (view == null) { return; } Transform t = view.Transform; if (t == null || t.parent != this.transform) { return; } t.SetParent(null, worldPositionStays); }
/// <summary> /// 推一个UI界面到栈顶,并打开 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="allowMulti"></param> /// <param name="parameters"></param> public void Push <T>(bool allowMulti = false, params object[] parameters) where T : UIView { UIInstance config = GetUIInstance(typeof(T)); if (config == null) { return; } //先将栈顶的UI界面置为暂停状态 if (_stackUIAsset.Count > 0) { UIInstance lastConfig = _stackUIAsset.Peek(); //若该UI已经打开,且不允许加载多个,则返回 if (Equals(lastConfig, config) && !allowMulti) { return; } IUIView uIView = GetUIView(lastConfig); UIEventArgs pauseArgs = new UIEventArgs(); pauseArgs.UIView = uIView; _event.CallEvent(this, EventType.UIPause, pauseArgs); uIView.OnPause(); } //UIInstance newConfig = null; //newConfig = config; //if (allowMulti) // newConfig = new UIInstance(config.AssetBundleName, config.AssetPath); //else // newConfig = config; _stackUIAsset.Push(config); UIView newUIView = GetUIView(config); newUIView.OnEnter(parameters); //触发打开事件 UIEventArgs newargs = new UIEventArgs(); newargs.UIView = newUIView; _event.CallEvent(this, EventType.UIEnter, newargs); }
public async void Push <T>(bool allowMulti = false, params object[] parameters) where T : UIView { AssetConfig assetConfig = CheckAssetPath(typeof(T)); if (assetConfig == null) { return; } if (_stackUiAsset.Count > 0) { AssetConfig lastAssetConfig = _stackUiAsset.Peek(); //如果界面已经打开 则不在执行 if (Equals(lastAssetConfig, assetConfig) && !allowMulti) { return; } IUIView uiView = await GetUiView(lastAssetConfig); //触发暂停事件 _uiPauseArgs.UIView = uiView; _event.Trigger(this, _uiPauseArgs); uiView.OnPause(); } AssetConfig newAssetConfig = null; if (allowMulti) { newAssetConfig = new AssetConfig(assetConfig.AssetBundleName, assetConfig.AssetPath); } else { newAssetConfig = assetConfig; } _stackUiAsset.Push(newAssetConfig); UIView newUiView = await GetUiView(newAssetConfig); newUiView.OnShow(parameters); //触发打开事件 _uiShowArgs.UIView = newUiView; _event.Trigger(this, _uiShowArgs); }
public static RectangleF GetFrame(IUIView parent, IUIView child) { var childFrame = new RectangleF(0,0,0,0); return childFrame; }