public void AddTextBlock() { var ret = new TextBlockDefinitionItemModel(TextBlocks); TextBlocks.Add(ret); Selection = ret; }
private void AddItemToLastTextBlock(ITextBlockItem item) { if (!TextBlocks.Any()) { TextBlocks.Add(new TextBlock()); } TextBlocks.Last().Items.Add(item); }
public virtual void ReadChildData(BinaryReader reader) { int x = 0; _arrowsBitmap.ReadString(reader); for (x = 0; (x < _itemAnimations.Count); x = (x + 1)) { ItemAnimations.Add(new SingleAnimationReferenceBlockBlock()); ItemAnimations[x].Read(reader); } for (x = 0; (x < _itemAnimations.Count); x = (x + 1)) { ItemAnimations[x].ReadChildData(reader); } for (x = 0; (x < _textBlocks.Count); x = (x + 1)) { TextBlocks.Add(new TextBlockReferenceBlockBlock()); TextBlocks[x].Read(reader); } for (x = 0; (x < _textBlocks.Count); x = (x + 1)) { TextBlocks[x].ReadChildData(reader); } for (x = 0; (x < _bitmapBlocks.Count); x = (x + 1)) { BitmapBlocks.Add(new BitmapBlockReferenceBlockBlock()); BitmapBlocks[x].Read(reader); } for (x = 0; (x < _bitmapBlocks.Count); x = (x + 1)) { BitmapBlocks[x].ReadChildData(reader); } for (x = 0; (x < _hudBlocks.Count); x = (x + 1)) { HudBlocks.Add(new HudBlockReferenceBlockBlock()); HudBlocks[x].Read(reader); } for (x = 0; (x < _hudBlocks.Count); x = (x + 1)) { HudBlocks[x].ReadChildData(reader); } for (x = 0; (x < _playerBlocks.Count); x = (x + 1)) { PlayerBlocks.Add(new PlayerBlockReferenceBlockBlock()); PlayerBlocks[x].Read(reader); } for (x = 0; (x < _playerBlocks.Count); x = (x + 1)) { PlayerBlocks[x].ReadChildData(reader); } }
public HandGestureControlKeyAddWindow() { InitializeComponent(); for (int i = 1; i <= 20; i++) { var slider = this.FindName("ValueSlider" + i.ToString("00")) as Slider; var textblock = this.FindName("ValueTextBlock" + i.ToString("00")) as TextBlock; slider.ValueChanged += Slider_ValueChanged; slider.Tag = i; Sliders.Add(slider); TextBlocks.Add(textblock); handAngles.Add((int)slider.Value); } AngleLimitCheckBox_Checked(null, null); if (Directory.Exists(Globals.GetCurrentAppDir() + PresetDirectory) == false) { Directory.CreateDirectory(Globals.GetCurrentAppDir() + PresetDirectory); } PresetComboBox.ItemsSource = Directory.EnumerateFiles(Globals.GetCurrentAppDir() + PresetDirectory, "*.json").Select(d => System.IO.Path.GetFileNameWithoutExtension(d)); }
private Panel CreatePanelForLane(KeyValuePair <int, Lane> laneAndId) { var lane = laneAndId.Value; var blocks = lane.Blocks; if (blocks.Count == 0) { return(null); } var canvas = new Canvas(); canvas.VerticalAlignment = VerticalAlignment.Top; var endpoints = new List <BlockEndpoint>(); foreach (var block in blocks) { block.StartPoint = new BlockEndpoint() { Block = block, Timestamp = block.StartTime.Ticks, IsStart = true }; block.EndPoint = new BlockEndpoint() { Block = block, Timestamp = block.EndTime.Ticks }; endpoints.Add(block.StartPoint); endpoints.Add(block.EndPoint); } endpoints.Sort((l, r) => l.Timestamp.CompareTo(r.Timestamp)); int level = 0; foreach (var endpoint in endpoints) { if (endpoint.IsStart) { level++; endpoint.Block.Indent = level; } else { level--; } } blocks.Sort((l, r) => { var startDifference = l.StartTime.Ticks.CompareTo(r.StartTime.Ticks); if (startDifference != 0) { return(startDifference); } return(l.Length.CompareTo(r.Length)); }); DateTime minDateTime = blocks[0].StartTime; DateTime maxDateTime = blocks[blocks.Count - 1].StartTime; foreach (var block in blocks) { block.Start = block.StartTime.Ticks; block.End = block.EndTime.Ticks; } double start = minDateTime.Ticks; double end = maxDateTime.Ticks; double totalDuration = end - start; if (totalDuration == 0) { totalDuration = 1; } double width = 0; var sample = new TextBlock(); sample.Text = "W"; sample.Measure(new Size(10000, 10000)); var textHeight = sample.DesiredSize.Height; double preferredTotalHeight = textHeight * blocks.Count(b => b.Length > totalDuration / 2000); double currentHeight = 0; double totalHeight = 0; foreach (var block in blocks) { //if (block.Length > minimumDurationToInclude) { var content = new ContentControl(); var textBlock = new TextBlock(); textBlock.Text = $"{block.Text} ({TextUtilities.DisplayDuration(block.Duration)})"; textBlock.Background = ChooseBackground(block); double left = 24 * block.Indent; double top = (block.Start - start) / totalDuration * preferredTotalHeight; double height = (block.End - block.Start) / totalDuration * preferredTotalHeight; if (height < textHeight) { height = textHeight; continue; } textBlock.Measure(new Size(10000, 10000)); double currentTotalWidth = left + textBlock.DesiredSize.Width; if (currentTotalWidth > width) { width = currentTotalWidth; } double minimumTop = currentHeight; if (minimumTop > top) { double adjustment = minimumTop - top; if (height > adjustment + textHeight) { height = height - adjustment; top = minimumTop; } else { continue; } } textBlock.Height = height; textBlock.ToolTip = block.GetTooltip(); textBlock.MouseUp += TextBlock_MouseUp; textBlock.Tag = block; TextBlocks.Add(block.Node, textBlock); currentHeight = top + textHeight; if (totalHeight < top + height) { totalHeight = top + height; } Canvas.SetLeft(content, left); Canvas.SetTop(content, top); content.Content = textBlock; content.MouseDoubleClick += Content_MouseDoubleClick; canvas.Children.Add(content); } } canvas.Height = totalHeight; canvas.Width = width; return(canvas); }
private void Add(object obj) { TextBlocks.Add(new TextBlock { Text = (TextBlocks.Count + 1).ToString() }); }