示例#1
0
        public FormOfflineMessages(ArrayList offlineMessages)
        {
            InitializeComponent();

            for (int i = 0; i < offlineMessages.Count; i++)
            {
                LetterReceive letter  = offlineMessages[i] as LetterReceive;
                string        message = letter.Message;
                string        person  = letter.From;
                if (message == "BUZZ IT")
                {
                    message = @"<DING>";
                    this.Focus();
                }
                if (File.Exists("UserSetting.dat"))
                {
                    ReadUserSetting();
                }
                else
                {
                    setting[5] = "1";
                }
                rtbOfflineMessages.SelectionFont = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Bold);
                rtbOfflineMessages.AppendText(person + " : ");
                rtbOfflineMessages.SelectionFont = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular);
                rtbOfflineMessages.AppendText(message + " \n");
                if (setting[5] == "1" || setting[5] == "2")
                {
                    WriteLogs(person + " : " + message, person); // Ghi logs chat Offline
                }
            }
        }
示例#2
0
        OnReadMessage

        (

            String msg

        )

        {
            int rgb = 0;



            for (int i = 0; i < msg.Length && msg[i] != ':'; i++)

            {
                rgb = rgb ^ ((int)msg[i] << (i % 3 + 2) * 8);
            }



            Color color = Color.FromArgb(rgb & 0x007F7FFF);

            richTextBox1.SelectionColor = color;

            richTextBox1.AppendText(msg + Environment.NewLine);
        }
示例#3
0
 private void SendMessage(object sender, System.Windows.Forms.KeyPressEventArgs e)
 {
     try
     {
         if (e.KeyChar == (char)Keys.Return)
         {
             if (pairEndPoint == null)
             {
                 MessageBox.Show(pair.Name + " is disconnected.");
             }
             else if (richTextBox2.Text == "" || richTextBox2.Text == "\n")
             {
             }
             else
             {
                 String formatted = String.Format("{0,20} | " + richTextBox2.Text, "[" + self.Name + "]");
                 iMessenger.ProcessMessage(self, richTextBox2.Text);
                 richTextBox1.AppendText(formatted);
             }
             richTextBox2.Clear();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message + " -- " + ex.StackTrace);
     }
 }
示例#4
0
文件: NFCclass.cs 项目: vebin/NewPOS
        private void displayOut(int errType, int retVal, string PrintText, System.Windows.Forms.RichTextBox mMsg)
        {
            try
            {
                switch (errType)
                {
                case 0:
                    mMsg.SelectionColor = Color.Green;
                    break;

                case 1:
                    mMsg.SelectionColor = Color.Red;
                    PrintText           = ModWinsCard.GetScardErrMsg(retVal);
                    break;

                case 2:
                    mMsg.SelectionColor = Color.Black;
                    PrintText           = "<" + PrintText;
                    break;

                case 3:
                    mMsg.SelectionColor = Color.Black;
                    PrintText           = ">" + PrintText;
                    break;

                case 4:
                    break;
                }
                mMsg.AppendText(PrintText);
                mMsg.AppendText("\n");
                mMsg.SelectionColor = Color.Black;
                mMsg.Focus();
            }
            catch (Exception ex) { }
        }
示例#5
0
        public void OnDataReceived(IAsyncResult asyn)
        {
            try
            {
                SocketPacket        theSockId = (SocketPacket)asyn.AsyncState;
                int                 iRx       = theSockId.thisSocket.EndReceive(asyn);
                char[]              chars     = new char[iRx + 1];
                System.Text.Decoder d         = System.Text.Encoding.UTF8.GetDecoder();
                int                 charLen   = d.GetChars(theSockId.dataBuffer, 0, iRx, chars, 0);
                System.String       szData    = new System.String(chars);

                CheckMessage(szData);


                richTextRxMessage.AppendText(szData);
                richTextRxMessage.AppendText("\r\n");

                richTextRxMessage.SelectionStart = richTextRxMessage.Text.Length;
                richTextRxMessage.Focus();
                tbTotalChar.Text = "" + richTextRxMessage.Text.Length;

                WaitForData();
            }
            catch (ObjectDisposedException)
            {
                System.Diagnostics.Debugger.Log(0, "1", "\nOnDataReceived: Socket has been closed\n");
            }
            catch (SocketException se)
            {
                MessageBox.Show(se.Message);
            }
        }
示例#6
0
        public static RichTextBox getAuthorAndTitles_GroupByAuthor()
        {
            BooksDataContext dc = new BooksDataContext();

            var authTitle = (from author in dc.GetTable<Author>()
                             orderby author.LastName, author.FirstName
                             let name = author.FirstName + " " + author.LastName
                             let titles =
                                 from book in author.AuthorISBNs
                                 orderby book.Title.BookTitle
                                 select book.Title.BookTitle
                             select new { Name = name, Titles = titles });

            RichTextBox temp = new RichTextBox();

            temp.AppendText("Titles Grouped by Author:\n");

            // display titles written by each author, grouped by author
            foreach ( var author in authTitle )
            {
                // display author's name
                temp.AppendText("\t" + author.Name + ":\n");

                // display titles written by that author
                foreach ( var title in author.Titles )
                {
                    temp.AppendText("\t\t" + title+"\n");
                } // end inner foreach
            } // end outer foreach

            return temp;
        }
        /// <summary>
        /// 显示信息
        /// </summary>
        /// <param name="txtInfo"></param>
        /// <param name="Info"></param>
        public static void ShowInfo(string Info, MsgType msgType, System.Windows.Forms.RichTextBox textInfo)
        {
            switch (msgType)
            {
            case MsgType.Default:
                textInfo.SelectionColor = Color.Black;
                break;

            case MsgType.Err:
                textInfo.SelectionColor = Color.Red;
                break;

            case MsgType.Warning:
                textInfo.SelectionColor = Color.Orange;
                break;

            default:
                textInfo.SelectionColor = Color.Black;
                break;
            }

            textInfo.AppendText($"【{DateTime.Now}】 {Info}");
            textInfo.AppendText(Environment.NewLine);
            textInfo.ScrollToCaret();
        }
