İnternetten bulduğum bir WYSIWYG editörü C# tan Vb.net'e dönüştürdüm ama hata çıktı

Bu konuyu okuyanlar

Vatansever

Asistan
Katılım
23 Ağustos 2007
Mesajlar
405
Reaksiyon puanı
1
Puanları
18
İnternetten C# dilinde yazılmış şimdiye kadar rastladığım en problemsiz WYSIWYG editörünü Vb.NET'e çevirip bir proje yaptım dönüştürme sonrasında ortaya çıkan birçok hatayı düzelttim ama yinede her çalıştırmada hata vererek açılıyor ama çalışması düzgün gibi görünüyor acaba hatamı yada hatalarımı düzeltmeme yardım edebilirmisiniz Projenin C# dilindeki orjinali ve benim çevirdiğim Vb.NET dilindeki hali alttaki linktedir
http://www.mediafire.com/?27g1t5nu7cm7gkz

HTMLTextBox.cs Orjinal kod
Kod:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace McDull.Windows.Forms
{
    /// <summary>
    /// Provides a user control that allows the user to edit HTML page.
    /// </summary>
    [Description("Provides a user control that allows the user to edit HTML page."), ClassInterface(ClassInterfaceType.AutoDispatch)]
    public partial class HTMLTextBox : UserControl
    {
        /// <summary>
        /// Constructor
        /// </summary>
        public HTMLTextBox()
        {
            dataUpdate = 0;

            InitializeComponent();

            InitializeControls();
        }

        #region Properties

        /// <summary>
        /// Gets or sets the current text in the HTMLTextBox
        /// </summary>
        public override string Text
        {
            get
            {
                return webBrowserBody.DocumentText;
            }
            set
            {
                webBrowserBody.DocumentText = value.Replace("\r\n", "<br>");
            }
        }

        /// <summary>
        /// Gets the collection of the image path in the HTMLTextBox
        /// </summary>
        public string[] Images
        {
            get
            {
                List<string> images = new List<string>();

                foreach (HtmlElement element in webBrowserBody.Document.Images)
                {
                    string image = element.GetAttribute("src");
                    if (!images.Contains(image))
                    {
                        images.Add(image);
                    }
                }

                return images.ToArray();
            }
        }

        #endregion

        #region Methods

        /// <summary>
        /// Initialize controls
        /// </summary>
        private void InitializeControls()
        {
            BeginUpdate();

            // Tool Bar
            foreach (FontFamily family in FontFamily.Families)
            {
                toolStripComboBoxName.Items.Add(family.Name);
            }

            toolStripComboBoxSize.Items.AddRange(FontSize.All.ToArray());

            // Web Browser
            webBrowserBody.DocumentText = string.Empty;
            webBrowserBody.Document.Click += new HtmlElementEventHandler(webBrowserBody_DocumentClick);
            webBrowserBody.Document.Focusing += new HtmlElementEventHandler(webBrowserBody_DocumentFocusing);
            webBrowserBody.Document.ExecCommand("EditMode", false, null);
            webBrowserBody.Document.ExecCommand("LiveResize", false, null);

            EndUpdate();
        }

        /// <summary>
        /// Refresh tool bar buttons
        /// </summary>
        private void RefreshToolBar()
        {
            BeginUpdate();

            try
            {
                mshtml.IHTMLDocument2 document = (mshtml.IHTMLDocument2)webBrowserBody.Document.DomDocument;

                toolStripComboBoxName.Text = document.queryCommandValue("FontName").ToString();
                toolStripComboBoxSize.SelectedItem = FontSize.Find((int)document.queryCommandValue("FontSize"));
                toolStripButtonBold.Checked = document.queryCommandState("Bold");
                toolStripButtonItalic.Checked = document.queryCommandState("Italic");
                toolStripButtonUnderline.Checked = document.queryCommandState("Underline");

                toolStripButtonNumbers.Checked = document.queryCommandState("InsertOrderedList");
                toolStripButtonBullets.Checked = document.queryCommandState("InsertUnorderedList");

                toolStripButtonLeft.Checked = document.queryCommandState("JustifyLeft");
                toolStripButtonCenter.Checked = document.queryCommandState("JustifyCenter");
                toolStripButtonRight.Checked = document.queryCommandState("JustifyRight");
                toolStripButtonFull.Checked = document.queryCommandState("JustifyFull");
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e);
            }
            finally
            {
                EndUpdate();
            }
        }

        #endregion

        #region Updating

        private int dataUpdate;
        private bool Updating
        {
            get
            {
                return dataUpdate != 0;
            }
        }

        private void BeginUpdate()
        {
            ++dataUpdate;
        }
        private void EndUpdate()
        {
            --dataUpdate;
        }

        #endregion

        #region Tool Bar

        private void toolStripComboBoxName_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (Updating)
            {
                return;
            }

            webBrowserBody.Document.ExecCommand("FontName", false, toolStripComboBoxName.Text);
        }
        private void toolStripComboBoxSize_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (Updating)
            {
                return;
            }

            int size = (toolStripComboBoxSize.SelectedItem == null) ? 1 : (toolStripComboBoxSize.SelectedItem as FontSize).Value;
            webBrowserBody.Document.ExecCommand("FontSize", false, size);
        }
        private void toolStripButtonBold_Click(object sender, EventArgs e)
        {
            if (Updating)
            {
                return;
            }

            webBrowserBody.Document.ExecCommand("Bold", false, null);
            RefreshToolBar();
        }
        private void toolStripButtonItalic_Click(object sender, EventArgs e)
        {
            if (Updating)
            {
                return;
            }

            webBrowserBody.Document.ExecCommand("Italic", false, null);
            RefreshToolBar();
        }
        private void toolStripButtonUnderline_Click(object sender, EventArgs e)
        {
            if (Updating)
            {
                return;
            }

            webBrowserBody.Document.ExecCommand("Underline", false, null);
            RefreshToolBar();
        }
        private void toolStripButtonColor_Click(object sender, EventArgs e)
        {
            if (Updating)
            {
                return;
            }

            int fontcolor = (int)((mshtml.IHTMLDocument2)webBrowserBody.Document.DomDocument).queryCommandValue("ForeColor");

            ColorDialog dialog = new ColorDialog();
            dialog.Color = Color.FromArgb(0xff, fontcolor & 0xff, (fontcolor >> 8) & 0xff, (fontcolor >> 16) & 0xff);

            DialogResult result = dialog.ShowDialog();
            if (result == DialogResult.OK)
            {
                string color = dialog.Color.Name;
                if (!dialog.Color.IsNamedColor)
                {
                    color = "#" + color.Remove(0, 2);
                }

                webBrowserBody.Document.ExecCommand("ForeColor", false, color);
            }
            RefreshToolBar();
        }

        private void toolStripButtonNumbers_Click(object sender, EventArgs e)
        {
            if (Updating)
            {
                return;
            }

            webBrowserBody.Document.ExecCommand("InsertOrderedList", false, null);
            RefreshToolBar();
        }
        private void toolStripButtonBullets_Click(object sender, EventArgs e)
        {
            if (Updating)
            {
                return;
            }

            webBrowserBody.Document.ExecCommand("InsertUnorderedList", false, null);
            RefreshToolBar();
        }
        private void toolStripButtonOutdent_Click(object sender, EventArgs e)
        {
            if (Updating)
            {
                return;
            }

            webBrowserBody.Document.ExecCommand("Outdent", false, null);
            RefreshToolBar();
        }
        private void toolStripButtonIndent_Click(object sender, EventArgs e)
        {
            if (Updating)
            {
                return;
            }

            webBrowserBody.Document.ExecCommand("Indent", false, null);
            RefreshToolBar();
        }

        private void toolStripButtonLeft_Click(object sender, EventArgs e)
        {
            if (Updating)
            {
                return;
            }

            webBrowserBody.Document.ExecCommand("JustifyLeft", false, null);
            RefreshToolBar();
        }
        private void toolStripButtonCenter_Click(object sender, EventArgs e)
        {
            if (Updating)
            {
                return;
            }

            webBrowserBody.Document.ExecCommand("JustifyCenter", false, null);
            RefreshToolBar();
        }
        private void toolStripButtonRight_Click(object sender, EventArgs e)
        {
            if (Updating)
            {
                return;
            }

            webBrowserBody.Document.ExecCommand("JustifyRight", false, null);
            RefreshToolBar();
        }
        private void toolStripButtonFull_Click(object sender, EventArgs e)
        {
            if (Updating)
            {
                return;
            }

            webBrowserBody.Document.ExecCommand("JustifyFull", false, null);
            RefreshToolBar();
        }

        private void toolStripButtonLine_Click(object sender, EventArgs e)
        {
            if (Updating)
            {
                return;
            }

            webBrowserBody.Document.ExecCommand("InsertHorizontalRule", false, null);
            RefreshToolBar();
        }
        private void toolStripButtonHyperlink_Click(object sender, EventArgs e)
        {
            if (Updating)
            {
                return;
            }

            webBrowserBody.Document.ExecCommand("CreateLink", true, null);
            RefreshToolBar();
        }
        private void toolStripButtonPicture_Click(object sender, EventArgs e)
        {
            if (Updating)
            {
                return;
            }

            webBrowserBody.Document.ExecCommand("InsertImage", true, null);
            RefreshToolBar();
        }

        #endregion

        #region Web Browser

        private void webBrowserBody_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
        }

        private void webBrowserBody_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            if (e.IsInputKey)
            {
                return;
            }
            RefreshToolBar();
        }

        private void webBrowserBody_DocumentClick(object sender, HtmlElementEventArgs e)
        {
            RefreshToolBar();
        }

        private void webBrowserBody_DocumentFocusing(object sender, HtmlElementEventArgs e)
        {
            RefreshToolBar();
        }

        #endregion

        #region Font Size
        private class FontSize
        {
            private static List<FontSize> allFontSize = null;
            public static List<FontSize> All
            {
                get
                {
                    if (allFontSize == null)
                    {
                        allFontSize = new List<FontSize>();
                        allFontSize.Add(new FontSize(8, 1));
                        allFontSize.Add(new FontSize(10, 2));
                        allFontSize.Add(new FontSize(12, 3));
                        allFontSize.Add(new FontSize(14, 4));
                        allFontSize.Add(new FontSize(18, 5));
                        allFontSize.Add(new FontSize(24, 6));
                        allFontSize.Add(new FontSize(36, 7));
                    }

                    return allFontSize;
                }
            }

            public static FontSize Find(int value)
            {
                if (value < 1)
                {
                    return All[0];
                }

                if (value > 7)
                {
                    return All[6];
                }

                return All[value - 1];
            }

            private FontSize(int display, int value)
            {
                displaySize = display;
                valueSize = value;
            }

            private int valueSize;
            public int Value
            {
                get
                {
                    return valueSize;
                }
            }

            private int displaySize;
            public int Display
            {
                get
                {
                    return displaySize;
                }
            }

            public override string ToString()
            {
                return displaySize.ToString();
            }
        }
        #endregion

        #region ToolStripComboBox
        private class ToolStripComboBoxEx : ToolStripComboBox
        {
            public override Size GetPreferredSize(Size constrainingSize)
            {
                Size size = base.GetPreferredSize(constrainingSize);
                size.Width = Math.Max(Width, 0x20);
                return size;
            }
        }
        #endregion

    }
}

