public static void setCorrectZIndex(Canvas currentCanvas, UIEntity currentEntity) { if (currentEntity is ConnectionLine) { currentEntity.SetValue(Canvas.ZIndexProperty, 0); } else if (currentCanvas.Children.Count > 1) { var maxZ = currentCanvas.Children.OfType <UIElement>() .Where(x => x != currentEntity) .Select(x => Panel.GetZIndex(x)) .Max(); maxZ = maxZ == 0 ? 1 : maxZ; foreach (Port port in currentEntity.getPorts()) { port.SetValue(Canvas.ZIndexProperty, maxZ + 2); } if (currentEntity.Label != null) { currentEntity.Label.SetValue(Canvas.ZIndexProperty, maxZ + 1); } currentEntity.SetValue(Canvas.ZIndexProperty, maxZ); } }
public void drawOnCanvas(Point position) { attachMovingEvents(currentEntity); Canvas.SetLeft(currentEntity, position.X + X_OFFSET); Canvas.SetTop(currentEntity, position.Y + Y_OFFSET); currentCanvas.Children.Add(currentEntity); currentEntity.createAndDraw(position.X + X_OFFSET, position.Y + Y_OFFSET); ZIndexUtil.setCorrectZIndex(currentCanvas, currentEntity); foreach (Port p in currentEntity.getPorts()) { p.MouseLeftButtonDown += Shape_MouseLeftButtonDown; p.MouseLeftButtonUp += Shape_MouseLeftButtonUp; } if (!(currentEntity is SubDiagram)) { currentEntity = Activator.CreateInstance(currentEntity.GetType(), currentCanvas) as UIEntity; } else { currentEntity = Activator.CreateInstance(currentEntity.GetType(), currentCanvas, (currentEntity as SubDiagram).ProjectItem) as UIEntity; } ModelChanged(); }
private List <UIEntity> mUIHideStack = new List <UIEntity>(); //Hide public void Register(UIEntity entity) { if (mUIStack.Contains(entity)) { this.Top(entity); return; } int cur_layer = mUIStack.Count * layerCount_per + layerCount_per; //全屏UI处理 if (entity.UIPage.FullScreenUI) { //最上层的UI是全屏UI,把下层的全屏UI都隐藏掉 foreach (var ui in mUIStack) { if (ui.UIPage.FullScreenUI) { if (!mUIHideStack.Contains(ui)) { mUIHideStack.Add(ui); } //隐藏 ui.UICanvas.enabled = false; ui.HideMaskIfExist(); } } } mUIStack.Add(entity); entity.SortingOrder = cur_layer; }
public List <UIEntity> transform(List <Identifable> elements) { List <UIEntity> uiEntities = new List <UIEntity>(elements.Count); foreach (Identifable e in elements) { if (e is Entity) { Entity ent = e as Entity; if (map.ContainsValue(ent)) { UIEntity uie = map.FirstOrDefault(x => x.Value.Equals(ent)).Key; if (uie != null) { uiEntities.Add(uie); } } } else if (e is Entities.Resource) { Entities.Resource res = e as Entities.Resource; if (resources.Contains(res)) { UIEntity uie = resMap.FirstOrDefault(x => x.Value.Equals(res)).Key; if (uie != null) { uiEntities.Add(uie); } } } } return(uiEntities); }
/// <summary> /// 初始化 /// </summary> public override void OnInit() { base.OnInit(); UIEntity.FindChildren("LogoutButton").rectTransform().AddEventListener(OnLogout); UIEntity.FindChildren("BackButton").rectTransform().AddEventListener(OnBack); }
public void Show() { var dt = UIEntity.GetComponentInChildren <DataTable>(); dt.Show(); UIShowHideHelper.ShowFromLeft(UIEntity); }
/// <summary> /// 初始化 /// </summary> public override void OnInit() { base.OnInit(); _scrollView_Tanks = UIEntity.GetComponentByChild <ScrollRect>("ScrollView_Tanks"); _panel_TankData = UIEntity.FindChildren("Panel_TankData"); _panel_TankWeapon = UIEntity.FindChildren("Panel_TankWeapon"); _button_Start = UIEntity.GetComponentByChild <Button>("Panel_Start/Button_Start"); _tankItems = _scrollView_Tanks.content.GetComponentsInChildren <Toggle>(); _isChangeChoose = false; for (int i = 0; i < _tankItems.Length; i++) { UITankItem tankItem = _tankItems[i].GetComponent <UITankItem>(); _tankItems[i].interactable = tankItem != null && tankItem.DataSet != null && tankItem.IsActive; _tankItems[i].onValueChanged.AddListener((value) => { _isChangeChoose = true; }); } UIEntity.FindChildren("Button_Back").rectTransform().AddEventListener(() => { Main.m_Procedure.SwitchProcedure <ProcedureLogin>(); }); _button_Start.onClick.AddListener(() => { Main.m_Procedure.GetProcedure <ProcedureGame>().ChooseDataSet = CurrentChoose.DataSet; Main.m_Procedure.SwitchProcedure <ProcedureChooseLevel>(); }); }
public Entities.Entity transform(UIEntity entity) { return(new EntityDestination() { name = entity.EntityName, id = entity.Id }); }
private void OnMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (currentEntity != null && e.LeftButton == MouseButtonState.Pressed) { if (currentEntity is ConnectionLine && selected != null && selected is Port) { connect(); } else if (currentEntity is SubDiagram) { SubDiagram sd = currentEntity as SubDiagram; ScrollableCanvas sc = currentCanvas as ScrollableCanvas; if (sc.Equals(sc, sd.ProjectItem.Canvas as ScrollableCanvas)) { currentEntity = null; MessageBox.Show("Нельзя добавить процесс к самому себе"); } else { UndoRedoManager.putInUndoStack((ScrollableCanvas)currentCanvas); UndoRedoManager.clearRedoStack((ScrollableCanvas)currentCanvas); sd.canvas = currentCanvas; drawOnCanvas(e.GetPosition(this)); } } else if (!(currentEntity is ConnectionLine)) { UndoRedoManager.putInUndoStack((ScrollableCanvas)currentCanvas); UndoRedoManager.clearRedoStack((ScrollableCanvas)currentCanvas); drawOnCanvas(e.GetPosition(this)); } } }
/// <summary> /// 打开UI /// </summary> public override void OnOpen(params object[] args) { base.OnOpen(args); QuantityModel quantity = (QuantityModel)args[0]; UIEntity.GetComponent <UncertaintyInput>().Show(quantity); }
public async Task <bool> ReplaceData(string tenant, string environment, string entity, UIEntity data) { var definition = await GetDefinitionForEntity(tenant, environment, entity).ConfigureAwait(false); var patch = new JsonPatchDocument(); var entityBehaviours = data.EntityBehaviours.Where(a => !string.IsNullOrEmpty(a.Element)).ToList(); if (entityBehaviours.Count() > 0) { var metadata = await GetMetadataForDefinition(tenant, environment, entity, definition).ConfigureAwait(false); patch = PatchAttributesToReplace(patch, metadata, entityBehaviours); } entityBehaviours = data.EntityBehaviours.Except(entityBehaviours).ToList(); if (entityBehaviours.Count > 0) { patch.Replace("/behaviours", entityBehaviours.ToArray()); } var dataAsString = JsonConvert.SerializeObject(patch); var response = await _apiClient.Patch($"/api/v1/{tenant}/{environment}/model/{definition}/{entity}", new StringContent(dataAsString, Encoding.UTF8, "application/json")).ConfigureAwait(false); return(response.Success); }
/// <summary> /// 初始化 /// </summary> public override void OnInit() { base.OnInit(); UIEntity.FindChildren("NewGameButton").GetComponent <Button>().onClick.AddListener(() => { GameManager.Instance.ChooseNewExp(); }); /*UIEntity.FindChildren("ExitButton").GetComponent<Button>().onClick.AddListener(() => * { * Application.Quit(); * });*/ UIEntity.FindChildren("UncertainLearnButton").GetComponent <Button>().onClick.AddListener(() => { GameManager.Instance.StartValidNumber(); }); UIEntity.FindChildren("ContinueButton").GetComponent <Button>().onClick.AddListener(() => { UIAPI.Instance.ShowAndHideLoading(1000); MainThread.Instance.DelayAndRun(500, GameManager.Instance.ContinueExp); }); UIEntity.FindChildren("ImportRecordButton").GetComponent <Button>().onClick.AddListener(() => { SaveOpenRecord.ImportRecord(); }); UIEntity.FindChildren("CommitButton").GetComponent <Button>().onClick.AddListener(() => { UIEntity.FindChildren("CommitButton").GetComponent <LoadImgFromFile>().OnUploadCustomImgBtnClick(); }); }
/// <summary> /// 初始化 /// </summary> public override void OnInit() { base.OnInit(); UIEntity.FindChildren("Role1Button").rectTransform().AddEventListener(OnChooseRole); UIEntity.FindChildren("Role2Button").rectTransform().AddEventListener(OnChooseRole); }
/// <summary> /// 初始化 /// </summary> public override void OnInit() { base.OnInit(); UIEntity.FindChildren("Button_Play").rectTransform().AddEventListener(OnPlay); UIEntity.FindChildren("Button_Quit").rectTransform().AddEventListener(OnQuit); }
private void connect() { UndoRedoManager.putInUndoStack(currentEntity); UndoRedoManager.clearRedoStack(currentEntity); if (firstConnect) { setBinding(ConnectionLine.SourceProperty); firstConnect = false; } else if (canConnect()) { setBinding(ConnectionLine.DestinationProperty); currentEntity.MouseLeftButtonDown += Shape_MouseLeftButtonDown; currentEntity.MouseLeftButtonUp += Shape_MouseLeftButtonUp; ZIndexUtil.setCorrectZIndex(currentCanvas, currentEntity); currentCanvas.Children.Add(currentEntity); currentEntity = Activator.CreateInstance(currentEntity.GetType(), currentCanvas) as UIEntity; firstConnect = true; ModelChanged(); } }
public void Remove(UIEntity entity) { if (!mUIStack.Contains(entity)) { return; } if (entity.UIPage.FullScreenUI) { if (!mUIHideStack.Contains(entity)) { //这是当前显示的一个全屏UI,得把上一个放出来 if (mUIHideStack.Count > 0) { var last = mUIHideStack.Last(); mUIHideStack.Remove(last); last.ShowMaskIfExist(); last.UICanvas.enabled = true; } } } for (var i = mUIStack.Count - 1; i >= 0; i--) { if (mUIStack[i] == entity) { //把在要Remove的entity上面的每个entiy,每个层级挨个缩小一个单位 mUIStack[i].SortingOrder -= layerCount_per; } else { mUIStack.RemoveAt(i); break; } } }
public TitleScreen(MainGame game) : base(game) { var title = new ScreenTitleMain { BindingContext = this }; title.OnNewGame += new OnButtonClickDelegate(() => { Exit(Result.StartGame); }); title.OnSandbox += new OnButtonClickDelegate(() => { Exit(Result.StartSandbox); }); title.OnLoadGame += new OnButtonClickDelegate(() => { Exit(Result.LoadGame); }); title.OnQuitGame += new OnButtonClickDelegate(() => { Exit(Result.Exit); }); GUI = title.AsEntity(); GUI.Size = new Xamarin.Forms.Size(Viewport.Width, Viewport.Height); background = Content.Load <Texture2D>("GUI/title_background"); Cursor = new Cursor(Content); AudioPlayer.PlayBGM("Exhilarate"); }
public static List <ConnectionLine> find(UIElementCollection entities, UIEntity entity) { List <ConnectionLine> result = new List <ConnectionLine>(); foreach (UIEntity e in entities) { if (e is ConnectionLine) { ConnectionLine conenctor = e as ConnectionLine; BindingExpression srcExp = conenctor.GetBindingExpression(ConnectionLine.SourceProperty); BindingExpression dstExp = conenctor.GetBindingExpression(ConnectionLine.DestinationProperty); if (srcExp != null && dstExp != null) { Port src = srcExp.DataItem as Port; Port dst = dstExp.DataItem as Port; //if (entity.Equals(src.Owner) || entity.Equals(dst.Owner)) if (entity.Equals(entity, src.Owner) || entity.Equals(entity, dst.Owner)) { result.Add(conenctor); } } } } return(result); }
void Start() { self = GetComponent <UIEntity>(); self.Hide(); pinchPointOffsetL = pinchPointOffsetR; pinchPointOffsetL.x *= -1; }
/// <summary> /// 初始化 /// </summary> public override void OnInit() { base.OnInit(); UIEntity.FindChildren("TweenObject").FindChildren("BackButton").GetComponent <Button>().onClick.AddListener(() => { NavigateBack(); }); }
public Entities.Entity transform(UIEntity entity) { Source s = entity as Source; return(new EntityStart() { projectsCount = s.ProjectsCount, Complexity = s.Complexity, name = s.EntityName, id = s.Id }); }
public void GetObjectData(SerializationInfo info, StreamingContext context) { for (int i = 0; i < Children.Count; i++) { UIEntity ent = Children[i] as UIEntity; info.AddValue("Child" + i, ent); } info.AddValue("id", id); }
public override void OnOpen(params object[] args) { base.OnOpen(args); if (args.Length == 3) { UIEntity.GetComponent <TipsPanel>().Show(args[0] as string, args[1] as string, (float)args[2]); } }
public Entities.Entity transform(UIEntity entity) { Decision d = entity as Decision; return(new DecisionMaker() { inputProbabilityParams = d.InputProbabilityParams, name = d.EntityName, id = d.Id }); }
/// <summary> /// 添加UI内部点击逻辑 /// </summary> private void AddInnerLogic() { foreach (var item in UIEntity.GetComponentsInChildren <Button>(true)) { if (item.gameObject.name.Equals("ContinueButton")) { ContinueButton = item; item.onClick.AddListener(() => { PauseManager.Instance.Continue(true); }); } /*else if (item.gameObject.name.Equals("QuitButton")) * { * QuitButton = item; * item.onClick.AddListener(() => * { * UIAPI.Instance.ShowModel(new ModelDialogModel() * { * Title = new BindableString("提示"), * Message = new BindableString("您确定要退出吗?"), * ConfirmAction = () => * { * Log.Info("程序已退出"); * Application.Quit(); * } * }); * }); * }*/ else if (item.gameObject.name.Equals("RestartButton")) { RestartButton = item; item.onClick.AddListener(() => { PauseManager.Instance.Continue(true); GameManager.Instance.SwitchBackToStart(); }); } else if (item.gameObject.name.Equals("SaveRecordButton")) { SaveRecordButton = item; item.onClick.AddListener(() => { Main.m_UI.OpenUI <SaveRecordUILogic>(); }); } else if (item.gameObject.name.Equals("ReadRecordButton")) { ReadRecordButton = item; item.onClick.AddListener(() => { Main.m_UI.OpenUI <SettingsLogicTemporary>(); }); } } }
/// <summary> /// 打开UI /// </summary> public override void OnOpen(params object[] args) { base.OnOpen(args); QuantityModel quantity = (QuantityModel)args[0]; UIEntity.GetComponent <MeasuredProcessController>().Show(quantity); //UIEntity.GetComponentInChildren<UncertaintyInput>(true).Show(quantity); //UIEntity.GetComponentInChildren<DealMeasuredDataInput>(true).Show(quantity); }
private void Canvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (selected != null && !captured) { selected.defaultBitmapEffect(); propertiesPanel.Children.Clear(); selected = null; } }
private void attachContextMenu(UIEntity ent) { if (ent.ContextMenu == null && !(ent is Port || ent is ConnectionLine)) { ContextMenu menu = new ContextMenu(); if (ent is SubDiagram) { MenuItem open = new MenuItem() { Header = "Открыть", InputGestureText = "Ctrl + V" }; open.Click += GotoSubprocess_Click; menu.Items.Add(open); menu.Items.Add(new Separator()); } MenuItem copy = new MenuItem() { Header = "Копировать", InputGestureText = "Ctrl + C" }; copy.Click += Copy_Click; menu.Items.Add(copy); MenuItem cut = new MenuItem() { Header = "Вырезать", InputGestureText = "Ctrl + X" }; cut.Click += Cut_Click; menu.Items.Add(cut); MenuItem delete = new MenuItem() { Header = "Удалить", InputGestureText = "Del" }; delete.Click += Delete_Click; menu.Items.Add(delete); if (!(ent is SubDiagram) && ent.ParametersExist) { menu.Items.Add(new Separator()); MenuItem properties = new MenuItem() { Header = "Свойства" }; properties.Click += OpenShapeProperties_Click; menu.Items.Add(properties); } ent.ContextMenu = menu; } }
public Scene() { root = new GameObject(); root.isRoot = true; root.isInScene = true; uiSystem = new UIEntity(); uiSystem.IsRoot = true; root.isInScene = true; }
private void processCoordinatesHandler(UIEntity ent, double x, double y) { UIEntity.CoordinatesHandler ch = selected.getMovingCoordinate(ent); ch.xShape += x - ch.xCanvas; ch.yShape += y - ch.yCanvas; Canvas.SetLeft(ent, ch.xShape); Canvas.SetTop(ent, ch.yShape); ch.xCanvas = x; ch.yCanvas = y; }