Example #1
0
        internal DragDropAction ShowChooseMergeOrConvert(TaxonDropContext context)
        {
            optMerge.Content = _owner.GetCaption("DragDropOptions.lblMerge", context.Source.Epithet, context.Target.Epithet);

            List<TaxonRank> conversionOptions = new List<TaxonRank>();
            if (context.TargetChildRank == null) {
                conversionOptions.AddRange(context.TaxaPlugin.Service.GetChildRanks(context.TargetRank));
            } else {
                conversionOptions.Add(context.TargetChildRank);
            }

            // Prepare the form depending on how many conversion options there all
            if (conversionOptions.Count == 0) {
                // No conversion options - only show the merge option
                grid.RowDefinitions[0].Height = new GridLength(80);
                grid.RowDefinitions[1].Height = Zero;
                grid.RowDefinitions[2].Height = Zero;
            } else if (conversionOptions.Count == 1) {
                var targetRank = conversionOptions[0];
                grid.RowDefinitions[0].Height = new GridLength(80);
                grid.RowDefinitions[1].Height = Forty;
                grid.RowDefinitions[2].Height = Zero;
                optConvert.Content = _owner.GetCaption("DragDropOptions.lblConvertAsChild", targetRank.LongName, context.Target.Epithet);
            } else {
                cmbRanks.ItemsSource = conversionOptions;
                cmbRanks.SelectedIndex = 0;
                grid.RowDefinitions[0].Height = new GridLength(80);
                grid.RowDefinitions[1].Height = Forty;
                grid.RowDefinitions[2].Height = Forty;
                optConvert.Content = _owner.GetCaption("DragDropOptions.lblConvert", context.SourceRank.LongName);
            }

            DragDropAction result = null;

            PrepareAutoSynonymy(context);

            optMerge.IsChecked = true;
            if (ShowDialog().GetValueOrDefault(false)) {
                if (optMerge.IsChecked.GetValueOrDefault(false)) {
                    result = new MergeDropAction(context, chkCreateIDRecord.IsChecked.GetValueOrDefault(false));
                    if (chkCreateAvailable.IsChecked.HasValue && chkCreateAvailable.IsChecked.Value) {
                        var availableName = _owner.TaxonExplorer.AddAvailableName(context.Target, false, false);
                        availableName.Epithet = context.Source.Epithet;
                        availableName.Author = context.Source.Author;
                        availableName.YearOfPub = context.Source.YearOfPub;
                        availableName.ChgComb = context.Source.ChgComb;
                    }
                } else {

                    TaxonRank convertToRank = null;
                    if (conversionOptions.Count == 1) {
                        convertToRank = conversionOptions[0];
                    } else {
                        convertToRank = cmbRanks.SelectedItem as TaxonRank;
                    }

                    result = new ConvertingMoveDropAction(context, convertToRank);
                }
            }

            return result;
        }
        internal DragDropAction ShowChooseMergeOrConvert(TaxonDropContext context)
        {
            optMerge.Content = _owner.GetCaption("DragDropOptions.lblMerge", context.Source.Epithet, context.Target.Epithet);

            List <TaxonRank> conversionOptions = new List <TaxonRank>();

            if (context.TargetChildRank == null)
            {
                conversionOptions.AddRange(context.TaxaPlugin.Service.GetChildRanks(context.TargetRank));
            }
            else
            {
                conversionOptions.Add(context.TargetChildRank);
            }

            // Prepare the form depending on how many conversion options there all
            if (conversionOptions.Count == 0)
            {
                // No conversion options - only show the merge option
                grid.RowDefinitions[0].Height = new GridLength(80);
                grid.RowDefinitions[1].Height = Zero;
                grid.RowDefinitions[2].Height = Zero;
            }
            else if (conversionOptions.Count == 1)
            {
                var targetRank = conversionOptions[0];
                grid.RowDefinitions[0].Height = new GridLength(80);
                grid.RowDefinitions[1].Height = Forty;
                grid.RowDefinitions[2].Height = Zero;
                optConvert.Content            = _owner.GetCaption("DragDropOptions.lblConvertAsChild", targetRank.LongName, context.Target.Epithet);
            }
            else
            {
                cmbRanks.ItemsSource          = conversionOptions;
                cmbRanks.SelectedIndex        = 0;
                grid.RowDefinitions[0].Height = new GridLength(80);
                grid.RowDefinitions[1].Height = Forty;
                grid.RowDefinitions[2].Height = Forty;
                optConvert.Content            = _owner.GetCaption("DragDropOptions.lblConvert", context.SourceRank.LongName);
            }

            DragDropAction result = null;

            PrepareAutoSynonymy(context);

            optMerge.IsChecked = true;
            if (ShowDialog().GetValueOrDefault(false))
            {
                if (optMerge.IsChecked.GetValueOrDefault(false))
                {
                    result = new MergeDropAction(context, chkCreateIDRecord.IsChecked.GetValueOrDefault(false));
                    if (chkCreateAvailable.IsChecked.HasValue && chkCreateAvailable.IsChecked.Value)
                    {
                        var availableName = _owner.TaxonExplorer.AddAvailableName(context.Target, false, false);
                        availableName.Epithet   = context.Source.Epithet;
                        availableName.Author    = context.Source.Author;
                        availableName.YearOfPub = context.Source.YearOfPub;
                        availableName.ChgComb   = context.Source.ChgComb;
                    }
                }
                else
                {
                    TaxonRank convertToRank = null;
                    if (conversionOptions.Count == 1)
                    {
                        convertToRank = conversionOptions[0];
                    }
                    else
                    {
                        convertToRank = cmbRanks.SelectedItem as TaxonRank;
                    }

                    result = new ConvertingMoveDropAction(context, convertToRank);
                }
            }

            return(result);
        }