HTMLTextBox1.vb Benim dönüştürdüğüm hali
Kod:
Imports System.ComponentModel
Imports System.Runtime.InteropServices

'Public Class HTMLTextBox

'End Class
'Imports System.Collections.Generic
'Imports System.ComponentModel
'Imports System.Drawing
'Imports System.Data
'Imports System.Text
'Imports System.Windows.Forms
'Imports System.Runtime.InteropServices

Namespace HTMLEditor.Windows.Forms
    ''' <summary>
    ''' Provides a user control that allows the user to edit HTML page.
    ''' </summary>
    <Description("Provides a user control that allows the user to edit HTML page."), ClassInterface(ClassInterfaceType.AutoDispatch)> _
    Partial Public Class HTMLTextBox
        Inherits UserControl
        ''' <summary>
        ''' Constructor
        ''' </summary>
        Public Sub New()
            dataUpdate = 0

            InitializeComponent()

            InitializeControls()
        End Sub

#Region "Properties"

        ''' <summary>
        ''' Gets or sets the current text in the HTMLTextBox
        ''' </summary>
        Public Overrides Property Text() As String
            Get
                Return WebBrowser1.DocumentText
            End Get
            Set(value As String)
                WebBrowser1.DocumentText = value.Replace(vbCr & vbLf, "<br>")
            End Set
        End Property

        ''' <summary>
        ''' Gets the collection of the image path in the HTMLTextBox
        ''' </summary>
        Public ReadOnly Property Images() As String()
            Get
                Dim images__1 As New List(Of String)()

                For Each element As HtmlElement In WebBrowser1.Document.Images
                    Dim image As String = element.GetAttribute("src")
                    If Not images__1.Contains(image) Then
                        images__1.Add(image)
                    End If
                Next

                Return images__1.ToArray()
            End Get
        End Property

