Ejemplo n.º 1
0
        public HtmlSite(HtmlControl hostControl)
        {
            if ((hostControl == null) || (!hostControl.IsHandleCreated))
            {
                throw new ArgumentException("hostControl");
            }

            this.hostControl = hostControl;
            this.hostControl.Resize += new EventHandler(this.HostControl_Resize);
        }
Ejemplo n.º 2
0
        public Document(CommandManager commandManager, string url)
        {
            this.url = url;
            this.permanentUrl = url;

            this.commandManager = commandManager;

            this.timer = new Timer();
            this.timer.Interval = 500;
            this.timer.Tick += new EventHandler(this.Timer_Tick);
            this.timer.Start();

            this.htmlControl = new HtmlControl();
            this.htmlControl.Dock = DockStyle.Fill;
            this.htmlControl.TabIndex = 0;
            this.htmlControl.IsDesignMode = true;

            if (this.url == null)
            {
                string tempPath = Path.GetTempFileName();
                if (File.Exists(tempPath))
                {
                    File.Delete(tempPath);
                }

                Directory.CreateDirectory(tempPath);

                string tempFileName = Path.ChangeExtension("Document" + documentIndex, ".htm");
                documentIndex++;

                this.url = Path.Combine(tempPath, tempFileName);

                StreamWriter writer = new StreamWriter(this.url);
                writer.Write("<html><body></body></html>");
                writer.Close();
            }

            StreamReader reader = File.OpenText(this.url);
            this.htmlControl.LoadHtml(reader.ReadToEnd(), this.url);
            reader.Close();

            CommandBarContextMenu contextMenu = new CommandBarContextMenu();
            this.commandManager.Add("Edit.Undo", contextMenu.Items.AddButton(CommandBarImageResource.Undo, "&Undo", null, Keys.Control | Keys.Z));
            this.commandManager.Add("Edit.Redo", contextMenu.Items.AddButton(CommandBarImageResource.Redo, "&Redo", null, Keys.Control | Keys.Y));
            contextMenu.Items.AddSeparator();
            this.commandManager.Add("Edit.Cut", contextMenu.Items.AddButton(CommandBarImageResource.Cut, "Cu&t", null, Keys.Control | Keys.X));
            this.commandManager.Add("Edit.Copy", contextMenu.Items.AddButton(CommandBarImageResource.Copy, "&Copy", null, Keys.Control | Keys.C));
            this.commandManager.Add("Edit.Paste", contextMenu.Items.AddButton(CommandBarImageResource.Paste, "&Paste", null, Keys.Control | Keys.V));
            this.commandManager.Add("Edit.Delete", contextMenu.Items.AddButton(CommandBarImageResource.Delete, "&Delete", null, Keys.Delete));
            this.htmlControl.ContextMenu = contextMenu;
        }
Ejemplo n.º 3
0
        public void Dispose()
        {
            this.commandManager.RemoveTarget(this);

            this.timer.Stop();
            this.timer.Tick -= new EventHandler(this.Timer_Tick);

            this.htmlControl.Dispose();
            this.htmlControl = null;

            if (this.permanentUrl == null)
            {
                string tempPath = Path.GetDirectoryName(this.url);
                if (Directory.Exists(tempPath))
                {
                    Directory.Delete(tempPath, true);
                }
            }
        }
Ejemplo n.º 4
0
 public HtmlSelection(HtmlControl control)
 {
     this.control = control;
     // this.minZIndex = 100;
     this.maxZIndex = 99;
 }
Ejemplo n.º 5
0
 internal HtmlElement(NativeMethods.IHTMLElement peer, HtmlControl owner)
 {
     Debug.Assert(peer != null);
     this.peer = peer;
     this.owner = owner;
 }
Ejemplo n.º 6
0
 public HtmlTextFormatting(HtmlControl control)
 {
     this.control = control;
 }
