// Enable/disale controls (safe for threading) void EnableControls(bool enable) { GUI.MethodInvoker m = delegate() { loadButton1.Enabled = enable; loadButton2.Enabled = enable; loadButton3.Enabled = enable; loadButton4.Enabled = enable; loadButton5.Enabled = enable; algorithmCombo.Enabled = enable; explorationRateBox.Enabled = enable; learningRateBox.Enabled = enable; iterationsBox.Enabled = enable; moveRewardBox.Enabled = enable; wallRewardBox.Enabled = enable; goalRewardBox.Enabled = enable; startLearningButton.Enabled = enable; showSolutionButton.Enabled = enable; stopButton.Enabled = !enable; }; Invoke(m); }
// loader end loading tiles void MainMap_OnTileLoadComplete(long ElapsedMilliseconds) { #if DEBUG && !UNITY_5 MainMap.ElapsedMilliseconds = ElapsedMilliseconds; #endif GUI.MethodInvoker m = delegate() { //TEMP panelMenu.Text = "Menu, last load in " + MainMap.ElapsedMilliseconds + "ms"; textBoxMemory.Text = string.Format(CultureInfo.InvariantCulture, "{0:0.00} MB of {1:0.00} MB", MainMap.Manager.MemoryCache.Size, MainMap.Manager.MemoryCache.Capacity); #if UNITY_WEBPLAYER || UNITY_5 MainMap.Refresh(); #endif }; try { BeginInvoke(m); } catch { } }
// Thread safe updating of control's text property void SetText(Alt.GUI.Temporary.Gwen.Control.TextBox control, string text) { GUI.MethodInvoker m = delegate() { control.Text = text; }; Invoke(m); }
void OnTileCacheProgress(int left) { if (!IsDisposed) { GUI.MethodInvoker m = delegate { textBoxCacheStatus.Text = left + " tile to save..."; }; Invoke(m); } }
void OnTileCacheStart() { Debug.WriteLine("OnTileCacheStart"); if (!IsDisposed) { GUI.MethodInvoker m = delegate { textBoxCacheStatus.Text = "saving tiles..."; }; Invoke(m); } }
/// <summary> /// Handle html renderer invalidate and re-layout as requested. /// </summary> void OnRefresh(object sender, HtmlRefreshEventArgs e) { GUI.MethodInvoker m = delegate() { m_NeedRepaint = true; }; try { Invoke(m); } catch { } }
// loader start loading tiles void MainMap_OnTileLoadStart() { GUI.MethodInvoker m = delegate() { //TEMP panelMenu.Text = "Menu: loading tiles..."; }; try { BeginInvoke(m); } catch { } }
// Enable/disale controls (safe for threading) void EnableControls(bool enable) { GUI.MethodInvoker m = delegate() { iterationsBox.Enabled = enable; rateBox.Enabled = enable; radiusBox.Enabled = enable; startButton.Enabled = enable; randomizeButton.Enabled = enable; stopButton.Enabled = !enable; }; Invoke(m); }
// Enable/disale controls (safe for threading) void EnableControls(bool enable) { GUI.MethodInvoker m = delegate() { citiesCountBox.Enabled = enable; populationSizeBox.Enabled = enable; iterationsBox.Enabled = enable; selectionBox.Enabled = enable; generateMapButton.Enabled = enable; startButton.Enabled = enable; stopButton.Enabled = !enable; }; Invoke(m); }
// Thread main cycle void MoveCycle() { try { while (Thread.CurrentThread.IsAlive) { GUI.MethodInvoker mi = new GUI.MethodInvoker(AGVStep); this.BeginInvoke(mi); Thread.Sleep(Convert.ToInt32(txtInterval.Value)); } } catch #if !SILVERLIGHT && !UNITY_WEBPLAYER (System.Threading.ThreadInterruptedException) #endif { } }
// -- map events -- void OnTileCacheComplete() { Debug.WriteLine("OnTileCacheComplete"); long size = 0; int db = 0; try { DirectoryInfo di = new DirectoryInfo(MainMap.CacheLocation); var dbs = di.GetFiles("*.gmdb", SearchOption.AllDirectories); foreach (var d in dbs) { size += d.Length; db++; } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } if (!IsDisposed) { GUI.MethodInvoker m = delegate { textBoxCacheSize.Text = string.Format(CultureInfo.InvariantCulture, "{0} db in {1:00} MB", db, size / (1024.0 * 1024.0)); textBoxCacheStatus.Text = "all tiles saved!"; }; if (!IsDisposed) { try { Invoke(m); } catch (Exception) { } } } }