#End Region

#Region "Methods"

        ''' <summary>
        ''' Initialize controls
        ''' </summary>
        Private Sub InitializeControls()
            BeginUpdate()

            ' Tool Bar
            For Each family As FontFamily In FontFamily.Families
                toolStripComboBoxName.Items.Add(family.Name)
            Next

            toolStripComboBoxSize.Items.AddRange(FontSize.All.ToArray())

            ' Web Browser
            WebBrowser1.DocumentText = String.Empty
            ' WebBrowser1.Document.Click += New HtmlElementEventHandler(AddressOf webBrowserBody_DocumentClick)
            ' WebBrowser1.Document.Focusing += New HtmlElementEventHandler(AddressOf webBrowserBody_DocumentFocusing)
            AddHandler WebBrowser1.Document.Click, AddressOf Me.webBrowserBody_DocumentClick
            AddHandler WebBrowser1.Document.Focusing, AddressOf Me.webBrowserBody_DocumentFocusing

            WebBrowser1.Document.ExecCommand("EditMode", False, Nothing)
            WebBrowser1.Document.ExecCommand("LiveResize", False, Nothing)

            EndUpdate()
        End Sub

        ''' <summary>
        ''' Refresh tool bar buttons
        ''' </summary>
        Private Sub RefreshToolBar()
            BeginUpdate()

            Try
                Dim document As mshtml.IHTMLDocument2 = DirectCast(WebBrowser1.Document.DomDocument, mshtml.IHTMLDocument2)

                toolStripComboBoxName.Text = document.queryCommandValue("FontName").ToString()
                toolStripComboBoxSize.SelectedItem = FontSize.Find(CInt(document.queryCommandValue("FontSize")))
                toolStripButtonBold.Checked = document.queryCommandState("Bold")
                toolStripButtonItalic.Checked = document.queryCommandState("Italic")
                toolStripButtonUnderline.Checked = document.queryCommandState("Underline")

                toolStripButtonNumbers.Checked = document.queryCommandState("InsertOrderedList")
                toolStripButtonBullets.Checked = document.queryCommandState("InsertUnorderedList")

                toolStripButtonLeft.Checked = document.queryCommandState("JustifyLeft")
                toolStripButtonCenter.Checked = document.queryCommandState("JustifyCenter")
                toolStripButtonRight.Checked = document.queryCommandState("JustifyRight")
                toolStripButtonFull.Checked = document.queryCommandState("JustifyFull")
            Catch e As Exception
                System.Diagnostics.Debug.WriteLine(e)
            Finally
                EndUpdate()
            End Try
        End Sub

#End Region

#Region "Updating"

        Private dataUpdate As Integer
        Private ReadOnly Property Updating() As Boolean
            Get
                Return dataUpdate <> 0
            End Get
        End Property

        Private Sub BeginUpdate()
            dataUpdate += 1
        End Sub
        Private Sub EndUpdate()
            dataUpdate -= 1
        End Sub

#End Region

