public static bool StartEditing(Window parent, CrawlingBucket bucket)
        {
            CrawlingBucketEditor view = new CrawlingBucketEditor(bucket);

            view.Owner = parent;
            view.ShowDialog();

            return(view.ApplyChanges);
        }
        private void BtnEdit_Click(object sender, RoutedEventArgs e)
        {
            CrawlingConfig config = (CrawlingConfig)DataContext;
            CrawlingBucket bucket = (CrawlingBucket)((Control)sender).DataContext;
            CrawlingBucket clone  = CrawlingConfigurationSerializer.Clone(bucket);

            if (CrawlingBucketEditor.StartEditing(Window.GetWindow(this), clone))
            {
                int index = config.Buckets.IndexOf(bucket);
                config.Buckets[index] = clone;

                foreach (CrawlingRule rule in config.Rules)
                {
                    if (rule.TargetBucket == bucket)
                    {
                        rule.TargetBucket = clone;
                    }
                }
            }
        }