.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Paletteset disapears when undocking?

5 REPLIES 5
Reply
Message 1 of 6
mahersy
424 Views, 5 Replies

Paletteset disapears when undocking?

I have placed a paletteset reference as a shared private member of my User Control so that any Added controls can be added to it. This works fine on some machines but on others when i undock the palettes it disappears.

How does the GUID get stored in Autocad?
(I have generated a unique GUID).

(Because it load if i don't include a GUID when creating the paletteset but when i undock it disappears. If i use a GUID it will load the first time with the GUID and then when i undock it will not load at all even on the creation.)

Is it a problem if the paletteset is a Private Shared member of the user control?

Thanks in advance...

Evan

Public Class DrawingData
Inherits System.Windows.Forms.UserControl

'Associated file control on the second tab
Private Shared AssocCtrl As AssocFiles

'collection that reference's the User Control in the paletteset
'because you can't get the User control from the paletteset
Private Shared m_DwgDataCollection As Collection

'holds the number of "drawingdata" user controls on the paletteset
Private Shared DwgdataCount As Integer

'holds reference to the paletteset
Private Shared dps As Autodesk.AutoCAD.Windows.PaletteSet

'unique key for DwgdataCollection
Private ReadOnly m_DwgDataIndexKey As String

ReadOnly Property dwgdataindexkey() As String
Get
Return m_DwgDataIndexKey
End Get
End Property

Public Shared Property PaletteVisiable() As Boolean
Get
If Not dps Is Nothing Then
Return dps.Visible
End If
End Get
Set(ByVal value As Boolean)
If Not dps Is Nothing Then dps.Visible = value
End Set
End Property

'replace the brackets so it displays correct
[CommandMethod("DwgDataPalette")]_
Public Sub dwgPalette()
If dps Is Nothing Then
Dim myCtrl As Windows.Forms.UserControl = New DrawingData()
AddDrawingDataToPaletteSet(myCtrl)
End If
dps.Visible = True
dps.RolledUp = False
dps.Activate(0)
End Sub


Public Sub New()

' This call is required by the Windows Form Designer.
InitializeComponent()

' Add any initialization after the InitializeComponent() call.

Me.m_DwgDataIndexKey = Now.Date.Day.ToString & "-" & _
Now.TimeOfDay.TotalSeconds.ToString & "-" & Now.Millisecond.ToString

End Sub

Public Shared Sub AddDrawingDataToPaletteSet(ByVal myctrl As DrawingData)
If dps Is Nothing Then
CreatePaletteSet()
dps.Add("Drawing Data", myctrl)
Else
dps.Visible = False
End If
'add the next tab
If AssocCtrl Is Nothing Then
AssocCtrl = New AssocFiles()
End If

If m_DwgDataCollection Is Nothing Then m_DwgDataCollection = New Collection
m_DwgDataCollection.Add(myctrl, myctrl.dwgdataindexkey)
DwgdataCount += 1

dps.Visible = True
End Sub

Private Shared Sub CreatePaletteSet()
'use constructor with Guid so that we can save/load user data
dps = New Autodesk.AutoCAD.Windows.PaletteSet("Drawing Data", _
New Guid("{54631659-64D7-4a3c-A40C-2D08D9D0E523}"))
'dps.Style = 16 'PaletteSetStyles.NameEditable
'dps.Style = 4 'PaletteSetStyles.ShowPropertiesMenu
'dps.Style = 2 'PaletteSetStyles.ShowAutoHideButton
'dps.Style = 8 'PaletteSetStyles.ShowCloseButton

dps.Style = 30

dps.Opacity = 0

dps.MinimumSize = New System.Drawing.Size(210, 420)

End Sub

'UserControl overrides dispose to clean up the component list.
'replace the brackets so it displays correct
[System.Diagnostics.DebuggerNonUserCode()] _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
If Not m_DwgDataCollection Is Nothing Then
If Not m_DwgDataCollection.Contains(Me.dwgdataindexkey) Then
'do some stuff to cleanup
End If
End If
End If
MyBase.Dispose(disposing)
End Sub

End Class Message was edited by: Mahersy
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: mahersy

I suspect the problem is not the static variable, but
something your code may be doing in an event handler
that's triggered when the paletteset is undocked.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

wrote in message news:5492293@discussion.autodesk.com...
I have placed a paletteset reference as a shared private member of my User Control so that any Added controls can be added to it. This works fine on some machines but on others when i undock the palettes it disappears.

How does the GUID get stored in Autocad?
(I have generated a unique GUID).

(Because it load if i don't include a GUID when creating the paletteset but when i undock it disappears. If i use a GUID it will load the first time with the GUID and then when i undock it will not load at all even on the creation.)

Is it a problem if the paletteset is a Private Shared member of the user control?

Thanks in advance...

Evan

Public Class DrawingData
Inherits System.Windows.Forms.UserControl

'Associated file control on the second tab
Private Shared AssocCtrl As AssocFiles

'collection that reference's the User Control in the paletteset
'because you can't get the User control from the paletteset
Private Shared m_DwgDataCollection As Collection

'holds the number of "drawingdata" user controls on the paletteset
Private Shared DwgdataCount As Integer

'holds reference to the paletteset
Private Shared dps As Autodesk.AutoCAD.Windows.PaletteSet

'unique key for DwgdataCollection
Private ReadOnly m_DwgDataIndexKey As String

ReadOnly Property dwgdataindexkey() As String
Get
Return m_DwgDataIndexKey
End Get
End Property

Public Shared Property PaletteVisiable() As Boolean
Get
If Not dps Is Nothing Then
Return dps.Visible
End If
End Get
Set(ByVal value As Boolean)
If Not dps Is Nothing Then dps.Visible = value
End Set
End Property

'replace the brackets so it displays correct
[CommandMethod("DwgDataPalette")]_
Public Sub dwgPalette()
If dps Is Nothing Then
Dim myCtrl As Windows.Forms.UserControl = New DrawingData()
AddDrawingDataToPaletteSet(myCtrl)
End If
dps.Visible = True
dps.RolledUp = False
dps.Activate(0)
End Sub


Public Sub New()

' This call is required by the Windows Form Designer.
InitializeComponent()

' Add any initialization after the InitializeComponent() call.

Me.m_DwgDataIndexKey = Now.Date.Day.ToString & "-" & _
Now.TimeOfDay.TotalSeconds.ToString & "-" & Now.Millisecond.ToString

End Sub

Public Shared Sub AddDrawingDataToPaletteSet(ByVal myctrl As DrawingData)
If dps Is Nothing Then
CreatePaletteSet()
dps.Add("Drawing Data", myctrl)
Else
dps.Visible = False
End If
'add the next tab
If AssocCtrl Is Nothing Then
AssocCtrl = New AssocFiles()
End If

If m_DwgDataCollection Is Nothing Then m_DwgDataCollection = New Collection
m_DwgDataCollection.Add(myctrl, myctrl.dwgdataindexkey)
DwgdataCount += 1

dps.Visible = True
End Sub

Private Shared Sub CreatePaletteSet()
'use constructor with Guid so that we can save/load user data
dps = New Autodesk.AutoCAD.Windows.PaletteSet("Drawing Data", _
New Guid("{54631659-64D7-4a3c-A40C-2D08D9D0E523}"))
'dps.Style = 16 'PaletteSetStyles.NameEditable
'dps.Style = 4 'PaletteSetStyles.ShowPropertiesMenu
'dps.Style = 2 'PaletteSetStyles.ShowAutoHideButton
'dps.Style = 8 'PaletteSetStyles.ShowCloseButton

dps.Style = 30

dps.Opacity = 0

dps.MinimumSize = New System.Drawing.Size(210, 420)

End Sub

'UserControl overrides dispose to clean up the component list.
'replace the brackets so it displays correct
[System.Diagnostics.DebuggerNonUserCode()] _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
If Not m_DwgDataCollection Is Nothing Then
If Not m_DwgDataCollection.Contains(Me.dwgdataindexkey) Then
'do some stuff to cleanup
End If
End If
End If
MyBase.Dispose(disposing)
End Sub

End Class

Message was edited by: Mahersy
Message 3 of 6
mahersy
in reply to: mahersy

Thanks Tony for your response.
The only event i am using is the load event on the user control to load some tool tips. I don't have any other events in my code other than the controls on the form i.e. validate and validated.

What events can be fired when the toolpalette undocks?

I am guessing that they have some event fire that stores the Location of the paletteset under the guid.

The funny thing is that it works on some machines and not others?
Message 4 of 6
mahersy
in reply to: mahersy

This goes down as another one of my stupidest moments....

I was setting the opacity to 0.

dps.Opacity=0

This would mean that you can't see the palette when it is dragged onto the screen, right?
Message 5 of 6
Anonymous
in reply to: mahersy

don't know, never tried it.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

wrote in message news:5495333@discussion.autodesk.com...
This goes down as another one of my stupidest moments....

I was setting the opacity to 0.

dps.Opacity=0

This would mean that you can't see the palette when it is dragged onto the screen, right?
Message 6 of 6
mahersy
in reply to: mahersy

Just a case of the Glass Half full or Half empty..... with the opacity property.

Maybe they could set a minimum value for the property so that it doesn't disappear completely.

The whole time i was looking for a visible property set to false. not allow an opacity set to 0 would have saved a lot of confusion...
Especialy when it seems you can only control it on the first time the Palette loads...

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost