Hexagon window

Updated ddanbe 0 Tallied Votes 951 Views Share

Yes, WPF. The learning curve is steep, but what amazing things you can do with it!
Look at this hexagon window for instance. Serves no purpose in a business environment I guess, but in a gaming situation it could work. For me, it was just fun to get this up and running.
I’m using VS 2017. Start up a new WPF window project. Call it HexagonWindow and fill in the missing code.
I still don’t understand all the intricacies of WPF, I’m just a mere mortal human being, but my quest on the subject is ongoing. Why don’t some of you get there feet wet and give it a try! Tutorials can be found on a site starting with the letter G.

Window x:Class="HexagonWindow.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
            xmlns:local="clr-namespace:HexagonWindow"
            mc:Ignorable="d"
            Title="Hexa" Height="300" Width="300" WindowStyle="None"
            AllowsTransparency="True" Background="Transparent" MouseLeftButtonDown="Window_MouseLeftButtonDown">
        <Grid>
            <!--Points="100,0 200,0 300,100 300,200 200,300 100,300 0,200 0,100" use these points for octagon window-->
            <Polygon  Points="75,0 225,0 300,150 225,300 75,300 0,150"  Stroke="Red" StrokeThickness="3" Fill="LightBlue"></Polygon>
            <Button Content = "X" Height="20" Width="20" Margin="150,0,0,0" Click="Button_Click" VerticalAlignment="Top"></Button>
            <StackPanel Height="80" Width="240">
                <TextBlock HorizontalAlignment="Center" Margin="5" Height="20" Text="He! I'm a hexagonal window!"></TextBlock>
                <TextBlock HorizontalAlignment="Center" Text="Drag me, by clicking the left mouse button"></TextBlock>
            </StackPanel>
        </Grid>
    </Window>


    using System.Windows;
    using System.Windows.Input;
    
    namespace HexagonWindow
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// MainWindow is the hexagon window here
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
            }
    
            private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
            {
                DragMove();
            }
    
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                this.Close();
            }
        }
    }
ddanbe 2,724 Professional Procrastinator Featured Poster

Oops, this should have been a code snippet. Apparently I forgot to mark it as such. :(

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Moved to code snippets. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.