How can I use my own application bar with tilt effec? - c#

For my Windows Phone 8 application, I'm implementing my own application bar (I can't use the application bar provided by the system). Everything is working fine, but I have one big problem: the tilt effect for menu items!
I've tried to used the tilt effect provided by the WP toolkit, but it doesn't look like the original one. So how can I use the exact tilt effect by the system application bar in my own application bar ?
Thanks.

because your own app bar is not Tiltable Item.
you can get the TiltEffect.cs file from this link:
http://code.msdn.microsoft.com/wpapps/Tilt-Effect-Sample-fab3b035
and then you should add your own app bar to the TiltableItems in TiltEffect's Constructor, some like this:
static TiltEffect()
{
// The tiltable items list.
TiltableItems = new List<Type>() { typeof(ButtonBase), typeof(ListBoxItem), };
TiltableItems.Add(typeof(Border));
TiltableItems.Add(typeof(TiltEffectAbleControl));
UseLogarithmicEase = false;
}

Related

Icons in FreshTabbedNavigationContainer tabs bar are giant in IOS

I am trying to show 4 icons for 4 tabs in the bar of my FreshTabbedNavigationContainer using FreshMVVM and Xamarin.Forms of course, they look as they should when I execute the app on an Android emulator, but when I use my Mac and emulate the app on an IOS emulator, these icons become gargantuan, just as you see in this picture.
Here is my code:
FreshTabbedNavigationContainer Code:
private static FreshTabbedNavigationContainer TabbedPageContainer = null;
TabbedPageContainer = new FreshTabbedNavigationContainer(navigation.ToString());
Products = TabbedPageContainer.AddTab<HomeViewModel>(null, "IconHomeInverted.ico", null);
Discover = TabbedPageContainer.AddTab<HomeViewModel>(null, "IconMagnifyingGlassInverted.ico", null);
Account = TabbedPageContainer.AddTab<HomeViewModel>(null, "IconUserInverted.ico", null);
Settings = TabbedPageContainer.AddTab<HomeViewModel>(null, "IconSettingsInverted.ico", null);
#region UI
//Dissables swipe only in android because in IOS can not be done
TabbedPageContainer.On<Xamarin.Forms.PlatformConfiguration.Android>().SetIsSwipePagingEnabled(false);
TabbedPageContainer.BarTextColor = Color.FromHex("#FFFFFF");
#endregion
page.CoreMethods.SwitchOutRootNavigation(navigation.ToString());
My icons are located in "MyProject.IOS", they are not in the resources folder or anything like that.
That is all, if you need more information I will provide it as soon as I see your request. I hope all of you have a great day.
Ok, I solved it, my icons were 500x500 aprox, on Windows, visual studio or fresh MVVM resize the image to fill the tabbed bars; this does not happen on Mac, so they were showing their actual size, I resized them to 38x38 and now they look like what I was looking for.
The iOS "Human Interface Guidelines" have suggested sizes for the custom icons in the Navigation Bar.
These sizes go from 24px to 28px for the #1x scale factor meaning that for the other scale factors we will have something like:
24px
48px#2x
72px#3x
28px
56px#2x
84px#3x
Of course, you are capable of adjusting these numbers to keep consistency across your application.
More information about this here
Hope this helps.-

Apple TV as an external UIScreen on an iOS device

