Added some loc work for documents

This commit is contained in:
Rick Falkvinge
2018-02-10 15:45:38 +01:00
parent 30b3d71c51
commit 1c586c2fdd
5 changed files with 73 additions and 6 deletions
+18
View File
@@ -60,6 +60,24 @@ namespace Swarmops.Logic.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to (Last page of {0}).
/// </summary>
internal static string LastPageOfX {
get {
return ResourceManager.GetString("LastPageOfX", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to (First page of {0}).
/// </summary>
internal static string PageOneOfX {
get {
return ResourceManager.GetString("PageOneOfX", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to (Single page).
/// </summary>
+7 -1
View File
@@ -117,12 +117,18 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="LastPageOfX" xml:space="preserve">
<value>(Last page of {0})</value>
</data>
<data name="PageOneOfX" xml:space="preserve">
<value>(First page of {0})</value>
<comment>This should say there's more than is beeing looked at (first page is the one that shows up first)</comment>
</data>
<data name="PageSingle" xml:space="preserve">
<value>(Single page)</value>
<comment>If it is possible to say "this is the only page" or "you're looking at the only page" in the translated language, it's preferable to the English wording. "Only page" doesn't sound like correct English, but your language might have a construct for it.</comment>
</data>
<data name="PageXofY" xml:space="preserve">
<value>(Page {0} of {1})</value>
<comment>This should convey a meaning that there's more than is being looked at.</comment>
</data>
</root>
-1
View File
@@ -21,7 +21,6 @@ namespace Swarmops.Logic.Support
{
foreach (BackendServiceOrder order in this)
{
Console.WriteLine("Excecuting backend order #" + order.Identity); // debug purposes
order.Execute();
}
}
@@ -25,7 +25,6 @@ namespace Swarmops.Logic.Support.BackendServices
HasWorkerThread = true;
WorkerThread = new Thread(LongRun);
WorkerThread.Start(this);
Console.WriteLine(" - Worker thread for #" + this.ServiceOrderIdentity + " started"); // debugging
}
private static void LongRun(object orderObject)
@@ -34,15 +33,13 @@ namespace Swarmops.Logic.Support.BackendServices
try
{
order = (RasterizeDocumentHiresOrder)orderObject;
Console.WriteLine(" - Worker thread for #" + order.ServiceOrderIdentity + " running"); // debugging
Document document = Document.FromIdentity(order.DocumentId);
PdfProcessor.Rerasterize((Document)document, PdfProcessor.PdfProcessorOptions.HighQuality | PdfProcessor.PdfProcessorOptions.ForceOrphans);
order.Close();
}
catch (Exception exception)
{
Console.WriteLine(" - Exception thrown: " + exception.ToString()); // debugging
order.ThrewException(exception);
order?.ThrewException(exception);
}
if (order != null)
+47
View File
@@ -2,6 +2,7 @@ using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Structure;
using Swarmops.Common.Enums;
@@ -30,6 +31,52 @@ namespace Swarmops.Logic.Support
}
}
public new string ClientFileName
{
get
{
string input = base.ClientFileName;
Regex regex = new Regex("{{LOCPAGE\\-(?<current>[0-9]+)\\-(?<total>[0-9]+)}}");
Match match = regex.Match(input);
if (match.Success)
{
input = input.Substring(0, input.IndexOf("{{LOCPAGE", StringComparison.InvariantCulture));
int currentPage = Int32.Parse(match.Groups["current"].Value);
int totalPages = Int32.Parse(match.Groups["total"].Value);
if (currentPage == 1 && totalPages == 1)
{
// Single page
return input + Resources.Logic_Support_Document.PageSingle;
}
if (currentPage == 1)
{
// First page of X
return input + String.Format(Resources.Logic_Support_Document.PageOneOfX, totalPages);
}
if (currentPage == totalPages)
{
// Last page of X
return input + String.Format(Resources.Logic_Support_Document.LastPageOfX, totalPages);
}
// Page X of Y
return input + String.Format(Resources.Logic_Support_Document.PageXofY, currentPage, totalPages);
}
// No localization
return input;
}
}
public IHasIdentity ForeignObject
{
get