예제 #1
0
 public Updater(Settings s)
 {
     this.settings = s;
     s["LastUpdateCheck"] = lastCheck;
     s["UpdateFrequency"] = updateFrequency;
     s["UpdateLocation"] = "";
     s["UpdateEnabled"] = enabled;
     s.Changed += new SettingsEventHandler(OnSettingChanged);
     StartTimer(5000); // give time for process to start & load
 }
예제 #2
0
        public virtual void OnSiteChanged()
        {
            HelpProvider hp = this.Site.GetService(typeof(HelpProvider)) as HelpProvider;
            if (hp != null) {
                hp.SetHelpKeyword(this, "Find");
                hp.SetHelpNavigator(this, HelpNavigator.KeywordIndex);
            }

            this.SuspendLayout();

            settings = (Settings)this.Site.GetService(typeof(Settings));

            SetCheckBoxValue(this.checkBoxXPath, "SearchXPath");
            SetCheckBoxValue(this.checkBoxWholeWord, "SearchWholeWord");
            SetCheckBoxValue(this.checkBoxRegex, "SearchRegex");
            SetCheckBoxValue(this.checkBoxMatchCase, "SearchMatchCase");

            Size s = this.ClientSize;
            object o = this.settings["FindMode"];
            if (o != null) {
                this.findOnly = (bool)o;
                SetFindModeControls(!this.findOnly);
            }

            object size = this.settings["SearchSize"];
            if (size != null && (Size)size != Size.Empty) {
                Size cs = (Size)size;
                s = new Size(cs.Width, cs.Height);
            }
            this.ClientSize = s;

            object location = this.settings["SearchWindowLocation"];
            if (location != null && (Point)location != Point.Empty) {
                Control ctrl = this.Site as Control;
                if (ctrl != null) {
                    Rectangle ownerBounds = ctrl.TopLevelControl.Bounds;
                    if (IsSameScreen((Point)location, ownerBounds)) {
                        this.Location = (Point)location;
                    } else {
                        this.Location = CenterPosition(ownerBounds);
                    }
                    this.StartPosition = FormStartPosition.Manual;
                }
            }

            this.ResumeLayout();
        }
예제 #3
0
 /// <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 );
 }
예제 #4
0
        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();
        }
예제 #5
0
        public UserSettings(Settings s)
        {
            this.settings = s;

            this.font = (Font)this.settings["Font"];
            this.fontName = font.Name + " " + font.SizeInPoints + " " + font.Style.ToString();
            Hashtable colors = (Hashtable)this.settings["Colors"];
            elementColor = (Color)colors["Element"];
            commentColor = (Color)colors["Comment"];
            attributeColor = (Color)colors["Attribute"];
            piColor = (Color)colors["PI"];
            textColor = (Color)colors["Text"];
            cdataColor = (Color)colors["CDATA"];
            backgroundColor = (Color)colors["Background"];
            updateLocation = (string)this.settings["UpdateLocation"];
            enableUpdate = (bool)this.settings["UpdateEnabled"];
            autoFormatOnSave = (bool)this.settings["AutoFormatOnSave"];
            indentLevel = (int)this.settings["IndentLevel"];
            indentChar = (IndentChar)this.settings["IndentChar"];
            newLineChars = Escape((string)this.settings["NewLineChars"]);
        }
예제 #6
0
        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);
        }