private void AddCustomMorph(Morph morph) { bool morphAddedToExistingRegion = false; foreach (Region region in this) { if (region.Name == morph.Region) { morph.Parent = region; region.AddMorph(morph); morphAddedToExistingRegion = true; } } if (!morphAddedToExistingRegion) { // This morph has a custom region that's not yet listed. // Create a new region before adding this morph. Region region = new Region(morph.Region); morph.Parent = region; region.AddMorph(morph); Add(region); } // Also add every morph the root region. _root_region.AddMorph(morph); }
internal void ScanMorphFolder(string dir) { try { foreach (string sub in Directory.GetDirectories(dir)) { foreach (string filepath in Directory.GetFiles(sub, "*.vmi")) { try { Morph morph = new Morph(filepath, _morph_references); if (MatchesFilter(morph)) { App.Current.Dispatcher.Invoke((Action) delegate { AddCustomMorph(morph); }); } } catch (Exception ex) { MessageBox.Show("Could not load morph metadata from:\n\n" + filepath + "\n\n" + ex.Message, "Morphology", MessageBoxButton.OK, MessageBoxImage.Error); } } ScanMorphFolder(sub); } } catch (Exception ex) { MessageBox.Show("Could not scan the selected folder.\n\n" + ex.Message, "Morphology", MessageBoxButton.OK, MessageBoxImage.Error); } }
private bool MatchesFilter(Morph morph) { bool matchesType = _settings.ShowAutoMorphs && morph.IsAuto || _settings.ShowBadMorphs && morph.IsBad || _settings.ShowPoseMorphs && morph.IsPose || _settings.ShowShapeMorphs && !morph.IsPose; bool matchesReference = _settings.ShowUsedMorphs && morph.ReferenceCount > 1 || _settings.ShowSingleUseMorphs && morph.ReferenceCount == 1 || _settings.ShowUnusedMorphs && morph.ReferenceCount == 0; bool matchesName = _settings.MorphNameFilter is null || _settings.MorphNameFilter.Length == 0 || morph.DisplayName.ToLower().Contains(_settings.MorphNameFilter); return(matchesName && (_morph_references is null ? matchesType : matchesReference && matchesType)); }
private void AddCustomMorph(Morph morph) { bool morphAddedToExistingRegion = false; foreach (Region region in this) { if (region.Name == morph.Region) { morph.Parent = region; region.Morphs.Add(morph); morphAddedToExistingRegion = true; } } if (!morphAddedToExistingRegion) { // this morph has a custom region that's not yet listed // create anew region before adding this morph Region region = new Region(morph.Region); morph.Parent = region; region.Morphs.Add(morph); Add(region); } }
public void AddMorph(Morph morph) { _morphs.Add(morph); OnPropertyChanged("Info"); OnPropertyChanged("Morphs"); }