<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Models\Settings.cs" />
+ <Compile Include="Models\Tab.cs" />
<Compile Include="ViewModels\SettingsWindowViewModel.cs" />
<Compile Include="Views\SettingsWindow.xaml.cs">
<DependentUpon>SettingsWindow.xaml</DependentUpon>
internal Model()
{
- Editing = new BlogItem();
+ this.Tabs = new DispatcherCollection<Tab>(DispatcherHelper.UIDispatcher);
+ this.Tabs.Add(new Tab() { Editing = new BlogItem(), TitleText = "新規" });
}
private Settings settings;
private HatenaDiary diary = new HatenaDiary();
private HatenaFotolife fotolife = new HatenaFotolife();
- public BlogItem Editing { private set; get; }
+ public DispatcherCollection<Tab> Tabs { private set; get; }
- public void Post()
+ public void Post(Tab tab)
{
- var re = diary.PostEntry(this.Editing.Title, this.Editing.Content);
- this.Editing.Entry = re;
+ var re = diary.PostEntry(tab.Editing.Title, tab.Editing.Content);
+ tab.Editing.Entry = re;
+ tab.TitleText = re.Title;
+ tab.Modified = false;
}
}
}
namespace Azyobuzi.HatenaDiaryClient.Models
{
- public class Settings : NotifyObject, ICloneable
+ public class Settings : NotifyObject
{
private static readonly string settingsFile =
Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]) + @"\settings.xml";
xs.Serialize(sw, this);
}
}
-
- public object Clone()
- {
- this.Save();
- return Load();
- }
}
}
--- /dev/null
+using System.ComponentModel;
+using Livet;
+
+namespace Azyobuzi.HatenaDiaryClient.Models
+{
+ class Tab : NotifyObject
+ {
+
+ BlogItem _Editing;
+
+ public BlogItem Editing
+ {
+ get
+ { return _Editing; }
+ set
+ {
+ if (_Editing == value)
+ return;
+ if (this._Editing != null)
+ this._Editing.PropertyChanged -= this.Editing_PropertyChanged;
+ _Editing = value;
+ this._Editing.PropertyChanged += this.Editing_PropertyChanged;
+ RaisePropertyChanged("Editing");
+ }
+ }
+
+ private void Editing_PropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ this.Modified = true;
+ }
+
+ string _TitleText;
+
+ public string TitleText
+ {
+ get
+ { return _TitleText; }
+ set
+ {
+ if (_TitleText == value)
+ return;
+ _TitleText = value;
+ RaisePropertyChanged("TitleText");
+ }
+ }
+
+ bool _Modified;
+
+ public bool Modified
+ {
+ get
+ { return _Modified; }
+ set
+ {
+ if (_Modified == value)
+ return;
+ _Modified = value;
+ RaisePropertyChanged("Modified");
+ }
+ }
+
+ }
+}
}
}
- public BlogItem Editing
+ public DispatcherCollection<Tab> Tabs
{
get
{
- return model.Editing;
+ return this.model.Tabs;
}
}
+ Tab _SelectedTab;
+
+ public Tab SelectedTab
+ {
+ get
+ { return _SelectedTab; }
+ set
+ {
+ if (_SelectedTab == value)
+ return;
+ _SelectedTab = value;
+ RaisePropertyChanged("SelectedTab");
+ }
+ }
+
+
+
#region PostCommand
DelegateCommand _PostCommand;
private bool CanPost()
{
- return this.model.SetIdPassword && !string.IsNullOrEmpty(this.Editing.Content);
+ return this.model.SetIdPassword &&
+ this.SelectedTab != null &&
+ !string.IsNullOrEmpty(this.SelectedTab.Editing.Content);
}
private void Post()
{
- this.model.Post();
+ this.model.Post(this.SelectedTab);
}
#endregion
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
- <RowDefinition Height="auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
</StackPanel>
</Button>
</WrapPanel>
-
- <Grid Grid.Row="2" Background="LightBlue">
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="auto"/>
- <ColumnDefinition/>
- </Grid.ColumnDefinitions>
-
- <TextBlock Grid.Column="0" Text="タイトル :" Margin="3,3,3,3" VerticalAlignment="Center" Foreground="White"/>
- <TextBox Grid.Column="1" Margin="3,3,3,3" Text="{Binding Editing.Title, UpdateSourceTrigger=PropertyChanged}"/>
- </Grid>
-
- <TextBox Grid.Row="3" TextWrapping="Wrap" AcceptsReturn="True" AcceptsTab="True" Text="{Binding Editing.Content, UpdateSourceTrigger=PropertyChanged}"/>
+
+ <TabControl Grid.Row="2" ItemsSource="{Binding Tabs}" SelectedItem="{Binding SelectedTab}">
+ <TabControl.ItemTemplate>
+ <DataTemplate>
+ <DataTemplate.Resources>
+ <Style x:Key="ModifiedText" TargetType="TextBlock">
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding Modified}" Value="True">
+ <DataTrigger.Setters>
+ <Setter Property="Text" Value="*"/>
+ </DataTrigger.Setters>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </DataTemplate.Resources>
+
+ <StackPanel Orientation="Horizontal">
+ <TextBlock Text="{Binding TitleText}"/>
+ <TextBlock Style="{StaticResource ModifiedText}" />
+ </StackPanel>
+ </DataTemplate>
+ </TabControl.ItemTemplate>
+ <TabControl.ContentTemplate>
+ <DataTemplate>
+ <Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="auto"/>
+ <RowDefinition/>
+ </Grid.RowDefinitions>
+
+ <Grid Grid.Row="0" Background="LightBlue">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="auto"/>
+ <ColumnDefinition/>
+ </Grid.ColumnDefinitions>
+
+ <TextBlock Grid.Column="0" Text="タイトル :" Margin="3,3,3,3" VerticalAlignment="Center" Foreground="White"/>
+ <TextBox Grid.Column="1" Margin="3,3,3,3" Text="{Binding Editing.Title, UpdateSourceTrigger=PropertyChanged}"/>
+ </Grid>
+
+ <TextBox Grid.Row="1" TextWrapping="Wrap" AcceptsReturn="True" AcceptsTab="True" Text="{Binding Editing.Content, UpdateSourceTrigger=PropertyChanged}"/>
+ </Grid>
+ </DataTemplate>
+ </TabControl.ContentTemplate>
+ </TabControl>
</Grid>
</Window>