示例#1
0
 /// <summary>
 /// Triggers the MaxValueChanged event.
 /// </summary>
 public virtual void OnMaxValueChanged()
 {
     if (MaxValueChanged != null)
     {
         ctx.Send(spcMaxValueChanged, null);
     }
 }
示例#2
0
 public void ShowLastLine()
 {
     synchronizationContext.Send(new System.Threading.SendOrPostCallback(
                                     delegate(object state)
     {
         richTextBox.ScrollToCaret();
     }
                                     ), null);
 }
示例#3
0
        private void BuildNodes(System.Threading.SynchronizationContext ui, string filterstring)
        {
            foreach (var mc in AnalysisManager.Instance.MemberCaches.Where(mc => mc is MethodBaseCache))
            {
                MemberNode n = null;
                foreach (string s in ((MethodBaseCache)mc).UsedStrings)
                {
                    if (s != null && s.ToLower().Contains(filterstring))
                    {
                        if (n == null)
                        {
                            n = MemberNode.GetNodeOfMember(mc.Member, true);
                        }

                        n.Nodes.Add(s);
                    }
                }

                if (n != null)
                {
                    ui.Send(o =>
                    {
                        ((FindString)o).tvSearchResults.Nodes.Add(n);
                    }, this);
                }
            }
        }
示例#4
0
        /// <summary>
        /// Notifies observers of CollectionChanged or PropertyChanged of an update to the dictionary.
        /// </summary>
        private void NotifyObserversOfChange()
        {
            var collectionHandler = CollectionChanged;
            var propertyHandler   = PropertyChanged;

            if (collectionHandler != null || propertyHandler != null)
            {
                var action = new System.Action(() =>
                {
                    collectionHandler?.Invoke(this, new System.Collections.Specialized.NotifyCollectionChangedEventArgs(System.Collections.Specialized.NotifyCollectionChangedAction.Reset));

                    if (propertyHandler != null)
                    {
                        propertyHandler(this, new System.ComponentModel.PropertyChangedEventArgs(nameof(Count)));
                        propertyHandler(this, new System.ComponentModel.PropertyChangedEventArgs(nameof(Keys)));
                        propertyHandler(this, new System.ComponentModel.PropertyChangedEventArgs(nameof(Values)));
                    }
                });

                if (System.Threading.SynchronizationContext.Current == _synchronizationContext)
                {
                    action();
                }
                else
                {
                    _synchronizationContext.Send(_ => action(), null);
                }
            }
        }
        private void BuildNodes(System.Threading.SynchronizationContext ui, string filterstring)
        {
            if (decryptedStrings == null)
            {
                return;
            }

            foreach (var pair in decryptedStrings)
            {
                MemberNode n = null;
                foreach (DecryptedString ds in pair.Value)
                {
                    if (string.IsNullOrEmpty(filterstring) || pair.Key.Name.ToLower().Contains(filterstring) ||
                        (ds != null && ds.Decrypted.ToLower().Contains(filterstring)))
                    {
                        if (n == null)
                        {
                            n = MemberNode.GetNodeOfMember(pair.Key, true);
                        }
                        n.Nodes.Add(ds.ILOffset.ToString("x4") + ": '" + ds.Decrypted + "' (=" + ds.Encrypted + ")");
                    }
                }

                if (n != null)
                {
                    ui.Send(o =>
                    {
                        ((DecryptStrings)o).tvSearchResults.Nodes.Add(n);
                    }, this);
                }
            }
        }
        private void BuildNodes(System.Threading.SynchronizationContext ui)
        {
            TaskFactory factory = new TaskFactory(4);

            foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies().Where(a => !(a is System.Reflection.Emit.AssemblyBuilder)))
            {
                factory.StartTask <Assembly, AssemblyNode>(ass =>
                {
                    AssemblyNode an = new AssemblyNode(ass);
                    an.PopulateAll(txtFilter.Text.ToLower());
                    an.ExpandAll();
                    if (an.Nodes.Count > 0)
                    {
                        return(an);
                    }
                    else
                    {
                        return(null);
                    }
                }, a, an =>
                {
                    if (an != null)
                    {
                        ui.Send(o =>
                        {
                            ((SearchTypeOrMember)o).tvSearchResults.Nodes.Add(an);
                        }, this);
                    }
                });
            }
            factory.WaitAll();
        }
示例#7
0
        public void Send(Action action, string memberName = null, string filePath = null, int lineNumber = 0)
        {
            AssertArg.IsNotNull(action, nameof(action));
            EnsureInitialized();

            Action wrapper = GetWrappedAction(
                action, null, false,
                memberName, filePath, lineNumber);

            if (InvokeRequired)
            {
                Context.Send(state => wrapper(), null);
            }
            else
            {
                wrapper();
            }
        }
