http://sourceforge.jp/projects/futonwriter/の旧リポジトリ
| Revision | cac08ec475462016f9942582797481b06c80634f (tree) |
|---|---|
| Time | 2011-05-19 23:22:00 |
| Author | azyobuzin <azyobuzin@user...> |
| Commiter | azyobuzin |
タブで分けるようにしたけどテスト不足
| @@ -70,6 +70,7 @@ | ||
| 70 | 70 | <SubType>Designer</SubType> |
| 71 | 71 | </ApplicationDefinition> |
| 72 | 72 | <Compile Include="Models\Settings.cs" /> |
| 73 | + <Compile Include="Models\Tab.cs" /> | |
| 73 | 74 | <Compile Include="ViewModels\SettingsWindowViewModel.cs" /> |
| 74 | 75 | <Compile Include="Views\SettingsWindow.xaml.cs"> |
| 75 | 76 | <DependentUpon>SettingsWindow.xaml</DependentUpon> |
| @@ -18,7 +18,8 @@ namespace Azyobuzi.HatenaDiaryClient.Models | ||
| 18 | 18 | |
| 19 | 19 | internal Model() |
| 20 | 20 | { |
| 21 | - Editing = new BlogItem(); | |
| 21 | + this.Tabs = new DispatcherCollection<Tab>(DispatcherHelper.UIDispatcher); | |
| 22 | + this.Tabs.Add(new Tab() { Editing = new BlogItem(), TitleText = "新規" }); | |
| 22 | 23 | } |
| 23 | 24 | |
| 24 | 25 | private Settings settings; |
| @@ -70,12 +71,14 @@ namespace Azyobuzi.HatenaDiaryClient.Models | ||
| 70 | 71 | private HatenaDiary diary = new HatenaDiary(); |
| 71 | 72 | private HatenaFotolife fotolife = new HatenaFotolife(); |
| 72 | 73 | |
| 73 | - public BlogItem Editing { private set; get; } | |
| 74 | + public DispatcherCollection<Tab> Tabs { private set; get; } | |
| 74 | 75 | |
| 75 | - public void Post() | |
| 76 | + public void Post(Tab tab) | |
| 76 | 77 | { |
| 77 | - var re = diary.PostEntry(this.Editing.Title, this.Editing.Content); | |
| 78 | - this.Editing.Entry = re; | |
| 78 | + var re = diary.PostEntry(tab.Editing.Title, tab.Editing.Content); | |
| 79 | + tab.Editing.Entry = re; | |
| 80 | + tab.TitleText = re.Title; | |
| 81 | + tab.Modified = false; | |
| 79 | 82 | } |
| 80 | 83 | } |
| 81 | 84 | } |
| @@ -7,7 +7,7 @@ using Livet; | ||
| 7 | 7 | |
| 8 | 8 | namespace Azyobuzi.HatenaDiaryClient.Models |
| 9 | 9 | { |
| 10 | - public class Settings : NotifyObject, ICloneable | |
| 10 | + public class Settings : NotifyObject | |
| 11 | 11 | { |
| 12 | 12 | private static readonly string settingsFile = |
| 13 | 13 | Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]) + @"\settings.xml"; |
| @@ -68,11 +68,5 @@ namespace Azyobuzi.HatenaDiaryClient.Models | ||
| 68 | 68 | xs.Serialize(sw, this); |
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | - | |
| 72 | - public object Clone() | |
| 73 | - { | |
| 74 | - this.Save(); | |
| 75 | - return Load(); | |
| 76 | - } | |
| 77 | 71 | } |
| 78 | 72 | } |
| @@ -0,0 +1,63 @@ | ||
| 1 | +using System.ComponentModel; | |
| 2 | +using Livet; | |
| 3 | + | |
| 4 | +namespace Azyobuzi.HatenaDiaryClient.Models | |
| 5 | +{ | |
| 6 | + class Tab : NotifyObject | |
| 7 | + { | |
| 8 | + | |
| 9 | + BlogItem _Editing; | |
| 10 | + | |
| 11 | + public BlogItem Editing | |
| 12 | + { | |
| 13 | + get | |
| 14 | + { return _Editing; } | |
| 15 | + set | |
| 16 | + { | |
| 17 | + if (_Editing == value) | |
| 18 | + return; | |
| 19 | + if (this._Editing != null) | |
| 20 | + this._Editing.PropertyChanged -= this.Editing_PropertyChanged; | |
| 21 | + _Editing = value; | |
| 22 | + this._Editing.PropertyChanged += this.Editing_PropertyChanged; | |
| 23 | + RaisePropertyChanged("Editing"); | |
| 24 | + } | |
| 25 | + } | |
| 26 | + | |
| 27 | + private void Editing_PropertyChanged(object sender, PropertyChangedEventArgs e) | |
| 28 | + { | |
| 29 | + this.Modified = true; | |
| 30 | + } | |
| 31 | + | |
| 32 | + string _TitleText; | |
| 33 | + | |
| 34 | + public string TitleText | |
| 35 | + { | |
| 36 | + get | |
| 37 | + { return _TitleText; } | |
| 38 | + set | |
| 39 | + { | |
| 40 | + if (_TitleText == value) | |
| 41 | + return; | |
| 42 | + _TitleText = value; | |
| 43 | + RaisePropertyChanged("TitleText"); | |
| 44 | + } | |
| 45 | + } | |
| 46 | + | |
| 47 | + bool _Modified; | |
| 48 | + | |
| 49 | + public bool Modified | |
| 50 | + { | |
| 51 | + get | |
| 52 | + { return _Modified; } | |
| 53 | + set | |
| 54 | + { | |
| 55 | + if (_Modified == value) | |
| 56 | + return; | |
| 57 | + _Modified = value; | |
| 58 | + RaisePropertyChanged("Modified"); | |
| 59 | + } | |
| 60 | + } | |
| 61 | + | |
| 62 | + } | |
| 63 | +} |
| @@ -65,15 +65,32 @@ namespace Azyobuzi.HatenaDiaryClient.ViewModels | ||
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - public BlogItem Editing | |
| 68 | + public DispatcherCollection<Tab> Tabs | |
| 69 | 69 | { |
| 70 | 70 | get |
| 71 | 71 | { |
| 72 | - return model.Editing; | |
| 72 | + return this.model.Tabs; | |
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | |
| 77 | + Tab _SelectedTab; | |
| 78 | + | |
| 79 | + public Tab SelectedTab | |
| 80 | + { | |
| 81 | + get | |
| 82 | + { return _SelectedTab; } | |
| 83 | + set | |
| 84 | + { | |
| 85 | + if (_SelectedTab == value) | |
| 86 | + return; | |
| 87 | + _SelectedTab = value; | |
| 88 | + RaisePropertyChanged("SelectedTab"); | |
| 89 | + } | |
| 90 | + } | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 77 | 94 | #region PostCommand |
| 78 | 95 | DelegateCommand _PostCommand; |
| 79 | 96 |
| @@ -89,12 +106,14 @@ namespace Azyobuzi.HatenaDiaryClient.ViewModels | ||
| 89 | 106 | |
| 90 | 107 | private bool CanPost() |
| 91 | 108 | { |
| 92 | - return this.model.SetIdPassword && !string.IsNullOrEmpty(this.Editing.Content); | |
| 109 | + return this.model.SetIdPassword && | |
| 110 | + this.SelectedTab != null && | |
| 111 | + !string.IsNullOrEmpty(this.SelectedTab.Editing.Content); | |
| 93 | 112 | } |
| 94 | 113 | |
| 95 | 114 | private void Post() |
| 96 | 115 | { |
| 97 | - this.model.Post(); | |
| 116 | + this.model.Post(this.SelectedTab); | |
| 98 | 117 | } |
| 99 | 118 | #endregion |
| 100 | 119 |
| @@ -28,7 +28,6 @@ | ||
| 28 | 28 | <Grid.RowDefinitions> |
| 29 | 29 | <RowDefinition Height="auto"/> |
| 30 | 30 | <RowDefinition Height="auto"/> |
| 31 | - <RowDefinition Height="auto"/> | |
| 32 | 31 | <RowDefinition/> |
| 33 | 32 | </Grid.RowDefinitions> |
| 34 | 33 |
| @@ -60,17 +59,50 @@ | ||
| 60 | 59 | </StackPanel> |
| 61 | 60 | </Button> |
| 62 | 61 | </WrapPanel> |
| 63 | - | |
| 64 | - <Grid Grid.Row="2" Background="LightBlue"> | |
| 65 | - <Grid.ColumnDefinitions> | |
| 66 | - <ColumnDefinition Width="auto"/> | |
| 67 | - <ColumnDefinition/> | |
| 68 | - </Grid.ColumnDefinitions> | |
| 69 | - | |
| 70 | - <TextBlock Grid.Column="0" Text="タイトル :" Margin="3,3,3,3" VerticalAlignment="Center" Foreground="White"/> | |
| 71 | - <TextBox Grid.Column="1" Margin="3,3,3,3" Text="{Binding Editing.Title, UpdateSourceTrigger=PropertyChanged}"/> | |
| 72 | - </Grid> | |
| 73 | - | |
| 74 | - <TextBox Grid.Row="3" TextWrapping="Wrap" AcceptsReturn="True" AcceptsTab="True" Text="{Binding Editing.Content, UpdateSourceTrigger=PropertyChanged}"/> | |
| 62 | + | |
| 63 | + <TabControl Grid.Row="2" ItemsSource="{Binding Tabs}" SelectedItem="{Binding SelectedTab}"> | |
| 64 | + <TabControl.ItemTemplate> | |
| 65 | + <DataTemplate> | |
| 66 | + <DataTemplate.Resources> | |
| 67 | + <Style x:Key="ModifiedText" TargetType="TextBlock"> | |
| 68 | + <Style.Triggers> | |
| 69 | + <DataTrigger Binding="{Binding Modified}" Value="True"> | |
| 70 | + <DataTrigger.Setters> | |
| 71 | + <Setter Property="Text" Value="*"/> | |
| 72 | + </DataTrigger.Setters> | |
| 73 | + </DataTrigger> | |
| 74 | + </Style.Triggers> | |
| 75 | + </Style> | |
| 76 | + </DataTemplate.Resources> | |
| 77 | + | |
| 78 | + <StackPanel Orientation="Horizontal"> | |
| 79 | + <TextBlock Text="{Binding TitleText}"/> | |
| 80 | + <TextBlock Style="{StaticResource ModifiedText}" /> | |
| 81 | + </StackPanel> | |
| 82 | + </DataTemplate> | |
| 83 | + </TabControl.ItemTemplate> | |
| 84 | + <TabControl.ContentTemplate> | |
| 85 | + <DataTemplate> | |
| 86 | + <Grid> | |
| 87 | + <Grid.RowDefinitions> | |
| 88 | + <RowDefinition Height="auto"/> | |
| 89 | + <RowDefinition/> | |
| 90 | + </Grid.RowDefinitions> | |
| 91 | + | |
| 92 | + <Grid Grid.Row="0" Background="LightBlue"> | |
| 93 | + <Grid.ColumnDefinitions> | |
| 94 | + <ColumnDefinition Width="auto"/> | |
| 95 | + <ColumnDefinition/> | |
| 96 | + </Grid.ColumnDefinitions> | |
| 97 | + | |
| 98 | + <TextBlock Grid.Column="0" Text="タイトル :" Margin="3,3,3,3" VerticalAlignment="Center" Foreground="White"/> | |
| 99 | + <TextBox Grid.Column="1" Margin="3,3,3,3" Text="{Binding Editing.Title, UpdateSourceTrigger=PropertyChanged}"/> | |
| 100 | + </Grid> | |
| 101 | + | |
| 102 | + <TextBox Grid.Row="1" TextWrapping="Wrap" AcceptsReturn="True" AcceptsTab="True" Text="{Binding Editing.Content, UpdateSourceTrigger=PropertyChanged}"/> | |
| 103 | + </Grid> | |
| 104 | + </DataTemplate> | |
| 105 | + </TabControl.ContentTemplate> | |
| 106 | + </TabControl> | |
| 75 | 107 | </Grid> |
| 76 | 108 | </Window> |