Пример #1
0
        /// <summary>
        /// Compares two nodes to sort them
        /// </summary>
        /// <param name="node1"></param>
        /// <param name="node2"></param>
        /// <returns></returns>
        private int CompareNodes(object node1, object node2)
        {
            int retVal = -1;

            FolderTreeNode folder1 = node1 as FolderTreeNode;
            FolderTreeNode folder2 = node2 as FolderTreeNode;

            TranslationTreeNode translation1 = node1 as TranslationTreeNode;
            TranslationTreeNode translation2 = node2 as TranslationTreeNode;

            if (folder1 != null && translation2 != null)
            {
                retVal = -1;
            }
            else if (folder2 != null && translation1 != null)
            {
                retVal = 1;
            }
            else if (folder1 != null && folder2 != null)
            {
                retVal = String.CompareOrdinal(folder1.Text, folder2.Text);
            }
            else if (translation1 != null && translation2 != null)
            {
                retVal = String.CompareOrdinal(translation1.Text, translation2.Text);
            }

            return(retVal);
        }
        /// <summary>
        ///     Accepts the drop event
        /// </summary>
        /// <param name="translationTreeNode"></param>
        /// <param name="sourceNode"></param>
        public static void AcceptDropForTranslation(TranslationTreeNode translationTreeNode, BaseTreeNode sourceNode)
        {
            if (sourceNode is SourceTextTreeNode)
            {
                SourceTextTreeNode text = sourceNode as SourceTextTreeNode;

                SourceText otherText = (SourceText)text.Item.Duplicate();
                translationTreeNode.Item.appendSourceTexts(otherText);
                text.Delete();
            }
            else if (sourceNode is StepTreeNode)
            {
                StepTreeNode step = sourceNode as StepTreeNode;

                if (string.IsNullOrEmpty(step.Item.getDescription()))
                {
                    MessageBox.Show(@"Step has no description and cannot be automatically translated",
                                    @"No description available", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    translationTreeNode.Item.appendSourceTexts(step.Item.CreateSourceText());
                }
            }
        }
        /// <summary>
        /// Creates a new translation
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public TranslationTreeNode createTranslation(DataDictionary.Tests.Translations.Translation translation)
        {
            TranslationTreeNode retVal;

            Item.appendTranslations(translation);
            retVal = new TranslationTreeNode(translation);
            Nodes.Add(retVal);
            SortSubNodes();

            return(retVal);
        }
Пример #4
0
        /// <summary>
        ///     Handles drop event
        /// </summary>
        /// <param name="sourceNode"></param>
        public override void AcceptDrop(BaseTreeNode sourceNode)
        {
            base.AcceptDrop(sourceNode);
            if (sourceNode is StepTreeNode)
            {
                StepTreeNode step = sourceNode as StepTreeNode;

                CreateTranslation(step.Item);
            }
            else if (sourceNode is TranslationTreeNode)
            {
                TranslationTreeNode translation      = sourceNode as TranslationTreeNode;
                Translation         otherTranslation = translation.Item;
                translation.Delete();
                CreateTranslation(otherTranslation);
            }
        }
        /// <summary>
        /// Accepts a drop event
        /// </summary>
        /// <param name="SourceNode"></param>
        public override void AcceptDrop(BaseTreeNode SourceNode)
        {
            base.AcceptDrop(SourceNode);
            if (SourceNode is TestRunnerView.StepTreeNode)
            {
                TestRunnerView.StepTreeNode step = SourceNode as TestRunnerView.StepTreeNode;

                createTranslation(step.Item);
            }
            else if (SourceNode is TranslationTreeNode)
            {
                TranslationTreeNode translation = SourceNode as TranslationTreeNode;

                DataDictionary.Tests.Translations.Translation otherTranslation = (DataDictionary.Tests.Translations.Translation)DataDictionary.Generated.acceptor.getFactory().createTranslation();
                translation.Item.copyTo(otherTranslation);
                createTranslation(otherTranslation);

                translation.Delete();
            }
        }
 /// <summary>
 ///     Handles drop event
 /// </summary>
 /// <param name="sourceNode"></param>
 public override void AcceptDrop(BaseTreeNode sourceNode)
 {
     base.AcceptDrop(sourceNode);
     TranslationTreeNode.AcceptDropForTranslation((TranslationTreeNode)Parent, sourceNode);
 }