Click or drag to resize

Win Application

A simple SOWI Win Application based of SOWI Framework

This chapter present SOWI Win Application Parts

Environment
WPF

Microsoft Windows Presentation Foundation

Microsoft WPF web site...

Project
References

SOWI Components

Exception Handling

This example display an exception on windows dialog

C#
try
{
    // ...
}
catch (Exception ex)
{
    SOWIWin.Helper.Message.Show(ref ex);
}
Layout
ScreenSOWIWin Layout
Controller
View and Content

Default view is MainWindow.xaml

XAML
<Window x:Class="SOWIWin1.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:ribbonMain="clr-namespace:System.Windows.Controls.Ribbon;assembly=System.Windows.Controls.Ribbon"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:SOWIWin1"
        xmlns:my="clr-namespace:SOWIWin1.Settings"
        mc:Ignorable="d"
        Title="SOWIWin1" Height="auto" Width="auto" Icon="faviconSOWI.ico">
    <Window.Resources>
        <Style x:Key="StyleRibbonControlGroupLabel" TargetType="{x:Type Label}">
            <Setter Property="Padding" Value="2"/>
            <Setter Property="FontSize" Value="12"/>
        </Style>
        <Style x:Key="StyleRibbonControlGroupComboBox" TargetType="{x:Type ComboBox}">
            <Setter Property="FontSize" Value="12"/>
            <Setter Property="Padding" Value="2"/>
            <Setter Property="Background" Value="{x:Null}" />
            <Setter Property="BorderBrush" Value="{x:Null}" />
        </Style>
    </Window.Resources>
    <DockPanel>
        <ribbonMain:Ribbon Name="RibbonMain" DockPanel.Dock="Top" Visibility="Visible" Title="" ShowQuickAccessToolBarOnTop="False" WindowIconVisibility="Collapsed" IsManipulationEnabled="True" >
            <Ribbon.ApplicationMenu>
                <RibbonApplicationMenu CanAddToQuickAccessToolBarDirectly="True" Label="File" LargeImageSource="Images/faviconSOWI.ico" SmallImageSource="Images/faviconSOWI.ico">
                    <MenuItem Name="MenuItemOpen" Header="Open..." Click="MenuItemOpen_Click" />
                    <MenuItem Name="MenuItemExit" Header="Exit" Click="MenuItemExit_Click"/>
                </RibbonApplicationMenu>
            </Ribbon.ApplicationMenu>
            <RibbonTab Name="RibbonTabData" Header="Data">
                <RibbonGroup Name="RibbonGroupDatabase" Header="Database" >
                    <RibbonButton Name="RibbonButtonDataOpen" Label="Open..." LargeImageSource="Images/Database.png" Click="RibbonButtonDataOpen_Click" />
                </RibbonGroup>
                <RibbonGroup Header="Data Source">
                    <RibbonControlGroup>
                        <Label Content="Table:" Style="{DynamicResource StyleRibbonControlGroupLabel}" />
                        <ComboBox Name="ComboBoxDataTable" Style="{DynamicResource StyleRibbonControlGroupComboBox}"   />
                    </RibbonControlGroup>
                </RibbonGroup>
                <RibbonGroup Header="Data">
                    <RibbonButton Name="RibbonButtonDataLoad" Label="Load" LargeImageSource="Images/DataLoad.png" Click="RibbonButtonDataLoad_Click" />
                    <RibbonButton Name="RibbonButtonDataUpdate" Label="Update" LargeImageSource="Images/DataUpdate.png" Click="RibbonButtonDataUpdate_Click" />
                </RibbonGroup>
            </RibbonTab>
            <RibbonTab Name="RibbonTabEdit" Header="Edit">
                <RibbonGroup>
                    <RibbonButton Name="RibbonButtonEditCopy" Label="Copy" LargeImageSource="Images/DataCopy.png" Click="RibbonButtonEditCopy_Click"/>
                    <RibbonButton Name="RibbonButtonEditPaste" Label="Paste" LargeImageSource="Images/DataPaste.png" Click="RibbonButtonEditPaste_Click"/>
                </RibbonGroup>
            </RibbonTab>
            <RibbonTab Name="RibbonTabView" Header="View">
                <!--<RibbonGroup Name="RibbonGroupViewDataGrid" Header="DataGridView">
                    <RibbonCheckBox Name="RibbonCheckBoxViewDataGridWinValues" Label="Win values" IsChecked="{my:WinSetting RibbonCheckBoxViewDataGridWinValues}" 
                                    Click="RibbonCheckBoxViewDataGridWinValues_Click" />
                </RibbonGroup>-->
                <RibbonGroup Header="Font size">
                    <Slider x:Name="SliderViewFont" Width="75" Value="{my:WinSetting SliderViewFont}" Minimum="8" Maximum="30" IsSnapToTickEnabled="True"
                            TickFrequency="0.5" ValueChanged="SliderViewFont_ValueChanged" />
                    <TextBox x:Name="EditBoxViewFont" Width="75" Margin="0,10,0,0" Padding="2" Text="{Binding ElementName=SliderViewFont, Path=Value, Mode=TwoWay}" />
                </RibbonGroup>
            </RibbonTab>
        </ribbonMain:Ribbon>
        <Grid>
            <Grid Margin="0,0,0,17">
                <TabControl x:Name="TabMain" SelectionChanged="TabMain_SelectionChanged">
                    <!-- * pattern *
                    <TabItem Header="Organisation" >
                        <Frame Name="FrameOrganisation" NavigationUIVisibility="Hidden" />
                    </TabItem>
                    -->
                </TabControl>
            </Grid>
            <Grid>
                <StatusBar x:Name="StatusBarMain" VerticalAlignment="Bottom">
                    <Label Name="StatusBarFile" Content="{Binding}"/>
                    <Label Name="StatusBarServer" Content="{Binding}"/>
                    <Label Name="StatusBarDatanbank" Content="{Binding}"/>
                    <Label Name="StatusBarVersion" Content="{Binding}"/>
                </StatusBar>
            </Grid>
        </Grid>
    </DockPanel>
</Window>
Templates
See Also