Beispiel #1
0
    public MyMainForm()
    {
        // Data Entity Items assocaited with form
        // Ties together CHAPTER 8 ADO.NET and CHAPTER 6 - WINDOWS FORMS)
        RSSFeedDataEntity feedEntity = new RSSFeedDataEntity();

        mainMenu  = new MyMenu();
        this.Menu = mainMenu;

        // Assign our event handler
        mainMenu.miFileOpen.Click  += new System.EventHandler(this.miFileOpen_Click);
        mainMenu.miFileClose.Click += new System.EventHandler(this.miFileClose_Click);
        mainMenu.miFileExit.Click  += new System.EventHandler(this.miFileExit_Click);

        // Construct our GUI controls
        lblSubscriptions = new System.Windows.Forms.Label();
        lstSubscriptions = new System.Windows.Forms.ListBox();
        dgThreads        = new System.Windows.Forms.DataGrid();
//    t = new System.Data.DataTable();
        txtContents      = new System.Windows.Forms.TextBox();
        pnlSubscriptions = new System.Windows.Forms.Panel();
        pnlThreads       = new System.Windows.Forms.Panel();
        pnlContents      = new System.Windows.Forms.Panel();

        // Initialize pnlSubscriptions
        pnlSubscriptions.AutoScroll = true;
        pnlSubscriptions.Controls.Add(lblSubscriptions);
        pnlSubscriptions.Controls.Add(lstSubscriptions);
        pnlSubscriptions.Location = new System.Drawing.Point(8, 8);
        pnlSubscriptions.Name     = "pnlSubscriptions";
        pnlSubscriptions.Size     = new System.Drawing.Size(208, 432);
        pnlSubscriptions.TabIndex = 0;

        // Initialise lblSubscriptions
        lblSubscriptions.Location = new System.Drawing.Point(8, 8);
        lblSubscriptions.Name     = "lblSubscriptions";
        lblSubscriptions.Size     = new System.Drawing.Size(192, 23);
        lblSubscriptions.TabIndex = 1;
        lblSubscriptions.Text     = "Subscribed Feeds:";

        // Subscriptions Listbox

        lstSubscriptions.Location = new System.Drawing.Point(8, 32);
        lstSubscriptions.Name     = "lstSubscriptions";
        lstSubscriptions.Size     = new System.Drawing.Size(192, 394);
        lstSubscriptions.TabIndex = 0;

        // Initialize pnlThreads
        pnlThreads.Controls.Add(this.dgThreads);
        pnlThreads.Location = new System.Drawing.Point(224, 8);
        pnlThreads.Name     = "pnlThreads";
        pnlThreads.Size     = new System.Drawing.Size(472, 208);
        pnlThreads.TabIndex = 1;

        // Initialize dgThreads
        dgThreads.DataMember      = "";
        dgThreads.HeaderForeColor = System.Drawing.SystemColors.ControlText;
        dgThreads.Location        = new System.Drawing.Point(8, 32);
        dgThreads.Name            = "dgThreads";
        dgThreads.Size            = new System.Drawing.Size(456, 168);
        dgThreads.TabIndex        = 0;

        // Initialize pnlContents
        pnlContents.Controls.Add(txtContents);
        pnlContents.Location = new System.Drawing.Point(224, 224);
        pnlContents.Name     = "pnlContents";
        pnlContents.Size     = new System.Drawing.Size(472, 216);
        pnlContents.TabIndex = 2;

        // Contents Textbox
        txtContents.AutoSize   = false;
        txtContents.Location   = new System.Drawing.Point(8, 8);
        txtContents.Name       = "textBox1";
        txtContents.ScrollBars = System.Windows.Forms.ScrollBars.Both;
        txtContents.Size       = new System.Drawing.Size(456, 200);
        txtContents.TabIndex   = 0;
        txtContents.Text       = "";

        // Initialise the form
        this.Text       = "Main Form";
        this.ClientSize = new System.Drawing.Size(704, 449);
        this.Controls.Add(this.pnlContents);
        this.Controls.Add(this.pnlThreads);
        this.Controls.Add(this.pnlSubscriptions);

        // Initialise Data
        feeds = feedEntity.ReadAll();
        if (feeds.Count > 0)
        {
            // Initialise User-Inteface control (lstSubscriptions) with feeds
            RefreshSubscriptions();
        }


/*
 *  t.Columns.Add("Title");
 *  t.Columns.Add("Date");
 *  t.Columns.Add("Author");
 *  t.Columns.Add("Subject");
 *  dgThreads.DataSource = t;
 *  pnlThreads.Controls.Add(dgThreads);
 */
    }
