private void StashedSelectedIndexChanged(object sender, EventArgs e) { GitStash gitStash = Stashes.SelectedItem as GitStash; GitItemStatus stashedItem = Stashed.SelectedItem; EnablePartialStash(); Cursor.Current = Cursors.WaitCursor; if (stashedItem != null && gitStash == currentWorkingDirStashItem) //current working directory { View.ViewCurrentChanges(stashedItem); } else if (stashedItem != null) { if (stashedItem.IsNew) { if (!stashedItem.IsSubmodule) { View.ViewGitItem(stashedItem.Name, stashedItem.TreeGuid); } else { View.ViewText(stashedItem.Name, LocalizationHelpers.GetSubmoduleText(Module, stashedItem.Name, stashedItem.TreeGuid)); } } else { string extraDiffArguments = View.GetExtraDiffArguments(); Encoding encoding = this.View.Encoding; View.ViewPatch(() => { Patch patch = Module.GetSingleDiff(gitStash.Name + "^", gitStash.Name, stashedItem.Name, stashedItem.OldName, extraDiffArguments, encoding, true, stashedItem.IsTracked); if (patch == null) { return(String.Empty); } if (stashedItem.IsSubmodule) { return(LocalizationHelpers.ProcessSubmodulePatch(Module, stashedItem.Name, patch)); } return(patch.Text); }); } } else { View.ViewText(string.Empty, string.Empty); } Cursor.Current = Cursors.Default; }
private void SaveClick(object sender, RoutedEventArgs e) { var dlg = new Microsoft.Win32.SaveFileDialog(); dlg.FileName = "English"; // Default file name dlg.DefaultExt = ".wgglang"; // Default file extension dlg.Filter = "Word Game Generator Localization (.wgglang) | *.wgglang"; // Filter files by extension var success = dlg.ShowDialog(); if (success.HasValue && success.Value) { LocalizationHelpers.SaveLocalization(dlg.FileName, _localization); } }
public object GetJsonLocalizations(string version) { var xml = LoadXml(_translationFilePath, version); var languages = GetEnabledLanguages(); var localizations = LocalizationHelpers.GetLocalizationDefinitions().Select(d => new { key = d.Key, translations = languages.Select(language => new { language, value = FindExistingTranslation(xml, language, d.Key) }) }); return(new { localizations }); }
protected override string GetLocalizedString(string value) { if (!string.IsNullOrEmpty(value)) { if (value.Contains(',')) { string[] values = value.Split(','); return(LocalizationHelpers.GetLocalizedString( values[0], values[1], CultureInfo.CurrentUICulture.LCID)); } } return(""); }
public void ProcessRequest(HttpContext context) { if (!String.Equals(context.Request.RequestType, "GET")) { return; } string path = context.Request.Path.TrimStart('/').Replace(".resjson", String.Empty); string resjson = LocalizationHelpers.GetResourceJson(path); context.Response.Clear(); context.Response.ContentType = "text/json"; context.Response.Write(resjson); context.Response.Flush(); }
public void Render_with_spaces_with_links() { var expectedHeader = "Author: <a href='mailto:[email protected]'>John Doe (Acme Inc) <[email protected]></a>" + Environment.NewLine + "Author date: 3 days ago (" + LocalizationHelpers.GetFullDateString(_data.AuthorDate) + ")" + Environment.NewLine + "Committer: <a href='mailto:[email protected]'>Jane Doe <[email protected]></a>" + Environment.NewLine + "Commit date: 2 days ago (" + LocalizationHelpers.GetFullDateString(_data.CommitDate) + ")" + Environment.NewLine + "Commit hash: " + _data.Guid + Environment.NewLine + "Children: " + "<a href='gitext://gotocommit/" + _data.ChildrenGuids[0] + "'>" + GitRevision.ToShortSha(_data.ChildrenGuids[0]) + "</a> " + "<a href='gitext://gotocommit/" + _data.ChildrenGuids[1] + "'>" + GitRevision.ToShortSha(_data.ChildrenGuids[1]) + "</a> " + "<a href='gitext://gotocommit/" + _data.ChildrenGuids[2] + "'>" + GitRevision.ToShortSha(_data.ChildrenGuids[2]) + "</a>" + Environment.NewLine + "Parent(s): " + "<a href='gitext://gotocommit/" + _data.ParentGuids[0] + "'>" + GitRevision.ToShortSha(_data.ParentGuids[0]) + "</a> " + "<a href='gitext://gotocommit/" + _data.ParentGuids[1] + "'>" + GitRevision.ToShortSha(_data.ParentGuids[1]) + "</a>"; var result = _rendererSpaces.Render(_data, true); result.Should().Be(expectedHeader); }
public void CanCreateCommitInformationFromFormatedData() { LinkFactory linkFactory = new LinkFactory(); var commitGuid = Guid.NewGuid(); var treeGuid = Guid.NewGuid(); var parentGuid1 = Guid.NewGuid().ToString(); var parentGuid2 = Guid.NewGuid().ToString(); var authorTime = DateTime.UtcNow.AddDays(-3); var commitTime = DateTime.UtcNow.AddDays(-2); var authorUnixTime = (int)(authorTime - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds; var commitUnixTime = (int)(commitTime - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds; var rawData = commitGuid + "\n" + treeGuid + "\n" + parentGuid1 + " " + parentGuid2 + "\n" + "John Doe (Acme Inc) <*****@*****.**>\n" + authorUnixTime + "\n" + "Jane Doe (Acme Inc) <*****@*****.**>\n" + commitUnixTime + "\n" + "\n" + "\tI made a really neato change.\n\n" + "Notes (p4notes):\n" + "\tP4@547123"; var expectedHeader = "Author: <a href='mailto:[email protected]'>John Doe (Acme Inc) <[email protected]></a>" + Environment.NewLine + "Author date: 3 days ago (" + LocalizationHelpers.GetFullDateString(authorTime) + ")" + Environment.NewLine + "Committer: <a href='mailto:[email protected]'>Jane Doe (Acme Inc) <[email protected]></a>" + Environment.NewLine + "Commit date: 2 days ago (" + LocalizationHelpers.GetFullDateString(commitTime) + ")" + Environment.NewLine + "Commit hash: " + commitGuid + Environment.NewLine + "Parent(s): <a href='gitext://gotocommit/" + parentGuid1 + "'>" + parentGuid1.Substring(0, 10) + "</a> <a href='gitext://gotocommit/" + parentGuid2 + "'>" + parentGuid2.Substring(0, 10) + "</a>"; var expectedBody = "\nI made a really neato change." + Environment.NewLine + Environment.NewLine + "Notes (p4notes):" + Environment.NewLine + "\tP4@547123"; // TEMP, will be refactored in the follow up refactor var commitData = new CommitDataManager(() => new GitModule("")).CreateFromFormatedData(rawData); var commitInformation = CommitInformation.GetCommitInfo(commitData, linkFactory, true); Assert.AreEqual(expectedHeader, commitInformation.Header); Assert.AreEqual(expectedBody, commitInformation.Body); }
public CategoryList GetLocalizations() { var xml = LoadXml(_translationFilePath); var languages = GetEnabledLanguages(); var categories = new CategoryList(); foreach (var localization in LocalizationHelpers.GetLocalizationDefinitions()) { var translation = categories.AddTranslation( localization.Key, localization.Description, localization.Category, localization.DefaultValue); foreach (var lang in languages) { var value = FindExistingTranslation(xml, lang, translation.Key); translation.AddTranslation(lang, value ?? string.Empty); } } return(categories); }
private void LanguageChanged(object sender, RoutedEventArgs e) { if (sender is MenuItem) { if ((sender as MenuItem).Header.ToString() == "English") { SetLocalization(new MainWindowLocalization()); } else { SetLocalization(LocalizationHelpers.LoadLocalization(new FileInfo(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath).DirectoryName + "/lang/" + (sender as MenuItem).Header + ".wgglang")); } foreach (var i in _languages) { if (i == sender) { continue; } i.IsChecked = false; } } }
private void GitTree_AfterSelect(object sender, TreeViewEventArgs e) { var item = e.Node.Tag as GitItem; if (item == null) { return; } if (item.IsBlob) { FileText.ViewGitItem(item.FileName, item.Guid); } else if (item.IsCommit) { FileText.ViewText(item.FileName, LocalizationHelpers.GetSubmoduleText(Module, item.FileName, item.Guid)); } else { FileText.ViewText("", ""); } }
static async Task <string?> GetSelectedPatchAsync( FileViewer fileViewer, ObjectId firstId, ObjectId selectedId, GitItemStatus file, CancellationToken cancellationToken) { if (firstId == ObjectId.CombinedDiffId) { var diffOfConflict = fileViewer.Module.GetCombinedDiffContent(selectedId, file.Name, fileViewer.GetExtraDiffArguments(), fileViewer.Encoding); cancellationToken.ThrowIfCancellationRequested(); return(string.IsNullOrWhiteSpace(diffOfConflict) ? TranslatedStrings.UninterestingDiffOmitted : diffOfConflict); } var task = file.GetSubmoduleStatusAsync(); if (file.IsSubmodule && task is not null) { // Patch already evaluated var status = await task; cancellationToken.ThrowIfCancellationRequested(); return(status is not null ? LocalizationHelpers.ProcessSubmoduleStatus(fileViewer.Module, status) : $"Failed to get status for submodule \"{file.Name}\""); } var patch = await GetItemPatchAsync(fileViewer.Module, file, firstId, selectedId, fileViewer.GetExtraDiffArguments(), fileViewer.Encoding); cancellationToken.ThrowIfCancellationRequested(); return(file.IsSubmodule ? LocalizationHelpers.ProcessSubmodulePatch(fileViewer.Module, file.Name, patch) : patch?.Text);
public void ViewGitItem(string fileName, string guid) { ViewItem(fileName, () => GetImage(fileName, guid), () => GetFileTextIfBlobExists(guid), () => LocalizationHelpers.GetSubmoduleText(Module, fileName.TrimEnd('/'), guid)); }
public void ViewFile(string fileName) { ViewItem(fileName, () => GetImage(fileName), () => GetFileText(fileName), () => LocalizationHelpers.GetSubmoduleText(Module, fileName.TrimEnd('/'), "")); }
public ActionResult _TreeCopy(int item, int destinationitem) { if (CheckPermissions(item) == false || CheckPermissions(destinationitem) == false) { return(Content(LocalizationHelpers.GetLocalResource("~/Areas/Admin/Views/Shared/_TreeView.cshtml", "ErrorPermitions"))); } AbstractPage ItemPage = _db.AbstractPages.FirstOrDefault(r => r.DomainID == AdminCurrentSettingsRepository.ID && r.ID == item); AbstractPage DestinationItemPage = _db.AbstractPages.FirstOrDefault(r => r.DomainID == AdminCurrentSettingsRepository.ID && r.ID == destinationitem); if (ItemPage.ParentID == 0 || ItemPage.RouteUrl == "d") { return(Content(LocalizationHelpers.GetLocalResource("~/Areas/Admin/Views/Shared/_TreeView.cshtml", "ErrorDomain"))); } Type t = ItemPage.GetType(); if (GetChildClasses(destinationitem).Contains(t)) { AbstractPage ap = ItemPage; AbstractPage Parent = _db.AbstractPages.FirstOrDefault(r => r.ID == destinationitem); ap.ParentID = Parent.ID; ap.DomainID = Parent.DomainID; ap.PermissionsEdit = Parent.PermissionsEdit; ap.PermissionsView = Parent.PermissionsView; Session["TreeCopy"] = true; if (ap.RouteUrl != "l") { ap.LanguageCode = Parent.LanguageCode; } ap.Title = ap.Title + "-Copy"; ap.SeoUrlName = (_db.AbstractPages.Max(r => r.ID) + 1).ToString(); if (_db.AbstractPages.Count(r => r.DomainID == ap.DomainID && r.SeoUrlName == ap.SeoUrlName) != 0) { return(Content(LocalizationHelpers.GetLocalResource("~/Areas/Admin/Views/Shared/_TreeView.cshtml", "ErrorTitle"))); } ap.CreateTime = DateTime.Now; if (_db.AbstractPages.Where(r => r.ParentID == ap.ParentID && r.DomainID == ap.DomainID).Count() == 0) { ap.Order = 1; } else { ap.Order = _db.AbstractPages.Where(r => r.ParentID == ap.ParentID && r.DomainID == ap.DomainID).Max(r => r.Order) + 1; } ap.OnCreate(); _db.AbstractPages.Add(ap); try { _db.SaveChanges(); } catch (DataException error) { return(Content(LocalizationHelpers.GetLocalResource("~/Areas/Admin/Views/Shared/_TreeView.cshtml", "ErrorGeneral") + error.Message)); } AbstractPage CopyItem = _db.AbstractPages.FirstOrDefault(r => r.DomainID == AdminCurrentSettingsRepository.ID && r.ID == item); foreach (AbstractPage item2 in _db.AbstractPages.Where(r => r.ParentID == CopyItem.ID).ToList()) { CopyPage(ap, item2, 5); } CleanCache.CleanCacheAfterPageEdit(); return(Content("true")); } else { return(Content(LocalizationHelpers.GetLocalResource("~/Areas/Admin/Views/Shared/_TreeView.cshtml", "ErrorParent"))); } }
protected override void ApplyStyle() { base.ApplyStyle(); Trace.Assert(TreeViewNode is not null); if (IsCurrent) { TreeViewNode.NodeFont = new Font(AppSettings.Font, FontStyle.Bold); } if (Info.Detailed?.RawStatus is not null) { // Prefer submodule status, shows ahead/behind TreeViewNode.ToolTipText = LocalizationHelpers.ProcessSubmoduleStatus( new GitModule(Info.Path), Info.Detailed.RawStatus, moduleIsParent: false, limitOutput: true); } else if (GitStatus is not null) { var changeCount = new ArtificialCommitChangeCount(); changeCount.Update(GitStatus); TreeViewNode.ToolTipText = changeCount.GetSummary(); } else { TreeViewNode.ToolTipText = DisplayText(); } TreeViewNode.ImageKey = GetSubmoduleItemImage(Info.Detailed); TreeViewNode.SelectedImageKey = TreeViewNode.ImageKey; return; // NOTE: Copied and adapated from FormBrowse.GetSubmoduleItemImage string GetSubmoduleItemImage(DetailedSubmoduleInfo details) { if (details?.Status is null) { return(nameof(Images.FolderSubmodule)); } if (details.Status == SubmoduleStatus.FastForward) { return(details.IsDirty ? nameof(Images.SubmoduleRevisionUpDirty) : nameof(Images.SubmoduleRevisionUp)); } if (details.Status == SubmoduleStatus.Rewind) { return(details.IsDirty ? nameof(Images.SubmoduleRevisionDownDirty) : nameof(Images.SubmoduleRevisionDown)); } if (details.Status == SubmoduleStatus.NewerTime) { return(details.IsDirty ? nameof(Images.SubmoduleRevisionSemiUpDirty) : nameof(Images.SubmoduleRevisionSemiUp)); } if (details.Status == SubmoduleStatus.OlderTime) { return(details.IsDirty ? nameof(Images.SubmoduleRevisionSemiDownDirty) : nameof(Images.SubmoduleRevisionSemiDown)); } // Unknown return(details.IsDirty ? nameof(Images.SubmoduleDirty) : nameof(Images.FileStatusModified)); } }
/// <summary> /// Formats the supplied date as relative local date (e.g. 3 months ago (10/9/17 4:38:40 pm)). /// </summary> /// <param name="date">Date to format.</param> /// <returns>Date in relative local date format.</returns> public string FormatDateAsRelativeLocal(DateTimeOffset date) { return(string.Format("{0} ({1})", LocalizationHelpers.GetRelativeDateString(_getUtcNow(), date.UtcDateTime), LocalizationHelpers.GetFullDateString(date))); }