public void addFocusToList(Focus FocusToAdd) { FociList.Add(FocusToAdd); RowCount = FocusToAdd.Y >= RowCount ? FocusToAdd.Y + 1 : RowCount; ColumnCount = FocusToAdd.X >= ColumnCount ? FocusToAdd.X + 1 : ColumnCount; DrawOnCanvas(); }
public void addFocusToList(FocusModel FocusToAdd) { FociList.Add(FocusToAdd); UndoService.Current[GetUndoRoot()].EndChangeSetBatch(); RowCount = FocusToAdd.Y >= RowCount ? FocusToAdd.Y + 1 : RowCount; ColumnCount = FocusToAdd.X >= ColumnCount ? FocusToAdd.X + 1 : ColumnCount; DrawOnCanvas(); }
public FocusGridModel(FocusGridModel model) { SetupCommons(); //Transfer data UniqueID = Guid.NewGuid(); visibleName = model.visibleName; tag = model.tag; additionnalMods = model.additionnalMods; foreach (FocusModel focus in model.FociList) { FociList.Add(new FocusModel(focus)); } //Rerun to create sets foreach (FocusModel focus in FociList) { focus.RepairSets(model.FociList.FirstOrDefault(f => f.UniqueName == focus.UniqueName), FociList.ToList()); } //Create the remaining stuff FociList.CollectionChanged += FociList_CollectionChanged; //Min Row & column Count EditGridDefinition(); }
public FocusGridModel(FociGridContainer container) { SetupCommons(); //Transfer data UniqueID = container.IdentifierID; visibleName = container.ContainerID; tag = container.TAG; additionnalMods = container.AdditionnalMods; foreach (Focus focus in container.FociList) { FociList.Add(new FocusModel(focus)); } //Rerun to create sets foreach (FocusModel model in FociList) { model.RepairSets( container.FociList.FirstOrDefault(f => f.UniqueName == model.UniqueName), FociList.ToList()); } //Create the remaining stuff FociList.CollectionChanged += FociList_CollectionChanged; //Min Row & column Count EditGridDefinition(); }
private void Paste(object sender) { if (!CanPaste(sender)) { return; } UndoService.Current[GetUndoRoot()] .BeginChangeSetBatch("PasteMultiple", false); Point mousePos = Mouse.GetPosition((IInputElement)sender); if (!CopyTempMemory.Any()) { return; } int XChange = 0; int YChange = 0; if (sender != null) { FocusModel First = CopyTempMemory.FirstOrDefault(); if (First == null) { return; } XChange = (int)Math.Floor(mousePos.X / 89 - 0.4) - First.DisplayX; YChange = (int)Math.Floor(mousePos.Y / 140) - First.DisplayY; } List <FocusModel> newSelected = CopyTempMemory.Select(selected => selected.Copy(XChange, YChange)).ToList(); for (int index = 0; index < CopyTempMemory.Count; index++) { FocusModel selected = CopyTempMemory[index]; FocusModel currentFocus = newSelected[index]; //Repair relative to if (selected.CoordinatesRelativeTo != null) { //If the relative to can be found in the current new list if (newSelected.Any(f => selected.CoordinatesRelativeTo.UniqueName == f.UniqueName)) { currentFocus.CoordinatesRelativeTo = newSelected.FirstOrDefault(f => selected.CoordinatesRelativeTo.UniqueName == f.UniqueName); } else { //Otherwise, keep the same currentFocus.CoordinatesRelativeTo = selected.CoordinatesRelativeTo; } } //Repair prerequisites foreach (PrerequisitesSetModel set in selected.Prerequisite) { PrerequisitesSetModel newset = new PrerequisitesSetModel(currentFocus); foreach (FocusModel child in set.FociList) { //If the focus to can be found in the current new list if (newSelected.Any(f => child.UniqueName == f.UniqueName)) { newset.FociList.Add(newSelected.FirstOrDefault(f => child.UniqueName == f.UniqueName)); } else { //Otherwise, keep the same newset.FociList.Add(child); } } currentFocus.Prerequisite.Add(newset); } //Repair mutually exclusives foreach (MutuallyExclusiveSetModel set in selected.MutualyExclusive) { FocusModel toFind; FocusModel focus1; FocusModel focus2; if (set.Focus1.UniqueName == currentFocus.UniqueName) { toFind = set.Focus2; focus1 = set.Focus1; } else if (set.Focus2.UniqueName == currentFocus.UniqueName) { toFind = set.Focus1; focus1 = set.Focus2; } else { //Cannot be found, cancel continue; } //If the focus to can be found in the current new list if (newSelected.Any(f => toFind.UniqueName == f.UniqueName)) { focus2 = newSelected.FirstOrDefault(f => toFind.UniqueName == f.UniqueName); } else { //Otherwise, keep the same focus2 = toFind; } currentFocus.MutualyExclusive.Add(new MutuallyExclusiveSetModel(focus1, focus2)); } currentFocus.IsSelected = true; FociList.Add(currentFocus); } //Unselect all the selected foci foreach (FocusModel selected in SelectedFocuses) { selected.IsSelected = false; } //Change all copied name to append _Copy foreach (FocusModel currentFocus in newSelected) { currentFocus.UniqueName += "_Copy"; } SelectedFocuses = newSelected; UndoService.Current[GetUndoRoot()].EndChangeSetBatch(); }