whereshould i put this code for creating a tile - windows-phone-7

i want to set secondry tile in my app but i don't know where i put code of secondry tile because it show unhandled exception and my App does not run it back
var foundTile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("DetailId=123"));
if (foundTile == null)
{
var secondaryTile = new StandardTileData
{
BackgroundImage = new Uri("Images/SecondaryTileFrontIcon.jpg", UriKind.Relative),
Title = "hiiiiiiii",
Count = null,
BackTitle = "",
BackContent = "byeeeee ",
BackBackgroundImage = new Uri("Images/ApplicationTileIcon.jpg", UriKind.Relative)
};
ShellTile.Create(new Uri("/Views/DetailsPage.xaml?DetailId=123", UriKind.Relative), secondaryTile);
}

Each tile is identified by the Uri supplied to ShellTile.Create. In your case, you're not creating a secondary tile, but checking if the same tile already exists, and if it's not, then you create it.
If you want more than one tile, you need to use different uri's for the ShellTile.Create call, typically with different query-string parameters/values.
And you obviously shouldn't make it dependant on the uri of completely unrelated tile.

Related

AVCapturePhotoSettings not accepting accept NSDictionary element

not sure what I am doing wrong, I wanna create a simple custom camera, I'm creating the AVCapturePhotoOutput attaching it to AVCaptureSession, then creating AVCapturePhotoSettings with minimum settings to make taking a picture work, see code below.
I get exception kCVPixelBufferPixelFormatTypeKey is not being define but it is indeed in the NSDictionary I am passing.
I need some light here, thanks
public void TakePicture()
{
var output = new AVCapturePhotoOutput();
_captureSession.AddOutput(output);
var settings = AVCapturePhotoSettings.Create();
var previewPixelType = settings.AvailablePreviewPhotoPixelFormatTypes.First();
var keys = new[]
{
new NSString("kCVPixelBufferPixelFormatTypeKey"),
new NSString("kCVPixelBufferWidthKey"),
new NSString("kCVPixelBufferHeightKey"),
};
var objects = new NSObject[]
{
// don't have to be strings... can be any NSObject.
previewPixelType,
new NSString("160"),
new NSString("160")
};
var dicionary = new NSDictionary<NSString, NSObject>(keys, objects);
settings.PreviewPhotoFormat = dicionary;
output.CapturePhoto(settings,this);
}
It is because kCVPixelBufferPixelFormatTypeKey is not available in Xamarin.
We should use CVPixelBuffer.PixelFormatTypeKey here . It will be convert to kCVPixelBufferPixelFormatTypeKey automatically when compiling.
The same reason for kCVPixelBufferWidthKey and kCVPixelBufferHeightKey , the api is CVPixelBuffer.WidthKey and CVPixelBuffer.HeightKey in Xamarin.iOS.

Applescript: Getting list of selected layers on Photoshop

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

nokia Imaging SDK customize BlendFilter