示例#8
0
        internal static async Task TestProgrammer(System.Threading.SynchronizationContext UIContext, string ProgrammerPath)
        {
            LogFile.BeginAction("TestProgrammer");
            try
            {
                LogFile.Log("Starting Firehose Test", LogType.FileAndConsole);

                PhoneNotifierViewModel Notifier = new();
                UIContext.Send(s => Notifier.Start(), null);
                if (Notifier.CurrentInterface == PhoneInterfaces.Qualcomm_Download)
                {
                    LogFile.Log("Phone found in emergency mode", LogType.FileAndConsole);
                }
                else
                {
                    LogFile.Log("Phone needs to be switched to emergency mode.", LogType.FileAndConsole);
                    await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash);

                    PhoneInfo Info = ((NokiaFlashModel)Notifier.CurrentModel).ReadPhoneInfo();
                    Info.Log(LogType.ConsoleOnly);
                    await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Qualcomm_Download);

                    if (Notifier.CurrentInterface != PhoneInterfaces.Qualcomm_Download)
                    {
                        throw new WPinternalsException("Switching mode failed.", "Could not switch the phone to Qualcomm Emergency 9008.");
                    }

                    LogFile.Log("Phone is in emergency mode.", LogType.FileAndConsole);
                }

                // Send and start programmer
                QualcommSerial Serial = (QualcommSerial)Notifier.CurrentModel;
                QualcommSahara Sahara = new(Serial);

                if (await Sahara.Reset(ProgrammerPath))
                {
                    LogFile.Log("Emergency programmer test succeeded", LogType.FileAndConsole);
                }
                else
                {
                    LogFile.Log("Emergency programmer test failed", LogType.FileAndConsole);
                }
            }
            catch (Exception Ex)
            {
                LogFile.LogException(Ex);
            }
            finally
            {
                LogFile.EndAction("TestProgrammer");
            }
        }
示例#9
0
        private void _VideoDevice_NewFrame(object sender, AForge.Video.NewFrameEventArgs eventArgs)
        {
            _SyncContext.Send(o =>
            {
                IntPtr hBitmap = eventArgs.Frame.GetHbitmap();
                Source         = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                    hBitmap,
                    IntPtr.Zero,
                    Int32Rect.Empty,
                    BitmapSizeOptions.FromEmptyOptions());

                DeleteObject(hBitmap);
            }, null);
        }
示例#10
0
        private void _Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (timerHackRunning)
            {
                return;
            }
            timerHackRunning = true;
            if (_uiContext != null)
            {
                _uiContext.Send(x => RaiseAllEvents(), null);
            }
            else
            {
                RaiseAllEvents();
            }

            timerHackRunning = false;
        }
        private void GameEndedCommon(PlayerType player, string message)
        {
            MessageBox.Show(string.Format(CultureInfo.InvariantCulture, message, player.ToString()),
                            "TicTacToe",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information);

            ActorProxy.Unregister(PlayerChoice.Value, true);

            _closeSilently = true;

            // Close Window from UI thread
            //System.Threading.SynchronizationContext.Current.Send((state) =>
            _synchronizationContext.Send((state) =>
            {
                Close();
            }, null);
        }
    public object Invoke(Delegate method, object[] args)
    {
        if (method == null)
        {
            throw new ArgumentNullException("method");
        }
        lock (_invokeLocker)
        {
            object objectToGet = null;

            SendOrPostCallback invoker = new SendOrPostCallback(
                delegate(object data)
            {
                objectToGet = method.DynamicInvoke(args);
            });

            _currentContext.Send(new SendOrPostCallback(invoker), method.Target);

            return(objectToGet);
        }
    }
 public Dispatcher(ISession session, System.Threading.SynchronizationContext synchronizationContext)
 {
     _session = session;
     _session.OnRawMessage = (string rawData) =>
     {
         //Logger.Instance.D(CLASS_NAME,"OnRawMessage");
         try
         {
             if (PreHandler(rawData))
             {
                 return;
             }
             JObject msg;
             try
             {
                 msg = JObject.Parse(rawData);
             }
             catch (Exception ex)
             {
                 Logger.Instance.E(CLASS_NAME, ex.Message);
                 SendUTF8(Newtonsoft.Json.JsonConvert.SerializeObject(new JObject
                 {
                     ["ReqId"]       = DEFAULT_QUIT_ID,
                     ["Method"]      = "unknow",
                     ["Status"]      = -1,
                     ["Action"]      = "error",
                     ["ErrorString"] = ex.Message
                 }));
                 return;
             }
             var reqId      = msg.ContainsKey("ReqId") ? msg["ReqId"] : new JValue(0);
             var method     = msg.Value <string>("Method");
             var methodInfo = GetType().GetMethod(method);
             if (methodInfo == null)
             {
                 throw new Exception($"method {method} not exist");
             }
             List <object> paramers = new List <object>();
             if (methodInfo.IsDefined(typeof(ParamertersAttribute), false))
             {
                 msg["ReqId"] = reqId;
                 var paramersAttr = methodInfo.GetCustomAttribute(typeof(ParamertersAttribute)) as ParamertersAttribute;
                 var paramersInfo = methodInfo.GetParameters();
                 for (int i = 0; i < paramersInfo.Length; i++)
                 {
                     if ((i < paramersAttr.Names.Length) && msg.ContainsKey(paramersAttr.Names[i]))
                     {
                         paramers.Add(msg[paramersAttr.Names[i]].ToObject(paramersInfo[i].ParameterType));
                     }
                     else
                     {
                         paramers.Add(null);
                     }
                 }
             }
             if (methodInfo.ReturnType == typeof(Task <JToken>))
             {
                 synchronizationContext.Post((object state) =>
                 {
                     var task = OnSessionMessageAsync(reqId, method, paramers);
                 }, null);
             }
             else
             {
                 synchronizationContext.Send((object state) =>
                 {
                     OnSessionMessage(reqId, method, paramers);
                 }, null);
             }
         }
         catch (Exception ex)
         {
             Logger.Instance.E(CLASS_NAME, ex.Message);
             SendUTF8(Newtonsoft.Json.JsonConvert.SerializeObject(new JObject
             {
                 ["ReqId"]       = DEFAULT_QUIT_ID,
                 ["Method"]      = "unknow",
                 ["Status"]      = -1,
                 ["Action"]      = "error",
                 ["ErrorString"] = ex.Message
             }));
         }
     };
 }