示例#8
0
        public void runMultipleTests()
        {
            if (fileNum <= files.Length)
            {
                thisTime.updateTime();
                infoTextBox.AppendText(thisTime.getTime() + "Parsing Test Cases from file [" + files[fileNum] + "]\n");

                if (thisTestFile != null)
                {
                    //remove the last test case file from memory
                    thisTestFile = null;
                    GC.Collect();
                }

                //create a new test case file
                thisTestFile = new TestCaseFile(this, files[fileNum]);

                //create and start this new test
                testThread = new Thread(new ThreadStart(thisTestFile.InstanceMethod));
                testThread.Start();

                //move onto the next test case file if we have one
                fileNum++;
            }
        }
示例#9
0
        /// <summary>
        /// Writes a message to the specified RichTextBox.
        /// </summary>
        /// <param name="textBox"></param>
        /// <param name="message">The <see cref="string">message</see> to be written.</param>
        /// <param name="col"></param>
        private static void AppendMessage(RichTextBox textBox, string message, Color col)
        {
            try
            {
                if (!textBox.IsDisposed)
                {
                    if (textBox.InvokeRequired)
                    {
                        textBox.Invoke(new Action<RichTextBox, string, Color>(AppendMessage), textBox, message, col);
                        return;
                    }

                    Color oldColor = textBox.SelectionColor;
                    textBox.SelectionColor = col;
                    textBox.AppendText(message);
                    textBox.SelectionColor = oldColor;
                    textBox.AppendText(Environment.NewLine);
                    textBox.ScrollToCaret();
                }
            }
            catch (Exception ex)
            {
                Logging.WriteException(ex);
            }
        }
示例#10
0
 /// <summary>
 /// 在富文本上打印消息
 /// </summary>
 /// <param name="richTextBox1">所在打印的富文本</param>
 /// <param name="color">打印字体颜色</param>
 /// <param name="text">要打印的文本</param>
 /// <param name="AutoTime">是否在每条打印结果前追加时间</param>
 public void AppendMsg(RichTextBox richTextBox1, Color color, string text,bool AutoTime)
 {
     richTextBox1.BeginInvoke(new ThreadStart(() =>
      {
          lock (richTextBox1)
          {
              //为控件输入焦点
              richTextBox1.Focus();
              //检查文本框过长
              if (richTextBox1.TextLength > 100000 )
              {
                  richTextBox1.Clear();
              }
              //得到有格式的文本
              using (var temp = new RichTextBox())
              {
                  temp.SelectionColor = color;
                  if (AutoTime)
                      temp.AppendText(DateTime.Now.ToString("yyyyMMdd HH:mm:ss"));
                  temp.AppendText(text);
                  //追加文本
                  richTextBox1.Select(richTextBox1.Rtf.Length, 0);
                  richTextBox1.SelectedRtf = temp.Rtf;
              }
              //设定光标所在位置
              //richTextBox1.SelectionStart = richTextBox1.TextLength;
              //滚动到当前光标处
              //richTextBox1.ScrollToCaret();
          }
      }));
 }
示例#11
0
文件: Form1.cs 项目: DatKami/FEAT
 private void AddLine(RichTextBox RTB, string line)
 {
     if (RTB.InvokeRequired)
         RTB.Invoke(new Action(() => RTB.AppendText(line + Environment.NewLine)));
     else
         RTB.AppendText(line + Environment.NewLine);
 }
示例#12
0
文件: Form1.cs 项目: DatKami/FEAT
 private void AddText(RichTextBox RTB, string msg)
 {
     if (RTB.InvokeRequired)
         RTB.Invoke(new Action(() => RTB.AppendText(msg)));
     else
         RTB.AppendText(msg);
 }
        private void ReceiveChat()
        {
            bool keepalive = true;

            while (keepalive)
            {
                try
                {
                    Byte[] buffer = new Byte[2048];
                    ns.Read(buffer, 0, buffer.Length);
                    string chatter = System.Text.Encoding.ASCII.GetString(buffer);

                    string[] tokens = chatter.Split(new Char[] { '|' });

                    if (tokens[0] == "CHAT")
                    {
                        rtbChatIn.AppendText(tokens[1]);
                        if (logging)
                        {
                            logwriter.WriteLine(tokens[1]);
                        }
                    }
                    if (tokens[0] == "JOIN")
                    {
                        rtbChatIn.AppendText(tokens[1].Trim());
                        rtbChatIn.AppendText(" has joined the Chat\r\n");
                        if (logging)
                        {
                            logwriter.Write(tokens[1]);
                            logwriter.WriteLine(" has joined the Chat");
                        }
                        //string newguy = tokens[1].Trim(new char[]{'\r','\n'});
                        lbChatters.Items.Add(tokens[1].Trim(new char[] { '\r', '\n' }));
                    }
                    if (tokens[0] == "GONE")
                    {
                        rtbChatIn.AppendText(tokens[1].Trim());
                        rtbChatIn.AppendText(" has left the Chat\r\n");
                        if (logging)
                        {
                            logwriter.Write(tokens[1]);
                            logwriter.WriteLine(" has left the Chat");
                        }
                        lbChatters.Items.Remove(tokens[1].Trim(new char[] { '\r', '\n' }));
                    }
                    if (tokens[0] == "QUIT")
                    {
                        ns.Close();
                        clientsocket.Close();
                        keepalive             = false;
                        statusBar1.Text       = "Server has stopped";
                        connected             = false;
                        btnSend.Enabled       = false;
                        btnDisconnect.Enabled = false;
                    }
                }
                catch (Exception e) {}
            }
        }
