Commits

Mark Heath committed c6a2b9d

able to load Git repositories

  • Participants
  • Parent commits ab22183

Comments (0)

Files changed (3)

File GraphPad/GraphPad.csproj

     </Reference>
     <Reference Include="System" />
     <Reference Include="System.Data" />
+    <Reference Include="System.Windows.Forms" />
     <Reference Include="System.Xml" />
     <Reference Include="Microsoft.CSharp" />
     <Reference Include="System.Core" />

File GraphPad/MainWindow.xaml

             <ColumnDefinition Width="200" />
             <ColumnDefinition Width="*" />
         </Grid.ColumnDefinitions>
-        <TextBox FontFamily="Consolas" AcceptsReturn="True" Grid.Column="0" x:Name="graphText"/>
+        <Grid Grid.Column="0">
+            <Grid.RowDefinitions>
+                <RowDefinition Height="Auto" />
+                <RowDefinition Height="*" />
+            </Grid.RowDefinitions>
+            <StackPanel Orientation="Horizontal">
+            <Button Content="Git..." x:Name="buttonGit" Margin="5" Width="50"/>
+            <Button Content="Hg..." x:Name="buttonMercurial" Margin="5" Width="50"/>
+            </StackPanel>
+            <TextBox FontFamily="Consolas" AcceptsReturn="True" Grid.Row="1" x:Name="graphText"/>
+        </Grid>
         <GridSplitter Grid.Column="0" Width="5"/>
         <ScrollViewer Grid.Column="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
             <Canvas x:Name="graphCanvas" />

File GraphPad/MainWindow.xaml.cs

         {
             InitializeComponent();
             this.graphText.TextChanged += new TextChangedEventHandler(graphText_TextChanged);
+            this.buttonGit.Click += new RoutedEventHandler(buttonGit_Click);
+        }
+
+        void buttonGit_Click(object sender, RoutedEventArgs e)
+        {
+            var dialog = new System.Windows.Forms.FolderBrowserDialog();
+            dialog.Description = "Select git repository";
+            var result = dialog.ShowDialog();
+            if (result == System.Windows.Forms.DialogResult.OK)
+            {
+                GitGraphBuilder gitBuilder = new GitGraphBuilder();
+                var graph = gitBuilder.LoadGraph(dialog.SelectedPath);
+                RedrawGraph(graph);
+            }
         }
 
         void graphText_TextChanged(object sender, TextChangedEventArgs e)
         private void RecreateGraph()
         {
             GraphBuilder builder = new GraphBuilder();
+            Graph graph = builder.GenerateGraph(graphText.Text);
+            RedrawGraph(graph);
+        }
+
+        private void RedrawGraph(Graph graph)
+        {
             GraphRenderer renderer = new GraphRenderer(graphCanvas);
             GraphLayoutEngine layout = new GraphLayoutEngine();
-            Graph graph = builder.GenerateGraph(graphText.Text);
             layout.Layout(graph);
             renderer.Render(graph);
         }