//
//
-// NOT COMPLETE
+// #define DEBUG
using System;
using System.Collections;
using System.Drawing;
using System.IO;
using System.Text;
+using System.Runtime.InteropServices;
using RTF=System.Windows.Forms.RTF;
namespace System.Windows.Forms {
+#if NET_2_0
+ [ClassInterface (ClassInterfaceType.AutoDispatch)]
+ [Docking (DockingBehavior.Ask)]
+ [ComVisible (true)]
+#endif
public class RichTextBox : TextBoxBase {
#region Local Variables
internal bool auto_word_select;
internal int bullet_indent;
- internal bool can_redo;
internal bool detect_urls;
- internal string redo_action_name;
internal int margin_right;
- internal string undo_action_name;
internal float zoom;
private RTF.TextMap rtf_text_map;
accepts_return = true;
auto_word_select = false;
bullet_indent = 0;
- can_redo = false;
detect_urls = true;
max_length = Int32.MaxValue;
- redo_action_name = string.Empty;
margin_right = 0;
- undo_action_name = string.Empty;
zoom = 1;
base.Multiline = true;
document.CRLFSize = 1;
#endregion // Private & Internal Methods
#region Public Instance Properties
+#if NET_2_0
+ [Browsable (false)]
+#endif
public override bool AllowDrop {
get {
return base.AllowDrop;
}
[DefaultValue(false)]
+#if NET_2_0
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Visible)]
+ [RefreshProperties (RefreshProperties.Repaint)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [Browsable (false)]
+#else
[Localizable(true)]
+#endif
public override bool AutoSize {
get {
return auto_size;
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool CanRedo {
get {
- return can_redo;
+ return document.undo.CanRedo;
}
}
// Font changes always set the whole doc to that font
start = document.GetLine(1);
end = document.GetLine(document.Lines);
- document.FormatText(start, 1, end, end.text.Length + 1, base.Font, new SolidBrush(this.ForeColor));
+ document.FormatText(start, 1, end, end.text.Length + 1, base.Font, null, null, FormatSpecified.Font);
}
}
}
[MonoTODO]
public string RedoActionName {
get {
- return redo_action_name;
+ return document.undo.RedoActionName;
}
}
}
[Browsable(false)]
- [DefaultValue("")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+#if NET_2_0
+ [RefreshProperties (RefreshProperties.All)]
+#else
+ [DefaultValue("")]
+#endif
public string Rtf {
get {
Line start_line;
}
[Localizable(true)]
+#if NET_2_0
+ [RefreshProperties (RefreshProperties.All)]
+#endif
public override string Text {
get {
return base.Text;
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string UndoActionName {
get {
- return document.undo.UndoName;
+ return document.undo.UndoActionName;
}
}
try {
sb = new StringBuilder((int)data.Length);
buffer = new byte[1024];
- }
-
- catch {
+ } catch {
throw new IOException("Not enough memory to load document");
}
data = null;
+
try {
data = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 1024);
+
LoadFile(data, fileType);
}
-
+#if !DEBUG
catch {
throw new IOException("Could not open file " + path);
}
-
+#endif
finally {
if (data != null) {
data.Close();
base.Paste(Clipboard.GetDataObject(), clipFormat, false);
}
- [MonoTODO()]
- public void Redo() {
+ public void Redo()
+ {
+ document.undo.Redo ();
}
public void SaveFile(Stream data, RichTextBoxStreamType fileType) {
}
[Browsable(false)]
+#if !NET_2_0
[EditorBrowsable(EditorBrowsableState.Never)]
+#endif
public new event DragEventHandler DragDrop {
add { base.DragDrop += value; }
remove { base.DragDrop -= value; }
}
[Browsable(false)]
+#if !NET_2_0
[EditorBrowsable(EditorBrowsableState.Never)]
+#endif
public new event DragEventHandler DragEnter {
add { base.DragEnter += value; }
remove { base.DragEnter -= value; }
System.Windows.Forms.RTF.Color color;
color = System.Windows.Forms.RTF.Color.GetColor(rtf, rtf.Param);
+
if (color != null) {
FlushText(rtf, false);
if (color.Red == -1 && color.Green == -1 && color.Blue == -1) {
} else {
this.rtf_color = new SolidBrush(Color.FromArgb(color.Red, color.Green, color.Blue));
}
+ FlushText (rtf, false);
}
break;
}
} else {
rtf_color = new SolidBrush(Color.FromArgb(color.Red, color.Green, color.Blue));
}
+
}
rtf_chars += rtf_line.Length;
line = document.GetLine(rtf_cursor_y);
if (rtf_line.Length > 0) {
document.InsertString(line, rtf_cursor_x, rtf_line.ToString());
- document.FormatText(line, rtf_cursor_x + 1, line, rtf_cursor_x + 1 + length, font, rtf_color); // FormatText is 1-based
+ document.FormatText(line, rtf_cursor_x + 1, line, rtf_cursor_x + 1 + length, font, rtf_color, null, FormatSpecified.Font | FormatSpecified.Color); // FormatText is 1-based
}
if (newline) {
document.Split(line, rtf_cursor_x + length);
rtf_text_map = new RTF.TextMap();
RTF.TextMap.SetupStandardTable(rtf_text_map.Table);
- document.NoRecalc = true;
+ document.SuspendRecalc ();
try {
rtf.Read(); // That's it
FlushText(rtf, false);
+
}
+
catch (RTF.RTFException e) {
+#if DEBUG
+ throw e;
+#endif
// Seems to be plain text or broken RTF
Console.WriteLine("RTF Parsing failure: {0}", e.Message);
- }
+ }
to_x = rtf_cursor_x;
to_y = rtf_cursor_y;
chars = rtf_chars;
document.RecalculateDocument(CreateGraphicsInternal(), cursor_y, document.Lines, false);
- document.NoRecalc = false;
+ document.ResumeRecalc (true);
- document.Invalidate(document.GetLine(cursor_y), 0, document.GetLine(document.Lines), -1);
+ document.Invalidate (document.GetLine(cursor_y), 0, document.GetLine(document.Lines), -1);
}
private void RichTextBox_HScrolled(object sender, EventArgs e) {