Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

Images behind a form, transparent

I want to accomplish something like this:
[Image: n0Iuin9.jpg]
In a winform. Any ideas?
[Image: hf.png]

Rep for rep!
You could use a layered window to get the main layout form and then use GDI to replicate the rest. But, the best option would be to ditch winforms and go for wpf as that handle transparency very well. Its a decent learning curve if you tackle wpf, but it's worth it, good luck.  🤝
Accepting freelancing jobs ! PM me for more info !
Be the [BRAND NAME REMOVED] king ..
(Oct 13, 2018 07:44 PM)StaticCG Wrote:  I want to accomplish something like this:
[Image: n0Iuin9.jpg]
In a winform. Any ideas?

I do not see the reason why you do not do this in wpf...but here is one solution at speed in wpf which should be upgraded and improve for your needs.

[Image: RhLy92J.gif]

Code
<Style TargetType="Window" x:Key="StandardWindow">            
           <Setter Property="WindowStyle" Value="None"/>            
           <Setter Property="BorderThickness" Value="0" />
           <Setter Property="Margin" Value="0" />
           <Setter Property="AllowsTransparency" Value="true"/>
           <Setter Property="WindowChrome.WindowChrome">


               <Setter.Value>


                   <WindowChrome
                            CaptionHeight="0"
                            NonClientFrameEdges="None"
                            ResizeBorderThickness="5"
                            GlassFrameThickness="0"
                            CornerRadius="0"
                   
                             />


               </Setter.Value>


           </Setter>

           <Setter Property="Template">
               <Setter.Value>
                   
                       <ControlTemplate TargetType="{x:Type Window}">
                       <Grid>
                           
                           <Grid.RowDefinitions>
                               <RowDefinition Height="60"/>
                               <RowDefinition Height="*"/>
                           </Grid.RowDefinitions>
                           <Grid.ColumnDefinitions>
                               <ColumnDefinition Width="Auto"/>
                               <ColumnDefinition Width="*"/>
                           </Grid.ColumnDefinitions>
                           <Image Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" Source="pack://application:,,/Resources/logoass.png"/>

                           <Grid Margin="52,11,0,0"   Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2">
                               <Grid.Background>

                                   <ImageBrush   ImageSource="pack://application:,,/Resources/ass.png" Opacity="09"  />

                               </Grid.Background>
                               <Grid Margin="-15,-15,-15,-15">
                                   <Grid.Background>

                                       <ImageBrush   ImageSource="pack://application:,,/Resources/diploma-frame-png-3.png"   />

                                   </Grid.Background>
                               </Grid>
                           </Grid>
                           <Image Grid.Row="0" Grid.RowSpan="2" Source="pack://application:,,/Resources/game.png"/>
                           <Grid Margin="150,40,40,35"  Grid.Row="1"  Grid.Column="0" Grid.ColumnSpan="2">
                               <AdornerDecorator >
                                   <ContentPresenter />
                               </AdornerDecorator>
                           </Grid>
                       </Grid>
                   </ControlTemplate>
                 
               </Setter.Value>
           </Setter>
           <Setter Property="WindowStyle" Value="None"/>
       </Style>

Code
       Title="MainWindow" Height="460" Width="800" WindowStartupLocation="CenterScreen" MouseDown="Window_MouseDown"  Style="{StaticResource StandardWindow}">

Code
private void Window_MouseDown(object sender, MouseButtonEventArgs e)
       {
           if (Mouse.LeftButton == MouseButtonState.Pressed)
               this.DragMove();
       }
buy me a coffee eth:0x88621A52aa5Eb3b6503628369687111810186c58
(Oct 14, 2018 06:38 AM)itcorp Wrote:  I do not see the reason why you do not do this in wpf...but here is one solution at speed in wpf which should be upgraded and improve for your needs.

[Image: RhLy92J.gif]

Code
<Style TargetType="Window" x:Key="StandardWindow">            
           <Setter Property="WindowStyle" Value="None"/>            
           <Setter Property="BorderThickness" Value="0" />
           <Setter Property="Margin" Value="0" />
           <Setter Property="AllowsTransparency" Value="true"/>
           <Setter Property="WindowChrome.WindowChrome">


               <Setter.Value>


                   <WindowChrome
                            CaptionHeight="0"
                            NonClientFrameEdges="None"
                            ResizeBorderThickness="5"
                            GlassFrameThickness="0"
                            CornerRadius="0"
                   
                             />


               </Setter.Value>


           </Setter>

           <Setter Property="Template">
               <Setter.Value>
                   
                       <ControlTemplate TargetType="{x:Type Window}">
                       <Grid>
                           
                           <Grid.RowDefinitions>
                               <RowDefinition Height="60"/>
                               <RowDefinition Height="*"/>
                           </Grid.RowDefinitions>
                           <Grid.ColumnDefinitions>
                               <ColumnDefinition Width="Auto"/>
                               <ColumnDefinition Width="*"/>
                           </Grid.ColumnDefinitions>
                           <Image Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" Source="pack://application:,,/Resources/logoass.png"/>

                           <Grid Margin="52,11,0,0"   Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2">
                               <Grid.Background>

                                   <ImageBrush   ImageSource="pack://application:,,/Resources/ass.png" Opacity="09"  />

                               </Grid.Background>
                               <Grid Margin="-15,-15,-15,-15">
                                   <Grid.Background>

                                       <ImageBrush   ImageSource="pack://application:,,/Resources/diploma-frame-png-3.png"   />

                                   </Grid.Background>
                               </Grid>
                           </Grid>
                           <Image Grid.Row="0" Grid.RowSpan="2" Source="pack://application:,,/Resources/game.png"/>
                           <Grid Margin="150,40,40,35"  Grid.Row="1"  Grid.Column="0" Grid.ColumnSpan="2">
                               <AdornerDecorator >
                                   <ContentPresenter />
                               </AdornerDecorator>
                           </Grid>
                       </Grid>
                   </ControlTemplate>
                 
               </Setter.Value>
           </Setter>
           <Setter Property="WindowStyle" Value="None"/>
       </Style>

Code
       Title="MainWindow" Height="460" Width="800" WindowStartupLocation="CenterScreen" MouseDown="Window_MouseDown"  Style="{StaticResource StandardWindow}">

Code
private void Window_MouseDown(object sender, MouseButtonEventArgs e)
       {
           if (Mouse.LeftButton == MouseButtonState.Pressed)
               this.DragMove();
       }

Thanks!
[Image: hf.png]

Rep for rep!
(Oct 14, 2018 08:48 AM)StaticCG Wrote:  Thanks!

You are welcome, anytime.
buy me a coffee eth:0x88621A52aa5Eb3b6503628369687111810186c58


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by _UnderDogMay 28, 2017 05:36 AM 2 482 May 28, 2017 05:36 AM
Last Post: _UnderDog
[C#] by Ðr1psNov 9, 2015 03:56 PM 19 416 Nov 9, 2015 03:56 PM
Last Post: Ðr1ps
[.NET] by WildElephantApr 21, 2015 10:48 AM 7 177 Apr 21, 2015 10:48 AM
Last Post: nuk