Пример #1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            for (int i = 0; i < people.Length(); i++)
            {
                RichTextBox1.AppendText("Игрок " + people[i].Name + " набрал " + people[i].Sum + " очков" + "\n");
            }

            var array     = new int[0];
            var pobeditel = Pobed(0, 0, array);

            RichTextBox1.Clear();
            for (int i = 0; i < people.Length(); i++)
            {
                RichTextBox1.AppendText("Игрок " + people[i].Name + " набрал " + people[i].Sum + " очков" + "\n");
            }

            TextBox1.Text = "Игрок " + pobeditel + " победил";
            Single single = new Single();

            try
            {
                single.Addbd(people);
            }
            catch
            {
                MessageBox.Show("Нет соединения");
            }
        }
Пример #2
0
 private void SaveToolStripButton_Click(object sender, EventArgs e)
 {
     try
     {
         if (IsSaved == false)
         {
             if (Saved)
             {
                 RichTextBox1.SaveFile(FileName);
             }
             else
             {
                 SaveFileDialog1.FileName = FileName;
                 if (SaveFileDialog1.ShowDialog() == DialogResult.OK)
                 {
                     FileName = SaveFileDialog1.FileName;
                     RichTextBox1.SaveFile(FileName);
                     IsSaved = true;
                     Saved   = true;
                 }
             }
         }
     }
     catch
     {
         return;
     }
 }
Пример #3
0
        // リッチテキストを保存
        private void ButtonSave_Click(System.Object sender, System.EventArgs e)
        {
            // SaveFileDialogクラスのインスタンスを作成
            SaveFileDialog sfd = new SaveFileDialog();

            // はじめのファイル名を指定する
            // はじめに「ファイル名」で表示される文字列を指定する
            sfd.FileName = "新しいファイル.rtf";
            // はじめに表示されるフォルダを指定する
            // 指定しない(空の文字列)の時は、現在のディレクトリが表示される
            // sfd.InitialDirectory = "C:\"
            // [ファイルの種類]に表示される選択肢を指定する
            sfd.Filter = "リッチテキストファイル(*.rtf)|*.rtf|すべてのファイル(*.*)|*.*";
            // [ファイルの種類]ではじめに選択されるものを指定する
            // 2番目の「すべてのファイル」が選択されているようにする
            sfd.FilterIndex = 1;
            // タイトルを設定する
            sfd.Title = "保存先のファイルを選択してください";
            // ダイアログボックスを閉じる前に現在のディレクトリを復元するようにする
            sfd.RestoreDirectory = true;
            // 既に存在するファイル名を指定したとき警告する
            // デフォルトでTrueなので指定する必要はない
            sfd.OverwritePrompt = true;
            // 存在しないパスが指定されたとき警告を表示する
            // デフォルトでTrueなので指定する必要はない
            sfd.CheckPathExists = true;
            // ダイアログを表示する
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                // OKボタンがクリックされたとき、選択されたファイル名を表示する
                Console.WriteLine(sfd.FileName);
                RichTextBox1.SaveFile(sfd.FileName, RichTextBoxStreamType.RichText);
            }
        }
