Esempio n. 1
0
        /// <summary>
        /// Modify the given hyperlink.
        /// </summary>
        public void ModifyHtmlHyperlink(HtmlHyperlink hyperlink)
        {
            using (HtmlSelectHyperlinkViewModel vm = new HtmlSelectHyperlinkViewModel(this.ViewModelStore))
            {
                vm.Title = "Edit a hyperlink";

                if (hyperlink.TargetName.Length > 0)
                {
                    bool bFoundTarget = false;
                    if (hyperlink.TargetName[0] == '#')
                    {
                        string href = hyperlink.TargetName.Substring(1, hyperlink.TargetName.Length - 1);
                        if (KeyGenerator.Instance.CanConvertVModellIDToGuid(href))
                        {
                            Guid         id           = KeyGenerator.Instance.ConvertVModellIDToGuid(href);
                            ModelElement modelElement = this.Store.ElementDirectory.FindElement(id);
                            if (modelElement != null)
                            {
                                bFoundTarget = true;
                                vm.SetSelectedElement(modelElement);
                            }
                        }
                    }

                    if (!bFoundTarget)
                    {
                        if (!String.IsNullOrEmpty(hyperlink.TargetName))
                        {
                            vm.SetSelectedElement(hyperlink.TargetName);
                        }
                    }
                }

                bool?result = this.GlobalServiceProvider.Resolve <IUIVisualizerService>().ShowDialog("SelectHyperlinkPopup", vm);
                if (result == true)
                {
                    if (vm.SelectedElement is string)
                    {
                        hyperlink.TargetName = vm.SelectedElement as string;
                    }
                    else if (vm.SelectedElement is ModelElement)
                    {
                        hyperlink.TargetName = "#" + KeyGenerator.Instance.ConvertGuidToVModellID(
                            (vm.SelectedElement as ModelElement).Id);
                    }
                }
            }
            GC.Collect();
        }
Esempio n. 2
0
        /// <summary>
        /// Insert hyperlink command executed.
        /// </summary>
        private void HtmlInsertHyperlinkCommand_Executed()
        {
            using (HtmlSelectHyperlinkViewModel vm = new HtmlSelectHyperlinkViewModel(this.ViewModelStore))
            {
                vm.Title = "Select a hyperlink to an existing element or as a web hyperlink.";

                bool?result = this.GlobalServiceProvider.Resolve <IUIVisualizerService>().ShowDialog("SelectHyperlinkPopup", vm);
                if (result == true)
                {
                    string targetName = null;
                    string targetText = null;
                    if (vm.SelectedElement is string)
                    {
                        targetName = vm.SelectedElement as string;
                        targetText = "Link";
                    }
                    else if (vm.SelectedElement is ModelElement)
                    {
                        ModelElement m = vm.SelectedElement as ModelElement;

                        targetName = "#" + KeyGenerator.Instance.ConvertGuidToVModellID(m.Id);
                        if (m is IDomainModelOwnable)
                        {
                            if ((m as IDomainModelOwnable).DomainElementHasName)
                            {
                                targetText = (m as IDomainModelOwnable).DomainElementName;
                            }
                            else
                            {
                                targetText = (m as IDomainModelOwnable).DomainElementTypeDisplayName;
                            }
                        }
                    }

                    if (targetName != null)
                    {
                        if (this.HtmlRichTextEditor != null)
                        {
                            this.HtmlRichTextEditor.InsertHyperlink(targetText, targetName);
                        }
                    }
                }
            }
            GC.Collect();
        }
        /// <summary>
        /// Insert hyperlink command executed.
        /// </summary>
        private void HtmlInsertHyperlinkCommand_Executed()
        {
            using (HtmlSelectHyperlinkViewModel vm = new HtmlSelectHyperlinkViewModel(this.ViewModelStore))
            {
                vm.Title = "Select a hyperlink to an existing element or as a web hyperlink.";

                bool? result = this.GlobalServiceProvider.Resolve<IUIVisualizerService>().ShowDialog("SelectHyperlinkPopup", vm);
                if (result == true)
                {
                    string targetName = null;
                    string targetText = null;
                    if (vm.SelectedElement is string)
                    {
                        targetName = vm.SelectedElement as string;
                        targetText = "Link";
                    }
                    else if (vm.SelectedElement is ModelElement)
                    {
                        ModelElement m = vm.SelectedElement as ModelElement;

                        targetName = "#" + KeyGenerator.Instance.ConvertGuidToVModellID(m.Id);
                        if (m is IDomainModelOwnable)
                        {
                            if ((m as IDomainModelOwnable).DomainElementHasName)
                                targetText = (m as IDomainModelOwnable).DomainElementName;
                            else
                                targetText = (m as IDomainModelOwnable).DomainElementTypeDisplayName;
                        }
                    }

                    if (targetName != null)
                    {
                        if (this.HtmlRichTextEditor != null)
                            this.HtmlRichTextEditor.InsertHyperlink(targetText, targetName);
                    }
                }
            }
            GC.Collect();
        }
        /// <summary>
        /// Modify the given hyperlink.
        /// </summary>
        public void ModifyHtmlHyperlink(HtmlHyperlink hyperlink)
        {
            using (HtmlSelectHyperlinkViewModel vm = new HtmlSelectHyperlinkViewModel(this.ViewModelStore))
            {
            vm.Title = "Edit a hyperlink";

            if (hyperlink.TargetName.Length > 0)
            {
                bool bFoundTarget = false;
                if (hyperlink.TargetName[0] == '#')
                {
                    string href = hyperlink.TargetName.Substring(1, hyperlink.TargetName.Length - 1);
                    if (KeyGenerator.Instance.CanConvertVModellIDToGuid(href))
                    {
                        Guid id = KeyGenerator.Instance.ConvertVModellIDToGuid(href);
                        ModelElement modelElement = this.Store.ElementDirectory.FindElement(id);
                        if (modelElement != null)
                        {
                            bFoundTarget = true;
                            vm.SetSelectedElement(modelElement);
                        }
                    }
                }

                if (!bFoundTarget)
                {
                    if (!String.IsNullOrEmpty(hyperlink.TargetName))
                        vm.SetSelectedElement(hyperlink.TargetName);
                }
            }

            bool? result = this.GlobalServiceProvider.Resolve<IUIVisualizerService>().ShowDialog("SelectHyperlinkPopup", vm);
            if (result == true)
            {
                if (vm.SelectedElement is string)
                {
                    hyperlink.TargetName = vm.SelectedElement as string;
                }
                else if (vm.SelectedElement is ModelElement)
                {
                    hyperlink.TargetName = "#" + KeyGenerator.Instance.ConvertGuidToVModellID(
                        (vm.SelectedElement as ModelElement).Id);
                }
            }
            }
            GC.Collect();
        }