WPF palette inside auto cad: close button ,auto hide button does not get display

WPF palette inside auto cad: close button ,auto hide button does not get display

Anonymous
Not applicable
4,336 Views
11 Replies
Message 1 of 12

WPF palette inside auto cad: close button ,auto hide button does not get display

Anonymous
Not applicable
Palette code

 <CommandMethod("myfirstwpfuc", CommandFlags.Session)>
    Public Sub myfirstudercontrol()
        Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
        Dim ed As Editor = doc.Editor
        Dim firstadd As Boolean = False

        If autocadPaletteset = Nothing Then
            autocadPaletteset = New PaletteSet("Modify attributes", New Guid("{773D4B0E-98A8-4AB4-9711-D80898DE40C0}"))
            'autocadPaletteset.Style = PaletteSetStyles.ShowAutoHideButton Or PaletteSetStyles.ShowCloseButton Or PaletteSetStyles.Snappable
            autocadPaletteset.Style = PaletteSetStyles.ShowCloseButton
            autocadPaletteset.Style = PaletteSetStyles.ShowAutoHideButton
            autocadPaletteset.Style = PaletteSetStyles.Snappable

            autocadPaletteset.Style = PaletteSetStyles.ShowPropertiesMenu
            autocadPaletteset.Style = PaletteSetStyles.ShowTabForSingle

            Dim elementhost As ElementHost = New System.Windows.Forms.Integration.ElementHost
            elementhost.Dock = DockStyle.Fill
            Dim UC2 As New View_ATT
            elementhost.Child = UC2
            autocadPaletteset.Dock = DockSides.None
            autocadPaletteset.DockEnabled = DockSides.None
            'autocadPaletteset.AddVisual("Modify", UC2)
            autocadPaletteset.Add("P", elementhost)
            firstadd = True
            autocadPaletteset.Visible = True

        End If
    End Sub
Xaml code

<UserControl x:Class="View_ATT"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:SchneiderMacros"
             mc:Ignorable="d" 
             d:DesignHeight="230" d:DesignWidth="325">
    <Grid Background="#FF007ACC">
        <StackPanel Margin="5 " Background="#FF252526">
            <StackPanel Orientation="Horizontal" >
                <TextBlock x:Name="Block" Width=" 30" Margin=" 5" Text="Block " Foreground="#FFE6E6EE" FontWeight="Bold" TextDecorations="{x:Null}"/>
                <StackPanel >
                    <TextBlock x:Name="txtBlkName" Width=" 150" Margin=" 2" Foreground="#FFEAEAF3" Text="{Binding blkname,Mode=TwoWay,NotifyOnSourceUpdated=True}"></TextBlock>
                    <TextBlock x:Name="txtblkBLKID" Width=" 150" Margin=" 2" Foreground="#FFDADAE4" Text="{Binding blockid,Mode=TwoWay,NotifyOnSourceUpdated=True}"></TextBlock>
                </StackPanel>
                <Button x:Name="GetAtt" Width="85" Margin=" 2" Content="Get Attributes"></Button>
                <Image Source="S:\Transfer\Pankaj_Potdar\acadplugin\unnamed.png" Height="28" Width="28" />
            </StackPanel>

            <StackPanel Orientation="Horizontal" Margin=" 5">
                <StackPanel Margin=" 2" HorizontalAlignment="Left" Width="140">
                    <TextBlock x:Name="tagDL" Margin="2 " Height=" 20" Text="{Binding tagDL,Mode=TwoWay,NotifyOnSourceUpdated=True}" Foreground="#FFD1D1E2" ></TextBlock>
                    <TextBlock x:Name="tagDN" Margin=" 2" Height=" 20" Text="{Binding tagDN,Mode=TwoWay,NotifyOnSourceUpdated=True}" Foreground="#FFD1D1E2"></TextBlock>
                    <TextBlock x:Name="tagSQDPN" Margin=" 2" Height=" 20" Text="{Binding tagsqdpn,Mode=TwoWay,NotifyOnSourceUpdated=True}" Foreground="#FFD1D1E2"></TextBlock>
                    <TextBlock x:Name="tagMODEL" Margin=" 2" Height=" 20" Text="{Binding tagmodel,Mode=TwoWay,NotifyOnSourceUpdated=True}" Foreground="#FFD1D1E2"></TextBlock>
                    <TextBlock x:Name="tagMANUFACTURER" Margin=" 2" Height=" 20" Text="{Binding tagmanufacturer,Mode=TwoWay,NotifyOnSourceUpdated=True}" Foreground="#FFD1D1E2"></TextBlock>
                </StackPanel>
                <StackPanel Margin=" 2" HorizontalAlignment="Right"  Width="140">
                    <TextBox x:Name="txtboxDL" Margin="2 " Height=" 20" Text="{Binding devicelocation,Mode=TwoWay,NotifyOnSourceUpdated=True}"/>
                    <TextBox x:Name="txtboxDN" Margin="2 " Height=" 20" Text="{Binding devicename,Mode=TwoWay,NotifyOnSourceUpdated=True}"/>
                    <TextBox x:Name="txtboxSQDPN" Margin="2 " Height=" 20" Text="{Binding sqdpn,Mode=TwoWay,NotifyOnSourceUpdated=True}"/>
                    <TextBox x:Name="txtboxMODEL" Margin="2 " Height=" 20" Text="{Binding model,Mode=TwoWay,NotifyOnSourceUpdated=True}"/>
                    <TextBox x:Name="txtboxMANUFACTURER" Margin="2 " Height=" 20" Text="{Binding manufacturer,Mode=TwoWay,NotifyOnSourceUpdated=True}"/>

                </StackPanel>
                <StackPanel Margin=" 2">

                    <CheckBox x:Name="sqdpnhdn" Margin="2,53,2,2" HorizontalAlignment="Center" IsChecked="{Binding hidden, Mode=TwoWay, NotifyOnSourceUpdated=True}"/>
                </StackPanel>
            </StackPanel>
            <StackPanel Orientation="Horizontal" >
                <Button x:Name="btnUpdate" Width="50 " Height=" 25" Margin=" 10" HorizontalAlignment="Left" Content="Update "></Button>
                <Image Source="S:\Transfer\Pankaj_Potdar\acadplugin\Schneider-Electric_White.png" Height="45" Width="68" Margin=" 170,0,0,0" Stretch="Fill"/>
            </StackPanel>
        </StackPanel>
    </Grid>
