How to minimize the start interface window?

How to minimize the start interface window?

Medithaibet
Contributor Contributor
307 Views
1 Reply
Message 1 of 2

How to minimize the start interface window?

Medithaibet
Contributor
Contributor

When I used the following code to simulate the window equal distribution, I found that if I switch between multiple documents by using the command, the window switching works successfully. However, when I activate other documents, the start interface will cover the display of other documents. If the start interface is minimized, this problem won't occur.

How should I fix this bug ,so how can I make the start interface minimized from the beginning?
Thank you first!

    [CommandMethod(nameof(SizeDocumentWindowTest), CommandFlags.Session)]
    public static void SizeDocumentWindowTest()
    {
        //Size the Document window
        Document acDoc = Acaop.DocumentManager.MdiActiveDocument;

        var count = Acaop.DocumentManager.Count;
        if (Acaop.DocumentManager.Count == 0)
            return;

        acDoc.Window.WindowState = Window.State.Maximized;
        var size = acDoc.Window.GetSize();
        $"size:{size}".Print();
        $"count:{count}".Print();

        acDoc.Window.WindowState = Window.State.Minimized;
        var width = size.Width / count;
        int i = 0;
        foreach (var item in Acaop.DocumentManager)
        {
            if (item is not Document doc)
                continue;
            if (string.IsNullOrEmpty(doc.Name))
                $"doc:{doc.Name}".Print();
            Acaop.DocumentManager.MdiActiveDocument = doc;
            doc.Window.WindowState = Window.State.Normal;
            doc.Window.DeviceIndependentLocation = new System.Windows.Point(width * i, 0);
            doc.Window.DeviceIndependentSize = new Size(width, size.Height);
            i++;
        }

        Acaop.DocumentManager.MdiActiveDocument = acDoc;
    }

 

0 Likes
Accepted solutions (1)
308 Views
1 Reply
Reply (1)
Message 2 of 2

ActivistInvestor
Mentor
Mentor
Accepted solution

For your purposes, you should be using the Application's DocumentWindowCollection. Searching this forum on 'DocumentWindowCollection' will lead you to some useful examples.

0 Likes