<?xml version="1.0" encoding="utf-8"?>
<UserControl x:Class="CustomDialogs.EditAppointmentControl" Loaded="EditAppointmentControl_Loaded" x:Name="root" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml">
    <Grid x:Name="LayoutRoot" BindingValidationError="LayoutRoot_BindingValidationError">
        <Grid.Resources>
            <c1:ImportanceEnumMemberConverter x:Key="ImportanceEnumMemberConverter" />
            
            <SolidColorBrush x:Key="BorderBrush" Color="#3F000000" />
 
            <DataTemplate x:Key="BaseObjectItemPictTextTemplate">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Border Name="imageBorder" BorderBrush="Black" BorderThickness="1" CornerRadius="2" Height="15" Width="15" Background="{Binding Brush.Brush}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="3">
                    </Border>
                    <TextBlock Grid.Column="1" Text="{Binding Text}" VerticalAlignment="Center" />
                </Grid>
            </DataTemplate>
            
            <c1:C1_Schedule_EditAppointment x:Key="C1_Schedule_EditAppointment" />
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Border BorderThickness="0,0,0,1" BorderBrush="{StaticResource BorderBrush}">
            <Border.Background>
                <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
                    <LinearGradientBrush.GradientStops>
                        <GradientStop Color="#26000000" Offset="1" />
                    </LinearGradientBrush.GradientStops>
                </LinearGradientBrush>
            </Border.Background>
            <StackPanel Grid.Row="0" Orientation="Horizontal" Margin="10,5">
                <Button x:Name="PART_DialogSaveButton" Click="PART_DialogSaveButton_Click" ToolTipService.ToolTip="{Binding PART_DialogSaveButton_Tooltip, Source={StaticResource C1_Schedule_EditAppointment}}" Margin="0,0,5,0">
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                        <Image Height="16" Width="16">
                            <Image.Source>
                                <BitmapImage UriSource="/C1.Silverlight.Schedule.5;component/Resources/save.png" />
                            </Image.Source>
                        </Image>
                        <TextBlock Margin="3,0,0,0" Text="{Binding PART_DialogSaveButton_AccessText, Source={StaticResource C1_Schedule_EditAppointment}}" VerticalAlignment="Center" />
                    </StackPanel>
                </Button>
                <Button x:Name="saveAsButton" Margin="0,0,5,0" Click="saveAsButton_Click" c1:CommandExtensions.CommandTarget="{Binding ParentCollection.ParentStorage.ScheduleStorage.Scheduler}" c1:CommandExtensions.CommandParameter="{Binding}" c1:CommandExtensions.Command="c1:C1Scheduler.ExportCommand" ToolTipService.ToolTip="{Binding saveAsButton_Tooltip, Source={StaticResource C1_Schedule_EditAppointment}}">
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                        <TextBlock Margin="3,0,0,0" Text="{Binding saveAsButton_AccessText, Source={StaticResource C1_Schedule_EditAppointment}}" />
                    </StackPanel>
                </Button>
				<Rectangle Width="0.5" Fill="{StaticResource BorderBrush}" Margin="0,0,5,0" />
                <Button IsTabStop="False" x:Name="reccButton" Margin="0,0,5,0" c1:CommandExtensions.CommandTarget="{Binding ParentCollection.ParentStorage.ScheduleStorage.Scheduler}" c1:CommandExtensions.CommandParameter="{Binding ElementName=root}" c1:CommandExtensions.Command="c1:C1Scheduler.EditRecurrenceDialogCommand" ToolTipService.ToolTip="{Binding reccButton_ToolTip, Source={StaticResource C1_Schedule_EditAppointment}}">
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                        <Image Height="16" Width="16">
                            <Image.Source>
                                <BitmapImage UriSource="/C1.Silverlight.Schedule.5;component/Resources/occurrence.png" />
                            </Image.Source>
                        </Image>
                        <TextBlock Margin="3,0,0,0" Text="{Binding reccButton_AccessText, Source={StaticResource C1_Schedule_EditAppointment}}" VerticalAlignment="Center" />
                    </StackPanel>
                </Button>
				<Rectangle Width="0.5" Fill="{StaticResource BorderBrush}" Margin="0,0,5,0" />    
                <ToggleButton Name="highImportance" IsTabStop="False" IsChecked="{Binding Path=Importance, Mode=TwoWay,       Converter={StaticResource ImportanceEnumMemberConverter}, ConverterParameter=High}" ToolTipService.ToolTip="{Binding highImportance_ToolTip, Source={StaticResource C1_Schedule_EditAppointment}}">
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                        <Image Height="16" Width="16">
                            <Image.Source>
                                <BitmapImage UriSource="/C1.Silverlight.Schedule.5;component/Resources/importance_up.png" />
                            </Image.Source>
                        </Image>
                    </StackPanel>
                </ToggleButton>
                <ToggleButton Name="lowImportance" IsTabStop="False" Margin="5,0" IsChecked="{Binding Path=Importance, Mode=TwoWay,             Converter={StaticResource ImportanceEnumMemberConverter}, ConverterParameter=Low}" ToolTipService.ToolTip="{Binding lowImportance_ToolTip, Source={StaticResource C1_Schedule_EditAppointment}}">
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                        <Image Height="16" Width="16">
                            <Image.Source>
                                <BitmapImage UriSource="/C1.Silverlight.Schedule.5;component/Resources/importance_down.png" />
                            </Image.Source>
                        </Image>
                    </StackPanel>
                </ToggleButton>
				<Rectangle Width="0.5" Fill="{StaticResource BorderBrush}" Margin="0,0,5,0" />
                <Button Name="deleteButton" IsTabStop="False" c1:CommandExtensions.CommandTarget="{Binding ParentCollection.ParentStorage.ScheduleStorage.Scheduler}" c1:CommandExtensions.CommandParameter="{Binding Tag}" c1:CommandExtensions.Command="c1:C1Scheduler.DeleteAppointmentCommand" ToolTipService.ToolTip="{Binding deleteButton_ToolTip, Source={StaticResource C1_Schedule_EditAppointment}}">
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                        <Image Height="16" Width="16">
                            <Image.Source>
                                <BitmapImage UriSource="/C1.Silverlight.Schedule.5;component/Resources/delete.png" />
                            </Image.Source>
                        </Image>
                    </StackPanel>
                </Button>
            </StackPanel>
        </Border>
        <Border Grid.Row="1" BorderBrush="{StaticResource BorderBrush}" Margin="5,5,5,0" Padding="5" BorderThickness="0,0,0,0.5">
            <Grid Margin="5, 0, 5, 5">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <!-- Subject -->
                <TextBlock VerticalAlignment="Center" Margin="10,2,0,2" HorizontalAlignment="Left" Text="{Binding subject, Source={StaticResource C1_Schedule_EditAppointment}}" />
                <TextBox x:Name="subject" TabIndex="0" Padding="2" Text="{Binding Subject, Mode=TwoWay}" TextChanged="subject_TextChanged" Grid.Column="1" Grid.ColumnSpan="3" MaxLength="255" VerticalAlignment="Center" Margin="10,2,0,2" />
                <!-- Location -->
                <TextBlock VerticalAlignment="Center" Margin="10,2,0,2" Grid.Row="1" HorizontalAlignment="Left" Text="{Binding location, Source={StaticResource C1_Schedule_EditAppointment}}" />
                <TextBox TabIndex="1" x:Name="location" Text="{Binding Location, Mode=TwoWay}" Grid.Column="1" Grid.Row="1" MaxLength="255" VerticalAlignment="Center" Margin="10,2,0,2" />
                <!-- Label -->
                <TextBlock VerticalAlignment="Center" Margin="10,2,0,2" Grid.Row="1" Grid.Column="2" HorizontalAlignment="Left" Text="{Binding label, Source={StaticResource C1_Schedule_EditAppointment}}" />
                <ComboBox Grid.Row="1" Grid.Column="3" TabIndex="2" x:Name="label" ItemTemplate="{StaticResource BaseObjectItemPictTextTemplate}" ItemsSource="{Binding ParentCollection.ParentStorage.ScheduleStorage.LabelStorage.Labels}" SelectedItem="{Binding Path=Label, Mode=TwoWay}" MinWidth="140" Padding="0" VerticalAlignment="Center" Margin="10,2,0,2" />
           </Grid>
        </Border>
        <!-- Start/End time -->
        <Border Grid.Row="2" BorderBrush="{StaticResource BorderBrush}" Margin="5" Padding="5" BorderThickness="0,0,0,0.5">
            <Grid Margin="0,0,0,5">
                <Grid Name="startEndPanel">
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <!-- Start -->
                    <TextBlock VerticalAlignment="Center" Margin="10,2,0,2" Grid.Row="0" HorizontalAlignment="Left" Text="{Binding startTime, Source={StaticResource C1_Schedule_EditAppointment}}" />
                    <c1:C1DateTimePicker x:Name="startCalendar" VerticalAlignment="Center" Margin="10,2,0,2" Padding="1" IsTabStop="False" Grid.Column="1" TimeFormat="ShortTime" DateFormat="Long" TimeIncrement="0:15" FirstDayOfWeek="{Binding Path=ParentCollection.ParentStorage.ScheduleStorage.Scheduler.CalendarHelper.WeekStart}" DateTime="{Binding Start, Mode=TwoWay}" />
                    <!-- End -->
                    <TextBlock VerticalAlignment="Center" Margin="10,2,0,2" Grid.Row="1" HorizontalAlignment="Left" Text="{Binding endTime, Source={StaticResource C1_Schedule_EditAppointment}}" />
                    <c1:C1DateTimePicker x:Name="endCalendar" VerticalAlignment="Center" Margin="10,2,0,2" Padding="1" DateTimeChanged="endCalendar_DateTimeChanged" FirstDayOfWeek="{Binding Path=ParentCollection.ParentStorage.ScheduleStorage.Scheduler.CalendarHelper.WeekStart}" TimeFormat="ShortTime" DateFormat="Long" TimeIncrement="0:15" Grid.Column="1" Grid.Row="1" />
                    <!-- All Day -->
                    <CheckBox Grid.Column="2" HorizontalAlignment="Left" x:Name="chkAllDay" Checked="chkAllDay_Checked" Unchecked="chkAllDay_Unchecked" VerticalAlignment="Center" Margin="10,2,0,2" IsChecked="{Binding AllDayEvent, Mode=TwoWay}" Content="{Binding allDayEvent, Source={StaticResource C1_Schedule_EditAppointment}}" />
               </Grid>
                <!-- recurrence info -->
                <StackPanel Name="recurrenceInfoPanel" Visibility="Collapsed" Orientation="Horizontal">
                    <TextBlock Text="{Binding recurrence, Source={StaticResource C1_Schedule_EditAppointment}}" />
                    <TextBlock Name="recDescription" Text="{Binding PatternDescription, ElementName=root}" />
                </StackPanel>
            </Grid>
        </Border>
        <StackPanel Grid.Row="3" Orientation="Horizontal" Margin="10,0">
            <CheckBox x:Name="reminderSet" IsChecked="{Binding ReminderSet, Mode=TwoWay}" VerticalAlignment="Center" Margin="10,2,0,2" Content="{Binding reminderSet, Source={StaticResource C1_Schedule_EditAppointment}}" />
            <c1:C1TimeEditor Format="TimeSpan" Padding="1" VerticalAlignment="Center" Margin="10,2,0,2" IsEnabled="{Binding Path=IsChecked, ElementName=reminderSet}" Maximum="14.00:00" CycleChangesOnBoundaries="False" Increment="00:05" AllowNull="False" Minimum="0:00" Value="{Binding Path=ReminderTimeBeforeStart, Mode=TwoWay}" />
            <TextBlock VerticalAlignment="Center" Margin="30, 2, 0, 2" Text="{Binding showTimeAs, Source={StaticResource C1_Schedule_EditAppointment}}" />
            <ComboBox x:Name="status" ItemTemplate="{StaticResource BaseObjectItemPictTextTemplate}" ItemsSource="{Binding        ParentCollection.ParentStorage.ScheduleStorage.StatusStorage.Statuses}" SelectedItem="{Binding Path=BusyStatus, Mode=TwoWay}" MinWidth="140" Padding="0" VerticalAlignment="Center" Margin="10,2,0,2" />
        </StackPanel>
        <Border Grid.Row="4" Margin="5" Padding="5">
            <TextBox x:Name="body" Text="{Binding Body, Mode=TwoWay}" TextWrapping="Wrap" MaxHeight="240" VerticalScrollBarVisibility="Auto" AcceptsReturn="true" />
        </Border>
        <Border Grid.Row="5" Margin="5" Padding="5">
            <c1:C1UniformGrid x:Name="editGrid" Columns="2">
                <!-- Resources -->
                <c1:EditCollectionControl x:Name="resources" ButtonText="{Binding resourcesButton, Source={StaticResource C1_Schedule_EditAppointment}}" LabelText="{Binding resourceLabel, Source={StaticResource C1_Schedule_EditAppointment}}" />
                <!-- Categories -->
                <c1:EditCollectionControl x:Name="categories" ButtonText="{Binding categoriesButton, Source={StaticResource C1_Schedule_EditAppointment}}" LabelText="{Binding categoryLabel, Source={StaticResource C1_Schedule_EditAppointment}}" />
                <!-- Contacts -->
                <c1:EditCollectionControl x:Name="contacts" ButtonText="{Binding contactsButton, Source={StaticResource C1_Schedule_EditAppointment}}" LabelText="{Binding contactLabel, Source={StaticResource C1_Schedule_EditAppointment}}" />

                <CheckBox IsChecked="{Binding Path=Private, Mode=TwoWay}" VerticalAlignment="Center" HorizontalAlignment="Right" Content="{Binding private_, Source={StaticResource C1_Schedule_EditAppointment}}" />
            </c1:C1UniformGrid>
        </Border>
    </Grid>
</UserControl>