/// <summary> /// Create new tab page /// </summary> /// <param name="tabName">name of the tab</param> public static TabPage CreateNewTabPage(string tabName) { //Create a new Tabpage TabPage newTabPage = new TabPage(tabName); //Init tab page status InitTabPageStatus(newTabPage); ////Declare a scintilla textBox MyRichTextBox textBox = new MyRichTextBox(); ////Init essential things to make scintilla textbox like a notepad ////these are the most important things in this project MyTextBoxClass.InitAllStuffs(textBox, tabControl); //Add scintilla TextBox to tabPage newTabPage.Controls.Add(textBox); //Fill the form by textArea textBox.Dock = DockStyle.Fill; //Add tabPage to tabControl tabControl.TabPages.Add(newTabPage); //switch to the new tab tabControl.SelectedTab = newTabPage; return(newTabPage); }
void StoryListele() { ComboboxItem item = new ComboboxItem(); komut.CommandText = "SELECT Id, Story FROM Stories"; DataTable tablom = new DataTable(); OleDbDataAdapter verilericek = new OleDbDataAdapter(komut); verilericek.Fill(tablom); int rtBoyut = 0; for (int i = 0; i < tablom.Rows.Count; i++) { item.Text = tablom.Rows[i][1].ToString(); item.Value = tablom.Rows[i][0].ToString(); //cbStroy.Items.Add(item); cbStroy.Items.Add(new { Text = tablom.Rows[i][1].ToString(), Value = tablom.Rows[i][0].ToString() }); cbStroy.DisplayMember = "Text"; cbStroy.ValueMember = "Value"; cbStroy.SelectedIndex = 0; MyRichTextBox rTBox = new MyRichTextBox(); rTBox.Text = tablom.Rows[i][1].ToString(); rTBox.BackColor = RenkSec(); rTBox.Cat1Count = 0; rTBox.Cat2Count = 0; rTBox.Cat3Count = 0; rTBox.Location = new System.Drawing.Point(5, rtBoyut); rTBox.Name = "rTBox" + item.Value; rTBox.Size = new System.Drawing.Size(117, 82); rTBox.TabIndex = 0; panel1.Controls.Add(rTBox); rtBoyut += 90; } }
private void NewTab() { var Tab = new TabPage { Text = "New document", Parent = TabControl, }; var RichTextBox = new MyRichTextBox { FileName = "New document", Dock = DockStyle.Fill, Name = "Body", Parent = Tab, ContextMenuStrip = contextMenuStrip1, AllowDrop = true, }; RichTextBox.KeyDown += new KeyEventHandler(RichTextBox_KeyDown); RichTextBox.TextChanged += new EventHandler(RichTextBox_TextChanged); RichTextBox.DragDrop += new DragEventHandler(RichTextBox_DragDrop); RichTextBox.DragEnter += new DragEventHandler(richTextBox1_DragEnter); TabControl.SelectTab(TabControl.TabCount - 1); }
public UndoRedoHelper(MyRichTextBox rtb) { Rtb = rtb; Rtb.CommandBindings.Add(new CommandBinding(ApplicationCommands.Undo, HandleUndo)); Rtb.CommandBindings.Add(new CommandBinding(ApplicationCommands.Redo, HandleRedo)); Rtb.LostFocus += HandleLostFocus; Init( ); }
private void LoadUserData() { // Имя Клиента if (label_PersonName.Text != _person.Name) { label_PersonName.Text = _person.Name; } // Телефон if (maskedTextBox_PhoneNumber.Text != _person.Phone) { maskedTextBox_PhoneNumber.Text = _person.Phone; } // Паспорт if (maskedTextBox_Passport.Text != _person.Passport) { maskedTextBox_Passport.Text = _person.Passport; } // Права if (maskedTextBox_DriverID.Text != _person.DriverIdNum) { maskedTextBox_DriverID.Text = _person.DriverIdNum; } // Персональный Номер if (textBox_Number.Text != _person.IdString) { textBox_Number.Text = _person.IdString; } // День Рождения try { if (dateTimePicker_birthDate.Value != _person.BirthDate) { dateTimePicker_birthDate.Value = _person.BirthDate; } } catch (Exception) { dateTimePicker_birthDate.Value = DateTime.Now; } // Пол var gendRange = Enum.GetNames(typeof(Gender)).ToArray <object>(); var gendSelected = _person.GenderType.ToString(); MyComboBox.Initialize(comboBox_Gender, gendRange, gendSelected); // Особые Отметки if (_editedSpecialNote != _person.SpecialNotes) { _editedSpecialNote = _person.SpecialNotes; } MyRichTextBox.Load(richTextBox_notes, _person.SpecialNotes); }
private static void RichTextPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) { MyRichTextBox richTextBox = (MyRichTextBox)dependencyObject; Paragraph paragraph = (Paragraph)dependencyPropertyChangedEventArgs.NewValue; // Remove any existing content from the text box richTextBox.Blocks.Clear(); // Add the paragraph to the text box richTextBox.Blocks.Add(paragraph); }
/// <summary> /// when we type something in text area, we need to make a mark to know /// if we have saved tab page or have't /// </summary> /// <param name="textBox"></param> /// <param name="tabControl"></param> private static void MarkTabPageOnTextChange(MyRichTextBox textBox, TabControl tabControl) { TextArea textArea = textBox.TextArea; textArea.TextChanged += delegate(object sender, EventArgs e) { if (tabControl.SelectedTab.Text.Contains("*") == false) { tabControl.SelectedTab.Text = "*" + tabControl.SelectedTab.Text; } }; }
void YeniTaskEkle(MyPictureBox a, int kategori) { int TasiId = 0; for (int x = 0; x < cbTasks.Items.Count; x++) { if ((cbTasks.Items[x] as dynamic).Text == a.Name.Replace("_", " ")) { TasiId = Convert.ToInt32((cbTasks.Items[x] as dynamic).Value); } } VeritabaninaBaglan(); komut.CommandText = "UPDATE Tasks SET TaskCategoryId=" + kategori + " WHERE Id=" + TasiId; komut.ExecuteNonQuery(); VeritabaniBaglantisiniKapat(); MyRichTextBox FoundStory = panel1.Controls.Find("rTBox" + a.StoryId, true).FirstOrDefault() as MyRichTextBox; if (a.CategoryId == "1") { FoundStory.Cat1Count--; } if (a.CategoryId == "2") { FoundStory.Cat2Count--; } if (a.CategoryId == "3") { FoundStory.Cat3Count--; } int sayac = -1; for (int x = 0; x < cbStroy.Items.Count; x++) { sayac++; if ((cbStroy.Items[x] as dynamic).Value == a.StoryId) { break; } } if (kategori == 1) { panel2.Controls.Add(a); TaskTasi(kategori, (90 * sayac), a.Name, a, FoundStory.Cat1Count); FoundStory.Cat1Count++; a.CategoryId = "1"; } if (kategori == 2) { panel3.Controls.Add(a); TaskTasi(kategori, (90 * sayac), a.Name, a, FoundStory.Cat2Count); FoundStory.Cat2Count++; a.CategoryId = "2"; } if (kategori == 3) { panel4.Controls.Add(a); TaskTasi(kategori, (90 * sayac), a.Name, a, FoundStory.Cat3Count); FoundStory.Cat3Count++; a.CategoryId = "3"; } }
/// <summary> /// set undo and redo status and status bar ( this event occur when a tab page is added) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tabControl_ControlAdded(object sender, ControlEventArgs e) { //variables to store previous undo and redo status bool previousUndoStatus = false; bool previousRedoStatus = false; //note that we can't use TabControlClass.CurrentTextBox here //because this event raise before we set selectedtab by new tab page //see TabControlClass.CreateNewTabPage for more details MyRichTextBox currentTextBox = tabControl.TabPages[tabControl.TabPages.Count - 1].Controls[0] as MyRichTextBox; //get current text area TextArea currentTextArea = currentTextBox.TextArea; //add text changed event currentTextArea.TextChanged += delegate(object supsender, EventArgs supe) { if ((undoToolStripMenuItem.Enabled & currentTextArea.CanUndo()) == false) { //update undo and redo tool strip undoToolStripMenuItem.Enabled = currentTextArea.CanUndo(); } if ((redoToolStripMenuItem.Enabled & currentTextArea.CanRedo()) == false) { //update undo and redo tool strip redoToolStripMenuItem.Enabled = currentTextArea.CanRedo(); } if (previousUndoStatus != currentTextArea.CanUndo()) { //update the status of current tabpage TabControlClass.CurrentTabPageStatus.CanUndo = currentTextArea.CanUndo(); previousUndoStatus = currentTextArea.CanUndo(); } if (previousRedoStatus != currentTextArea.CanRedo()) { //update the status of current tabpage TabControlClass.CurrentTabPageStatus.CanRedo = currentTextArea.CanRedo(); previousRedoStatus = currentTextArea.CanRedo(); } //set status bar textLengthStatusLabel.Text = "TextLength: " + currentTextArea.TextLength.ToString(); }; currentTextArea.SelectionChanged += delegate(object supsender, EventArgs supe) { //set status bar lineNumberStatusLabel.Text = "LineNumber: " + (currentTextArea.GetLineFromCharIndex(currentTextArea.SelectionStart) + 1).ToString(); }; }
public override void _presenter_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { _inkCanvas.ReleaseMouseCapture(); if (_startpoint != null) { _startpoint = null; } MyRichTextBox myRichTextBox = new MyRichTextBox(_richTextBox); AddTextCommand atc = new AddTextCommand(_inkCollector, myRichTextBox); atc.execute(); _inkCollector.CommandStack.Push(atc); _richTextBox.Focus(); }
private void InitDocument() { MyRichTextBox editBox1 = new MyRichTextBox(); editBox1.AcceptsTab = true; editBox1.TextChanged += EditBox1_TextChanged; editBox1.Tag = textFileName + "-" + 0; editBox1.Size = tabPage1.Size; editBox1.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top); editBox1.Name = "edit" + (myRiches.Count - 1).ToString(); editBox1.TextChanged += editBox1_TextChanged; myRiches.Add(editBox1); tabPage1.Text = editBox1.Tag.ToString(); tabPage1.Controls.Add(editBox1); }
private void Log(String text) { MyForm.Invoke(new Action( delegate() { MyRichTextBox.Text += text + Environment.NewLine; MyRichTextBox.SelectionStart = MyRichTextBox.Text.Length; MyRichTextBox.ScrollToCaret(); })); MyForm.Invoke(new Action( delegate() { MyForm.Refresh(); })); }
private void LogException(Exception ex) { MyForm.Invoke(new Action( delegate() { MyRichTextBox.Text += ex.Message + Environment.NewLine; MyRichTextBox.Text += ex.StackTrace + Environment.NewLine; MyRichTextBox.SelectionStart = MyRichTextBox.Text.Length; MyRichTextBox.ScrollToCaret(); })); MyForm.Invoke(new Action( delegate() { MyForm.Refresh(); })); }
/// <summary> /// Init all stuffs /// </summary> /// <param name="textBox"></param> public static void InitAllStuffs(MyRichTextBox textBox, TabControl tabControl) { StylesClass.GetAllStylesIntoProperties(); //init basic text area color textBox.TextArea.Language = StylesClass.DefaultLanguage; textBox.TextArea.DefaultLanguageColor = StylesClass.DefaultLanguageColor; textBox.TextArea.StringsColor = StylesClass.StringsColor; textBox.TextArea.KeyWordsColor = StylesClass.KeywordsColor; textBox.TextArea.CommentLinesColor = StylesClass.CommentLinesColor; textBox.TextArea.CommentBlocksColor = StylesClass.CommentBlocksColor; if (StylesClass.Theme == "Default") { textBox.TextArea.DefaultLanguageColor = Color.Black; textBox.TextArea.BackColor = Color.White; } else { if (StylesClass.Theme == "Dark") { textBox.TextArea.DefaultLanguageColor = Color.White; textBox.TextArea.BackColor = Color.Black; } else { textBox.TextArea.BackColor = StylesClass.BackColor; } } //init auto numbering textBox.NumberMargin.AutoNumbering(true); //init book mark textBox.BookMarkMargin.AutoBookMark(true); textBox.DocumentMap.AutoDocumentMap(false); //textBox.DocumentMap.AutoDocumentMap(true); //Allow drap and drop file into text area InitDragDropFile(textBox, tabControl); //mark a "*" in a tab page if the text in text area changed //this will allow us to know whether this tab page is saved or not MarkTabPageOnTextChange(textBox, tabControl); }
private void AddNewDocumentObj() { MyRichTextBox editBox1 = new MyRichTextBox(); editBox1.AcceptsTab = true; editBox1.Tag = textFileName + "-" + tabControl1.TabPages.Count; editBox1.Size = tabPage1.Size; editBox1.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top); editBox1.Name = "edit" + (myRiches.Count).ToString(); editBox1.TextChanged += editBox1_TextChanged; myRiches.Add(editBox1); TabPage tabPage = new TabPage(editBox1.Tag.ToString()); tabPage.Size = tabControl1.TabPages[0].Size; tabControl1.TabPages.Add(tabPage); tabControl1.TabPages[tabControl1.TabPages.Count - 1].Controls.Add(editBox1); }
} // (disable this adorner for debugging purposes) public WhitespaceAdorner(MyRichTextBox rtb, ChangeEventHelper ceh) : base(rtb) { ChangeEventHelper = ceh; Debug.Assert(ChangeEventHelper != null); WsBrush.Freeze( ); TabPen.Freeze( ); EolPen.Freeze( ); EofPen.Freeze( ); EofBrush.Freeze( ); IsHitTestVisible = false; Rtb.TextChanged += Rtb_TextChanged; Rtb.AddHandler(ScrollViewer.ScrollChangedEvent, new RoutedEventHandler(Rtb_ScrollChanged), true); Loop = new ResumableLoop(ThreadProc, 33, 33, 444); }
private void radioButton_1_Click(object sender, System.Windows.RoutedEventArgs e) { _thumbInk.Thumb_InkFrame._inkCanvas.Children.Clear(); _thumbInk.Thumb_InkFrame._inkCanvas.Strokes.Clear(); string content = "Cat, Sofa, Dog, Fight, Falling Down, Dancing, Outside, Man, Car, Run"; RichTextBox tb = new RichTextBox(); tb.HorizontalAlignment = HorizontalAlignment.Left; tb.VerticalAlignment = VerticalAlignment.Top; tb.Margin = new Thickness(0); tb.Width = _thumbInk.ActualWidth - 100; tb.Height = _thumbInk.ActualHeight - 100; tb.Padding = new Thickness(0); System.Windows.Documents.Paragraph paragraph = new Paragraph(); paragraph.LineHeight = 1; paragraph.Padding = new Thickness(0); paragraph.TextAlignment = TextAlignment.Left; Run run = new Run(); run.Text = content; paragraph.Inlines.Add(run); tb.Document.Blocks.Clear(); tb.Document.Blocks.Add(paragraph); tb.IsHitTestVisible = false; tb.BorderBrush = null; tb.AcceptsReturn = true; tb.Background = new SolidColorBrush(Colors.Transparent); TextRange textRange = new TextRange(tb.Document.ContentStart, tb.Document.ContentEnd); textRange.ApplyPropertyValue(RichTextBox.FontSizeProperty, "30"); textRange.ApplyPropertyValue(RichTextBox.FontWeightProperty, "Bold"); SolidColorBrush myBrush = new SolidColorBrush(Colors.Blue); textRange.ApplyPropertyValue(RichTextBox.ForegroundProperty, myBrush); InkCollector ic = _thumbInk.Thumb_InkFrame.InkCollector; ic.InkCanvas.Children.Add(tb); MyRichTextBox mt = new MyRichTextBox(tb); ic.Sketch.AddText(mt); }
public void OnNullEventArgs() { MyRichTextBox rtb = new MyRichTextBox(); Assert.Throws <ArgumentNullException> (delegate { rtb.OnGotFocus_Null(); }, "OnGotFocus"); Assert.Throws <ArgumentNullException> (delegate { rtb.OnKeyDown_Null(); }, "OnKeyDown"); Assert.Throws <ArgumentNullException> (delegate { rtb.OnKeyUp_Null(); }, "OnKeyUp"); Assert.Throws <ArgumentNullException> (delegate { rtb.OnLostFocus_Null(); }, "OnLostFocus"); Assert.Throws <ArgumentNullException> (delegate { rtb.OnMouseEnter_Null(); }, "OnMouseEnter"); Assert.Throws <ArgumentNullException> (delegate { rtb.OnMouseLeave_Null(); }, "OnMouseLeave"); Assert.Throws <ArgumentNullException> (delegate { rtb.OnMouseLeftButtonDown_Null(); }, "OnMouseLeftButtonDown"); Assert.Throws <ArgumentNullException> (delegate { rtb.OnMouseLeftButtonUp_Null(); }, "OnMouseLeftButtonUp"); Assert.Throws <ArgumentNullException> (delegate { rtb.OnMouseMove_Null(); }, "OnMouseMove"); Assert.Throws <ArgumentNullException> (delegate { rtb.OnTextInput_Null(); }, "OnTextInput"); Assert.Throws <ArgumentNullException> (delegate { rtb.OnTextInputStart_Null(); }, "OnTextInputStart"); Assert.Throws <ArgumentNullException> (delegate { rtb.OnTextInputUpdate_Null(); }, "OnTextInputUpdate"); }
/// <summary> /// Init all stuffs /// </summary> /// <param name="textBox"></param> public static void InitAllStuffs(MyRichTextBox textBox, TabControl tabControl) { //init basic text area color //StyleClass.InitDefaultStyle(textBox); //init auto numbering textBox.NumberMargin.AutoNumbering(true); //init book mark textBox.BookMarkMargin.AutoBookMark(true); textBox.DocumentMap.AutoDocumentMap(false); //textBox.DocumentMap.AutoDocumentMap(true); //Allow drap and drop file into text area InitDragDropFile(textBox, tabControl); //mark a "*" in a tab page if the text in text area changed //this will allow us to know whether this tab page is saved or not MarkTabPageOnTextChange(textBox, tabControl); }
private void Func_SelectionChanged(object sender, SelectionChangedEventArgs e) { TextBlock selectedItem = (TextBlock)Func.SelectedItem; if (selectedItem.Text == "Copy") { MyRichTextBox.SelectAll(); MyRichTextBox.Copy(); } else if (selectedItem.Text == "Paste") { MyRichTextBox.Paste(); } else if (selectedItem.Text == "Undo") { MyRichTextBox.Undo(); } else if (selectedItem.Text == "Cut") { MyRichTextBox.Cut(); } }
void TaskleriListele() { int rtBoyut = 5; int satirY = 0; int yerlestirY = 5; int sayac = -1; OleDbDataAdapter odat = new OleDbDataAdapter("SELECT Id, Story FROM Stories", baglanti); DataSet ds = new DataSet(); odat.Fill(ds); for (int z = 0; z < ds.Tables[0].Rows.Count; z++) { ComboboxItem item = new ComboboxItem(); komut.CommandText = "SELECT Id, TaskName, TaskCategoryId, TaskStoryId FROM Tasks WHERE TaskStoryId=" + ds.Tables[0].Rows[z][0].ToString(); DataTable tablom = new DataTable(); OleDbDataAdapter verilericek = new OleDbDataAdapter(komut); verilericek.Fill(tablom); for (int i = 0; i < tablom.Rows.Count; i++) { item.Text = tablom.Rows[i][1].ToString(); item.Value = tablom.Rows[i][0].ToString(); string tsid = tablom.Rows[i][3].ToString(); cbTasks.Items.Add(new { Text = tablom.Rows[i][1].ToString(), Value = tablom.Rows[i][0].ToString() }); cbTasks.DisplayMember = "Text"; cbStroy.ValueMember = "Value"; cbTasks.SelectedIndex = 0; MyPictureBox pictureBoxx = new MyPictureBox(); pictureBoxx.StoryId = tablom.Rows[i][3].ToString(); pictureBoxx.CategoryId = tablom.Rows[i][2].ToString(); pictureBoxx.Image = TaskResimAl(); int bolum = 0; bolum = objepanel2 / 2; if (tablom.Rows[i][2].ToString() == "1") { if (objepanel2 % 2 == 0) { yerlestirY = (bolum * 35) + ((bolum + 1) * 5); } else { } } pictureBoxx.Location = new System.Drawing.Point(rtBoyut, yerlestirY); pictureBoxx.Name = item.Text.Replace(" ", "_"); //"pictureBox" + i.ToString(); pictureBoxx.Size = new System.Drawing.Size(51, 35); pictureBoxx.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; pictureBoxx.TabIndex = 3; pictureBoxx.TabStop = false; pictureBoxx.Paint += new PaintEventHandler((sender, e) => { e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; string text = pictureBoxx.Name.Replace("_", " "); SizeF textSize = e.Graphics.MeasureString(text, Font); PointF locationToDraw = new PointF(); locationToDraw.X = (pictureBoxx.Width / 2) - (textSize.Width / 2); locationToDraw.Y = (pictureBoxx.Height / 2) - (textSize.Height / 2); e.Graphics.DrawString(text, Font, Brushes.Black, locationToDraw); }); pictureBoxx.Invalidate(); pictureBoxx.MouseDown += new System.Windows.Forms.MouseEventHandler((sender, e) => { dragsource = pictureBoxx; pictureBoxx.DoDragDrop(pictureBoxx.Image, DragDropEffects.All); }); MyRichTextBox FoundStory = panel1.Controls.Find("rTBox" + tsid, true).FirstOrDefault() as MyRichTextBox; if (tablom.Rows[i][2].ToString() == "1") { panel2.Controls.Add(pictureBoxx); pictureBoxx.Location = TaskYerlestir(1, satirY, pictureBoxx.Name); objepanel2++; FoundStory.Cat1Count++; } if (tablom.Rows[i][2].ToString() == "2") { panel3.Controls.Add(pictureBoxx); pictureBoxx.Location = TaskYerlestir(2, satirY, pictureBoxx.Name); objepanel3++; FoundStory.Cat2Count++; } if (tablom.Rows[i][2].ToString() == "3") { panel4.Controls.Add(pictureBoxx); pictureBoxx.Location = TaskYerlestir(3, satirY, pictureBoxx.Name); objepanel4++; FoundStory.Cat3Count++; } sayac = -1; } satirY += 90; objepanel2 = 0; objepanel3 = 0; objepanel4 = 0; } }
public MyContextMenu(MyRichTextBox myRichTextBox) : base() { _myRichTextBox = myRichTextBox; }
public AddTextCommand(InkCollector inkcollector, MyRichTextBox myRichTextBox) { this._inkCollector = inkcollector; this._myRichTextBox = myRichTextBox; }
/// <summary> /// Только тут создаются заголовки всех полей и записываются основные данные /// </summary> /// <param name="first"></param> /// <returns></returns> public static IEnumerable <PersonField> GetPersonFieldsFull(Person first) { var person = first; var instAbonContr = AbonementController.GetInstance(); var abonHistoriesOld = PersonObject.GetAbonHistoryList(person.Name); var abonListAll = instAbonContr.GetList(person.Name); var abonValid = instAbonContr.GetFirstValid(person.Name); // Создается текстовый список всех абонементов. var abonHistString = new StringBuilder(); foreach (var item in abonListAll) { abonHistString.AppendLine(item?.AbonementName + $"({item?.BuyDate.Date}), "); } if (abonHistoriesOld != null) { foreach (var item in abonHistoriesOld) { abonHistString.Append(item?.AbonementName + $"({item?.BuyDate}), "); } } // Для выдергивания не форматированного текста в заметки. RichTextBox tempSpecialNotesRtb = new RichTextBox(); MyRichTextBox.Load(tempSpecialNotesRtb, person.SpecialNotes); var abon = abonValid ?? abonListAll?.LastOrDefault(); var isAbonExist = abon != null; var personFields = new List <PersonField> { new PersonField { HeaderName = "Имя", Value = person.Name }, new PersonField { HeaderName = "Телефон", Value = person.Phone }, new PersonField { HeaderName = "Дата Рождения", Value = $"{person.BirthDate.Date:MM/dd/yyyy}" }, new PersonField { HeaderName = "Пол", Value = person.GenderType.ToString() }, new PersonField { HeaderName = "Статус", Value = person.Status.ToString() }, new PersonField { HeaderName = "ID номер", Value = person.IdString }, new PersonField { HeaderName = "Паспорт", Value = person.Passport }, new PersonField { HeaderName = "Права", Value = person.DriverIdNum }, // Абонемент new PersonField { HeaderName = "Название", Value = (isAbonExist) ?abon.AbonementName: "" }, new PersonField { HeaderName = "Доступное время", Value = (isAbonExist) ?abon.TimeTraining.ToString():"" }, new PersonField { HeaderName = "Осталось дней", Value = (isAbonExist) ?abon.GetRemainderDays().ToString():"" }, new PersonField { HeaderName = "Аэробных", Value = (isAbonExist) ?abon.NumAerobicTr.ToString():"" }, new PersonField { HeaderName = "Персональных", Value = (isAbonExist) ?abon.NumPersonalTr.ToString():"" }, new PersonField { HeaderName = "Мини Групп", Value = (isAbonExist) ?abon.NumMiniGroup.ToString():"" }, new PersonField { HeaderName = "Спа услуги", Value = (isAbonExist) ?abon.Spa.ToString():"" }, new PersonField { HeaderName = "Доступный тип", Value = (isAbonExist) ?abon.TypeWorkout.ToString():"" }, new PersonField { HeaderName = "Оплата", Value = (isAbonExist) ?abon.PayStatus.ToString():"" }, new PersonField { HeaderName = "Абон. Покупка", Value = (isAbonExist) ? $"{abon.BuyDate:MM/dd/yyyy}" :"" }, new PersonField { HeaderName = "Абон. Активация", Value = (isAbonExist) ? $"{abon.BuyActivationDate:MM/dd/yyyy}" :"" }, new PersonField { HeaderName = "Абон. Конец", Value = (isAbonExist) ? $"{abon.EndDate:MM/dd/yyyy}":"" }, new PersonField { HeaderName = "Активация", Value = (isAbonExist) ?abon.IsActivated.ToString():"" }, new PersonField { HeaderName = "Заметки", Value = tempSpecialNotesRtb.Text }, new PersonField { HeaderName = "Заморозки", Value = GetFreezeString(person) }, new PersonField { HeaderName = "История Абон.", Value = abonHistString.ToString() } }; return(personFields); }
public MainWindow() { InitializeComponent(); MyRichTextBox.AddHandler(RichTextBox.DragOverEvent, new DragEventHandler(MyRichTextBox_DragOver), true); MyRichTextBox.AddHandler(RichTextBox.DropEvent, new DragEventHandler(MyRichTextBox_Drop), true); }
/// <summary> /// Constructor /// </summary> public StateDiagramWindow() { descriptionRichTextBox = new MyRichTextBox(true); InitializeComponent(); splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; }
/// <summary> /// Allow drag and drop file into text area /// </summary> /// <param name="textBox"></param> private static void InitDragDropFile(MyRichTextBox textBox, TabControl tabControl) { TextArea textArea = textBox.TextArea; //allow drop file textArea.AllowDrop = true; //On Drag Enter event textArea.DragEnter += delegate(object sender, DragEventArgs e) { //if the dropped file can be converted to specified format //simply means if the dropped file can be read if (e.Data.GetDataPresent(DataFormats.FileDrop)) { //make an effect to look like we are dragging something //this is not really important but we should do it e.Effect = DragDropEffects.Copy; } else { e.Effect = DragDropEffects.None; } }; //On Drop File textArea.DragDrop += delegate(object sender, DragEventArgs e) { //if the dropped file can be read if (e.Data.GetDataPresent(DataFormats.FileDrop)) { //get data in this file //note that because the various type of things can be dropped in the text area //that's why it makes sense that the GetData function return an object //we need to convert this into a String Array (or simply an Array) to get the data stored in the object //it's important to know somehow the data store in the object just the path of the file we are about to read String[] strArray = (String[])e.Data.GetData(DataFormats.FileDrop); //get the path from String Array //note that although the String Array has just only one element (the path of the file), //we can't convert directly the object above into just one string string path = strArray[0]; //just check to make sure the path existing if (File.Exists(path)) { //the number lines of code below is just a copy of open function in MainForm //check to see if there is already this tab page being opened TabPage targetTabPage = null; foreach (TabPage tabPage in tabControl.TabPages) { if (tabPage.Name == path) { targetTabPage = tabPage; break; } } //if this tab page has already opened, just focus this tab and return if (targetTabPage != null) { tabControl.SelectedTab = targetTabPage; return; } //it's better to create a new tab page to write the stuffs than using the selected tab page, //so I'll create new one //this all the code below just a copy of OpenDialog function //Create a new tab page TabPage newTabPage = TabControlClass.CreateNewTabPage(Path.GetFileName(path)); //a variable to hold text box contained in tab page TextArea newTextArea = (newTabPage.Controls[0] as MyRichTextBox).TextArea; //Get the text of the file string fileText = File.ReadAllText(path); //Set the text of current text box by file Text newTextArea.StopRecordingUndo(); newTextArea.Text = fileText; newTextArea.ContinueRecordingUndo(); //when we set the text by the code above, we changed the text in the text area //and accidentally lead to the MarkTabPage event //that's the reason why we have to do this to unmark the tabPage initially newTabPage.Text = newTabPage.Text.Replace("*", ""); //this is a trick to save the path(FileName) of the saved tab page //and the next time if this tab page has already had a name, we shouldn't open the savefiledialog again //and just implicitly save tabControl.SelectedTab.Name = path; } } }; }
public FindDialog(MyRichTextBox _mRTB) { InitializeComponent(); richTextBox1 = new RichTextBox(); richTextBox1.SelectionChanged += new System.EventHandler(richTextBox1_SelectionChanged); }
private void _person_SpecialNotesChanged(object sender, string e) { MyRichTextBox.Load(richTextBox_notes, _person.SpecialNotes); }
public void OnNullEventArgs () { MyRichTextBox rtb = new MyRichTextBox (); Assert.Throws<ArgumentNullException> (delegate { rtb.OnGotFocus_Null (); }, "OnGotFocus"); Assert.Throws<ArgumentNullException> (delegate { rtb.OnKeyDown_Null (); }, "OnKeyDown"); Assert.Throws<ArgumentNullException> (delegate { rtb.OnKeyUp_Null (); }, "OnKeyUp"); Assert.Throws<ArgumentNullException> (delegate { rtb.OnLostFocus_Null (); }, "OnLostFocus"); Assert.Throws<ArgumentNullException> (delegate { rtb.OnMouseEnter_Null (); }, "OnMouseEnter"); Assert.Throws<ArgumentNullException> (delegate { rtb.OnMouseLeave_Null (); }, "OnMouseLeave"); Assert.Throws<ArgumentNullException> (delegate { rtb.OnMouseLeftButtonDown_Null (); }, "OnMouseLeftButtonDown"); Assert.Throws<ArgumentNullException> (delegate { rtb.OnMouseLeftButtonUp_Null (); }, "OnMouseLeftButtonUp"); Assert.Throws<ArgumentNullException> (delegate { rtb.OnMouseMove_Null (); }, "OnMouseMove"); #if false // throw NotImplementedException Assert.Throws<ArgumentNullException> (delegate { rtb.OnTextInput_Null (); }, "OnTextInput"); Assert.Throws<ArgumentNullException> (delegate { rtb.OnTextInputStart_Null (); }, "OnTextInputStart"); Assert.Throws<ArgumentNullException> (delegate { rtb.OnTextInputUpdate_Null (); }, "OnTextInputUpdate"); #endif }
/// <summary> /// 构造函数 /// </summary> /// <param name="image">图片</param> /// <param name="offsetx">移动x距离</param> /// <param name="offsety">移动y距离</param> public TextMoveCommand(MyRichTextBox myRichTextBox, double offsetx, double offsety) { this._myRichTextBox = myRichTextBox; this.offset_x = offsetx; this.offset_y = offsety; }