I'm trying to create an IconicTile for Windows Phone 8. I've defined with VS2012 the type of Tile Template to TemplateIconic and added a Tile Title and two images for small and medium.
If I pin my app to the start screen, I can choose between small and medium tiles like expected.
Now I want to update the IconicTile I defined in my WMAppManifest.xml. As I understand IconicTile, it needs to be updated in code and will also update the LockScreen icon and count, if I defined one. I've added a DeviceLockImageURI and this Extensions:
<Extensions>
<Extension ExtensionName="LockScreen_Notification_IconCount" ConsumerID="{111DFF24-AA15-4A96-8006-2BFF8122084F}" TaskID="_default"/>
<Extension ExtensionName="LockScreen_Notification_TextField" ConsumerID="{111DFF24-AA15-4A96-8006-2BFF8122084F}" TaskID="_default" />
</Extensions>
First question: Is this ConsumerID always the same or which ID is it?
To update the IconicTile I've defined in WMAppManifest.xml, I need to get hold of any pinned Tiles of my Application on the screen. I've read a lot of tutorials explaining how to add tiles manually from your application, but I only want to use the tile I've defined in WMAppManifest.xml. Therefore all tutorials recommended to get the current active Tile with this code:
ShellTile.ActiveTiles.FirstOrDefault();
ActiveTiles is an IEnumeration and only offers me: Equals, GetEnumerator, GetHashCode, GetType and ToString
Second question: What am I missing here? Does FirstOrDefault only work for FlipTiles or CycleTiles? I only want to use the IconicTile!
So I'm stuck at identifying the current active IconicTile on the screen, so that I can use an IconicTileData object to update the count or text of the IconicTile. What am I missing here?
For the first question:
I've seen a Tile ID when you create an IconicTile from Xml:
<wp:Tile Id="[Tile ID]" Template="IconicTile">
Maybe it is this ID? Otherwise I'll go with allways the same static ID, as there is no documentation on how to create this ID.
For the second question:
I've found the error: I was missing
using System.Linq;
This using enables access to the Linq Methods necessary to use FirstOrDefault or similar commands. I was mislead by
using System.Xml.Linq;
which is definitevly not the same Linq class ;)
Related
I've got a customised instance of GraphEditor in a view in an ASP.NET MVC app and I've got it set to use a database for diagram persistence. When opening, I've programmed it to create a new model to initialise the graph using the model data stored in the database. This works, except that vertexes and edges that were black and white when saved become blue when loaded. I'm guessing there's some default mxGraph style variable that's responsible for this, but I'm not sure. Anyone have any ideas? Thanks!
So, in case it's useful to anyone else, I actually found the solution. The default colours are defined in mxClient as hexadecimals and can be replaced with whatever you want to use.
I'm currently testing the downloadcache and this really looks great.
I have some questions regarding this plugin (I'm pretty new to C# and don't understand the full source code of the plugin):
1) ProgressView
I would like to show a progressview on the image until it has been loaded.
To do that, I need to be notified when the image is loaded.
In the "MvxImageViewLoader" I see there is an Action "afterImageChangeAction" (null by default).
However, I don't understand if and how I can access that Action from "MvxImageView"?
(how to set it)
2) Don't load old image
When using Tables or Cellectionviews in iOS, it's important to check if the URL has been changed before setting the image (because iOS reuses the objects). I looked at the source code of the downloadcache and I don't see this check.
However, in the "MvxDynamicImageHelper.cs" class, I see that when a new URL is set, it calls "ClearCurrentHttpImageRequest();" which removes the "update" Events.
So I assume this is enough to prevent that an image is set to the wrong UIImageView?
3) ImageCache size in (mega)bytes
The ImageCache does not have a property to define the mamiximum size (megabytes for example) of the persistent image store (on the HD). I prefer to use a maximum size in (mega)bytes instead of a maximum amount of files because the user will care more how much space an app takes instead of how many files are stored by the app.
I assume the easiest for me is to define a "TimeSpan PeriodSaveInterval" independent from the one in MvxFileDownloadCache to just check the size of the folder defined for the Image Cache or any other recommendations?
Is it dangerous for performance to scan the folder and calculate the size of all the images in a folder?
Regards,
Matt
1) ProgressView
I would like to show a progressview on the image until it has been loaded. To do that, I need to be notified when the image is loaded.
There is a DefaultImagePath which provides the path of an image that should be shown during loading.
But if you need a dynamic animation or other custom view, then afterImageChangeAction can be used
As you've seen, you can't do this in MvxImageView - the Action wasn't really a suitable candidate to be a bindable property so it wasn't exposed as a property.
However, you can:
do this by using MvxImageViewLoader directly in your View - there are several samples of using this in views in the N+1 samples - https://github.com/slodge/NPlus1DaysOfMvvmCross/search?q=MvxImageViewLoader
do this by creating your own MyImageView class - it's not a big class to write - https://github.com/slodge/MvvmCross/blob/v3/Cirrious/Cirrious.MvvmCross.Binding.Touch/Views/MvxImageView.cs
As an alternative to using the Action callback, you can also inherit from MvxBaseImageViewLoader<T> and provide an override for the ImageHelperOnImageChanged method - see https://github.com/slodge/MvvmCross/blob/v3/Cirrious/Cirrious.MvvmCross.Binding/Views/MvxBaseImageViewLoader.cs#L49
2) Don't load old image
3) ImageCache size in (mega)bytes
The interface-driven and plugin structure of MvvmCross is defined to allow you to implement alternatives.
In the case of loading images from HTTP, there are many alternatives - you don't have to use the MvvmCross download cache for image loading.
The only docs available for the download cache plugin currently is https://github.com/slodge/MvvmCross/wiki/MvvmCross-plugins#downloadcache
For Android, some suggestions for alternative implementations are listed in: https://github.com/slodge/MvvmCross/issues/416
For iOS, it may be useful to read https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html including the section on <Application_Home>/Library/Caches
I know Stuart already provided an excellent answer. But what I did, when I needed the exact same feature, was to subclass MvxImageView and override the UIImageView.Image property. When the image is set I fire an event which is caught by the viewcontroller.
I'm just getting into my first project with (the unbelieveably excellent) MVVMCross and I can't figure out how to do something that seems fairly basic: composite views.
Suppose I've got a Person (FirstName, LastName, etc), and a person has an Address (Street, City, PostalCode, etc.). So I'll also have a PersonViewModel and an AddressViewModel.
This is a strictly tablet based app (iPad only, actually) and I want to use containment to have the PersonView contain the (reusable) AddressView, such that the outer (person) view binds to Person, while the inner (address) view binds to Person.Address.
I (dimly) understand the presenter concept for showing the views, as discussed here, but I can't see how to handle the propagation of changes from Person to Address and back.
Suppose the Person object has an Address object, but the PersonViewModel shows the AddressViewModel in an AddressView by passing some sort of Address id and rehydrating. Then the AddressView is binding to a different Address object than the one the Person contains. I don't see how to keep the two in sync, which of course would defeat the whole purpose of binding.
How should I do what I'm trying to do?
This is a really wide topic...
...and there are lots of possible answers.
I think it's important to consider ViewModel's as a very simple concept - I'd like to encourage you to think of ViewModels just as being models for views - definitely don't think of them as 'whole page' objects.
....
Within MvvmCross, you can use ShowViewModel and custom presenters to change the UI if you want to - and this is demonstrated in several MvvmCross examples including the split view presenter - http://slodge.blogspot.com/2013/05/n24-splitviewpresenter-n1-days-of.html
This ShowViewModel technique is really useful for navigation - for changing the whole page or for significant portions of it.
However, you don't have to use navigation paradigms if your app doesn't need them.
If you want to, then you can instead:
build your own hierarchies of viewmodels within the core
and you can then build your own databound hierarchies of views within the UIs
It's entirely up to you - your app is king.
....
I feel like I'm not explaining this very well...
....
So I gave up and recorded this video - maybe it helps: http://slodge.blogspot.co.uk/2013/06/n32-truth-about-viewmodels-starring.html
The video and sample code only covers the iPad, but I hope it's easy(ish) to see how you would extend it to other platforms:
for Windows you can use UserControl
for Android you can use MvxFrameControl, custom view or Fragment code.
There's a plugin that allows Control navigation in addition to the default Views navigation, hope it helps: https://github.com/ChristianRuiz/MvvmCross-ControlsNavigation
Please check out this implementation of a custom presenter for MvvmCross projects. To support Fragments in android and also multiple fragments into one other fragment/activity:
https://github.com/JelleDamen/CustomMvxAndroidPresenter
i need to clone a FrameworkELement in my CodeBehind in WinRT...
I did found a solution in the internet, though this workaround doesn't work in WinRT because the XamlWriter is NOT available in winRT! Is there an easy/built-in way to get an exact copy (clone) of a XAML element?
is there any other way to get another instance of my FrameworkElement?
I don't think there is an easy way to clone an element exactly - I don't know for example if there is a way to figure out the arbitrary attached properties set on one or figure out if properties are set by style, animation, template, explicit value etc.
There is one way that would possibly be a solution for your scenario if you have a specific element tree you want cloned - simply put it in a DataTemplate in XAML and then retrieve that template by name or resource key in code behind and call LoadContent() to generate an instance from the template.
If you have your original one in your XAML already that you don't want to put in resources and generate or lay out from code behind again - simply wrap it inside ContentControl/ContentTemplate/DataTemplate.
I have a flash assignment that I need help getting started, any advice would be greatly appreciated. The assignment is to create an application for playing a card game, I have to create an MXML component that has two variables, one variable stores the image of the back of a playing card, the other variable has t store all 52 options of a front facing card (the second variable will store over 50 images).
I've written the variable for the back of the card image like this:
public var backOfCard:Image = new Image();
backofCard.source = 'asset/backImage';
However I get an undefined variable error (1120: Access of undefined propery variable img1), I feel like there's something small that I'm missing here, but I was wondering if anyone could spot it.
I'd also like to know if I should use the same method for each jpg image for the front of the cards, it seems like it would be a lot of repetitive code aside from the change in filename for the front of the card images.
Here's a snippet of the homework assignment, again I just need help getting this part correct, I really appreciate any help with this.
Your job is to supply the custom component named Card. Create the
component by using File → New → MXML Component. In the popup dialog
box
leave the Package blank
Name the component Card
Base Card on spark.components.Image
What goes into the Card component?
For each card, we'll want to be able to show the front face of the
card, or its back face. That means each card should have a place to
store information about what file to show as its front face, and what
file to show as its back face.
To do this, create two variables in the Card component to store the
file names. You might call these variables backImage and frontImage.
Your access modifier is what's bothering me.
If you're creating these definitions in your class file, then the first statement works:
public var backOfCard:Image = new Image();
But if you're in one of the methods, usually the constructor (sometimes called the ctor), or any other method of the application, you could use the 2nd statement:
backofCard.source = 'asset/backImage';
But the combination of both is what I think is confusing. Because the "access modifier" (i.e. public, private, internal, protected) is what you use to define variables and methods within a class. And since you're putting both side-by-side (a definition and an assignment statement), I think you're mixing when to declare them.