Author Topic: Palette Problem  (Read 22711 times)

0 Members and 1 Guest are viewing this topic.

DBARANAS

  • Guest
Palette Problem
« on: July 18, 2006, 10:48:07 PM »
Using code translated from MickD's simple palette app I made lots of palettes based on the following:

All of the user controls are thin strips 1240w x 32h meant to go at the top of the app. When they open they eat up the whole screen and have to be minimized then redocked and resized.

Has anybody been able to get palettes to work properly when docking to the top or bottom?

This would be so nice to have as so much screen space gets saved this way.

regards, Dave

    <CommandMethod("cmd")> Public Sub createPalettes()

        createPaletteCommand()

    End Sub
    Public Sub createPaletteCommand()

        If paletteCommand Is Nothing Then
            paletteCommand = New Autodesk.AutoCAD.Windows.PaletteSet("Command Palette")
            paletteCommand.Style = PaletteSetStyles.Snappable Or  PaletteSetStyles.ShowAutoHideButton
            paletteCommand.Opacity = 60
            paletteCommand.Size = New System.Drawing.Size(1240, 32)
            paletteCommand.MinimumSize = New System.Drawing.Size(1240, 32)
            'paletteCommand.WindowState = FormWindowState.Normal
            paletteCommand.Add("Commands", New commands())
            paletteCommand.Dock = Autodesk.AutoCAD.Windows.DockSides.Top
            'You may or may not need the below code for list/combo boxes to retain focus.
            paletteCommand.KeepFocus = True
            paletteCommand.Visible = True
        Else
            paletteCommand.Visible = True
        End If

    End Sub

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: Palette Problem
« Reply #1 on: July 18, 2006, 11:23:52 PM »
What size is your user control? try setting this to suit and set it to 'locked'.
Otherwise I'm not sure, there may be some base methods that need to be overridden.
hth,
Mick.
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

DBARANAS

  • Guest
Re: Palette Problem
« Reply #2 on: July 18, 2006, 11:58:45 PM »
The User Control is set to 1240 x 32. I locked it but it still does the same thing

When I minimize it it looks like 1280x1024, then when I redock it to the top it now knows that it is only 32 pixels high and does what it's supposed to.

It's like something is short circuited inside between width and height when the palette first loads

Dave


MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: Palette Problem
« Reply #3 on: July 19, 2006, 12:17:44 AM »
Ah ok, I have noticed that myself and I don't think it can be changed easily but I haven't really tried too hard either  :roll:

I have my docksides set to none and it loads up docked and sized properly after docking in the first session after loading (or last good session) so acad must be saving its state some where.
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

DBARANAS

  • Guest
Re: Palette Problem
« Reply #4 on: July 19, 2006, 12:19:58 AM »
It seems the problem is that the palette always docks to the left no matter what side you set it to when it loads

