/// <summary> /// Load result to the calling panel. /// </summary> /// <param name="sender"></param> /// <param name="contentType"></param> /// <param name="resultCategory"></param> public void loadResult(object sender, String resultType, String resultSource, String Market, object mainWindow) { //Instantiate current panel ResultPanel panel = sender as ResultPanel; //Set current panel to loading (if the panel isn't already loading content) if (!panel.getLoading()) { refreshContentPanels(); //Clear current panel panel.Controls.Clear(); //Create loading panel Panel loadingPanel = new Panel(); //Create loading label Label loadingLabel = new Label(); //Set loading panel do fill loadingPanel.Dock = DockStyle.Fill; /* * Set custom position for loading label. * The Y position should always be based on * the right panel since that panel is the biggest. */ int x = (panel.Width / 2) - (loadingLabel.Width / 2); int y = (panel.Height / 2) - (loadingLabel.Height / 2); int yDiff = (panel.Height / 2 - rightPanel.Height / 2); loadingLabel.Location = new Point(x, y + yDiff); //Set font for loading label loadingLabel.Font = new Font("Segoe UI", 15, FontStyle.Bold); //Set label to base its size on the content loadingLabel.AutoSize = true; //Add loading text to label loadingLabel.Text = "Loading..."; //Set backcolor of loading label loadingPanel.BackColor = Color.LightGray; //Set text aligntment of text inside label loadingLabel.TextAlign = ContentAlignment.TopCenter; //Add label to loading panel loadingPanel.Controls.Add(loadingLabel); //Add to current panel panel.Controls.Add(loadingPanel); //Save the loading panel as the current content panel.setContent(loadingPanel); panel.setLoading(true); //Createnew instance of class for threading th = new ThreadHandler(); th.fetchResult(panel, resultType, resultSource, Market, mainWindow); refreshContentPanels(); } }
/// <summary> /// Method triggered when a stock in list clicked /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <param name="s"></param> /// <param name="num"></param> private void stock_clicked(object sender, System.EventArgs e, Stock s, int num) { // set colors setListColors(); for (int k = 0; k < listLabels.GetLength(1); k++) { listLabels[num, k].BackColor = c.mercuryBlue; listLabels[num, k].ForeColor = Color.White; } setBlue = true; // load rightPanelResul as resultPanel listItemClicked = num; ResultPanel temp = mw.rightPanelResults as ResultPanel; mw.loadResult(temp, "stockinfo", s.Symbol, s.Market, mw); }
public MainWindow() { c = new Controller(); //Initialize all boolean values dragging = false; maximized = false; searchFieldHasText = false; //Initialize market panel height marketPanelHeight = 40; //Initialize left and right parent panels leftPanel = new Panel(); rightPanel = new Panel(); //Initialize component InitializeComponent(); //Initialize result panels leftPanelResults = new ResultPanel(); rightPanelResults = new ResultPanel(); //Add result panels to left and right parent panels leftPanel.Controls.Add(leftPanelResults); rightPanel.Controls.Add(rightPanelResults); //Set custom color for controls leftPanel.BackColor = Color.Gray; rightPanel.BackColor = Color.Gray; leftParentPanel.BackColor = Color.Gray; mainContentPanel.BackColor = Color.Gray; menu.BackColor = c.mercuryBeige; searchField.BackColor = c.mercuryGrey; dragPanel.BackColor = c.highlightWhite; marketPanel.BackColor = c.highlightWhite; //Reset buttons resetMenuButtons(); extraPanel.BackColor = c.mercuryBeige; disableMarketButtons(); //Refresh all content panels refreshContentPanels(); //Add event handlers to all necessary panels dragPanel.MouseDown += new MouseEventHandler(dragPanel_MouseDown); dragPanel.MouseMove += new MouseEventHandler(dragPanel_MouseMove); dragPanel.MouseUp += new MouseEventHandler(dragPanel_MouseUp); this.SizeChanged += MainWindow_SizeChanged; //Set size of drag panel dragPanelHeight = dragPanel.Height; }
/// <summary> /// Method triggered when a news in list clicked /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <param name="n"></param> private void news_clicked(object sender, System.EventArgs e, News n, int num) { // set colors setListColors(); for (int k = 0; k < listLabels.GetLength(1); k++) { listLabels[num, k].BackColor = c.mercuryBlue; listLabels[num, k].ForeColor = Color.White; } listItemClicked = num; setBlue = true; // load rightPanelResul as resultPanel ResultPanel temp = mw.rightPanelResults as ResultPanel; NewsReader newsPanel = new NewsReader(n, true); temp.Controls.Clear(); temp.setContent(newsPanel); temp.updateSize(); temp.Controls.Add(newsPanel); }
/// <summary> /// Method that handles all thread requests. /// </summary> /// <param name="sender"></param> /// <param name="resultType"></param> /// <param name="source"></param> /// <param name="n"></param> /// <param name="Market"></param> /// <param name="mainWindow"></param> private void fetchResultThread(Object sender, String resultType, String source, News n, String Market, object mainWindow) { ResultPanel panel = sender as ResultPanel; //Return result list of stocks if (resultType == "stocks") { try { //Initialize new result list ResultList list = new ResultList(resultType, source, mainWindow); //Invoke panel to clear its contents panel.Invoke((MethodInvoker)(() => panel.Controls.Clear())); panel.Controls.Clear(); //Set new contents of panel panel.setContent(list); //Update size of panel panel.updateSize(); //Invoke panel to add contents to panel panel.Invoke((MethodInvoker)(() => panel.Controls.Add(list))); } //Catch all exceptions catch (Exception e) {} } //Return result list of portfolio items else if (resultType == "portfolio") { try { ResultList list = new ResultList(resultType, source, mainWindow); panel.Invoke((MethodInvoker)(() => panel.Controls.Clear())); panel.Controls.Clear(); panel.setContent(list); panel.updateSize(); panel.Invoke((MethodInvoker)(() => panel.Controls.Add(list))); } catch (Exception e) {} } //Return result list of search results else if (resultType == "search") { try { ResultList list = new ResultList(resultType, source, mainWindow); panel.Invoke((MethodInvoker)(() => panel.Controls.Clear())); panel.Controls.Clear(); panel.setContent(list); panel.updateSize(); panel.Invoke((MethodInvoker)(() => panel.Controls.Add(list))); } catch (Exception e) {} } //Return info display of selected stock else if (resultType == "stockinfo") { try { InfoDisplay info = new InfoDisplay("stock", source, Market); panel.Invoke((MethodInvoker)(() => panel.Controls.Clear())); panel.Controls.Clear(); panel.setContent(info); panel.updateSize(); panel.Invoke((MethodInvoker)(() => panel.Controls.Add(info))); } catch (Exception e) {} } //Return info display of selected market else if (resultType == "marketinfo") { try { InfoDisplay info = new InfoDisplay("market", source, Market); panel.Invoke((MethodInvoker)(() => panel.Controls.Clear())); panel.Controls.Clear(); panel.setContent(info); panel.updateSize(); panel.Invoke((MethodInvoker)(() => panel.Controls.Add(info))); } catch (Exception e) {} } //Return news list else if (resultType == "news") { try { ResultList newsDisplay = new ResultList(resultType, source, mainWindow); panel.Invoke((MethodInvoker)(() => panel.Controls.Clear())); panel.Controls.Clear(); panel.setContent(newsDisplay); panel.updateSize(); panel.Invoke((MethodInvoker)(() => panel.Controls.Add(newsDisplay))); } catch (Exception e) {} } //Set loading of panel to false panel.setLoading(false); }