Notes

Форк
0
/
MainWindow.xaml 
134 строки · 6.1 Кб
1
<Window x:Class="View.MainWindow"
2
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6
        xmlns:view="clr-namespace:View"
7
        xmlns:viewModel="clr-namespace:ViewModel;assembly=ViewModel"
8
        xmlns:services="clr-namespace:ViewModel.Services;assembly=ViewModel"
9
        xmlns:converters="clr-namespace:ValueConverters;assembly=ValueConverters"
10
        mc:Ignorable="d"
11
        Title="Notes" Height="450" Width="800" MinHeight="450" MinWidth="800">
12
    <Window.Resources>
13
        <converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" IsInverted="False"/>
14
        <DataTemplate x:Key="noteTemplate">
15
            <StackPanel Margin="3" Orientation="Horizontal" HorizontalAlignment="Right">
16
                <TextBlock Text="{Binding Title}"
17
                           Validation.ErrorTemplate="{x:Null}"
18
                           FontSize="12" Width="auto"
19
                           TextWrapping="Wrap"/>
20
                <Ellipse Width="5" Height="5" Fill="#FF9BBAC7" Margin="3"
21
                         Visibility="{Binding IsEdit, 
22
                    Converter={StaticResource BoolToVisibilityConverter}, 
23
                    UpdateSourceTrigger=PropertyChanged}"/>
24
            </StackPanel>
25
        </DataTemplate>
26
    </Window.Resources>
27
    <Window.DataContext>
28
        <viewModel:MainViewModel/>
29
    </Window.DataContext>
30
    <Grid>
31
        <Grid.ColumnDefinitions>
32
            <ColumnDefinition Width="175" 
33
                              MinWidth="175" 
34
                              MaxWidth="300"/>
35
            <ColumnDefinition Width="*"/>
36
        </Grid.ColumnDefinitions>
37
        <Grid Grid.Column="0" 
38
              Background="LightGray">
39
            <Grid.RowDefinitions>
40
                <RowDefinition Height="Auto"/>
41
                <RowDefinition Height="*"/>
42
                <RowDefinition Height="Auto"/>
43
            </Grid.RowDefinitions>
44
            <Grid Grid.Row="0" Margin="3" >
45
                <Grid.ColumnDefinitions>
46
                    <ColumnDefinition Width="Auto"/>
47
                    <ColumnDefinition Width="*"/>
48
                    <ColumnDefinition Width="Auto"/>
49
                </Grid.ColumnDefinitions>
50
                <TextBlock Grid.Column="0"
51
                           Text="Find:"
52
                           Margin="3"
53
                           HorizontalAlignment="Center" VerticalAlignment="Center"/>
54
                <TextBox Grid.Column="1"
55
                         Background="LightGray"
56
                         Margin="0, 3, 3, 3"
57
                         Text="{Binding SearchNoteTitle, UpdateSourceTrigger=PropertyChanged, 
58
                    Mode=TwoWay}" 
59
                         VerticalAlignment="Center"/>
60
            </Grid>
61
            <Grid Grid.Row="1"
62
                  Margin="3">
63
                <ListBox Margin="3"
64
                         Background="LightGray"
65
                         BorderThickness="0"
66
                         ItemsSource="{Binding Notes, 
67
                            UpdateSourceTrigger=PropertyChanged}"
68
                         SelectedItem="{Binding SelectedNote, 
69
                    UpdateSourceTrigger=PropertyChanged}"
70
                         ItemTemplate="{StaticResource noteTemplate}"/>
71
            </Grid>
72
            <Grid Grid.Row="2"
73
                  Margin="3">
74
                <Grid.ColumnDefinitions>
75
                    <ColumnDefinition/>
76
                    <ColumnDefinition/>
77
                </Grid.ColumnDefinitions>
78
                <Button Grid.Column="0"
79
                        Height="25"
80
                        Width="auto"
81
                        Margin="3"
82
                        Content="Add"
83
                        Command="{Binding AddNoteCommand}"/>
84
                <Button Grid.Column="1"
85
                        Height="25"
86
                        Width="auto"
87
                        Margin="0, 3, 3, 3"
88
                        Content="Delete"
89
                        Command="{Binding DeleteNoteCommand}"/>
90
            </Grid>
91
        </Grid>
92
        <Grid Grid.Column="1"  
93
              Margin="50,3,50,0">
94
            <Grid.RowDefinitions>
95
                <RowDefinition Height="Auto"/>
96
                <RowDefinition Height="*" />
97
            </Grid.RowDefinitions>
98
            <Grid Grid.Row="0">
99
                <TextBox FontSize="50"
100
                         BorderThickness="0"
101
                         Text="{Binding SelectedNote.Title, UpdateSourceTrigger=PropertyChanged}"
102
                         IsEnabled="{Binding IsEnabled}">
103
                    <TextBox.ContextMenu>
104
                        <ContextMenu Visibility="{Binding IsEdit, 
105
                            Converter={StaticResource BoolToVisibilityConverter}, UpdateSourceTrigger=PropertyChanged}">
106
                            <MenuItem Header="Save" Command="{Binding SaveNoteCommand}"/>
107
                        </ContextMenu>
108
                    </TextBox.ContextMenu>
109
                </TextBox>
110
            </Grid>
111
            <Grid Grid.Row="1"
112
                    Margin="0, 10, 0, 0">
113
                <RichTextBox 
114
                         VerticalScrollBarVisibility="Auto"
115
                         BorderThickness="0"
116
                         IsEnabled="{Binding IsEnabled}"
117
                         AcceptsReturn="True"
118
                         AcceptsTab="True"
119
                         SpellCheck.IsEnabled="True"
120
                         services:RichTextBoxHelper.DocumentXaml="{Binding SelectedNote.Text, 
121
                    UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}">
122
                    <FlowDocument>
123
                    </FlowDocument>
124
                    <RichTextBox.ContextMenu>
125
                        <ContextMenu>
126
                            <MenuItem Header="Save" Command="{Binding SaveNoteCommand}"/>
127
                        </ContextMenu>
128
                    </RichTextBox.ContextMenu>
129
                </RichTextBox>
130
            </Grid>
131
        </Grid>
132
        <GridSplitter Grid.Column="0" Width="2" Background="White"/>
133
    </Grid>
134
</Window>
135

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.