Showing posts with label controls. Show all posts
Showing posts with label controls. Show all posts

Winforms HTML Editor control – source code

A lot of people requested the source code, so I put it together in a small VS 2008 solution.

Feel free to download (Link at bottom of post).
Let me know of any problems

Basically what I did is:

  1. I extended this Windows Forms based text editor with HTML output control from Kevin (from codeproject) to use TinyMce as an editor.
  2. With this helpful control  HTML Viewer component from Nikhil
  3. and changed it, see Siag.Seca.WinForms.ServiceBrowser.Controls.Html.HtmlEditor

Reason: We wanted (in our Windows Forms application) to have the same look-and-feel as web users have with the web tinyMce editor.

 

View Mode (the easy part)

The usercontrol "Siag.Seca.WinForms.ServiceBrowser.Controls.Html.HTMLUserControl" is a wrapper around: "HtmlEditor"
Property HTMLUserControl.TextHtml  = my property from datasource

Edit Mode

Prerequisites

  • Subdirectory with tinymce (like on the web) called /tiny_mce
    this folder contains a .html file with the tinymce code
  • TinyEditWithReplace.htm
    that file has a placeholder for the HTML string


Go into Edit Mode

See Siag.Seca.WinForms.ServiceBrowser.Controls.Html.HtmlEditor

Method: cHANGEToolStripMenuItem_Click

using (EditDialog dialogForm = new EditDialog())
    {
        dialogForm.ChangeEditorHtmlText(this.TextHtml);

        if (dialogForm.ShowDialog() == DialogResult.OK)
        {
            this.TextHtml = dialogForm.TextHtml;
        }
    }

 

Siag.Seca.WinForms.ServiceBrowser.Controls.Html.EditDialog

Method: ChangeEditorHtmlText(string htmlTextOnInit)

string absolutePath = Path.GetDirectoryName(Application.ExecutablePath);
    string htmlText = File.ReadAllText(absolutePath + @"TinyEditWithReplace.htm"); // TODO change to use Path.Combine()

    // Now I replace '{ReplaceTEXT}'  with my html string property, and a bit more... :-)
    string filename = Path.GetTempFileName();
    File.WriteAllText(filename, htmlText, Encoding.UTF8);

    htmleditorEdit.NavigateTo(filename);

--> Now the control displays webbrowser.

Inside the webbrower there is tinyMce with the content from my datasource

User can edit the content with TinyMce
--> On OK  Click Handler
i read the string back from webbrowser, tinymce


Advanced

On how to add an attachment link to the HTML (string) see my blog post...

http://peitor.blogspot.com/2007/12/how-to-get-javasrcipt-returnvalue-from.html

 

Screens of my sample app


image
 Figure: Left side: HTML control in view mode - Right side: Source code of the HTMLEditor

 

image
Figure: Clicking on "Edit" brings the control into Edit mode

 

image
Figure: Edit mode (WYSIWYG HTML editor )

 

image
Figure: Example using databinding the control to a grid with HTML content

 

 

More screens can be found here on my older blog entry

 

NOTE

#1
tinyMce: Updated to current version 3.2.7
http://tinymce.moxiecode.com/download.php

#2
Have a look at the file: \SolutionItems\ValidHtmlText.txt   to configure layout of textarea and tinyMCE  

#3
On Build I have a Post build event that copies the tinyMce files and ValidHTMLtext to the output folder…

image

REM ---------------
REM IF "$(ConfigurationName)"=="Release" xcopy /Y /E "$(SolutionDir)SolutionItems\tiny_mce" "$(TargetDir)tiny_mce\" -- DON'T COPY whole tinyMCE on all builds
xcopy /Y /E "$(SolutionDir)SolutionItems\tiny_mce" "$(TargetDir)tiny_mce\"

xcopy /Y /E /i "$(SolutionDir)SolutionItems\tiny_mce\TinyEditWithReplace.htm" "$(TargetDir)tiny_mce\"
xcopy /Y /E /i "$(SolutionDir)SolutionItems\ValidHtmlText.txt" $(TargetDir)

REM ---------------

#4
Deployment problems –> see this blog post

 

disk_blue Download here

arrow_right_blue Please test, let me know of any problems!

arrow_right_blue Free to send suggestions. Make improvements and let me know!

Winforms: ListBox vs. ListView

Had some discussions about Lists and controls, like Listbox and Listview, and sometimes its difficult to distinguish those.

