Ejemplo n.º 1
0
 private async void ArchiveButton_Click(object sender, RoutedEventArgs e)
 {
     if (Archiving)
     {
         CancellationTokenSource.Cancel();
         CancellationTokenSource = new CancellationTokenSource();
     }
     else
     {
         ProgressIndicator.IsIndeterminate = true;
         Archiving = true;
         ContinuallyUpdateCounter();
         try
         {
             await Archiver.Begin(connection, CancellationTokenSource.Token);
         }
         catch (OperationCanceledException) { }
         Archiving = false;
         ProgressIndicator.IsIndeterminate = false;
     }
 }
Ejemplo n.º 2
0
        public void RunQuery(string query)
        {
            DataGrid.RowDefinitions.Clear();
            DataGrid.ColumnDefinitions.Clear();
            DataGrid.Children.Clear();

            string[] columns;
            int      numRows;
            var      results = Archiver.ExecuteSQL(connection, query, out columns, out numRows);

            DataGrid.RowDefinitions.Add(new RowDefinition()
            {
                Height = GridLength.Auto
            });
            for (int i = 0; i < columns.Length; i++)
            {
                DataGrid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = GridLength.Auto
                });
                TextBlock propBlock = new TextBlock()
                {
                    Text = columns[i], Margin = new Thickness(3, 2, 3, 3), MinWidth = 70
                };
                Grid.SetColumn(propBlock, i);
                DataGrid.Children.Add(propBlock);
            }

            Rectangle divider = new Rectangle()
            {
                Fill = new SolidColorBrush(Colors.Black), Height = 1, VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Stretch
            };

            Grid.SetColumnSpan(divider, columns.Length);
            DataGrid.Children.Add(divider);


            object item = null;

            for (int h = 0; h < numRows; h++)
            {
                DataGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = GridLength.Auto
                });
                for (int i = 0; i < columns.Length; i++)
                {
                    item = results[i, h];
                    if (item != null)
                    {
                        TextBlock itemBlock = new TextBlock()
                        {
                            Text = item.ToString(), Margin = new Thickness(2, 0, 2, 0)
                        };
                        Grid.SetRow(itemBlock, h + 1);
                        Grid.SetColumn(itemBlock, i);
                        DataGrid.Children.Add(itemBlock);
                    }
                }
            }
        }