Пример #4
0
        private void window_Loaded(object sender, RoutedEventArgs e)
        {
            var sbText   = new StringBuilder();
            var assembly = Assembly.GetEntryAssembly();

            if (assembly != null)
            {
                var attributes = assembly.GetCustomAttributes(false);
                foreach (var attribute in attributes)
                {
                    var type = attribute.GetType();
                    if (type == typeof(AssemblyTitleAttribute))
                    {
                        var title = (AssemblyTitleAttribute)attribute;
                        LabelAssemblyName.Content = title.Title;
                    }
                    if (type == typeof(AssemblyFileVersionAttribute))
                    {
                        var version = (AssemblyFileVersionAttribute)attribute;
                        LabelAssemblyVersion.Content = version.Version;
                    }
                    if (type == typeof(AssemblyCopyrightAttribute))
                    {
                        var copyright = (AssemblyCopyrightAttribute)attribute;
                        sbText.AppendFormat("{0}\r", copyright.Copyright);
                    }
                    if (type == typeof(AssemblyCompanyAttribute))
                    {
                        var company = (AssemblyCompanyAttribute)attribute;
                        sbText.AppendFormat("{0}\r", company.Company);
                    }
                    if (type == typeof(AssemblyDescriptionAttribute))
                    {
                        var description = (AssemblyDescriptionAttribute)attribute;
                        sbText.AppendFormat("{0}\r", description.Description);
                    }
                }
                LabelAssembly.Content = sbText.ToString();
            }
// ReSharper disable VerbatimStringLiteralsWordIsNotInDictionary
            const string text = @"<log4net>
  <appender name=""RollingFileAppender"" type=""log4net.Appender.RollingFileAppender"">
    <file type=""log4net.Util.PatternString"" value=""c:\log\log.xml"" />
    <appendToFile value=""true"" />
    <datePattern value=""yyyyMMdd"" />
    <rollingStyle value=""Date"" />
    <layout type=""log4net.Layout.XmlLayoutSchemaLog4j"">
      <locationInfo value=""true"" />
    </layout>
  </appender>
  <root>
    <level value=""DEBUG"" />
    <appender-ref ref=""RollingFileAppender"" />
  </root>
</log4net>";

// ReSharper restore VerbatimStringLiteralsWordIsNotInDictionary

            RichTextBox1.AppendText(text);
        }
Пример #5
0
 private void DisplayText(object sender, EventArgs e)
 {
     RichTextBox1.AppendText(rxString);
     RichTextBox1.ScrollToCaret();
     chart1.Series["Series1"].Points.AddXY(a, Convert.ToInt16(rxString));
     a++;
 }
Пример #6
0
 public void Log(string format, params string[] message)
 {
     Dispatcher.Invoke(delegate {
         RichTextBox1.AppendText(string.Format(format, message));
         RichTextBox1.AppendText("\n");
     });
 }
Пример #7
0
        //Button1のClickイベントハンドラ:データ受信の待機
        private void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                //UdpClientを作成
                udpClient = new UdpClient(int.Parse(TextBox1.Text));
                //非同期的なデータ受信を開始する
                udpClient.BeginReceive(ReceiveCallback, udpClient);
            }
            catch (SocketException ex)
            {
                Console.WriteLine("受信待機時エラー({0}/{1})",
                                  ex.Message, ex.ErrorCode);
                return;
            }

            string displayMsg = string.Format("[you] > データ受信の待機中 ポート:" + TextBox1.Text);

            RichTextBox1.BeginInvoke(
                new Action <string>(ShowTextboxString), displayMsg);

            //同じポートで2回以上接続開始しないようにボタンを押せなくする
            Button1.Enabled = false;

            //送信ボタンが押せるようにする
            Button2.Enabled = true;
        }
Пример #8
0
        private void OpenFile()
        {
            try
            {
                openFileDialog1.Filter      = "XML Files (*.xml)|*.xml|Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
                openFileDialog1.FilterIndex = 1;
                openFileDialog1.Title       = "Select a file to open";
                openFileDialog1.FileName    = "";
                openFileDialog1.ShowDialog();

                if (openFileDialog1.FileName != "")
                {
                    xmlFileName = openFileDialog1.FileName;

                    txtXmlFile.Text = xmlFileName.Trim();

                    RichTextBox1.LoadFile(openFileDialog1.FileName, RichTextBoxStreamType.PlainText);
                    this.Text = "Xml Editor | " + xmlFileName.Substring(xmlFileName.LastIndexOf("\\") + 1);
                }

                Changed = false;
            }
            catch (Exception ex)
            {
                PepsiLiteErrorHandling.WriteErrorLog(ex.ToString());
            }
        }
Пример #9
0
 public void Log(string message)
 {
     Dispatcher.Invoke(delegate {
         RichTextBox1.AppendText(message);
         RichTextBox1.AppendText("\n");
     });
 }
Пример #10
0
 private void CutToolStripButton_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(RichTextBox1.SelectedText))
     {
         RichTextBox1.Cut();
     }
 }
