private void Button_Click(object sender, RoutedEventArgs e) { TYPE_BLOCK type = TYPE_BLOCK.none; String tag = ((Button)sender).Tag.ToString(); switch (tag) { case "begin": type = TYPE_BLOCK.begin; break; case "end": type = TYPE_BLOCK.end; break; case "calculate": type = TYPE_BLOCK.calculate; break; case "cycle": type = TYPE_BLOCK.cycle; break; case "input": type = TYPE_BLOCK.input; break; case "output": type = TYPE_BLOCK.output; break; case "joint": type = TYPE_BLOCK.joint; break; case "condition": type = TYPE_BLOCK.condition; break; case "subroutine": type = TYPE_BLOCK.subroutine; break; case "camera": type = TYPE_BLOCK.camera; break; } if (clickButtons != null) { clickButtons(type); } }
public LMD_Workspace() { InitializeComponent(); this.selectTypeBlock = TYPE_BLOCK.none; this.MouseMove += LMD_Workspace_MouseMove; this.MouseUp += LMD_Workspace_MouseUp; this.MouseDown += LMD_Workspace_MouseDown; blocks = new List <LMD_BLOCKS.BLOCK_JOINT.BASE_BLOCK>(); joints = new List <LMD_BLOCKS.BlockJoint>(); element_buffer = new List <UIElement>(); }
public void CreateSelectBlock(double x, double y) { date_select = false; if (SelectUIElement != null) { SelectUIElement.Opacity = 1; Canvas.SetLeft(SelectUIElement, x - 200); Canvas.SetTop(SelectUIElement, y - 100); if (createNewBlock != null) { createNewBlock(SelectUIElement, selectTypeBlock); } selectTypeBlock = TYPE_BLOCK.none; SelectUIElement = null; } }
public void AddBlock(TYPE_BLOCK type) { canvas.Children.Remove(SelectUIElement); SelectUIElement = null; selectTypeBlock = TYPE_BLOCK.none; date_select = true; selectTypeBlock = type; LMD_BLOCKS.BLOCK_JOINT.BASE_BLOCK b_b = null; switch (type) { case TYPE_BLOCK.begin: LMD_BLOCKS.BlockBegin bb = new LMD_BLOCKS.BlockBegin(); bb.expanderClickItem += bb_expanderClickItem; SelectUIElement = bb; b_b = new LMD_BLOCKS.BLOCK_JOINT.BEGIN(); break; case TYPE_BLOCK.end: LMD_BLOCKS.BlockEnd be = new LMD_BLOCKS.BlockEnd(); be.expanderClickItem += bb_expanderClickItem; SelectUIElement = be; b_b = new LMD_BLOCKS.BLOCK_JOINT.END(); break; case TYPE_BLOCK.input: LMD_BLOCKS.BlockInput bi = new LMD_BLOCKS.BlockInput(); bi.expanderClickItem += bb_expanderClickItem; SelectUIElement = bi; b_b = new LMD_BLOCKS.BLOCK_JOINT.INPUT(); break; case TYPE_BLOCK.output: LMD_BLOCKS.BlockOutput bo = new LMD_BLOCKS.BlockOutput(); bo.expanderClickItem += bb_expanderClickItem; SelectUIElement = bo; b_b = new LMD_BLOCKS.BLOCK_JOINT.OUTPUT(); break; case TYPE_BLOCK.calculate: LMD_BLOCKS.BlockCalculate bca = new LMD_BLOCKS.BlockCalculate(); bca.expanderClickItem += bb_expanderClickItem; SelectUIElement = bca; b_b = new LMD_BLOCKS.BLOCK_JOINT.CALCULATE(); break; case TYPE_BLOCK.condition: LMD_BLOCKS.BlockCondition bco = new LMD_BLOCKS.BlockCondition(); bco.expanderClickItem += bb_expanderClickItem; bco.clickJoint += bco_clickJoint; SelectUIElement = bco; b_b = new LMD_BLOCKS.BLOCK_JOINT.CONDITION(); break; case TYPE_BLOCK.camera: break; case TYPE_BLOCK.joint: joint_select = true; break; } b_b.element = SelectUIElement; b_b.element.MouseEnter += element_MouseEnter; b_b.element.MouseLeave += element_MouseLeave; blocks.Add(b_b); SelectUIElement.Opacity = 0.5; canvas.Children.Add(SelectUIElement); Canvas.SetLeft(SelectUIElement, -500); Canvas.SetTop(SelectUIElement, -500); }