private void Form1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { if (hitState == null) { selectedState = startConnectionState = null; //empty interaction states } if (stateList.Count > 2) { StateXML[0] = State.DataSerializeState(stateList); //update config } if (regionList.Count > 0) { RegionXML[0] = AutomataRegion.DataSerializeRegion(regionList); //update region config } if (dragState != null) { dragState = null; TransitionXML[0] = Transition.DataSerializeTransition(transitionList); } //new selection rectangle ? create region if (p.selectionRectangle.Height != 0) { CreateRegion(); p.selectionRectangle.Height = 0; } hitRegion = null; hitsizeHandle = null; }
private void EditRegion(AutomataRegion region) { string input = region.Name; if (PaintAutomataClass.Dialogs.RegionDialog(ref input, "Edit Region", p.dpi) == DialogResult.OK) { region.Name = input; this.Invalidate(); //redraw UpdateRegionsConfigs(); } }
private void UpdateRegionsConfigs() { // Update Config Pin if there is a change if (regionList.Count > 0) { RegionXML[0] = AutomataRegion.DataSerializeRegion(regionList); EnumManager.UpdateEnum(myGUID + "_Regions", regionList[0].Name, regionList.Select(x => x.Name).ToArray()); } else { RegionXML[0] = ""; //EnumManager.UpdateEnum(myGUID + "_Regions", "", regionList.Select(x => x.Name).ToArray()); } }
private void UpdateRegionsConfigs() { // Update Config Pin if there is a change if (regionList.Count > 0) { RegionXML = AutomataRegion.DataSerializeRegion(regionList); //EnumManager.UpdateEnum(myGUID + "_Regions", regionList[0].Name, regionList.Select(x => x.Name).ToArray()); RegionsEnum.Clear(); regionList.ForEach(region => RegionsEnum.AddEntry(region.Name)); } else { RegionXML = ""; //EnumManager.UpdateEnum(myGUID + "_Regions", "", regionList.Select(x => x.Name).ToArray()); RegionsEnum.Clear(); } }
private void InitSettings() { //load settings if (stateList.Count < 2 && StateXML[0].Length > 3 && Initialize) { try { stateList = State.DataDeserializeState(StateXML[0]); transitionList = Transition.DataDeserializeTransition(TransitionXML[0]); if (RegionXML[0].Length > 3) { regionList = AutomataRegion.DataDeserializeRegion(RegionXML[0]); } EnumManager.UpdateEnum(myGUID + "_Regions", regionList[0].Name, regionList.Select(x => x.Name).ToArray()); } catch { FLogger.Log(LogType.Debug, "Loading XML Graph failed!"); } //new enum technique EnumManager.UpdateEnum(myGUID + "_States", stateList[0].Name, stateList.Select(x => x.Name).ToArray()); EnumManager.UpdateEnum(myGUID + "_Transitions", transitionList[0].Name, transitionList.Select(x => x.Name).Distinct().ToArray()); EnumManager.UpdateEnum(myGUID + "_AllTransitions", transitionList[0].Name, transitionList.Select(x => x.Name).ToArray()); //repair relation foreach (Transition transition in transitionList) { transition.startState = stateList.First(x => x.ID.Contains(transition.startState.ID)); transition.endState = stateList.First(x => x.ID.Contains(transition.endState.ID)); } this.Invalidate(); previousPosition = MousePosition; p.StagePos.X = 0; p.StagePos.Y = 0; UpdateOutputs(); //update State and Transition Outputs Initialize = false; } }
private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { //hit detection for various use hitState = stateList.FirstOrDefault(x => x.Bounds.Contains(new Point(this.x, this.y))); hitTransition = transitionList.FirstOrDefault(x => x.Bounds.Contains(new Point(this.x, this.y))); hitRegion = regionList.FirstOrDefault(x => x.Bounds.Contains(new Point(this.x, this.y))); hitsizeHandle = regionList.FirstOrDefault(x => x.SizeHandle.Contains(new Point(this.x, this.y))); if (hitsizeHandle != null) { hitRegion = null; } previousPosition = MousePosition; // get mouse position difference holdMousePos = new Point(x, y); // on mouse down hold last position //delete transitions or Regions if (e.Button == MouseButtons.Middle) { DeleteTransition(e); DeleteRegion(e); this.Invalidate(); //redraw } //hit detection bezier transition if (e.Button == MouseButtons.Right) { int i = 0; p.bezierEdit.HighlightTransitionIndex = null; p.bezierEdit.highlightTransition = null; foreach (GraphicsPath path in p.transitionPaths) { if (path.IsOutlineVisible(this.x, this.y, p.greenPen)) { p.bezierEdit.HighlightTransitionIndex = i; p.bezierEdit.highlightTransition = transitionList[i]; //FLogger.Log(LogType.Debug, "hit transition"); } i++; } } if (p.bezierEdit.bezierStart.Contains(new Point(this.x, this.y)) && e.Button == MouseButtons.Left) { dragState = "bezierStart"; } if (p.bezierEdit.bezierEnd.Contains(new Point(this.x, this.y)) && e.Button == MouseButtons.Left) { dragState = "bezierEnd"; } // Override Active State by CTRL Mouseclick if (e.Button == MouseButtons.Left && Form.ModifierKeys == Keys.Control && hitState != null) { ActiveStateIndex[ShowSlice[0]] = TargetStateIndex[ShowSlice[0]] = stateList.IndexOf(hitState); ElapsedStateTime[ShowSlice[0]] = TransitionFramesOut[ShowSlice[0]] = 0; this.Invalidate(); //redraw } // Override Active Transition by CTRL Mouseclick if (e.Button == MouseButtons.Left && Form.ModifierKeys == Keys.Control && hitTransition != null) { TargetStateIndex[ShowSlice[0]] = stateList.IndexOf(hitTransition.endState); // set target state index ActiveStateIndex[ShowSlice[0]] = stateList.IndexOf(hitTransition.startState); TransitionFramesOut[ShowSlice[0]] = hitTransition.Frames; // get frames of transition TransitionIndex[ShowSlice[0]] = transitionList.IndexOf(hitTransition); //get transition ElapsedStateTime[ShowSlice[0]] = 0; // stop ElapsedStateTimer FLogger.Log(LogType.Debug, "force transition"); this.Invalidate(); //redraw } // empty hit ? if (hitState == null) { selectedState = null; startConnectionState = null; } else { if (Form.ModifierKeys != Keys.Control) { selectedState = hitState; //on click set selected state for dragging in case no forcing state happens } if (startConnectionState != null && targetConnectionState != null && e.Button == MouseButtons.Left) { //Create Transition if (startConnectionState.ID != targetConnectionState.ID) { AddTransition(startConnectionState, hitState); } startConnectionState = null; targetConnectionState = null; selectedState = null; } //set connection start if (selectedState != null && e.Button == MouseButtons.Right) { startConnectionState = hitState; } else { startConnectionState = null; } //delete state and relevant transitions if (selectedState != null && e.Button == MouseButtons.Middle && hitState.ID != "Init") { DeleteState(e); } } // hit test for spreadbuttons top left for (int i = 0; i < p.Spreadbuttons.Count; i++) { if (p.Spreadbuttons[i].Contains(new Point(e.X, e.Y)) && e.Button == MouseButtons.Left) { ShowSlice[0] = i; break; } } this.Invalidate(); }
private void InitSettings() { //load settings if (stateList.Count < 2 && StateXML.Length > 3 && Initialize) { try { stateList = State.DataDeserializeState(StateXML); transitionList = Transition.DataDeserializeTransition(TransitionXML); if (RegionXML.Length > 3) { regionList = AutomataRegion.DataDeserializeRegion(RegionXML); } } catch { debug = "Loading XML Graph failed!"; } //new enum technique //EnumManager.UpdateEnum(myGUID + "_States", stateList[0].Name, stateList.Select(x => x.Name).ToArray()); stateList.ForEach(state => StatesEnum.AddEntry(state.Name)); //EnumManager.UpdateEnum(myGUID + "_Transitions", transitionList[0].Name, transitionList.Select(x => x.Name).Distinct().ToArray()); transitionList.ForEach(transition => TransitionsEnum.AddEntry(transition.Name)); //EnumManager.UpdateEnum(myGUID + "_Regions", regionList[0].Name, regionList.Select(x => x.Name).ToArray()); regionList.ForEach(region => RegionsEnum.AddEntry(region.Name)); //EnumManager.UpdateEnum(myGUID + "_AllTransitions", transitionList[0].Name, transitionList.Select(x => x.Name).ToArray()); //repair relation foreach (Transition transition in transitionList) { transition.startState = stateList.First(x => x.ID.Contains(transition.startState.ID)); transition.endState = stateList.First(x => x.ID.Contains(transition.endState.ID)); } this.Invalidate(); previousPosition = MousePosition; p.StagePos.X = 0; p.StagePos.Y = 0; Initialize = false; } else if (stateList.Count < 2 && Initialize) { //add state to state list stateList.Add(new State() { ID = "Init", Name = "Init", Bounds = new Rectangle(new Point(0, 0), new Size(p.StateSize, p.StateSize)) }); UpdateStateConfigs(); // update JSON,Enums and Redraw this.Invalidate(); previousPosition = MousePosition; p.StagePos.X = 0; p.StagePos.Y = 0; Initialize = false; } }