示例#14
0
        void SelectCa(int n)
        {
            if (m_cab == null || m_cab.GetType() != m_atype[n])
            {
                m_cab = (CaBase)System.Activator.CreateInstance(m_atype[n]);
            }

            m_labelDescription.Text = Helper.GetDescription(m_cab.GetType());

            m_richTextBox.Clear();

            // String replacement, order independent

            string str = m_cab.GetString();

            CaType[] acat = m_cab.GetTypes();
            for (int j = 0; j < acat.Length; j++)
            {
                str = str.Replace("$" + (j + 1), "~" + j + acat[j].ToString() + "~" + j);
            }

            // Save this away for hittesting purposes

            m_strParse = (string)str.Clone();

            // && delimited pieces are links

            while (str.Length != 0)
            {
                int ichT = str.IndexOf("~");
                if (ichT == -1)
                {
                    m_richTextBox.AppendText(str);
                    break;
                }
                if (ichT != 0)
                {
                    m_richTextBox.AppendText(str.Substring(0, ichT));
                }
                str = str.Remove(0, ichT + 2);

                // Now add the underlined text

                int ichStart = m_richTextBox.TextLength;
                int cchLink  = str.IndexOf("~");
                Debug.Assert(cchLink != -1);
                m_richTextBox.AppendText(str.Substring(0, cchLink));
                str = str.Remove(0, cchLink + 2);
                m_richTextBox.Select(ichStart, cchLink);
                Color clr = m_richTextBox.SelectionColor;
                Font  fnt = m_richTextBox.SelectionFont;
                m_richTextBox.SelectionColor = Color.Blue;
                m_richTextBox.SelectionFont  = new Font(fnt.FontFamily, fnt.Size, /* FontStyle.Bold | */ FontStyle.Underline);
                m_richTextBox.Select(m_richTextBox.TextLength, 0);
                m_richTextBox.SelectionFont  = fnt;
                m_richTextBox.SelectionColor = clr;
            }
        }
示例#15
0
 private void ftpc_Message(object sender, FTPCom.FTPEventArgs e)
 {
     TextLog.SelectionColor = Color.Green;
     if (e.Message != string.Empty)
     {
         TextLog.AppendText(e.Message);
     }
     TextLog.AppendText(Environment.NewLine);
 }
示例#16
0
        //******************************************************************
        #region [T(), B() and P() Methods]
        //******************************************************************
        /// <summary>
        /// Appends the given string to the RichTextBox as regular text.
        /// </summary>
        private void T(string sString)
        {
            Font oFont = new Font(moRichTextBox.Font, FontStyle.Regular);

            moRichTextBox.Select(moRichTextBox.TextLength, 0);
            moRichTextBox.SelectionFont = oFont;
            moRichTextBox.AppendText(sString);
            moRichTextBox.Select(0, 0);
        }
示例#17
0
 /// <summary>
 /// The LogIncomingMessageToForm
 /// </summary>
 /// <param name="msg">The msg<see cref="String"/></param>
 internal void LogIncomingMessageToForm(String msg)
 {
     Invoke(new Action(() =>
     {
         //String message = String.Format("{0} - {1}", GetTimeStamp(DateTime.Now), msg);
         richTextRxMessage.AppendText(msg);
         richTextRxMessage.AppendText(Environment.NewLine); // Only works as a seperate append...
         richTextRxMessage.ScrollToCaret();
     }));
 }
示例#18
0
    public static void AppendText(this System.Windows.Forms.RichTextBox box, string text, Color color)
    {
        box.SelectionStart  = box.TextLength;
        box.SelectionLength = 0;

        box.SelectionColor = System.Drawing.Color.FromArgb(color.A, color.R, color.G, color.B);
        box.AppendText(text);
        box.SelectionColor = box.ForeColor;
        box.AppendText(Environment.NewLine);
    }
示例#19
0
        /// <summary>
        /// The LogIncomingMessageToForm
        /// </summary>
        /// <param name="clientId">The clientId<see cref="String"/></param>
        /// <param name="msg">The msg<see cref="String"/></param>
        internal void LogIncomingMessageToForm(String clientId, String msg)
        {
            String message = AddMetaToMessage(clientId, msg);

            Invoke(new Action(() =>
            {
                richTextBoxReceivedMsg.AppendText(message);
                richTextBoxReceivedMsg.AppendText(Environment.NewLine); // Only works as a seperate append...
                richTextBoxReceivedMsg.ScrollToCaret();
            }));
        }
示例#20
0
        public void RefreshLog()
        {
            RichTextBoxConsole.Clear();

            //lock(Login.ConsoleText.SyncRoot)
            foreach (string message in (Queue)Core.ConsoleText)
            {
                //if( !entry.Packet || (entry.Packet && ShowPackets))
                RichTextBoxConsole.AppendText(message + "\n");
            }
        }