</UserControl>

WPF Palette get loaded sucessfully but can not see close button, auto hide or properties menu on palette
0 Likes
Accepted solutions (1)
4,337 Views
11 Replies
Replies (11)
Message 2 of 12

_gile
Consultant
Consultant

Hi,

 

It looks like you don't have a good understanding on how an enum (PaletteSetStyles) with the Flags attribute works.

See this topic (last examples talk about the Flags atttribute).

 

autocadPaletteset.Style = PaletteSetStyles.ShowCloseButton    ' style is set to  8
autocadPaletteset.Style = PaletteSetStyles.ShowAutoHideButton ' style is reset to 2
autocadPaletteset.Style = PaletteSetStyles.Snappable          ' style is reset to 32
' finally style = 32 (only Snappable)

 

I don't know much about VB syntax, but the commented line in you code (using 'or') should work.

 

' set style to 8 or 2 or 32 = 42
autocadPaletteset.Style = PaletteSetStyles.ShowAutoHideButton Or _
    PaletteSetStyles.ShowCloseButton Or _
    PaletteSetStyles.Snappable


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 12

Anonymous
Not applicable

@_gile, I tried using or syntax which is equivalent to "|" in C# I think.

But it does not work.

Can you please through some more light?

 

Pankaj

0 Likes
Message 4 of 12

_gile
Consultant
Consultant

Oops!

I was editing my message when you replied.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 5 of 12

Anonymous
Not applicable

@_gile

As per post ,

 autocadPaletteset.Style = PaletteSetStyles.ShowAutoHideButton Or PaletteSetStyles.ShowCloseButton Or PaletteSetStyles.Snappable

 

Above statement should work right?

 

But it does not!!!

 

Please help

 

Thanks,

Pankaj

0 Likes
Message 6 of 12

_gile
Consultant
Consultant

If you have many: autocadPaletteset.Style = <something> successive expressions, the last one will overwrite all the previous settings.

 

You have to put all the settings in a single expression:

 

autocadPaletteset.Style = PaletteSetStyles.ShowCloseButton Or _
    PaletteSetStyles.ShowAutoHideButton Or _
    PaletteSetStyles.Snappable Or _
    PaletteSetStyles.ShowPropertiesMenu Or  _
    PaletteSetStyles.ShowTabForSingle 

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 7 of 12

Anonymous
Not applicable

@_gile

As I said earlier I tried this , even I copied your statemen tas it is... but still it does not work!!! 

 

Pankaj

0 Likes
Message 8 of 12

kerry_w_brown
Advisor
Advisor

@Anonymous wrote:

@_gile

As I said earlier I tried this , even I copied your statemen tas it is... but still it does not work!!! 

 

Pankaj


In a case like this, perhaps zip your solution and post it here so anyone who chooses to look at your issue won't have  to guess about possible causes for your errors.

 

 


// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
0 Likes
Message 9 of 12

_gile
Consultant
Consultant
Accepted solution

This works for me:

 

        <CommandMethod("myfirstwpfuc", CommandFlags.Session)>
        Public Sub myfirstudercontrol()
            Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
            Dim ed As Editor = doc.Editor
            Dim firstadd As Boolean = False

            If autocadPaletteset = Nothing Then
                autocadPaletteset = New PaletteSet("Modify attributes", New Guid("{773D4B0E-98A8-4AB4-9711-D80898DE40C0}"))
                autocadPaletteset.Style = PaletteSetStyles.ShowAutoHideButton Or
                    PaletteSetStyles.ShowCloseButton Or
                    PaletteSetStyles.Snappable Or
                    PaletteSetStyles.ShowPropertiesMenu Or
                    PaletteSetStyles.ShowTabForSingle

                Dim elementhost As ElementHost = New ElementHost
                elementhost.Dock = DockStyle.Fill
                Dim UC2 As New View_ATT
                elementhost.Child = UC2
                autocadPaletteset.Dock = DockSides.None
                autocadPaletteset.DockEnabled = DockSides.None
                'autocadPaletteset.AddVisual("Modify", UC2)
                autocadPaletteset.Add("P", elementhost)
                firstadd = True
                autocadPaletteset.Visible = True

            End If
        End Sub

WpfVb.png



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 10 of 12

Anonymous
Not applicable

I am using Autocad 2012 and it does not work for me. But I still accept as solution as it works for you may be soemthing wrong with my autocad.

 

Thanks for all your help!!

 

Pankaj

0 Likes
Message 11 of 12

_gile
Consultant
Consultant

Hi tried with An AutoCAD 2012 version with succes.

Can you post the code which don't work for you?



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 12 of 12

Anonymous
Not applicable

@_gile I am running same code which you posted in earlier post but , when I run command I am seeing this..

 

Capture.JPG

 

 

You can see palette is without close button. or any otehr button on left side

 

0 Likes