Пример #1
0
    public MdiBrowser()
    {
        // Set basic Form properties.
        Text           = "MDI Browser";
        Icon           = new Icon(GetType(), "MdiBrowser.MdiBrowser.ico");
        IsMdiContainer = true;

        // Load settings.
        settings = MdiBrowserSettings.Load(strAppData);

        // Set window size and state.
        Bounds      = settings.WindowBounds;
        WindowState = settings.WindowState;

        // Create Address bar ToolStrip
        addr = CreateAddressBar("MdiBrowser");  // in MdiBrowser.AddrBar.cs

        // Create Toolbar ToolStrip
        tool = CreateToolBar("MdiBrowser");  // in MdiBrowser.ToolBar.cs

        // Create MenuStrip
        menu          = new MenuStrip();
        menu.Parent   = this;
        MainMenuStrip = menu;            // This is good for MDI.

        menu.Items.Add(FileMenu());      // in MdiBrowser.FileMenu.cs
        menu.Items.Add(ViewMenu());      // in MdiBrowser.ViewMenu.cs
        menu.Items.Add(FavoritesMenu()); // in MdiBrowser.FavoritesMenu.cs
        menu.Items.Add(WindowMenu());    // in MdiBrowser.WindowMenu.cs
        menu.Items.Add(HelpMenu());      // in MdiBrowser.HelpMenu.cs

        // Load a child window with the Home page.
        Go(settings.Home, false);
    }
Пример #2
0
    // Load settings from file.
    public static MdiBrowserSettings Load(string strAppData)
    {
        StreamReader       sr;
        MdiBrowserSettings settings;
        XmlSerializer      xmlser =
            new XmlSerializer(typeof(MdiBrowserSettings));

        try
        {
            sr       = new StreamReader(strAppData);
            settings = (MdiBrowserSettings)xmlser.Deserialize(sr);
            sr.Close();
        }
        catch
        {
            settings = new MdiBrowserSettings();
        }
        return(settings);
    }
Пример #3
0
    // Constructor.
    public OpenDialog(MdiBrowserSettings settings)
    {
        // Set numerous properties.
        Text            = "Open";
        AutoSize        = true;
        AutoSizeMode    = AutoSizeMode.GrowAndShrink;
        FormBorderStyle = FormBorderStyle.FixedDialog;
        ControlBox      = false;
        MinimizeBox     = false;
        MaximizeBox     = false;
        ShowInTaskbar   = false;
        Icon            = ActiveForm.Icon;
        StartPosition   = FormStartPosition.Manual;
        Location        = ActiveForm.Location + SystemInformation.CaptionButtonSize +
                          SystemInformation.FrameBorderSize;

        // Create table layout panel and controls.
        TableLayoutPanel table = new TableLayoutPanel();

        table.Parent      = this;
        table.AutoSize    = true;
        table.Padding     = new Padding(Font.Height);
        table.RowCount    = 3;
        table.ColumnCount = 4;

        Label lbl = new Label();

        lbl.Text = "Enter a URL or filename, or\r\n" +
                   "Select a previously visited site from the list, or\r\n" +
                   "Press Browse to select a file.";
        lbl.AutoSize = true;
        table.Controls.Add(lbl, 1, 0);
        table.SetColumnSpan(lbl, 3);

        lbl          = new Label();
        lbl.Text     = "Open: ";
        lbl.AutoSize = true;
        lbl.Anchor   = AnchorStyles.Left;
        table.Controls.Add(lbl, 0, 1);

        combo              = new ComboBox();
        combo.AutoSize     = true;
        combo.Anchor       = AnchorStyles.Left | AnchorStyles.Right;
        combo.TextChanged += ComboBoxOnTextChanged;
        combo.BeginUpdate();
        foreach (string str in settings.ManualUrls)
        {
            combo.Items.Add(str);
        }
        combo.EndUpdate();

        table.Controls.Add(combo, 1, 1);
        table.SetColumnSpan(combo, 3);

        btnOk              = new Button();
        btnOk.Text         = "OK";
        btnOk.AutoSize     = true;
        btnOk.DialogResult = DialogResult.OK;
        btnOk.Enabled      = false;
        btnOk.Margin       = new Padding(Font.Height);
        table.Controls.Add(btnOk, 1, 2);
        AcceptButton = btnOk;

        Button btn = new Button();

        btn.Text         = "Cancel";
        btn.AutoSize     = true;
        btn.DialogResult = DialogResult.Cancel;
        btn.Margin       = new Padding(Font.Height);
        table.Controls.Add(btn, 2, 2);
        CancelButton = btn;

        btn          = new Button();
        btn.Text     = "Browse...";
        btn.AutoSize = true;
        btn.Margin   = new Padding(Font.Height);
        btn.Click   += BrowseOnClick;
        table.Controls.Add(btn, 3, 2);
    }