示例#21
0
 public void Log(string log)
 {
     if (txtLog.InvokeRequired)
     {
         txtLog.Invoke(new LogDelegate(Log), log);
     }
     else
     {
         txtLog.AppendText("# " + log + "\r\n");
         txtLog.SelectionStart = txtLog.Text.Length;
         txtLog.ScrollToCaret();
     }
 }
示例#22
0
        //Wypisz na konsoli
        private void ConsoleMessage(System.Windows.Forms.RichTextBox richTextBox, string text, System.Drawing.Color color, bool newLine = true)
        {
            var startIndex = richTextBox.TextLength;

            richTextBox.AppendText(text);
            if (newLine)
            {
                richTextBox.AppendText(Environment.NewLine);
            }
            var endIndex = richTextBox.TextLength;

            richTextBox.Select(startIndex, endIndex - startIndex);
            richTextBox.SelectionColor = color;
        }
示例#23
0
        public static void SetText(string text, RichTextBox tb)
        {
            if (tb.InvokeRequired)
            {
                SetTextCallback d = new SetTextCallback(SetText);
                tb.Invoke(d, new object[] { text, tb });

            }
            else
            {
                tb.AppendText(text);
                tb.AppendText("\r\n");
            }
        }
示例#24
0
        /// <summary>
        /// We use the Math.Round method since none of the transforms are exact.
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        private void ComparePoints(string msg, DPoint p1, DPoint p2)
        {
            int prec = 5;

            if (Math.Round(p1.x, prec) == Math.Round(p2.x, prec) &&
                Math.Round(p1.y, prec) == Math.Round(p2.y, prec))
            {
                outputTextBox.AppendText(msg + " points are equal: (" + Math.Round(p1.x, prec) + ", " + Math.Round(p1.y, prec) + ") == (" + Math.Round(p2.x, prec) + ", " + Math.Round(p2.y, prec) + ")\n");
            }
            else
            {
                outputTextBox.AppendText(msg + " points are NOT equal: (" + Math.Round(p1.x, prec) + ", " + Math.Round(p1.y, prec) + ") != (" + Math.Round(p2.x, prec) + ", " + Math.Round(p2.y, prec) + ")\n");
            }
        }
示例#25
0
        public void DrawString()
        {
            RichTextBox richTextBox1 = new RichTextBox();
            richTextBox1.Font = new Font("Consolas", 18f, FontStyle.Bold);
            richTextBox1.BackColor = Color.AliceBlue;

            string sentence = "    Welcome To Secure Computer Program";
            richTextBox1.AppendText(sentence);
            richTextBox1.SelectionBackColor = Color.AliceBlue;
            richTextBox1.AppendText(" ");
            richTextBox1.Width += 500;
            richTextBox1.Height = 40;
            Controls.Add(richTextBox1);
        }
示例#26
0
        void MenuToolsCountClick(object sender, System.EventArgs e)
        {
            string u = Convert.ToString(pi.countMindMemory());

            outputBox.AppendText("Bot's current memory size: " + u + " \n");
            presentLine++;
        }
示例#27
0
        private void txtTextBox_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            if (_dlg.WindowState != FormWindowState.Normal)
            {
                return;
            }

            if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down)
            {
                if (_dlg.ListBoxData.Items.Count > 0)
                {
                    if (e.KeyCode == Keys.Down)
                    {
                        if (_dlg.ListBoxData.SelectedIndex < _dlg.ListBoxData.Items.Count - 1)
                        {
                            _dlg.ListBoxData.SelectedIndex = _dlg.ListBoxData.SelectedIndex + 1;
                        }
                    }
                    else
                    {
                        if (_dlg.ListBoxData.SelectedIndex > 0)
                        {
                            _dlg.ListBoxData.SelectedIndex = _dlg.ListBoxData.SelectedIndex - 1;
                        }
                    }
                }
            }

            if (e.KeyCode == Keys.Escape)
            {
                _dlg.Hide();
                _dlg.WindowState = FormWindowState.Minimized;
                txtTextBox.Focus();
            }

            if (e.KeyCode == Keys.Enter)
            {
                string ss = ProcessText();

                _flag           = false;
                txtTextBox.Text = "";
                txtTextBox.AppendText(ss);
                _flag = true;

                _dlg.Hide();
                _dlg.WindowState = FormWindowState.Minimized;
                txtTextBox.Focus();
            }
        }
示例#28
0
        private void button2_Click(object sender, EventArgs e)
        {
            System.Registro.Solicitud solicitud = new System.Registro.Solicitud();
            solicitud.RegistrandoSolicitud += new System.Registro.Solicitud.DlgRegistrandoSolicitud(RegistrandoSolicitudEvent);

            txtRegistroLog.Text = "";
            txtRegistroLog.AppendText("Registrando solicitud...*\n");

            solicitud.Cantidad        = int.Parse(txtCantidad.Text);
            solicitud.Precio          = int.Parse(txtPrecio.Text);
            solicitud.TipoDeSolicitud = (System.Registro.Solicitud.Tipo)Enum.Parse(typeof(System.Registro.Solicitud.Tipo), cmbTipoDeSolicitudes.Text);
            solicitud.Registrar();
            System.Registro.RepositorioSolicitud.Guardar(solicitud);
            MessageBox.Show("Solicitud Registrada!");
        }