Dave

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: Palette Problem
« Reply #5 on: July 19, 2006, 01:06:58 AM »
I know this probably won't help you with what you want to do but are you using this like a tool bar?
If you are I've noticed some editor <-> palette focus issues which crop up such as if you still have your mouse over the palette your code doesn't get executed! This mainly happens with methods that don't require user action from the editor.
For instance, I have some view setting buttons with default views of 3d models, when I pick to set the new view it seemed to take a long time and then I noticed what was happening. The user still had the mouse over the button waiting for the screen to update :)
This probably can be fixed but toolbars take up less room anyway (and I don't have the spare time lately :) )

So, I'll be moving all of my simple methods to commands and toolbars and save the palette for list boxes and larger controls which are better suited to side docking anyway.
Cheers,
Mick.
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

DBARANAS

  • Guest
Re: Palette Problem
« Reply #6 on: July 19, 2006, 03:30:50 AM »
Yes that's pretty much what I am trying to do. I got about 20 of these palette strips and they contain textboxes, cmdButtons, cboBoxes, etc

There should never have to be more than 3 or 4 displayed at any given time. I am trying to make them intuitive and autoswitch on and go away when not needed.

I got it working now and can autoload the main "Command" palette and have it dock to the top.
It remembers the palette location for next time wherever you set it as well. But only if I use a Guid and the addHandlers

I found an example over in acad.net from Mike Tuersley I distilled down and mixed with your sample to get this:

    Public paletteCommands As Autodesk.AutoCAD.Windows.PaletteSet
    Public paletteCommand As commands

    Public Class Class1
        Implements IExtensionApplication

        Public Sub Initialize() Implements IExtensionApplication.Initialize

            Autodesk.AutoCAD.ApplicationServices.Application.StatusBar.RemoveDefaultPane(DefaultPane.All)

            StartInterface()

        End Sub

        Public Sub Terminate() Implements IExtensionApplication.Terminate

        End Sub

    End Class

    Public Sub StartInterface()

        If paletteCommands Is Nothing Then

            paletteCommands = New Autodesk.AutoCAD.Windows.PaletteSet("acadToolPalette", New Guid("63B8DB5B-10E4-4924-B8A2-A9CF9158E4F6"))

            AddHandler paletteCommands.Load, AddressOf ps_Load 'add the events
            AddHandler paletteCommands.Save, AddressOf ps_Save

            paletteCommands.Style = PaletteSetStyles.ShowPropertiesMenu Or PaletteSetStyles.ShowAutoHideButton Or PaletteSetStyles.ShowCloseButton
            paletteCommands.MinimumSize = New System.Drawing.Size(1240, 36)
            paletteCommands.Dock = Autodesk.AutoCAD.Windows.DockSides.Top

            paletteCommand = New commands
            paletteCommands.Add("Commands", paletteCommand)

        End If
        paletteCommands.Visible = True

    End Sub

    'skeleton construct to configuration settings
    'refer to acadDefaults example project
    Private Sub ps_Load(ByVal sender As Object, ByVal e As Autodesk.AutoCAD.Windows.PalettePersistEventArgs)
        '
        Dim a As Double = CType(e.ConfigurationSection.ReadProperty("whatever", 22.3), Double)

    End Sub

    Private Sub ps_Save(ByVal sender As Object, ByVal e As Autodesk.AutoCAD.Windows.PalettePersistEventArgs)
        '
        e.ConfigurationSection.WriteProperty("whatever", 32.3)

    End Sub

Next I will see if I can get all the palettes to work together

DBARANAS

  • Guest
Re: Palette Problem
« Reply #7 on: July 19, 2006, 07:08:36 AM »
I got the palettes working and only needed this code:

        palCommands = New Autodesk.AutoCAD.Windows.PaletteSet("Commands", New Guid("63B8DB5B-10E4-4924-B8A2-A9CF9158E4F6"))
        palCommands.Style = PaletteSetStyles.ShowPropertiesMenu
        palCommand = New commands
        palCommands.Add("Commands", palCommand)
        palCommands.KeepFocus = True
        palCommands.Visible = True

There is no need to specify the docking or add the handlers. the palettes just remember wherever they were set to the next time the drawing is opened...just like normal acad.

But I find out the enter method does not work or the keydown method either. I can type normal and enter text but can't trap the enter key. This one is just too much!



DBARANAS

  • Guest
Re: Palette Problem
« Reply #8 on: July 20, 2006, 09:40:06 PM »
Palettes all working very nice including comboboxes tha drop off the palette.

The text boxes are a strange creature .......this works

    Private Sub txtLength_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtLength.KeyDown

        If e.KeyData = Keys.Right Then
          'Stuff
        End If

    End Sub

but this ......does not

        If e.KeyData = Keys.Enter Then

or this .....either

        If e.KeyData = Keys.Return Then

The keydown method does not get triggered by those....using the right arrow key is a way to make it work but it is weird that the proper keys do not work.

This happens only with textboxes inside palettes. Has anyone ever seen this happen??

regards,

Dave

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: Palette Problem
« Reply #9 on: July 20, 2006, 09:58:16 PM »
Try using 'e.KeyCode' to get your key value.
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

DBARANAS

  • Guest
Re: Palette Problem
« Reply #10 on: July 20, 2006, 11:40:22 PM »
Thanks Mick

I already tried it before and no luck.

I ended up with key.value after sailing and trying the sea of texbox events.

key.code works the same way as key.data

In fact I tried every way to make it work for me trying to capture a "key.enter" event and when I hit "enter" it is as like I never did anything.

I went through key.*.* and they all work except key.enter or key.return

Thanks for always helping me Mick.

I could come up with "because this app is so special you have to hit the right arrow key instead of the enter key" "every one knows the right arrow key is way faster...aren't you glad I shared that with you????"

As always...you get something almost figured out and hit a stupid wall. This should be my best signature!!!

Everyone in the swamp please forgive this unmanaged uncontrolled exception.....CLR cops on the way!

" You exception is now unmanaged...danger....danger...step back from the unmanaged zone!!!

I am going to get some sleep......programming is now my drug of choice and I am now brain dead

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: Palette Problem
« Reply #11 on: July 21, 2006, 12:20:33 AM »
Have you tried the keyPress or KeyUp events?
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

DBARANAS

  • Guest
Re: Palette Problem
« Reply #12 on: July 21, 2006, 08:17:34 PM »
Yes I tried those as well...

This is for all swampers so we all know why I went off....

I got a little frustrated last night trying every textbox method to see if I could get around this problem,, and ranted off a bit....but the batteries are full again and I am back for more.

I spent 3 years working almost every day non stop to make a program that could design a building like ADT but then tear the model down and load it onto a truck based on assembly order for the crane operator so he could watch how every peice gets loaded off looking at his pocket PC.

I had all of this already figured out in VBA but smashed into the memory leak wall. If you try to make an app in VBA you will see what I mean. I am not talking about a few macros but 30,000+ lines of code.

So far I have 70% of that code working in .Net and did it in 25 days.

My goal is to learn things the .Net way and throw back my pain and how I overcame it showing solutions.

You will not see yet where I have answered a problem yet .....but I explain where I mess up. And that must be of some help. I never take something and run away...even if it was an easy thing I try to explain in the context of the problem why I asked the question in the 1st place.

I think this swamp is the only hope for those working in acad.net....Thanks to everyone here for putting up with me

Dave






MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: Palette Problem
« Reply #13 on: July 25, 2006, 03:09:48 AM »
Hey Dave, give something like this a go -

Code: [Select]
protected override void OnKeyDown(KeyEventArgs kea)
{
base.OnKeyDown(kea); // note call to base class!
switch(kea.KeyCode)
{
case Keys.Enter:
//do sumtin:
break;
}
}
« Last Edit: July 25, 2006, 03:11:11 AM by MickD »
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: Palette Problem
« Reply #14 on: July 25, 2006, 04:33:38 AM »
Nope, that don't work neither :(
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien