/// <summary> /// Updates the result panel and its contents. /// </summary> public void updateSize() { //Resultlist if (content is ResultList) { ResultList temp = content as ResultList; temp.setSize(this.Width, this.Height); } //Info display else if (content is InfoDisplay) { InfoDisplay temp = content as InfoDisplay; temp.setSize(this.Width, this.Height); } //News reader else if (content is NewsReader) { NewsReader temp = content as NewsReader; temp.setSize(this.Width, this.Height); } //Integrated news list else if (content is IntegratedNewsList) { IntegratedNewsList temp = content as IntegratedNewsList; temp.setSize(this.Width, this.Height); } //Sets size of result panel content.Width = this.Width; content.Height = this.Height; }
/// <summary> /// Initilize the news lsit /// </summary> private void initilizeNewsList() { // cleear the panel this.Controls.Clear(); // create new main panel and set sizes and autoscroll mainPanel = new FlowLayoutPanel(); mainPanel.Width = panelWidth; mainPanel.Height = panelHeigth; mainPanel.AutoScroll = true; // check displayNews, i.e if a news item is clicked if (displayNews != null) { // add new NewsReader NewsReader np = new NewsReader(displayNews, false); np.setSize(panelWidth - 20, 300); mainPanel.Controls.Add(np); } int stop; // calculate the stop of the loop if (maxButtons > newsList.Count) { stop = newsList.Count; } else { stop = maxButtons; } // initilize newsLabels newsLabels = new Label[stop, 3]; int j = 0; for (int i = 0; i < stop; i++) { // get news News n = newsList[i]; // create the news labels Label symbolLabel = createLabel(n.symbol, n, j); Label titleLabel = createLabel(n.title, n, j); Label updatedLabel = createLabel(c.getDate(n.pubDate).ToString(), n, j); // add the news labels to the 2d array newsLabels[j, 0] = symbolLabel; newsLabels[j, 1] = titleLabel; newsLabels[j, 2] = updatedLabel; j++; } // initilize the newsPanels and add the labels to it newsPanels = new FlowLayoutPanel[stop]; for (int i = 0; i < newsLabels.GetLength(0); i++) { FlowLayoutPanel newsPanel = new FlowLayoutPanel(); newsPanel.FlowDirection = System.Windows.Forms.FlowDirection.LeftToRight; newsPanel.Height = 40; newsPanel.BackColor = c.highlightWhite; newsPanel.Width = panelWidth - 25; for (int k = 0; k < newsLabels.GetLength(1); k++) { newsPanel.Controls.Add(newsLabels[i, k]); } newsPanels[i] = newsPanel; } // add buttons to the mainPanel foreach (FlowLayoutPanel p in newsPanels) { mainPanel.Controls.Add(p); } // add main panel this.Controls.Add(mainPanel); }