private void createBlock(int row, int col, int blockWidth, int blockHeight) { if (currentBlockType == JsonToDML.DMLUIElementSyntax.InputBlock) { InputBlockPropertiesViewModel ob = new InputBlockPropertiesViewModel(); ob.OnParameterChange += ParameterViewModel_OnParameterChange_Input; int numberOfBlocksLabel; int numberOfBlocksBox; LabelTextBox ltb = new LabelTextBox(); ltb.DataContext = ob; uid++; ob.ID = uid.ToString(); ob.Row = row.ToString(); ob.Col = col.ToString(); ob.dmlKeyword = currentBlockType; ltb.txb.Text = "Label"; Size s = MeasureTextSize(ltb.txb.Text, ltb); numberOfBlocksLabel = (int)Math.Ceiling((double)(Math.Ceiling(s.Width) / WIDTH)); numberOfBlocksBox = blockWidth - numberOfBlocksLabel; ltb.Width = blockWidth * WIDTH; ltb.Height = blockHeight * HEIGHT; ltb.txb.Width = WIDTH * numberOfBlocksLabel; ltb.txb.Height = HEIGHT * blockHeight; ltb.txt.Width = WIDTH * numberOfBlocksBox; ltb.txt.Height = HEIGHT * blockHeight; ltb.txt.BorderBrush = Brushes.Red; ltb.txt.BorderThickness = new Thickness(2, 2, 2, 2); ltb.txt.TextChanged += blockTextChange; ltb.PreviewKeyDown += selectInputBlock; ltb.PreviewMouseDown += mouseClickInputBlock; Grid.SetRow(ltb, row); Grid.SetColumn(ltb, col - numberOfBlocksLabel); Grid.SetColumnSpan(ltb, ((int)(ltb.Width) / WIDTH)); Grid.SetRowSpan(ltb, ((int)(ltb.Height) / HEIGHT)); MyGrid.Children.Add(ltb); var blockName = "BLOCK"; blockNameCount = blockNameCount + 1; blockName = "BLOCK_" + blockNameCount; daElement = new DrawAreaUiElement(ob.ID, currentBlockType, ob.Row.ToString(), ob.Col.ToString(), blockName, "TOKEN", "", "#TARGET", "#SOURCE", "", ltb.txt.Width.ToString(), "12", ltb.txt.Height.ToString()); daList.addUIElementToUIElementList(daElement); DrawToJSON.DrawAreaToJSON(daList.UIL); inputBlockPropertiesViewModel = ob; viewModelList.Add(ob); inputBlockPropertiesViewModel.inputBlockVisibility = Visibility.Visible; outputBlockPropertiesViewModel.outputBlockVisibility = Visibility.Collapsed; } else if (currentBlockType == JsonToDML.DMLUIElementSyntax.OutputBlock) { OutputBlockPropertiesViewModel ob = new OutputBlockPropertiesViewModel(); ob.OnParameterChange += ParameterViewModel_OnParameterChange_Output; int numberOfBlocksLabel; int numberOfBlocksBox; LabelTextBox ltb = new LabelTextBox(); ltb.DataContext = ob; uid++; ob.ID = uid.ToString(); ob.Row = row.ToString(); ob.Col = col.ToString(); ob.dmlKeyword = currentBlockType; ltb.txb.Text = "Label"; Size s = MeasureTextSize(ltb.txb.Text, ltb); numberOfBlocksLabel = (int)Math.Ceiling((double)(Math.Ceiling(s.Width) / WIDTH)); numberOfBlocksBox = blockWidth - numberOfBlocksLabel; ltb.Width = blockWidth * WIDTH; ltb.Height = blockHeight * HEIGHT; ltb.txb.Width = WIDTH * numberOfBlocksLabel; ltb.txb.Height = HEIGHT * blockHeight; ltb.txt.Width = WIDTH * numberOfBlocksBox; ltb.txt.Height = HEIGHT * blockHeight; ltb.txt.BorderBrush = Brushes.Red; ltb.txt.BorderThickness = new Thickness(2, 2, 2, 2); ltb.txt.TextChanged += blockTextChange; ltb.PreviewKeyDown += selectOutputBlock; ltb.PreviewMouseDown += mouseClickOutputBlock; Grid.SetRow(ltb, row); Grid.SetColumn(ltb, col - numberOfBlocksLabel); Grid.SetColumnSpan(ltb, ((int)(ltb.Width) / WIDTH)); Grid.SetRowSpan(ltb, ((int)(ltb.Height) / HEIGHT)); MyGrid.Children.Add(ltb); var blockName = "BLOCK"; blockNameCount = blockNameCount + 1; blockName = "BLOCK_" + blockNameCount; daElement = new DrawAreaUiElement(ob.ID, currentBlockType, ob.Row.ToString(), ob.Col.ToString(), blockName, "TOKEN", "", "#TARGET", "#SOURCE", "", ltb.txt.Width.ToString(), "12", ltb.txt.Height.ToString()); daList.addUIElementToUIElementList(daElement); DrawToJSON.DrawAreaToJSON(daList.UIL); outputBlockPropertiesViewModel = ob; viewModelOutputList.Add(ob); inputBlockPropertiesViewModel.inputBlockVisibility = Visibility.Collapsed; outputBlockPropertiesViewModel.outputBlockVisibility = Visibility.Visible; } }
private void createBlock(int row, int col, int blockWidth, int blockHeight) { int numberOfBlocksLabel; int numberOfBlocksBox; LabelTextBox ltb = new LabelTextBox(); ltb.txb.Text = "Label"; ltb.Block_Row = row; ltb.Block_Col = col; ltb.Id = System.DateTime.Now.Millisecond.ToString(); Size s = MeasureTextSize(ltb.txb.Text, ltb); numberOfBlocksLabel = (int)Math.Ceiling((double)(Math.Ceiling(s.Width) / WIDTH)); numberOfBlocksBox = blockWidth - numberOfBlocksLabel; ltb.Width = blockWidth * WIDTH; ltb.Height = blockHeight * HEIGHT; ltb.txb.Width = WIDTH * numberOfBlocksLabel; ltb.txb.Height = HEIGHT * blockHeight; ltb.txt.Width = WIDTH * numberOfBlocksBox; ltb.txt.Height = HEIGHT * blockHeight; ltb.txt.BorderBrush = Brushes.Red; ltb.txt.BorderThickness = new Thickness(2, 2, 2, 2); ltb.txt.TextChanged += block_Text_Change; ltb.PreviewKeyDown += select_Input_Block; Grid.SetRow(ltb, row); Grid.SetColumn(ltb, col - numberOfBlocksLabel); Grid.SetColumnSpan(ltb, ((int)(ltb.Width) / WIDTH)); Grid.SetRowSpan(ltb, ((int)(ltb.Height) / HEIGHT)); myGrid.Children.Add(ltb); daElement = new DrawAreaUiElement(ltb.Id, "INPUT_BLOCK", ltb.Block_Row.ToString(), ltb.Block_Col.ToString(), "BLOCK", "TOKEN", "", "#TARGET", "#SOURCE", "", ltb.txt.Width.ToString(), "12", ltb.txt.Height.ToString()); daList.addUIElementToUIElementList(daElement); DrawToJSON.DrawAreaToJSON(daList.UIL); }