Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel')
-rw-r--r--Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel/DesignerHost.cs30
-rw-r--r--Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel/Document.cs41
-rw-r--r--Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel/NameCreationService.cs16
3 files changed, 49 insertions, 38 deletions
diff --git a/Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel/DesignerHost.cs b/Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel/DesignerHost.cs
index 3434d8c816..c456a9fa99 100644
--- a/Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel/DesignerHost.cs
+++ b/Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel/DesignerHost.cs
@@ -74,8 +74,15 @@ namespace AspNetEdit.Editor.ComponentModel
{
get { return container; }
}
-
- public IComponent CreateComponent (Type componentClass, string name)
+
+ public IComponent CreateComponent (Type componentClass, string name)
+ {
+ //add to document, unless loading
+ bool addToDoc = (this.RootDocument != null);
+ return CreateComponent (componentClass, name, addToDoc);
+ }
+
+ internal IComponent CreateComponent (Type componentClass, string name, bool addToDoc)
{
System.Diagnostics.Trace.WriteLine("Attempting to create component "+name);
//check arguments
@@ -91,19 +98,18 @@ namespace AspNetEdit.Editor.ComponentModel
IComponent component = (IComponent) Activator.CreateInstance (componentClass);
//and add to container
- container.Add (component, name);
-
- //add to document, unless loading
- if (RootDocument != null) {
+ container.Add (component, name);
+
+ if (addToDoc) {
((Control)RootComponent).Controls.Add ((Control) component);
RootDocument.AddControl ((Control)component);
- }
- //select it
- ISelectionService sel = this.GetService (typeof (ISelectionService)) as ISelectionService;
- if (sel != null)
- sel.SetSelectedComponents (new IComponent[] {component});
-
+ //select it
+ ISelectionService sel = this.GetService (typeof (ISelectionService)) as ISelectionService;
+ if (sel != null)
+ sel.SetSelectedComponents (new IComponent[] {component});
+ }
+
System.Diagnostics.Trace.WriteLine("Created component "+name);
return component;
}
diff --git a/Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel/Document.cs b/Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel/Document.cs
index 34bfa115d1..11cda93139 100644
--- a/Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel/Document.cs
+++ b/Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel/Document.cs
@@ -71,8 +71,9 @@ namespace AspNetEdit.Editor.ComponentModel
public Document (Control parent, DesignerHost host, string document, string fileName)
{
initDocument (parent, host);
- this.document = DeserializeAndAdd (document);
-
+
+ Control[] controls;
+ aspParser.ProcessFragment (document, out controls, out this.document);
GetView ();
}
@@ -241,20 +242,15 @@ namespace AspNetEdit.Editor.ComponentModel
return serializedDoc;
}
- ///<summary>Converts a ASP.NET fragment to a a designer document fragment,
- /// and adds the controls and directives etc to the host.</summary>
- public string DeserializeAndAdd (string aspFragment)
+ public void InitialiseControls (IEnumerable controls)
{
- string document;
- Control[] controls;
-
- aspParser.ParseDocument (aspFragment, out controls, out document);
-
- foreach (Control c in controls) {
- OnInitMethodInfo.Invoke (c, new object[] {EventArgs.Empty});
- }
-
- return document;
+ foreach (Control c in controls)
+ InitialiseControl(c);
+ }
+
+ public static void InitialiseControl (Control control)
+ {
+ OnInitMethodInfo.Invoke (control, new object[] {EventArgs.Empty});
}
//modes for the Serializing parser
@@ -333,9 +329,14 @@ namespace AspNetEdit.Editor.ComponentModel
}
#region add/remove/update controls
+
+ bool suppressAddControl = false;
public void AddControl (Control control)
{
+ if (suppressAddControl) return;
+
+ System.Console.WriteLine("AddControl method called");
OnInitMethodInfo.Invoke (control, new object[] {EventArgs.Empty});
view.AddControl (control);
}
@@ -352,7 +353,15 @@ namespace AspNetEdit.Editor.ComponentModel
public void InsertFragment (string fragment)
{
- view.InsertFragment (fragment);
+ Control[] controls;
+ string doc;
+ aspParser.ProcessFragment (fragment, out controls, out doc);
+ view.InsertFragment (doc);
+
+ //FIXME: when controls are inserted en masse using InsertFragment, the designer surface
+ //doesn't seem to display then properly till they've been updated
+ foreach (Control c in controls)
+ view.UpdateRender (c);
}
#endregion
diff --git a/Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel/NameCreationService.cs b/Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel/NameCreationService.cs
index 818dae819d..7a5bdf34aa 100644
--- a/Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel/NameCreationService.cs
+++ b/Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel/NameCreationService.cs
@@ -48,16 +48,12 @@ namespace AspNetEdit.Editor.ComponentModel
//check existing components with name of same form
// and make suffixNumber bigger than the greatest of them
foreach (IComponent comp in container.Components) {
- if (comp.Site.Name.StartsWith (dataType.Name)) {
- string str = comp.Site.Name.Remove (0, dataType.Name.Length);
- //TODO: Use int.TryParse in .NET 2.0
- try {
- int val = int.Parse (str);
- if (val >= suffixNumber)
- suffixNumber = val + 1;
- }
- catch (Exception ex) {}
- }
+ if (comp.Site.Name.ToLowerInvariant().StartsWith (dataType.Name.ToLowerInvariant())) {
+ string str = comp.Site.Name.Substring(dataType.Name.Length);
+ int val;
+ if (int.TryParse(str, out val) && val >= suffixNumber)
+ suffixNumber = val + 1;
+ }
}
return dataType.Name + suffixNumber.ToString ();