Added some more HTML elements to the text toolbox
svn path=/trunk/aspeditor/; revision=49619
This commit is contained in:
Родитель
88b38ecb01
Коммит
b4d890351a
|
@ -26,8 +26,8 @@
|
|||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
* USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
*/
|
||||
|
||||
using System;
|
||||
using Gtk;
|
||||
using GtkSharp;
|
||||
|
@ -35,7 +35,7 @@ using AspNetEdit.Editor;
|
|||
using AspNetEdit.Editor.UI;
|
||||
using AspNetEdit.Editor.ComponentModel;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Drawing.Design;
|
||||
using System.ComponentModel.Design.Serialization;
|
||||
using System.IO;
|
||||
|
@ -45,17 +45,17 @@ namespace AspNetEdit.SampleHost
|
|||
{
|
||||
class SampleHost
|
||||
{
|
||||
static DesignerHost host;
|
||||
static Frame geckoFrame;
|
||||
static DesignerHost host;
|
||||
static Frame geckoFrame;
|
||||
static AspNetEdit.Editor.ComponentModel.ToolboxService toolboxService;
|
||||
|
||||
static void Main ()
|
||||
{
|
||||
#if TRACE
|
||||
System.Diagnostics.TextWriterTraceListener listener
|
||||
= new System.Diagnostics.TextWriterTraceListener (System.Console.Out);
|
||||
System.Diagnostics.Trace.Listeners.Add (listener);
|
||||
#endif
|
||||
{
|
||||
#if TRACE
|
||||
System.Diagnostics.TextWriterTraceListener listener
|
||||
= new System.Diagnostics.TextWriterTraceListener (System.Console.Out);
|
||||
System.Diagnostics.Trace.Listeners.Add (listener);
|
||||
#endif
|
||||
|
||||
Application.Init ();
|
||||
|
||||
|
@ -80,8 +80,8 @@ namespace AspNetEdit.SampleHost
|
|||
#endregion
|
||||
|
||||
#region Toolbar
|
||||
|
||||
// * Save/Open
|
||||
|
||||
// * Save/Open
|
||||
|
||||
Toolbar buttons = new Toolbar ();
|
||||
outerBox.PackStart (buttons, false, false, 0);
|
||||
|
@ -92,10 +92,10 @@ namespace AspNetEdit.SampleHost
|
|||
|
||||
ToolButton openButton = new ToolButton(Stock.Open);
|
||||
buttons.Add(openButton);
|
||||
openButton.Clicked += new EventHandler(openButton_Clicked);
|
||||
|
||||
buttons.Add (new SeparatorToolItem());
|
||||
|
||||
openButton.Clicked += new EventHandler(openButton_Clicked);
|
||||
|
||||
buttons.Add (new SeparatorToolItem());
|
||||
|
||||
// * Clipboard
|
||||
|
||||
ToolButton undoButton = new ToolButton (Stock.Undo);
|
||||
|
@ -116,36 +116,36 @@ namespace AspNetEdit.SampleHost
|
|||
|
||||
ToolButton pasteButton = new ToolButton (Stock.Paste);
|
||||
buttons.Add (pasteButton);
|
||||
pasteButton.Clicked += new EventHandler (pasteButton_Clicked);
|
||||
|
||||
buttons.Add (new SeparatorToolItem());
|
||||
|
||||
// * Text style
|
||||
|
||||
pasteButton.Clicked += new EventHandler (pasteButton_Clicked);
|
||||
|
||||
buttons.Add (new SeparatorToolItem());
|
||||
|
||||
// * Text style
|
||||
|
||||
ToolButton boldButton = new ToolButton (Stock.Bold);
|
||||
buttons.Add (boldButton);
|
||||
boldButton.Clicked += new EventHandler (boldButton_Clicked);
|
||||
|
||||
boldButton.Clicked += new EventHandler (boldButton_Clicked);
|
||||
|
||||
ToolButton italicButton = new ToolButton (Stock.Italic);
|
||||
buttons.Add (italicButton);
|
||||
italicButton.Clicked += new EventHandler (italicButton_Clicked);
|
||||
|
||||
italicButton.Clicked += new EventHandler (italicButton_Clicked);
|
||||
|
||||
ToolButton underlineButton = new ToolButton (Stock.Underline);
|
||||
buttons.Add (underlineButton);
|
||||
underlineButton.Clicked += new EventHandler (underlineButton_Clicked);
|
||||
|
||||
underlineButton.Clicked += new EventHandler (underlineButton_Clicked);
|
||||
|
||||
ToolButton indentButton = new ToolButton (Stock.Indent);
|
||||
buttons.Add (indentButton);
|
||||
indentButton.Clicked += new EventHandler (indentButton_Clicked);
|
||||
|
||||
indentButton.Clicked += new EventHandler (indentButton_Clicked);
|
||||
|
||||
ToolButton unindentButton = new ToolButton (Stock.Unindent);
|
||||
buttons.Add (unindentButton);
|
||||
unindentButton.Clicked += new EventHandler (unindentButton_Clicked);
|
||||
|
||||
buttons.Add (new SeparatorToolItem());
|
||||
|
||||
// * Toolbox
|
||||
|
||||
unindentButton.Clicked += new EventHandler (unindentButton_Clicked);
|
||||
|
||||
buttons.Add (new SeparatorToolItem());
|
||||
|
||||
// * Toolbox
|
||||
|
||||
ToolButton toolboxAddButton = new ToolButton (Stock.Add);
|
||||
buttons.Add (toolboxAddButton);
|
||||
toolboxAddButton.Clicked += new EventHandler (toolboxAddButton_Clicked);
|
||||
|
@ -157,15 +157,15 @@ namespace AspNetEdit.SampleHost
|
|||
//set up the services
|
||||
ServiceContainer services = new ServiceContainer ();
|
||||
services.AddService (typeof (INameCreationService), new NameCreationService ());
|
||||
services.AddService (typeof (ISelectionService), new SelectionService ());
|
||||
services.AddService (typeof (ISelectionService), new SelectionService ());
|
||||
services.AddService (typeof (IEventBindingService), new EventBindingService (window));
|
||||
services.AddService (typeof (ITypeResolutionService), new TypeResolutionService ());
|
||||
ExtenderListService extListServ = new AspNetEdit.Editor.ComponentModel.ExtenderListService ();
|
||||
services.AddService (typeof (IExtenderListService), extListServ);
|
||||
services.AddService (typeof (IExtenderProviderService), extListServ);
|
||||
services.AddService (typeof (ITypeDescriptorFilterService), new TypeDescriptorFilterService ());
|
||||
toolboxService = new ToolboxService ();
|
||||
services.AddService (typeof (IToolboxService), toolboxService);
|
||||
services.AddService (typeof (IExtenderProviderService), extListServ);
|
||||
services.AddService (typeof (ITypeDescriptorFilterService), new TypeDescriptorFilterService ());
|
||||
toolboxService = new ToolboxService ();
|
||||
services.AddService (typeof (IToolboxService), toolboxService);
|
||||
|
||||
//create our host
|
||||
host = new DesignerHost(services);
|
||||
|
@ -174,23 +174,37 @@ namespace AspNetEdit.SampleHost
|
|||
|
||||
#endregion
|
||||
|
||||
#region Designer UI and panels
|
||||
#region Designer UI and panels
|
||||
|
||||
IRootDesigner rootDesigner = (IRootDesigner) host.GetDesigner (host.RootComponent);
|
||||
RootDesignerView designerView = (RootDesignerView) rootDesigner.GetView (ViewTechnology.Passthrough);
|
||||
geckoFrame.Add (designerView);
|
||||
|
||||
PropertyGrid p = new PropertyGrid (services);
|
||||
PropertyGrid p = new PropertyGrid (services);
|
||||
p.WidthRequest = 200;
|
||||
rightBox.Pack2 (p, false, false);
|
||||
|
||||
Toolbox toolbox = new Toolbox (services);
|
||||
leftBox.Pack1 (toolbox, false, false);
|
||||
toolboxService.PopulateFromAssembly (System.Reflection.Assembly.GetAssembly (typeof (System.Web.UI.Control)));
|
||||
toolboxService.PopulateFromAssembly (System.Reflection.Assembly.GetAssembly (typeof (System.Web.UI.Control)));
|
||||
toolboxService.AddToolboxItem (new TextToolboxItem ("<table><tr><td></td><td></td></tr><tr><td></td><td></td></tr></table>", "Table"), "Html");
|
||||
toolbox.UpdateCategories ();
|
||||
toolboxService.AddToolboxItem (new TextToolboxItem ("<div style=\"width: 100px; height: 100px;\"></div>", "Div"), "Html");
|
||||
toolboxService.AddToolboxItem (new TextToolboxItem ("<hr />", "Horizontal Rule"), "Html");
|
||||
toolboxService.AddToolboxItem (new TextToolboxItem ("<select><option></option></select>", "Select"), "Html");
|
||||
toolboxService.AddToolboxItem (new TextToolboxItem ("<img src=\"\" />", "Image"), "Html");
|
||||
toolboxService.AddToolboxItem (new TextToolboxItem ("<textarea cols=\"20\" rows=\"2\"></textarea>", "Textarea"), "Html");
|
||||
toolboxService.AddToolboxItem (new TextToolboxItem ("<input type=\"hidden\" />", "Input [Hidden]"), "Html");
|
||||
toolboxService.AddToolboxItem (new TextToolboxItem ("<input type=\"radio\" />", "Input [Radio]"), "Html");
|
||||
toolboxService.AddToolboxItem (new TextToolboxItem ("<input type=\"checkbox\" />", "Input [Checkbox]"), "Html");
|
||||
toolboxService.AddToolboxItem (new TextToolboxItem ("<input type=\"password\" />", "Input [Password]"), "Html");
|
||||
toolboxService.AddToolboxItem (new TextToolboxItem ("<input type=\"file\" />", "Input [File]"), "Html");
|
||||
toolboxService.AddToolboxItem (new TextToolboxItem ("<input type=\"text\" />", "Input [Text]"), "Html");
|
||||
toolboxService.AddToolboxItem (new TextToolboxItem ("<input type=\"submit\" value=\"submit\" />", "Input [Submit]"), "Html");
|
||||
toolboxService.AddToolboxItem (new TextToolboxItem ("<input type=\"reset\" value=\"reset\" />", "Input [Reset]"), "Html");
|
||||
toolboxService.AddToolboxItem (new TextToolboxItem ("<input type=\"button\" value=\"button\" />", "Input [Button]"), "Html");
|
||||
toolbox.UpdateCategories ();
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
window.ShowAll ();
|
||||
Application.Run ();
|
||||
|
@ -212,13 +226,13 @@ namespace AspNetEdit.SampleHost
|
|||
fcd.SetFilename (((System.Web.UI.Control)host.RootComponent).ID + ".aspx");
|
||||
|
||||
ResponseType response = (ResponseType) fcd.Run();
|
||||
fcd.Hide();
|
||||
|
||||
if (response == ResponseType.Ok && fcd.Filename != null)
|
||||
using (FileStream fileStream = new FileStream (fcd.Filename, FileMode.Create))
|
||||
{
|
||||
if (fileStream == null)
|
||||
return;
|
||||
fcd.Hide();
|
||||
|
||||
if (response == ResponseType.Ok && fcd.Filename != null)
|
||||
using (FileStream fileStream = new FileStream (fcd.Filename, FileMode.Create))
|
||||
{
|
||||
if (fileStream == null)
|
||||
return;
|
||||
host.SaveDocument (fileStream);
|
||||
}
|
||||
fcd.Destroy ();
|
||||
|
@ -241,9 +255,9 @@ namespace AspNetEdit.SampleHost
|
|||
using (FileStream fileStream = new FileStream (fcd.Filename, FileMode.Open))
|
||||
{
|
||||
if (fileStream == null)
|
||||
return;
|
||||
return;
|
||||
|
||||
host.Reset ();
|
||||
host.Reset ();
|
||||
|
||||
host.Load (fileStream, fcd.Filename);
|
||||
host.Activate ();
|
||||
|
@ -252,7 +266,7 @@ namespace AspNetEdit.SampleHost
|
|||
}
|
||||
|
||||
static void redoButton_Clicked (object sender, EventArgs e)
|
||||
{
|
||||
{
|
||||
host.RootDocument.DoCommand (EditorCommand.Redo);
|
||||
}
|
||||
|
||||
|
@ -274,33 +288,33 @@ namespace AspNetEdit.SampleHost
|
|||
static void pasteButton_Clicked (object sender, EventArgs e)
|
||||
{
|
||||
host.RootDocument.DoCommand (EditorCommand.Paste);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void italicButton_Clicked (object sender, EventArgs e)
|
||||
{
|
||||
host.RootDocument.DoCommand (EditorCommand.Italic);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void boldButton_Clicked (object sender, EventArgs e)
|
||||
{
|
||||
host.RootDocument.DoCommand (EditorCommand.Bold);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void underlineButton_Clicked (object sender, EventArgs e)
|
||||
{
|
||||
host.RootDocument.DoCommand (EditorCommand.Underline);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void indentButton_Clicked (object sender, EventArgs e)
|
||||
{
|
||||
host.RootDocument.DoCommand (EditorCommand.Indent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void unindentButton_Clicked (object sender, EventArgs e)
|
||||
{
|
||||
host.RootDocument.DoCommand (EditorCommand.Outdent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void toolboxAddButton_Clicked (object sender, EventArgs e)
|
||||
{
|
||||
FileChooserDialog fcd = new FileChooserDialog ("Add custom controls...", (Window)((Widget)sender).Toplevel, FileChooserAction.Open);
|
||||
|
@ -314,14 +328,14 @@ namespace AspNetEdit.SampleHost
|
|||
ResponseType response = (ResponseType) fcd.Run( );
|
||||
fcd.Hide ();
|
||||
|
||||
if (response == ResponseType.Ok && fcd.Filename != null)
|
||||
try{
|
||||
System.Reflection.Assembly a = System.Reflection.Assembly.LoadFrom (fcd.Filename);
|
||||
toolboxService.PopulateFromAssembly (a);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
//TODO: handle this better!
|
||||
System.Diagnostics.Trace.WriteLine ("Could not load assembly \"" + fcd.Filename + "\".");
|
||||
if (response == ResponseType.Ok && fcd.Filename != null)
|
||||
try{
|
||||
System.Reflection.Assembly a = System.Reflection.Assembly.LoadFrom (fcd.Filename);
|
||||
toolboxService.PopulateFromAssembly (a);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
//TODO: handle this better!
|
||||
System.Diagnostics.Trace.WriteLine ("Could not load assembly \"" + fcd.Filename + "\".");
|
||||
}
|
||||
fcd.Destroy();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче