/// <summary> /// This will load the scene root. /// </summary> /// <returns>Coroutine process.</returns> public IEnumerator LoadSceneRoot() { // Close panel flag is reset. this.panelVisibility = true; if (rootGameObjects == null || rootGameObjects.Length == 0) { // Asynchronously load next scene. AsyncOperation ao = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive); while (!ao.isDone) { yield return(null); } // Get the loaded scene. Scene target = SceneManager.GetSceneByName(sceneName); rootGameObjects = target.GetRootGameObjects(); // Yield break if still no root objects. if (rootGameObjects == null || rootGameObjects.Length == 0) { yield break; } } // Get the ModalController from the single root game object. (If hierarchy is correctly followed). rootGameObjects[0].SetActive(true); ModalController mc = rootGameObjects[0].GetComponent <ModalController>(); mc.SetVisibility(true); yield return(WatchSceneRoot(mc)); }
/// <summary> /// Watch the scene root until it is closed. /// </summary> /// <returns>Coroutine process.</returns> public IEnumerator WatchSceneRoot(ModalController mc) { // This will wait until the panel visiblity is false. yield return(new WaitUntil(() => !mc.GetVisibility())); this.panelVisibility = mc.GetVisibility(); }
/// <summary> /// Converts the (A,B) coordinates to (X,Y,Z) coordinates. /// </summary> public Location fromABToXYZ(int a, int b, ModalController controller) { int t = 2 * b - 16; int x = (a - t) >> 5; int y = (a + t) >> 5; x += (world.size.y - 1) / 2; // (x,y,0) is the base location. disambiguate the location. // TODO: use height-cut here to force the specified z-level if (controller != null) { LocationDisambiguator disambiguator = controller.disambiguator; for (int z = heightCutHeight; z >= 0; z--) { Location loc = new Location(x - z, y + z, z); if (disambiguator.isSelectable(loc)) { return(loc); } } } return(new Location(x, y, 0)); }
/// <summary> /// Update the surface by redrawing necessary parts. /// </summary> private void updateScreen() { if (dirtyRect.isEmpty || offscreenBuffer == null) { return; // no need for draw. } DateTime start = DateTime.Now; MapOverlay overlay = null; ModalController controller = MainWindow.mainWindow.currentController; if (controller != null) { overlay = controller.overlay; } if (overlay != null) { overlay.drawBefore(this, drawContext); } // draw the rect Rectangle dr = dirtyRect.rect; if (dr.Top < 0) { dr.Y = 0; // clipping. higher voxel on the northen edge could make top<0 } draw(dr, overlay); dirtyRect.clear(); // allow MapOverlay to do the wrap-up if (overlay != null) { overlay.drawAfter(this, drawContext); } if (Core.options.drawStationNames) { // REVISIT: I don't want these code inside this method. // it needs to be extensible. Graphics graphics = drawContext.graphics; foreach (freetrain.world.rail.Station st in world.stations) { Point pt = fromXYZToClient(st.baseLocation); pt.Y -= 16; // display the string above the station SizeF sz = graphics.MeasureString(st.name, drawFont); pt.X -= (int)sz.Width / 2; graphics.DrawString(st.name, drawFont, drawBrush1, pt.X + 1, pt.Y + 1); graphics.DrawString(st.name, drawFont, drawBrush2, pt.X, pt.Y); } } drawContext.tag = null; // reset the attached tag Debug.WriteLine("update took " + (DateTime.Now - start).TotalMilliseconds + "ms"); }
public ConsultaPC(ModalController modalcontrol) { modalcontroller = modalcontrol; InitializeComponent(); dataSet.MultiSelect = false; //No se permite seleccionar muchas celdas seleccionarTipo.SelectedIndex = 0; //Empieza el combobox en el indice 0 }
protected override void OnMouseUp(MouseEventArgs arg) { ModalController controller = MainWindow.mainWindow.currentController; if (dragMode) { bool r = scrollByDrag(arg); // end the drag mode dragMode = false; this.Capture = false; this.Cursor = null; if (r) { return; // if the scroll-by-drag was successful, don't process the click event } } if (controller != null) { Point ab = drawer.fromClientToAB(arg.X, arg.Y); Location xyz = drawer.fromABToXYZ(ab, controller); if (arg.Button == MouseButtons.Left) { controller.onClick(this, xyz, ab); } if (arg.Button == MouseButtons.Right) { controller.onRightClick(this, xyz, ab); } } else { if (arg.Button == MouseButtons.Left) { // dispatch this click event to the appropriate voxel. Location loc = drawer.fromClientToXYZ(arg, null); { // print debug information Debug.WriteLine("mouse clicked on MapViewWindow. (x,y,z)=" + loc); int h, v; World.world.toHV(loc.x, loc.y, out h, out v); Debug.WriteLine(string.Format(" (h,v)=({0},{1})", h, v)); } // look for voxels that can process this event for (int z = drawer.heightCutHeight; z >= 0; z--) { Voxel v = World.world[loc.x - z, loc.y + z, z]; if (v != null && v.onClick()) { return; } } } } }
protected override void OnMouseDown(MouseEventArgs arg) { ModalController controller = MainWindow.mainWindow.currentController; // start the drag mode dragMode = true; dragStartMousePos = getPoint(arg); dragStartScrollPos = this.AutoScrollPosition; dragAccel = (Keyboard.isControlKeyPressed?2:1) * (Keyboard.isShiftKeyPressed?2:1); this.Capture = true; }
void Awake() { if (instance == null) { DontDestroyOnLoad(this); instance = this; } else if (instance != this) { Destroy(this); } }
public MainWindowViewModel() { ModalController = new ModalController(); _repo = PackageRepositoryFactory.Default.CreateRepository("https://www.nuget.org/api/v2/"); _random = new Random(); Page = 0; PageSize = 25; HasError = false; Load = ReactiveCommand.CreateAsyncObservable(_ => SearchImpl(Page, PageSize), RxApp.TaskpoolScheduler); Load.ThrownExceptions.Subscribe(HandleSearchError); Load.IsExecuting.ObserveOn(RxApp.MainThreadScheduler).ToPropertyEx(this, x => x.IsBusy); Load.ToReadOnlyList(GetPackageCardViewModel) .ObserveOn(RxApp.MainThreadScheduler) .ToPropertyEx(this, x => x.Packages, new List <PackageCardViewModel>().AsReadOnly()); var canNext = this.WhenAny(x => x.IsBusy, busy => !busy.Value); Next = ReactiveCommand.CreateAsyncObservable(canNext, _ => { Page = Page + 1; return(Load.ExecuteAsync()); }); Next.ThrownExceptions.Subscribe(ex => this.Log().Error($"Error occurred: {ex.ToString()}")); var canPrevious = this.WhenAny(x => x.IsBusy, x => x.Page, (busy, page) => !busy.Value && page.Value > 0); Previous = ReactiveCommand.CreateAsyncObservable(canPrevious, _ => { Page = Page - 1; return(Load.ExecuteAsync()); }); Previous.ThrownExceptions.Subscribe(ex => this.Log().Error($"Error occurred: {ex.ToString()}")); ShowDialog = ReactiveCommand.Create(); ShowDialog.Subscribe(_ => ModalController.ShowModal(new FirstModalViewModel())); this.WhenActivated(d => { d(Load.ExecuteAsync().Subscribe()); }); }
protected override void OnMouseMove(MouseEventArgs arg) { ModalController controller = MainWindow.mainWindow.currentController; if (dragMode) { scrollByDrag(arg); } else { if (controller != null) { Point ab = drawer.fromClientToAB(arg.X, arg.Y); controller.onMouseMove(this, drawer.fromABToXYZ(ab, controller), ab); } } }
public Location fromClientToXYZ(int cx, int cy, ModalController controller) { return(fromABToXYZ(fromClientToAB(cx, cy), controller)); }
/// <summary> /// Converts the mouse coordinate (which is client coordinate) /// to (X,Y) coordinates. /// </summary> public Location fromClientToXYZ(MouseEventArgs mea, ModalController controller) { return(fromABToXYZ(fromClientToAB(mea.X, mea.Y), controller)); }
public Location fromABToXYZ(Point pt, ModalController controller) { return(fromABToXYZ(pt.X, pt.Y, controller)); }