I have a UWP C++ app which was ported from old good DirectX PC game. It does not use XAML stuff at all. There is a class Direct3DApplicationSource which implements Windows::ApplicationModel::Core::IFrameworkViewSource interface and everything is initialized as simple as
[Platform::MTAThread]
int main(Platform::Array<Platform::String^>^)
{
auto direct3DApplicationSource = ref new Direct3DApplicationSource();
Windows::ApplicationModel::Core::CoreApplication::Run(direct3DApplicationSource);
return 0;
}
Now I need to add a video player functionality into the app. I learned that the simplest way is to use MediaPlayerElement which presents video player with play/stop/pause UI.
In order to implement it, I need to add sort of XAML page to my app like this:
Windows::UI::Xaml::Window::Current->Content = myVideoPlayerFrame;
But in my case Windows::UI::Xaml::Window::Current == nullptr because as I mentioned the app is XAML-free initially.
Does anybody has an idea how to "push" XAML page into the DirectX app and then pop it back?
I don't think app it's possible to do that however you can render DirectX content in a XAML app using SwapChainPanel.
Related
I have been trying to create a Xamarin Forms App using Prism that works on both phones and tablets.
For the tablet layout I'm trying to create something similar to the draft image below while still reusing the Pages/ViewModels from the phone.
What I have tried:
Using a TabbedPage where each Tab contains a MasterDetailPage. There are two issues with this solution:
Xamarin only recommends using a MasterDetailPage as the root page
I managed to implement this "solution" but probably due to the reason above the xaml of the pages inside the MasterDetailPage don't bind correctly to their ViewModels.
Using a TabbedPage in which each Tab contains a Page divided in two parts which have a ContentView:
This solution works, but I can't reuse the Page from the Phone version directly on the layout.
I did try using Prism Partial Views to implement this solution, but I think the parent Page needs to contain the ViewModel that is going to be used by the ContentView which wouldn't work in this scenario (because it's going to contain two View Models).
Not sharing the Pages/ContentViews/ViewModels between phone and tablet:
This solution works, because I can implement the MasterDetailPage with ContentViews but there's is no code being shared for pages/views that basically do exactly same thing so it's really not ideal.
Any idea on how I can implement this layout while still sharing the Views and View Models between the Phone and Tablet implementations?
Note: This app is for Android, iOS and UWP using Xamarin Forms 3.4 and Prism 7.1
I have a client that adamantly insists on a solution with embedded camera in terms of having a ContentPage with an camera stream and custom buttons and icons, similar to https://github.com/pierceboggan/Moments, or at very least as I understand it seeing as it is a Snapchat clone. And my client wants similar swipe capabilities as to how navigation works in Snapchat.
However, as far as I can tell most of what is utilized in that solution has been deprecated.
I have suggested using the Media Plugin https://github.com/jamesmontemagno/MediaPlugin but they're not satisfied with the camera being pushed on the stack.
I've looked into implementing it natively and using dependency injections but it appears to be an overwhelming amount of work just to implement the most basic functions, particularly for Android's Camera2.
I'm hoping someone can provide me with good news of an easier alternative or an alteration to either Moments or Media Plugin or anything similar that will facilitate the requirements or if my only option is time consuming and complex?
From the code of Moment, you can do what you want to achieve. I did this for iOS.
You will have to create a custom renderer to display the camera page. You will be able to add buttons on top of it.
You could try this example which use custom renderer to add a take photo button and switch camera button on the camera view. Which is able to use on iOS and Android platform.
Main Page:
Camera View with custom button page:
First of all, thanks to everything of codenameone.
I would like to customize camera view, simply overlaying PNG image on the full camera view screen.
Any way how to do it?
Here is code snippet.
Form mainForm = new Form();
ImageViewer iv = new ImageViewer();
mainForm.getToolbar().addMaterialCommandToRightBar("",
FontImage.MATERIAL_CAMERA_ALT, 4, (ev) -> {
filePath = Capture.capturePhoto();
setImage(filePath, iv);
});
I couldn't any view component of camera view, because Capture.capturePhoto() works automatically.
Or is there any way to build custom camera component in codename one?
I googled and got about PeerComponents, however don't know how to use it.
Just please provide some small sample code for me.
Best regards.
Currently Capture.capturePhoto() opens its own "window" over the app so you can't customize it. In the future we will likely add a more flexible API to embed the camera into your UI, especially now that we have Z-layering (we can draw over top of native widgets).
If you need this functionality right now, you would need to write a native interface and make your own capture component.
I need to make a picker like this in the picture below:
What you see is a TimePicker and I took it just to give you an example. I would like to have one with about 200 numbers on the left and 100 on the right (for example). How can I do it in a Xamarin.Forms PCL project?
The first problem you'll face is that the picker control you see here is a native iOS control. The Xamarin.Forms TimePicker is basically not a physical control in itself but it translates to a native control on each platform. That's why it will look different on Android and UWP devices because they provide their own picker controls, as seen in the picture below.
Now, if you're ok with the controls looking different, you could use custom renderers to modify each native control or even replace them to provide the functionality you need. I thought I'd outline the basic steps for you to get you started:
Create a new Xamarin.Forms control called CustomPicker or something.
Create custom renderers for each platform.
On iOS, you can use the UIPickerView and specify numberOfComponents, numberOfRows and the data source.
On Android, you might want to use a 3rd party control since by default, there are no scrolling picker controls like the one on iOS. WheelPicker looks promising.
On UWP, you might be able to work something out using the PickerFlyoutBase. I have limited knowledge on the platform but you should be able to find something quite easily.
As you can see, it's going to be quite an effort to get the scroll picker working on each platform.
Edit: You could also look into native embedding, which lets you embed native controls into Xamarin.Forms app's pages.
Native Embedding
Embedding native controls into Xamarin.Forms
We've developed a two-column picker for Xamarin.Forms (Android and iOS).
Sample:
https://github.com/HorusSoftwareUY/MaterialDesignControlsPlugin#materialdoublepicker
Screenshots:
Android
iOS
We added this control to MaterialDesignControls NuGet (https://www.nuget.org/packages/Plugin.MaterialDesignControls/), where you can find other interesting controls with the material design look and feel.
Contributions are welcome!
I am in the process of writing a menubar icon for an app i'm developing. However the NSStatusBar class does not have a method which would make the icon draggable, via cmd+left mouse drag.
How do you make your menubar icon draggable with Objective-C code?
Thank you :)
You can't currently do it with NSStatusBar. NSMenuExtra will behave the the way you want, but unfortunately it's not part of the part of the public Cocoa API, and from what I understand (I haven't used it myself) takes a bit of a hack to even get it working. Also NSStatusBar will be easier to integrate into an existing application, NSMenuExtra is more of a separate bundle that's loaded by the system.
In my opinion it's not a good idea to depend on private APIs to add major functionality like this to your app. I would stick with NSStatusBar, most users will be used to the behavior from other applications, and with any luck a future version of Mac OS X will allow dragging the icon the same way NSMenuExtra works.