#Region "Tool Bar"

        Private Sub toolStripComboBoxName_SelectedIndexChanged1(sender As Object, e As EventArgs) Handles toolStripComboBoxName.SelectedIndexChanged
            If Updating Then
                Return
            End If

            WebBrowser1.Document.ExecCommand("FontName", False, toolStripComboBoxName.Text)

        End Sub

        Private Sub toolStripButtonBold_Click1(sender As Object, e As EventArgs) Handles toolStripButtonBold.Click
            If Updating Then
                Return
            End If
            WebBrowser1.Document.ExecCommand("Bold", False, Nothing)
            RefreshToolBar()
        End Sub

        Private Sub toolStripComboBoxSize_SelectedIndexChanged1(sender As Object, e As EventArgs) Handles toolStripComboBoxSize.SelectedIndexChanged
            If Updating Then
                Return
            End If

            Dim size As Integer = If((toolStripComboBoxSize.SelectedItem Is Nothing), 1, TryCast(toolStripComboBoxSize.SelectedItem, FontSize).Value)
            WebBrowser1.Document.ExecCommand("FontSize", False, size)
        End Sub

        Private Sub toolStripButtonColor_Click1(sender As Object, e As EventArgs) Handles toolStripButtonColor.Click
            If Updating Then
                Return
            End If

            Dim fontcolor As Integer = CInt(DirectCast(WebBrowser1.Document.DomDocument, mshtml.IHTMLDocument2).queryCommandValue("ForeColor"))

            Dim dialog As New ColorDialog()
            dialog.Color = Color.FromArgb(&HFF, fontcolor And &HFF, (fontcolor >> 8) And &HFF, (fontcolor >> 16) And &HFF)

            Dim result As DialogResult = dialog.ShowDialog()
            If result = DialogResult.OK Then
                Dim color__1 As String = dialog.Color.Name
                If Not dialog.Color.IsNamedColor Then
                    color__1 = "#" & color__1.Remove(0, 2)
                End If

                WebBrowser1.Document.ExecCommand("ForeColor", False, color__1)
            End If
            RefreshToolBar()
        End Sub

        Private Sub toolStripButtonItalic_Click1(sender As Object, e As EventArgs) Handles toolStripButtonItalic.Click
            If Updating Then
                Return
            End If

            WebBrowser1.Document.ExecCommand("Italic", False, Nothing)
            RefreshToolBar()
        End Sub

        Private Sub toolStripButtonUnderline_Click1(sender As Object, e As EventArgs) Handles toolStripButtonUnderline.Click
            If Updating Then
                Return
            End If

            WebBrowser1.Document.ExecCommand("Underline", False, Nothing)
            RefreshToolBar()
        End Sub

        Private Sub toolStripButtonNumbers_Click1(sender As Object, e As EventArgs) Handles toolStripButtonNumbers.Click
            If Updating Then
                Return
            End If

            WebBrowser1.Document.ExecCommand("InsertOrderedList", False, Nothing)
            RefreshToolBar()
        End Sub

        Private Sub toolStripButtonBullets_Click1(sender As Object, e As EventArgs) Handles toolStripButtonBullets.Click
            If Updating Then
                Return
            End If

            WebBrowser1.Document.ExecCommand("InsertUnorderedList", False, Nothing)
            RefreshToolBar()
        End Sub

        Private Sub toolStripButtonOutdent_Click1(sender As Object, e As EventArgs) Handles toolStripButtonOutdent.Click
            If Updating Then
                Return
            End If

            WebBrowser1.Document.ExecCommand("Outdent", False, Nothing)
            RefreshToolBar()
        End Sub

        Private Sub toolStripButtonIndent_Click1(sender As Object, e As EventArgs) Handles toolStripButtonIndent.Click
            If Updating Then
                Return
            End If

            WebBrowser1.Document.ExecCommand("Indent", False, Nothing)
            RefreshToolBar()
        End Sub

        Private Sub toolStripButtonLeft_Click1(sender As Object, e As EventArgs) Handles toolStripButtonLeft.Click
            If Updating Then
                Return
            End If

            WebBrowser1.Document.ExecCommand("JustifyLeft", False, Nothing)
            RefreshToolBar()
        End Sub

        Private Sub toolStripButtonCenter_Click1(sender As Object, e As EventArgs) Handles toolStripButtonCenter.Click
            If Updating Then
                Return
            End If

            WebBrowser1.Document.ExecCommand("JustifyCenter", False, Nothing)
            RefreshToolBar()
        End Sub

        Private Sub toolStripButtonRight_Click1(sender As Object, e As EventArgs) Handles toolStripButtonRight.Click
            If Updating Then
                Return
            End If

            WebBrowser1.Document.ExecCommand("JustifyRight", False, Nothing)
            RefreshToolBar()
        End Sub

        Private Sub toolStripButtonFull_Click1(sender As Object, e As EventArgs) Handles toolStripButtonFull.Click
            If Updating Then
                Return
            End If

            WebBrowser1.Document.ExecCommand("JustifyFull", False, Nothing)
            RefreshToolBar()
        End Sub

        Private Sub toolStripButtonLine_Click1(sender As Object, e As EventArgs) Handles toolStripButtonLine.Click
            If Updating Then
                Return
            End If

            WebBrowser1.Document.ExecCommand("InsertHorizontalRule", False, Nothing)
            RefreshToolBar()
        End Sub

        Private Sub toolStripButtonHyperlink_Click1(sender As Object, e As EventArgs) Handles toolStripButtonHyperlink.Click
            If Updating Then
                Return
            End If

            WebBrowser1.Document.ExecCommand("CreateLink", True, Nothing)
            RefreshToolBar()
        End Sub

        Private Sub toolStripButtonPicture_Click1(sender As Object, e As EventArgs) Handles toolStripButtonPicture.Click
            If Updating Then
                Return
            End If

            WebBrowser1.Document.ExecCommand("InsertImage", True, Nothing)
            RefreshToolBar()
        End Sub

        Private Sub WebBrowser1_PreviewKeyDown(sender As Object, e As PreviewKeyDownEventArgs) Handles WebBrowser1.PreviewKeyDown
            If e.IsInputKey Then
                Return
            End If
            RefreshToolBar()
        End Sub

