/// <summary>
        /// Creates a link that opens the platform's Xbox Music app with the specified view.
        /// </summary>
        /// <param name="action">The view to open for this particular entity.</param>
        /// <returns></returns>
        public string GetDeepLink(LinkAction action = LinkAction.View)
        {
            var actionString = Enum.GetName(typeof(LinkAction), action).ToLower();
            var format       = Link.Contains("?") ? "{0}&action={1}" : "{0}?action={1}";

            return(string.Format(format, Link, actionString));
        }
示例#2
0
 /// <summary>
 /// Makes sure the current action is the required Destination action
 /// </summary>
 /// <param name="action"></param>
 private void AssertIsRemoteDestination(LinkAction action)
 {
     if (action != LinkAction.ExternalDestination)
     {
         throw new ArgumentOutOfRangeException("action");
     }
 }
示例#3
0
 /// <summary>
 /// Makes sure the current action is the required ExternalDestination action
 /// </summary>
 /// <param name="action"></param>
 private void AssertIsUrlDestination(LinkAction action)
 {
     if (action != LinkAction.Uri)
     {
         throw new ArgumentOutOfRangeException("action");
     }
 }
示例#4
0
        public static MvcHtmlString DynamicLink(this HtmlHelper helper, LinkAction action, string id, string caption, object viewData = null, string href = null)
        {
            href = HtmlHelpers.ActionToCommand(action, href);

            TagBuilder tag = new TagBuilder("a");

            tag.Attributes.Add("id", id);
            tag.Attributes.Add("href", href);
            tag.SetInnerText(caption);

            RouteValueDictionary htmlAttributes;
            RouteValueDictionary viewDataObj = HtmlHelper.AnonymousObjectToHtmlAttributes(viewData);

            if (viewDataObj.ContainsKey("htmlAttributes"))
            {
                htmlAttributes = HtmlHelper.AnonymousObjectToHtmlAttributes(viewDataObj["htmlAttributes"]);
            }
            else
            {
                htmlAttributes = viewDataObj;
            }

            foreach (var attr in viewDataObj)
            {
                tag.Attributes.Add(attr.Key, attr.Value.ToString());
            }

            return(tag.ToMvcHtmlString(TagRenderMode.Normal));
        }
示例#5
0
        /// <summary>
        /// Gets the known PDF name for the specified action. Only the supported named actions will return a value.
        /// Other action types with throw an ArgumentOutOfRange excpetion
        /// </summary>
        /// <param name="linkAction"></param>
        /// <returns></returns>
        private string GetNameForAction(LinkAction linkAction)
        {
            string name;

            switch (linkAction)
            {
            case LinkAction.Undefined:
            case LinkAction.Uri:
            case LinkAction.Destination:
            case LinkAction.ExternalDestination:
            case LinkAction.Launch:
                throw RecordAndRaise.ArgumentOutOfRange("linkAction");

            case LinkAction.NextPage:
                name = "NextPage";
                break;

            case LinkAction.PrevPage:
                name = "PrevPage";
                break;

            case LinkAction.FirstPage:
                name = "FirstPage";
                break;

            case LinkAction.LastPage:
                name = "LastPage";
                break;

            default:
                throw RecordAndRaise.ArgumentOutOfRange("linkAction");
            }
            return(name);
        }
示例#6
0
 /// <summary>
 /// [RegisterLinkNotifyCallback]
 /// コマンダーが変更された場合に呼び出されるコールバックを登録する
 /// 引数1: 登録するコールバック
 /// </summary>
 public void RegisterLinkNotifyCallback(LinkAction callback)
 {
     if (callback != null)
     {
         m_linkNotifyCallback += callback;
     }
 }
示例#7
0
 public Link(string url, int startIndex, int length, LinkAction action, string argument)
 {
     Url      = url;
     Index    = startIndex;
     Length   = length;
     Action   = action;
     Argument = argument;
 }
