예제 #1
0
        public void ShowHexString(bool tohex)
        {
            string text = new TextRange(DisplayBox.Document.ContentStart, DisplayBox.Document.ContentEnd).Text;
            string s;

            if (tohex)
            {
                s = StringTool.String2Hex(text);
            }
            else
            {
                s = StringTool.Hex2String(text);
            }
            DisplayBox.Document.Blocks.Clear();
            DisplayBox.AppendText(s);
        }
예제 #2
0
 public void ST(string text)
 {
     DisplayBox.AppendText(text + "\n");
 }
예제 #3
0
        private void SearchButton_Click(object sender, EventArgs e)
        {
            //Is this a batch? True if yes
            //bool batchOrder = batchOrderCheck.Checked;

            //Used to store the added tickers
            string tickers = "";

            //base string that represents the JSON and the input
            string input = "";

            //Goes until 'end' is entered
            while (!input.ToUpper().Equals("END"))
            {
                ShowInputDialog(ref input);
                //only adds valid tickers
                if (!input.ToUpper().Equals("END"))
                {
                    tickers = input.ToUpper();
                }
            }
            //Networking section
            try
            {
                //Defines arrays to be used
                char[] textToSend  = new char[0];
                byte[] bytesToRead = new byte[0];
                byte[] bytesToSend = new byte[0];
                int    bytesRead   = 0;

                //Initializes NetworkStream and TCPClient
                textToSend = tickers.ToCharArray();

                bytesToSend = ASCIIEncoding.ASCII.GetBytes(textToSend);
                MessageBox.Show("Sending : " + tickers);
                nwStream.Write(bytesToSend, 0, bytesToSend.Length);

                //---read back the text---
                bytesToRead = new byte[client.ReceiveBufferSize];
                bytesRead   = nwStream.Read(bytesToRead, 0, client.ReceiveBufferSize);
                string returned = Encoding.ASCII.GetString(bytesToRead, 0, bytesRead);
                Console.WriteLine("Received : " + returned);
                DisplayBox.AppendText(returned);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            /*{
             * //    //use web as a webclient to allow API access
             * //    using (var web = new WebClient())
             * //    {
             * //        if (input.Equals(""))
             * //        {
             * //            input = "AAPL";
             * //        }
             * //        var url = $"";
             * //        //If batch, special URL used
             * //        if (batchOrder)
             * //        {
             * //            url = $"https://api.iextrading.com/1.0/stock/market/batch?symbols={tickers}&types=quote";
             * //        }
             * //        else
             * //        {
             * //            url = $"https://api.iextrading.com/1.0/stock/{tickers}/book/";
             * //        }
             * //        //Download the returned API call as a string
             * //        json = web.DownloadString(url);
             * //    }
             * //}//Moved JSON
             * //json = json.Replace("//", "");
             * {
             *  //Parse the json string to a JSON object
             *  var v = JToken.Parse(json);
             *  //Display ticker and other info for each stock requested in batch.
             *  foreach (var j in v)
             *  {
             *      JToken i = j.First.First.First;
             *      Stock stockShow = crawl.FillStock(i);
             *      var ticker = i.SelectToken("symbol");
             *      var price = i.SelectToken("latestPrice");
             *      var peRat = i.SelectToken("peRatio");
             *
             *      DisplayBox.AppendText($"{ticker} : {price} : {peRat}");
             *      DisplayBox.AppendText(Environment.NewLine);
             *      DisplayBox.AppendText(stockShow.ToString());
             *  }
             * }//Old JSON Batch Code
             * {
             *  var v = JToken.Parse(json);
             *  var mainStuff = v.First.First;
             *  Stock stockShow = crawl.FillStock(mainStuff);
             *  var ticker = mainStuff.SelectToken("symbol");
             *  var price = mainStuff.SelectToken("close");
             *  var peRat = mainStuff.SelectToken("peRatio");
             *  var rating = stockShow.Rating;
             *
             *  DisplayBox.Text += ($"{ticker} : {price} : {peRat} : {rating}");
             *  DisplayBox.AppendText(Environment.NewLine);
             *  DisplayBox.AppendText(stockShow.ToString());
             * }//Old JSON Solo Code*/
        }
예제 #4
0
 private void UpdateUI(string data)
 {
     DisplayBox.AppendText(data);
     DisplayScroll.ScrollToEnd();
 }
예제 #5
0
 public void DisplayMessages(string message)
 {
     DisplayBox.AppendText(message);
 }
예제 #6
0
 private void button1_Click(object sender, EventArgs e)
 {
     DisplayBox.AppendText(XButton.Text);
 }
예제 #7
0
 private void SubstractButton_Click(object sender, EventArgs e)
 {
     DisplayBox.AppendText(SubButton.Text);
 }
예제 #8
0
 private void AddButton_Click(object sender, EventArgs e)
 {
     DisplayBox.AppendText(AddButton.Text);
 }
예제 #9
0
 private void CosButton_Click(object sender, EventArgs e)
 {
     DisplayBox.AppendText(CosButton.Text);
     // DisplayBox.Text
 }