#End Region

#Region "Web Browser"


        Private Sub webBrowserBody_DocumentClick(sender As Object, e As HtmlElementEventArgs)
            RefreshToolBar()
        End Sub

        Private Sub webBrowserBody_DocumentFocusing(sender As Object, e As HtmlElementEventArgs)
            RefreshToolBar()
        End Sub
        Friend WithEvents ToolStrip1 As System.Windows.Forms.ToolStrip
        Private WithEvents toolStripComboBoxName As System.Windows.Forms.ToolStripComboBox
        Private WithEvents toolStripComboBoxSize As System.Windows.Forms.ToolStripComboBox
        Private WithEvents toolStripButtonBold As System.Windows.Forms.ToolStripButton
        Private WithEvents toolStripButtonItalic As System.Windows.Forms.ToolStripButton
        Private WithEvents toolStripButtonUnderline As System.Windows.Forms.ToolStripButton
        Private WithEvents toolStripButtonColor As System.Windows.Forms.ToolStripButton
        Private WithEvents toolStripSeparatorFont As System.Windows.Forms.ToolStripSeparator
        Private WithEvents toolStripButtonNumbers As System.Windows.Forms.ToolStripButton
        Private WithEvents toolStripButtonBullets As System.Windows.Forms.ToolStripButton
        Private WithEvents toolStripButtonOutdent As System.Windows.Forms.ToolStripButton
        Private WithEvents toolStripButtonIndent As System.Windows.Forms.ToolStripButton
        Private WithEvents toolStripSeparatorFormat As System.Windows.Forms.ToolStripSeparator
        Private WithEvents toolStripButtonLeft As System.Windows.Forms.ToolStripButton
        Private WithEvents toolStripButtonCenter As System.Windows.Forms.ToolStripButton
        Private WithEvents toolStripButtonRight As System.Windows.Forms.ToolStripButton
        Private WithEvents toolStripButtonFull As System.Windows.Forms.ToolStripButton
        Private WithEvents toolStripSeparatorAlign As System.Windows.Forms.ToolStripSeparator
        Private WithEvents toolStripButtonLine As System.Windows.Forms.ToolStripButton
        Private WithEvents toolStripButtonHyperlink As System.Windows.Forms.ToolStripButton
        Private WithEvents toolStripButtonPicture As System.Windows.Forms.ToolStripButton
        Private WithEvents toolStripButtonPrint As System.Windows.Forms.ToolStripButton

#End Region

#Region "Font Size"
        Private Class FontSize
            Private Shared allFontSize As List(Of FontSize) = Nothing
            Public Shared ReadOnly Property All() As List(Of FontSize)
                Get
                    If allFontSize Is Nothing Then
                        allFontSize = New List(Of FontSize)()
                        allFontSize.Add(New FontSize(8, 1))
                        allFontSize.Add(New FontSize(10, 2))
                        allFontSize.Add(New FontSize(12, 3))
                        allFontSize.Add(New FontSize(14, 4))
                        allFontSize.Add(New FontSize(18, 5))
                        allFontSize.Add(New FontSize(24, 6))
                        allFontSize.Add(New FontSize(36, 7))
                    End If

                    Return allFontSize
                End Get
            End Property

            Public Shared Function Find(value As Integer) As FontSize
                If value < 1 Then
                    Return All(0)
                End If

                If value > 7 Then
                    Return All(6)
                End If

                Return All(value - 1)
            End Function

            Private Sub New(display As Integer, value As Integer)
                displaySize = display
                valueSize = value
            End Sub

            Private valueSize As Integer
            Public ReadOnly Property Value() As Integer
                Get
                    Return valueSize
                End Get
            End Property

            Private displaySize As Integer
            Public ReadOnly Property Display() As Integer
                Get
                    Return displaySize
                End Get
            End Property

            Public Overrides Function ToString() As String
                Return displaySize.ToString()
            End Function
        End Class
#End Region

#Region "ToolStripComboBox"
        Private Class ToolStripComboBoxEx
            Inherits ToolStripComboBox
            Public Overrides Function GetPreferredSize(constrainingSize As Size) As Size
                Dim size As Size = MyBase.GetPreferredSize(constrainingSize)
                size.Width = Math.Max(Width, &H20)
                Return size
            End Function
        End Class
