Using a string resource in UWP Style Setter - localization

I am migrating an app from Windows 8 to UWP. The app uses string resources for localization.
In Windows 8 I used to do this to localize AppBar buttons:
<Style x:Key="SkipAheadAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="SkipAheadAppBarButton"/>
<Setter x:Uid="Step" Property="AutomationProperties.Name" Value=".skip"/>
<Setter Property="Content" Value=""/>
</Style>
And then I would have a string for "Step.Value". For some reason that does not work in UWP project in Visual Studio 2017. The button shows ".skip" instead of the actual value of Step.Value in Resources.resw.
Simpler <Run x:Uid="App" Text=".Rob"/> works without any problems.

We can not use the x:Uid in the Setter.
Use x:Uid to identify an object element in your XAML. Typically this object element is an instance of a control class or other element that is displayed in a UI.
For more info, please refer Remarks of x:Uid directive.
You should be able to add x:Uid in the Button.
For example:
<Button x:Uid="MyButton" AutomationProperties.Name="AddToIndexButton" Content="Button"></Button>
You should be able to set MyButton.AutomationProperties.Name to the Name and YourValue to the Value of the Resources.resw.
I have also test the <Run x:Uid="App" Text=".Rob"/>, it will throw exception. If you can use it in UWP, could you please give us a sample?

Related

Issue with FDF on different platforms PDFTron

I am facing an issue wherein I am unable to show annotations on my PDF on IOS device that are made from some other platforms e.g web, Windows or android. What is actually happening is if I am editing an already created annotation like an underline by changing the notes associated with it from my iOS device, then it is not reflecting on other platforms.
On further Investigation, I found that the PDF format generated by PDFTRON on iOS is different from the format generated by PDFTRON on any other platform. For example, I draw an underline annotation on a document from the web. The initial FDF received is as follows:
<squiggly subject="Squiggly" page="0" rect="275.93,656.703203,336.2084,665.759453" flags="print" name="0eabf5b2-77ab-4c04-3379-438e7a8fc714" title="testuser" date="D:20161027122930+05'30'" color="#FF0000" opacity="1" creationdate="D:20161027121425+05'30'" coords="275.93,665.76,336.21,665.76,275.93,656.7,336.21,656.7"><contents-richtext><body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:spec="2.0.2" xfa:APIVersion="Acrobat:10.1.3"><p dir="ltr"><span dir="ltr" style="font-size:10.0pt;text-align:left;color:#000000;font-weight:normal;font-style:normal">under_line</span></p></body></contents-richtext><contents>under_line</contents><popup flags="print,nozoom,norotate" page="0" rect="0,692,150,792" open="no"/></squiggly>
I have entered the text under_line in the notes initially. Now when I edit this annotation from the web (Changing the text from under_line to under_lines) , the resulting FDF is as follows:
<squiggly subject="Squiggly" page="0" rect="275.93,656.703203,336.2084,665.759453" flags="print" name="0eabf5b2-77ab-4c04-3379-438e7a8fc714" title="testuser" date="D:20161027122930+05'30'" color="#FF0000" opacity="1" creationdate="D:20161027121425+05'30'" coords="275.93,665.76,336.21,665.76,275.93,656.7,336.21,656.7"><contents-richtext><body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:spec="2.0.2" xfa:APIVersion="Acrobat:10.1.3"><p dir="ltr"><span dir="ltr" style="font-size:10.0pt;text-align:left;color:#000000;font-weight:normal;font-style:normal">under_lines</span></p></body></contents-richtext><contents>under_lines</contents><popup flags="print,nozoom,norotate" page="0" rect="0,692,150,792" open="no"/></squiggly>
The same annotation when edited from an iOS device produces the following FDF:
<squiggly subject="Squiggly" page="0" rect="275.93,656.703203,336.2084,665.759453" flags="print" name="0eabf5b2-77ab-4c04-3379-438e7a8fc714" title="testuser" date="D:20161027122930+05'30'" color="#FF0000" opacity="1" creationdate="D:20161027121425+05'30'" coords="275.93,665.76,336.21,665.76,275.93,656.7,336.21,656.7"><contents-richtext><body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:spec="2.0.2" xfa:APIVersion="Acrobat:10.1.3"><p dir="ltr"><span dir="ltr" style="font-size:10.0pt;text-align:left;color:#000000;font-weight:normal;font-style:normal">under_line</span></p></body></contents-richtext><contents>under_lines</contents><popup flags="print,nozoom,norotate" page="0" rect="0,692,150,792" open="no"/></squiggly>
Now you can see the difference. When I edit the text on the web, the text is changed at both points wherever it appears while when it is changed from the iOS device , the text is updated at only one place.
I believe this is causing a problem for me. How can I resolve this?
Annotation can actually have two Contents. The regular one, and a Rich Contents (essentially a minimal subset of HTML). The two are not guaranteed to be the same, which is the case here. One field got updated, the other didn't, as this actually depends on the specific PDF software used.
There is no difference between our different SDK's in this regards, so either you used two different files, or two different PDF readers. It sounds like on iOS used a 3rd party program.

