Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added very basic index manipulation and committing capability. This c…

…ommit was produced by GitSharp.Demo itself.
  • Loading branch information...
commit 6cabae01527cc77067ac1c76d078751f5b7f310c 1 parent c1f2546
@henon authored
Showing with 6,518 additions and 1,359 deletions.
  1. +8 −2 App.xaml
  2. +0 −173 Browser.xaml
  3. +0 −244 Browser.xaml.cs
  4. +113 −0 BrowserView.xaml
  5. +114 −0 BrowserView.xaml.cs
  6. +39 −1 CommitSummaryView.xaml
  7. +37 −1 CommitSummaryView.xaml.cs
  8. +74 −0 CommitView/CommitDialog.xaml
  9. +96 −0 CommitView/CommitDialog.xaml.cs
  10. +105 −0 CommitView/StatusListView.xaml
  11. +235 −0 CommitView/StatusListView.xaml.cs
  12. +53 −0 CommitView/StatusView.xaml
  13. +99 −0 CommitView/StatusView.xaml.cs
  14. +161 −0 CommitView/WorkingTree.cs
  15. +91 −0 CommitView/WorkingTreeView.xaml
  16. +99 −0 CommitView/WorkingTreeView.xaml.cs
  17. +66 −8 GitSharp.Demo.csproj
  18. +1 −1  HistoryGraph/HistoryGraphView.xaml.cs
  19. +48 −0 IRepositoryView.cs
  20. +76 −0 MainFrame.xaml
  21. +116 −0 MainFrame.xaml.cs
  22. +39 −1 TextDiffView.xaml.cs
  23. +66 −0 Util/GenericConverter.cs
  24. BIN  depend/GitSharp.Core.dll
  25. BIN  depend/GitSharp.Core.pdb
  26. BIN  depend/GitSharp.dll
  27. BIN  depend/GitSharp.pdb
  28. 0  {depend → lib}/DiffieHellman.dll
  29. BIN  lib/GitSharp.Core.dll
  30. BIN  lib/GitSharp.Core.pdb
  31. +4,583 −852 {depend → lib}/GitSharp.Core.xml
  32. BIN  lib/GitSharp.dll
  33. BIN  lib/GitSharp.pdb
  34. +199 −76 {depend → lib}/GitSharp.xml
  35. 0  {depend → lib}/ICSharpCode.SharpZipLib.dll
  36. 0  {depend → lib}/ICSharpCode.SharpZipLib.xml
  37. 0  {depend → lib}/Org.Mentalis.Security.dll
  38. 0  {depend → lib}/Tamir.SharpSSH.dll
  39. 0  {depend → lib}/Winterdom.IO.FileMap.dll
  40. 0  {depend → lib}/nunit.framework.dll