示例#29
0
        /// <summary>
        /// Displays message to the user in a RichTextBox Control</summary>
        /// <param name="messageType">Message type, which modifies display of message</param>
        /// <param name="message">Text message to display</param>
        /// <param name="textBox">RichTextBox in which to display message</param>
        protected override void OutputMessage(OutputMessageType messageType, string message, RichTextBox textBox)
        {
            Color c;
            string messageTypeText;
            Font font;

            switch (messageType)
            {
                case OutputMessageType.Error:
                    c = Color.Red;
                    messageTypeText = "Danger!";
                    font = s_errorFont;
                    break;
                case OutputMessageType.Warning:
                    c = Color.Orange;
                    messageTypeText = "Careful.";
                    font = s_warningFont;
                    break;
                default:
                    c = Color.Beige;
                    messageTypeText = "<Yawn>";
                    font = Font;
                    break;
            }

            textBox.SelectionFont = font;
            textBox.SelectionColor = c;
            textBox.AppendText(messageTypeText + ": " + message);
        }
 void ButtonSendMsgClick(object sender, System.EventArgs e)
 {
     try
     {
         // Send txStr string buffer instead of
         // RichTextBox string
         Object objData = this.txStr;
         richTextBoxSendMsg.AppendText("Sending " + this.txStr.Length + " chars.\n");
         byte[] byData = System.Text.Encoding.ASCII.GetBytes(objData.ToString());
         for (int i = 0; i < m_clientCount; i++)
         {
             if (m_workerSocket[i] != null)
             {
                 if (m_workerSocket[i].Connected)
                 {
                     m_workerSocket[i].Send(byData);
                 }
             }
         }
     }
     catch (SocketException se)
     {
         MessageBox.Show(se.Message);
     }
 }
示例#31
0
        private void previewclick(object sender, EventArgs e)
        {
            string sResult = "";

            if (GenerateResults != null)
            {
                sResult = GenerateResults();
            }


//
            if (sResult != Constants.BLANK)
            {
                richTextBox1.Visible = true;
                label1.Visible       = true;
                panel1.Visible       = true;
                richTextBox1.Text    = "";
                sResult = sResult.Trim();
                if (sResult != null && sResult != "")
                {
                    sResult = sResult + "\n";                     // the trim removes the \n
                    richTextBox1.AppendText(sResult);
                }
            }
        }
示例#32
0
        private void recieve()
        {
            sock = listener.AcceptSocket();
            if (sock.Connected)
            {
                //statusBarPanel1.Text="与客户建立连接";
                //string str=richTextBox1.Text;
                string str   = "";
                byte[] bytee = System.Text.Encoding.BigEndianUnicode.GetBytes(str.ToCharArray());
                sock.Send(bytee, bytee.Length, 0);

                //接受信息++++
                while (!control)
                {
                    NetworkStream stream = new NetworkStream(sock);
                    byte[]        by     = new Byte[1024];
                    int           i      = sock.Receive(by, by.Length, 0);
                    string        ss     = System.Text.Encoding.BigEndianUnicode.GetString(by);

                    richTextBox2.AppendText(ss);
                    j = richTextBox2.Lines.Length;

                    if (j >= 2)
                    {
                        transfer(ref stream);
                    } //对应于if(j>=2)的“{”
                }     //对应于while(!control)的“{”
            }         //对应于if(sock.Connected)的“{”
        }             //对应于private void recieve()的“{”
示例#33
0
 void AddText(string s)
 {
     try
     {
         RTFText.AppendText(s);
     }
     catch (Exception)
     {
         System.Threading.Thread.Sleep(1000);
         try
         {
             RTFText.AppendText(s);
         }
         catch (Exception) {}
     }
 }
示例#34
0
 //<Snippet1>
 private void WriteOffsetTextToRichTextBox()
 {
     // Clear all text from the RichTextBox.
     richTextBox1.Clear();
     // Set the font for the text.
     richTextBox1.SelectionFont = new Font("Lucinda Console", 12);
     // Set the foreground color of the text.
     richTextBox1.SelectionColor = Color.Purple;
     // Set the baseline text.
     richTextBox1.SelectedText = "10";
     // Set the CharOffset to display superscript text.
     richTextBox1.SelectionCharOffset = 10;
     // Set the superscripted text.
     richTextBox1.SelectedText = "2";
     // Reset the CharOffset to display text at the baseline.
     richTextBox1.SelectionCharOffset = 0;
     richTextBox1.AppendText("\n\n");
     // Change the forecolor of the next text selection.
     richTextBox1.SelectionColor = Color.Blue;
     // Set the baseline text.
     richTextBox1.SelectedText = "77";
     // Set the CharOffset to display subscript text.
     richTextBox1.SelectionCharOffset = -10;
     // Set the subscripted text.
     richTextBox1.SelectedText = "3";
     // Reset the CharOffset to display text at the baseline.
     richTextBox1.SelectionCharOffset = 0;
 }
