<UserControl x:Class="CustomDialogs.EditAppointmentControl" Loaded="EditAppointmentControl_Loaded" x:Name="root" 
             Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" 
             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">
        <Grid.Resources>
            <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>

        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <ToolBarTray Grid.Row="0">
            <ToolBar Band="1" BandIndex="1" IsTabStop="False">
                <Button x:Name="PART_DialogSaveButton" IsTabStop="False" Click="PART_DialogSaveButton_Click" Margin="0,0,5,0">
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                        <Image Height="{DynamicResource {x:Static SystemParameters.SmallIconHeightKey}}" Width="{DynamicResource {x:Static SystemParameters.SmallIconWidthKey}}" Source="/C1.WPF.Schedule.4;component/Resources/save.png" />
                        <TextBlock Margin="3,0,0,0" VerticalAlignment="Center">
								<AccessText>
									<AccessText.Text>
										<c1:SchedulerLoc Key="EditAppointment:PART_DialogSaveButton_AccessText" DefaultValue="_Save and Close" />
									</AccessText.Text>
								</AccessText>
                        </TextBlock>
                    </StackPanel>
                    <Button.ToolTip>
                        <TextBlock>
								<TextBlock.Text>
									<c1:SchedulerLoc Key="EditAppointment:PART_DialogSaveButton_Tooltip" DefaultValue="Save and Close" />
								</TextBlock.Text>
                        </TextBlock>
                    </Button.ToolTip>
                </Button>
                <Button x:Name="saveAsButton" IsTabStop="False" Margin="0,0,5,0" Click="saveAsButton_Click" CommandTarget="{Binding ParentCollection.ParentStorage.ScheduleStorage.Scheduler}" CommandParameter="{Binding}" Command="c1:C1Scheduler.ExportCommand">
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                        <TextBlock Margin="3,0,0,0">
								<AccessText>
									<AccessText.Text>
										<c1:SchedulerLoc Key="EditAppointment:saveAsButton_AccessText" DefaultValue="Save _As..." />
									</AccessText.Text>
								</AccessText>
                        </TextBlock>
                    </StackPanel>
                    <Button.ToolTip>
                        <TextBlock>
								<TextBlock.Text>
									<c1:SchedulerLoc Key="EditAppointment:saveAsButton_Tooltip" DefaultValue="Save As" />
								</TextBlock.Text>
                        </TextBlock>
                    </Button.ToolTip>
                </Button>
                <Separator />
                <Button IsTabStop="False" x:Name="reccButton" Margin="0,0,5,0" CommandTarget="{Binding ParentCollection.ParentStorage.ScheduleStorage.Scheduler}" CommandParameter="{Binding ElementName=root}" Command="c1:C1Scheduler.EditRecurrenceDialogCommand">
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                        <Image Source="/C1.WPF.Schedule.4;component/Resources/occurrence.png" Height="{DynamicResource {x:Static SystemParameters.SmallIconHeightKey}}" Width="{DynamicResource {x:Static SystemParameters.SmallIconWidthKey}}" />
                        <TextBlock Margin="3,0,0,0">
								<AccessText Text="{c1:SchedulerLoc Key=EditAppointment:reccButton_AccessText, DefaultValue=_Recurrence...}" />
                        </TextBlock>
                    </StackPanel>
                    <Button.ToolTip>
                        <TextBlock Text="{c1:SchedulerLoc Key=EditAppointment:reccButton_ToolTip, DefaultValue=Recurrence}" />
                    </Button.ToolTip>
                </Button>
                <Separator />
                <ToggleButton Name="highImportance" IsTabStop="False" IsChecked="{Binding Path=Importance, Mode=TwoWay,       Converter={x:Static c1:ImportanceEnumMemberConverter.Default}, ConverterParameter=High}">
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                        <Image Source="/C1.WPF.Schedule.4;component/Resources/importance_up.png" Height="{DynamicResource {x:Static SystemParameters.SmallIconHeightKey}}" Width="{DynamicResource {x:Static SystemParameters.SmallIconWidthKey}}" />
                    </StackPanel>
                    <ToggleButton.ToolTip>
                        <TextBlock>
								<TextBlock.Text>
									<c1:SchedulerLoc Key="EditAppointment:highImportance_ToolTip" DefaultValue="High Importance" />
								</TextBlock.Text>
                        </TextBlock>
                    </ToggleButton.ToolTip>
                </ToggleButton>
                <ToggleButton Name="lowImportance" IsTabStop="False" Margin="5,0" IsChecked="{Binding Path=Importance, Mode=TwoWay,             Converter={x:Static c1:ImportanceEnumMemberConverter.Default}, ConverterParameter=Low}">
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                        <Image Source="/C1.WPF.Schedule.4;component/Resources/importance_down.png" Height="{DynamicResource {x:Static SystemParameters.SmallIconHeightKey}}" Width="{DynamicResource {x:Static SystemParameters.SmallIconWidthKey}}" />
                    </StackPanel>
                    <ToggleButton.ToolTip>
                        <TextBlock>
								<TextBlock.Text>
									<c1:SchedulerLoc Key="EditAppointment:lowImportance_ToolTip" DefaultValue="Low Importance" />
								</TextBlock.Text>
                        </TextBlock>
                    </ToggleButton.ToolTip>
                </ToggleButton>
                <Separator />
                <Button Name="deleteButton" IsTabStop="False" CommandTarget="{Binding ParentCollection.ParentStorage.ScheduleStorage.Scheduler}" CommandParameter="{Binding Tag}" Command="c1:C1Scheduler.DeleteAppointmentCommand">
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                        <Image Source="/C1.WPF.Schedule.4;component/Resources/delete.png" Height="{DynamicResource {x:Static SystemParameters.SmallIconHeightKey}}" Width="{DynamicResource {x:Static SystemParameters.SmallIconWidthKey}}" />
                    </StackPanel>
                    <Button.ToolTip>
                        <TextBlock Text="{c1:SchedulerLoc Key=EditAppointment:deleteButton_ToolTip, DefaultValue=Delete}" />
                    </Button.ToolTip>
                </Button>
            </ToolBar>
        </ToolBarTray>
        <Border Grid.Row="1" BorderBrush="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" 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 -->
                <Label Target="{Binding ElementName=subject}" VerticalAlignment="Center" Margin="10,2,0,2" HorizontalAlignment="Left" Content="{c1:SchedulerLoc Key=EditAppointment:subject, DefaultValue=Sub_ject:}" />
                <TextBox x:Name="subject" TabIndex="0" Padding="2" Text="{Binding Subject, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextChanged="subject_TextChanged" Grid.Column="1" Grid.ColumnSpan="3" MaxLength="255" VerticalAlignment="Center" Margin="10,2,0,2" />
                <!-- Location -->
                <Label VerticalAlignment="Center" Margin="10,2,0,2" Grid.Row="1" Target="{Binding ElementName=location}" HorizontalAlignment="Left" Content="{c1:SchedulerLoc Key=EditAppointment:location, DefaultValue=_Location:}" />
                <TextBox TabIndex="1" x:Name="location" Text="{Binding Location, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Column="1" Grid.Row="1" MaxLength="255" VerticalAlignment="Center" Margin="10,2,0,2" />
                <!-- Label -->
                <Label VerticalAlignment="Center" Margin="10,2,0,2" Grid.Row="1" Target="{Binding ElementName=label}" Grid.Column="2" HorizontalAlignment="Left" Content="{c1:SchedulerLoc Key=EditAppointment:label, DefaultValue=La_bel:}" />
                <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="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" 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 -->
                    <Label VerticalAlignment="Center" Margin="10,2,0,2" Grid.Row="0" HorizontalAlignment="Left" Target="{Binding ElementName=startCalendar}">
                        <Label.Content>
                            <c1:SchedulerLoc Key="EditAppointment:startTime" DefaultValue="Start time:" />
                        </Label.Content>
                    </Label>
                    <c1:C1DateTimePicker x:Name="startCalendar" VerticalAlignment="Center" Margin="10,2,0,2" Padding="1" IsTabStop="False" Grid.Column="1" FirstDayOfWeek="{Binding Path=ParentCollection.ParentStorage.ScheduleStorage.Scheduler.CalendarHelper.WeekStart}" TimeFormat="ShortTime" DateFormat="Long" TimeIncrement="0:15" DateTime="{Binding Start, Mode=TwoWay}" />
                    <!-- End -->
                    <Label VerticalAlignment="Center" Margin="10,2,0,2" Grid.Row="1" HorizontalAlignment="Left" Target="{Binding ElementName=endCalendar}">
                        <Label.Content>
                            <c1:SchedulerLoc Key="EditAppointment:endTime" DefaultValue="End time:" />
                        </Label.Content>
                    </Label>
                    <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}">
                        <CheckBox.Content>
                            <c1:SchedulerLoc Key="EditAppointment:allDayEvent" DefaultValue="All da_y event" />
                        </CheckBox.Content>
                    </CheckBox>
               </Grid>
                <!-- recurrence info -->
                <StackPanel Name="recurrenceInfoPanel" Visibility="Collapsed" Orientation="Horizontal">
                    <TextBlock>
							<TextBlock.Text>
								<c1:SchedulerLoc Key="EditAppointment:recurrence" DefaultValue="Recurrence: " />
							</TextBlock.Text>
                    </TextBlock>
                    <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="{c1:SchedulerLoc Key=EditAppointment:reminderSet, DefaultValue=Re_minder:}" />
            <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}" />
            <Label VerticalAlignment="Center" Margin="30, 2, 0, 2" Target="{Binding ElementName=status}">
                <Label.Content>
                    <c1:SchedulerLoc Key="EditAppointment:showTimeAs" DefaultValue="Sho_w time as:" />
                </Label.Content>
            </Label>
            <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" ScrollViewer.VerticalScrollBarVisibility="Auto" TextWrapping="Wrap" Text="{Binding Body, Mode=TwoWay}" AcceptsReturn="true" />
        </Border>
        <Border Grid.Row="5" Margin="5" Padding="5">
            <UniformGrid x:Name="editGrid" Columns="2">
                <!-- Resources -->
                <c1:EditCollectionControl x:Name="resources" ButtonText="{c1:SchedulerLoc Key=EditAppointment:resourcesButton, DefaultValue=R_esources...}" LabelText="{c1:SchedulerLoc Key=EditAppointment:resourceLabel, DefaultValue=Resource:}" />
                <!-- Categories -->
                <c1:EditCollectionControl x:Name="categories" ButtonText="{c1:SchedulerLoc Key=EditAppointment:categoriesButton, DefaultValue=Cate_gories...}" LabelText="{c1:SchedulerLoc Key=EditAppointment:categoryLabel, DefaultValue=Category:}" />
                <!-- Contacts -->
                <c1:EditCollectionControl x:Name="contacts" ButtonText="{c1:SchedulerLoc Key=EditAppointment:contactsButton, DefaultValue=_Contacts...}" LabelText="{c1:SchedulerLoc Key=EditAppointment:contactLabel, DefaultValue=Contact:}" />

                <CheckBox IsChecked="{Binding Path=Private, Mode=TwoWay}" Grid.Row="2" Grid.Column="3" VerticalAlignment="Center" HorizontalAlignment="Right" Content="{c1:SchedulerLoc Key=EditAppointment:private_, DefaultValue=_Private}" />
            </UniformGrid>
        </Border>
    </Grid>
</UserControl>