DirectoryInfo Refresh(IconRootType type) { if (!type.IsMain()) { throw new ArgumentOutOfRangeException(nameof(type), type, null); } var path = ApplicationArguments.Options?.Roots?.Get(type) ?? LibSettings.LibSetting?.Directories?.Roots?.Get(type); return(string.IsNullOrWhiteSpace(path) ? null : new DirectoryInfo(path)); }
public void Set(IconRootType type, T value) { switch (type) { case IconRootType.Icons: _icons = value; break; case IconRootType.Library: _library = value; break; case IconRootType.Content: _content = value; break; case IconRootType.Action: _action = value; break; case IconRootType.Labels: var info = value as DirectoryInfo; if (info != null) { Labels.Add(info?.Name); RefreshLabelsRegex(); break; } var str = value?.ToString(); if (!string.IsNullOrWhiteSpace(str)) { var label = Paths.GetFileName(str); if (Labels.Contains(label)) { return; } Labels.Add(label); var sortedLabels = Labels.OrderBy(x => x).ToArray(); Labels.Clear(); Labels.AddRange(sortedLabels); RefreshLabelsRegex(); } break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } OnPropertyChanged(type.ToString()); }
public virtual T Get(IconRootType type) { switch (type) { case IconRootType.Icons: return(_icons); case IconRootType.Library: return(_library); case IconRootType.Content: return(_content); case IconRootType.Action: return(_action); default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } }
public static bool IsMain(this IconRootType value) => Main.Contains(value);