Exemplo n.º 1
0
        public OutputWindow()
        {
            InitializeComponent();

            Output = new MultilineTextBox();
            Output.LinesChanged += onLinesChanged;
        }
Exemplo n.º 2
0
		public async Task ProcessRequest(string uri, MultilineTextBox output = null)
		{
			if (output != null)
				output.AddLine($"Accessing '{uri}'...");

			try
			{
				WebClient client = new WebClient();
				string response = await client.DownloadStringTaskAsync(uri);
				var parsedResponse = JsonConvert.DeserializeObject<Dictionary<string, string>>(response);
				if (output != null)
				{
					output.AddLine("Status: " + parsedResponse["status"]);
					if (parsedResponse.ContainsKey("response"))
						output.AddLine("Response: " + parsedResponse["response"]);
					else
					{
						output.AddLine("Error: " + parsedResponse["error"]);
						Resolved = true;
						_canceller.Cancel();
					}
				}
				Resolved = true;
			}
			catch (Exception ex)
			{
				if (output != null)
					output.AddLine($"ERROR: Exception thrown during access: {ex.Message}");
				Resolved = true;
				_canceller.Cancel();
			}
		}
Exemplo n.º 3
0
		public OutputWindow()
		{
			InitializeComponent();

			Output = new MultilineTextBox();
			Output.LinesChanged += onLinesChanged;
		}
Exemplo n.º 4
0
        public async Task ProcessRequest(string uri, MultilineTextBox output = null)
        {
            if (output != null)
            {
                output.AddLine($"Accessing '{uri}'...");
            }

            try
            {
                WebClient client   = new WebClient();
                string    response = await client.DownloadStringTaskAsync(uri);

                var parsedResponse = JsonConvert.DeserializeObject <Dictionary <string, string> >(response);
                if (output != null)
                {
                    output.AddLine("Status: " + parsedResponse["status"]);
                    if (parsedResponse.ContainsKey("response"))
                    {
                        output.AddLine("Response: " + parsedResponse["response"]);
                    }
                    else
                    {
                        output.AddLine("Error: " + parsedResponse["error"]);
                        Resolved = true;
                        _canceller.Cancel();
                    }
                }
                Resolved = true;
            }
            catch (Exception ex)
            {
                if (output != null)
                {
                    output.AddLine($"ERROR: Exception thrown during access: {ex.Message}");
                }
                Resolved = true;
                _canceller.Cancel();
            }
        }
Exemplo n.º 5
0
		void onLinesChanged(MultilineTextBox.ChangedEventArgs e)
		{
			Dispatcher.Invoke(() => outputBox.Text = e.FullText);
		}