I have created this code
Uri _blendImageUri = new Uri(#"Assets/1.png", UriKind.Relative);
var _blendImageProvider = new StreamImageSource((System.Windows.Application.GetResourceStream(_blendImageUri).Stream));
var bf = new BlendFilter(_blendImageProvider);
Filter work nice. But I want change image size for ForegroundSource property. How can I load image with my size?
If I understood you correctly you are trying to blend ForegroundSource with only a part of the original image? That is called local blending at it is currently not supported on the BlendFilter itself.
You can however use ReframingFilter to reframe the ForegroundSource and then blend it. Your chain will look like something like this:
using (var mainImage = new StreamImageSource(...))
using (var filterEffect = new FilterEffect(mainImage))
{
using (var secondaryImage = new StreamImageSource(...))
using (var secondaryFilterEffect = new FilterEffect(secondaryImage))
using (var reframing = new ReframingFilter(new Rect(0, 0, 500, 500), 0)) //reframe your image, thus "setting" the location and size of the content when blending
{
secondaryFilterEffect.Filters = new [] { reframing };
using (var blendFilter = new BlendFilter(secondaryFilterEffect)
using (var renderer = new JpegRenderer(filterEffect))
{
filterEffect.Filters = new [] { blendFilter };
await renderer.RenderAsync();
}
}
}
As you can see, you can use the reframing filter to position the content of your ForegroundSource so that it will only blend locally. Note that when reframeing you can set the borders outside of the image location (for example new Rect(-100, -100, 500, 500)) and the areas outside of the image will appear as black transparent areas - exactly what you need in BlendFilter.

Change tile navigation after tile update on Windows Phone

I'm sending a tile update to my app users. After the tile update I would like to automatically direct the user to the new updated page once he clicks the new tile. Is there any way I can achieve this?
I can't pull the server anymore because it's a fire & forget mechanism.
With toast notifications I can use the following message in my notification:
<wp:Param>/Views/MyPage.xaml</wp:Param>
But that doesn't seem to work with my FlipTile update.
Im not quite sure if this is what you are looking for, but can you just replace the Tile once the app is loaded? Somewhat like this:
/// <summary>
/// Creates or replaces a tile with a Title and a parameter
/// </summary>
public void replaceTile()
{
//ShellTile TileToFind = ShellTile.ActiveTiles.First();
string tileTitle = "Title of the Tile";
//You might want to use your Parameter from the toast here as the PageName
ShellTile TileToFind = FindTile( "/PageName.xaml?parameter" );
StandardTileData NewTileData = new StandardTileData
{
Title = tileTitle,
BackgroundImage = new Uri( "/Resources/tile_icon.png", UriKind.Relative ),
Count = 0,
BackTitle = "",
//BackBackgroundImage = new Uri("/Resources/appicon_large.png", UriKind.Relative),
BackBackgroundImage = new Uri( "", UriKind.Relative ),
BackContent = ""
};
// Application should always be found, since it is always the first tile (even if not on homescreen)
if ( TileToFind == null )
{
// Update the Application Tile with the NewTileData
//TileToFind.Update( NewTileData );
//Or replace an existing (second) tile with the new, updated Tile
//ShellTile alreadyExistingTile = FindTile( "/PageName.xaml?parameter" );
//if ( alreadyExistingTile != null )
//{
// alreadyExistingTile.Delete();
//}
ShellTile.Create( new Uri( "/PageName.xaml?parameter=" + newParameter, UriKind.Relative ), NewTileData );
}
else
{
TileToFind.Update( NewTileData );
}}

Can I update a live tile in Mango using local data?

I have a Mango WP7.5 app that uses a local SqlCe database. I would like to add a LiveTile update that shows info taken from the local DB based on current day and month.
All the samples that I've found update the background by downloading remote images from servers but I would simply need to make a local database query and show a string in my tile.
Can I do it? How?
Yes, you can. You have to
generate an image containing your textual information
save this image to isolated storage and
access it via isostore URI.
Here is code showing how to do this (it updates the Application Tile):
// set properties of the Application Tile
private void button1_Click(object sender, RoutedEventArgs e)
{
// Application Tile is always the first Tile, even if it is not pinned to Start
ShellTile TileToFind = ShellTile.ActiveTiles.First();
// Application Tile should always be found
if (TileToFind != null)
{
// create bitmap to write text to
WriteableBitmap wbmp = new WriteableBitmap(173, 173);
TextBlock text = new TextBlock() { FontSize = (double)Resources["PhoneFontSizeExtraLarge"], Foreground = new SolidColorBrush(Colors.White) };
// your text from database goes here:
text.Text = "Hello\nWorld";
wbmp.Render(text, new TranslateTransform() { Y = 20 });
wbmp.Invalidate();
// save image to isolated storage
using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
{
// use of "/Shared/ShellContent/" folder is mandatory!
using (IsolatedStorageFileStream imageStream = new IsolatedStorageFileStream("/Shared/ShellContent/MyImage.jpg", System.IO.FileMode.Create, isf))
{
wbmp.SaveJpeg(imageStream, wbmp.PixelWidth, wbmp.PixelHeight, 0, 100);
}
}
StandardTileData NewTileData = new StandardTileData
{
Title = "Title",
// reference saved image via isostore URI
BackgroundImage = new Uri("isostore:/Shared/ShellContent/MyImage.jpg", UriKind.Absolute),
};
// update the Application Tile
TileToFind.Update(NewTileData);
}
}

Resources