Permalink
Browse files

added a very simple config editor to the testgui

Signed-off-by: henon <meinrad.recheis@gmail.com>
  • Loading branch information...
1 parent dec9809 commit 12ffa0bb269adbbe24cbcf5230e7ae3cb26e77d6 @henon committed Jun 11, 2009
Showing with 123 additions and 10 deletions.
  1. +64 −3 TestGUI/Browser.xaml
  2. +58 −7 TestGUI/Browser.xaml.cs
  3. +1 −0 TestGUI/TestGUI.csproj
View
67 TestGUI/Browser.xaml
@@ -2,25 +2,44 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:objects="clr-namespace:dotGit.Objects;assembly=dotGit"
+ xmlns:config="clr-namespace:dotGit.Config;assembly=dotGit"
Title="Repository Browser" MinHeight="423" MinWidth="568">
<Window.Resources>
+ <!--repository tree templates-->
<HierarchicalDataTemplate DataType="{x:Type objects:Tree}" ItemsSource="{Binding Path=Children}">
<TextBlock Text="{Binding Path}" TextTrimming="CharacterEllipsis" ToolTip="{Binding SHA}"/>
</HierarchicalDataTemplate>
<DataTemplate DataType="{x:Type objects:Blob}">
<TextBlock Text="{Binding Path}" TextTrimming="CharacterEllipsis" Foreground="CornflowerBlue" ToolTip="{Binding SHA}"/>
</DataTemplate>
+
+ <!--config tree templates-->
+ <HierarchicalDataTemplate DataType="{x:Type config:Section}" ItemsSource="{Binding Path=Entries}">
+ <TextBlock Text="{Binding Name}" TextTrimming="CharacterEllipsis"/>
+ </HierarchicalDataTemplate>
+ <DataTemplate DataType="{x:Type config:Entry}">
+ <StackPanel Orientation="Horizontal">
+ <Label Content="{Binding Name}" ToolTip="{Binding FullName}" Width="200"/>
+ <Label Content=" = "/>
+ <TextBox Text="{Binding Path=Value, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" ToolTip="{Binding Value}" Width="300"/>
+ </StackPanel>
+ </DataTemplate>
</Window.Resources>
<DockPanel>
+ <Menu DockPanel.Dock="Top">
+ <MenuItem Header="Repository">
+ <MenuItem Header="Open ..." Click="OnSelectRepository"/>
+ </MenuItem>
+ </Menu>
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Margin="0,0,0,5">
<Label>Path to repository:</Label>
<TextBox Name="m_url_textbox">..\..\..\</TextBox>
<Button Click="Button_Click" Margin="5,0,0,0">Load</Button>
<!--<Label Margin="10,0,0,0">Select a commit. Differences to the previous commit are highlited in red.</Label>-->
</StackPanel>
- <TabControl>
+ <TabControl SelectedIndex="2">
<!--repository-->
<TabItem Header="Repository" IsSelected="True">
@@ -32,6 +51,10 @@
<!--branches-->
<DockPanel>
+ <StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
+ <Label>Current branch:</Label>
+ <ComboBox Width="100" Text="TODO"></ComboBox>
+ </StackPanel>
<Label DockPanel.Dock="Top">Branches:</Label>
<ListView Name="m_branches" DockPanel.Dock="Top">
<ListView.View>
@@ -55,9 +78,13 @@
<GridView>
<GridView.Columns>
<GridViewColumn Header="Name" DisplayMemberBinding="{Binding Path=Name}"/>
- <GridViewColumn Header="Path" DisplayMemberBinding="{Binding Path=Path}"/>
- <GridViewColumn Header="Commit" DisplayMemberBinding="{Binding Path=Commit}"/>
<GridViewColumn Header="SHA" DisplayMemberBinding="{Binding Path=SHA}"/>
+ <GridViewColumn Header="Size" DisplayMemberBinding="{Binding Path=Size}"/>
+ <GridViewColumn Header="Path" DisplayMemberBinding="{Binding Path=Path}"/>
+ <GridViewColumn Header="Annotated" DisplayMemberBinding="{Binding Path=IsAnnotated}"/>
+ <GridViewColumn Header="Date" DisplayMemberBinding="{Binding Path=TagDate}"/>
+ <GridViewColumn Header="Tagger" DisplayMemberBinding="{Binding Path=Tagger}"/>
+ <GridViewColumn Header="Message" DisplayMemberBinding="{Binding Path=Message}"/>
</GridView.Columns>
</GridView>
</ListView.View>
@@ -105,6 +132,40 @@
</DockPanel>
</Grid>
</TabItem>
+
+ <!--config-->
+ <TabItem Header="Configuration">
+ <DockPanel>
+ <StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Margin="4">
+ <Button Click="OnLoadConfiguration">Load</Button>
+ <Button Click="OnSaveConfiguration">Save</Button>
+ </StackPanel>
+ <Grid>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="2*"/>
+ <!--<ColumnDefinition Width="2"/>
+ <ColumnDefinition Width="1*"/>-->
+ </Grid.ColumnDefinitions>
+
+ <!--config tree-->
+ <DockPanel Grid.Column="0">
+ <TextBlock DockPanel.Dock="Top" Background="Silver">Confgiuration</TextBlock>
+ <TreeView Name="m_config_tree">
+
+ </TreeView>
+ </DockPanel>
+
+ <!--config editor-->
+ <!--<DockPanel Grid.Column="2" >
+ <TextBlock DockPanel.Dock="Top" Background="Silver">Edit ... </TextBlock>
+ <Label Name="m_config_name" DockPanel.Dock="Top" ></Label>
+ <TextBox Name="m_config_value" DockPanel.Dock="Top" ></TextBox>
+ </DockPanel>
+ <GridSplitter Width="2" Grid.Column="1" ResizeBehavior="PreviousAndNext"/>-->
+ </Grid>
+ </DockPanel>
+ </TabItem>
+
</TabControl>
</DockPanel>
</Window>
View
65 TestGUI/Browser.xaml.cs
@@ -14,6 +14,8 @@
using dotGit;
using dotGit.Objects;
using System.Collections.ObjectModel;
+using Microsoft.Win32;
+using dotGit.Config;
namespace TestGUI
{
@@ -24,28 +26,77 @@ public Browser()
{
InitializeComponent();
m_commits.SelectionChanged += (o, args) => SelectCommit(m_commits.SelectedItem as Commit);
+ //m_config_tree.SelectedItemChanged += (o, args) => SelectConfiguration(m_config_tree.SelectedItem);
}
- private void SelectCommit(Commit commit)
- {
- if (commit == null)
- return;
- m_tree.ItemsSource = commit.Tree.Children;
- //(m_tree.ItemContainerGenerator.ContainerFromIndex(0) as TreeViewItem).IsExpanded = true;
- }
+ Repository m_repository;
+
// load
private void Button_Click(object sender, RoutedEventArgs e)
{
var url = m_url_textbox.Text;
Repository repo = Repository.Open(url);
+ m_repository = repo;
m_branches.ItemsSource = repo.Branches;
m_tags.ItemsSource = repo.Tags;
var list = repo.HEAD.Commit.Ancestors.ToList();
list.Insert(0, repo.HEAD.Commit);
m_commits.ItemsSource = list;
m_commits.SelectedIndex = 0;
+ ReloadConfiguration();
}
+ private void OnSelectRepository(object sender, RoutedEventArgs e)
+ {
+ var dlg = new System.Windows.Forms.FolderBrowserDialog();
+ //dlg.CheckPathExists = true;
+ if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+ {
+ m_url_textbox.Text = dlg.SelectedPath;
+ }
+ }
+
+ //private void SelectConfiguration(object obj)
+ //{
+ // if (obj is Entry)
+ // {
+ // var entry = obj as dotGit.Config.Entry;
+ // m_config_name.Content = entry.FullName;
+ // if (entry.Value != null)
+ // m_config_value.Text = entry.Value;
+ // }
+ //}
+
+ private void SelectCommit(Commit commit)
+ {
+ if (commit == null)
+ return;
+ m_tree.ItemsSource = commit.Tree.Children;
+ //(m_tree.ItemContainerGenerator.ContainerFromIndex(0) as TreeViewItem).IsExpanded = true;
+ }
+
+ private void OnLoadConfiguration(object sender, RoutedEventArgs e)
+ {
+ ReloadConfiguration();
+ }
+
+ private void ReloadConfiguration()
+ {
+ m_repository.Config.Reload();
+ m_config_tree.ItemsSource = null;
+ m_config_tree.ItemsSource = m_repository.Config.Sections;
+ }
+
+ private void SaveConfiguration()
+ {
+ m_repository.Config.Save();
+ ReloadConfiguration();
+ }
+
+ private void OnSaveConfiguration(object sender, RoutedEventArgs e)
+ {
+ SaveConfiguration();
+ }
}
}
View
1 TestGUI/TestGUI.csproj
@@ -37,6 +37,7 @@
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
+ <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>

0 comments on commit 12ffa0b

Please sign in to comment.