示例#35
0
        public void BookingLockoutsForDate(RichTextBox rtb, DateTime date)
        {
            rtb.Text = "";
            var unitOfWork = new UnitOfWork();
            var today = date.Date;
            var notes = unitOfWork.LockedOutDateRepository.Get(x => today < x.EndDate && today > x.StartDate,includeProperties:"LockOutTimes");

            notes = notes.OrderBy(x => x.DateCreated);
            if (notes.Count() > 0)
            {

                rtb.AppendBoldColoredLine("Locked:", System.Drawing.Color.Red);
                int i = 1;
                foreach (var note in notes)
                {
                    rtb.AppendBoldColoredLine(i + ". " + note.Name, System.Drawing.Color.Red);
                    string reason = note.Reason;

                    rtb.AppendLine(reason);
                    if (note.LockOutTimes.Count>0)
                    {
                        foreach(var v in note.LockOutTimes)
                        {
                            rtb.AppendText(v.StartTime.ToShortTimeString() + " - "+ v.EndTime.ToShortTimeString()+", " );

                        }
                    }
                }

            }
        }
        // This the call back function which will be invoked when the socket
        // detects any client writing of data on the stream
        public void OnDataReceived(IAsyncResult asyn)
        {
            try
            {
                SocketPacket socketData = (SocketPacket)asyn.AsyncState;

                int iRx = 0;
                // Complete the BeginReceive() asynchronous call by EndReceive() method
                // which will return the number of characters written to the stream
                // by the client
                iRx = socketData.m_currentSocket.EndReceive(asyn);
                char[] chars          = new char[iRx + 1];
                System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
                int charLen           = d.GetChars(socketData.dataBuffer,
                                                   0, iRx, chars, 0);
                System.String szData = new System.String(chars);
                richTextBoxReceivedMsg.AppendText(szData);

                // Continue the waiting for data on the Socket
                WaitForData(socketData.m_currentSocket);
            }
            catch (ObjectDisposedException)
            {
                System.Diagnostics.Debugger.Log(0, "1", "\nOnDataReceived: Socket has been closed\n");
            }
            catch (SocketException se)
            {
                MessageBox.Show(se.Message);
            }
        }
 public void dodajWiadomosc(RichTextBox rt, string w)
 {
     if (rt.InvokeRequired)
         rt.BeginInvoke(new Action<RichTextBox, string>(dodajWiadomosc), rt, w);
     else
         rt.AppendText(w + Environment.NewLine);
 }
示例#38
0
 public void wyswietl(RichTextBox o, string tekst)
 {
     o.Focus();
     o.AppendText(tekst);
     o.ScrollToCaret();
     txtWysylane.Focus();
 }
示例#39
0
        public static void InitializeCompile(ISynchronizeInvoke _isi, RichTextBox _rtMain, Button _Compile)
        {
            CompileRich     = _rtMain;
            MainForm        = _isi;
            CompileButton   = _Compile;

            if (!Directory.Exists("Source"))
                Directory.CreateDirectory("Source");

            if (Settings.Default.CoreGit == "")
            {
                CompileRich.AppendText("Core will not compile\nReason: No Core git settings");
                CompileButton.Enabled = true;
                return;
            }

            if (!File.Exists("Source\\Core\\CMakeLists.txt"))
                CloneGit(GitTypes.Core);
            else
                PullGit(GitTypes.Core);

            if (!Directory.Exists("Database"))
                CloneGit(GitTypes.Database);
            else
                PullGit(GitTypes.Database);
        }
示例#40
0
        private void btnAdd_Click(object sender, System.EventArgs e)
        {
            string cSharpCode = "";

            switch (this.cmbAPITypes.Text)
            {
            case "Types":
                cSharpCode = structViewer.GetCSharpSyntax(lstAvailableFuncs.SelectedIndex);
                break;

            case "Declares":
                cSharpCode = dllImportViewer.GetCSharpSyntax(lstAvailableFuncs.SelectedIndex);
                break;

            case "Constants":
                cSharpCode = constViewer.GetCSharpSyntax(lstAvailableFuncs.SelectedIndex);
                break;
            }
            if (rdPrivate.Checked)
            {
                cSharpCode = cSharpCode.Replace(APIUtility.CSHP_SCOPE, rdPrivate.Text.ToLower());
            }
            else
            {
                cSharpCode = cSharpCode.Replace(APIUtility.CSHP_SCOPE, rdPublic.Text.ToLower());
            }

            if (txtSelected.Text.IndexOf(cSharpCode) < 0)
            {
                txtSelected.AppendText(cSharpCode + "\n");
            }
        }
示例#41
0
        protected void InternalLog(Color foreColor, string fmt, params object[] args)
        {
            if (LogViewer.InvokeRequired)
            {
                if (_Log == null)
                {
                    _Log = new LogHandler(InternalLog);
                }

                LogViewer.Invoke(_Log, new object [] { foreColor, fmt, args });
            }
            else
            {
                string msg = LogMessage(fmt, args);
                msg = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss.fff") + " " + msg;

                FileWriter.Write(msg);
                FileWriter.Flush();

                LogViewer.SelectionLength = 0;
                int start = LogViewer.TextLength;
                LogViewer.AppendText(msg);
                LogViewer.Select(start, msg.Length);
                LogViewer.SelectionColor = foreColor;
            }
        }
示例#42
0
        //写日志
        public void Writelog(string logstr)
        {
            FileStream    fs     = new FileStream(m_strInitXmlPath, FileMode.OpenOrCreate, FileAccess.ReadWrite);
            StreamReader  reader = new StreamReader(fs, Encoding.GetEncoding("gb2312"));
            List <string> list   = new List <string>();
            string        strread;

            while ((strread = reader.ReadLine()) != null)
            {
                list.Add(strread);
            }
            reader.Close();

            string strTime = DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + " " + DateTime.Now.ToLongTimeString();

            if (m_tipRichBox != null)
            {
                m_tipRichBox.AppendText(strTime + "/" + logstr + "\r\n");
            }
            for (int i = 0; i < list.Count; i++)
            {
                strread += list[i] + "\r\n";
            }
            strread = DateTime.Now.ToString() + "/" + logstr + "\r\n" + strread;
            StreamWriter sw = new StreamWriter(m_strInitXmlPath, false, Encoding.GetEncoding("gb2312"));

            sw.Write(strread);
            sw.Close();
            fs.Close();
            sw = null;
            fs = null;
        }