System.Windows.Forms.ListView

  • Inherits from Control
  • Represents a Windows list view control, which displays a collection of items that can be displayed using one of four different views
  • Windows Explorer like
  • Wrapper of the standard Win32 list view

more control over appearance
4 different view styles: iconview, small icon-view, list-view, details-view (report-view)
image   image   image   image

Multiple columns are possible
image
property Multicolumn = true
 

Heavier than the listbox

Has no DataSource property, Items must be added to Items property and must be ListViewItem

No design-time databinding,  -->  maybe an advantage :-)

 Msdn Link
http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.aspx

 

 

System.Windows.Forms.ListBox

  • Inherits from ListControl, common impl. for Listbox and ComboBox
  • Represents a Windows control to display a list of items

Datasource property can be used for databinding

More lightweight

Simple to use --> Use DataSource, or add your items to Items property

Msdn Link
http://msdn.microsoft.com/en-us/library/system.windows.forms.listbox.aspx

 

Essence

In very simple scenarios use Listbox or ListView, but try to use the DataGridView, or even a datagrid from a third vendor.

 

There exists also a rule from SSW on this.

Do Do you always use GridView instead of ListBox?

TinyMce with webeditor Control IN ACTION

Control hosted in Winforms Application:




Control in Editmode - new Form ShowDialog

devexpress Controls ....

These days im diving into a new project, where we use devexpress controls.
Mainly the xtraggrid and xtrabars

Next post will be about usage, handling, performance ... of this controls.

Infragistics controls compared ....

Infragistics Controls comparisonTranslation of the german post: Infragistics Controls Vergleich


In this post I show the results of a study made in our department about performance and handling in development with devexpress, Infragistics and Janus Controls

Infragistics controls
DevExpress Controls
Janus Controls


Information about:
- the company, number emloyees, clients, partner, references, presence in the market
- controls for which technology, .net2.0 .net3.0, support?
- sourcecode, quality
- performance of the single components
- usage of the controls in development, maintainment
- periodic regular updates? help? Support forum? Support mail, phone?
- what kind of controls? Prices?
- opinions from devleap members http://www.devleap.it/


Infragistics

Employees
Infragistics currently employs more than 100 industry professionals
Clients
IBM, Johnson & Johnson, Pfizer, Dell, United Airlines, Charles Schwab, AIG, Fidelity Group, Merrill Lynch
Partners
Microsoft, Sun, Ajilon Inc., Oracle, IBM, Borland
References (reference applications)
Tracker; Expense
Controls available for
Winforms; ASP.NET; COM; AJAX; Usability Testing,
Source Code?
YES
Source Code Quality
Very good, clean class diagram and composition
Usage of components
good; with many easy designers
Updates
regularly (4months); good
Help ms-help://
very good, with examples
Support Mail
Good fast reaction time
Controls
Grid
- Filter Row
- Extended functionality
UI Controls
-Explorerbar
-MDI Tabs
-Toolbar
-PanelManagement
Schedule Control: YES
Timeline Control
No; its in the Feature Request DB
Mail Question: Released when?
Productmanager Infragistics: "No, I can't provide that sort of information."
Prices
~1000€ for Winforms, Asp.net, com components with 1 year Priority Support and source code

opinions from Devleap
Translated by me… don’t blame me
Silvano: I know better Infragistics than the others and they seem very serious
Original ITALIAN: Io conosco In + Infragistics e mi sembrano molto seri. Altrimenti ho visto anche ComponentOne che non mi sembrano male, erano gratis dentro il VB.NET ResKit.
Brunetti: I know Infragistics, they are famous too for the web. The controls are a bit heavy and the assistance is not very good.
Original ITALIAN: Io conosco Infrangistics, sono famosi, anche per il web oltre che per windows.
In generale tutti questi prodotti sono un po' pesantoni e non offrono un'assistenza eccezionale.
Paolo: I vote for Infragistics, but only for Winforms, in Webforms they are horrible for a lot of Viewstate overhead…
Original ITALIAN: Io voto x Infragistics, ma solo per la parte Windows Forms.
La parte WebForm fa cacare con un sacco di Viewstate …
Marco: I vote for Infragistics too, but you should try ComponentOne, some of them seem very good. Infragistics is more a complete package (Winforms)
Original ITALIAN: Anche io voto Infragistics, ma digli di provare anche ComponentOne, per alcuni specifici componenti è meglio, ma come suite complessiva (per Windows Forms) Infragistics è più completo di tutti.



Performance of the grid control

