public static void InvokeIfRequired(Control c, VoidDelegate d) { if (c.InvokeRequired) c.Invoke(d); else d.Invoke(); }
public static Vector2 ScrollView(Vector2 scrollPosition, VoidDelegate callback) { var newScrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); callback(); EditorGUILayout.EndScrollView(); return newScrollPosition; }
private bool Init(UnityEngine.Object obj, EditorFeatures requirements) { this.editor = Editor.CreateEditor(obj); if (this.editor == null) { return false; } if (((requirements & EditorFeatures.PreviewGUI) > EditorFeatures.None) && !this.editor.HasPreviewGUI()) { return false; } MethodInfo method = this.editor.GetType().GetMethod("OnSceneDrag", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); if (method != null) { this.OnSceneDrag = (VoidDelegate) Delegate.CreateDelegate(typeof(VoidDelegate), this.editor, method); } else { if ((requirements & EditorFeatures.OnSceneDrag) > EditorFeatures.None) { return false; } this.OnSceneDrag = new VoidDelegate(this.DefaultOnSceneDrag); } return true; }
public void Move(int numNodes, VoidDelegate callback) { _nodesLeft = numNodes; _callback = callback; StartMoving(); }
public static void OnClick(this Transform trans,VoidDelegate.WithGo callback) { QFramework.UI.UGUIEventListener.Get (trans.gameObject); var listener = QFramework.UI.UGUIEventListener.CheckAndAddListener (trans.gameObject); listener.onClick += callback; }
public static void OnClick(this GameObject go,VoidDelegate.WithGo callback) { QFramework.UI.UGUIEventListener.Get (go); var listener = QFramework.UI.UGUIEventListener.CheckAndAddListener (go); listener.onClick += callback; }
/// <summary> /// Executes NASM on the output file. It is assumed the output file now exists. /// </summary> /// <param name="inputFilePath">Path to the ASM file to process.</param> /// <param name="outputFilePath">Path to output the object file to.</param> /// <param name="OnComplete">Handler to call once NASM has completed. Default: null.</param> /// <param name="state">The state object to use when calling the OnComplete handler. Default: null.</param> /// <returns>True if execution completed successfully. Otherwise false.</returns> public override bool ExecuteAssemblyCodeCompiler(string inputFilePath, string outputFilePath, VoidDelegate OnComplete = null, object state = null) { bool OK = true; //Compile the .ASM file to .BIN file string ToolPath = Path.Combine(Options.ToolsPath, @"MIPS\mips-linux-gnu-as.exe"); //Delete an existing output file so we start from scratch if (File.Exists(outputFilePath)) { File.Delete(outputFilePath); } if (!File.Exists(inputFilePath)) { throw new NullReferenceException("ASM file does not exist! Path: \"" + inputFilePath + "\""); } string inputCommand = String.Format("-mips32 -Os -EL -o \"{1}\" \"{2}\"", "elf", outputFilePath, inputFilePath, "ELF"); //Logger.LogMessage(inputFilePath, 0, inputCommand); OK = Utilities.ExecuteProcess(Path.GetDirectoryName(outputFilePath), ToolPath, inputCommand, "MIPS:GCC", false, null, OnComplete, state); return OK; }
public static GoTween MakeTween( Transform TheTransform, Vector3 Position, Quaternion Rotation, float MoveTime = 0.5f, bool IsLocal = false, GoEaseType Ease = GoEaseType.Linear, VoidDelegate OnCompleteFunction = null ) { GoTweenConfig Config = new GoTweenConfig(); Config.addTweenProperty(new PositionTweenProperty(Position, false, IsLocal)); //Config.addTweenProperty(new EulerAnglesTweenProperty(Rotation, false, IsLocal)); Config.addTweenProperty(new RotationQuaternionTweenProperty(Rotation, false, IsLocal)); Config.setEaseType(Ease); if(OnCompleteFunction != null){ Config.onComplete(c => { OnCompleteFunction(); }); } GoTween NewTween = new GoTween(TheTransform, MoveTime, Config); Go.addTween(NewTween); return NewTween; }
public static void RegisterLogicMsg(this IMsgReceiver self, string msgName,VoidDelegate.WithParams callback,QMsgChannel channel = QMsgChannel.Global) { if (CheckStrNullOrEmpty (msgName)||CheckDelegateNull(callback)) { return; } // 添加消息通道 if (!mMsgHandlerDict.ContainsKey (channel)) { mMsgHandlerDict [channel] = new Dictionary<string, List<QMsgHandler>> (); } // 略过 if (!mMsgHandlerDict[channel].ContainsKey (msgName)) { mMsgHandlerDict[channel] [msgName] = new List<QMsgHandler> (); } // 看下这里 var handlers = mMsgHandlerDict [channel][msgName]; // 略过 // 防止重复注册 foreach (var handler in handlers) { if (handler.receiver == self && handler.callback == callback) { Debug.LogWarning ("RegisterMsg:" + msgName + " ayready Register"); return; } } // 再看下这里 handlers.Add (new QMsgHandler (self, callback)); }
public static void OnClick(this MonoBehaviour behaviour,VoidDelegate.WithGo callback) { QFramework.UI.UGUIEventListener.Get (behaviour.gameObject); var listener = QFramework.UI.UGUIEventListener.CheckAndAddListener (behaviour.gameObject); listener.onClick += callback; }
public static int Main() { RunGetFncSecTest(); int retVal = 100; VoidDelegate md = new VoidDelegate(FunctionPtr.Method); Console.WriteLine("\r\nTesting Marshal.GetFunctionPointerForDelegate()."); try { Marshal.GetFunctionPointerForDelegate<Object>(null); retVal = 0; Console.WriteLine("Failure - did not receive an exception while passing null as the delegate"); } catch (ArgumentNullException e) { Console.WriteLine("Pass - threw the right exception passing null as the delegate"); } catch (Exception e) { retVal = 0; Console.WriteLine("Failure - receive an incorrect exception while passing null as the delegate"); Console.WriteLine(e); } RunGetDelForFcnPtrTest(); return retVal; }
/// <summary> /// Black magic that lets us ignore issues where something is wrong /// without surrounding every single line in a try-catch. /// <para> /// Don't try this at home folks. /// </para> /// Source: http://stackoverflow.com/questions/117173/c-try-catch-every-line-of-code-without-individual-try-catch-blocks /// </summary> public static void Try(VoidDelegate v) { try { v(); } catch { } }
// Token: 0x060024FA RID: 9466 // RVA: 0x0001CDB8 File Offset: 0x0001AFB8 public Class523(VoidDelegate voidDelegate_1, Delegate2 delegate2_1) : base(false) { Class115.bool_31 = true; this.voidDelegate_0 = voidDelegate_1; this.delegate2_0 = delegate2_1; this.thread_0 = Class115.smethod_87(new VoidDelegate(this.method_0)); }
public static bool Foldout(bool toggle, GUIContent label, VoidDelegate callback) { var rect = GUILayoutUtility.GetRect(new GUIContent("\t" + label.text), GUIStyle.none); bool result = EditorGUI.Foldout(rect, toggle, label, true); if (result) callback(); return result; }
public LogBrowser() { closeDelegate = new VoidDelegate(this.Close); InitializeComponent(); sqLiteConnection.Open(); logDataAdapter.Fill(logDataSet); serversDataAdapter.Fill(serverDataSet); }
public SensorNetServer() { InitializeComponent(); descriptionUpdater = new VoidDelegate(UpdateServerDescription); closeDelegate = new VoidDelegate(this.Close); log.Name = "log"; log.LogMessage += new LogMessageEventHandler(log_LogMessage); log.Start(); #region copy data files if (!Directory.Exists(Application.UserAppDataPath)) { Directory.CreateDirectory(Application.UserAppDataPath ); } if (!File.Exists(Application.UserAppDataPath + "\\" + SensorNetConfig.ServerDatabase)) { File.Copy(Application.StartupPath + "\\" + SensorNetConfig.ServerDatabase, Application.UserAppDataPath + "\\" + SensorNetConfig.ServerDatabase); } database = DatabaseHelper.ConnectToSQL("Data Source=\"" + Application.UserAppDataPath + "\\" + SensorNetConfig.ServerDatabase + "\""); #endregion #region Regestry data setup RegistryKey registryKey = Registry.CurrentUser.CreateSubKey(SensorNetConfig.ConfigKeyName); bool createNewConfig = true; object regKey = registryKey.GetValue("ServerID"); if (regKey != null) { Guid serverID = new Guid((string)regKey); CurrentServerData = DatabaseHelper.GetServerByID(database, serverID); if (CurrentServerData != null) { createNewConfig = false; } } if (createNewConfig) { // Show server config before starting server (which is automatically done when config box is closed) Bitmap serverPic = new Bitmap(Application.StartupPath + "/defaultImage.jpg"); CurrentServerData = new ServerConfigData(Guid.Empty, "New Server", "Location", "Description", JpegImage.GetBytes(serverPic)); configMenuItem_Click(this, new EventArgs()); } else { //If config isn't needed, start now registryKey.Close(); StartServer(); } #endregion }
/// <summary> /// Run any pending work tasks. /// </summary> /// <returns>true if any tasks were run.</returns> public bool Update() { VoidDelegate[] runnable; lock (schedulerQueue) { //purge any waiting timed tasks to the main schedulerQueue. lock (timedTasks) { long currentTime = timer.ElapsedMilliseconds; ScheduledDelegate sd; while (timedTasks.Count > 0 && (sd = timedTasks[0]).WaitTime <= currentTime) { timedTasks.RemoveAt(0); if (sd.Cancelled) { continue; } schedulerQueue.Enqueue(sd.Task); if (sd.RepeatInterval > 0) { sd.WaitTime = timer.ElapsedMilliseconds + sd.RepeatInterval; timedTasks.AddInPlace(sd); } } } int c = schedulerQueue.Count; if (c == 0) { return(false); } //create a safe copy of pending tasks. runnable = new VoidDelegate[c]; schedulerQueue.CopyTo(runnable, 0); schedulerQueue.Clear(); } foreach (VoidDelegate v in runnable) { try { VoidDelegate mi = new VoidDelegate(v); mi.Invoke(); } catch (Exception e) { Logger.Log($@"Error in scheduled task: {e}", LoggingTarget.Runtime); } } return(true); }
void Test3(int a) { int u = 8; VoidDelegate d = delegate() { u = 9; }; VoidDelegate d2 = delegate() { }; }
public AudioOneShotPlay(GameObject hostObject, string strAudioFile, float audioVolume, VoidDelegate callback) { this.m_hostObject = hostObject; this.m_callBack = callback; this.m_audioVolume = audioVolume; this.m_audioFile = strAudioFile; this.IsStopped = false; ResourceManager.singleton.LoadAudio(strAudioFile, new AssetRequestFinishedEventHandler(this.OnLoadOneShotAudioFinished), AssetPRI.DownloadPRI_Low); }
public void MoveTo(Vector3 position, VoidDelegate onArrival = null) { Tween.toWithSpeed(transform.position, position, 3f, Tween.EaseType.easeInOutSine, (Tween tween) => { transform.position = (Vector3)tween.Value; }, (Tween tween) => { if (onArrival != null) onArrival(); } ); }
public void Unregister(VoidDelegate callback) { if (m_Callback == null) { return; } m_Callback -= callback; }
public ScheduledDelegate Add(VoidDelegate d, int timeUntilRun) { lock (schedulerQueue) { ScheduledDelegate del = new ScheduledDelegate(d, timer.ElapsedMilliseconds + timeUntilRun); timedQueue.Add(del); return(del); } }
public void Close() { OnCanceled = null; OnConfirmed = null; if (DontDestroyGameobject) { Destroy(this); } else { Destroy(gameObject); } }
public bool AddAutomaticResponse(Conditional condition, VoidDelegate effect) { if (automaticResponses.ContainsKey(condition)) { return(false); } automaticResponses.Add(condition, effect); return(true); }
protected void OnDestroy() { onClick = null; onDown = null; onUp = null; onEnter = null; onExit = null; onMove = null; }
public bool RemoveAutomaticResponse(Conditional condition, VoidDelegate effect) { if (!automaticResponses.ContainsKey(condition) || (effect != null && automaticResponses[condition] != effect)) { return(false); } automaticResponses.Remove(condition); return(true); }
public static int EntryPoint(string ignored) { IntPtr pFunc = IntPtr.Zero; Delegate myFuncDelegate = new VoidDelegate(SomeMethod); gcDelegateHandle = GCHandle.Alloc(myFuncDelegate); pFunc = Marshal.GetFunctionPointerForDelegate(myFuncDelegate); return((int)pFunc.ToInt32()); }
private static void InvokeOnPassing() { VoidDelegate passing = OnPassing; if (passing != null) { passing(); } }
public static void FireEvent(VoidDelegate pEvent) { VoidDelegate eh = pEvent; if (eh != null) { eh(); } }
public ASyncLoader(VoidDelegate load, BoolReturnDelegate complete = null) { GameBase.BackgroundLoading = true; this.loadFunction = load; this.completeFunction = complete; runningThread = GameBase.RunBackgroundThread(run); }
private void InitialseProgressBar(int numberOfSteps) { SetIntDelegate setProgressStep = new SetIntDelegate(SetProgressStep); this.Invoke(setProgressStep, new object[] { numberOfSteps }); VoidDelegate progressStep = new VoidDelegate(ProgressStep); this.Invoke(progressStep); }
public static void DoVoidDelegate(VoidDelegate func, GameObject arg) { try { func(arg); } catch (Exception ex) { //TopTip.addTip(a.Method.Name + "执行出错" + ex.ToString()); FuncUtil.ShowError(func.Method.Name + "执行出错" + ex.ToString()); } }
static void EngineStopped() { VoidDelegate d = delegate() { Application.Exit(); }; main.Invoke(d); }
private static void InvokeOnFailing() { VoidDelegate failing = OnFailing; if (failing != null) { failing(); } }
public RunHelper(VoidDelegate start, VoidDelegate end, DebugDelegate deb, string name) { OnStart = start; OnEnd = end; Name = name; OnDebug = deb; bw.DoWork += new System.ComponentModel.DoWorkEventHandler(bw_DoWork); bw.WorkerReportsProgress = false; }
static IEnumerator CountDown(float timer, VoidDelegate callback = null) { yield return(new WaitForSeconds(timer)); if (callback != null) { callback(); } }
private void EndTimer() { if (TimerEnded != null) { TimerEnded(); TimerEnded = null; } }
private void Clean() { RemoveHotUpdateEventHandle(); while (DoHotUpdateComplete != null) { DoHotUpdateComplete -= this.DoHotUpdateComplete; } }
static public object CreateMenuItem(string title, VoidDelegate voidVoidDelegate) { var menuItem = new MenuItem { Header = title }; menuItem.Click += (RoutedEventHandler)(delegate { voidVoidDelegate(); }); return(menuItem); }
public static bool TriggerEvent(VoidDelegate e) { if (e == null) { return(false); } e(); return(true); }
private void HideBoxAnimationCompleted(object sender, EventArgs e) { HideBoxAnimation.Stop(); Visibility = Visibility.Collapsed; VoidDelegate method = HideBoxAnimationCompletedAsync; Dispatcher.BeginInvoke(method, new object[0]); }
private void AsyncCallVoid(VoidDelegate caller) { caller.BeginInvoke(asyncResult => { AsyncResult ar = (AsyncResult)asyncResult; VoidDelegate remoteDel = (VoidDelegate)ar.AsyncDelegate; remoteDel.EndInvoke(asyncResult); }, null); }
public IEnumerator TimeIE(float time, VoidDelegate callback) { yield return(new WaitForSeconds(time)); callback(); TimeTool timetool = gameObject.GetComponent <TimeTool>(); Destroy(timetool); }
/// <summary> /// /// </summary> /// <param name="objs"></param> /// <param name="del"></param> public static void FOR_EACH(T[] objs, VoidDelegate del) { int c = objs.Length; for (int i = 0; i < c; ++i) { del.Invoke(objs[i]); } }
private void btnOk_Click(object sender, EventArgs e) { if (oldPlugins != null) { // 削除されたスクリプトをアンインストールする foreach (string file in oldPlugins) { if (!getPlugins().Contains(file)) { string name = getPluginName(file); if (name != "") { string script_path = Path.Combine(Utility.getScriptPath(), name + ".txt"); if (File.Exists(script_path)) { PortUtil.deleteFile(script_path); } } } } } foreach (string file in getPlugins()) { if (!File.Exists(file)) { continue; } string name = getPluginName(file); if (name == "") { continue; } char[] invalid_classname = new char[] { ' ', '!', '#', '$', '%', '&', '\'', '(', ')', '=', '-', '~', '^', '`', '@', '{', '}', '[', ']', '+', '*', ';', '.' }; foreach (char c in invalid_classname) { name = name.Replace(c, '_'); } string text = TEXT; string code = text.Replace("{0}", name); code = code.Replace("{1}", file); using (StreamWriter sw = new StreamWriter(Path.Combine(Utility.getScriptPath(), name + ".txt"))) { sw.WriteLine(code); } } if (AppManager.mMainWindow != null) { VoidDelegate deleg = new VoidDelegate(AppManager.mMainWindow.updateScriptShortcut); if (deleg != null) { AppManager.mMainWindow.Invoke(deleg); } } }
public CIdlePage() : base((int)EPages.P_IDLE) { _timedate = new CText(""); _timedate.PosY = 0; _timedate.Caption = System.DateTime.Now.ToShortDateString() + " " + System.DateTime.Now.ToShortTimeString(); CTimeoutDecorator timeDecor = new CTimeoutDecorator(_timedate, 1000, true); timeDecor.OnTimeout += new VoidDelegate(timeDateHandler); this.add(timeDecor); CText title = new CText("SIPek", EAlignment.justify_center); title.PosY = 3; add(title); // status indicator _statusBar = new CStatusBar(EAlignment.justify_right); _statusBar.PosY = 0; add(_statusBar); _displayName = new CText(""); _displayName.PosY = 4; _displayName.Align = EAlignment.justify_center; add(_displayName); CLink mlinkPhonebook = new CLink("Buddies", (int)EPages.P_PHONEBOOK); mlinkPhonebook.PosY = 9; mlinkPhonebook.LinkKey = mlinkPhonebook.PosY; this.add(mlinkPhonebook); _linkRinger = new CLink("Ring Mode", (int)EPages.P_RINGMODE); _linkRinger.Align = EAlignment.justify_right; _linkRinger.PosY = 8; _linkRinger.LinkKey = _linkRinger.PosY; this.add(_linkRinger); CLink mlinkCalls = new CLink("Calls", (int)EPages.P_CALLLOG); mlinkCalls.Align = EAlignment.justify_right; mlinkCalls.PosY = 10; mlinkCalls.LinkKey = mlinkCalls.PosY; this.add(mlinkCalls); _linkAccounts = new CLink("Accounts", (int)EPages.P_ACCOUNTS); _linkAccounts.PosY = 7; this.add(_linkAccounts); // Initialize handlers Digitkey += new BoolIntDelegate(digitkeyHandler); Charkey += new BoolIntDelegate(CIdlePage_Charkey); Offhook += new VoidDelegate(IdlePage_Offhook); Menu += new VoidDelegate(IdlePage_Menu); Ok += new VoidDelegate(IdlePage_Ok); }
public void Dispose() { if (this.editor != null) { this.OnSceneDrag = null; UnityEngine.Object.DestroyImmediate(this.editor); this.editor = null; } GC.SuppressFinalize(this); }
public Form1() { InitializeComponent(); blockReceivedHandler = new EventHandler<BlockReceivedEventArgs>(currentSession_BlockReceived); sessionStatusHandler = new EventHandler<SessionStatusChangeEventArgs>(currentSession_SessionStatusChanged); _connectionSettings.ConnectionSettingsUpdated+=new EventHandler(_connectionSettings_ConnectionSettingsUpdated); terminalBuffer = new TerminalEmulator(); ShowTerminalBufferDelegate = new VoidDelegate(this.ShowTerminalBuffer); sbOutputBuffer = new StringBuilder(_maxBufferSize); }
public void PushFunc(VoidDelegate func, int timeMS) { if(dictVoidFunc.ContainsKey(func)) { Debug.LogWarning("void func is already exist..."); return; } dictVoidFunc.Add(func, new VoidTimeParam(timeMS, func)); }
public void LogMessage(string message) { VoidDelegate itemAdder = delegate { _logListBox.Items.Add(message); _logListBox.ScrollIntoView(message); }; _logListBox.Dispatcher.Invoke(itemAdder); }
public static void DumpTime(VoidDelegate dv) { Stopwatch watch = new Stopwatch(); watch.Reset(); watch.Start(); dv(); watch.Stop(); LogMgr.Log("Cost Time = " + watch.ElapsedMilliseconds.ToString() + " ms"); LogMgr.Log("Cost Time Span = " + watch.Elapsed.ToString()); }
public ViewNotAvailableAnnotationControl(Image infoImage) { InitializeComponent(); infoPicture.Image = infoImage; this.Height = headingLabel.Height; updateSizes = new VoidDelegate(UpdateSizes); updateDel = new VoidDelegate(DoUpdate); }
public static void Main() { MainClass mc = new MainClass (); VoidDelegate del = new VoidDelegate (delegate { StringSender ss = delegate (string s) { SimpleCallback(mc, s); }; ss("Yo!"); }); del(); }
private void OnButton2Click(GameObject sender) { WindowManager.Instance.Show(typeof(AssertionWindow), false); if (CancelButtonClicked != null) { CancelButtonClicked(sender); } CancelButtonClicked = null; }
public static void Box(VoidDelegate callback) { Rect rect = EditorGUILayout.BeginVertical(); GUI.Box(rect, ""); EditorGUILayout.Space(); callback(); EditorGUILayout.Space(); EditorGUILayout.EndVertical(); }
private void button2_Click(object sender, EventArgs e) { clodeDel = new VoidDelegate(this.Close); if (this.InvokeRequired) { this.Invoke(clodeDel); } else { this.Close(); } }
private void saveButton_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.OK; VoidDelegate closeDelegate = new VoidDelegate(this.Close); if(this.InvokeRequired) { this.Invoke(closeDelegate); } else { this.Close(); } }
public void AppActivate() { if (InvokeRequired) { if (_appActivateFunc == null) _appActivateFunc = new VoidDelegate(AppActivate); Invoke(_appActivateFunc); return; } WindowState = _windowState; Bounds = _windowBounds; SetForegroundWindow(this.Handle); }