示例#43
0
        public ViewDictionary()
        {
            Form viewDictionaryForm = new Form();
            viewDictionaryForm.StartPosition = FormStartPosition.CenterScreen;
            viewDictionaryForm.FormBorderStyle = FormBorderStyle.Fixed3D;
            viewDictionaryForm.Size = new Size(250, 185);
            viewDictionaryForm.MinimizeBox = false;
            viewDictionaryForm.MaximizeBox = false;
            viewDictionaryForm.Text = "Просмотр переводчика";
            #endregion

            RichTextBox richText = new RichTextBox();
            richText.Location = new Point(10, 10);
            richText.Size = new Size(215, 105);
            richText.ScrollBars = RichTextBoxScrollBars.ForcedVertical;
            richText.ReadOnly = true;
            for (int i = 0; i < ruText.Length; i++)
            {
                ruText[i] = File.ReadAllLines("ru.txt")[i];
                ukrText[i] = File.ReadAllLines("ukr.txt")[i];
                richText.AppendText(ruText[i] + " - " + ukrText[i] + "\n");
            }
            viewDictionaryForm.Controls.Add(richText);

            Button closeButton = new Button();
            closeButton.Location = new Point(150, 120);
            closeButton.Size = new Size(75, 25);
            closeButton.Text = "Закрыть";
            closeButton.DialogResult = DialogResult.OK;
            viewDictionaryForm.Controls.Add(closeButton);

            viewDictionaryForm.ShowDialog();
        }
示例#44
0
        public ServerTab(ServerManager manager, PBUCONServer server)
        {
            this.manager = manager;
            this.server = server;

            // Create console box
            rtb = new RichTextBox();
            rtb.Anchor = ((AnchorStyles)((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right)));
            rtb.BackColor = SystemColors.ControlLight;
            rtb.Font = new Font("Consolas", 9F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(0)));
            rtb.ForeColor = SystemColors.WindowText;
            rtb.Location = new Point(7, 7);
            rtb.ReadOnly = true;
            rtb.ScrollBars = RichTextBoxScrollBars.Vertical;
            rtb.Size = new Size(839, 354);
            rtb.TabIndex = 0;

            // Create send button
            sendButton = new Button();
            sendButton.Anchor = ((AnchorStyles)((AnchorStyles.Bottom | AnchorStyles.Right)));
            sendButton.Font = new Font("Segoe UI", 9F);
            sendButton.Location = new Point(771, 367);
            sendButton.Size = new Size(75, 23);
            sendButton.TabIndex = 2;
            sendButton.Text = "Send";
            sendButton.UseVisualStyleBackColor = true;
            sendButton.Click += new EventHandler(sendButton_Click);

            // Create command bar
            commandBox = new TextBox();
            commandBox.Anchor = ((AnchorStyles)(((AnchorStyles.Bottom | AnchorStyles.Left) | AnchorStyles.Right)));
            commandBox.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            commandBox.Location = new Point(7, 367);
            commandBox.Size = new Size(758, 23);
            commandBox.TabIndex = 1;
            commandBox.KeyPress += new KeyPressEventHandler(commandBox_KeyPress);

            // Create tab page that holds everything
            tab = new TabPage();
            tab.ImageIndex = 0;
            tab.Location = new Point(4, 23);
            tab.Name = server.Name;
            tab.Padding = new Padding(3);
            tab.Size = new Size(852, 396);
            tab.TabIndex = 0;
            tab.Text = server.Name;
            tab.UseVisualStyleBackColor = true;

            tab.Controls.Add(rtb);
            tab.Controls.Add(commandBox);
            tab.Controls.Add(sendButton);

            // Add events to the server
            server.NewMessage += NewMessage;
            server.ServerChallengeChanged += ChallengeChange;

            // Show the client challenge
            rtb.AppendText("Client challenge: " + server.ClientChallenge.ToString("X8") + "\n");
        }
示例#45
0
文件: MainForm.cs 项目: rmc47/K3Key
 private void AppendText(RichTextBox box, string text)
 {
     Invoke(new MethodInvoker(() =>
     {
         box.AppendText(text + "\r\n");
         box.ScrollToCaret();
     }));
 }
示例#46
0
        void ShowNotification(string Header, string Body, int Duration)
        {
            List<string> Messages = new List<string>();

            RichTextBox Box = new RichTextBox();
            Box.Font = new Font("Tahoma", 8.25F);
            Box.SelectionColor = Color.FromArgb(204, 0, 0);
            Box.SelectionFont = new Font(Box.Font, FontStyle.Bold);
            Box.AppendText(Header);
            Box.SelectionColor = Box.ForeColor;
            Box.SelectionFont = Box.Font;
            Box.AppendText("\r\n" + Body);

            Messages.Add(Box.Rtf);

            ShowNotification(Messages, Duration);
        }
示例#47
0
 public RichTextBox erro(RichTextBox objeto, string valor)
 {
     objeto.AppendText(valor);
     objeto.SelectionStart = objeto.TextLength - valor.Length;
     objeto.SelectionLength = valor.Length;
     objeto.SelectionColor = Color.Red;
     return objeto;
 }
