.NET

Reply
New Member
mpalan
Posts: 2
Registered: ‎01-04-2012
Message 1 of 8 (881 Views)

Persistant Paletteset Location

881 Views, 7 Replies
01-04-2012 02:49 PM

I have been trying to get my paletteset to remember it's closed location but cannot.  I have tried using a ststic GUD when starting the Paletteset:

 

Dim MYGuid As Guid = New Guid("DC218198-EFDE-4802-AF55-C9613342F7A4")

M_ps = New Autodesk.AutoCAD.Windows.PaletteSet(String.Format("Rapid Layer", MYGuid))

 

I have tried saving the location value to the registry from the Close event of the palette, and then restoring it in the Command function.

 

I have also tried using the App settings to save and restore this value. Can someone help me out Please?

 

How can I get the Paletteset to remember it's last location?

 

Thanks

Matthew

*Expert Elite*
Jeff_M
Posts: 4,385
Registered: ‎07-22-2003
Message 2 of 8 (865 Views)

Re: Persistant Paletteset Location

01-04-2012 09:01 PM in reply to: mpalan

Not sure if VB.NET works the same as C# for this, but in my C# applications this format works:

 

M_ps = New Autodesk.AutoCAD.Windows.PaletteSet("Rapid Layer", MYGuid)

Jeff_M, also a frequent Swamper
Distinguished Contributor
Irvin
Posts: 112
Registered: ‎04-22-2009
Message 3 of 8 (858 Views)

Re: Persistant Paletteset Location

01-05-2012 01:55 AM in reply to: mpalan

Hi there,

 

Here's my pallet creation code:

 

System.Windows.Forms.UserControl Control = PalletControl;
            Pallet.Add("51F835F4-5369-43FA-B6E0-A8447DED66D1", Control);
            Pallet.MinimumSize = new System.Drawing.Size(300, 500);
            Pallet.Size = new System.Drawing.Size(507, 600);
            Pallet.StateChanged += new PaletteSetStateEventHandler(Pallet_StateChanged);
            Pallet.Location = new System.Windows.Point(X, y);

 

Please look at the last line. Here i set te position of the Palletset. But there is a getter aswell.

System.Windows.Forms.

*Expert Elite*
Alfred.NESWADBA
Posts: 9,071
Registered: ‎06-29-2007
Message 4 of 8 (857 Views)

Re: Persistant Paletteset Location

01-05-2012 01:57 AM in reply to: mpalan

Hi,

 

IMHO it will be saved by AutoCAD's WORKSPACE!

Open your palette, start command _WORKSPACE, save the workspace and the next time you start AutoCAD plus your application/palette the position should be where you left it.

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
New Member
mpalan
Posts: 2
Registered: ‎01-04-2012
Message 5 of 8 (821 Views)

Re: Persistant Paletteset Location

01-05-2012 02:35 PM in reply to: mpalan

Saving the workspace works If I leave the palette where it is.  If I move the palete, close it, and then would like it to open where I left it, I need to save the the location out somewhere. 

 

I found that I needed to subtract 1,000 from the DeviceIndependentLocation.y.  ??

 

Thanks for your help.

Matthew

 

Public Sub PaletteCommand()
    Dim MyPalette As MyLayerPalette = New MyLayerPalette()
    ' recover the location from the registry
    Dim RegPLoca() As String = regapp.GetLocation("Rapid Layer").Split(",")
    Dim PLoca As New Point
   
    If SystemInformation.VirtualScreen.Width < RegPLoca.First Then
        PLoca.X = 200
    Else
        PLoca.X = CInt(RegPLoca.First)
    End If
    If SystemInformation.VirtualScreen.Height < RegPLoca.Last Then
        PLoca.Y = 200
    Else
        PLoca.Y = CInt(RegPLoca.Last)
    End If
    M_ps = New Autodesk.AutoCAD.Windows.PaletteSet("Rapid Layer", MYGuid)
    M_ps.Add(MYGuid.ToString, MyPalette)
    M_ps.Visible = True
    M_ps.MinimumSize = New System.Drawing.Size(340, 140)
    M_ps.DockEnabled = Autodesk.AutoCAD.Windows.DockSides.None
    M_ps.Location() = PLoca
    AddHandler M_ps.StateChanged, AddressOf Palette_Close
End Sub

Public Sub Palette_Close(ByVal sender As System.Object, ByVal e As System.EventArgs) 'Handles M_ps.StateChanged
    RapidLayer.RapidLayerApp.regapp.SaveFormLocation(M_ps.Text, M_ps.DeviceIndependentLocation.X.ToString + "," & _
                                                             + (M_ps.DeviceIndependentLocation.Y - 1000).ToString)
    RemoveHandler M_ps.StateChanged, AddressOf Palette_Close

End Sub

Mentor
Rob.O
Posts: 259
Registered: ‎06-25-2007
Message 6 of 8 (805 Views)

Re: Persistant Paletteset Location

01-06-2012 07:02 AM in reply to: mpalan

Not sure if it helps, but this works for me...

 

myPaletteSet = New PaletteSet("Name", New Guid("C2C52873-B1D8-4D40-99F6-6ECEB4D932CC"))

 

Mentor
Rob.O
Posts: 259
Registered: ‎06-25-2007
Message 7 of 8 (800 Views)

Re: Persistant Paletteset Location

01-06-2012 07:10 AM in reply to: Rob.O

Forgot to add...

 

Check out the "Restore Users Settings" section in the attached PDF from Mike Tuersley's AU class.  I think it has everything you need to save the palette set settings.

 

Hope it helps!

*Expert Elite*
norman.yuan
Posts: 998
Registered: ‎04-27-2009
Message 8 of 8 (784 Views)

Re: Persistant Paletteset Location

01-06-2012 11:18 AM in reply to: mpalan

If you create your own custom PaletteSet, AutoCAD can either remember its last size/location (when the PaleteSet has its identification supplied - a GUID), or AutoCAD do not remember its size/location at all (when there is no GUID id is provided).

 

Replies from Jeff_M and Dull_Blades clearly showed you how it is done: in the constructor, you supply a string value as name and a GUID as its id. Then AutoCAD will take care of persisting its location/size when the PaletteSet is closed.

 

However your 2 code sample showed here all are not supplying the GUID id, thus, AutoCAd does not remember your PaletteSet's size/location, so you are trying to reinvent a wheel here.

 

In your first post, you create your PaletteSet this way:

 

M_ps = New Autodesk.AutoCAD.Windows.PaletteSet(String.Format(​"Rapid Layer", MYGuid))

 

What does String.Format("XXXX", MyGuid) do is a mystry to me. But I am sure it would only produce a string value, at most.

 

So, it is like you do

 

M_ps = New Autodesk.AutoCAD.Windows.PaletteSet("xxxxxx").

 

That is, not GUID id is supplied. That is why Acad does not remember PaletteSet size/location for you.

 

So, as long as you use the same GUID correctly in the PaletteSet constructior, AutoCAD will recall its previous location/size. You do not painstakingly to try implement your own saving/calling code at all.

 

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.