Example #1
0
 /// <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;
 }
Example #2
0
        /// <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);
        }