/// <summary> /// 在新线程中运行函数 /// </summary> /// <param name="func">传入 函数名(无参、无返回值)</param> /// <param name="IsBackground">是否为后台线程(后台线程,窗口关闭后就终止线程)</param> public static void ThreadNew(VoidFunction func, bool IsBackground) { Thread th1 = new Thread(new ThreadStart(func)); th1.IsBackground = IsBackground;//后台线程,窗口关闭后就终止线程 th1.Start(); }
public void ShouldRun(VoidFunction f, ContinuousSnake snake) // true if game is running and is used to make descisions whether or not to run something related to game play { if (snake != null && (snake.Alive && runTimer.Enabled)) // run only if gameplay is should happen { f(); } }
/// <summary> /// Sets the status label content in a thread safe way /// </summary> /// <param name="pos">Status label position</param> /// <param name="str">Status label content</param> private void SetStatus(int pos, string str) { if (statusLabel1.CheckAccess()) { switch (pos) { case 1: statusLabel1.Text = str; break; case 2: statusLabel2.Text = str; break; case 3: statusLabel3.Text = str; break; } } else { VoidFunction <int, string> d = new VoidFunction <int, string>(SetStatus); //statusLabel1.Dispatcher.Invoke(d, DispatcherPriority.Normal, new object[] { pos, str }); statusLabel1.Dispatcher.Invoke(DispatcherPriority.Normal, d, (object)pos, (object)str); } }
public static IEnumerator setTimeoutHelper(VoidFunction action, float seconds) { yield return(new WaitForSecondsRealtime(seconds)); action(); yield return(null); }
public void run(LocalMap aMap, VoidFunction aCallback) { mJackedAi = new Dictionary <string, MapCharacter.MapCharaJackedAi>(); //AI Jack //jackできるか確認 foreach (string tName in mEvent.get <List <String> >("jack")) { if (!aMap.getCharacter(tName).canJackAi())//jack不可(イベント発火中止) { aCallback(); return; } } //jackする foreach (string tName in mEvent.get <List <String> >("jack")) { mJackedAi[tName] = aMap.getCharacter(tName).jackAi(); } //イベント発火 runEventList(() => { //jackしたAIを解放 foreach (KeyValuePair <string, MapCharacter.MapCharaJackedAi> tAi in mJackedAi) { tAi.Value.endJack(); } mJackedAi = new Dictionary <string, MapCharacter.MapCharaJackedAi>(); //会話ウィンドウを閉じる ConversationWindow.close(() => { aCallback(); }); }); }
public static void Start(VoidFunction Enable, VoidFunction Disable, VoidFunction EStop) { enable = Enable; disable = Disable; estop = EStop; hook = SetHook(llkpr); }
public void set_search_func(VoidFunction sf) { search_func = sf; foreach (Category cat in categories) cat.search_func = search_func; }
public InputHandler() { OnButtonClick = new VoidFunction(Kastul); OnButtonPush = new VoidFunction(Kastul); AfterButtonClick = new VoidFunction(Kastul); _isClicked = false; }
public SearchPopup(VoidFunction<CalendarDriver.View, DateTime> set_view) { popup = null; elements = null; set_view_callback = set_view; name = "search_popup"; offset = 0; sizes_of_last_pages = new Stack<int>(); }
private void InitializeWarp() { string mapTo = Name.Split('-')[1] + ".map"; string entryPoint = "from" + Globals.Players[0].Map.MobmapToString().Split('.')[0]; Func = delegate () { LevelMap map = (LevelMap)ScreenManager.CurrentScreen; map.ChangeMap(mapTo, entryPoint); }; }
private void InitializeWarp() { string mapTo = Name.Split('-')[1] + ".map"; string entryPoint = "from" + Globals.Players[0].Map.MobmapToString().Split('.')[0]; Func = delegate() { LevelMap map = (LevelMap)ScreenManager.CurrentScreen; map.ChangeMap(mapTo, entryPoint); }; }
public void ExecuteWithInvoke(Form form, VoidFunction function) { if (form.InvokeRequired) { form.Invoke(new MethodInvoker(function)); } else { function(); } }
/// <summary> /// Sets the DataView of a DataGrid in a thread safe way /// </summary> /// <param name="view">The DataView to set</param> private void SetGridView(DataView view) { if (dataGrid1.CheckAccess()) { dataGrid1.ItemsSource = view; } else { VoidFunction <DataView> d = new VoidFunction <DataView>(SetGridView); dataGrid1.Dispatcher.Invoke(DispatcherPriority.Normal, d, (object)view); } }
/// <summary> /// Enable/disable buttons in a thead safe way /// </summary> /// <param name="enabled">The value indication whether the buttons are enabled</param> private void SetBtnEnabled(bool enabled) { if (ExecuteSqlButton.CheckAccess()) { ExecuteSqlButton.IsEnabled = enabled; SelectDbButton.IsEnabled = enabled; } else { VoidFunction <bool> d = new VoidFunction <bool>(SetBtnEnabled); ExecuteSqlButton.Dispatcher.Invoke(DispatcherPriority.Normal, d, (object)enabled); } }
public TextBox(Window owner) : base(owner) { zTypinRoutineRunning = false; zAutoScale = false; input = string.Empty; carret = (char)300; MaxLength = uint.MaxValue; OnEnter = delegate() { }; OnClick = StartTyping; zText.RelativePosition.X = 0.5f; zText.RelativePosition.Y = -zSprite.ScaleY; Globals.EventManager.AddEvent(AutoScalling, "autoscalling"); zOriginalScalex = Size.X; }
private static void RepeatTillTimeout(VoidFunction voidFunction, TimeSpan timeout, IBackoffPolicy backoffPolicy) { var stopwatch = Stopwatch.StartNew(); while (stopwatch.Elapsed < timeout) { try { voidFunction(); } catch (Exception e) { Trace.WriteLine(e); } backoffPolicy.Wait(); } }
protected bool Collect; //used to signal running events that this window has been destroyed public Window(Window owner = null, bool modal = false, string sprite = "") { if (owner != null && modal) { throw new ArgumentException("Child cannot be modal"); } Collect = false; Immovable = false; zEventEscape = null; zModal = modal; Name = string.Empty; zOrigin = new Vector2(0, 0); if (sprite == "") { zSprite = SpriteManager.AddSprite(Path.Make(Path.Misc, "pixel.bmp")); } else { zSprite = SpriteManager.AddSprite(sprite); } zSprite.ColorOperation = ColorOperation.ColorTextureAlpha; Color = Color.White; zVisible = true; OnClick = delegate() { }; Hover = delegate() { }; HoverMousedown = delegate() { }; MouseLeave = delegate() { }; MouseEnter = delegate() { }; zParent = owner; zChildren = new List <Window>(); zText = TextManager.AddText(string.Empty, Globals.Font); zText.ColorOperation = ColorOperation.ColorTextureAlpha; zText.AttachTo(zSprite, false); Size = new Vector2(1, 1); if (owner == null) { InitializeAsTopLevel(); } else { InitializeAsChild(); } SpriteManager.AddToLayer(zSprite, zLayer); TextManager.AddToLayer(zText, zLayer); zSprite.AttachTo(Camera.Main, true); }
private IEnumerator WaitAndDoThis( float a_TimeToWait, VoidFunction a_Delegate, bool a_CallDelegateFirst = false) { if (a_CallDelegateFirst) { a_Delegate(); } yield return(new WaitForSeconds(a_TimeToWait)); if (!a_CallDelegateFirst) { a_Delegate(); } }
///イベント発火 private void runEventList(VoidFunction aCallback) { List <Arg> tEvents = mEvent.get <List <Arg> >("events"); int tLength = tEvents.Count; //イベントを1つずつ実行 Action <int> fNext = (_) => { }; fNext = (i) => { if (tLength <= i)//全てのイベント終了 { aCallback(); return; } //イベントを1つ実行 runEvent(tEvents[i], () => { fNext(i + 1); }); }; fNext(0); }
///イベントを一つ実行 private void runEvent(Arg aEvent, VoidFunction aCallback) { switch (aEvent.get <string>("event")) { case "log": //ログ出力 Debug.Log(aEvent.get <string>("value")); aCallback(); break; case "text": //会話イベント ConversationWindow.show(aEvent, () => { aCallback(); }); break; default: throw new Exception("MapEvent : 「" + aEvent.get <string>("event") + "」ってどんなイベント?"); } }
protected bool Collect; //used to signal running events that this window has been destroyed public Window(Window owner = null, bool modal = false, string sprite = "") { if (owner != null && modal) throw new ArgumentException("Child cannot be modal"); Collect = false; Immovable = false; zEventEscape = null; zModal = modal; Name = string.Empty; zOrigin = new Vector2(0, 0); if (sprite == "") zSprite = SpriteManager.AddSprite(Path.Make(Path.Misc, "pixel.bmp")); else zSprite = SpriteManager.AddSprite(sprite); zSprite.ColorOperation = ColorOperation.ColorTextureAlpha; Color = Color.White; zVisible = true; OnClick = delegate () { }; Hover = delegate () { }; HoverMousedown = delegate () { }; MouseLeave = delegate () { }; MouseEnter = delegate () { }; zParent = owner; zChildren = new List<Window>(); zText = TextManager.AddText(string.Empty, Globals.Font); zText.ColorOperation = ColorOperation.ColorTextureAlpha; zText.AttachTo(zSprite, false); Size = new Vector2(1, 1); if (owner == null) InitializeAsTopLevel(); else InitializeAsChild(); SpriteManager.AddToLayer(zSprite, zLayer); TextManager.AddToLayer(zText, zLayer); zSprite.AttachTo(Camera.Main, true); }
public abstract void search_snippet(string uri, string search_string, VoidFunction<string> callback);
public abstract void SearchForText(string search_string, bool fast, VoidFunction<List<Tuple<string[], File>>> callback);
public void Search(List<MetaLabel> keywords, List<long> types, DateTime date_start, DateTime date_end, bool starred, VoidFunction<List<File>> callback) { Query q = new Query(); q.labels = keywords; q.types = types; q.date_start = date_start; q.date_end = date_end; q.starred = starred; #if false meta.set_query_result_callback(callback); meta.set_query(q); meta.trigger_query_result_changed(); #endif #if true meta.set_query_result_callback(delegate (List<File> files) { meta.set_query_result_callback(null); callback(files); }); ++cur_search_id; int search_id = cur_search_id; meta.search(q, delegate(List<File> files) { if (cur_search_id == search_id) callback(files); }); #endif }
private Gtk.HBox create_element(Item item, string search_text, string snippet_text, VoidFunction update) { Gtk.HBox element = new Gtk.HBox(); Gtk.VBox lines = new Gtk.VBox(); Gtk.HBox title_date = new Gtk.HBox(); Gtk.EventBox title_wrapper = new Gtk.EventBox(); Gtk.Label title = new Gtk.Label(); string str_title = item.name(40); string capitalized = search_text.Substring(0, 1).ToUpper() + search_text.Substring(1); if (str_title.Contains(search_text)) { int index = str_title.IndexOf(search_text); str_title = str_title.Substring(0, index) + "<b>" + search_text + "</b>" + str_title.Substring(index+search_text.Length); } else if (str_title.Contains(capitalized)) { int index = str_title.IndexOf(capitalized); str_title = str_title.Substring(0, index) + "<b>" + capitalized + "</b>" + str_title.Substring(index+capitalized.Length); } title.Markup = "<big>" + str_title + "</big>"; title.UseUnderline = false; title.SetAlignment(0, 0); // left aligned title_wrapper.ButtonPressEvent += delegate(object sender, Gtk.ButtonPressEventArgs args) { if (args.Event.Button == 1) item.open(); }; title_wrapper.Add(title); GtkCommon.set_background_color(title_wrapper, "white"); GtkCommon.show_hand_and_tooltip(title_wrapper, String.Format(Mono.Unix.Catalog.GetString("Open: {0}"), item.long_name)); GtkCommon.create_preview(item, lines, title_wrapper); title_date.PackStart(title_wrapper, true, true, 0); Gtk.Alignment date_alignment = new Gtk.Alignment(1, 0, 0, 0); Gtk.Label date = new Gtk.Label(); date.Markup = "<big>" + String.Format("{0:dd/MM/yy}", item.last_modify) + "</big>"; date_alignment.Add(date); date_alignment.LeftPadding = 10; title_date.PackStart(date_alignment, true, true, 0); lines.PackStart(title_date, true, true, 0); try { DocumentItem doc_item = item as DocumentItem; if (doc_item != null) { doc_item.on_snippet_callback = delegate (string snippet) { if (!String.IsNullOrEmpty(snippet)) { System.Console.WriteLine("got snippet: {0}", snippet); Gtk.Label snippet_label = new Gtk.Label(); snippet_label.SetAlignment(0, 0); // left aligned snippet_label.Markup = snippet; lines.PackStart(snippet_label, true, true, 2); lines.ReorderChild(snippet_label, 1); update(); } }; if (!String.IsNullOrEmpty(doc_item.snippet)) doc_item.on_snippet_callback(doc_item.snippet); } } catch (Exception) { // not document item } Gtk.HBox label_links = new Gtk.HBox(); Gtk.HBox bubbles = new Gtk.HBox(); foreach (UserLabel label in item.labels) bubbles.Add(label.dot()); label_links.PackStart(bubbles, false, false, 0); item.on_labels_callback = delegate() { foreach (Widget w in bubbles) w.Destroy(); foreach (UserLabel label in item.labels) bubbles.Add(label.dot()); element.ShowAll(); }; Gtk.Alignment links_alignment = new Gtk.Alignment(1,1,0,0); Gtk.HBox links = new Gtk.HBox(); add_link(Mono.Unix.Catalog.GetString("Go to week"), CalendarDriver.View.Week, item.last_modify, links); add_link(Mono.Unix.Catalog.GetString("Go to month"), CalendarDriver.View.Month, item.last_modify, links); add_link(Mono.Unix.Catalog.GetString("Go to year"), CalendarDriver.View.Year, item.last_modify, links); links_alignment.Add(links); label_links.PackStart(links_alignment, true, true, 0); lines.PackStart(label_links, true, true, 2); string image = String.Empty; if (item.file != null) image = Singleton<Types>.Instance.get_type((int)item.file.type.category).icon; Gtk.Alignment img_alignment = new Gtk.Alignment(0, (float)0.05, 0,0); if (!String.IsNullOrEmpty(image)) { Gtk.Image img; if (item.file.starred) img = CairoDrawing.create_small_starred_image(image); else img = new Gtk.Image(null, image); item.register_small_starred_change(delegate(bool starred) { foreach (Widget w in img_alignment) w.Destroy(); if (starred) img = CairoDrawing.create_small_starred_image(image); else img = new Gtk.Image(null, image); img_alignment.Add(img); img_alignment.ShowAll(); }); img_alignment.Add(img); img_alignment.ShowAll(); } element.PackStart(img_alignment, false, false, 5); element.PackStart(lines, true, true, 0); return element; }
///タイムアウト設定 public void setTimeout(float aSeconds, VoidFunction aFunction) { StartCoroutine(coroutine(aSeconds, aFunction)); }
public static VoidFunction <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> Lambda <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(VoidFunction <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> value) => value;
public void get_file_from_metadata_store(string filename, VoidFunction<File> callback) { ThreadPool.QueueUserWorkItem(delegate { meta.get_file_from_path(filename, callback); }); }
public TextBox(Window owner) : base(owner) { zTypinRoutineRunning = false; zAutoScale = false; input = string.Empty; carret = (char)300; MaxLength = uint.MaxValue; OnEnter = delegate () { }; OnClick = StartTyping; zText.RelativePosition.X = 0.5f; zText.RelativePosition.Y = -zSprite.ScaleY; Globals.EventManager.AddEvent(AutoScalling, "autoscalling"); zOriginalScalex = Size.X; }
public void set_item(Item item) { button_press_handler = GtkCommon.OnButtonPressEventWrapper(item); }
public void AddDelegate(string MenuItem, VoidFunction function) { Delegates.Add(MenuItem, function); }
protected void ThenExceptionIsThrown <T>(VoidFunction method, string exceptionMessage) where T : Exception { var ex = Assert.Throws <T>(() => method()); Assert.That(ex.Message, Is.EqualTo(exceptionMessage)); }
void setTimeout(VoidFunction eh, int ms) { DispatcherTimer dt = new DispatcherTimer(); dt.Interval = new TimeSpan(0, 0, 0, 0, ms); dt.Tick += delegate { dt.Stop(); eh(); }; dt.Start(); }
private IEnumerator coroutine(float aSeconds, VoidFunction aFunction) { yield return(new WaitForSeconds(aSeconds)); aFunction(); }
public void get_text(string uri, VoidFunction<string> callback) { // FIXME: remember thread pool // System.Console.WriteLine("TRACKER IS FUBARED"); //string result = bus_files.GetTextContents(uri, 0, 100); callback(""); // result }
protected void ThenExceptionIsThrown <T>(VoidFunction method) where T : Exception { Assert.Throws <T>(() => method()); }
public void get_all_labels(VoidFunction<List<MetaLabel>> callback) { meta.set_labels_changed_callback(callback); meta.trigger_labels_changed(); }
public static VoidFunction <T1, T2, T3> Lambda <T1, T2, T3>(VoidFunction <T1, T2, T3> value) => value;
public void get_type_labels(VoidFunction<List<Tuple<FileTypeCategory, int>>> callback) { meta.set_type_labels_changed_callback(callback); meta.trigger_type_labels_changed(); }
public static VoidFunction <T1, T2, T3, T4, T5, T6, T7> Lambda <T1, T2, T3, T4, T5, T6, T7>(VoidFunction <T1, T2, T3, T4, T5, T6, T7> value) => value;
public static VoidFunction <T1> Lambda <T1>(VoidFunction <T1> value) => value;
/// <summary> /// Metoda, která přidá nového pozorovatele (resp. jeho funkci na pozdější zavolání) /// </summary> /// <param name="newObserverFunction"></param> public void Add(VoidFunction newObserverFunction) { observerFunctions.Add(newObserverFunction); }
public static VoidFunction <T1, T2, T3, T4, T5> Lambda <T1, T2, T3, T4, T5>(VoidFunction <T1, T2, T3, T4, T5> value) => value;
void Main() { VoidFunction t = RealFunction; int i = 1; }
public static VoidFunction <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Lambda <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(VoidFunction <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> value) => value;
private IEnumerator WaitThenDoThis(float a_TimeToWait, VoidFunction a_Delegate) { yield return(new WaitForSeconds(a_TimeToWait)); a_Delegate(); }
public RangeAndValue(float min, float max, float value, bool wrap, bool allowOOB, VoidFunction invalidatecall) { Init(min, max, value, wrap, allowOOB); Invalidate += invalidatecall; }
public void register_small_starred_change(VoidFunction<bool> update_function) { small_starred_update_function = update_function; }