#End Region

        Private WithEvents WebBrowser1 As System.Windows.Forms.WebBrowser
        Private Sub InitializeComponent()
            Me.ToolStrip1 = New System.Windows.Forms.ToolStrip()
            Me.toolStripComboBoxName = New System.Windows.Forms.ToolStripComboBox()
            Me.toolStripComboBoxSize = New System.Windows.Forms.ToolStripComboBox()
            Me.toolStripSeparatorFont = New System.Windows.Forms.ToolStripSeparator()
            Me.toolStripSeparatorFormat = New System.Windows.Forms.ToolStripSeparator()
            Me.toolStripSeparatorAlign = New System.Windows.Forms.ToolStripSeparator()
            Me.WebBrowser1 = New System.Windows.Forms.WebBrowser()
            Me.toolStripButtonBold = New System.Windows.Forms.ToolStripButton()
            Me.toolStripButtonItalic = New System.Windows.Forms.ToolStripButton()
            Me.toolStripButtonUnderline = New System.Windows.Forms.ToolStripButton()
            Me.toolStripButtonColor = New System.Windows.Forms.ToolStripButton()
            Me.toolStripButtonNumbers = New System.Windows.Forms.ToolStripButton()
            Me.toolStripButtonBullets = New System.Windows.Forms.ToolStripButton()
            Me.toolStripButtonOutdent = New System.Windows.Forms.ToolStripButton()
            Me.toolStripButtonIndent = New System.Windows.Forms.ToolStripButton()
            Me.toolStripButtonLeft = New System.Windows.Forms.ToolStripButton()
            Me.toolStripButtonCenter = New System.Windows.Forms.ToolStripButton()
            Me.toolStripButtonRight = New System.Windows.Forms.ToolStripButton()
            Me.toolStripButtonFull = New System.Windows.Forms.ToolStripButton()
            Me.toolStripButtonLine = New System.Windows.Forms.ToolStripButton()
            Me.toolStripButtonHyperlink = New System.Windows.Forms.ToolStripButton()
            Me.toolStripButtonPicture = New System.Windows.Forms.ToolStripButton()
            Me.toolStripButtonPrint = New System.Windows.Forms.ToolStripButton()
            Me.ToolStrip1.SuspendLayout()
            Me.SuspendLayout()
            '
            'ToolStrip1
            '
            Me.ToolStrip1.BackColor = System.Drawing.SystemColors.Control
            Me.ToolStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.toolStripComboBoxName, Me.toolStripComboBoxSize, Me.toolStripButtonBold, Me.toolStripButtonItalic, Me.toolStripButtonUnderline, Me.toolStripButtonColor, Me.toolStripSeparatorFont, Me.toolStripButtonNumbers, Me.toolStripButtonBullets, Me.toolStripButtonOutdent, Me.toolStripButtonIndent, Me.toolStripSeparatorFormat, Me.toolStripButtonLeft, Me.toolStripButtonCenter, Me.toolStripButtonRight, Me.toolStripButtonFull, Me.toolStripSeparatorAlign, Me.toolStripButtonLine, Me.toolStripButtonHyperlink, Me.toolStripButtonPicture, Me.toolStripButtonPrint})
            Me.ToolStrip1.Location = New System.Drawing.Point(0, 0)
            Me.ToolStrip1.Name = "ToolStrip1"
            Me.ToolStrip1.Size = New System.Drawing.Size(578, 25)
            Me.ToolStrip1.TabIndex = 0
            Me.ToolStrip1.Text = "ToolStrip1"
            '
            'toolStripComboBoxName
            '
            Me.toolStripComboBoxName.BackColor = System.Drawing.SystemColors.Control
            Me.toolStripComboBoxName.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
            Me.toolStripComboBoxName.FlatStyle = System.Windows.Forms.FlatStyle.System
            Me.toolStripComboBoxName.Name = "toolStripComboBoxName"
            Me.toolStripComboBoxName.Size = New System.Drawing.Size(121, 25)
            '
            'toolStripComboBoxSize
            '
            Me.toolStripComboBoxSize.AutoSize = False
            Me.toolStripComboBoxSize.BackColor = System.Drawing.SystemColors.Control
            Me.toolStripComboBoxSize.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
            Me.toolStripComboBoxSize.FlatStyle = System.Windows.Forms.FlatStyle.System
            Me.toolStripComboBoxSize.Name = "toolStripComboBoxSize"
            Me.toolStripComboBoxSize.Size = New System.Drawing.Size(40, 25)
            '
            'toolStripSeparatorFont
            '
            Me.toolStripSeparatorFont.Name = "toolStripSeparatorFont"
            Me.toolStripSeparatorFont.Size = New System.Drawing.Size(6, 25)
            '
            'toolStripSeparatorFormat
            '
            Me.toolStripSeparatorFormat.Name = "toolStripSeparatorFormat"
            Me.toolStripSeparatorFormat.Size = New System.Drawing.Size(6, 25)
            '
            'toolStripSeparatorAlign
            '
            Me.toolStripSeparatorAlign.Name = "toolStripSeparatorAlign"
            Me.toolStripSeparatorAlign.Size = New System.Drawing.Size(6, 25)
            '
            'WebBrowser1
            '
            Me.WebBrowser1.Dock = System.Windows.Forms.DockStyle.Fill
            Me.WebBrowser1.Location = New System.Drawing.Point(0, 0)
            Me.WebBrowser1.MinimumSize = New System.Drawing.Size(20, 20)
            Me.WebBrowser1.Name = "WebBrowser1"
            Me.WebBrowser1.Size = New System.Drawing.Size(578, 237)
            Me.WebBrowser1.TabIndex = 1
            '
            'toolStripButtonBold
            '
            Me.toolStripButtonBold.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.toolStripButtonBold.Image = Global.HTMLTextBox.My.Resources.ToolBars.font_bold
            Me.toolStripButtonBold.ImageTransparentColor = System.Drawing.Color.Magenta
            Me.toolStripButtonBold.Name = "toolStripButtonBold"
            Me.toolStripButtonBold.Size = New System.Drawing.Size(23, 22)
            Me.toolStripButtonBold.Text = "ToolStripButton1"
            '
            'toolStripButtonItalic
            '
            Me.toolStripButtonItalic.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.toolStripButtonItalic.Image = Global.HTMLTextBox.My.Resources.ToolBars.font_italic
            Me.toolStripButtonItalic.ImageTransparentColor = System.Drawing.Color.Magenta
            Me.toolStripButtonItalic.Name = "toolStripButtonItalic"
            Me.toolStripButtonItalic.Size = New System.Drawing.Size(23, 22)
            Me.toolStripButtonItalic.Text = "ToolStripButton2"
            '
            'toolStripButtonUnderline
            '
            Me.toolStripButtonUnderline.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.toolStripButtonUnderline.Image = Global.HTMLTextBox.My.Resources.ToolBars.font_underline
            Me.toolStripButtonUnderline.ImageTransparentColor = System.Drawing.Color.Magenta
            Me.toolStripButtonUnderline.Name = "toolStripButtonUnderline"
            Me.toolStripButtonUnderline.Size = New System.Drawing.Size(23, 22)
            Me.toolStripButtonUnderline.Text = "ToolStripButton3"
            '
            'toolStripButtonColor
            '
            Me.toolStripButtonColor.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.toolStripButtonColor.Image = Global.HTMLTextBox.My.Resources.ToolBars.font_color
            Me.toolStripButtonColor.ImageTransparentColor = System.Drawing.Color.Magenta
            Me.toolStripButtonColor.Name = "toolStripButtonColor"
            Me.toolStripButtonColor.Size = New System.Drawing.Size(23, 22)
            Me.toolStripButtonColor.Text = "ToolStripButton4"
            '
            'toolStripButtonNumbers
            '
            Me.toolStripButtonNumbers.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.toolStripButtonNumbers.Image = Global.HTMLTextBox.My.Resources.ToolBars.format_numbers
            Me.toolStripButtonNumbers.ImageTransparentColor = System.Drawing.Color.Magenta
            Me.toolStripButtonNumbers.Name = "toolStripButtonNumbers"
            Me.toolStripButtonNumbers.Size = New System.Drawing.Size(23, 22)
            Me.toolStripButtonNumbers.Text = "ToolStripButton5"
            '
            'toolStripButtonBullets
            '
            Me.toolStripButtonBullets.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.toolStripButtonBullets.Image = Global.HTMLTextBox.My.Resources.ToolBars.format_bullets
            Me.toolStripButtonBullets.ImageTransparentColor = System.Drawing.Color.Magenta
            Me.toolStripButtonBullets.Name = "toolStripButtonBullets"
            Me.toolStripButtonBullets.Size = New System.Drawing.Size(23, 22)
            Me.toolStripButtonBullets.Text = "ToolStripButton6"
            '
            'toolStripButtonOutdent
            '
            Me.toolStripButtonOutdent.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.toolStripButtonOutdent.Image = Global.HTMLTextBox.My.Resources.ToolBars.format_outdent
            Me.toolStripButtonOutdent.ImageTransparentColor = System.Drawing.Color.Magenta
            Me.toolStripButtonOutdent.Name = "toolStripButtonOutdent"
            Me.toolStripButtonOutdent.Size = New System.Drawing.Size(23, 22)
            Me.toolStripButtonOutdent.Text = "ToolStripButton7"
            '
            'toolStripButtonIndent
            '
            Me.toolStripButtonIndent.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.toolStripButtonIndent.Image = Global.HTMLTextBox.My.Resources.ToolBars.format_indent
            Me.toolStripButtonIndent.ImageTransparentColor = System.Drawing.Color.Magenta
            Me.toolStripButtonIndent.Name = "toolStripButtonIndent"
            Me.toolStripButtonIndent.Size = New System.Drawing.Size(23, 22)
            Me.toolStripButtonIndent.Text = "ToolStripButton8"
            '
            'toolStripButtonLeft
            '
            Me.toolStripButtonLeft.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.toolStripButtonLeft.Image = Global.HTMLTextBox.My.Resources.ToolBars.align_left
            Me.toolStripButtonLeft.ImageTransparentColor = System.Drawing.Color.Magenta
            Me.toolStripButtonLeft.Name = "toolStripButtonLeft"
            Me.toolStripButtonLeft.Size = New System.Drawing.Size(23, 22)
            Me.toolStripButtonLeft.Text = "ToolStripButton9"
            '
            'toolStripButtonCenter
            '
            Me.toolStripButtonCenter.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.toolStripButtonCenter.Image = Global.HTMLTextBox.My.Resources.ToolBars.align_center
            Me.toolStripButtonCenter.ImageTransparentColor = System.Drawing.Color.Magenta
            Me.toolStripButtonCenter.Name = "toolStripButtonCenter"
            Me.toolStripButtonCenter.Size = New System.Drawing.Size(23, 22)
            Me.toolStripButtonCenter.Text = "ToolStripButton10"
            '
            'toolStripButtonRight
            '
            Me.toolStripButtonRight.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.toolStripButtonRight.Image = Global.HTMLTextBox.My.Resources.ToolBars.align_right
            Me.toolStripButtonRight.ImageTransparentColor = System.Drawing.Color.Magenta
            Me.toolStripButtonRight.Name = "toolStripButtonRight"
            Me.toolStripButtonRight.Size = New System.Drawing.Size(23, 22)
            Me.toolStripButtonRight.Text = "ToolStripButton11"
            '
            'toolStripButtonFull
            '
            Me.toolStripButtonFull.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.toolStripButtonFull.Image = Global.HTMLTextBox.My.Resources.ToolBars.align_none
            Me.toolStripButtonFull.ImageTransparentColor = System.Drawing.Color.Magenta
            Me.toolStripButtonFull.Name = "toolStripButtonFull"
            Me.toolStripButtonFull.Size = New System.Drawing.Size(23, 22)
            Me.toolStripButtonFull.Text = "ToolStripButton12"
            '
            'toolStripButtonLine
            '
            Me.toolStripButtonLine.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.toolStripButtonLine.Image = Global.HTMLTextBox.My.Resources.ToolBars.insert_line
            Me.toolStripButtonLine.ImageTransparentColor = System.Drawing.Color.Magenta
            Me.toolStripButtonLine.Name = "toolStripButtonLine"
            Me.toolStripButtonLine.Size = New System.Drawing.Size(23, 22)
            Me.toolStripButtonLine.Text = "ToolStripButton13"
            '
            'toolStripButtonHyperlink
            '
            Me.toolStripButtonHyperlink.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.toolStripButtonHyperlink.Image = Global.HTMLTextBox.My.Resources.ToolBars.insert_hyperlink
            Me.toolStripButtonHyperlink.ImageTransparentColor = System.Drawing.Color.Magenta
            Me.toolStripButtonHyperlink.Name = "toolStripButtonHyperlink"
            Me.toolStripButtonHyperlink.Size = New System.Drawing.Size(23, 22)
            Me.toolStripButtonHyperlink.Text = "ToolStripButton14"
            '
            'toolStripButtonPicture
            '
            Me.toolStripButtonPicture.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.toolStripButtonPicture.Image = Global.HTMLTextBox.My.Resources.ToolBars.insert_picture
            Me.toolStripButtonPicture.ImageTransparentColor = System.Drawing.Color.Magenta
            Me.toolStripButtonPicture.Name = "toolStripButtonPicture"
            Me.toolStripButtonPicture.Size = New System.Drawing.Size(23, 22)
            Me.toolStripButtonPicture.Text = "ToolStripButton15"
            '
            'toolStripButtonPrint
            '
            Me.toolStripButtonPrint.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
            Me.toolStripButtonPrint.Image = Global.HTMLTextBox.My.Resources.ToolBars.Print
            Me.toolStripButtonPrint.ImageTransparentColor = System.Drawing.Color.Magenta
            Me.toolStripButtonPrint.Name = "toolStripButtonPrint"
            Me.toolStripButtonPrint.Size = New System.Drawing.Size(23, 22)
            Me.toolStripButtonPrint.Text = "ToolStripButton16"
            '
            'HTMLTextBox
            '
            Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            Me.Controls.Add(Me.ToolStrip1)
            Me.Controls.Add(Me.WebBrowser1)
            Me.Name = "HTMLTextBox"
            Me.Size = New System.Drawing.Size(578, 237)
            Me.ToolStrip1.ResumeLayout(False)
            Me.ToolStrip1.PerformLayout()
            Me.ResumeLayout(False)
            Me.PerformLayout()

        End Sub


    
    End Class
