Keresés

Új hozzászólás Aktív témák

  • pmonitor

    aktív tag

    válasz pmonitor #9497 üzenetére

    Talán 4 perc is volt... Ezért írtam, hogy tudni kell, hogy mit csinál az ember fia/lánya. :)
    using System;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Security.Permissions;

    [PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
    public class Form1 : Form
    {
    private IContainer components;
    private WebBrowser webBrowser1;

    private MenuStrip menuStrip1;
    private ToolStripMenuItem fileToolStripMenuItem,
    saveAsToolStripMenuItem, printToolStripMenuItem,
    printPreviewToolStripMenuItem, exitToolStripMenuItem,
    pageSetupToolStripMenuItem, propertiesToolStripMenuItem;
    private ToolStripSeparator toolStripSeparator1, toolStripSeparator2;

    private ToolStrip toolStrip1, toolStrip2;
    private ToolStripTextBox toolStripTextBox1;
    private ToolStripButton goButton, backButton,
    forwardButton, stopButton, refreshButton,
    homeButton, searchButton, printButton;

    private StatusStrip statusStrip1;
    private ToolStripStatusLabel toolStripStatusLabel1;

    public Form1()
    {
    // Create the form layout. If you are using Visual Studio,
    // you can replace this code with code generated by the designer.
    InitializeComponent();

    // The following events are not visible in the designer, so
    // you must associate them with their event-handlers in code.
    webBrowser1.CanGoBackChanged +=
    new EventHandler(webBrowser1_CanGoBackChanged);
    webBrowser1.CanGoForwardChanged +=
    new EventHandler(webBrowser1_CanGoForwardChanged);
    webBrowser1.DocumentTitleChanged +=
    new EventHandler(webBrowser1_DocumentTitleChanged);
    webBrowser1.StatusTextChanged +=
    new EventHandler(webBrowser1_StatusTextChanged);

    // Load the user's home page.
    webBrowser1.GoHome();
    }

    // Displays the Save dialog box.
    private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
    {
    webBrowser1.ShowSaveAsDialog();
    }

    // Displays the Page Setup dialog box.
    private void pageSetupToolStripMenuItem_Click(object sender, EventArgs e)
    {
    webBrowser1.ShowPageSetupDialog();
    }

    // Displays the Print dialog box.
    private void printToolStripMenuItem_Click(object sender, EventArgs e)
    {
    webBrowser1.ShowPrintDialog();
    }

    // Displays the Print Preview dialog box.
    private void printPreviewToolStripMenuItem_Click(
    object sender, EventArgs e)
    {
    webBrowser1.ShowPrintPreviewDialog();
    }

    // Displays the Properties dialog box.
    private void propertiesToolStripMenuItem_Click(
    object sender, EventArgs e)
    {
    webBrowser1.ShowPropertiesDialog();
    }

    // Selects all the text in the text box when the user clicks it.
    private void toolStripTextBox1_Click(object sender, EventArgs e)
    {
    toolStripTextBox1.SelectAll();
    }

    // Navigates to the URL in the address box when
    // the ENTER key is pressed while the ToolStripTextBox has focus.
    private void toolStripTextBox1_KeyDown(object sender, KeyEventArgs e)
    {
    if (e.KeyCode == Keys.Enter)
    {
    Navigate(toolStripTextBox1.Text);
    }
    }

    // Navigates to the URL in the address box when
    // the Go button is clicked.
    private void goButton_Click(object sender, EventArgs e)
    {
    Navigate(toolStripTextBox1.Text);
    }

    // Navigates to the given URL if it is valid.
    private void Navigate(String address)
    {
    if (String.IsNullOrEmpty(address)) return;
    if (address.Equals("about:blank")) return;
    if (!address.StartsWith("http://") &&
    !address.StartsWith("https://"))
    {
    address = "http://" + address;
    }
    try
    {
    webBrowser1.Navigate(new Uri(address));
    }
    catch (System.UriFormatException)
    {
    return;
    }
    }

    // Updates the URL in TextBoxAddress upon navigation.
    private void webBrowser1_Navigated(object sender,
    WebBrowserNavigatedEventArgs e)
    {
    toolStripTextBox1.Text = webBrowser1.Url.ToString();
    }

    // Navigates webBrowser1 to the previous page in the history.
    private void backButton_Click(object sender, EventArgs e)
    {
    webBrowser1.GoBack();
    }

    // Disables the Back button at the beginning of the navigation history.
    private void webBrowser1_CanGoBackChanged(object sender, EventArgs e)
    {
    backButton.Enabled = webBrowser1.CanGoBack;
    }

    // Navigates webBrowser1 to the next page in history.
    private void forwardButton_Click(object sender, EventArgs e)
    {
    webBrowser1.GoForward();
    }

    // Disables the Forward button at the end of navigation history.
    private void webBrowser1_CanGoForwardChanged(object sender, EventArgs e)
    {
    forwardButton.Enabled = webBrowser1.CanGoForward;
    }

    // Halts the current navigation and any sounds or animations on
    // the page.
    private void stopButton_Click(object sender, EventArgs e)
    {
    webBrowser1.Stop();
    }

    // Reloads the current page.
    private void refreshButton_Click(object sender, EventArgs e)
    {
    // Skip refresh if about:blank is loaded to avoid removing
    // content specified by the DocumentText property.
    if (!webBrowser1.Url.Equals("about:blank"))
    {
    webBrowser1.Refresh();
    }
    }

    // Navigates webBrowser1 to the home page of the current user.
    private void homeButton_Click(object sender, EventArgs e)
    {
    webBrowser1.GoHome();
    }

    // Navigates webBrowser1 to the search page of the current user.
    private void searchButton_Click(object sender, EventArgs e)
    {
    webBrowser1.GoSearch();
    }

    // Prints the current document using the current print settings.
    private void printButton_Click(object sender, EventArgs e)
    {
    webBrowser1.Print();
    }

    // Updates the status bar with the current browser status text.
    private void webBrowser1_StatusTextChanged(object sender, EventArgs e)
    {
    toolStripStatusLabel1.Text = webBrowser1.StatusText;
    }

    // Updates the title bar with the current document title.
    private void webBrowser1_DocumentTitleChanged(object sender, EventArgs e)
    {
    this.Text = webBrowser1.DocumentTitle;
    }

    // Exits the application.
    private void exitToolStripMenuItem_Click(object sender, EventArgs e)
    {
    Application.Exit();
    }

    private void InitializeComponent()
    {
    this.components = new Container();
    this.webBrowser1 = new System.Windows.Forms.WebBrowser();
    this.menuStrip1 = new System.Windows.Forms.MenuStrip();
    this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
    this.pageSetupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    this.printToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    this.printPreviewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
    this.propertiesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    this.toolStrip1 = new System.Windows.Forms.ToolStrip();
    this.goButton = new System.Windows.Forms.ToolStripButton();
    this.backButton = new System.Windows.Forms.ToolStripButton();
    this.forwardButton = new System.Windows.Forms.ToolStripButton();
    this.stopButton = new System.Windows.Forms.ToolStripButton();
    this.refreshButton = new System.Windows.Forms.ToolStripButton();
    this.homeButton = new System.Windows.Forms.ToolStripButton();
    this.searchButton = new System.Windows.Forms.ToolStripButton();
    this.printButton = new System.Windows.Forms.ToolStripButton();
    this.toolStrip2 = new System.Windows.Forms.ToolStrip();
    this.toolStripTextBox1 = new System.Windows.Forms.ToolStripTextBox();
    this.statusStrip1 = new System.Windows.Forms.StatusStrip();
    this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
    this.menuStrip1.SuspendLayout();
    this.toolStrip1.SuspendLayout();
    this.toolStrip2.SuspendLayout();
    this.statusStrip1.SuspendLayout();
    this.SuspendLayout();
    //
    // webBrowser1
    //
    this.webBrowser1.Dock = System.Windows.Forms.DockStyle.Fill;
    this.webBrowser1.Location = new System.Drawing.Point(0, 74);
    this.webBrowser1.Name = "webBrowser1";
    this.webBrowser1.Size = new System.Drawing.Size(704, 304);
    this.webBrowser1.TabIndex = 0;
    this.webBrowser1.Navigated += new System.Windows.Forms.WebBrowserNavigatedEventHandler(this.webBrowser1_Navigated);
    //
    // menuStrip1
    //
    this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
    this.fileToolStripMenuItem});
    this.menuStrip1.Location = new System.Drawing.Point(0, 0);
    this.menuStrip1.Name = "menuStrip1";
    this.menuStrip1.Size = new System.Drawing.Size(704, 24);
    this.menuStrip1.TabIndex = 3;
    //
    // fileToolStripMenuItem
    //
    this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
    this.saveAsToolStripMenuItem,
    this.toolStripSeparator1,
    this.pageSetupToolStripMenuItem,
    this.printToolStripMenuItem,
    this.printPreviewToolStripMenuItem,
    this.toolStripSeparator2,
    this.propertiesToolStripMenuItem,
    this.exitToolStripMenuItem});
    this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
    this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
    this.fileToolStripMenuItem.Text = "&File";
    //
    // saveAsToolStripMenuItem
    //
    this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem";
    this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
    this.saveAsToolStripMenuItem.Text = "Save &As...";
    this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.saveAsToolStripMenuItem_Click);
    //
    // toolStripSeparator1
    //
    this.toolStripSeparator1.Name = "toolStripSeparator1";
    this.toolStripSeparator1.Size = new System.Drawing.Size(149, 6);
    //
    // pageSetupToolStripMenuItem
    //
    this.pageSetupToolStripMenuItem.Name = "pageSetupToolStripMenuItem";
    this.pageSetupToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
    this.pageSetupToolStripMenuItem.Text = "Page Set&up...";
    this.pageSetupToolStripMenuItem.Click += new System.EventHandler(this.pageSetupToolStripMenuItem_Click);
    //
    // printToolStripMenuItem
    //
    this.printToolStripMenuItem.Name = "printToolStripMenuItem";
    this.printToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.P)));
    this.printToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
    this.printToolStripMenuItem.Text = "&Print...";
    this.printToolStripMenuItem.Click += new System.EventHandler(this.printToolStripMenuItem_Click);
    //
    // printPreviewToolStripMenuItem
    //
    this.printPreviewToolStripMenuItem.Name = "printPreviewToolStripMenuItem";
    this.printPreviewToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
    this.printPreviewToolStripMenuItem.Text = "Print Pre&view...";
    this.printPreviewToolStripMenuItem.Click += new System.EventHandler(this.printPreviewToolStripMenuItem_Click);
    //
    // toolStripSeparator2
    //
    this.toolStripSeparator2.Name = "toolStripSeparator2";
    this.toolStripSeparator2.Size = new System.Drawing.Size(149, 6);
    //
    // propertiesToolStripMenuItem
    //
    this.propertiesToolStripMenuItem.Name = "propertiesToolStripMenuItem";
    this.propertiesToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
    this.propertiesToolStripMenuItem.Text = "Properties";
    this.propertiesToolStripMenuItem.Click += new System.EventHandler(this.propertiesToolStripMenuItem_Click);
    //
    // exitToolStripMenuItem
    //
    this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
    this.exitToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
    this.exitToolStripMenuItem.Text = "E&xit";
    this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
    //
    // toolStrip1
    //
    this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
    this.goButton,
    this.backButton,
    this.forwardButton,
    this.stopButton,
    this.refreshButton,
    this.homeButton,
    this.searchButton,
    this.printButton});
    this.toolStrip1.Location = new System.Drawing.Point(0, 24);
    this.toolStrip1.Name = "toolStrip1";
    this.toolStrip1.Size = new System.Drawing.Size(704, 25);
    this.toolStrip1.TabIndex = 2;
    //
    // goButton
    //
    this.goButton.Name = "goButton";
    this.goButton.Size = new System.Drawing.Size(26, 22);
    this.goButton.Text = "Go";
    this.goButton.Click += new System.EventHandler(this.goButton_Click);
    //
    // backButton
    //
    this.backButton.Enabled = false;
    this.backButton.Name = "backButton";
    this.backButton.Size = new System.Drawing.Size(36, 22);
    this.backButton.Text = "Back";
    this.backButton.Click += new System.EventHandler(this.backButton_Click);
    //
    // forwardButton
    //
    this.forwardButton.Enabled = false;
    this.forwardButton.Name = "forwardButton";
    this.forwardButton.Size = new System.Drawing.Size(54, 22);
    this.forwardButton.Text = "Forward";
    this.forwardButton.Click += new System.EventHandler(this.forwardButton_Click);
    //
    // stopButton
    //
    this.stopButton.Name = "stopButton";
    this.stopButton.Size = new System.Drawing.Size(35, 22);
    this.stopButton.Text = "Stop";
    this.stopButton.Click += new System.EventHandler(this.stopButton_Click);
    //
    // refreshButton
    //
    this.refreshButton.Name = "refreshButton";
    this.refreshButton.Size = new System.Drawing.Size(50, 22);
    this.refreshButton.Text = "Refresh";
    this.refreshButton.Click += new System.EventHandler(this.refreshButton_Click);
    //
    // homeButton
    //
    this.homeButton.Name = "homeButton";
    this.homeButton.Size = new System.Drawing.Size(44, 22);
    this.homeButton.Text = "Home";
    this.homeButton.Click += new System.EventHandler(this.homeButton_Click);
    //
    // searchButton
    //
    this.searchButton.Name = "searchButton";
    this.searchButton.Size = new System.Drawing.Size(46, 22);
    this.searchButton.Text = "Search";
    this.searchButton.Click += new System.EventHandler(this.searchButton_Click);
    //
    // printButton
    //
    this.printButton.Name = "printButton";
    this.printButton.Size = new System.Drawing.Size(36, 22);
    this.printButton.Text = "Print";
    this.printButton.Click += new System.EventHandler(this.printButton_Click);
    //
    // toolStrip2
    //
    this.toolStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
    this.toolStripTextBox1});
    this.toolStrip2.Location = new System.Drawing.Point(0, 49);
    this.toolStrip2.Name = "toolStrip2";
    this.toolStrip2.Size = new System.Drawing.Size(704, 25);
    this.toolStrip2.TabIndex = 1;
    //
    // toolStripTextBox1
    //
    this.toolStripTextBox1.Font = new System.Drawing.Font("Segoe UI", 9F);
    this.toolStripTextBox1.Name = "toolStripTextBox1";
    this.toolStripTextBox1.Size = new System.Drawing.Size(250, 25);
    this.toolStripTextBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.toolStripTextBox1_KeyDown);
    this.toolStripTextBox1.Click += new System.EventHandler(this.toolStripTextBox1_Click);
    //
    // statusStrip1
    //
    this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
    this.toolStripStatusLabel1});
    this.statusStrip1.Location = new System.Drawing.Point(0, 378);
    this.statusStrip1.Name = "statusStrip1";
    this.statusStrip1.Size = new System.Drawing.Size(704, 22);
    this.statusStrip1.TabIndex = 4;
    //
    // toolStripStatusLabel1
    //
    this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
    this.toolStripStatusLabel1.Size = new System.Drawing.Size(0, 17);
    //
    // Form1
    //
    this.ClientSize = new System.Drawing.Size(704, 400);
    this.Controls.Add(this.webBrowser1);
    this.Controls.Add(this.toolStrip2);
    this.Controls.Add(this.toolStrip1);
    this.Controls.Add(this.statusStrip1);
    this.Controls.Add(this.menuStrip1);
    this.Name = "Form1";
    this.menuStrip1.ResumeLayout(false);
    this.menuStrip1.PerformLayout();
    this.toolStrip1.ResumeLayout(false);
    this.toolStrip1.PerformLayout();
    this.toolStrip2.ResumeLayout(false);
    this.toolStrip2.PerformLayout();
    this.statusStrip1.ResumeLayout(false);
    this.statusStrip1.PerformLayout();
    this.ResumeLayout(false);
    this.PerformLayout();

    }


    protected override void Dispose(bool disposing)
    {
    if (disposing) { if (components != null) { components.Dispose(); } }
    base.Dispose(disposing);
    }
    }

    [ Szerkesztve ]

    http://www.bferi.hu/download.php ; http://bferi.hu/egyeb.php

Új hozzászólás Aktív témák