public object GetService(Type service) { if (service == typeof(UndoManager)) { return(this.undoManager); } else if (service == typeof(SchemaCache)) { return(this.settings["SchemaCache"]); } //else if (service == typeof(TreeView)) //{ // XmlTreeView view = (XmlTreeView)GetService(typeof(XmlTreeView)); // return view.TreeView; //} //else if (service == typeof(XmlTreeView)) //{ // if (this.xmlTreeView1 == null) // { // this.xmlTreeView1 = this.CreateTreeView(); // } // return this.xmlTreeView1; //} else if (service == typeof(XmlCache)) { if (null == this.model) { this.model = new XmlCache((IServiceProvider)this, (SchemaCache)this.settings["SchemaCache"], this.delayedActions); } return(this.model); } else if (service == typeof(Settings)) { return(this.settings); } else if (service == typeof(IIntellisenseProvider)) { if (this.xip == null) { this.xip = new XmlIntellisenseProvider(this.model); } return(this.xip); } else if (service == typeof(HelpProvider)) { return(this.helpProvider); } //else if (service == typeof(WebProxyService)) //{ // if (this._proxyService == null) // this._proxyService = new WebProxyService((IServiceProvider)this); // return this._proxyService; //} else if (service == typeof(DelayedActions)) { return(this.delayedActions); } return(null); }
public void SetSite(ISite site) { this.site = site; IServiceProvider sp = (IServiceProvider)site; this.resolver = new XmlProxyResolver(sp); this.model = (XmlCache)site.GetService(typeof(XmlCache)); this.model.ModelChanged += new EventHandler <ModelChangedEventArgs>(OnModelChanged); }
public void SetSite(ISite site) { // Overriding the Site property directly breaks the WinForms designer. this.Site = site; this.editor.Site = site; XmlCache model = (XmlCache)site.GetService(typeof(XmlCache)); model.ModelChanged += new EventHandler <ModelChangedEventArgs>(OnModelChanged); }
public void SetSite(ISite site) { this._site = site; this.xsltControl.SetSite(site); IServiceProvider sp = (IServiceProvider)site; this._model = (XmlCache)site.GetService(typeof(XmlCache)); this._model.ModelChanged -= new EventHandler <ModelChangedEventArgs>(OnModelChanged); this._model.ModelChanged += new EventHandler <ModelChangedEventArgs>(OnModelChanged); }
public void ValidateContext(XmlCache xcache) { this._cache = xcache; if (string.IsNullOrEmpty(_cache.FileName)) { _baseUri = null; } else { _baseUri = new Uri(new Uri(xcache.FileName), new Uri(".", UriKind.Relative)); } SchemaResolver resolver = xcache.SchemaResolver as SchemaResolver; resolver.Handler = OnValidationEvent; XmlDocument doc = xcache.Document; this._info = new XmlSchemaInfo(); this._nsResolver = new MyXmlNamespaceResolver(doc.NameTable); XmlSchemaSet set = new XmlSchemaSet(); // Make sure the SchemaCache is up to date with document. SchemaCache sc = xcache.SchemaCache; foreach (XmlSchema s in doc.Schemas.Schemas()) { sc.Add(s); } if (LoadSchemas(doc, set, resolver)) { set.ValidationEventHandler += OnValidationEvent; set.Compile(); set.ValidationEventHandler -= OnValidationEvent; } this._validator = new XmlSchemaValidator(doc.NameTable, set, _nsResolver, XmlSchemaValidationFlags.AllowXmlAttributes | XmlSchemaValidationFlags.ProcessIdentityConstraints | XmlSchemaValidationFlags.ProcessInlineSchema); this._validator.ValidationEventHandler += OnValidationEvent; this._validator.XmlResolver = resolver; this._validator.Initialize(); this._nsResolver.Context = doc; ValidateContent(doc); this._nsResolver.Context = doc; this._validator.EndValidation(); }
public void SetSite(ISite site) { // Overriding the Site property directly breaks the WinForms designer. this.Site = site; this.settings = (Settings)site.GetService(typeof(Settings)); if (this.settings != null) { this.settings.Changed += new SettingsEventHandler(settings_Changed); } settings_Changed(this, ""); this.editor.Site = site; XmlCache model = (XmlCache)site.GetService(typeof(XmlCache)); model.ModelChanged += new EventHandler <ModelChangedEventArgs>(OnModelChanged); }
public XmlIntellisenseProvider(XmlCache model) { this._model = model; }
protected virtual IIntellisenseProvider CreateIntellisenseProvider(XmlCache model, ISite site) { return new XmlIntellisenseProvider(this.model, site); }
public void Validate(XmlCache xcache) { this.ValidateContext(xcache); xcache.TypeInfoMap = typeInfo; // save schema type information for intellisense. }
public void ValidateContext(XmlCache xcache) { this.cache = xcache; if (string.IsNullOrEmpty(cache.FileName)) { baseUri = null; } else { baseUri = new Uri(new Uri(xcache.FileName), new Uri(".", UriKind.Relative)); } ValidationEventHandler handler = new ValidationEventHandler(OnValidationEvent); SchemaResolver resolver = xcache.SchemaResolver as SchemaResolver; resolver.Handler = handler; XmlDocument doc = xcache.Document; this.info = new XmlSchemaInfo(); this.nsResolver = new MyXmlNamespaceResolver(doc.NameTable); XmlSchemaSet set = new XmlSchemaSet(); // Make sure the SchemaCache is up to date with document. SchemaCache sc = xcache.SchemaCache; foreach (XmlSchema s in doc.Schemas.Schemas()) { sc.Add(s); } if (LoadSchemas(doc, set, resolver)) { set.ValidationEventHandler += handler; set.Compile(); } this.validator = new XmlSchemaValidator(doc.NameTable, set, nsResolver, XmlSchemaValidationFlags.AllowXmlAttributes | XmlSchemaValidationFlags.ProcessIdentityConstraints | XmlSchemaValidationFlags.ProcessInlineSchema); this.validator.ValidationEventHandler += handler; this.validator.XmlResolver = resolver; this.validator.Initialize(); this.nsResolver.Context = doc; ValidateContent(doc); this.nsResolver.Context = doc; this.validator.EndValidation(); }
public void SetSite(ISite site) { this.site = site; IServiceProvider sp = (IServiceProvider)site; this.resolver = new XmlProxyResolver(sp); this.model = (XmlCache)site.GetService(typeof(XmlCache)); this.model.ModelChanged -= new EventHandler<ModelChangedEventArgs>(OnModelChanged); this.model.ModelChanged += new EventHandler<ModelChangedEventArgs>(OnModelChanged); }
protected override object GetService(Type service) { if (service == typeof(UndoManager)){ return this.undoManager; } else if (service == typeof(SchemaCache)) { return this.model.SchemaCache; } else if (service == typeof(TreeView)) { XmlTreeView view = (XmlTreeView)GetService(typeof(XmlTreeView)); return view.TreeView; } else if (service == typeof(XmlTreeView)) { if (this.xmlTreeView1 == null) { this.xmlTreeView1 = this.CreateTreeView(); } return this.xmlTreeView1; } else if (service == typeof(XmlCache)) { if (null == this.model) { this.model = new XmlCache((IServiceProvider)this, (ISynchronizeInvoke)this); } return this.model; } else if (service == typeof(Settings)){ return this.settings; } else if (service == typeof(IIntellisenseProvider)) { if (this.ip == null) this.ip = CreateIntellisenseProvider(this.model, this); return this.ip; } else if (service == typeof(HelpProvider)) { return this.helpProvider1; } else if (service == typeof(WebProxyService)) { if (this.proxyService == null) this.proxyService = new WebProxyService((IServiceProvider)this); return this.proxyService; } else if (service == typeof(UserSettings)) { return new UserSettings(this.settings); } return base.GetService (service); }
/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } if (this.settings != null) { this.settings.Dispose(); this.settings = null; } if (this.model != null) { this.model.Dispose(); this.model = null; } IDisposable d = this.ip as IDisposable; if (d != null) { d.Dispose(); } this.ip = null; } base.Dispose( disposing ); }
public void ValidateContext(XmlCache xcache) { this.cache = xcache; if (string.IsNullOrEmpty(cache.FileName)) { baseUri = null; } else { baseUri = new Uri(new Uri(xcache.FileName), new Uri(".", UriKind.Relative)); } ValidationEventHandler handler = new ValidationEventHandler(OnValidationEvent); SchemaResolver resolver = xcache.SchemaResolver as SchemaResolver; resolver.Handler = handler; XmlDocument doc = xcache.Document; this.info = new XmlSchemaInfo(); this.nsResolver = new MyXmlNamespaceResolver(doc.NameTable); XmlSchemaSet set = new XmlSchemaSet(); // Make sure the SchemaCache is up to date with document. SchemaCache sc = xcache.SchemaCache; foreach (XmlSchema s in doc.Schemas.Schemas()) { sc.Add(s); } // hack to force application to validate with local copy of collada schema try { string appPath = Directory.GetCurrentDirectory(); set.Add("http://www.w3.org/XML/1998/namespace", appPath + "/xml.xsd"); set.Add("http://www.collada.org/2005/11/COLLADASchema", appPath + "/collada_schema_1_4.xsd"); } catch { Console.WriteLine("Cannot find xml.xmd or collada_schema_1_4.xsd" ); } if (LoadSchemas(doc, set, resolver)) { set.ValidationEventHandler += handler; set.Compile(); } this.validator = new XmlSchemaValidator(doc.NameTable, set, nsResolver, XmlSchemaValidationFlags.AllowXmlAttributes | XmlSchemaValidationFlags.ProcessIdentityConstraints | XmlSchemaValidationFlags.ProcessInlineSchema); this.validator.ValidationEventHandler += handler; this.validator.XmlResolver = resolver; this.validator.Initialize(); this.nsResolver.Context = doc; ValidateContent(doc); this.nsResolver.Context = doc; this.validator.EndValidation(); }
public FormMain() { this.settings = new Settings(); this.model = (XmlCache)GetService(typeof(XmlCache)); this.ip = (XmlIntellisenseProvider)GetService(typeof(XmlIntellisenseProvider)); //this.model = new XmlCache((ISynchronizeInvoke)this); this.undoManager = new UndoManager(1000); this.undoManager.StateChanged += new EventHandler(undoManager_StateChanged); this.SuspendLayout(); // // Required for Windows Form Designer support // InitializeComponent(); // Separated out so we can have virtual CreateTreeView without causing WinForms designer to barf. InitializeTreeView(); this.xmlTreeView1.Dock = System.Windows.Forms.DockStyle.None; this.xmlTreeView1.Size = this.tabPageTreeView.ClientSize; this.xmlTreeView1.Dock = System.Windows.Forms.DockStyle.Fill; this.undoLabel = this.undoToolStripMenuItem.Text; this.redoLabel = this.redoToolStripMenuItem.Text; // this.xsltViewer.SetSite(this); // this.dynamicHelpViewer.SetSite(this); CreateTabControl(); this.ResumeLayout(); InitializeHelp(this.helpProvider1); /* this.dynamicHelpViewer.DefaultStylesheetResource = "XmlNotepad.DynamicHelp.xslt"; this.dynamicHelpViewer.ShowFileStrip = false; */ model.FileChanged += new EventHandler(OnFileChanged); model.ModelChanged += new EventHandler<ModelChangedEventArgs>(OnModelChanged); recentFiles = new RecentFilesMenu(recentFilesToolStripMenuItem, this.comboBoxLocation); this.recentFiles.RecentFileSelected += new RecentFileHandler(OnRecentFileSelected); //this.resizer.Pane1 = this.xmlTreeView1; this.resizer.Pane1 = this.tabControlViews; this.resizer.Pane2 = this.tabControlLists; this.Controls.SetChildIndex(this.resizer, 0); this.taskList.Site = this; // populate default settings and provide type info. Font f = new Font("Courier New", 10, FontStyle.Regular); this.Font = f; this.settings["Font"] = f; System.Collections.Hashtable colors = new System.Collections.Hashtable(); colors["Element"] = Color.FromArgb(0, 64, 128); colors["Attribute"] = Color.Maroon; colors["Text"] = Color.Black; colors["Comment"] = Color.Green; colors["PI"] = Color.Purple; colors["CDATA"] = Color.Gray; colors["Background"] = Color.White; colors["ContainerBackground"] = Color.AliceBlue; this.settings["Colors"] = colors; this.settings["FileName"] = new Uri("/",UriKind.RelativeOrAbsolute); this.settings["WindowBounds"] = new Rectangle(0,0,0,0); this.settings["TaskListSize"] = 0; this.settings["TreeViewSize"] = 0; this.settings["RecentFiles"] = new Uri[0]; this.settings["SchemaCache"] = this.model.SchemaCache; this.settings["SearchLocation"] = new Point(0, 0); this.settings["SearchSize"] = new Size(0, 0); this.settings["FindMode"] = false; this.settings["SearchXPath"] = false; this.settings["SearchWholeWord"] = false; this.settings["SearchRegex"] = false; this.settings["SearchMatchCase"] = false; this.settings["LastUpdateCheck"] = DateTime.Now; this.settings["UpdateFrequency"] = TimeSpan.FromDays(20); this.settings["UpdateLocation"] = "http://download.microsoft.com/download/6/e/e/6eef2361-33d4-48a2-b52e-5827c7f2ad68/Updates.xml"; this.settings["UpdateEnabled"] = true; this.settings["AutoFormatOnSave"] = true; this.settings["IndentLevel"] = 2; this.settings["IndentChar"] = IndentChar.Space; this.settings["NewLineChars"] = "\r\n"; this.settings.Changed += new SettingsEventHandler(settings_Changed); // now that we have a font, override the tabControlViews font setting. this.xmlTreeView1.Font = this.Font; // Event wiring this.xmlTreeView1.SetSite(this); this.xmlTreeView1.SelectionChanged += new EventHandler(treeView1_SelectionChanged); this.xmlTreeView1.ClipboardChanged += new EventHandler(treeView1_ClipboardChanged); this.xmlTreeView1.NodeChanged += new EventHandler<NodeChangeEventArgs>(treeView1_NodeChanged); this.xmlTreeView1.KeyDown += new KeyEventHandler(treeView1_KeyDown); this.taskList.GridKeyDown += new KeyEventHandler(taskList_KeyDown); this.toolStripButtonUndo.Enabled = false; this.toolStripButtonRedo.Enabled = false; this.statusBarToolStripMenuItem.Checked = true; this.duplicateToolStripMenuItem.Enabled = false; this.findToolStripMenuItem.Enabled = true; this.replaceToolStripMenuItem.Enabled = true; this.DragOver += new DragEventHandler(Form1_DragOver); this.xmlTreeView1.TreeView.DragOver += new DragEventHandler(Form1_DragOver); this.DragDrop += new DragEventHandler(Form1_DragDrop); this.xmlTreeView1.TreeView.DragDrop += new DragEventHandler(Form1_DragDrop); this.AllowDrop = true; this.urlFormat = DataFormats.GetFormat("UniformResourceLocatorW"); ctxcutToolStripMenuItem.Click += new EventHandler(this.cutToolStripMenuItem_Click); ctxcutToolStripMenuItem.ImageIndex = this.cutToolStripMenuItem.ImageIndex; ctxMenuItemCopy.Click += new EventHandler(this.copyToolStripMenuItem_Click); ctxMenuItemCopy.ImageIndex = copyToolStripMenuItem.ImageIndex; ctxMenuItemPaste.Click += new EventHandler(this.pasteToolStripMenuItem_Click); ctxMenuItemPaste.ImageIndex = pasteToolStripMenuItem.ImageIndex; ctxMenuItemExpand.Click += new EventHandler(this.expandToolStripMenuItem_Click); ctxMenuItemCollapse.Click += new EventHandler(this.collapseToolStripMenuItem_Click); this.toolStripMenuItemUpdate.Visible = false; this.toolStripMenuItemUpdate.Click += new EventHandler(toolStripMenuItemUpdate_Click); // now set in virtual InitializeHelp() // // helpProvider1 // //this.helpProvider1.HelpNamespace = Application.StartupPath + "\\Help.chm"; //this.helpProvider1.Site = this; this.ContextMenuStrip = this.contextMenu1; New(); }
public XmlIntellisenseProvider(XmlCache model, ISite site) { this.model = model; this.site = site; }