Пример #11
0
        /// <summary>
        /// 显示序号
        /// </summary>
        private void ShwoNumber()
        {
            System.Windows.Documents.List listx = new System.Windows.Documents.List();
            listx.Margin = new Thickness()
            {
                Left = 3
            };
            // Set the space between the markers and list content to 25 DIP.
            listx.MarkerOffset = 5;
            // Use uppercase Roman numerals.
            listx.MarkerStyle = TextMarkerStyle.Decimal;
            // Start list numbering at 5.
            listx.StartIndex = 1;
            // Create the list items that will go into the list.
            System.Windows.Documents.ListItem liV = new System.Windows.Documents.ListItem(new System.Windows.Documents.Paragraph(new System.Windows.Documents.Run("")));
            // Finally, add the list items to the list.
            listx.ListItems.Add(liV);

            if (RichTextBox1.Document.Blocks.Count == 2)
            {
                RichTextBox1.Document.Blocks.Remove(RichTextBox1.Document.Blocks.LastBlock);
            }

            RichTextBox1.Document.Blocks.Add(listx);

            RichTextBox1.Focus();
            RichTextBox1.CaretPosition = this.RichTextBox1.Document.ContentEnd;
        }
Пример #12
0
 public void SetText(string input)
 {
     RichTextBox1.AppendText(input + Environment.NewLine);
     RichTextBox1.SelectionStart = RichTextBox1.TextLength;
     RichTextBox1.SelectionStart = 0;
     RichTextBox1.ScrollToCaret();
 }
Пример #13
0
        private void FileDrop(object sender, DragEventArgs e)
        {
            string[]     docPath = (string[])e.Data.GetData(DataFormats.FileDrop);
            StreamReader sr      = new StreamReader(docPath[0], Encoding.Default);

            originalText = sr.ReadToEnd();
            RichTextBox1.Document.Blocks.Clear();
            RichTextBox1.AppendText(originalText);
        }
Пример #14
0
 private void Launch_Handler(object sender, ExecutedRoutedEventArgs e)
 {
     RichTextBox1.AppendText((string)textBox.DataContext);
     using (System.IO.StreamWriter writer = new System.IO.StreamWriter("log.txt", true))
     {
         writer.WriteLine("Внесено {0}: {1} ", textBox.ContextMenu, DateTime.Now.ToShortDateString() + ", время: " +
                          DateTime.Now.ToLongTimeString());
         writer.Flush();
     }
 }
        private void cboFontFamilies_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (cboFontFamilies.SelectedItem != null)
            {
                RichTextBox1.Selection.ApplyPropertyValue(TextElement.FontFamilyProperty, cboFontFamilies.SelectedItem);
                RichTextBox1.Focus();
                e.Handled = true;
            }

        }
Пример #16
0
        private void LoadFile(string Filename)
        {
            flag = false;
            StreamReader sr = new StreamReader(Filename, Encoding.Default);

            originalText = sr.ReadToEnd();
            string temp = originalText.Substring(0, 1000);

            RichTextBox1.AppendText(temp);
            index += 1000;
        }
Пример #17
0
        // 添加命令到richtextbox
        private void AddCmd(string cmd)
        {
            Action act = new Action(() =>
            {
                string c = cmd + Environment.NewLine;
                RichTextBox1.AppendText(c);
            }
                                    );

            this.Dispatcher.BeginInvoke(act);
        }
Пример #18
0
 public void LogString(bool isIncoming, string text)
 {
     if (isIncoming)
     {
         RichTextBox1.AppendText(string.Format("IN  : {0}{1}", text, Environment.NewLine));
     }
     else
     {
         RichTextBox1.AppendText(string.Format("OUT : {0}{1}", text, Environment.NewLine));
     }
 }
Пример #19
0
        /// <summary>
        /// 事件--操作事件包括 添加提醒,添加确认,添加序号
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItemOperating_OnClick(object sender, RoutedEventArgs e)
        {
            string header = ((System.Windows.Controls.HeaderedItemsControl)sender).Tag.ToString();

            switch (header)
            {
            case "添加确认":
                SetCheck();
                break;

            case "添加图片":
                AddImage(RichTextBox1);
                break;

            case "添加提醒":
                SetRemind();
                break;

            case "发送给":
                var v = new StringCollection();
                v.Add(CacheFileName);
                Clipboard.SetFileDropList(v);
                MessageBox.Show("复制成功,快去聊天工具上粘贴吧Ctrl+C", "发送给...", MessageBoxButton.OK, MessageBoxImage.Information);
                break;

            case "去格式粘贴":
                //Class1.Text();
                //pgn,jpg两种格式FileDrop

                if (Clipboard.ContainsFileDropList())
                {
                    e.Handled = true;

                    StringCollection stringCollection = Clipboard.GetFileDropList();
                    foreach (string s in stringCollection)
                    {         //如果是图片,则导入图片
                        RichTextBoxTool.RichTextBoxAddImage(RichTextBox1, s, image_MouseDown);
                    }
                    ;
                }
                else if (Clipboard.ContainsText())
                {
                    e.Handled = true;

                    string paste = Clipboard.GetText();
                    Clipboard.SetText(paste);
                    RichTextBox1.Paste();
                    Clipboard.Clear();
                }


                break;
            }
        }
