<Window x:Class="OPSCallCenterCRM.View.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:tb="clr-namespace:Hardcodet.Wpf.TaskbarNotification;assembly=Hardcodet.Wpf.TaskbarNotification"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:ViewModel="clr-namespace:OPSCallCenterCRM.ViewModel" mc:Ignorable="d"
        Title="Call Center CRM"
        Closing="WindowClosing" Height="800" WindowStartupLocation="CenterScreen" WindowStyle="None" AllowsTransparency="True">
    <Window.DataContext>
        <ViewModel:MainViewModel/>
    </Window.DataContext>
    <Window.Resources></Window.Resources>

    <DockPanel VerticalAlignment="Stretch"
               Background="#1c4027"
               LastChildFill="True">
        <Grid Margin="0"
              DockPanel.Dock="Top"
              x:Name="MainDockpanel">
            <DockPanel VerticalAlignment="Top">
                <Grid DockPanel.Dock="Top"
                      Height="32">
                    <Grid.Background>
                        <LinearGradientBrush EndPoint="0.5,1"
                                             StartPoint="0.5,0">
                            <GradientStop Color="#FF235631"
                                          Offset="0" />
                            <GradientStop Color="#FF1B3825"
                                          Offset="1" />
                        </LinearGradientBrush>
                    </Grid.Background>
                    <DockPanel LastChildFill="True"
                               x:Name="DragableArea"
                               MouseDown="DragableGridMouseDown"
                               MouseMove="DragableGrid_OnMouseMove"
                               DockPanel.Dock="Top">
                        <DockPanel DockPanel.Dock="Left">
                            <Button x:Name="WindowIcon"
                                    RenderOptions.BitmapScalingMode="HighQuality"
                                    Content=""
                                    DockPanel.Dock="Left"
                                    Height="20"
                                    Margin="10,0,5,0"
                                    Style="{DynamicResource WindowIcon}"
                                    Click="WindowsIcon_Click">
                                <Button.ContextMenu>
                                    <ContextMenu x:Name="WindowIconMenu">
                                        <MenuItem x:Name="RestoreWindowSize"
                                                  Header="Restore"
                                                  Click="RestoreWindowSize_Click">
                                            <MenuItem.Icon>
                                                <TextBlock Text="2"
                                                           FontFamily="Webdings"
                                                           Foreground="Gray" />
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <MenuItem x:Name="MinimizedWindow"
                                                  Header="Minimize"
                                                  Click="MinimizeWindow_Click">
                                            <MenuItem.Icon>
                                                <TextBlock Text="0"
                                                           FontFamily="Webdings"
                                                           Foreground="Gray" />
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <MenuItem x:Name="MaximizeWindow"
                                                  Header="Maximize"
                                                  Click="MaximizeWindow_Click">
                                            <MenuItem.Icon>
                                                <TextBlock Text="1"
                                                           FontFamily="Webdings"
                                                           Foreground="Gray" />
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <Separator />
                                        <MenuItem Header="Close   Alt+F4"
                                                  x:Name="CloseWindow"
                                                  Click="CloseWindow_Click">
                                            <MenuItem.Icon>
                                                <TextBlock Text="r"
                                                           FontFamily="Webdings"
                                                           Foreground="Gray"
                                                           FontWeight="Bold" />
                                            </MenuItem.Icon>
                                        </MenuItem>
                                    </ContextMenu>
                                </Button.ContextMenu>
                            </Button>
                            <Image  Source="/OPSCallCenterCRM;component/Styles/ozeki_logo.png"
                                    Height="16"
                                    RenderOptions.BitmapScalingMode="HighQuality" />
                            <Label Content="Call Center CRM"
                                   VerticalContentAlignment="Center"
                                   FontFamily="Arial"
                                   FontSize="14"
                                   FontWeight="Normal"
                                   Foreground="#bbc4bc"
                                   DockPanel.Dock="Left" />
                        </DockPanel>
                        <TextBlock Width="422"
                                   FontFamily="Arial"
                                   FontSize="14"
                                   FontWeight="Normal"
                                   Foreground="#bbc4bc"
                                   VerticalAlignment="Center"
                                   Margin="0,8" />
                        <TextBlock DockPanel.Dock="Left"
                                   VerticalAlignment="Stretch" />
                    </DockPanel>

                    <DockPanel HorizontalAlignment="Right"
                               VerticalAlignment="Center"
                               DockPanel.Dock="Right"
                               Margin="0,0,5,0">
                        <TextBlock x:Name="MinimizeButton"
                                   Text="0"
                                   FontFamily="Webdings"
                                   Foreground="Gray"
                                   Margin="5,0,0,0"
                                   HorizontalAlignment="Right"
                                   VerticalAlignment="Top"
                                   MouseLeftButtonUp="MinimizeButtonMouseLeftButtonUp"
                                   MouseEnter="MinimizeButton_OnMouseEnter"
                                   MouseLeave="MinizeButton_MouseLeave" />
                        <TextBlock x:Name="MaximizeButton"
                                   Text="1"
                                   FontFamily="Webdings"
                                   Visibility="Collapsed"
                                   Foreground="Gray"
                                   Margin="5,0,0,0"
                                   HorizontalAlignment="Right"
                                   VerticalAlignment="Top"
                                   MouseLeftButtonUp="MaximizeButtonMouseLeftButtonUp"
                                   MouseEnter="MaximizeButton_OnMouseEnter"
                                   MouseLeave="MaximizeButton_MouseLeave" />
                        <TextBlock x:Name="ChangeViewButton"
                                   Text="2"
                                   FontFamily="Webdings"
                                   Foreground="Gray"
                                   Margin="5,0,0,0"
                                   VerticalAlignment="Top"
                                   HorizontalAlignment="Right"
                                   MouseLeftButtonUp="ChangeViewButtonMouseLeftButtonUp"
                                   MouseEnter="ChangeViewButton_OnMouseEnter"
                                   MouseLeave="ChangeViewButton_MouseLeave" />
                        <TextBlock x:Name="CloseButton"
                                   Text="r"
                                   FontFamily="Webdings"
                                   Foreground="Gray"
                                   Margin="5,0,8,0"
                                   HorizontalAlignment="Right"
                                   VerticalAlignment="Top"
                                   MouseLeftButtonUp="CloseButtonMouseLeftButtonUp"
                                   MouseEnter="CloseButton_OnMouseEnter"
                                   MouseLeave="CloseButton_MouseLeave" />
                    </DockPanel>

                </Grid>
                <DockPanel DockPanel.Dock="Top">
                    <Menu x:Name="UpMenu"
                          DockPanel.Dock="Top">
                        <Menu.Background>
                            <LinearGradientBrush EndPoint="0.5,1"
                                                 StartPoint="0.5,0">
                                <GradientStop Color="#FF1A2F21"
                                              Offset="0" />
                                <GradientStop Color="#FF20442A"
                                              Offset="1" />
                            </LinearGradientBrush>
                        </Menu.Background>

                        <MenuItem Header="_File" Style="{DynamicResource menutitles}" Foreground="White">
                            <MenuItem Header="_Add"
                                      Click="AddEntry_OnClick" Style="{DynamicResource submenutitles}"></MenuItem>
                            <Separator />
                            <MenuItem Header="_Exit"
                                      Click="Exit_OnClick" Style="{DynamicResource submenutitles}"/>
                        </MenuItem>
                        <MenuItem Header="_Help" Style="{DynamicResource menutitles}" Foreground="White">
                            <MenuItem Header="_Visit to our Home Page"
                                      Command="{Binding HomePage}" Style="{DynamicResource submenutitles}"/>
                            <MenuItem Header="_About" Style="{DynamicResource submenutitles}"
                                      Command="{Binding About}">
                            </MenuItem>
                        </MenuItem>
                    </Menu>
                </DockPanel>
                <DockPanel DockPanel.Dock="Top"
                           Height="47">
                    <DockPanel.Background>
                        <ImageBrush ImageSource="/Styles\broadcast_menu_bg.png">
                        </ImageBrush>
                    </DockPanel.Background>
                    <DockPanel Height="25"
                               
                               LastChildFill="False"
                               DockPanel.Dock="Top">
                        <Label Content="Search:" Margin="10,0,0,0"></Label>
                        <TextBox DockPanel.Dock="Left"
                                 Width="200"
                                 Margin="5,0,0,0"
                                 Text="{Binding Filter, Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged}"></TextBox>
                        <Button DockPanel.Dock="Right"
                                Width="80"
                                Margin="0,0,5,0"
                                Content="Add"
                                Click="AddEntry_OnClick"></Button>
                    </DockPanel>
                </DockPanel>
            </DockPanel>
        </Grid>
        
        <DockPanel Margin="5,0,5,5"
                   Background="#dceadd">
            <Grid>
                <DockPanel Margin="5">
                    
                    
                    <DataGrid ItemsSource="{Binding CrmEntries}"
                              DockPanel.Dock="Top"
                              MinHeight="200"
                              MaxHeight="250"
                              CanUserAddRows="False"
                              AutoGenerateColumns="False"
                              LoadingRow="DataGridLoadingRow"
                              SelectionMode="Single"
                              SelectedItem="{Binding SelectedCrmEntry, Mode=TwoWay}"
                              ColumnWidth="*">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="Name"
                                                IsReadOnly="True"
                                                Width="0.75*">
                                <DataGridTextColumn.Binding>
                                    <MultiBinding StringFormat="{}{1}, {0}">
                                        <Binding Path="FirstName" />
                                        <Binding Path="LastName" />
                                    </MultiBinding>
                                </DataGridTextColumn.Binding>
                            </DataGridTextColumn>
                            <DataGridTextColumn Header="Phone Number"
                                                Binding="{Binding PhoneNumber}"
                                                IsReadOnly="True"
                                                Width="0.5*" />
                            <DataGridTextColumn Header="E-mail"
                                                Binding="{Binding Email}"
                                                IsReadOnly="True"
                                                Width="0.75*"></DataGridTextColumn>
                            <DataGridTextColumn Header="Job Title"
                                                Binding="{Binding JobTitle}"
                                                IsReadOnly="True"
                                                Width="0.5*"></DataGridTextColumn>
                            <DataGridTextColumn Header="Fax Number"
                                                Binding="{Binding FaxNumber}"
                                                IsReadOnly="True"
                                                Width="0.5*"></DataGridTextColumn>
                        </DataGrid.Columns>
                    </DataGrid>
                    <Separator DockPanel.Dock="Top"
                               Height="10" />
                    <StackPanel Background="#FF6C9B6C"
                                DockPanel.Dock="Top">
                        <Label Content="Customer Credentials"
                               FontSize="18" />
                        <StackPanel Orientation="Horizontal">
                            <Label Content="First Name"></Label>
                            <TextBox Width="150"
                                     Height="20"
                                     Margin="15,0,0,0"
                                     Text="{Binding SelectedCrmEntry.FirstName}"></TextBox>
                            <Label Content="Business"
                                   Margin="15,0,0,0"></Label>
                            <TextBox Width="150"
                                     Height="20"
                                     Margin="34,0,0,0"
                                     Text="{Binding SelectedCrmEntry.BusinessName}"></TextBox>
                            <Label Content="Category"
                                   Margin="15,0,0,0"></Label>
                            <TextBox Width="150"
                                     Height="20"
                                     Text="{Binding SelectedCrmEntry.Category}"></TextBox>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <Label Content="Middle Name"></Label>
                            <TextBox Width="150"
                                     Height="20"
                                     Text="{Binding SelectedCrmEntry.MiddleName}"></TextBox>
                            <Label Content="Fax"
                                   Margin="15,0,0,0"></Label>
                            <TextBox Width="150"
                                     Height="20"
                                     Margin="62,0,0,0"
                                     Text="{Binding SelectedCrmEntry.FaxNumber}"></TextBox>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <Label Content="Last Name"></Label>
                            <TextBox Width="150"
                                     Height="20"
                                     Margin="16,0,0,0"
                                     Text="{Binding SelectedCrmEntry.LastName}"></TextBox>
                            <Label Content="E-mail"
                                   Margin="15,0,0,0"></Label>
                            <TextBox Width="150"
                                     Height="20"
                                     Margin="46,0,0,0"
                                     Text="{Binding SelectedCrmEntry.Email}"></TextBox>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <Label Content="Job Title"></Label>
                            <TextBox Width="150"
                                     Height="20"
                                     Margin="27,0,0,0"
                                     Text="{Binding SelectedCrmEntry.JobTitle}"></TextBox>
                            <Label Content="Phone Number"
                                   Margin="15,0,0,0"></Label>
                            <TextBox Width="150"
                                     Height="20"
                                     Text="{Binding SelectedCrmEntry.PhoneNumber}"></TextBox>
                            <Button Content="Modify"
                                    Margin="48,0,0,5"
                                    Width="60"
                                    Command="{Binding ModifySelectedCrmEntry}" Style="{DynamicResource zoldgomb}"></Button>
                            <Button Content="Revert"
                                    Margin="5,0,0,5"
                                    Width="60"
                                    Command="{Binding RevertSelectedCrmEntry}" Style="{DynamicResource zoldgomb}"></Button>
                            <Button Content="Delete"
                                    Width="60"
                                    Margin="5,0,0,5"
                                    Command="{Binding Delete}" Style="{DynamicResource zoldgomb}"></Button>
                        </StackPanel>
                    </StackPanel>
                    <Separator Height="10"
                               DockPanel.Dock="Top"></Separator>
                    <Grid  DockPanel.Dock="Top">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="7*" />
                            <ColumnDefinition Width="13*" />
                        </Grid.ColumnDefinitions>
                        <DockPanel Background="#FF6C9B6C"
                                   Margin="0,0,5,0">
                            <Label Content="Call History"
                                   FontSize="18"
                                   DockPanel.Dock="Top" />
                            <DataGrid ItemsSource="{Binding SelectedCrmEntry.CallHistoryEntries}"
                                      AutoGenerateColumns="False"
                                      LoadingRow="DataGridLoadingRow"
                                      CanUserAddRows="False"
                                      SelectionMode="Single"
                                      Width="auto"
                                      DockPanel.Dock="Top">
                                <DataGrid.Columns>
                                    <DataGridTextColumn Header="Date"
                                                        Binding="{Binding StartDate}"
                                                        IsReadOnly="True"
                                                        Width="0.9*"></DataGridTextColumn>
                                    <DataGridTextColumn Header="Caller"
                                                        Binding="{Binding Caller}"
                                                        IsReadOnly="True"
                                                        Width="0.7*"></DataGridTextColumn>
                                    <DataGridTextColumn Header="Callee"
                                                        Binding="{Binding Callee}"
                                                        IsReadOnly="True"
                                                        Width="0.7*"></DataGridTextColumn>
                                    <DataGridTextColumn Header="Call Length"
                                                        Binding="{Binding CallLength}"
                                                        IsReadOnly="True"
                                                        Width="*"></DataGridTextColumn>
                                </DataGrid.Columns>
                            </DataGrid>
                        </DockPanel>
                        <DockPanel Grid.Column="1"
                                   Background="#FF6C9B6C"
                                   Margin="5,0,0,0">
                            <Label Content="Customer Notes"
                                   FontSize="18"
                                   DockPanel.Dock="Top" />

                            <StackPanel Orientation="Horizontal"
                                        HorizontalAlignment="Right"
                                        DockPanel.Dock="Bottom"
                                        Margin="0,5,0,5">
                                <Button Content="Add"
                                        Margin="5,0,5,0"
                                        Command="{Binding AddNote}" Style="{DynamicResource zoldgomb}" Width="60" Height="30"></Button>
                                <Button Content="Delete"
                                        Margin="5,0,5,0"
                                        Command="{Binding RemoveNote}" Style="{DynamicResource zoldgomb}" Width="60" Height="30"></Button>
                            </StackPanel>
                            <TextBox Margin="8,5,8,0"
                                     Text="{Binding NewCrmEntryNote.Note, Mode=TwoWay}"
                                     DockPanel.Dock="Bottom"></TextBox>
                            <ListBox ItemsSource="{Binding SelectedCrmEntry.Notes}"
                                     SelectionMode="Single"
                                     ScrollViewer.VerticalScrollBarVisibility="Visible"
                                     SelectedItem="{Binding SelectedCrmEntryNote}"
                                     DockPanel.Dock="Top" Margin="3,0,3,0"></ListBox>
                        </DockPanel>
                    </Grid>
                </DockPanel>

                <tb:TaskbarIcon x:Name="TaskBarIcon"
                                MenuActivation="RightClick"
                                IconSource="/OPSCallCenterCRM;component/Resources/call_center_client.ico">
                    <tb:TaskbarIcon.ContextMenu>
                        <ContextMenu x:Name="ContextMenu">
                            <MenuItem Header="About"
                                      Command="{Binding About}" />
                            <MenuItem Header="Close"
                                      Click="Exit_OnClick" />
                        </ContextMenu>
                    </tb:TaskbarIcon.ContextMenu>
                </tb:TaskbarIcon>
            </Grid>
        </DockPanel>
        </DockPanel>

</Window>
