Hi all. Rhino 6, Rhino7 c# rhinocommon. I have a problem with dual screen if rhino is not opened in primary screen. If a show my System.Windows.Forms.Form or my window wpf it appears always in primary screen. What is wrong?
Hi @gianfranco74, in case of a Windows.Forms.Form
you can set the form.StartPosition
to be used from the parent (Rhino) like this:
form.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
_
c.
Hi, thank you for your replay but it does not work with me, did you try it? Sure Rhino opens in secondary screen?
Hi All i think i am close to solution.
I did not know how dual screens think.
I saw that it is only a problem of Location because it seems to be a big one screen. I tried to change manually Location and i can show it on rhino like before .
As I save Location when i close my windows i thought it was a problem of methods or parameters but i did not realize that when opening a window even if i read a Location for example of 6000, 300 The Form changes it into 1920 ,1080 .
I have a 4k (3840,2160) screen plus a smaller one(1024,600). Ther will be a maximum or something like this, Any ideas?
My mistake,i think it is right what i said until the question about location that changes for a hypothetical maximumum value,i only forgot one value in my tests.
The soluiotn is only to set manually the location of forms and the location when you close the window, it does not need any information on which screen you have to show your forms: It works fine know.
Unfortunately the solution form.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent does not work , so the first time i open the window it will be on primary screen. Any ideas to solve this ?
form.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen works even if rhino is in secondary screen.
Ther is another question. I have a method that controls the maximum of location based on screen working area.
It is the sum of all screens working area.
I need it because if i save location in dual screen and then i want to open rhino with only one screen you can imagine where the window can go.
So my solution is that if saved Location exceeds maximum of ALL screens workingarea it becomes centerscreen.
int width = 0, height = 0;
var screens = System.Windows.Forms.Screen.AllScreens;
if (screens != null && screens.Length > 0)
{
foreach (var screen in screens)
{
width = width + screen.Bounds.Width;
height = height + screen.Bounds.Height;
}
}
There are two things i would like to undestand.
i have now 2 screens (3840,2160) , (1024,600) When i am in dual screen ,maximum working area is (5376,3060) .
- Shouldn’t that be it (4864,2760)? Second screen is different from its specifics : its working area is ( 1536,900).
- if a move the window manually , its location may be more than maximum location. ??? There is no corrispondence. If I save that value it is mandatory that at the next reading I will be over the maximum
Hi @gianfranco74,
it depends how your screens are set up. You can set them up as one large screen or as seperate screens. You might add some temporary display in your form which shows the screen bounds to find out.
if you save your form location and need to check if the saved location is invalid next time you open your form you could get the screen and bounds from the form:
bounds = Screen.FromControl(this).Bounds
Then you would decide if your saved location is larger than the bounds and revert to CenterScreen
.
_
c.