I have an application with pinned secondary live tiles, they are showing days on the back of the tile and I would like to reduce the number of days each day. Now the problem is, that I don't want to change the other properties of the tile (so Title, Images, etc), only the content (a string) on the back: FlipTileData.BackContent
So I don't want to create new FlipTileData to pass that as a parameter for the Update method.
Second problem: How do I even know which tile is what I'm about to update?
I've tried this:
foreach (ShellTile tile in ShellTile.ActiveTiles) but tile has no attribute that gives me a help. Should I use NavigationUri to find out which tile is that?
Follow this example Working with Live Tiles in Windows Phone 7 and it should solve your problems.
Notice the x.NavigationUri.ToString().**Contains("Title=SecondaryTile")** on the code.
EDIT:
Combining a few lines of code from that website:
// modify Application Secondary Tile data
private void updateTile_Click(object sender, RoutedEventArgs e)
{
// get application specific tile - EXAMPLE
ShellTile Tile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("Title=SecondaryTileEXAMPLE_TITLE"));
if (null != tile)
{
// create a new data for tile
StandardTileData data = new StandardTileData();
// tile foreground data
data.Title = "Title text here";
data.BackgroundImage = new Uri("/Images/Blue.jpg", UriKind.Relative);
data.Count = random.Next(99);
// to make tile flip add data to background also
data.BackTitle = "Secret text here";
data.BackBackgroundImage = new Uri("/Images/Green.jpg", UriKind.Relative);
data.BackContent = "Back Content Text here...";
// update tile
tile.Update(data);
}
}
Related
I'm trying to display an overlay during an auto login HTTP call.
I've found this code, which seems outdated somehow, but found nothing more recent.
Anyway, the Overlay is showing but not covering the whole screen as expected.
The calling code is this:
AppDelegate.FinishedLaunching
var avc = new AutoLoginViewController();
var navController = new UINavigationController(avc);
AutoLoginViewController.ViewDidLoad
var bounds = UIScreen.MainScreen.Bounds;
// show the loading overlay on the UI thread using the correct orientation sizing
loadPop = new LoadingOverlay(bounds, NSBundle.MainBundle.GetLocalizedString("connecting"));
View.Add(loadPop);
But the result is the following:
If I set a breakpoint in the LoadingOverlay constructor, I can see that the screen bounds (iPhone 6) are fine:
{{X=0,Y=0,Width=375,Height=667}}
public class LoadingOverlay : UIView
{
public LoadingOverlay(CGRect frame, string text) : base(frame)
{
// configurable bits
BackgroundColor = UIColor.Black;
Alpha = 0.75f;
AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
...
}
}
Clearly the UIView width is incorrect.
Because we're in 2020, maybe there is another way.
Any help appreciated.
EDIT: The app breaks on iPhone 8 iOS 13.3 simulator, So I can't say if this is tied to a particular screen size (1x in my case).
Cause :
It seems that you didn't set the LaunchImage , So whether on a simulator or real device , the value of bounds is a static value .
Solution:
The easiest way is set the size of overlay as bounds of View .
var bounds = View.Bounds;
Or you could set all size of LaunchImage of different screen .
Does anybody know of any ways to use an image as a mask for another image in UWP, the only masking function I can see is CompositionMaskBrush which I don't believe can achieve what I want.
An example of what I'm looking to achieve is the following.
I have a solid black PNG in the shape of a mobile phone case, the user adds their own image which is then clipped and masked to the dimensions of the solid black PNG - Resulting in the image below.
Any help whatsoever would be greatly appreciated. I've spent quite a while browsing for a solution.
Example Image Here
Just posting for anybody else who needs and answer to this, but I finally managed to find a solution using Win2D and an Imageloader.
Here is a link to the ImageLoader. Note that I had to roll back a few versions in order make it work how the documentation states. The link below is to the version that I'm using. Anything later than this version will not work with the sample code I'm going to post.
https://www.nuget.org/packages/Robmikh.Util.CompositionImageLoader/0.4.0-alpha
private Compositor _compositor;
private IImageLoader _imageLoader;
private CompositionEffectFactory _effectFactory;
private async void InitMask()
{
// Store our Compositor and create our ImageLoader.
_compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;
_imageLoader = ImageLoaderFactory.CreateImageLoader(_compositor);
// Setup our effect definition. First is the CompositeEffect that will take
// our sources and produce the intersection of the images (because we selected
// the DestinationIn mode for the effect). Next we take our CompositeEffect
// and make it the source of our next effect, the InvertEffect. This will take
// the intersection image and invert the colors. Finally we take that combined
// effect and put it through a HueRotationEffect, were we can adjust the colors
// using the Angle property (which we will animate below).
IGraphicsEffect graphicsEffect = new HueRotationEffect
{
Name = "hueEffect",
Angle = 0.0f,
Source = new InvertEffect
{
Source = new CompositeEffect
{
Mode = CanvasComposite.DestinationIn,
Sources =
{
new CompositionEffectSourceParameter("image"),
new CompositionEffectSourceParameter("mask")
}
}
}
};
// Create our effect factory using the effect definition and mark the Angle
// property as adjustable/animatable.
_effectFactory = _compositor.CreateEffectFactory(graphicsEffect, new string[] { "hueEffect.Angle" });
// Create MangedSurfaces for both our base image and the mask we'll be using.
// The mask is a transparent image with a white circle in the middle. This is
// important since the CompositeEffect will use just the circle for the
// intersectionsince the rest is transparent.
var managedImageSurface = await _imageLoader.CreateManagedSurfaceFromUriAsync(new Uri("http://sendus.pics/uploads/" + ImagePass + "/0.png", UriKind.Absolute));
//var managedImageSurface = await _imageLoader.CreateManagedSurfaceFromUriAsync(new Uri("ms-appx:///Assets/colour.jpg", UriKind.Absolute));
var managedMaskSurface = await _imageLoader.CreateManagedSurfaceFromUriAsync(new Uri("ms-appx:///" + MaskImage, UriKind.Absolute));
// Create brushes from our surfaces.
var imageBrush = _compositor.CreateSurfaceBrush(managedImageSurface.Surface);
var maskBrush = _compositor.CreateSurfaceBrush(managedMaskSurface.Surface);
// Create an setup our effect brush.Assign both the base image and mask image
// brushes as source parameters in the effect (with the same names we used in
// the effect definition). If we wanted, we could create many effect brushes
// and use different images in all of them.
var effectBrush = _effectFactory.CreateBrush();
effectBrush.SetSourceParameter("image", imageBrush);
effectBrush.SetSourceParameter("mask", maskBrush);
// All that's left is to create a visual, assign the effect brush to the Brush
// property, and attach it into the tree...
var visual = _compositor.CreateSpriteVisual();
visual.Size = new Vector2(MaskH, MaskW);
visual.Offset = new Vector3(0, 300, 0);
visual.Brush = effectBrush;
ElementCompositionPreview.SetElementChildVisual(this, visual);
}
I need to update data on several secondary tiles in a windows phone 8 application. I am using a BackGround Agent to update the tiles.
IconicTileData tileData = new IconicTileData
{
IconImage = new Uri("ApplicationIcon.png", UriKind.RelativeOrAbsolute),
Title = "My Tile title",
Count = new Random().Next(1, 10),
};
ShellTile mainTile = ShellTile.ActiveTiles.FirstOrDefault();
if (mainTile != null)
{
mainTile.Update(tileData);
}
// If debugging is enabled, launch the agent again in one minute.
#if DEBUG_AGENT
ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(60));
#endif
Here it is to update the mainTile data. But how can I find how many secondary tiles are pinned and how to update them individually?
Frok the MSDN documentation for ShellTile.ActiveTiles: This list includes an Application Tile, which cannot be deleted, and all of its Secondary Tiles. The Application Tile is always the first in the collection.
So:
foreach (var tile in ShellTile.ActiveTiles)
{
//update the tile
}
As you know each tile has some Navigation URI.You can search for unique word in the query string of Navigation URI.
ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("unique key/value in querystring"));
In this way you can identify all secondary tiles by iterating through them and checking the Navigation URI.
I'm trying to extract a specific frame from a video file. I have a frame that I want when I play a video file with the aforge library. I call a new frame event, and if the new frame matches my specific frame, then it shows me a message: "Frame Match". This specific frame randomly appears in a video file. Here is my code:
private void Form1_Load(object sender, EventArgs e)
{
IVideoSource videoSource = new FileVideoSource(#"e:\media\test\a.mkv");
playerControl.VideoSource = videoSource;
playerControl.Start( );
videoSource.NewFrame += new AForge.Video.NewFrameEventHandler(Video_NewFrame );
}
private void Video_NewFrame(object sender, AForge.Video.NewFrameEventArgs eventArgs)
{
//Create Bitmap from frame
Bitmap FrameData = new Bitmap(eventArgs.Frame);
//Add to PictureBox
pictureBox1.Image = FrameData;
//compare current frame to specific fram
if (pictureBox1.Image == pictureBox2.Image)
{
MessageBox.Show("Frame Match");
}
}
pictureBox2.image is a fixed frame that I want to match. This code is working fine when I play video files and extract new frames, but I am unable to compare new frames to specific frames. Please guide me on how to achieve this.
You can take a look at:
https://github.com/dajuric/accord-net-extensions
var capture = new FileCapture(#"C:\Users\Public\Videos\Sample Videos\Wildlife.wmv");
capture.Open();
capture.Seek(<yourFrameIndex>, SeekOrigin.Begin);
var image = capture.ReadAs<Bgr, byte>();
or you can use standard IEnumerable like:
var capture = new FileCapture(#"C:\Users\Public\Videos\Sample Videos\Wildlife.wmv");
capture.Open();
var image = capture.ElementAt(<yourFrameIndex>); //will actually just cast image
Examples are included.
moved to: https://github.com/dajuric/dot-imaging
As far as I can understand your problem the issue is that you can't compare image to image this way. I think you will find that the way to do this is to build a histogram table and then compare image histograms.
Some of the related things to look into are:
how to compare two images
image comparer class form VS 2015 unit testing
The second one is from unit testing library so not sure of performance (haven't tried myself yet)
I have a Windows Phone 8 supporting Live Tiles (the default medium and small). I update the Live Tile using a fairly standard code
var tile = ShellTile.ActiveTiles.First();
if (tile == null) return;
var data = new StandardTileData {Title = "some title"};
data.BackgroundImage = new Uri("/Background.png", UriKind.Relative);
data.Count = count;
tile.Update(data);
I want to add support for the Large tile but I want to to be different. I do not want to use the count and I want to render some custom text to the images:
var data = new StandardTileData {Title = "some title"};
data.BackgroundImage = new Uri("path to a custom rendered image", UriKind.Relative);
data.Count = 0;
My question is, how do I determine if my Live tile is Medium (small) or Large make the appropriate update? Or how do I set the tile update to be entirely different for Medium (small) and Large tile?
StandardTileData is the WP7 specific format for tile data. It's WP8 equivalent is
FlipTileData which includes separate properties for the different tile sizes:
FlipTileData TileData = new FlipTileData()
{
Title = "[title]",
BackTitle = "[back of Tile title]",
BackContent = "[back of medium Tile size content]",
WideBackContent = "[back of wide Tile size content]",
Count = [count],
SmallBackgroundImage = [small Tile size URI],
BackgroundImage = [front of medium Tile size URI],
BackBackgroundImage = [back of medium Tile size URI],
WideBackgroundImage = [front of wide Tile size URI],
WideBackBackgroundImage = [back of wide Tile size URI],
};
See also the WP8 specific docs for tiles. http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202948(v=vs.105).aspx