private void AddSubEntry(CourseSubEntry e) { SubEntries.Add(e); SubEntries.Sort((c1, c2) => { return((int)c1.DayOfWeek * 10 + c1.CourseTime - (int)c2.DayOfWeek * 10 - c2.CourseTime); }); }
public void SelectNamespace(string namespaceName) { SubEntries.Clear(); foreach (var type in cycle.TypesReferencingOutOf(namespaceName)) { SubEntries.Add(new TypeReferenceVM(type)); } }
/// <summary> /// 储存到json /// </summary> /// <returns></returns> public string ToJson() { return(JsonConvert.SerializeObject(new CourseEntryJson { CourseName = CourseName, EnableNotification = EnableNotification, SubEntries = SubEntries.Select(se => se.ToJson()).ToList() }));; }
/// <summary> /// Add prototype of this name to the subentries /// </summary> public void AddPrototype(string prototypeName) { var prototype = Entry.GetPrototype(prototypeName).Instantiate(); var prototypeVm = new EntryViewModel(prototype); SubEntries.Add(prototypeVm); UpdateParent(prototypeVm); }
/// <inheritdoc /> public override int GetHashCode() { unchecked { // ReSharper disable NonReadonlyMemberInGetHashCode // These values will not be modified var hashCode = Identifier.GetHashCode(); hashCode = (hashCode * 397) ^ Value.Current.GetHashCode(); hashCode = (hashCode * 397) ^ SubEntries.GetHashCode(); return(hashCode); } }
public BSA.BSA_Entry ConvertToXv2(int skillID) { BSA.BSA_SubEntries Xv2SubEntries = null; if (SubEntries != null) { Xv2SubEntries = SubEntries.ConvertToXv2(skillID); } if (skillID != -1) { Type6 = BSA.BSA_Type6.ChangeSkillId(Type6, skillID); } return(new BSA.BSA_Entry() { Index = Index.ToString(), I_00 = I_00, I_16_a = I_16_a, I_16_b = I_16_b, I_17 = I_17, I_18 = I_18, I_22 = I_22, I_24 = I_24, I_26 = I_26.ToString(), I_28 = "-1", I_30 = "-1", I_32 = "-1", I_40 = new int[3], SubEntries = Xv2SubEntries, Type0 = Type0, Type1 = BSA_Type1.ConvertToXv2(Type1), Type2 = Type2, Type3 = Type3, Type4 = Type4, Type6 = Type6, Type7 = Type7, Type8 = Type8 }); }
public override int GetHashCode() { unchecked { return(((Name != null ? Name.GetHashCode() : 0) * 397) ^ (SubEntries != null ? SubEntries.GetHashCode() : 0)); } }
/// <inheritdoc/> public IEnumerator <CourseSubEntry> GetEnumerator() { return(SubEntries.GetEnumerator()); }
public void BuildOutput(StringWriter stream, Settings settings) { if (IsSeperator) { stream.WriteLine("---"); } else if (IsCategory) { if (SubEntries.Count > 0) { stream.WriteLine(string.Format(". // (alias:{0})", Name)); SubEntries.ForEach(x => x.BuildOutput(stream, settings)); } } else { string finalPath; if (FolderPath.StartsWith(settings.DownloadsFolderPath)) { if (FolderPath == settings.DownloadsFolderPath) { finalPath = string.Format(". //{0} (alias: {1})", Comment, Name); } else { finalPath = FolderPath.Remove(0, settings.DownloadsFolderPath.Length + 1); } } else { // Get the drive prefix. string drivePrefix = Path.GetPathRoot(FolderPath);; // Get the folder path with the drive prefix removed string relativePath = FolderPath.Remove(0, drivePrefix.Length); // Get the safe identifier of the drive char[] arr = drivePrefix.ToCharArray(); arr = Array.FindAll <char>(arr, (c => (char.IsLetterOrDigit(c) || char.IsWhiteSpace(c) || c == '-'))); string driveLetter = new string(arr); // Get the root folder of the relative path. string rootFolder = GetRootFolder(relativePath); // create final written path finalPath = string.Format("{0}{1} //{2} (alias:{3})", new string('>', Deepness), Path.Combine(settings.SaveInLinksFolderName, driveLetter + relativePath), Comment, Name); if (!settings.SkipLinkCreation) { // Create a link path. string link = Path.Combine(settings.SaveInLinksFolderPath, driveLetter + rootFolder); if (!Directory.Exists(link)) { string realPath; // Get real path folder //HACK: if (rootFolder == "SaveInRoot") { realPath = "/"; } else { realPath = Path.Combine(drivePrefix, rootFolder); } CreateSymbolicLink(link, realPath); } } } // Write the final path stream.WriteLine(finalPath); // Do all of this for each sub entry and so on. SubEntries.ForEach(x => x.BuildOutput(stream, settings)); } }
public void LoadSubdirectories(Settings settings) { if (FolderPath == settings.SaveInLinksFolderPath || FolderPath == null || FolderPath == string.Empty) { return; } try { string[] subdirectoryEntries = Directory.GetDirectories(FolderPath); if (subdirectoryEntries.Length > 0) { for (int i = 0; i < subdirectoryEntries.Length; i++) { SubEntries.Add(new MenuEntry() { FolderPath = subdirectoryEntries[i], Name = Path.GetFileName(subdirectoryEntries[i]), Deepness = this.Deepness + 1 }); SubEntries[i].LoadSubdirectories(settings); } if (!settings.DisableLinkBack) { string insertName = settings.BackLinkStartText + this.Name + settings.BackLinkEndText; if (settings.IncludeNameInBackLink) { insertName = settings.BackLinkStartText + this.Name + settings.BackLinkEndText; } else { insertName = settings.BackLinkStartText + settings.BackLinkEndText; } MenuEntry entry = new MenuEntry() { FolderPath = this.FolderPath, Name = insertName, Deepness = this.Deepness + 1 }; if (settings.LinkBackOnBottom) { SubEntries.Add(entry); } else { SubEntries.Insert(0, entry); } } } else if (!settings.DisableLinkBack && settings.ForceLinkBack && Deepness > 0) { string insertName = settings.BackLinkStartText + this.Name + settings.BackLinkEndText; if (settings.IncludeNameInBackLink) { insertName = settings.BackLinkStartText + this.Name + settings.BackLinkEndText; } else { insertName = settings.BackLinkStartText + settings.BackLinkEndText; } MenuEntry entry = new MenuEntry() { FolderPath = this.FolderPath, Name = insertName, Deepness = this.Deepness + 1 }; SubEntries.Add(entry); } } catch (UnauthorizedAccessException) { return; } catch (DirectoryNotFoundException) // Probably a broken link within the path, in this context.. { return; } //TODO: Should probably give some feedback. catch (PathTooLongException) { return; } }