End Namespace
 

algea

Doçent
Katılım
15 Temmuz 2011
Mesajlar
505
Reaksiyon puanı
22
Puanları
18
Zaten gerekli yerleri çevirmişsin HTMLEditor sorunsuz çalışıyor bir kaç yeri düzenledim o kadar. Dosyayı buradan indirebilirsin.
 

algea

Doçent
Katılım
15 Temmuz 2011
Mesajlar
505
Reaksiyon puanı
22
Puanları
18
Bilmem farkettin mi resimler gitmiyor. System.Net.Mail.Attachment olarak düzenlemek gerekecek sanırım.
 

Vatansever

Asistan
Katılım
23 Ağustos 2007
Mesajlar
405
Reaksiyon puanı
1
Puanları
18
Bilmem farkettin mi resimler gitmiyor. System.Net.Mail.Attachment olarak düzenlemek gerekecek sanırım.

Evet onu bende farkettim fakat bunun mümkün olup olmadığını bilmiyorum çünkü bilgisayarda yüklü bir sesmi ekliyorsun mail ise sadece html kaynak kodunu gönderiyor resmi göndermiyor ama bu nedenle mümkün olduğunu sanmıyorum yapılabiliyorsa nasıl yapıldığını bilmek isterim doğrusu ama bir internet sayfasını kopyala yapıştır yapınca gönderiyor çünkü ordaki resimler resim değil sadece link olduğu için mail adresime gidip mail'ime baktığımda internet sayfasındaki resimler görünüyor.