Infragistics
testapplication:
Fetch data and paint the grid:
between 32 and 36 seconds (first time)

Sorting:
Bad average 10 seconds, the worst of all grids
No difference between sorting on numbers or text

Grouping:
between 28 and 30 seconds
Bad better than janus grid, but definitely worser than the XTRA Grid

Remove grouping:
circa 1 second, very fast

Filtering:
between 2,5 and 4,5 seconds, depending of the filter criteria
Bad Overall the slowest filter




devExpress
fetch data and paint the grid:
between 32 and 36 seconds (first time)
same performance as Infragistics

Sorting:
between 1,5 and 3 seconds, depending if I sort on numbers or text
Good definitely the fastest grid

Grouping:
between 2,5 and 4 seconds,
Good very fast on grouping

Remove grouping:

Good very fast, about 1 second

Filtering:
ActiveFilter, which filters on every keystroke.

Good Hard to compare to the others, cause it filters on every keypress, but this function seems very fast (between 2 and ~5 seconds), 5 seconds cause we input more letters




Janus Controls
fetch data and paint the grid:
between 36 and 39 seconds (first time)
Bad slowest buildup

sorting:
between 3 and 7,5 seconds , depending if we sort on numbers or text

grouping:
between 39 and 50 seconds,
Bad definitely the slowest grouping function of the 3 grids

remove grouping:
Bad slow, average 5-7 seconds

filtering:

Good fast filtering between 2 and 3,5 seconds




Comparison done with the actual versions from the software producers on 29 August 2005

Weird AutoSize Label

I like User Interfaces where the label with the description is beneath the textbox where you input the data...

Like this:


The Labels have 2 important properties set:


this.label1.AutoSize = true;
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;


BUT!!!!!!

When i change the text of the label in my code
(maybe localize it?)

It looks like this!



Grrr!!!
I have expected that it would be aligned right....


SOLUTION:
Dont use the AutoSize property, set it to false.
Set the width (Size) large enough...


this.label1.AutoSize = false;
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label1.Size = new System.Drawing.Size(100, 13);

Infragistics Controls Vergleich

