コード例 #1
0
        void GetMessage(string dataReceived)
        {
            if (InvokeRequired)
            {
                GetMessageCallback callback = GetMessage;
                Invoke(callback, dataReceived);
            }
            else
            {
                string sAux;

                int index = dataReceived.IndexOf('\0');

                sAux = dataReceived.Substring(0, index);
                if (sAux.ElementAt(0) != ':')
                {
                    index = sAux.IndexOf(':');
                    int    iCodigoUsuario = 0;
                    string sMensagem;

                    if (index != -1)
                    {
                        iCodigoUsuario = Int32.Parse(sAux.Substring(0, index));
                        index++;
                        sMensagem = sAux.Substring(index, sAux.Length - index);

                        string sMensagens   = "";
                        string sNomeUsuario = "";

                        for (int i = 0; i < Usuarios.Count; i++)
                        {
                            if (Usuarios[i].iCodigo == iCodigoUsuario)
                            {
                                sNomeUsuario = Usuarios[i].sNome;
                                break;
                            }
                        }

                        sMensagem = "[" + sNomeUsuario + "] - " + sMensagem;

                        mapMensagens.TryGetValue(iCodigoUsuario, out sMensagens);
                        sMensagens += sMensagem;

                        mapMensagens[iCodigoUsuario] = sMensagens;

                        Usuario usuario = (Usuario)this.listBox1.SelectedItem;

                        if (usuario != null)
                        {
                            if (usuario.iCodigo == iCodigoUsuario)
                            {
                                rtbMensagens.AppendText(sMensagem);
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: TickerBar.cs プロジェクト: terrariumapp/terrarium
        /// <summary>
        /// Fired when the current text scrolls off of the bounds.  Increments
        /// the callback and executes it to retrieve the next text.
        /// </summary>
        /// <param name="args">Standard EventArgs</param>
        protected virtual void OnScrollComplete(EventArgs args)
        {
            if (this.messageCallbacks.Count == 0)
            {
                this.currentCallbackIndex = -1;
                this.currentMessage.Text  = "";
            }
            else
            {
                this.currentCallbackIndex++;
                if (this.currentCallbackIndex >= this.messageCallbacks.Count)
                {
                    this.currentCallbackIndex = 0;
                }

                Object callbackObject = this.messageCallbacks[this.currentCallbackIndex];
                if (callbackObject is GetMessageCallback)
                {
                    GetMessageCallback messageCallback = (GetMessageCallback)callbackObject;

                    try
                    {
                        this.currentMessage = messageCallback();
                        this.Invalidate();
                        if (this.currentMessage.RemoveCallback == true)
                        {
                            // Remove the callback
                            this.messageCallbacks.Remove(messageCallback);

                            // Push the index back one so that the next one
                            // won't get skipped
                            this.currentCallbackIndex--;
                        }
                    }
                    catch (Exception ex)
                    {
                        this.currentMessage       = new TickerMessage();
                        this.currentMessage.Text  = "*** TickerMessageCallback Exception: " + messageCallback.Method.Name + " ***";
                        this.currentMessage.Color = Color.Red;
                        Trace.WriteLine(this.currentMessage.Text);
                        Trace.WriteLine(ex.ToString());
                    }
                }
                else
                {
                    this.messageCallbacks.Remove(callbackObject);
                    this.currentMessage      = new TickerMessage();
                    this.currentMessage.Text = "";
                    this.currentCallbackIndex--;
                }
            }

            if (this.ScrollComplete != null)
            {
                this.ScrollComplete(this, args);
            }
        }
コード例 #3
0
        //-------------------------------------------------------------------------
        // This is the one and only entry point called when Postgres loads the language handler DLL
        // At this point there is no way to report problems, so avoid any exceptions. Just store things for later use.
        public static int Entry(string arg)
        {
            // Leave these here commented out if ever needed
            //Debugger.Launch();
            //pg_elog(ElogLevel.NOTICE, $"Entry: '{arg}'");
            _initial_arg = arg;

            // These are the (static) callback functions. Look up an instance and call it...
            ConnectCallback    cncb = (h, o) => GetInstance(h).Connect(o);
            TypeCheckCallback  tccb = (h, f, n, a, r) => GetInstance(h).TypeCheck(f, a, r);
            InvokeCallback     ivcb = (h, f, n, a, r) => GetInstance(h).Invoke(f, a, r);
            GetMessageCallback gmcb = (h) => GetInstance(h).GetMessage();

            // call back with the real entry points for later use
            return(plandl_init_callback(cncb, tccb, ivcb, gmcb));
        }
コード例 #4
0
 public static extern int plandl_init_callback(ConnectCallback cncb, TypeCheckCallback tccb, InvokeCallback ivcb, GetMessageCallback gmcb);