/// <summary> /// Define or redefine a Level using the values in the <see cref="LevelEntry"/> argument /// </summary> /// <param name="levelEntry">the level values</param> /// <remarks> /// <para> /// Define or redefine a Level using the values in the <see cref="LevelEntry"/> argument /// </para> /// </remarks> internal void AddLevel(LevelEntry levelEntry) { if (levelEntry == null) throw new ArgumentNullException("levelEntry"); if (levelEntry.Name == null) throw new ArgumentNullException("levelEntry.Name"); // Lookup replacement value if (levelEntry.Value == -1) { Level previousLevel = LevelMap[levelEntry.Name]; if (previousLevel == null) { throw new InvalidOperationException("Cannot redefine level ["+levelEntry.Name+"] because it is not defined in the LevelMap. To define the level supply the level value."); } levelEntry.Value = previousLevel.Value; } LevelMap.Add(levelEntry.Name, levelEntry.Value, levelEntry.DisplayName); }
public void AddToSelection(LevelEntry entry) { mSelectedEntries.Add(entry); CheckSelectionChanged(); }
private void duplicateAndPhaseRibbonButton_Click(object sender, EventArgs e) { if (!IsEditorAvailable()) { return; } //Check if there is only one peg selected LevelEntryCollection objs = LevelEditor.GetSelectedObjects(); if (objs.Count != 1) { MessageBox.Show("You must have only one movement peg selected."); return; } //Check if its a moving peg LevelEntry movementPeg = objs[0]; if (movementPeg == null) { MessageBox.Show("You must have only one movement peg selected."); return; } //Check if the peg has moving details Movement movement = movementPeg.MovementInfo; if (movement == null) { MessageBox.Show("The peg must have movement properties."); return; } //Find out how many pegs to duplicate string ans = InputForm.Show("How many pegs would you like in this movement cycle, including the selected one?", "Duplicate and Phase", "8"); int num_pegs; if (!Int32.TryParse(ans, out num_pegs) || num_pegs < 0 || num_pegs > 100) { MessageBox.Show("Invalid number of pegs."); return; } LevelEntryCollection entries = new LevelEntryCollection(); entries.Add((LevelEntry)objs[0]); //Duplicate the peg for (int i = 0; i < num_pegs - 1; i++) { LevelEntry entry = (LevelEntry)objs[0].Clone(); LevelEditor.Level.Entries.Add(entry); entries.Add(entry); } LevelEditor.ClearSelection(); LevelEditor.SelectedEntries = entries; spreadPhaseRibbonButton_Click(sender, e); LevelEditor.UpdateRedraw(); UpdatePropertyGrid(); }
public DrawEditorTool(LevelEntry le, bool draw) { mEntry = le; mDraw = draw; }
public override void MouseDown(MouseButtons button, Point location, Keys modifierKeys) { Level level = Editor.Level; Point vl = Editor.Level.GetVirtualXY(location); //Get the pegs at this point LevelEntry[] les = level.GetObjectsIn(new RectangleF(vl.X, vl.Y, 1, 1)); //Get top most object LevelEntry top_le = null; if (les.Length > 0) { top_le = les[les.Length - 1]; } //Select the one thats already selected if possible LevelEntry le = null; foreach (LevelEntry entry in les) { if (Editor.SelectedEntries.Contains(entry)) { le = entry; break; } } if (top_le != le) { le = null; } //Select whatever one is there if (le == null && les.Length > 0) { le = top_le; } //Did we click on an object if (le != null) { if (Editor.SelectedEntries.Contains(le)) { } else { //Unless control is down, clear selection if ((modifierKeys & Keys.Control) == 0) { Editor.SelectedEntries.Clear(); } //Add the new peg to the selection Editor.SelectedEntries.Add(le); } if (button == MouseButtons.Left) { //Set the selection start to here mSelectionStart = location; //Store all the original poisitons of the objects mObjectPoints.Clear(); for (int i = 0; i < Editor.SelectedEntries.Count; i++) { LevelEntry objs = Editor.SelectedEntries[i]; mObjectPoints.Add(new PointF(objs.X, objs.Y)); } //We are moving the pegs mDragObject = le; mMovingObjects = true; mFirstObjectMovement = true; } } else { Editor.SelectedEntries.Clear(); //Start selection rectangle mSelectionStart = location; mSelecting = true; } Editor.UpdateRedraw(); Editor.CheckSelectionChanged(); }