示例#48
0
 public void Appender(string text, Color cor, RichTextBox campo)
 {
     campo.SelectionStart = campo.TextLength;
     campo.SelectionLength = 0;
     campo.SelectionColor = cor;
     campo.AppendText(text);
     campo.SelectionColor = campo.ForeColor;
 }
示例#49
0
        public static void AppendTextWithColor(ref RichTextBox box, string text, Color color)
        {
            box.SelectionStart = box.TextLength;
            box.SelectionLength = 0;

            box.SelectionColor = color;
            box.AppendText(text);
            box.SelectionColor = box.ForeColor;
        }
示例#50
0
 public RichTextBox alert(RichTextBox objeto, string valor)
 {
     objeto.AppendText(valor);
     objeto.SelectionStart = objeto.TextLength - valor.Length;
     objeto.SelectionLength = valor.Length;
     objeto.SelectionColor = System.Drawing.Color.FromArgb(221, 245, 65);
     Console.WriteLine("Alertando: {0}",valor);
     return objeto;     
 }
示例#51
0
 void AppendText(RichTextBox box, Color color, string text)
 {
     int start = box.TextLength;
     box.AppendText(text);
     int end = box.TextLength;
     box.Select(start, end-start);
     box.SelectionColor = color;
     box.SelectionLength = 0;
 }
示例#52
0
 public void appendTextBox(RichTextBox textBox, string strInput, Color fontColor, Font fontType)
 {
     int p1 = textBox.TextLength;            //取出未添加时的字符串长度
     textBox.AppendText(strInput);           //保留每行的所有颜色
     int p2 = strInput.Length;               //取出要添加的文本的长度
     textBox.Select(p1, p2);                 //选中要添加的文本
     textBox.SelectionColor = fontColor;     //设置要添加的文本的字体色
     textBox.SelectionFont = fontType;       //设置要添加的文本的字体
 }
示例#53
0
 //========================================================================== MENSAGENS ====================================================================
     public RichTextBox sucess( RichTextBox objeto,string valor)
     {
         objeto.AppendText(valor);
         objeto.SelectionStart = objeto.TextLength - valor.Length ;
         objeto.SelectionLength = valor.Length;
         objeto.SelectionColor = Color.Green;
         Console.WriteLine("Concluido: {0}", valor);
         return objeto;
     }
示例#54
0
 void Append(RichTextBox rtb, string message)
 {
     rtb.AppendText(message);
     if (rtb.TextLength > 2048) {
         rtb.Text = rtb.Text.Substring(rtb.TextLength - 2048);
     }
     rtb.SelectionStart = rtb.TextLength;
     rtb.ScrollToCaret();
 }
示例#55
0
        private void AddText(RichTextBox box, string text, Color color)
        {
            box.SelectionStart = box.TextLength;
            box.SelectionLength = 0;

            box.SelectionColor = color;
            box.AppendText(text);
            box.SelectionColor = box.ForeColor;
        }
        public DataTable exec_Sql(string sql, NpgsqlConnection conn,RichTextBox t)
        {
            DataTable dt = new DataTable();
            try
            {

                NpgsqlCommand cmd = new NpgsqlCommand(sql, conn);
                NpgsqlDataReader r;

                r = cmd.ExecuteReader();
                if (r.HasRows)
                {
                    dt.Load(r);
                    r.Close();
                }
                r.Close();

                int length = t.TextLength;
                string msg = "Succesfull Query!";
                t.AppendText(DateTime.Now + " "+msg + "\n");

                t.SelectionStart = length;
                int flength = msg.Length + DateTime.Now.ToString().Length + 1;
                t.SelectionLength = flength;
                t.SelectionColor = Color.Green;
                t.ScrollToCaret();

            }
            catch (Exception ex)
            {
                int length = t.TextLength;

               t.AppendText(DateTime.Now + " " + ex.Message + "\n");

                t.SelectionStart = length;
                int flength = ex.Message.Length + DateTime.Now.ToString().Length + 1;
                t.SelectionLength = flength;
                t.SelectionColor = Color.Red;
                t.ScrollToCaret();

            }

            return dt;
        }
        public void UyariGoster(string msj, RichTextBox txtMesajlar)
        {
            if (txtMesajlar.Text != "")
            {
                txtMesajlar.AppendText("\r\n");
            }

            Yazdir("Bilgi: " + msj, adtarihFontColor, adtarihFont, adtarihKertmeDegeri, "", txtMesajlar);
            txtMesajlar.ScrollToCaret();
        }
示例#58
0
        private void AddText(RichTextBox box, string text, Color color, FontStyle font)
        {
            box.SelectionStart = box.TextLength;
            box.SelectionLength = 0;

            box.SelectionColor = color;
            box.SelectionFont = new Font(box.Font.FontFamily, box.Font.Size, font);
            box.AppendText(text);
            box.SelectionColor = box.ForeColor;
        }
示例#59
0
 public static void AppendText(RichTextBox box, string line)
 {
     try
     {
         box.AppendText(line + Environment.NewLine);
         ScrollRichTextBox(box);
     }
     catch
     {
     }
 }
示例#60
0
 public static void AppendText(RichTextBox box, string text, Color color)
 {
     box.SelectionStart = box.TextLength;
     box.SelectionLength = 0;
     box.SelectionColor = color;
     box.AppendText(text);
     box.SelectionColor = box.ForeColor;
     box.SelectionStart = box.TextLength;
     box.ScrollToCaret();
     box.Refresh();
 }