View
10 App.xaml
@@ -39,8 +39,14 @@
<Application x:Class="GitSharp.Demo.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- StartupUri="Browser.xaml">
+ StartupUri="MainFrame.xaml">
<Application.Resources>
-
+ <LinearGradientBrush x:Key="SilverGradientTopVertical" StartPoint="0,0" EndPoint="0,1">
+ <GradientStop Color="#FFEEEEEE" Offset="0" />
+ <GradientStop Color="#FFCCCCCC" Offset="1" />
+ </LinearGradientBrush>
+ <Style x:Key="HeaderLabelStyle">
+ <Setter Property="Label.Background" Value="{StaticResource SilverGradientTopVertical}" ></Setter>
+ </Style>
</Application.Resources>
</Application>
View
173 Browser.xaml
@@ -1,173 +0,0 @@
-<!--
- /*
- * Copyright (C) 2009, Henon<meinrad.recheis@gmail.com>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- *
- * - Neither the name of the project nor the
- * names of its contributors may be used to endorse or promote
- * products derived from this software without specific prior
- * written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- -->
-<Window x:Class="GitSharp.Demo.Browser"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:g="clr-namespace:GitSharp;assembly=GitSharp"
- xmlns:HistoryGraph="clr-namespace:GitSharp.Demo.HistoryGraph"
- xmlns:Demo="clr-namespace:GitSharp.Demo"
- xmlns:Controls="clr-namespace:GitSharp.Demo.Controls"
- Title="GitSharp.Demo - Repository Browser" MinHeight="300" MinWidth="640" Width="800" Height="600">
-
- <Window.Resources>
- <!--repository tree templates-->
- <HierarchicalDataTemplate DataType="{x:Type g:Tree}" ItemsSource="{Binding Path=Children}">
- <TextBlock Text="{Binding Name}" TextTrimming="CharacterEllipsis" ToolTip="{Binding Hash}"/>
- </HierarchicalDataTemplate>
- <DataTemplate DataType="{x:Type g:AbstractObject}">
- <TextBlock Text="{Binding Name}" TextTrimming="CharacterEllipsis" Foreground="CornflowerBlue" ToolTip="{Binding Hash}"/>
- </DataTemplate>
- <LinearGradientBrush x:Key="SilverGradientTopVertical" StartPoint="0,0" EndPoint="0,1">
- <GradientStop Color="#FFEEEEEE" Offset="0" />
- <GradientStop Color="#FFCCCCCC" Offset="1" />
- </LinearGradientBrush>
- <Style x:Key="HeaderLabelStyle">
- <Setter Property="Label.Background" Value="{StaticResource SilverGradientTopVertical}" ></Setter>
- </Style>
- <!--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-->
- <Menu DockPanel.Dock="Top">
- <MenuItem Header="File" >
- <MenuItem Header="Open repository ..." Click="OnSelectRepository"/>
- <Separator />
- <MenuItem Header="Exit" Click="OnMenuClose" />
- </MenuItem>
- <MenuItem Header="Edit" >
- <MenuItem Header="Repository configuration..." Click="OnOpenRepositoryConfiguration"/>
- </MenuItem>
- </Menu>
- <!--status bar-->
- <DockPanel DockPanel.Dock="Bottom" LastChildFill="False" Background="LightGray">
- <Label Margin="0,0,5,0" Content="Repository:">
- <Label.ContextMenu>
- <ContextMenu>
- <MenuItem Header="Select repository path" Click="OnSelectRepository"/>
- </ContextMenu>
- </Label.ContextMenu>
- </Label>
- <TextBox Name="m_url_textbox" MinWidth="100">.</TextBox>
- <Button Click="OnLoadRepository" Margin="5,0,0,0">Reload</Button>
- </DockPanel>
- <DockPanel >
- <!--commit history graph-->
- <DockPanel Width="400">
- <Label DockPanel.Dock="Top" Style="{StaticResource HeaderLabelStyle}">Revision History</Label>
- <HistoryGraph:HistoryGraphView x:Name="m_history_graph" DockPanel.Dock="Top" Height="300"/>
- <Controls:DockPanelSplitter DockPanel.Dock="Top" Height="4"/>
-
- <!--lower half-->
-
- <Grid Grid.Row="2" DockPanel.Dock="Top">
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="1*"/>
- <ColumnDefinition Width="2"/>
- <ColumnDefinition Width="2*"/>
- </Grid.ColumnDefinitions>
- <!--tree-->
- <DockPanel Grid.Column="0">
- <Label DockPanel.Dock="Top" Name="m_tree_title" Style="{StaticResource HeaderLabelStyle}">Source Tree (select to show content)</Label>
- <TreeView Name="m_tree"/>
- </DockPanel>
-
- <GridSplitter ResizeBehavior="PreviousAndNext" Width="2" Grid.Column="1"/>
- <!--object-->
- <DockPanel Grid.Column="2">
- <Label DockPanel.Dock="Top" Name="m_object_title" Style="{StaticResource HeaderLabelStyle}">Blob contents of selected tree node</Label>
- <RichTextBox Name="m_object" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"/>
- </DockPanel>
-
- </Grid>
-
- </DockPanel>
- <Controls:DockPanelSplitter DockPanel.Dock="Left" Width="4" BorderThickness="1"/>
- <!--commit browser-->
- <DockPanel DockPanel.Dock="Top">
-
- <!--upper half-->
- <DockPanel DockPanel.Dock="Top">
-
- <!--tags and branches-->
- <DockPanel Margin="0" DockPanel.Dock="Top">
- <Label DockPanel.Dock="Top" Name="m_refs_title" Style="{StaticResource HeaderLabelStyle}">Selected Commit</Label>
- <!--<ListView Name="m_refs" DockPanel.Dock="Top" >
- <ListView.View>
- <GridView>
- <GridView.Columns>
- <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Path=Name}"/>
- <GridViewColumn Header="SHA" DisplayMemberBinding="{Binding Path=ObjectId}"/>
- <GridViewColumn Header="OriginalName" DisplayMemberBinding="{Binding Path=OriginalName}"/>
- <GridViewColumn Header="Detached" DisplayMemberBinding="{Binding Path=Detached}"/>
- <GridViewColumn Header="Storage" DisplayMemberBinding="{Binding Path=StorageFormat.Name}"/>
- </GridView.Columns>
- </GridView>
- </ListView.View>
- </ListView>-->
- <Demo:CommitSummaryView x:Name="m_commit_view"/>
- </DockPanel>
- <Controls:DockPanelSplitter DockPanel.Dock="Top" Height="4"/>
- <!--commits-->
- <DockPanel DockPanel.Dock="Top">
- <Label DockPanel.Dock="Top" Name="m_commit_title" Style="{StaticResource HeaderLabelStyle}">Changes by this commit (select a modification to view the diff)</Label>
- <Demo:CommitDiffView x:Name="m_commit_diff" DockPanel.Dock="Top" />
- <Controls:DockPanelSplitter DockPanel.Dock="Top" Height="4"/>
- <Label DockPanel.Dock="Top" Style="{StaticResource HeaderLabelStyle}">Differences</Label>
- <Demo:TextDiffView x:Name="m_text_diff" DockPanel.Dock="Top" />
- </DockPanel>
- <!--<GridSplitter Width="2" Grid.Column="1" ResizeBehavior="PreviousAndNext"/>-->
-
- </DockPanel>
- <!--<GridSplitter Grid.Row="1" ResizeBehavior="PreviousAndNext" ResizeDirection="Rows" Height="6" Background="White"/>-->
- </DockPanel>
-
- </DockPanel>
- </DockPanel>
-
-</Window>
View
244 Browser.xaml.cs
@@ -1,244 +0,0 @@
-/*
- * Copyright (C) 2009, Henon <meinrad.recheis@gmail.com>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- *
- * - Neither the name of the project nor the
- * names of its contributors may be used to endorse or promote
- * products derived from this software without specific prior
- * written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.IO;
-using System.Linq;
-using System.Security;
-using System.Windows;
-using System.Windows.Documents;
-using System.Diagnostics;
-using System.Windows.Threading;
-
-
-namespace GitSharp.Demo
-{
-
- public partial class Browser
- {
- public const string CURRENT_REPOSITORY = "repository";
- public Browser()
- {
- InitializeComponent();
- //m_commits.SelectionChanged += (o, args) => SelectCommit(m_commits.SelectedItem as Commit);
- //m_branches.SelectionChanged += (o, args) => SelectBranch(m_branches.SelectedItem as Branch);
- //m_refs.SelectionChanged += (o, args) => SelectRef(m_refs.SelectedItem as Ref);
- m_tree.SelectedItemChanged += (o, args) => SelectObject(m_tree.SelectedValue as AbstractObject);
- m_commit_diff.SelectionChanged += change => m_text_diff.Show(change);
- //m_config_tree.SelectedItemChanged += (o, args) => SelectConfiguration(m_config_tree.SelectedItem);
- m_history_graph.CommitClicked += SelectCommit;
- m_url_textbox.Text = UserSettings.GetString(CURRENT_REPOSITORY);
- Loaded += (o, args) => Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => LoadRepository(m_url_textbox.Text)));
- }
-
-
- Repository m_repository;
-
- // load
- private void OnLoadRepository(object sender, RoutedEventArgs e)
- {
- var url = m_url_textbox.Text;
- LoadRepository(url);
- }
-
- private void LoadRepository(string url)
- {
- var git_url = Repository.FindRepository(url);
- if (git_url == null || !Repository.IsValid(git_url))
- {
- MessageBox.Show("Given path doesn't seem to refer to a git repository: " + url);
- return;
- }
- var repo = new Repository(git_url);
- m_url_textbox.Text = git_url;
- UserSettings.SetValue(CURRENT_REPOSITORY, git_url);
- var head = repo.Head.Target as Commit;
- Debug.Assert(head != null);
- m_repository = repo;
- //var tags = repo.getTags().Values.Select(@ref => repo.MapTag(@ref.Name, @ref.ObjectId));
- //var branches = repo.Branches.Values.Select(@ref => repo.MapCommit(@ref.ObjectId));
- //m_refs.ItemsSource = repo.Refs.Values;
- SelectCommit(head);
- m_history_graph.Update(repo);
- }
-
- private void SelectObject(AbstractObject node)
- {
- if (node.IsBlob)
- {
- var blob = node as Leaf;
- var text = blob.Data;
- m_object.Document.Blocks.Clear();
- var p = new Paragraph();
- p.Inlines.Add(text);
- m_object.Document.Blocks.Add(p);
- m_object_title.Content = "Content of " + blob.Path;
- }
- else
- {
- m_object.Document.Blocks.Clear();
- }
- }
-
- private void SelectBranch(object branch)
- {
- if (branch == null)
- return;
- //DisplayCommit(branch.Commit, "Branch "+branch.Name);
- }
-
- private void SelectRef(Ref r)
- {
- if (r == null)
- return;
- var obj = r.Target;
- if (obj.IsCommit)
- {
- DisplayCommit(obj as Commit, "Commit history of " + r.Name);
- return;
- }
- else if (obj.IsTag)
- {
- var tag = obj as Tag;
- if (tag.Target == tag) // it sometimes happens to have self referencing tags
- {
- return;
- }
- SelectTag(tag);
- return;
- }
- else if (obj.IsTree)
- {
- // hmm, display somehow
- }
- else if (obj.IsBlob)
- {
- // hmm, display somehow
- }
- else
- {
- Debug.Fail("don't know how to display this object: " + obj.ToString());
- }
- }
-
- private void SelectTag(Tag tag)
- {
- if (tag == null)
- return;
- if (tag.Target.IsCommit)
- DisplayCommit(tag.Target as Commit, "Commit history of Tag " + tag.Name);
- else
- SelectObject(tag.Target);
- }
-
- private void OnSelectRepository(object sender, RoutedEventArgs e)
- {
- var dlg = new System.Windows.Forms.FolderBrowserDialog();
- dlg.SelectedPath = Path.GetDirectoryName(UserSettings.GetString(CURRENT_REPOSITORY));
- //dlg.CheckPathExists = true;
- if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- m_url_textbox.Text = dlg.SelectedPath;
- LoadRepository(m_url_textbox.Text);
- }
- }
-
- //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 DisplayCommit(Commit commit, string info)
- {
- if (commit == null)
- return;
- //var list = commit.Ancestors.ToList();
- //list.Insert(0, commit);
- //m_commits.ItemsSource = list;
- //m_commits.SelectedIndex = 0;
- }
-
- private void SelectCommit(Commit commit)
- {
- if (commit == null || commit.Tree == null)
- return;
- m_commit_view.Commit = commit;
- m_tree.ItemsSource = commit.Tree.Children;
- m_tree_title.Content = "Repository tree of Commit " + commit.ShortHash;
- m_commit_diff.Init(commit.Parent, commit);
- //m_text_diff.Clear();
- //m_commit_title.Text = "Commit history for " + info;
- //(m_tree.ItemContainerGenerator.ContainerFromIndex(0) as TreeViewItem).IsExpanded = true;
- }
-
-
-
- private void OnDiffSelectedCommits(object sender, RoutedEventArgs e)
- {
- //var selection = m_commits.SelectedItems;
- //if (selection.Count < 2)
- // return;
- //var first_two=selection.Cast<Commit>().Take(2).ToArray();
- //var commit_diff = new CommitDiffView();
- //commit_diff.Init(first_two[0], first_two[1]);
- //commit_diff.ShowDialog();
- }
-
-
-
- private void OnMenuClose(object sender, RoutedEventArgs e)
- {
- this.Close();
- }
-
-
- private void OnOpenRepositoryConfiguration(object sender, RoutedEventArgs e)
- {
- Configuration configurationWindow = new Configuration();
- configurationWindow.Init(m_repository);
- configurationWindow.ShowDialog();
- }
-
-
- }
-}
View
113 BrowserView.xaml
@@ -0,0 +1,113 @@
+<!--
+ /*
+ * Copyright (C) 2009, Henon<meinrad.recheis@gmail.com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the project nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+ -->
+<UserControl x:Class="GitSharp.Demo.BrowserView"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:g="clr-namespace:GitSharp;assembly=GitSharp"
+ xmlns:HistoryGraph="clr-namespace:GitSharp.Demo.HistoryGraph"
+ xmlns:Demo="clr-namespace:GitSharp.Demo"
+ xmlns:Controls="clr-namespace:GitSharp.Demo.Controls"
+ MinHeight="300" MinWidth="300">
+
+ <UserControl.Resources>
+ <!--repository tree templates-->
+ <HierarchicalDataTemplate DataType="{x:Type g:Tree}" ItemsSource="{Binding Path=Children}">
+ <TextBlock Text="{Binding Name}" TextTrimming="CharacterEllipsis" ToolTip="{Binding Hash}"/>
+ </HierarchicalDataTemplate>
+ <DataTemplate DataType="{x:Type g:AbstractObject}">
+ <TextBlock Text="{Binding Name}" TextTrimming="CharacterEllipsis" Foreground="CornflowerBlue" ToolTip="{Binding Hash}"/>
+ </DataTemplate>
+ </UserControl.Resources>
+ <DockPanel >
+ <!--commit history graph-->
+ <DockPanel Width="400">
+ <Label DockPanel.Dock="Top" Style="{StaticResource HeaderLabelStyle}">Revision History</Label>
+ <HistoryGraph:HistoryGraphView x:Name="m_history_graph" DockPanel.Dock="Top" Height="300"/>
+ <Controls:DockPanelSplitter DockPanel.Dock="Top" Height="4"/>
+
+ <!--lower half-->
+
+ <Grid Grid.Row="2" DockPanel.Dock="Top">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="1*"/>
+ <ColumnDefinition Width="2"/>
+ <ColumnDefinition Width="2*"/>
+ </Grid.ColumnDefinitions>
+ <!--tree-->
+ <DockPanel Grid.Column="0">
+ <Label DockPanel.Dock="Top" Name="m_tree_title" Style="{StaticResource HeaderLabelStyle}">Source Tree (select to show content)</Label>
+ <TreeView Name="m_tree"/>
+ </DockPanel>
+
+ <GridSplitter ResizeBehavior="PreviousAndNext" Width="2" Grid.Column="1"/>
+ <!--object-->
+ <DockPanel Grid.Column="2">
+ <Label DockPanel.Dock="Top" Name="m_object_title" Style="{StaticResource HeaderLabelStyle}">Blob contents of selected tree node</Label>
+ <RichTextBox Name="m_object" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"/>
+ </DockPanel>
+
+ </Grid>
+
+ </DockPanel>
+ <Controls:DockPanelSplitter DockPanel.Dock="Left" Width="4" BorderThickness="1"/>
+ <!--commit browser-->
+ <DockPanel DockPanel.Dock="Top">
+
+ <!--upper half-->
+ <DockPanel DockPanel.Dock="Top">
+
+ <!--tags and branches-->
+ <DockPanel Margin="0" DockPanel.Dock="Top">
+ <Label DockPanel.Dock="Top" Name="m_refs_title" Style="{StaticResource HeaderLabelStyle}">Selected Commit</Label>
+ <Demo:CommitSummaryView x:Name="m_commit_view"/>
+ </DockPanel>
+ <Controls:DockPanelSplitter DockPanel.Dock="Top" Height="4"/>
+ <!--commits-->
+ <DockPanel DockPanel.Dock="Top">
+ <Label DockPanel.Dock="Top" Name="m_commit_title" Style="{StaticResource HeaderLabelStyle}">Changes by this commit (select a modification to view the diff)</Label>
+ <Demo:CommitDiffView x:Name="m_commit_diff" DockPanel.Dock="Top" />
+ <Controls:DockPanelSplitter DockPanel.Dock="Top" Height="4"/>
+ <Label DockPanel.Dock="Top" Style="{StaticResource HeaderLabelStyle}">Differences</Label>
+ <Demo:TextDiffView x:Name="m_text_diff" DockPanel.Dock="Top" />
+ </DockPanel>
+
+ </DockPanel>
+ </DockPanel>
+ </DockPanel>
+</UserControl>
View
114 BrowserView.xaml.cs
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2009, Henon <meinrad.recheis@gmail.com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the project nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using System.IO;
+using System.Linq;
+using System.Security;
+using System.Windows;
+using System.Windows.Documents;
+using System.Diagnostics;
+using System.Windows.Threading;
+using GitSharp.Demo.CommitView;
+
+
+namespace GitSharp.Demo
+{
+
+ public partial class BrowserView : IRepositoryView
+ {
+ public BrowserView()
+ {
+ InitializeComponent();
+ m_tree.SelectedItemChanged += (o, args) => SelectObject(m_tree.SelectedValue as AbstractObject);
+ m_commit_diff.SelectionChanged += change => m_text_diff.Show(change);
+ m_history_graph.CommitClicked += SelectCommit;
+ }
+
+ public Repository Repository { get; private set; }
+
+ private void SelectObject(AbstractObject node)
+ {
+ if (node.IsBlob)
+ {
+ var blob = node as Leaf;
+ var text = blob.Data;
+ m_object.Document.Blocks.Clear();
+ var p = new Paragraph();
+ p.Inlines.Add(text);
+ m_object.Document.Blocks.Add(p);
+ m_object_title.Content = "Content of " + blob.Path;
+ }
+ else
+ {
+ m_object.Document.Blocks.Clear();
+ }
+ }
+
+ private void SelectCommit(Commit commit)
+ {
+ if (commit == null || commit.Tree == null)
+ return;
+ m_commit_view.Commit = commit;
+ m_tree.ItemsSource = commit.Tree.Children;
+ m_tree_title.Content = "Repository tree of Commit " + commit.ShortHash;
+ m_commit_diff.Init(commit.Parent, commit);
+ }
+
+ private void OnDiffSelectedCommits(object sender, RoutedEventArgs e)
+ {
+ //var selection = m_commits.SelectedItems;
+ //if (selection.Count < 2)
+ // return;
+ //var first_two=selection.Cast<Commit>().Take(2).ToArray();
+ //var commit_diff = new CommitDiffView();
+ //commit_diff.Init(first_two[0], first_two[1]);
+ //commit_diff.ShowDialog();
+ }
+
+ #region IRepositoryView Members
+
+ public void Update(Repository repository)
+ {
+ Repository = repository;
+ SelectCommit(Repository.Head.CurrentCommit);
+ m_history_graph.Update(Repository);
+ }
+
+ #endregion
+ }
+}
View
40 CommitSummaryView.xaml
@@ -1,4 +1,42 @@
-<UserControl x:Class="GitSharp.Demo.CommitSummaryView"
+<!--
+ /*
+ * Copyright (C) 2010, Henon<meinrad.recheis@gmail.com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the project nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+ -->
+ <UserControl x:Class="GitSharp.Demo.CommitSummaryView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Demo="clr-namespace:GitSharp.Demo"
View
38 CommitSummaryView.xaml.cs
@@ -1,4 +1,40 @@
-using System;
+/*
+ * Copyright (C) 2010, Henon <meinrad.recheis@gmail.com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the project nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
View
74 CommitView/CommitDialog.xaml
@@ -0,0 +1,74 @@
+<!--
+ /*
+ * Copyright (C) 2010, Henon<meinrad.recheis@gmail.com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the project nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+ -->
+<Window x:Class="GitSharp.Demo.CommitView.CommitDialog"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:Demo="clr-namespace:GitSharp.Demo"
+ Title="CommitDialog" Height="300" Width="300">
+ <DockPanel LastChildFill="True">
+ <DockPanel DockPanel.Dock="Bottom" LastChildFill="False">
+ <Button IsCancel="True" DockPanel.Dock="Right" Margin="5" Click="Button_Click_1">Cancel</Button>
+ <Button IsDefault="True" DockPanel.Dock="Right" Margin="5" Click="Button_Click">Commit</Button>
+ </DockPanel>
+ <DockPanel DockPanel.Dock="Bottom" >
+ <Label DockPanel.Dock="Top">Commit message</Label>
+ <TextBox AcceptsReturn="True" AcceptsTab="True" Margin="5" VerticalScrollBarVisibility="Auto" Height="100" Name="m_message" TextWrapping="Wrap">
+
+ </TextBox>
+ </DockPanel>
+ <DockPanel DockPanel.Dock="Top" >
+ <Label DockPanel.Dock="Top">Staged changes</Label>
+ <ListView DockPanel.Dock="Top" Name="m_list">
+ <ListView.View>
+ <GridView>
+ <GridViewColumn Header="Name" Width="100">
+ <GridViewColumn.CellTemplate>
+ <DataTemplate>
+ <TextBlock Text="{Binding Name}" Foreground="{Binding Converter={x:Static Demo:StatusListView.StatusToColorConverter}}"/>
+ </DataTemplate>
+ </GridViewColumn.CellTemplate>
+ </GridViewColumn>
+ <GridViewColumn Header="Status" DisplayMemberBinding="{Binding IndexPathStatus}"/>
+ <GridViewColumn Header="Path" DisplayMemberBinding="{Binding Path}"/>
+ </GridView>
+ </ListView.View>
+ </ListView>
+ </DockPanel>
+ </DockPanel>
+</Window>
View
96 CommitView/CommitDialog.xaml.cs
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2010, Henon <meinrad.recheis@gmail.com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the project nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace GitSharp.Demo.CommitView
+{
+ /// <summary>
+ /// Interaction logic for CommitDialog.xaml
+ /// </summary>
+ public partial class CommitDialog : Window
+ {
+ public CommitDialog()
+ {
+ InitializeComponent();
+ Width = double.NaN;
+ Height = double.NaN;
+ }
+
+ private Repository m_repository;
+
+ public Repository Repository
+ {
+ get { return m_repository; }
+ set
+ {
+ m_repository = value;
+ }
+ }
+
+ public void Init(IEnumerable<PathStatus> paths)
+ {
+ m_list.ItemsSource = paths;
+ }
+
+ private void Button_Click(object sender, RoutedEventArgs e)
+ {
+ if (m_message.Text.Trim().Length == 0)
+ {
+ MessageBox.Show("A commit message is required!");
+ return;
+ }
+ Repository.Commit(m_message.Text, new Author(Repository.Config["user.name"] ?? "anonymous", Repository.Config["user.email"] ?? ""));
+ Close();
+ }
+
+ private void Button_Click_1(object sender, RoutedEventArgs e)
+ {
+ Close();
+ }
+ }
+}
View
105 CommitView/StatusListView.xaml
@@ -0,0 +1,105 @@
+<!--
+ /*
+ * Copyright (C) 2009, Henon<meinrad.recheis@gmail.com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the project nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+ -->
+<UserControl x:Class="GitSharp.Demo.StatusListView"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:Demo="clr-namespace:GitSharp.Demo"
+ MinHeight="300" MinWidth="300">
+ <DockPanel>
+ <!--tree-->
+ <DockPanel>
+ <Label DockPanel.Dock="Top" Style="{StaticResource HeaderLabelStyle}">Changes</Label>
+ <ListView Name="m_list">
+ <ListView.View>
+ <GridView>
+ <GridViewColumn Header="Name">
+ <GridViewColumn.CellTemplate>
+ <DataTemplate>
+ <StackPanel Orientation="Horizontal">
+ <Viewbox Width="16" Height="16"></Viewbox>
+ <TextBlock Text="{Binding Name}" TextTrimming="CharacterEllipsis" Foreground="{Binding Converter={x:Static Demo:StatusListView.StatusToColorConverter}}" ToolTip="{Binding Path}"/>
+ </StackPanel>
+ </DataTemplate>
+ </GridViewColumn.CellTemplate>
+ </GridViewColumn>
+ <GridViewColumn Header="WorkingPathStatus" DisplayMemberBinding="{Binding WorkingPathStatus}"/>
+ <GridViewColumn Header="IndexPathStatus" DisplayMemberBinding="{Binding IndexPathStatus}"/>
+ <GridViewColumn Header="Path" DisplayMemberBinding="{Binding Path}"/>
+ </GridView>
+ </ListView.View>
+ <ListView.ContextMenu>
+ <ContextMenu>
+ <MenuItem Header="Stage" Click="OnStage" />
+ <MenuItem Header="Unstage" Click="OnUnstage" />
+ <MenuItem Header="Checkout staged (Modified --> Staged)" Click="OnCheckoutIndex" />
+ <MenuItem Header="Checkout" Click="OnCheckout" />
+ <MenuItem Header="Remove from index" Click="OnRemove" />
+ <MenuItem Header="Delete from index and directory" Click="OnDelete" />
+ <MenuItem Header="Commit staged changes" Click="OnCommitIndex" />
+ </ContextMenu>
+ </ListView.ContextMenu>
+ </ListView>
+ </DockPanel>
+ <!--<Controls:DockPanelSplitter Width="4"/>-->
+ <!--list-->
+ <!--<DockPanel>
+ <Label DockPanel.Dock="Top" Style="{StaticResource HeaderLabelStyle}">Files</Label>
+ <ListView Name="m_files">
+ <ListView.View>
+ <GridView>
+ <GridViewColumn Header="Name">
+ <GridViewColumn.CellTemplate>
+ <DataTemplate>
+ <TextBlock Text="{Binding}"/>
+ </DataTemplate>
+ </GridViewColumn.CellTemplate>
+ </GridViewColumn>
+ <GridViewColumn Header="Index state">
+ <GridViewColumn.CellTemplate>
+ <DataTemplate>
+ <TextBlock Text="{Binding}"/>
+ </DataTemplate>
+ </GridViewColumn.CellTemplate>
+ </GridViewColumn>
+ </GridView>
+ </ListView.View>
+ </ListView>
+ </DockPanel>-->
+ </DockPanel>
+</UserControl>
View
235 CommitView/StatusListView.xaml.cs
@@ -0,0 +1,235 @@
+/*
+ * Copyright (C) 2010, Henon <meinrad.recheis@gmail.com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the project nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Globalization;
+using System.Linq;
+using System.Threading;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Media;
+using System.Windows.Threading;
+using GitSharp.Demo.CommitView;
+using GitSharp.Demo.Util;
+
+namespace GitSharp.Demo
+{
+ public partial class StatusListView : IRepositoryView
+ {
+ public StatusListView()
+ {
+ InitializeComponent();
+ }
+
+ public event Action<IEnumerable<PathStatus>> SelectionChanged;
+
+
+ #region IRepositoryView Members
+
+ public void Update(Repository repository)
+ {
+ Repository = repository;
+ Reload();
+ }
+
+ #endregion
+
+
+ ObservableCollection<PathStatus> _status_paths = new ObservableCollection<PathStatus>();
+
+ private void Reload()
+ {
+ _status_paths.Clear();
+ m_list.ItemsSource = null;
+ m_list.ItemsSource = _status_paths;
+ ThreadPool.QueueUserWorkItem(o => new RepositoryStatus(Repository, new RepositoryStatusOptions { ForceContentCheck = false, PerPathNotificationCallback = OnUpdateStatus }));
+ m_list.SelectionChanged += (o, args) =>
+ {
+ if (SelectionChanged != null)
+ SelectionChanged(m_list.SelectedItems.OfType<PathStatus>());
+ };
+ }
+
+ private void OnUpdateStatus(PathStatus status)
+ {
+ this.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => _status_paths.Add(status)));
+ }
+
+ public Repository Repository
+ {
+ get;
+ private set;
+ }
+
+ public static IValueConverter StatusToColorConverter
+ {
+ get
+ {
+ return new GenericConverter { ConvertFunc = ConvertStatusToColor };
+ }
+ }
+
+ private static object ConvertStatusToColor(object arg, Type t, object parameter, CultureInfo culture)
+ {
+ var status = arg as PathStatus;
+ if (status == null)
+ return Brushes.Black;
+ if (status.IndexPathStatus == IndexPathStatus.MergeConflict)
+ return Brushes.Red;
+ if (status.IndexPathStatus == IndexPathStatus.Added || status.IndexPathStatus == IndexPathStatus.Staged)
+ return Brushes.Chartreuse;
+ if (status.IndexPathStatus == IndexPathStatus.Removed)
+ return Brushes.Orange;
+ if (status.WorkingPathStatus == WorkingPathStatus.Modified || status.WorkingPathStatus == WorkingPathStatus.Missing)
+ return Brushes.RoyalBlue;
+ if (status.WorkingPathStatus == WorkingPathStatus.Untracked)
+ return Brushes.Black;
+ return Brushes.Black;
+ }
+
+ private void OnStage(object sender, RoutedEventArgs e)
+ {
+ var status_paths = m_list.SelectedItems.OfType<PathStatus>();
+ if (status_paths == null)
+ return;
+ try
+ {
+ Repository.Index.Stage(status_paths.Select(sp => sp.Path).ToArray());
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+ }
+ Reload();
+ }
+
+ private void OnUnstage(object sender, RoutedEventArgs e)
+ {
+ var status_paths = m_list.SelectedItems.OfType<PathStatus>();
+ if (status_paths == null)
+ return;
+ try
+ {
+ Repository.Index.Unstage(status_paths.Select(sp => sp.Path).ToArray());
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+ }
+ Reload();
+ }
+
+ private void OnCheckout(object sender, RoutedEventArgs e)
+ {
+ var status_paths = m_list.SelectedItems.OfType<PathStatus>();
+ if (status_paths == null)
+ return;
+ try
+ {
+ Repository.Head.CurrentCommit.Checkout(status_paths.Select(sp => sp.Path).ToArray());
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+ }
+ Reload();
+ }
+
+ private void OnCheckoutIndex(object sender, RoutedEventArgs e)
+ {
+ var status_paths = m_list.SelectedItems.OfType<PathStatus>();
+ if (status_paths == null)
+ return; try
+ {
+ Repository.Index.Checkout(status_paths.Select(sp => sp.Path).ToArray());
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+ }
+ Reload();
+ }
+
+ private void OnDelete(object sender, RoutedEventArgs e)
+ {
+ var status_paths = m_list.SelectedItems.OfType<PathStatus>();
+ if (status_paths == null)
+ return;
+ try
+ {
+ Repository.Index.Delete(status_paths.Select(sp => sp.Path).ToArray());
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+ }
+ Reload();
+ }
+
+ private void OnRemove(object sender, RoutedEventArgs e)
+ {
+ var status_paths = m_list.SelectedItems.OfType<PathStatus>();
+ if (status_paths == null)
+ return;
+ try
+ {
+ Repository.Index.Remove(status_paths.Select(sp => sp.Path).ToArray());
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+ }
+ Reload();
+ }
+
+ private void OnCommitIndex(object sender, RoutedEventArgs e)
+ {
+ StartCommitDialog();
+ }
+
+ public void StartCommitDialog()
+ {
+ var dlg = new CommitDialog { Repository = Repository };
+ dlg.Init(_status_paths.Where(p => p.IndexPathStatus != IndexPathStatus.Unchanged));
+ dlg.ShowDialog();
+ Update(Repository);
+ }
+ }
+
+}
View
53 CommitView/StatusView.xaml
@@ -0,0 +1,53 @@
+<!--
+ /*
+ * Copyright (C) 2010, Henon<meinrad.recheis@gmail.com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the project nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+ -->
+<UserControl x:Class="GitSharp.Demo.CommitView.StatusView"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:Demo="clr-namespace:GitSharp.Demo"
+ xmlns:Controls="clr-namespace:GitSharp.Demo.Controls"
+ MinHeight="300" MinWidth="300">
+ <DockPanel>
+ <StackPanel Orientation ="Horizontal" DockPanel.Dock="Top">
+ <Button Click="OnCommitButtonClick">Commit staged changes ...</Button>
+ </StackPanel>
+ <Demo:StatusListView x:Name="m_status_list"/>
+ <Controls:DockPanelSplitter Width="4"/>
+ <Demo:TextDiffView x:Name="m_diff_view"/>
+ </DockPanel>
+</UserControl>
View
99 CommitView/StatusView.xaml.cs
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2010, Henon <meinrad.recheis@gmail.com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the project nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Windows;
+
+namespace GitSharp.Demo.CommitView
+{
+ /// <summary>
+ /// Interaction logic for StatusWindow.xaml
+ /// </summary>
+ public partial class StatusView : IRepositoryView
+ {
+ public StatusView()
+ {
+ InitializeComponent();
+ m_status_list.SelectionChanged += OnStatusViewSelectionChanged;
+ }
+
+ public void Update(Repository repo)
+ {
+ Repository = repo;
+ m_status_list.Update(repo);
+ }
+
+ private void OnStatusViewSelectionChanged(IEnumerable<PathStatus> status_paths)
+ {
+ var status_path = status_paths.FirstOrDefault();
+ if (status_path == null)
+ return;
+ byte[] a = new byte[0];
+ var a_path = Path.Combine(Repository.WorkingDirectory, status_path.Path);
+ if (new FileInfo(a_path).Exists)
+ {
+ if (Diff.IsBinary(a_path) == true)
+ a = Encoding.ASCII.GetBytes("Binary content\nFile size: " + new FileInfo(a_path).Length);
+ else
+ a = File.ReadAllBytes(a_path);
+ }
+ byte[] b = new byte[0];
+ var blob = Repository.Index[status_path.Path];
+ if (blob != null)
+ if (Diff.IsBinary(blob.RawData) == true)
+ b = Encoding.ASCII.GetBytes("Binary content\nFile size: " + blob.RawData.Length);
+ else
+ b = blob.RawData;
+ m_diff_view.Init(new Diff(a, b));
+ }
+
+ public Repository Repository
+ {
+ get;
+ private set;
+ }
+
+ private void OnCommitButtonClick(object sender, RoutedEventArgs e)
+ {
+ m_status_list.StartCommitDialog();
+ }
+ }
+}
View
161 CommitView/WorkingTree.cs
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2010, Henon <meinrad.recheis@gmail.com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the project nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+
+namespace GitSharp.Demo.CommitView
+{
+ public class WorkingTree
+ {
+ public WorkingTree(string path, RepositoryStatus status)
+ {
+ Path = path;
+ RelativePath = "";
+ RepositoryStatus = status;
+ }
+
+ public RepositoryStatus RepositoryStatus
+ {
+ get; set;
+ }
+
+ public string Path
+ {
+ get;
+ private set;
+ }
+
+ protected virtual DirectoryInfo DirectoryInfo
+ {
+ get
+ {
+ return new DirectoryInfo(Path);
+ }
+ }
+
+ public string Name
+ {
+ get
+ {
+ return DirectoryInfo.Name;
+ }
+ }
+
+ public string RelativePath
+ {
+ get; private set;
+ }
+
+ public IEnumerable<WorkingTree> Children
+ {
+ get {
+ return DirectoryInfo.GetDirectories().Select(d => new WorkingTree(d.FullName, RepositoryStatus) {RelativePath = System.IO.Path.Combine(RelativePath, d.Name)}).Concat
+ (
+ DirectoryInfo.GetFiles().Select(f => new WorkingFile(f.FullName, RepositoryStatus) { RelativePath = System.IO.Path.Combine(RelativePath, f.Name) } as WorkingTree)
+ );
+ }
+ }
+
+ public virtual string Status
+ {
+ get { return ""; }
+ }
+ }
+
+ public class WorkingFile : WorkingTree
+ {
+ public WorkingFile(string path, RepositoryStatus status)
+ : base(path, status)
+ {
+ }
+
+
+ protected override DirectoryInfo DirectoryInfo
+ {
+ get
+ {
+ return new FileInfo(Path).Directory;
+ }
+ }
+
+ FileInfo FileInfo
+ {
+ get
+ {
+ return new FileInfo(Path);
+ }
+ }
+
+ public string Name
+ {
+ get
+ {
+ return FileInfo.Name;
+ }
+ }
+
+ public IEnumerable<WorkingTree> Children
+ {
+ get { return new WorkingTree[0]; }
+ }
+
+ public override string Status
+ {
+ get
+ {
+ if (RepositoryStatus.Added.Contains(RelativePath))
+ return "Added";
+ if (RepositoryStatus.MergeConflict.Contains(RelativePath))
+ return "MergeConflict";
+ if (RepositoryStatus.Missing.Contains(RelativePath))
+ return "Missing";
+ if (RepositoryStatus.Modified.Contains(RelativePath))
+ return "Modified";
+ if (RepositoryStatus.Removed.Contains(RelativePath))
+ return "Removed";
+ if (RepositoryStatus.Staged.Contains(RelativePath))
+ return "Staged";
+ if (RepositoryStatus.Untracked.Contains(RelativePath))
+ return "Untracked";
+ return "";
+ }
+ }
+ }
+}
View
91 CommitView/WorkingTreeView.xaml
@@ -0,0 +1,91 @@
+<!--
+ /*
+ * Copyright (C) 2009, Henon<meinrad.recheis@gmail.com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the project nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+ -->
+<UserControl x:Class="GitSharp.Demo.WorkingTreeView"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:Controls="clr-namespace:GitSharp.Demo.Controls"
+ xmlns:CommitView="clr-namespace:GitSharp.Demo.CommitView"
+ xmlns:Demo="clr-namespace:GitSharp.Demo"
+ Height="300" Width="300">
+ <UserControl.Resources>
+ <HierarchicalDataTemplate DataType="{x:Type CommitView:WorkingTree}" ItemsSource="{Binding Path=Children}">
+ <TextBlock Text="{Binding Name}" TextTrimming="CharacterEllipsis" ToolTip="{Binding Path}"/>
+ </HierarchicalDataTemplate>
+ <DataTemplate DataType="{x:Type CommitView:WorkingFile}">
+ <StackPanel Orientation="Horizontal">
+ <TextBlock Text="{Binding Name}" TextTrimming="CharacterEllipsis" Foreground="{Binding Path=Status, Converter={x:Static Demo:StatusListView.StatusToColorConverter}}" ToolTip="{Binding Path}"/>
+ <TextBlock Text=" ("/>
+ <TextBlock Text="{Binding Status}"/>
+ <TextBlock Text=")"/>
+ </StackPanel>
+ </DataTemplate>
+ </UserControl.Resources>
+ <DockPanel>
+ <!--tree-->
+ <DockPanel>
+ <Label DockPanel.Dock="Top" Style="{StaticResource HeaderLabelStyle}">Directories</Label>
+ <TreeView Name="m_directories"/>
+ </DockPanel>
+ <!--<Controls:DockPanelSplitter Width="4"/>-->
+ <!--list-->
+ <!--<DockPanel>
+ <Label DockPanel.Dock="Top" Style="{StaticResource HeaderLabelStyle}">Files</Label>
+ <ListView Name="m_files">
+ <ListView.View>
+ <GridView>
+ <GridViewColumn Header="Name">
+ <GridViewColumn.CellTemplate>
+ <DataTemplate>
+ <TextBlock Text="{Binding}"/>
+ </DataTemplate>
+ </GridViewColumn.CellTemplate>
+ </GridViewColumn>
+ <GridViewColumn Header="Index state">
+ <GridViewColumn.CellTemplate>
+ <DataTemplate>
+ <TextBlock Text="{Binding}"/>
+ </DataTemplate>
+ </GridViewColumn.CellTemplate>
+ </GridViewColumn>
+ </GridView>
+ </ListView.View>
+ </ListView>
+ </DockPanel>-->
+ </DockPanel>
+</UserControl>
View
99 CommitView/WorkingTreeView.xaml.cs
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2010, Henon <meinrad.recheis@gmail.com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the project nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using GitSharp.Demo.CommitView;
+using GitSharp.Demo.Util;
+
+namespace GitSharp.Demo
+{
+ /// <summary>
+ /// Interaction logic for StatusView.xaml
+ /// </summary>
+ public partial class WorkingTreeView : UserControl
+ {
+ public WorkingTreeView()
+ {
+ InitializeComponent();
+ Height = double.NaN;
+ Width = double.NaN;
+ }
+
+ public static IValueConverter StatusToColorConverter
+ {
+ get
+ {
+ return new GenericConverter {ConvertFunc = ConvertStatusToColor};
+ }
+ }
+
+ private static object ConvertStatusToColor(object arg, Type t, object parameter, CultureInfo culture)
+ {
+ var status = arg as string;
+ switch (status)
+ {
+ case "Modified":
+ return Brushes.RoyalBlue;
+ case "Added":
+ case "Staged":
+ return Brushes.Chartreuse;
+ case "MergeConflict":
+ return Brushes.Red;
+ //case "Missing":
+ //case "Removed":
+
+ case "Untracked":
+ return Brushes.DarkGray;
+ }
+ return Brushes.Black;
+ }
+ }
+
+
+}
View
74 GitSharp.Demo.csproj
@@ -33,17 +33,29 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="GitSharp, Version=0.2.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <Reference Include="DiffieHellman, Version=0.0.0.0, Culture=neutral">
<SpecificVersion>False</SpecificVersion>
- <HintPath>depend\GitSharp.dll</HintPath>
+ <HintPath>lib\DiffieHellman.dll</HintPath>
</Reference>
- <Reference Include="GitSharp.Core, Version=0.2.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <Reference Include="GitSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>depend\GitSharp.Core.dll</HintPath>
+ <HintPath>lib\GitSharp.dll</HintPath>
+ </Reference>
+ <Reference Include="GitSharp.Core, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>lib\GitSharp.Core.dll</HintPath>
+ </Reference>
+ <Reference Include="ICSharpCode.SharpZipLib, Version=0.85.4.369, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>lib\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=2.5.2.9222, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>depend\nunit.framework.dll</HintPath>
+ <HintPath>lib\nunit.framework.dll</HintPath>
+ </Reference>
+ <Reference Include="Org.Mentalis.Security, Version=1.0.13.715, Culture=neutral">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>lib\Org.Mentalis.Security.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
@@ -58,6 +70,10 @@
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
+ <Reference Include="Tamir.SharpSSH, Version=1.1.1.13, Culture=neutral">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>lib\Tamir.SharpSSH.dll</HintPath>
+ </Reference>
<Reference Include="UIAutomationProvider">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
@@ -70,13 +86,17 @@
<Reference Include="PresentationFramework">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
+ <Reference Include="Winterdom.IO.FileMap, Version=2.0.2.0, Culture=neutral, PublicKeyToken=4982617362e1edb5, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>lib\Winterdom.IO.FileMap.dll</HintPath>
+ </Reference>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
- <Page Include="Browser.xaml">
+ <Page Include="BrowserView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
@@ -88,6 +108,18 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+ <Page Include="CommitView\CommitDialog.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
+ <Page Include="CommitView\StatusView.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
+ <Page Include="CommitView\StatusListView.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
<Page Include="Configuration.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -100,6 +132,14 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+ <Page Include="CommitView\WorkingTreeView.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
+ <Page Include="MainFrame.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
<Page Include="TextDiffView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -108,8 +148,8 @@
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
- <Compile Include="Browser.xaml.cs">
- <DependentUpon>Browser.xaml</DependentUpon>
+ <Compile Include="BrowserView.xaml.cs">
+ <DependentUpon>BrowserView.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
@@ -120,6 +160,16 @@
<Compile Include="CommitSummaryView.xaml.cs">
<DependentUpon>CommitSummaryView.xaml</DependentUpon>
</Compile>
+ <Compile Include="CommitView\CommitDialog.xaml.cs">
+ <DependentUpon>CommitDialog.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="CommitView\StatusView.xaml.cs">
+ <DependentUpon>StatusView.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="CommitView\StatusListView.xaml.cs">
+ <DependentUpon>StatusListView.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="CommitView\WorkingTree.cs" />
<Compile Include="Configuration.xaml.cs">
<DependentUpon>Configuration.xaml</DependentUpon>
</Compile>
@@ -131,6 +181,10 @@
<DependentUpon>HistoryGraphView.xaml</DependentUpon>
</Compile>
<Compile Include="HistoryGraph\Selection.cs" />
+ <Compile Include="IRepositoryView.cs" />
+ <Compile Include="MainFrame.xaml.cs">
+ <DependentUpon>MainFrame.xaml</DependentUpon>
+ </Compile>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
@@ -144,10 +198,14 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
+ <Compile Include="CommitView\WorkingTreeView.xaml.cs">
+ <DependentUpon>WorkingTreeView.xaml</DependentUpon>
+ </Compile>
<Compile Include="TextDiffView.xaml.cs">
<DependentUpon>TextDiffView.xaml</DependentUpon>
</Compile>
<Compile Include="UserSettings.cs" />
+ <Compile Include="Util\GenericConverter.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
View
2  HistoryGraph/HistoryGraphView.xaml.cs
@@ -41,7 +41,7 @@
namespace GitSharp.Demo.HistoryGraph
{
- public partial class HistoryGraphView
+ public partial class HistoryGraphView : IRepositoryView
{
public event Action<Commit> CommitClicked;
View
48 IRepositoryView.cs
@@ -0,0 +1,48 @@
+ /*
+ * Copyright (C) 2010, Henon<meinrad.recheis@gmail.com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the project nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace GitSharp.Demo
+{
+ public interface IRepositoryView
+ {
+ void Update(Repository repository);
+ }
+}
View
76 MainFrame.xaml
@@ -0,0 +1,76 @@
+<!--
+ /*
+ * Copyright (C) 2010, Henon<meinrad.recheis@gmail.com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the project nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+ -->
+<Window x:Class="GitSharp.Demo.MainFrame"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:Demo="clr-namespace:GitSharp.Demo"
+ xmlns:CommitView="clr-namespace:GitSharp.Demo.CommitView"
+ Title="GitSharp Demo" MinHeight="300" MinWidth="300">
+ <DockPanel>
+ <!--menu-->
+ <Menu DockPanel.Dock="Top">
+ <MenuItem Header="File" >
+ <MenuItem Header="Open repository ..." Click="OnSelectRepository"/>
+ <Separator />
+ <MenuItem Header="Exit" Click="OnMenuClose" />
+ </MenuItem>
+ </Menu>
+ <!--status bar-->
+ <DockPanel DockPanel.Dock="Bottom" LastChildFill="False" Background="LightGray">
+ <Label Margin="0,0,5,0" Content="Repository:">
+ <Label.ContextMenu>
+ <ContextMenu>
+ <MenuItem Header="Select repository path" Click="OnSelectRepository"/>
+ </ContextMenu>
+ </Label.ContextMenu>
+ </Label>
+ <TextBox Name="m_url_textbox" MinWidth="100">.</TextBox>
+ <Button Click="OnLoadRepository" Margin="5,0,0,0">Reload</Button>
+ </DockPanel>
+
+ <TabControl Name="m_tab_control">
+ <TabItem Header="Browsing">
+ <Demo:BrowserView/>
+ </TabItem>
+ <TabItem Header="Committing" >
+ <CommitView:StatusView/>
+ </TabItem>
+ </TabControl>
+ </DockPanel>
+</Window>
View
116 MainFrame.xaml.cs
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2010, Henon <meinrad.recheis@gmail.com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the project nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Threading;
+
+namespace GitSharp.Demo
+{
+ /// <summary>
+ /// Interaction logic for MainFrame.xaml
+ /// </summary>
+ public partial class MainFrame : Window
+ {
+ public const string CURRENT_REPOSITORY = "repository";
+
+ public MainFrame()
+ {
+ InitializeComponent();
+ m_url_textbox.Text = UserSettings.GetString(CURRENT_REPOSITORY);
+ Loaded += (o, args) => Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => LoadRepository(m_url_textbox.Text)));
+ }
+
+
+ Repository m_repository;
+
+ private void OnLoadRepository(object sender, RoutedEventArgs e)
+ {
+ LoadRepository(m_url_textbox.Text);
+ }
+
+ private void LoadRepository(string url)
+ {
+ var git_url = Repository.FindRepository(url);
+ if (git_url == null || !Repository.IsValid(git_url))
+ {
+ MessageBox.Show("Given path doesn't seem to refer to a git repository: " + url);
+ return;
+ }
+ var repo = new Repository(git_url);
+ m_url_textbox.Text = git_url;
+ UserSettings.SetValue(CURRENT_REPOSITORY, git_url);
+ var head = repo.Head.Target as Commit;
+ Debug.Assert(head != null);
+ m_repository = repo;
+ foreach (TabItem tab in m_tab_control.Items)
+ {
+ var repo_view = tab.Content as IRepositoryView;
+ if (repo_view==null)
+ continue;
+ repo_view.Update(m_repository);
+ }
+ }
+
+ private void OnSelectRepository(object sender, RoutedEventArgs e)
+ {
+ var dlg = new System.Windows.Forms.FolderBrowserDialog();
+ dlg.SelectedPath = Path.GetDirectoryName(UserSettings.GetString(CURRENT_REPOSITORY));
+ if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+ {
+ m_url_textbox.Text = dlg.SelectedPath;
+ LoadRepository(m_url_textbox.Text);
+ }
+ }
+
+ private void OnMenuClose(object sender, RoutedEventArgs e)
+ {
+ this.Close();
+ Application.Current.Shutdown();
+ }
+ }
+}
View
40 TextDiffView.xaml.cs
@@ -1,4 +1,40 @@
-using System;
+/*
+ * Copyright (C) 2010, Henon <meinrad.recheis@gmail.com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the project nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -45,6 +81,8 @@ internal void Show(Change change)
}
var a = (change.ReferenceObject != null ? (change.ReferenceObject as Blob).RawData : new byte[0]);
var b = (change.ComparedObject != null ? (change.ComparedObject as Blob).RawData : new byte[0]);
+ a = (Diff.IsBinary(a)==true ? Encoding.ASCII.GetBytes("Binary content\nFile size: "+a.Length) : a);
+ b = (Diff.IsBinary(b) == true ? Encoding.ASCII.GetBytes("Binary content\nFile size: " + b.Length) : b);
Init(new Diff(a, b));
}
View
66 Util/GenericConverter.cs
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2010, Henon <meinrad.recheis@gmail.com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the project nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Windows.Data;
+
+namespace GitSharp.Demo.Util
+{
+
+ public class GenericConverter : IValueConverter
+ {
+ public Func<object, Type, object, CultureInfo, object> ConvertFunc { get; set; }
+ public Func<object, Type, object, CultureInfo, object> ConvertBackFunc { get; set; }
+
+ #region IValueConverter Members
+
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return ConvertFunc(value, targetType, parameter, culture);
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return ConvertBackFunc(value, targetType, parameter, culture);
+ }
+
+ #endregion
+ }
+}
View
BIN  depend/GitSharp.Core.dll
Binary file not shown