I have an app that displays video in a subview and where it would be nice to give the option to display that video on a second screen such as an Apple TV and be able to use that freed-up space to show additional controls.
I've found all sorts of help about how to do that, but I'm hitting a wall even before getting out of the starting gate.
In order to detect that the app has started up in a multiple display environment, all the sample code features a line like...
if (UIScreen.Screens.Length > 1) {
// ...
}
(I'm doing this in C#/Xamarin, though I doubt the problem is related to that; anyway, the snippets are in C#)
My problem is that the array of screens is always 1 no matter what I do. The iPad is running iOS 11.2.5, and if I turn on mirroring, the iPad is mirrored, but , again, the array of screens only has a single item.
There are also a couple of observers to detect screens being added/removed while the app is running. I haven't seen Xamarin specific code, but I presume it looks like:
NSNotificationCenter.DefaultCenter.AddObserver(this, UIScreen.DidConnectNotification, NSKeyValueObservingOptions.New, IntPtr.Zero);
NSNotificationCenter.DefaultCenter.AddObserver(this, UIScreen.DidDisconnectNotification, NSKeyValueObservingOptions.New, IntPtr.Zero);
Anyway, those never fire even if I add/remove the Apple TV or enter/exit Mirroring Mode on the iPad.
Oh; also if I do
avPlayer.AllowsExternalPlayback = true;
avPlayer.UsesExternalPlaybackWhileExternalScreenIsActive = true;
then that works as expected, too. The video now appears full-screen on the Apple TV and the UIView on the iPad containing the avPlayer greys out rather than showing the video.
However, that's not what I'm looking for. I would like to control the layout of both screens and that does neither. (While I do want the video to be full screen on the Apple TV, I don't want it to be an AVPlayerViewController and I do want to repurpose the screen real-estate taken up by the iPad video view)
At the end of the day, all I think I need is to manage to get
UIScreen.Screens.Length to be equal to 2 when I launch the app.
What's the secret of getting UIScreen to detect/report a second display?
When an app is launched with screen mirroring already enabled, the UIScreen.screens array initially only contains the device's screen. Shortly after launch, iOS posts a UIScreenDidConnect notification to advise your app that a second screen is connected.
What you will see at launch is that the captured property of your main screen is true if mirroring is enabled, however you can't actually access the second screen until after the notification is posted. Note that captured could also indicate that screen recording is in progress.
Although this seems slightly counter-intuitive it actually makes your coding a little simpler; you need to observe the UIScreenDidConnect and UIScreenDidDisconnect notifications anyway and now you don't need to write any special code to handle the case where the app is launched with a second screen already attached.
You can use something like this in your didFinishLaunching:
let nc = NotificationCenter.default
nc.addObserver(forName: NSNotification.Name.UIScreenDidConnect, object: nil, queue: nil) { (notification) in
print("Screen connected")
self.enableExternalDisplay()
}
nc.addObserver(forName: NSNotification.Name.UIScreenDidDisconnect, object: nil, queue: nil) { (notification) in
print("Screen disconnected")
self.disableExternalDisplay()
}
UPDATE
Actually, it looks like you have the key/value observing format of AddObserver in your code, when you actually want notification observing. Something like:
NSNotificationCenter.DefaultCenter.AddObserver(UIScreen.DidConnectNotification,OnScreenConnected)
And then you need to implement an OnScreenConnected method.

How to properly resize app to visible bounds on UWP? (VisibleBoundsMode doesn't seem to work)

I have two UWP apps and after testing them out with Continuum I noticed the app bar of the OS (the bar with the Start button) at the bottom of the screen (it can be at each of the 4 edges of the screen, of course) was covering part of my app.
Now, I'm already using ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseVisible) before calling Window.Current.Activate(), but that doesn't seem to solve the issue.
1) Why is it that setting the DesiredBoundsMode property doesn't seem to work here? Shouldn't that automatically resize the window
content to the visible bounds (ie. excluding system overlays like the
navigation bar or the app bar)?
The workaround I'm using for now on Windows 10 Mobile devices is to subscribe to the VisibleBoundsChanged event and then manually adjust the margins of my Window.Current.Content item to make sure it doesn't show anything behind covered areas of the screen.
Basically, I use the Window.Current.Bounds property and the ApplicationView.VisibleBounds property to calculate the occluded areas on the different edges of the app window, and increase the margins from there.
2) Is there a proper/better way to do this?
I mean, I'm quite sure there's another method that should be used to avoid this issue (considering there are tons of different situations like Continuum, navigation bar etc... that I don't think are supposed to be manually handled one by one).
Thank you for your help!
Use the subscription to the event VisibleBoundsChanged. This is the best solution that I found.
var curr = ApplicationView.GetForCurrentView();
if (curr.IsFullScreenMode == true)
{
ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.FullScreen;
curr.FullScreenSystemOverlayMode = FullScreenSystemOverlayMode.Minimal;
}
else
{
ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.Auto;
curr.FullScreenSystemOverlayMode = FullScreenSystemOverlayMode.Standard;
}

Creating a marquee lookalike in Windows Store Apps

im trying to create the equivalent of this(html)
<marquee behavior="alternate">Your bouncing text goes here</marquee>
in a Windows Store App, with C#
is there any control that can do this or do i have to create a custom one?
There are no Marquee controls in Windows Store Apps.
I have managed to find code doing something similar to what you are trying to do. Go take a look at WPF Marquee Text Animation. If you play around with that code you should be able to get the wanted result
The main difference with your Marquee is that once you reach the edge of the screen you want to go back the other way. Something as simple as getting the Width of your textblock and your grid and substracting them could give you the wanted result
One way to do it would be something like this :
Get the width difference of your controls
int TotalMargin = gridTest.Width - textblocktest.Width
You would then need to add continuously a value to your margin
if textblocktest.Margin.Left < TotalMargin {
textBlock.Margin = New Thickness(textblock.Margin.Left + aNumber,0,0,0)
}
else{
//Call a procedure doing the same thing but decrementing the margin until it is at 0 and then going back to adding margin
}

How to position progressIndicator to center in windows phone?

I am newbie to windows phone development.
I have created the progress indicator using following code .
ProgressIndicator progressIndicator = new ProgressIndicator();
progressIndicator.IsVisible = true;
progressIndicator.IsIndeterminate = true;
SystemTray.SetProgressIndicator(this, progressIndicator);
It is working fine. But it is coming in the top of display. I want to place it in center of display. How to do this ?
The Windows Phone SDK has an progress bar control which can be placed into any place of the page. But this control has weak performance to avoid this weakness you should use PerformanceProgressBar control from the Silverlight for Windows Phone
You can create a custom progress bar. That way you can define the control template as you would like. The following link should get you started:
http://msdn.microsoft.com/en-us/library/windowsphone/develop/gg442303(v=vs.105).aspx
or you can override the control template of the standard ProgressIndicator, though I believe the performance of this control is quite poor.

Categories