Birşey daha acaba bu projeyi gördün bilmek istediğim birşey var frmMain.vb içinden HTMLTextBox1.vb özelliklerine erişebiliniyormu yada tam tersi çok uğraştım olmadı yapmak istediğim çok basit mail projemde editörü biraz kısa tutmak istiyorum kısa mesajlara uygun boyutta ama bir butona basınca frmMain ile birlikte belirlediğim miktarda aşağıya doğru uzasın istiyorum fakat HTMLTextBox1 özelliklerine ulaşmayı beceremedim? mümkünse kodu nasıl yazmalıyım?


:yes:
 

engerex

Müdavim
Katılım
16 Ağustos 2008
Mesajlar
7,676
Reaksiyon puanı
26
Puanları
48
Ses, resim gibi ekler XXE, UUE gibi formatlara encode edilip maile ekleniyor olmalı.
 

algea

Doçent
Katılım
15 Temmuz 2011
Mesajlar
505
Reaksiyon puanı
22
Puanları
18
Private Sub HTMLTextBox_Resize(sender As Object, e As System.EventArgs) Handles Me.Resize bölümüne webbrowser1 ile ilgili değişkenleri ayarla. HTMLTextBox.Height ve Width değiştiğinde otamatik çeki düzen verirsin
 
Üst