Пример #20
0
        private void File_clicked(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();

            if (ofd.ShowDialog() == true)
            {
                StreamReader sr = new StreamReader(ofd.FileName, Encoding.Default);
                originalText = sr.ReadToEnd();
                RichTextBox1.Document.Blocks.Clear();
                RichTextBox1.AppendText(originalText);
            }
        }
 private void btnSetBulletList_Click(object sender, RoutedEventArgs e)
 {
     List list = GetList();
     list.MarkerStyle = (TextMarkerStyle)Enum.Parse(typeof(TextMarkerStyle), "Box");
     //获取当前选中的字体大小
     Object obj = RichTextBox1.Selection.GetPropertyValue(
                                      FlowDocument.FontSizeProperty);
     //保证项目符号与文字大小一致
     if (obj is double)
         list.FontSize = (double)obj;
     RichTextBox1.Focus();
 }
Пример #22
0
 public void listner()
 {
     try
     {
         while (ServerSocket.Connected)
         {
             byte[] buffer       = new byte[2048];
             int    bytesReceive = ServerSocket.Receive(buffer);
             handleCommand(Encoding.Unicode.GetString(buffer, 0, bytesReceive));
         }
     }
     catch { RichTextBox1.AppendText("\n Связь с сервером прервана"); }
 }
Пример #23
0
        public PopupHelpForm()
        {
            InitializeComponent();
            //現在のコードを実行しているAssemblyを取得
            Assembly myAssembly = Assembly.GetExecutingAssembly();

            //指定されたマニフェストリソースを読み込む
            string[] names = myAssembly.GetManifestResourceNames();

            Stream stream = myAssembly.GetManifestResourceStream("MyScrapBook.help.rtf");

            RichTextBox1.LoadFile(stream, RichTextBoxStreamType.RichText);
        }
Пример #24
0
        //用于实现递归调用的Sub过程
        private void DoRecursion(int times)
        {
            //结束条件
            if (times == 0)
            {
                return;
            }

            //每次递归调用时要完成的工作
            RichTextBox1.AppendText("第 " + times + " 次\n");
            RichTextBox1.AppendText(Story);
            //递归调用,参数减一
            DoRecursion(times - 1);
        }
Пример #25
0
 private void PasteToolStripButton_Click(object sender, EventArgs e)
 {
     try
     {
         if (Clipboard.ContainsText())
         {
             RichTextBox1.Paste();
         }
     }
     catch
     {
         return;
     }
 }
Пример #26
0
 private void Scrolling(object sender, MouseWheelEventArgs e)
 {
     if (flag == false)
     {
         if (e.Delta < 0)
         {
             if (index <= originalText.Length)
             {
                 RichTextBox1.AppendText(originalText.Substring(index - 1000, index));
                 index += 1000;
             }
         }
     }
 }
