//method to provide incremental adjustments for method blocks private Block MethodTransform(ListBox listBox, Block block) { StackPanel conan = (StackPanel)block.innerPane.Children.ElementAt(2); //shrinking block & socket sizes to readjust for newest parameter count block.LayoutRoot.Height = 40 * .7; while (listBox.Height > 40) { Debigulate(listBox); } //individually running through each parameter and expanding as needed for (int i = 0; i < conan.Children.Count; i++) { SocketDragDropTarget needle = (SocketDragDropTarget)conan.Children.ElementAt(i); needle.Height *= .75; ListBox zula = (ListBox)needle.Content; zula.Height *= .75; if (i > 0) { AdjustBlock(listBox, true); block.LayoutRoot.Height += 31; } } return(block); }
//method to convert a logic block so as to work with nesting private Block LogicTransform(ListBox listBox, Block block) { //routing accordingly if block is a method if (block.flag_isCustom) { return(MethodTransform(listBox, block)); } //Changing the socket's block to account for stacking style for (int i = 0; i < 3; i++) { AdjustBlock(listBox, true); } block.LayoutRoot.Height *= 3.5; //creating and populating a stacked block List <System.Windows.UIElement> components = block.innerPane.Children.ToList(); block.innerPane.Children.Clear();//clearing the block so the layout can be changed easier StackPanel stackBox = new StackPanel(); stackBox.Width = block.LayoutRoot.Width; foreach (System.Windows.UIElement element in components) { //casting sockets into specific objects so their widths can be changed if (element is SocketDragDropTarget) { SocketDragDropTarget x = (SocketDragDropTarget)element; x.Width = stackBox.Width - 2; ListBox inner = (ListBox)x.Content; inner.Width = stackBox.Width - 2; stackBox.Children.Add(x); } else { stackBox.Children.Add(element); } } //style to eliminate excess padding Style style = new Style(typeof(StackPanel)); style.Setters.Add(new Setter(StackPanel.MarginProperty, new Thickness(-1))); stackBox.Style = style; //setting up elements in order to hide whitespace SolidColorBrush tempBrush = new SolidColorBrush(Colors.Purple); stackBox.Background = tempBrush; stackBox.Background.Opacity = 0; block.innerPane.Children.Add(stackBox); return(block); }
//adjusting assignment block into stacked structure private void adjustAssign() { LayoutRoot.Height *= 2.4; List <System.Windows.UIElement> components = innerPane.Children.ToList(); innerPane.Children.Clear(); //making sure line number and name are not in the stackpanel innerPane.Children.Add(components.ElementAt(0)); components.RemoveAt(0); innerPane.Children.Add(components.ElementAt(0)); components.RemoveAt(0); StackPanel stackBox = new StackPanel(); stackBox.Width = LayoutRoot.Width * .75; stackBox.MaxWidth = LayoutRoot.Width * .75; foreach (System.Windows.UIElement element in components) { //casting sockets into specific objects so their widths can be changed if (element is SocketDragDropTarget) { SocketDragDropTarget x = (SocketDragDropTarget)element; x.Width = stackBox.Width - 2; ListBox inner = (ListBox)x.Content; inner.Width = stackBox.Width - 2; stackBox.Children.Add(x); } else { stackBox.Children.Add(element); } } //style to eliminate excess padding Style style = new Style(typeof(StackPanel)); style.Setters.Add(new Setter(StackPanel.MarginProperty, new Thickness(-1))); stackBox.Style = style; //setting up elements in order to hide whitespace SolidColorBrush tempBrush = new SolidColorBrush(Colors.Purple); stackBox.Background = tempBrush; stackBox.Background.Opacity = 0; innerPane.Children.Add(stackBox); }
//method to adjust sockets so they fit properly in socketted blocks private void AdjustSockets(Block block) { //looping through each component so it can be cast to its object to change properties List <System.Windows.UIElement> components = block.innerPane.Children.ToList(); for (int i = 0; i < components.Count; i++) { //casting sockets into specific objects so their widths can be changed //catching method sockets if (components.ElementAt(i) is StackPanel && block.flag_isCustom) { StackPanel y = (StackPanel)components.ElementAt(i); List <System.Windows.UIElement> methodSockets = y.Children.ToList(); foreach (UIElement UI in methodSockets) { SocketDragDropTarget SDDT = (SocketDragDropTarget)UI; SDDT.Width = block.LayoutRoot.Width * .63; ListBox inner = (ListBox)SDDT.Content; inner.Width = block.LayoutRoot.Width * .63; components.RemoveAt(i); components.Insert(i, SDDT); } } //catching standard sockets else if (components.ElementAt(i) is SocketDragDropTarget) { SocketDragDropTarget SDDT = (SocketDragDropTarget)components.ElementAt(i); SDDT.Width = block.LayoutRoot.Width * .96; ListBox inner = (ListBox)SDDT.Content; inner.Width = block.LayoutRoot.Width * .96; components.RemoveAt(i); components.Insert(i, SDDT); } //ensuring text boxes are caught as well else if (components.ElementAt(i) is NumericTextBox || components.ElementAt(i) is TextBox) { TextBox x = (TextBox)components.ElementAt(i); x.Width = block.LayoutRoot.Width * .4; components.RemoveAt(i); components.Insert(i, x); } } }
private void createParameterList() { flag_hasSocks = false; StackPanel webby2 = new StackPanel(); webby2.Orientation = Orientation.Vertical; innerPane.Children.Add(webby2); for (int i = 0; i < parameterList.Count; i++) { flag_hasSocks = true; SocketDragDropTarget target = new SocketDragDropTarget(); target.socketType = parameterList[i]; Style style = new Style(typeof(ListBoxItem)); style.Setters.Add(new Setter(ListBoxItem.PaddingProperty, new Thickness(-1))); if (type.Contains("CONDITION")) { target.isCondition = true; } if (type.Contains("CONSTANT")) { target.isConstant = true; } ListBox listBox = new ListBox(); ObservableCollection <Block> collection = new ObservableCollection <Block>(); listBox.Height = 40; listBox.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Hidden); listBox.ItemContainerStyle = style; listBox.Width = LayoutRoot.Width * .6; listBox.BorderThickness = new Thickness(2); listBox.Background = new SolidColorBrush(Colors.LightGray); listBox.ItemsSource = collection; target.Content = listBox; if (i > 0) { LayoutRoot.Height = LayoutRoot.Height + listBox.Height; } webby2.Children.Add(target); } }
//Currently creates numeric text boxes public void createSocket(string type, bool multiple) { SocketDragDropTarget target = new SocketDragDropTarget(); target.socketType = type; Style style = new Style(typeof(ListBoxItem)); style.Setters.Add(new Setter(ListBoxItem.PaddingProperty, new Thickness(-1))); if (type.Contains("CONDITION")) { target.isCondition = true; } if (type.Contains("CONSTANT")) { target.isConstant = true; } ListBox listBox = new ListBox(); listBox.Height = LayoutRoot.Height - 2; listBox.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Hidden); listBox.ItemContainerStyle = style; /*if (multiple) * { * listBox.Width = LayoutRoot.Width * .6; * //listBox.MinWidth = LayoutRoot.Width * .75; * * //listBox.Width = LayoutRoot.Width * .33;//175; * } * else*/ listBox.Width = LayoutRoot.Width * .75; //350; listBox.BorderThickness = new Thickness(2); listBox.Background = new SolidColorBrush(Colors.LightGray); target.Content = listBox; innerPane.Children.Add(target); }
//Currently creates numeric text boxes public void createSocket(string type, bool multiple) { SocketDragDropTarget target = new SocketDragDropTarget(); target.socketType = type; Style style = new Style(typeof(ListBoxItem)); style.Setters.Add(new Setter(ListBoxItem.PaddingProperty, new Thickness(-1))); if (type.Contains("CONDITION")) target.isCondition = true; if (type.Contains("CONSTANT")) target.isConstant = true; ListBox listBox = new ListBox(); listBox.Height = LayoutRoot.Height - 2; listBox.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Hidden); listBox.ItemContainerStyle = style; /*if (multiple) { listBox.Width = LayoutRoot.Width * .6; //listBox.MinWidth = LayoutRoot.Width * .75; //listBox.Width = LayoutRoot.Width * .33;//175; } else*/ listBox.Width = LayoutRoot.Width * .75;//350; listBox.BorderThickness = new Thickness(2); listBox.Background = new SolidColorBrush(Colors.LightGray); target.Content = listBox; innerPane.Children.Add(target); }
private void createParameterList() { flag_hasSocks = false; StackPanel webby2 = new StackPanel(); webby2.Orientation = Orientation.Vertical; innerPane.Children.Add(webby2); for (int i = 0; i < parameterList.Count; i++) { flag_hasSocks = true; SocketDragDropTarget target = new SocketDragDropTarget(); target.socketType = parameterList[i]; Style style = new Style(typeof(ListBoxItem)); style.Setters.Add(new Setter(ListBoxItem.PaddingProperty, new Thickness(-1))); if (type.Contains("CONDITION")) target.isCondition = true; if (type.Contains("CONSTANT")) target.isConstant = true; ListBox listBox = new ListBox(); ObservableCollection<Block> collection = new ObservableCollection<Block>(); listBox.Height = 40; listBox.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Hidden); listBox.ItemContainerStyle = style; listBox.Width = LayoutRoot.Width * .6; listBox.BorderThickness = new Thickness(2); listBox.Background = new SolidColorBrush(Colors.LightGray); listBox.ItemsSource = collection; target.Content = listBox; if(i > 0) LayoutRoot.Height = LayoutRoot.Height + listBox.Height; webby2.Children.Add(target); } }