Adding a datamodule to the delphi object repository

I am using D10 Pro. I added a datamodule to the object repository by right clicking it and selecting "Add to Repository" on the popup menu.
The datamodule shows up in the New>Other dialog and I am able to click the icon for it. When I do, I get the following exception: "Unable to find both a form () and source file (). The same exception occurs with forms I place there. The object that came with Delphi load without any problem. How do I fix this?
When adding items to the repository, you should avoid using dotnet style names for your files. For example, I originally named the file "MyLib.Datamodule.TextImporter.pas" and I received the error in my question. I experienced the same problem with a form using the same dotnet style naming. After changing the file name to "TextImporterDatamodule.pas" and adding it to the repository, I was able to use it to create new datamodules without a problem. This is something Embarcadero needs to address.
I can't answer your q, but maybe this will help you track down your problem.
Contrary to what the DocWiki says for Seattle, the repository .Xml file is actually named "Repository.Xml" and in my case is located here:
C:\Users\MA\AppData\Roaming\Embarcadero\BDS\17.0\Repository.Xml
I added a data module to it, resulting in the entry shown below being added.
Notice that for a datamodule, the path to it is stored in its IDString
attribute along with the filename, unlike a form, where the path+name is stored
in the the Value attribute of the FormName node.
With that entry in place, unlike you I can then include a copy of it in a project
by going to File | New | Other in the IDE. However, if I then change the
on-disk name of the folder where the item is located, and try to use it, I get the error
message you quoted. Of course, that doesn't mean that's why you're getting
it, but I thought it might help to see the repository entry for something that's known to work.
<Item IDString="D:\Delphi\Code\SO\Devex\DM1" CreatorIDString="BorlandDelphiRepositoryCreator">
<Name Value="AAADataModule"/>
<Icon Value=""/>
<Description Value="MA datamodule"/>
<Author Value="MA"/>
<Personality Value="Delphi.Personality"/>
<Platforms Value=""/>
<Frameworks Value=""/>
<Identities Value="RADSTUDIO"/>
<Categories>
<Category Value="InternalRepositoryCategory.MyCategory" Parent="Borland.Delphi.NewFiles">MyCategory</Category>
<Category Value="Borland.Delphi.NewFiles" Parent="Borland.Delphi.New">Delphi Files</Category>
<Category Value="Borland.Delphi.New" Parent="Borland.Root">Delphi Projects</Category>
</Categories>
<Type Value="FormTemplate"/>
<Ancestor Value=""/>
<FormName Value=""/>
<Designer Value="Any"/>
</Item>
If this doesn't help, best I can suggest is to post your q in the IDE section
of EMBA's newsgroups here:
https://forums.embarcadero.com/forum.jspa?forumID=62
I don't think that should provoke cross-posting complaints, seeing as your q has been up here for a while without getting a definitive answer.

iOS 8 + Swift - Looking to define multiple lanes, but draw them based on events