Beispiel #2
0
    public MyMainForm()
    {
        // Data Entity Items assocaited with form
        // Ties together CHAPTER 8 ADO.NET and CHAPTER 6 - WINDOWS FORMS)
        feedEntity = new RSSFeedDataEntity();
        mainMenu   = new MyMenu();
        this.Menu  = mainMenu;

        // Assign our event handler
        mainMenu.miFileOpen.Click  += new System.EventHandler(this.miFileOpen_Click);
        mainMenu.miFileClose.Click += new System.EventHandler(this.miFileClose_Click);
        mainMenu.miFileExit.Click  += new System.EventHandler(this.miFileExit_Click);

        // Construct our GUI controls
        lblSubscriptions = new System.Windows.Forms.Label();
        lstSubscriptions = new System.Windows.Forms.ListBox();
        dgThreads        = new System.Windows.Forms.DataGrid();
        txtContents      = new System.Windows.Forms.TextBox();
        pnlSubscriptions = new System.Windows.Forms.Panel();
        pnlThreads       = new System.Windows.Forms.Panel();
        pnlContents      = new System.Windows.Forms.Panel();
        pctImage         = new System.Windows.Forms.PictureBox();
        lblImage         = new System.Windows.Forms.Label();


        // Initialize pnlSubscriptions
        pnlSubscriptions.AutoScroll = true;
        pnlSubscriptions.Controls.Add(lblSubscriptions);
        pnlSubscriptions.Controls.Add(lstSubscriptions);
        pnlSubscriptions.Location = new System.Drawing.Point(8, 8);
        pnlSubscriptions.Name     = "pnlSubscriptions";
        pnlSubscriptions.Size     = new System.Drawing.Size(208, 432);
        pnlSubscriptions.TabIndex = 0;

        // Initialise lblSubscriptions
        lblSubscriptions.Location = new System.Drawing.Point(8, 8);
        lblSubscriptions.Name     = "lblSubscriptions";
        lblSubscriptions.Size     = new System.Drawing.Size(192, 23);
        lblSubscriptions.TabIndex = 1;
        lblSubscriptions.Text     = "Subscribed Feeds:";

        // Subscriptions Listbox
        lstSubscriptions.Location = new System.Drawing.Point(8, 32);
        lstSubscriptions.Name     = "lstSubscriptions";
        lstSubscriptions.Size     = new System.Drawing.Size(192, 394);
        lstSubscriptions.TabIndex = 0;

        // DataGrid events
        lstSubscriptions.Click += new System.EventHandler(this.lstSubscriptions_Click);

        // Initialize pnlThreads
        pnlThreads.Controls.Add(this.lblImage);
        pnlThreads.Controls.Add(this.pctImage);
        pnlThreads.Controls.Add(this.dgThreads);
        pnlThreads.Location = new System.Drawing.Point(224, 8);
        pnlThreads.Name     = "pnlThreads";
        pnlThreads.Size     = new System.Drawing.Size(472, 210);
        pnlThreads.TabIndex = 1;

        pnlSubscriptions.BorderStyle = BorderStyle.FixedSingle;
        pnlThreads.BorderStyle       = BorderStyle.FixedSingle;
        pnlContents.BorderStyle      = BorderStyle.FixedSingle;
        pctImage.BorderStyle         = BorderStyle.FixedSingle;
        // Initialize dgThreads
        dgThreads.HeaderForeColor = System.Drawing.SystemColors.ControlText;
        dgThreads.Location        = new System.Drawing.Point(8, 32);
        dgThreads.Name            = "dgThreads";
        dgThreads.Size            = new System.Drawing.Size(472, 208);
        dgThreads.TabIndex        = 0;

        // dgThreads TABLE STYLE
        DataGridTableStyle tableStyle = new DataGridTableStyle();

        tableStyle.MappingName = "ArrayList";

        // Column 1
        DataGridTextBoxColumn pd = new DataGridTextBoxColumn();

        pd.MappingName = "PublishedDate";
        pd.HeaderText  = "Date";
        pd.ReadOnly    = true;
        pd.Width       = 150;
        tableStyle.GridColumnStyles.Add(pd);

        // Column 2
        DataGridTextBoxColumn hd = new DataGridTextBoxColumn();

        hd.MappingName = "Title";
        hd.HeaderText  = "Headline";
        hd.ReadOnly    = true;
        hd.Width       = 300;
        tableStyle.GridColumnStyles.Add(hd);

        // DataGrid style
        dgThreads.TableStyles.Clear();
        dgThreads.TableStyles.Add(tableStyle);

        // DataGrid events
        dgThreads.Click += new System.EventHandler(this.dgThread_Click);

        // Initialize pnlContents
        pnlContents.Controls.Add(txtContents);
        pnlContents.Location = new System.Drawing.Point(224, 224);
        pnlContents.Name     = "pnlContents";
        pnlContents.Size     = new System.Drawing.Size(472, 216);
        pnlContents.TabIndex = 2;

        // Contents Textbox
        txtContents.AutoSize   = false;
        txtContents.Location   = new System.Drawing.Point(8, 8);
        txtContents.Name       = "textBox1";
        txtContents.ScrollBars = System.Windows.Forms.ScrollBars.Both;
        txtContents.Size       = new System.Drawing.Size(456, 200);
        txtContents.TabIndex   = 0;
        txtContents.Text       = "";
        txtContents.Multiline  = true;
        txtContents.WordWrap   = true;
        //
        // pctImage
        //
        pctImage.Location = new System.Drawing.Point(8, 8);
        pctImage.Name     = "pctImage";
        pctImage.TabIndex = 1;
        pctImage.Visible  = false;
        //
        // lblImage
        //
        lblImage.Name     = "lblImage";
        lblImage.Size     = new System.Drawing.Size(344, 24);
        lblImage.TabIndex = 2;
        lblImage.Text     = "label3";
        lblImage.Visible  = false;

        // Initialise the forms core properties
        this.Text       = "RSS Aggreagator";
        this.ClientSize = new System.Drawing.Size(704, 449);
        this.Controls.Add(this.pnlContents);
        this.Controls.Add(this.pnlThreads);
        this.Controls.Add(this.pnlSubscriptions);

        // Initialise the list of default
        // feeds from the 'feed' table
        feeds = feedEntity.ReadAll();
        if (feeds.Count > 0)
        {
            // Initialise User-Inteface control (lstSubscriptions) with feeds
            RefreshSubscriptions();
        }
    }