Ejemplo n.º 7
0
        public ReplaceDialog(HtmlControl _htmlControl)
        {
            this.htmlControl = _htmlControl;

            this.ClientSize = new System.Drawing.Size(360, 122);
            this.Text = "Replace";

            Label findWhatLabel = new Label();
            findWhatLabel.FlatStyle = FlatStyle.System;
            findWhatLabel.Location = new Point(8, 8 + 4);
            findWhatLabel.Size = new Size(56, 16);
            findWhatLabel.TabIndex = 0;
            findWhatLabel.Text = "Fi&nd what:";
            this.Controls.Add(findWhatLabel);

            // this.searchTextBox.BorderStyle = BorderStyle.FixedSingle;
            this.searchTextBox.Location = new Point(84, 8);
            this.searchTextBox.Size = new Size(184, 20);
            this.searchTextBox.TabIndex = 1;
            this.searchTextBox.Text = "";
            this.searchTextBox.TextChanged += new EventHandler(this.TextChangeSearchTextBox);
            this.Controls.Add(searchTextBox);

            this.findNextButton.FlatStyle = FlatStyle.System;
            this.findNextButton.Location = new Point(276, 8);
            this.findNextButton.TabIndex = 9;
            this.findNextButton.Text = "&Find Next";
            this.findNextButton.Enabled = false;
            this.findNextButton.Click += new EventHandler(this.ClickFindNextButton);
            this.Controls.Add(findNextButton);

            Button cancelButton = new Button();
            cancelButton.FlatStyle = FlatStyle.System;
            cancelButton.Location = new Point(276, 92);
            cancelButton.TabIndex = 12;
            cancelButton.Text = "Cancel";
            cancelButton.DialogResult = DialogResult.Cancel;
            this.Controls.Add(cancelButton);
            this.CancelButton = cancelButton;

            RadioButton downRadio = new RadioButton();
            downRadio.Checked = true;
            downRadio.FlatStyle = FlatStyle.System;
            downRadio.Location = new Point(48, 16);
            downRadio.Size = new Size(48, 16);
            downRadio.TabIndex = 7;
            downRadio.TabStop = true;
            downRadio.Text = "&Down";
            this.Controls.Add(downRadio);

            this.upRadio.FlatStyle = FlatStyle.System;
            this.upRadio.Location = new Point(8, 16);
            this.upRadio.Size = new System.Drawing.Size(40, 16);
            this.upRadio.TabIndex = 8;
            this.upRadio.Text = "&Up";
            this.Controls.Add(upRadio);

            GroupBox directionGroupBox = new GroupBox();
            directionGroupBox.Controls.Add(downRadio);
            directionGroupBox.Controls.Add(upRadio);
            directionGroupBox.FlatStyle = FlatStyle.System;
            directionGroupBox.Location = new Point(164, 60);
            directionGroupBox.Size = new Size(104, 40);
            directionGroupBox.TabIndex = 6;
            directionGroupBox.TabStop = false;
            directionGroupBox.Text = "Direction";
            this.Controls.Add(directionGroupBox);

            this.wholeCheckBox.FlatStyle = FlatStyle.System;
            this.wholeCheckBox.Location = new Point(8, 60 + 4);
            this.wholeCheckBox.Size = new Size(136, 16);
            this.wholeCheckBox.TabIndex = 4;
            this.wholeCheckBox.Text = "Match &whole word only";
            this.Controls.Add(wholeCheckBox);

            this.caseCheckBox.FlatStyle = FlatStyle.System;
            this.caseCheckBox.Location = new Point(8, 76 + 4);
            this.caseCheckBox.Size = new Size(128, 16);
            this.caseCheckBox.TabIndex = 5;
            this.caseCheckBox.Text = "Match &case";
            this.Controls.Add(caseCheckBox);

            Label replaceWithLabel = new Label();
            replaceWithLabel.FlatStyle = FlatStyle.System;
            replaceWithLabel.Location = new Point(8, 32 + 4);
            replaceWithLabel.Size = new Size(72, 16);
            replaceWithLabel.TabIndex = 2;
            replaceWithLabel.Text = "Re&place with:";
            this.Controls.Add(replaceWithLabel);

            // this.replaceTextBox.BorderStyle = BorderStyle.FixedSingle;
            this.replaceTextBox.Location = new Point(84, 32);
            this.replaceTextBox.Size = new Size(184, 20);
            this.replaceTextBox.TabIndex = 3;
            this.replaceTextBox.Text = "";
            this.Controls.Add(replaceTextBox);

            this.replaceAllButton.FlatStyle = FlatStyle.System;
            this.replaceAllButton.Location = new Point(276, 64);
            this.replaceAllButton.TabIndex = 11;
            this.replaceAllButton.Text = "Replace &All";
            this.replaceAllButton.Enabled = false;
            this.replaceAllButton.Click += new EventHandler(this.ClickReplaceAllButton);
            this.Controls.Add(replaceAllButton);

            this.replaceButton.FlatStyle = FlatStyle.System;
            this.replaceButton.Location = new Point(276, 36);
            this.replaceButton.TabIndex = 10;
            this.replaceButton.Text = "&Replace";
            this.replaceButton.Enabled = false;
            this.replaceButton.Click += new EventHandler(this.ClickReplaceButton);
            this.Controls.Add(replaceButton);

            this.searchTextBox.Focus();
        }