I have 3 buttons in one of my app storyboards. Based on the button pressed by the user, I would like to have a different line drawn. I'm new to iOS development and I was looking at Apple's Developer Library for details on how to create a context, path and line definition, but I was not able to figure out the implementation to define the contexts and paths for multiple lines.
Thanks in advance for the help.
Edit - 2015-02-24: To clarify the question and adding a video explaining how I do this on another platform.
Because the question might be difficult to understand, and because I have more experience with Windows development, I created a Windows Phone app showing what I'd like to do on iOS+Swift.
Here is how I do this in XAML + C# for Windows Universal Apps (Runtime)
First, I define the line in MainPage.xaml (The Tranform tags are added later):
<Line x:Name="line1" Stroke="Black" StrokeThickness="6" Y1="60" Y2="60" RenderTransformOrigin="0.5,0.5" Margin="1,0,-1,0" X1="30" X2="30">
<Line.RenderTransform>
<CompositeTransform/>
</Line.RenderTransform>
</Line>
Then I define the storyboard animation within the Page.Resources section in the XAML file:
<Storyboard x:Name="anLine2">
<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="line1" d:IsOptimized="True"/>
<DoubleAnimationUsingKeyFrames EnableDependentAnimation="True" Storyboard.TargetProperty="(Line.X2)" Storyboard.TargetName="line2">
<EasingDoubleKeyFrame KeyTime="0" Value="30"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.30" Value="380"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
I define the button:
<Button x:Name="btnL1" Content="Line 1" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="10,0,0,0" Click="btnL1_Click"/>
And finally I trigger the animation <> when the button is pressed:
private void btnL1_Click(object sender, RoutedEventArgs e)
{
anLine1.Begin();
}
I defined 3 lines and 3 buttons. The result is seen in this video (It looks a bit choppy in the video, but it is because of the screen capture software. The execution in the emulator and test devices is very smooth):
http://youtu.be/Y4i2IUehl7U
Now, what I want is being able to do exactly this, but on iOS using Swift. I hope this helps clarifying the question.
Thanks in advance!
I think what you want is to animate a line being drawn - if so, see this questions:
how to draw line with animation?
In particular one of the answers has this link:
http://tumbljack.com/post/179975074/complex-interpolation-with-cashapelayer-free
Basically, use a CAShapeLayer and animate from an empty path to a path with your destination.

obtaining a reference to IHTMLCanvasElement

How Can I get a DOM reference to the canvas Handle. I'm using Delphi, IE11 and the corresponding MSMHTML Type library,I suspected it's along the lines of
canvasHandle := (HTMLDoc3.getElementById('canvas') as IHTMLCanvasElement);
the Html:
<canvas id="canvas">
....
</canvas>
however this throws an exception 'Interface not supported'
TWebBrowser control, by default uses IE7 standards/rendering mode.
You need to tell the control to use latest standards.
There are a few ways of doing this.
Here are two of the ways known to me:
Either you specify FEATURE_<some feature> for your application in the registry (.e.g. FEATURE_BROWSER_EMULATION also a nice article here).
Add a "meta http-equiv-'X-UA-Compatible' content= edge" to the <head> block of a webpage to force Windows IE to use the latest standards.
This will enable your HTML5 functionality working without the need for registry tweaks.

monodroid: how to create receiver/meta-data clause in manisfest.xml

I note the the mono android port of the SDK API Demos does not include the DeviceAdministration pieces.
Is this because it (DeviceAdmin) doesnt work? I have tried to make a small sample app and have not succeeded.
EDIT: Well I got a fair way in, now my problem is that I cannot generate the receiver/meta-data clause
I am on my way to writing my own aapt.exe to intercept the xml file on its way through this seems like a lot of heavy lifting
You can use the [BroadcastReceiverAttribute] custom attribute to generate the <receiver/> element, and you can use the [MetaDataAttribute] custom attribute to generate the <meta-data/> element:
[BroadcastReceiver]
[MetaData ("foo", Value="bar")]
public class MyReceiver : BroadcastReceiver {
}
Would generate the XML fragment within AndroidManifest:
<receiver android:name="generated-by-mandroid">
<meta-data android:name="foo" android:value="bar" />
</receiver>

Resources