TryEnterFullScreenMode does not call Page.SizeChanged UWP XAML - vb.net

In my code it is dependent on Page.SizeChanged being called but when I use ApplicationView.GetForCurrentView().TryEnterFullScreenMode it does not call Page.SizeChanged if there is any way to call Page.SizeChanged and BTW I need to have both oldSize and newSize in the eventArgs variable
ApplicationView.GetForCurrentView().TryEnterFullScreenMode

Related

Updating a textbox in main GUI from a thread (created on button click) in cli

I am very new with C++/CLI, which is based on c#. I have a main GUI form.
public ref class MyForm : public System::Windows::Forms::Form
On clicking a button in the from I am creating a thread using CreateThread. Code as following:
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e)
{
HANDLE h1;
h1 = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)thread1,0, 0, &threadID1);
}
Now my problem is I need to update a TextBox in Myform from the thread. Can anybody please tell me how to do it in cli?
It is safe to use .NET Thread^ in this scenario. Inside your thread1 method use Control::BeginInvoke or Control::Invoke like #AlexF mentioned. Here you have an example from C#.

Helix Toolkit How to use MouseWheelEventHandler to run specific methods in other classes

I would like to run particular methods of a custom Camera class whenever the user zooms in or out in the helix toolkit view that my program is running inside of.
A key feature of this functionality is getting the mouseargs from the event so I can adjust the camera in a way that is proportional to the number of scroll ticks.
I began to try this:
public event PropertyChangedEventHandler PropertyChanged;
public virtual void onMouseWheeled(MouseDevice Mouse, int time,
MouseWheelEventArgs e) {
MouseWheel?.Invoke(this, new MouseWheelEventArgs(Mouse, time,
e.Delta)); }
//This next line goes in a MainWindow_Loaded method that gets called in the
//MainWindowConstructor
void MainWindow_Loaded(object sender, RoutedEventArgs e) {
view1.MouseWheel += new MouseWheelEventHandler(onMouseWheeled(Cursor,
Time.simTime, view1.MouseWheeledEventArgs)); }
but was having a lot of trouble figuring out how to pass a MouseWheelEventArgs object into the onMouseWheeled method when I'm trying to add the onMouseWheeled method to the MouseWheelEventHandler. Assuming nothing is fundamentally wrong with that sentence, which is nothing more than wishful thinking, The last thing I am trying to figure out is how to get mouse wheel event args so that I can pass it into a method.
Then I tried this:
public event MouseWheelEventHandler MouseWheel;
public virtual void onMouseWheeled(object sender, MouseWheelEventArgs e)
{
Console.WriteLine(e.Delta);
}
//In Main Window Loaded method...
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
view1.MouseWheel += onMouseWheeled;
}
But I get no output when i scroll the wheel. I assumed this might actually work because view1 is the helix window I'm attaching all of my objects to, as children of view1.
Basically my main questions are:
What does invoke actually do? I only have this running to try to see if its working because onPropertyChanged methods I always use run the Invoke command like so. I'm actually not sure where I'm going with this.
How does the handler work?
How do the event args get called out so that I can use them and pass them as objects to other methods?
Thank you for your time. And Thank you twice for any and all pointers and advice you may give me.
Try to use preview mouse wheel event

Hooking to empty C++ implementation with C++/CLI events

I am using an open source toolkit (VTK) that has an object with a method that is triggered by pressing any key. The idea is to overwrite the implementation in your own class but I can't figure out how to do it in C++/CLI.
This is what I have, but I can't figure out how to hook it to an object.
delegate void myEventHandler(vtkObject * sender, EventArgs ^ e);
event myEventHandler^ LeftButtonPressEvt;
LeftButtonPressEvt += gcnew myEventHandler(&MyClass::MyModifiedOnKeyPress);
void MyModifiedOnKeyPress(vtkObject * sender, EventArgs ^ e)
{
//this should be called whenever the button is pressed
}
Hooking it to the vtk object would look something like this:
vtkObject->OnKeyPress += gcnew myEventHandler(&MyClass::Pick);
This returns the error that a function is the left operand which makes sense, but I cant figure out how this would be hooked to the event.
For non-static methods, you need to specify which object the delegate should point to.
vtkObject->OnKeyPress += gcnew myEventHandler(this, &MyClass::Pick);
// ^^^^
(If that doesn't solve the problem, then I don't understand exactly what problem you're having. If you're getting an error message, don't describe the error, copy & paste exactly what the error message is.)

Equivalent of CGRectInfinite & CGRectIsInfinite in MonoTouch/Xamarin

I am trying to convert an open source flyout menu from Objective-C to Xamarin. The current issue I have is that the Obj-C code creates a frame using CGRectInfinite. This does not appear to be available under MonoTouch, via the usual RectangleF class. Is there an alternative?
Similarly, there does not appear to be a CGRectIsInfinite equivalent in RectangleF. What, if any, is the alternative?
Add this using statement first:
using MonoTouch.CoreGraphics;
Then you can test it with this:
public static RectangleF GetInfinite()
{
var image = CIImage.EmptyImage;
if (image.Extent.IsInfinite ())
{
return image.Extent;
}
throw new Exception ("Unable to create infinite rect");
}

How do I draw to the window's title bar in C++.NET?

I'm trying to draw a custom title bar, and I've read that in order to paint outside a window's client area, I need to override WndProc and handle the WM_NCPAINT message. Currently, I'm doing that like this:
//WndProc override
virtual void WndProc(Message% m) override
{
switch(m.Msg)
{
case 0x85: //WM_NCPAINT
case 0x0A: //WM_PAINT
//Call original
System::Windows::Forms::Form::WndProc(m);
//Now we'll do our painting
DrawTitleBar(m.HWnd);
break;
default:
System::Windows::Forms::Form::WndProc(m);
break;
}
}
Which works, because I can put a breakpoint in and it gets hit. If I remove the call to the original, the window's frame isn't drawn. DrawTitleBar looks like this:
void DrawTitleBar(IntPtr hWnd)
{
IntPtr hDC;
Graphics^ g;
//Get the device context (DC)
hDC = GetWindowDC(hWnd);
//Get the graphics
g = Graphics::FromHdc(hDC);
//Draw
g->FillRectangle(Brushes::Blue, 0, 0, 100, 10);
//Cleanup
g->Flush();
ReleaseDC(hWnd, hDC);
}
I first get the DC from the window handle. Then I get the Graphics object by using Graphics::FromHdc. I release the DC with ReleaseDC. Incase there's an issue here, this is how I import the native Win32 functions:
[DllImport("user32.dll")]
extern IntPtr GetWindowDC(IntPtr hWnd);
[DllImport("user32.dll")]
extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
Also: I've tried a bunch of different methods, all with the same results. I can find a bunch of C# and VB examples on the web, but no C++ examples. I've also read about Windows Vista compatibility being an issue with this sort of thing. Currently, I don't care about that, as I will add it later.
Two simple facts. 1. under DWM GetWindowDC is essentially broken.
2. Two work arounds partially exist A. set compatiblity mode to xp or 98 or 95.
B. program example in msdn social exists. search for
"GetWindowDC broken" then follow a lengthy url to a code
sample [fix the broken url by adding a trailing ) ].
Unhappily, the window shows up with rounded corners on
my box build 9200, win 8.0 , no updates.