Пример #27
0
        private void btnWellFormNess_Click(object sender, EventArgs e)
        {
            try
            {
                lstErrors.Items.Clear();

                RichTextBox1.SaveFile(xmlFileName, RichTextBoxStreamType.PlainText);

                IsWellFormedXml = true;

                using (FileStream stream = File.OpenRead(AppDomain.CurrentDomain.BaseDirectory + "PatentEnhancedPrioritySubstanceIndexing-2.3.xsd"))
                {
                    XmlReaderSettings settings = new XmlReaderSettings();

                    XmlSchema schema = XmlSchema.Read(stream, OnXmlSyntaxError);
                    settings.ValidationType = ValidationType.Schema;
                    settings.Schemas.Add(schema);
                    settings.ValidationEventHandler += OnXmlSyntaxError;

                    string strError = "";
                    using (XmlReader validator = XmlReader.Create(txtXmlFile.Text.Trim(), settings))
                    {
                        try
                        {
                            // Validate the entire xml file
                            while (validator.Read())
                            {
                                lineInf = (IXmlLineInfo)validator;
                            }
                        }
                        catch (Exception ex)
                        {
                            if (lineInf.HasLineInfo())
                            {
                                strError = lineInf.LineNumber.ToString() + ": " + lineInf.LinePosition.ToString() + " " + ex.Message;
                            }
                            lstErrors.Items.Add(strError);
                        }
                    }
                }
                if (IsWellFormedXml)
                {
                    MessageBox.Show("Wellformed XML", "Wellformed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                PepsiLiteErrorHandling.WriteErrorLog(ex.ToString());
            }
        }
Пример #28
0
        //按指定的种子Seed生成nums个随机数
        private void GenerateRandomSequence(int nums, float seed)
        {
            float lastNum, nextNum;

            lastNum = seed;
            RichTextBox1.Clear();
            RichTextBox1.AppendText(seed.ToString());
            for (int i = 0; i < nums; i++)
            {
                nextNum = GetNextRanNumber(m, a, c, lastNum);
                RichTextBox1.AppendText(" ," + nextNum);
                lastNum = nextNum;
            }
        }
Пример #29
0
        private void SendButton_Click(object sender, EventArgs e)
        {
            if (OutgoingTextBox.TextLength > 0)
            {
                RichTextBox1.SelectionColor = Color.Blue;
                RichTextBox1.AppendText(string.Format("({0}) Me: ", DateTime.Now.ToString("hh:mm:ss")));
                RichTextBox1.SelectionColor = Color.Black;
                RichTextBox1.AppendText(string.Format("{0}\n", OutgoingTextBox.Text));

                XmppGlobal.Messaging.SendMessage(foreign_jid, OutgoingTextBox.Text, message_type, thread_id);
                OutgoingTextBox.Text = string.Empty;
                XmppSounds.PlaySound(DefaultSounds.MessageIn);
            }
        }
        private void listMarkerStyleChange(object sender, RoutedEventArgs e)
        {
            List list = GetList();
            switch ((e.Source as MenuItem).Name)
            {
                case "mnuNone":
                case "mnuNone2":
                    EditingCommands.ToggleBullets.Execute(null, RichTextBox1);
                    break;
                case "mnuBox":

                    list.MarkerStyle = (TextMarkerStyle)Enum.Parse(typeof(TextMarkerStyle), "Box");
                    break;
                case "mnuSquare":
                    list.MarkerStyle = (TextMarkerStyle)Enum.Parse(typeof(TextMarkerStyle), "Square");
                    break;
                case "mnuDisc":
                    list.MarkerStyle = (TextMarkerStyle)Enum.Parse(typeof(TextMarkerStyle), "Disc");
                    break;
                case "mnuCircle":
                    list.MarkerStyle = (TextMarkerStyle)Enum.Parse(typeof(TextMarkerStyle), "Circle");
                    break;
                case "mnuDecimal":
                    list.MarkerStyle = (TextMarkerStyle)Enum.Parse(typeof(TextMarkerStyle), "Decimal");
                    break;
                case "mnuLowerLatin":
                    list.MarkerStyle = (TextMarkerStyle)Enum.Parse(typeof(TextMarkerStyle), "LowerLatin");
                    break;
                case "mnuUpperLatin":
                    list.MarkerStyle = (TextMarkerStyle)Enum.Parse(typeof(TextMarkerStyle), "UpperLatin");
                    break;
                case "mnuLowerRoman":
                    list.MarkerStyle = (TextMarkerStyle)Enum.Parse(typeof(TextMarkerStyle), "LowerRoman");
                    break;
                case "mnuUpperRoman":
                    list.MarkerStyle = (TextMarkerStyle)Enum.Parse(typeof(TextMarkerStyle), "UpperRoman");
                    break;
                default:
                    break;
            }
            //获取当前选中的字体大小

            Object obj = RichTextBox1.Selection.GetPropertyValue(
                                             FlowDocument.FontSizeProperty);
            //保证项目符号与文字大小一致
            if (obj is double)
                list.FontSize = (double)obj;
            RichTextBox1.Focus();
        }