/// <summary> /// The GetMultiPartImages method. /// </summary> /// <param name="snapshotFilter">The <paramref name="snapshotFilter"/> parameter.</param> /// <returns>A list of image data.</returns> private static async Task <List <ImageByteArray> > GetMultiPartImages(SnapshotFilter snapshotFilter) { var listBytes = new List <ImageByteArray>(); var uri = new Uri(SelectedClip.GetSnapshotEndpoint(snapshotFilter)); var response = await MainForm.Instance.SendRequest(uri); if (response.StatusCode != HttpStatusCode.OK) { return(null); } var multipartContent = await response.Content.ReadAsMultipartAsync(); foreach (var content in multipartContent.Contents) { var bytes = await content.ReadAsByteArrayAsync(); if (bytes == null) { continue; } listBytes.Add(new ImageByteArray(bytes, content.Headers)); } listBytes.Sort((a, b) => a.ImageTime.CompareTo(b.ImageTime)); return(listBytes); }
/// <summary> /// The RefreshClipImages method. /// </summary> private async void RefreshClipImages() { var startTime = dtpStartDate.Value.ToUniversalTime(); var endTime = dtpEndDate.Value.ToUniversalTime(); var snapshotFilter = new SnapshotFilter { StartTime = startTime, EndTime = endTime, Offset = (int)Math.Round((endTime - startTime).TotalSeconds / 5), Width = pbxImage1.Width }; var pictureBoxes = new List <PictureBox> { pbxImage1, pbxImage2, pbxImage3, pbxImage4, pbxImage5 }; var labels = new List <Label> { lblSnapshot1, lblSnapshot2, lblSnapshot3, lblSnapshot4, lblSnapshot5 }; var listBytes = await GetMultiPartImages(snapshotFilter); if ((listBytes == null) || (listBytes.Count == 0)) { return; } var i = 0; foreach (var pictureBox in pictureBoxes) { MemoryStream memStream = null; try { memStream = new MemoryStream(listBytes[i].Bytes); pictureBox.SizeMode = PictureBoxSizeMode.StretchImage; pictureBox.Image = Image.FromStream(memStream); } finally { memStream?.Dispose(); } if (listBytes.Count > i + 1) { i++; } } i = 0; foreach (var label in labels) { label.Text = listBytes[i].ImageTime.ToLocalTime().ToString("s"); if (listBytes.Count > i + 1) { i++; } } }
public void SetFilterProperties(SnapshotFilter filter) { filterEffectText.text = filter.GetName(); foreach (var graphic in graphics) { graphic.color = filter.GetColor(); } }
public CodeBlock Parse(ITextSnapshot snapshot, AbortCheck abort) { CodeBlock root = new CodeBlock(null, BlockType.Root, null, new SnapshotSpan(snapshot, 0, snapshot.Length), 0, 0); CodeBlock parent = root; Stack <CodeBlock> blockOpenings = new Stack <CodeBlock>(); bool leadingWhitespace = true; int statementStart = -1; StringBuilder currentStatement = new StringBuilder(); SnapshotFilter filter = new SnapshotFilter(snapshot); while (filter.Next()) { int position = filter.Position; char c = filter.Character; if (statementStart == -1) { statementStart = position; } else if (leadingWhitespace) { leadingWhitespace = char.IsWhiteSpace(c); statementStart = position; } if (!filter.InQuote) { if (c == '{') { CodeBlock child = CreateCodeBlock(parent, currentStatement, new SnapshotSpan(snapshot, position, 0), statementStart, blockOpenings.Count + 1); blockOpenings.Push(child); parent = child; } else if (c == '}') { if (blockOpenings.Count > 0) { CodeBlock child = blockOpenings.Pop(); child.SetSpan(new SnapshotSpan(snapshot, Span.FromBounds(child.Span.Start, position + 1))); parent = child.Parent; } } } if (filter.EOS) { currentStatement.Remove(0, currentStatement.Length); statementStart = -1; leadingWhitespace = true; } else { currentStatement.Append(c); } if (abort()) { return(null); } } while (blockOpenings.Count > 0) { CodeBlock child = blockOpenings.Pop(); child.SetSpan(new SnapshotSpan(snapshot, Span.FromBounds(child.Span.Start, snapshot.Length))); } return(root); }
public Task<CodeBlock> ParseAsync(ITextSnapshot snapshot, CancellationToken token) { CodeBlock root = new CodeBlock(null, BlockType.Root, null, new SnapshotSpan(snapshot, 0, snapshot.Length), 0, 0); CodeBlock parent = root; Stack<CodeBlock> blockOpenings = new Stack<CodeBlock>(); bool leadingWhitespace = true; int statementStart = 0; StringBuilder currentStatement = new StringBuilder(); StringBuilder filteredStatement = new StringBuilder(); SnapshotFilter filter = new SnapshotFilter(snapshot); while (filter.Next()) { int position = filter.Position; char c = filter.Character; if (leadingWhitespace) { leadingWhitespace = char.IsWhiteSpace(c); statementStart = position; } if (!filter.InQuote) { if (c == '{') { CodeBlock child = CreateCodeBlock(parent, currentStatement, filteredStatement, new SnapshotSpan(snapshot, position, 0), statementStart, blockOpenings.Count + 1); blockOpenings.Push(child); parent = child; } else if (c == '}') { if (blockOpenings.Count > 0) { CodeBlock child = blockOpenings.Pop(); child.SetSpan(new SnapshotSpan(snapshot, Span.FromBounds(child.Span.Start, position + 1))); parent = child.Parent; } } } if (filter.EOS) { currentStatement.Length = 0; filteredStatement.Length = 0; leadingWhitespace = true; } else { AppendCharacter(currentStatement, c); if (!filter.InQuote) AppendCharacter(filteredStatement, c); } if (token.IsCancellationRequested) return null; } while (blockOpenings.Count > 0) { CodeBlock child = blockOpenings.Pop(); child.SetSpan(new SnapshotSpan(snapshot, Span.FromBounds(child.Span.Start, snapshot.Length))); } return Task.FromResult<CodeBlock>(root); }
public Task <CodeBlock> ParseAsync(ITextSnapshot snapshot, CancellationToken token) { CodeBlock root = new CodeBlock(null, BlockType.Root, null, new SnapshotSpan(snapshot, 0, snapshot.Length), 0, 0); CodeBlock parent = root; Stack <CodeBlock> blockOpenings = new Stack <CodeBlock>(); bool leadingWhitespace = true; int statementStart = 0; StringBuilder currentStatement = new StringBuilder(); StringBuilder filteredStatement = new StringBuilder(); SnapshotFilter filter = new SnapshotFilter(snapshot); while (filter.Next()) { int position = filter.Position; char c = filter.Character; if (leadingWhitespace) { leadingWhitespace = char.IsWhiteSpace(c); statementStart = position; } if (!filter.InQuote) { if (c == '{') { CodeBlock child = CreateCodeBlock(parent, currentStatement, filteredStatement, new SnapshotSpan(snapshot, position, 0), statementStart, blockOpenings.Count + 1); blockOpenings.Push(child); parent = child; } else if (c == '}') { if (blockOpenings.Count > 0) { CodeBlock child = blockOpenings.Pop(); child.SetSpan(new SnapshotSpan(snapshot, Span.FromBounds(child.Span.Start, position + 1))); parent = child.Parent; } } } if (filter.EOS) { currentStatement.Length = 0; filteredStatement.Length = 0; leadingWhitespace = true; } else { AppendCharacter(currentStatement, c); if (!filter.InQuote) { AppendCharacter(filteredStatement, c); } } if (token.IsCancellationRequested) { return(null); } } while (blockOpenings.Count > 0) { CodeBlock child = blockOpenings.Pop(); child.SetSpan(new SnapshotSpan(snapshot, Span.FromBounds(child.Span.Start, snapshot.Length))); } return(Task.FromResult <CodeBlock>(root)); }
public CodeBlock Parse(ITextSnapshot snapshot, AbortCheck abort) { CodeBlock root = new CodeBlock(null, BlockType.Root, null, new SnapshotSpan(snapshot, 0, snapshot.Length), 0, 0); CodeBlock parent = root; Stack<CodeBlock> blockOpenings = new Stack<CodeBlock>(); bool leadingWhitespace = true; int statementStart = -1; StringBuilder currentStatement = new StringBuilder(); SnapshotFilter filter = new SnapshotFilter(snapshot); while (filter.Next()) { int position = filter.Position; char c = filter.Character; if (statementStart == -1) statementStart = position; else if (leadingWhitespace) { leadingWhitespace = char.IsWhiteSpace(c); statementStart = position; } if (!filter.InQuote) { if (c == '{') { CodeBlock child = CreateCodeBlock(parent, currentStatement, new SnapshotSpan(snapshot, position, 0), statementStart, blockOpenings.Count + 1); blockOpenings.Push(child); parent = child; } else if (c == '}') { if (blockOpenings.Count > 0) { CodeBlock child = blockOpenings.Pop(); child.SetSpan(new SnapshotSpan(snapshot, Span.FromBounds(child.Span.Start, position + 1))); parent = child.Parent; } } } if (filter.EOS) { currentStatement.Remove(0, currentStatement.Length); statementStart = -1; leadingWhitespace = true; } else currentStatement.Append(c); if (abort()) return null; } while (blockOpenings.Count > 0) { CodeBlock child = blockOpenings.Pop(); child.SetSpan(new SnapshotSpan(snapshot, Span.FromBounds(child.Span.Start, snapshot.Length))); } return root; }