Nur Vergleich Geschwindigkeit (Performance) in diesem Post mit DevExpress und Janus Controls DevExpress Controls Janus Controls Infos über: - HerstellerFirma, Mitarbeiteranzahl, Kunden, Partner, Referenzen, Marktpräsenz - Controls für welche Technologien? .net2.0 .net3.0 Support? - Quellcode, Qualität des Sourcecodes? - Performance der Komponenten, Wie ist ihre Benutzung? - Regelmässige Updates? Hilfe? Support Forum, Support Mail, Supoort Tel? - Welche Controls werden geboten? Preise? - Meinungen von devleap? Infragistics Mitarbeiter Infragistics currently employs more than 100 industry professionals Kunden IBM, Johnson & Johnson, Pfizer, Dell, United Airlines, Charles Schwab, AIG, Fidelity Group, Merrill Lynch Partner Microsoft, Sun, Ajilon Inc., Oracle, IBM, Borland Referenzen Tracker; Expense Controls für Winforms; ASP.NET; COM; AJAX; Usability Testing, Quellcode JA Quellocde Qualität Gut; Gute, saubere Klassenhierarchie Komponenten Benutzung Gut Updates regelmässig, sehr gut Hilfe ms-help:// "Sehr gut; Beschreibung mit Beispielen" Support Mail Schnelle Reaktionszeiten Controls Grid - Filter Row - Extended Funkt. UI Controls -Explorerbar -MDI Tabs -Toolbar -PanelManagement Schedule JA Timeline Control NEIN -> Feature Request DB; Bis wann? --> Produkmanager Infragistics: ""No, I can't provide that sort of information.""" Preise ~1000€ für Winforms, Asp.net, com Komponenten 1 Jahr Priority Support, Quellcode Meinungen von Devleap Slivano: Io conosco In + Infragistics e mi sembrano molto seri. Altrimenti ho visto anche ComponentOne che non mi sembrano male, erano gratis dentro il VB.NET ResKit. Brunetti: Io conosco Infrangistics, sono famosi, anche per il web oltre che per windows. In generale tutti questi prodotti sono un po' pesantoni e non offrono un'assistenza eccezionale. Paolo: Io voto x Infragistics, ma solo per la parte Windows Forms. La parte WebForm fa cacare con un sacco di Viewstate … Marco: Anche io voto Infragistics, ma digli di provare anche ComponentOne, per alcuni specifici componenti è meglio, ma come suite complessiva (per Windows Forms) Infragistics è più completo di tutti. Komponenten Geschwindigkeit Infragistics Testapplikation: Daten Holen und Grid zeichnen: zwischen 32 (Beim erstmaligen holen der Daten) und 36 Sekunden (Beim erneuten holen der Daten und neu zeichnen des Grids). Sortieren: Durchschnittlich 10 Sekunden, schnitt am schlechtesten von allen getesteten Grids ab. Kein Unterschied zwischen Nummern Sortierung und Text Sortierung. Gruppieren: Zwischen 28 und 30 Sekunden besser als Janus Grid jedoch deutlich langsamer als XTRA Grid. Gruppierung löschen: ca 1 Sekunde, sehr schnell. Filterfunktion: Zwischen 2,5 und 4,5 Sekunden, abhängig von Filterkriterium, insgesamt jedoch der langsamste Filter. devExpress Daten Holen und Grid zeichnen: zwischen 32 (Beim erstmaligen holen der Daten) und 36 Sekunden (Beim erneuten holen der Daten und neu zeichnen des Grids), gleiche Performance wie Infragistics Grid. Sortieren: Zwischen 1.5 und 3 Sekunden abhängig von Nummern Sortierung oder Text Sortierung, deutlich der schnellste Grid. Gruppieren: Zwischen 2.5 und 4 Sekunden sehr schnell beim Gruppieren. Gruppierung löschen: Sehr schnell ca 1-2 Sekunden. Filterfunktion: AktivFilter der gleich nach Eingabe filtert deshalb fällt Vergleich schwer, jedoch auch diese Funktion ziemlich schnell zwischen 2 und ~5 Sekunden (die 5 Sekunden ergeben sich allerdings nur durch die Verzögerung der Eingabe von mehreren Buchstaben) Janus Controls Daten Holen und Grid zeichnen: zwischen 36 (Beim erstmaligen holen der Daten) und 39 Sekunden (Beim erneuten holen der Daten und neu zeichnen des Grids), langsamster Aufbau. Sortieren: Zwischen 3 und 7,5 Sekunden abhängig von Nummern Sortierung oder Text Sortierung. Gruppieren: Zwischen 39 und 50 Sekunden eindeutig die langsamste Gruppierfunktion der 3 Grids. Gruppierung löschen: Langsam durchschnittlich 5- 7 Sekunden . Filterfunktion: schneller Filter zwischen 2 und 3,5 Sekunden.

ErrorProviders anpassen - Hintergrundfarbe eines Controls für Pflichtfelder

Supersache, Hintergrundfarbe für Pflichtfelder ROT färben... Noch nicht ganz das was ich suche, aber immerhin...

Interessant wäre noch ein Control welches sich anders einfärbt sobald der Text geändert wurde, dass man gleich sieht was man geändert hat seit dem letzten Speichern.

Link doesn't work anymore ;-(

Customisable ErrorProviders - The Code Project - Smart Client
REMOVED
href="http://www.codeproject.com/useritems/customerrorproviders.asp

How to suppress paint during resize

Von:Shawn Burke [MSFT] (sburke_online@no.spamming.microsoft.com) Betrifft:Re: How to suppress paint during resize View: Complete Thread (10 Beiträge) Rather than using a timer you should turn off resize-redraw, and use the Idle event to invalidate and cause the paint after the resize: public class MyControl : UserControl { private idleSet = false; protected void override OnResize(EventArgs e) { if (!idleSet) { idleSet = true; Application.Idle += new EventHandler(this.OnIdle); } base.OnResize(e); } private void OnIdle(object sender, EventArgs e) { idleSet = false; Application.Idle -= new EventHandler(this.OnIdle); Invalidate(); } } Suppress Paint on Resize

AutoScroll Panel mit eigenen Controls füllen


Wenn man Controls einem Panel hinzufügt und vorher .SuspendLayout() macht muss man danach Invalidate und PerformLayout machen damit di Scrollbars angezeigt werden, sonst checkt es dass .net Framework nicht. Autoscroll im Panel muss auf true sein als Voraussetzung. this.SuspendLayout(); panelDataGrid.SuspendLayout(); ... add Controls zu Panel.. .... this.ResumeLayout(true); panelDataGrid.ResumeLayout(true); panelDataGrid.Invalidate(); panelDataGrid.PerformLayout();

Latest Posts

Popular Posts