Basically, I'm almost finished making this note app which the users save notes etc. Basic note app function. The reason I'm not fully done is that i just need help with adding tiles to my app for the notes. Basically the user clicks the "Pin to start" from the menu item and for the selected note, pins that to the start. I've done this through:
Private Sub PinToStart_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs)
Dim Storage As IsolatedStorageFile = IsolatedStorageFile.GetUserStoreForApplication()
Dim data As SampleData = TryCast(TryCast(sender, MenuItem).DataContext, SampleData)
Dim selectedItem As ListBoxItem = TryCast(Me.SavedNotesList.ItemContainerGenerator.ContainerFromItem(data), ListBoxItem)
Dim directory As String = "./MyNote/SavedNotes/*.*"
Dim filenames As String() = Storage.GetFileNames(directory)
Dim dataSource As New List(Of SampleData)()
For Each filename As String In filenames
Dim ISF As IsolatedStorageFile = IsolatedStorageFile.GetUserStoreForApplication()
Dim FS As IsolatedStorageFileStream = ISF.OpenFile("MyNote/SavedNotes/" & filename, FileMode.Open, FileAccess.Read)
Dim FETime As String = Storage.GetCreationTime("MyNote/SavedNotes/" & data.FileNameX).ToString("dd/mm/yyyy h:mmtt")
Dim tileData As New StandardTileData() With { _
.Title = data.FileNameX, _
.BackgroundImage = New Uri("/Assets/202.png", UriKind.Relative), _
.BackTitle = data.FileNameX, _
.BackContent = data.Description}
ShellTile.Create(New Uri("/ViewPage.xaml?Title=" & data.FileNameX & "&Body=" & data.Description, UriKind.Relative), tileData)
Next
End Sub
Currently this is the code which creates the tile. Although there is one problem, once the tile is created it throws an exception and says "Tiles can only be created when the application is in the foreground" but it still proceeds and creates the tile with no problem. Second error i have is that I need a way to update the tile. I just don't know how.
Can anyone help me?
use HubTile control from Microsoft.Phone.Controls.Toolkit to created tile
you can try this code:
var shellTileData = new StandardTileData
{
BackgroundImage = new Uri("Path for image", UriKind.RelativeOrAbsolute),
BackContent = "xyz"
};
var tile = ShellTile.ActiveTiles.First();
tile.Update(shellTileData);
Related
i try to convert beloved code same into nativescript but i am new i have no idea for this please tell me how to convert android code to nativescript ...
private void createWebPrintJob() {
// Get a PrintManager instance
PrintManager printManager = (PrintManager)
getSystemService(Context.PRINT_SERVICE);
// Get a print adapter instance
PrintDocumentAdapter printAdapter = webView.createPrintDocumentAdapter();
// Create a print job with name and adapter instance
String jobName = getString(R.string.app_name) + " Document";
PrintJob printJob = printManager.print(jobName, printAdapter,
new PrintAttributes.Builder().build());
// Save the job object for later status checking
// mPrintJobs.add(printJob);
}
May be something like this,
var application = require('application');
var utils = require('utils/utils');
function createWebPrintJob() {
var printManager = application.android.context
.getSystemService(android.content.Context.PRINT_SERVICE);
var printAdapter = webView.createPrintDocumentAdapter();
var jobName = getString(utils.ad.getStringId("app_name")) + " Document";
var printJob = printManager.print(jobName, printAdapter, new namespace.to.PrintAttributes.Builder().build());
mPrintJobs.add(printJob);
}
The above is just puedo code, end of the day it's JavaScript nothing super special.
I am creating an AppleScript where I need to do something to the selected layers on Photoshop.
How do I get the list of the selected layers on Photoshop even if the selected layers are inside groups?
I don't have code to show right now because it all starts by having the list of selected layers, sorry.
Selected layers is not a property in JavaScript's artLayer object and selected is not an property of the layer object in AppleScript either. However we can work with AM in PhotoShop and use actions and it's descriptor result to get the selected layers. Because the layers may need to swift depending on whether there is an background layer or not we first create an array with selected indices (code is based on this post) and after that we resolve the names of the layers.
tell application "Adobe Photoshop CS6"
tell document 1
set selectedLayers to paragraphs of (do javascript "
var typeDocument = stringIDToTypeID('document');
var typeItemIndex = stringIDToTypeID('itemIndex');
var typeLayer = stringIDToTypeID('layer');
var typeName = stringIDToTypeID('name');
var typeOrdinal = stringIDToTypeID('ordinal');
var typeProperty = stringIDToTypeID('property');
var typeTarget = stringIDToTypeID('targetEnum');
var typeTargetLayers = stringIDToTypeID('targetLayers');
var selectedLayers = new Array();
var actionRef = new ActionReference();
actionRef.putEnumerated(typeDocument, typeOrdinal, typeTarget);
var actionDesc = executeActionGet(actionRef);
if(actionDesc.hasKey(typeTargetLayers) ){
actionDesc = actionDesc.getList(typeTargetLayers);
var c = actionDesc.count
for(var i=0;i<c;i++){
try{
activeDocument.backgroundLayer;
selectedLayers.push(actionDesc.getReference( i ).getIndex() );
}catch(e){
selectedLayers.push(actionDesc.getReference( i ).getIndex()+1 );
}
}
}else{
var actionRef = new ActionReference();
actionRef.putProperty(typeProperty , typeItemIndex);
actionRef.putEnumerated(typeLayer, typeOrdinal, typeTarget);
try{
activeDocument.backgroundLayer;
selectedLayers.push( executeActionGet(actionRef).getInteger(typeItemIndex)-1);
}catch(e){
selectedLayers.push( executeActionGet(actionRef).getInteger(typeItemIndex));
}
}
var selectedLayerNames = new Array();
for (var a in selectedLayers){
var ref = new ActionReference();
ref.putIndex(typeLayer, Number(selectedLayers[a]) );
var layerName = executeActionGet(ref).getString(typeName);
selectedLayerNames.push(layerName);
}
selectedLayerNames.join('\\n');
")
end tell
end tell
Building a document generation system for our web app and am branding the document as required. The document is designed in powerpoint and printed to via NitroPdf. The first page is a large image essentially, with a white area in the image.
I am attempting to place the branding logo in the whitespace allocated. Positioning is ok, however, my branding image is appearing behind the PDF'd document full page image.
Having googled, i can't seem to find a 'z-index' type function... would have thought i wouldn't be the only one with the issue?
Section of code adding the image is as follows:
image.ScaleToFit(width, height);
image.SetDpi(300, 300);
// Position the logo.
image.SetAbsolutePosition(fromLeft, fromBottom);
// Add the image.
document.Add(image);
It is very strange that you would need the following line to add an image to an existing PDF:
document.Add(image);
It's as if you're using PdfWriter instead of PdfStamper, which would be very strange.
Perhaps you overlooked the documentation or maybe you didn't search StackOverflow before you started writing your code: How can I insert an image with iTextSharp in an existing PDF?
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
class Program
{
static void Main(string[] args)
{
using (Stream inputPdfStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read, FileShare.Read))
using (Stream inputImageStream = new FileStream("some_image.jpg", FileMode.Open, FileAccess.Read, FileShare.Read))
using (Stream outputPdfStream = new FileStream("result.pdf", FileMode.Create, FileAccess.Write, FileShare.None))
{
var reader = new PdfReader(inputPdfStream);
var stamper = new PdfStamper(reader, outputPdfStream);
var pdfContentByte = stamper.GetOverContent(1);
Image image = Image.GetInstance(inputImageStream);
image.SetAbsolutePosition(100, 100);
pdfContentByte.AddImage(image);
stamper.Close();
}
}
}
You may have found examples where GetUnderContent() is used. This adds content under the existing content. If you want the content to cover the existing content, you need GetOverContent() as is shown in the code sample.
Maybe it's a bit late, but I've faced with the same issue and I've solved with a workaround with Paragraphs (hereunder the code in Visual Basic):
Public Class PDF
Public Doc As Document
Public Writer As PdfWriter
Public Cb As PdfContentByte
Public Sub setFrontImage(ByVal _appendImg As String, align As Integer, x As Integer, y As Integer, ByVal w As Integer, h As Integer, _leading As Integer)
Dim ct As New ColumnText(Cb)
Dim ph As Phrase
Dim ch As Chunk
Dim p As Paragraph = new Paragraph()
Dim image As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(_appendImg)
image.ScaleAbsolute(w, h)
p.Add(new Chunk(image,x,y))
ct.SetSimpleColumn(p,x, y, w, h, _leading, align)
ct.Go()
End Sub
End Class
I saw you used the absolute position to put your logo up your image so am I, consider to modify the usage of Chunk with width and height if you don't need to fit it inside a restricted space.
Okay so I'm using the below code to display the camera in my app and it works great! the problem is when i navigate away and come back to the app using the back stack the camera is not showing until i call the code manually.
how can i get it to show automatically ?
Thank Youuu in advance
Dim cam As New Microsoft.Devices.PhotoCamera()
Public Sub New()
InitializeComponent()
SupportedOrientations = SupportedPageOrientation.Portrait
End Sub
Private Sub opening() Handles Me.Loaded
cam = New Microsoft.Devices.PhotoCamera()
viewfinderBrush.RelativeTransform = New CompositeTransform() With {.CenterX = 0.5, .CenterY = 0.5, .Rotation = 90}
viewfinderBrush.SetSource(cam)
End Sub
Private Sub Closing() Handles Me.Unloaded
cam.Dispose()
End Sub
Fixed my Own Problem, just used protected overide subs :)
Like So
Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs)
MyBase.OnNavigatedTo(e)
cam = New Microsoft.Devices.PhotoCamera()
viewfinderBrush.RelativeTransform = New CompositeTransform() With {.CenterX = 0.5, .CenterY = 0.5, .Rotation = 90}
viewfinderBrush.SetSource(cam)
End Sub
Protected Overrides Sub OnNavigatedFrom(e As NavigationEventArgs)
MyBase.OnNavigatedFrom(e)
If cam IsNot Nothing Then
cam.Dispose()
cam = Nothing
End If
End Sub
I am building a customer ajaxhelper extension in order to create an Ajax.ActionImage(...) method (see code below).
What I don't know how to do is "merge" the AjaxOptions into my anchor href attribute. I could use ajax.ActionLink(...) but then I don't know how t build my image element inside the created MvcHtmlString.
Thanks in advance!
<Extension()> _
Public Function ActionImage(ByVal ajax As AjaxHelper, ByVal controller As String, ByVal action As String, ByVal routeValues As Object, ByVal AjaxOptions As Object, ByVal imagePath As String, ByVal alt As String, ByVal width As Integer, ByVal height As Integer) As MvcHtmlString
Dim url = New UrlHelper(ajax.ViewContext.RequestContext)
Dim imgHtml As String
Dim anchorHtml As String
Dim imgbuilder = New TagBuilder("img")
imgbuilder.MergeAttribute("src", url.Content(imagePath))
imgbuilder.MergeAttribute("alt", alt)
imgbuilder.MergeAttribute("width", width)
imgbuilder.MergeAttribute("height", height)
imgHtml = imgbuilder.ToString(TagRenderMode.SelfClosing)
Dim anchorBuilder = New TagBuilder("a")
anchorBuilder.MergeAttribute("href", url.Action(action, controller, routeValues))
anchorBuilder.InnerHtml = imgHtml
anchorHtml = anchorBuilder.ToString(TagRenderMode.Normal)
Return MvcHtmlString.Create(anchorHtml)
End Function
First, you need to change the type of the variable ajaxOptions to AjaxOptions (in the System.Web.Ajax namespace). Once you have done this, you can add the following to merge your ajaxOptions into your anchor tag:
If ajaxHelper.ViewContext.UnobtrusiveJavaScriptEnabled Then
anchorBuilder.MergeAttributes(ajaxOptions.ToUnobtrusiveHtmlAttributes())
End If
You do not want the options inside your href. The options must be part of the anchor tag, in order to be parsed correctly by jquery.unobtrusive-ajax.js.
counsellorben