示例#8
0
        public void AddLink(string text, string url, LinkAction linkType = LinkAction.External, string linkArgument = null, string tooltipText = null, Action <SpriteText> creationParameters = null)
        {
            AddInternal(new DrawableLinkCompiler(AddText(text, creationParameters).ToList())
            {
                TooltipText = tooltipText ?? (url != text ? url : string.Empty),
                Action      = () =>
                {
                    switch (linkType)
                    {
                    case LinkAction.OpenBeatmap:
                        // TODO: proper query params handling
                        if (linkArgument != null && int.TryParse(linkArgument.Contains('?') ? linkArgument.Split('?')[0] : linkArgument, out int beatmapId))
                        {
                            game?.ShowBeatmap(beatmapId);
                        }
                        break;

                    case LinkAction.OpenBeatmapSet:
                        if (int.TryParse(linkArgument, out int setId))
                        {
                            game?.ShowBeatmapSet(setId);
                        }
                        break;

                    case LinkAction.OpenChannel:
                        try
                        {
                            channelManager?.OpenChannel(linkArgument);
                        }
                        catch (ChannelNotFoundException e)
                        {
                            Logger.Log($"The requested channel \"{linkArgument}\" does not exist");
                        }

                        break;

                    case LinkAction.OpenEditorTimestamp:
                    case LinkAction.JoinMultiplayerMatch:
                    case LinkAction.Spectate:
                        showNotImplementedError?.Invoke();
                        break;

                    case LinkAction.External:
                        host.OpenUrlExternally(url);
                        break;

                    case LinkAction.OpenUserProfile:
                        if (long.TryParse(linkArgument, out long userId))
                        {
                            game?.ShowUser(userId);
                        }
                        break;

                    default:
                        throw new NotImplementedException($"This {nameof(LinkAction)} ({linkType.ToString()}) is missing an associated action.");
                    }
                },
            });
示例#9
0
        public void AddLink(IEnumerable <SpriteText> text, LinkAction action = LinkAction.External, string linkArgument = null, string tooltipText = null)
        {
            foreach (var t in text)
            {
                AddArbitraryDrawable(t);
            }

            createLink(text, new LinkDetails(action, linkArgument), tooltipText);
        }
 private void CreateLink(Units target)
 {
     this._deltaTime    = 0f;
     this.linePointUnit = target;
     this.lineTargets.Clear();
     this.lineTargets.Add(target);
     this.linkAction = ActionManager.Link(new SkillDataKey(string.Empty, 0, 0), "PaotaLink", this.self, this.lineTargets, null, null);
     this.ResetSkillIconMask(base.skillIndex);
 }
示例#11
0
        /**
         * @param string icon
         * @param string name
         * @param string href
         * @return ILinkAction
         */
        public ILinkAction newLinkAction(string icon, string name, string href)
        {
            var action = new LinkAction();

            action.setName(name);
            action.setIcon(icon);
            action.setHref(href);
            return(action);
        }
示例#12
0
        public void AddLink(IEnumerable <SpriteText> text, string url, LinkAction linkType = LinkAction.External, string linkArgument = null, string tooltipText = null)
        {
            foreach (var t in text)
            {
                AddArbitraryDrawable(t);
            }

            createLink(text, null, url, linkType, linkArgument, tooltipText);
        }
示例#13
0
        private void Loaded(string args)
        {
            LinkAction link = new LinkAction();

            link.DisplayName = "AnimatedTabControl";
            link.Logo        = "&#xe69f;";
            link.Controller  = "Tab";
            link.Action      = "AnimatedTab";
            this.SelectLink  = link;
        }
 private void ClearLink()
 {
     if (this.linkAction != null)
     {
         this.linkAction.Destroy();
         this.linkAction = null;
     }
     this.linePointUnit = null;
     this._deltaTime    = 0f;
     this.ResetSkillIconMask(base.skillIndex);
 }
示例#15
0
        /// <summary>
        /// Creates a new remote destination action to link to a destination in another file.
        /// </summary>
        /// <param name="owner"></param>
        /// <param name="action">Must be RemoteDestination</param>
        /// <param name="file">The path to the file where this is a link action to</param>
        /// <param name="name">The name of the item in the remote file to link to</param>
        public PDFRemoteDestinationAction(Component owner, LinkAction action, string file, string name)
            : base(owner, action)
        {
            if (string.IsNullOrEmpty(file))
            {
                throw new ArgumentNullException("file", Errors.NoRemoteDestinationSpecifiedOnLink);
            }
            this.File = file;

            this.DestinationName = name;
            AssertIsRemoteDestination(action);
        }
示例#16
0
        /// <summary>
        /// Get the content's deep linking URL. Optionaly allows specifying an action.
        /// </summary>
        /// <param name="content">An artist, album or track content item.</param>
        /// <param name="action">An action to take when the link opens the Groove client.</param>
        /// <returns>The deep link.</returns>
        public static string GetLink(this Content content, LinkAction action = LinkAction.Default)
        {
            string link = content.Link;

            if (action == LinkAction.Default || string.IsNullOrEmpty(link))
            {
                return(link);
            }

            string paramsSeparator = link.Contains("?") ? "&" : "?";

            return($"{link}{paramsSeparator}action={action}");
        }
示例#17
0
        private static String GetLink <T>(T model, LinkAction action, String iconClass)
        {
            UrlHelper  url       = new UrlHelper(HttpContext.Current.Request.RequestContext);
            TagBuilder actionTag = new TagBuilder("a");
            TagBuilder icon      = new TagBuilder("i");

            actionTag.MergeAttribute("href", url.Action(action.ToString(), GetRouteValuesFor(model)));
            actionTag.AddCssClass(String.Format("{0}-action", action.ToString().ToLower()));
            icon.AddCssClass(iconClass);

            actionTag.InnerHtml = icon.ToString();

            return(actionTag.ToString());
        }
        /// <summary>
        /// Get the content's deep linking URL. Optionaly allows specifying an action.
        /// </summary>
        /// <param name="content">An artist, album or track content item.</param>
        /// <param name="action">An action to take when the link opens the Xbox Music client.</param>
        /// <returns>The deep link.</returns>
        public static string GetLink(this Content content, LinkAction action = LinkAction.Default)
        {
            string link = content.Link;

            if (action == LinkAction.Default || String.IsNullOrEmpty(link))
            {
                return(link);
            }
            else
            {
                return(String.Format(CultureInfo.InvariantCulture,
                                     "{0}{1}action={2}", link, link.Contains("?") ? "&" : "?", action));
            }
        }
示例#19
0
        private bool IsNamedAction(LinkAction action)
        {
            switch (action)
            {
            case LinkAction.NextPage:
            case LinkAction.PrevPage:
            case LinkAction.FirstPage:
            case LinkAction.LastPage:
                return(true);

            default:
                return(false);
            }
        }
示例#20
0
        public void AddLink(string text, string url, LinkAction linkType = LinkAction.External, string linkArgument = null, string tooltipText = null)
        {
            AddInternal(new DrawableLinkCompiler(AddText(text).ToList())
            {
                TooltipText = tooltipText ?? (url != text ? url : string.Empty),
                Action      = () =>
                {
                    switch (linkType)
                    {
                    case LinkAction.OpenBeatmap:
                        // todo: replace this with overlay.ShowBeatmap(id) once an appropriate API call is implemented.
                        if (int.TryParse(linkArgument, out int beatmapId))
                        {
                            Process.Start($"https://osu.ppy.sh/b/{beatmapId}");
                        }
                        break;

                    case LinkAction.OpenBeatmapSet:
                        if (int.TryParse(linkArgument, out int setId))
                        {
                            game?.ShowBeatmapSet(setId);
                        }
                        break;

                    case LinkAction.OpenChannel:
                        game?.OpenChannel(linkArgument);
                        break;

                    case LinkAction.OpenEditorTimestamp:
                    case LinkAction.JoinMultiplayerMatch:
                    case LinkAction.Spectate:
                        showNotImplementedError?.Invoke();
                        break;

                    case LinkAction.External:
                        Process.Start(url);
                        break;

                    case LinkAction.OpenUserProfile:
                        if (long.TryParse(linkArgument, out long userId))
                        {
                            game?.ShowUser(userId);
                        }
                        break;

                    default:
                        throw new NotImplementedException($"This {nameof(LinkAction)} ({linkType.ToString()}) is missing an associated action.");
                    }
                },
            });
示例#21
0
        public void TestBeatmapLinks(LinkAction expectedAction, string expectedArg, string link)
        {
            Message result = MessageFormatter.FormatMessage(new Message {
                Content = link
            });

            Assert.AreEqual(result.Content, result.DisplayContent);
            Assert.AreEqual(1, result.Links.Count);
            Assert.AreEqual(expectedAction, result.Links[0].Action);
            Assert.AreEqual(expectedArg, result.Links[0].Argument);
            if (expectedAction == LinkAction.External)
            {
                Assert.AreEqual(link, result.Links[0].Url);
            }
        }
示例#22
0
        private static void AddLinkAction <T>(IColumn <T> column, LinkAction action)
        {
            switch (action)
            {
            case LinkAction.Details:
                column.RenderValueAs(GetDetailsLink);
                break;

            case LinkAction.Edit:
                column.RenderValueAs(GetEditLink);
                break;

            case LinkAction.Delete:
                column.RenderValueAs(GetDeleteLink);
                break;
            }
        }
示例#23
0
        public static string ActionToCommand(LinkAction action, string customCommand = null)
        {
            switch (action)
            {
            case LinkAction.Custom:
                return(customCommand);

            case LinkAction.Refresh:
                return("javascript:location.reload();");

            case LinkAction.GoBack:
                return("javascript:window.history.back();");

            case LinkAction.GoForward:
                return("javascript:window.history.forward();");

            default:
                return(null);
            }
        }
        public static MvcHtmlString DynamicButton(this HtmlHelper helper, LinkAction action, string id, string caption, bool printable = true, object viewData = null, string function = null)
        {
            function = HtmlHelpers.ActionToCommand(action, function);

            TagBuilder tag = new TagBuilder("input");

            tag.Attributes.Add("type", "button");
            tag.Attributes.Add("id", id);
            tag.Attributes.Add("value", caption);
            tag.Attributes.Add("onClick", function);

            RouteValueDictionary htmlAttributes;
            RouteValueDictionary viewDataObj = HtmlHelper.AnonymousObjectToHtmlAttributes(viewData);

            if (viewDataObj.ContainsKey("htmlAttributes"))
            {
                htmlAttributes = HtmlHelper.AnonymousObjectToHtmlAttributes(viewDataObj["htmlAttributes"]);
            }
            else
            {
                htmlAttributes = viewDataObj;
            }

            tag.MergeAttributeValue("class", "btn", true);
            if (!printable)
            {
                tag.MergeAttributeValue("class", "d-print-none", true);
            }

            foreach (var attr in htmlAttributes)
            {
                tag.Attributes.Add(attr.Key, attr.Value.ToString());
            }

            return(tag.ToMvcHtmlString(TagRenderMode.SelfClosing));
        }
 /// <summary>
 /// Register a link action between two node types.
 /// </summary>
 /// <typeparam name="TLinkerNode"></typeparam>
 /// <typeparam name="TLinkedNode"></typeparam>
 /// <param name="action"></param>
 public static void AddLinkAction <TLinkerNode, TLinkedNode>(LinkAction action)
 {
     linkActions.Add(new LinkArguments(typeof(TLinkerNode), typeof(TLinkedNode)), action);
 }
示例#26
0
 public LinkDetails(LinkAction action, string argument)
 {
     Action   = action;
     Argument = argument;
 }
 /// <summary>
 /// Get the content's deep linking URL. Optionaly allows specifying an action.
 /// </summary>
 /// <param name="content">An Artist, XboxAlbum or track content item.</param>
 /// <param name="action">An action to take when the link opens the Xbox Music client.</param>
 /// <returns>The deep link.</returns>
 public static string GetLink(this Content content, LinkAction action = LinkAction.Default)
 {
     string link = content.Link;
     if (action == LinkAction.Default || String.IsNullOrEmpty(link))
     {
         return link;
     }
     else
     {
         return String.Format(CultureInfo.InvariantCulture,
             "{0}{1}action={2}", link, link.Contains("?") ? "&" : "?", action);
     }
 }
示例#28
0
        protected override void DoRegisterArtefacts(PDFLayoutContext context, PDFArtefactRegistrationSet set, Style fullstyle)
        {
            base.DoRegisterArtefacts(context, set, fullstyle);

            LinkAction actiontype = this.Action;

            if (actiontype == LinkAction.Undefined)
            {
                actiontype = this.ResolveActionType(this.Destination, this.File);
            }

            object[]  entries = null;
            PDFAction action;

            if (this.IsNamedAction(actiontype))
            {
                PDFNamedAction named = new PDFNamedAction(this, this.Action);
                action = named;
            }
            else if (actiontype == LinkAction.Uri)
            {
                string url = this.File;
                if (!string.IsNullOrEmpty(url))
                {
                    action = new PDFUriDestinationAction(this, actiontype, url);
                }
                else
                {
                    throw new PDFLinkException(Errors.NoFileLinkSpecifiedOnUriAction);
                }
            }
            else if (actiontype == LinkAction.Destination)
            {
                //If we start with a # then we are an ID, otherwise we are a uniqueID or Name
                PDFDestination dest;
                Component      comp;
                if (string.IsNullOrEmpty(this.Destination))
                {
                    //if there is no destination then there is no link. So do not register
                    comp = null;
                    return;
                }
                else if (this.Destination.StartsWith(ComponentIDPrefix))
                {
                    string id = this.Destination.Substring(ComponentIDPrefix.Length);
                    comp = this.Document.FindAComponentById(id);
                }
                else
                {
                    comp = this.Document.FindAComponentByName(this.Destination);
                }


                if (null == comp)
                {
                    if (context.Conformance == ParserConformanceMode.Strict)
                    {
                        throw new PDFLayoutException(string.Format(Errors.LinkToDestinationCouldNotBeMade, this.Destination));
                    }
                    else
                    {
                        context.TraceLog.Add(TraceLevel.Error, "PDFLink", string.Format(Errors.LinkToDestinationCouldNotBeMade, this.Destination));
                    }

                    //cannot continue as we dont have anything to link to
                    return;
                }

                dest = new PDFDestination(comp, this.DestinationFit, this.UniqueID);

                PDFDestinationAction destact = new PDFDestinationAction(this, actiontype, dest);
                action = destact;


                if (null != dest)
                {
                    object link = context.DocumentLayout.RegisterCatalogEntry(context, PDFArtefactTypes.Names, dest);
                    set.SetArtefact(LinkArtefactName, link);
                }
            }
            else if (actiontype == LinkAction.ExternalDestination)
            {
                string name = this.Destination;
                string file = this.File;
                PDFRemoteDestinationAction remote = new PDFRemoteDestinationAction(this, actiontype, file, name);
                remote.NewWindow = this.NewWindow;

                action = remote;
            }
            else
            {
                throw RecordAndRaise.Argument("actiontype");
            }

            if (null != action)
            {
                entries = this.AddActionAnnotationToChildren(context, fullstyle, action);
                set.SetArtefact(LinkAnnotationChildEntries, entries);
            }
        }
示例#29
0
 /// <summary>
 /// Creates an Affiliate link that opens the platform's Xbox Music app with the specified view.
 /// </summary>
 /// <param name="affiliateId">The AffiliateID assigned to you by LinkSynergy.</param>
 /// <param name="action">The view to open for this particular entity.</param>
 /// <returns></returns>
 public string GetDeepLink(string affiliateId, LinkAction action = LinkAction.View)
 {
     var deepLink = Uri.EscapeUriString(GetDeepLink(action));
     return string.Format("http://click.linksynergy.com/deeplink?id={0}&mid=39033&murl={1}", affiliateId, deepLink);
 }
示例#30
0
 public void AddLink(string text, string url, LinkAction linkType = LinkAction.External, string linkArgument = null, string tooltipText = null, Action <SpriteText> creationParameters = null)
 => createLink(AddText(text, creationParameters), text, url, linkType, linkArgument, tooltipText);
        /// <summary>
        /// Creates an Affiliate link that opens the platform's Xbox Music app with the specified view.
        /// </summary>
        /// <param name="affiliateId">The AffiliateID assigned to you by LinkSynergy.</param>
        /// <param name="action">The view to open for this particular entity.</param>
        /// <returns></returns>
        public string GetDeepLink(string affiliateId, LinkAction action = LinkAction.View)
        {
            var deepLink = Uri.EscapeUriString(GetDeepLink(action));

            return(string.Format("http://click.linksynergy.com/deeplink?id={0}&mid=39033&murl={1}", affiliateId, deepLink));
        }
示例#32
0
 /// <summary>
 /// Creates a new known named action with the link action as specified
 /// </summary>
 /// <param name="component">The component that owns this action (in this case can be null)</param>
 /// <param name="action">The action to perform</param>
 public PDFNamedAction(Component component, LinkAction action)
     : base(component, action)
 {
     AssertLinkAction(action);
 }
示例#33
0
        /// <summary>
        /// Creates a link that opens the platform's Xbox Music app with the specified view.
        /// </summary>
        /// <param name="action">The view to open for this particular entity.</param>
        /// <returns></returns>
        public string GetDeepLink(LinkAction action = LinkAction.View)
        {
            var actionString = Enum.GetName(typeof(LinkAction), action).ToLower();
            var format = Link.Contains("?") ? "{0}&action={1}" : "{0}?action={1}";
            return string.Format(format, Link, actionString);

        }