private void RemLink(GameObject node1, GameObject node2) { LinkData link = erDiagram_.RemLink(node1, node2); PlayerEventHandler.RemLink(link); erData_.RemoveLink(link); }
private MessageObject ProcessLinkMessage(JsonReader jsonReader) { Debug.Log("ProcessLinkMessage"); MessageObject messageObject = new MessageObject(); messageObject.type = ChatMessageTypes.Link; LinkData linkData = new LinkData(); while (jsonReader.Read()) { // Look for data section if (jsonReader.Value != null) { switch (jsonReader.Value.ToString()) { case "url": jsonReader.ReadAsString(); linkData.url = jsonReader.Value.ToString(); break; case "text": jsonReader.ReadAsString(); linkData.text = jsonReader.Value.ToString(); break; default: // No-op break; } ; } } messageObject.data = linkData; return(messageObject); }
private void tsbAddLink_Click(object sender, EventArgs e) { /* * int NumLinks = dgvLinkData.Rows.Count; //get number of entered links * if (NumLinks == 1000) //maximum, based on 500 nodes (roughly nodes * 2) * { * MessageBox.Show("The number of entered links is limited to a maximum of 1000.", "XXE", MessageBoxButtons.OK, MessageBoxIcon.Information); * return; * } */ dgvLinkData.Rows.Add(1); for (int i = 0; i < dgvLinkData.Columns.Count; i++) { dgvLinkData.Rows[dgvLinkData.Rows.Count - 1].Cells[i].Style.BackColor = Color.Yellow; } if (dgvLinkData.Rows.Count > 1) { tsbDeleteLink.Enabled = true; } if (Project.Type == ProjectType.BPRlinks) { LinkData NewLink = new LinkData(); Links.Add(NewLink); } else { FreewayData NewFreewayFacility = new FreewayData(); FreewayFacilities.Add(NewFreewayFacility); } }
public override void Initialize(RectTransform[] rectTransforms, Transform linksContent, LinkData link) { linkAttached = link; GameObject line = Instantiate(linePrefab, linksContent); line.GetComponent <UILineConnector>().transforms = rectTransforms; lines.Add(line); myCent.rcts = rectTransforms; index = states.IndexOf(link.nodeState); if (index == -1) { //Not cardinality found index = 0; } if (linkAttached.type == LinkData.LinkTypes.Specialization) { linkAttached.type = LinkData.LinkTypes.Generalization; } else { linkAttached.type = LinkData.LinkTypes.Specialization; } link.nodeState = states[index]; textComp.text = states[index]; }
/// <summary> Converts xml to link data. </summary> public static LinkData ConvertXml(string xml) { // Check if (string.IsNullOrWhiteSpace(xml)) { return(null); } LinkData data = new LinkData(); if (xml.IsXml()) { XDocument doc = XDocument.Parse(xml); XElement xe = (XElement)doc.Root.FirstNode; data.Url = xe.Value; data.DisplayText = xe.Attribute("display").Value; data.Title = xe.Attribute("title").Value; if (!string.IsNullOrWhiteSpace(xe.Attribute("target").Value)) { data.Target = (LinkTarget)Convert.ToInt32(xe.Attribute("target").Value); } } else { data.Url = xml; } return(data); }
void IPointerDownHandler.OnPointerDown(PointerEventData eventData) { /* * //if use OnPointerUp, when drag start on link and if pixelDragThreshold is none or small, called OnPointerUp() Handler by unity system * eventData.useDragThreshold = true; * float screenCoef = 1f; * if(Screen.width > Screen.height) * screenCoef = (float)Screen.height / (float)Screen.currentResolution.height; * else * screenCoef = (float)Screen.width / (float)Screen.currentResolution.width; * int threshold = Mathf.CeilToInt(((float)Screen.dpi * 0.2f) * screenCoef); * EventSystem.current.pixelDragThreshold = threshold; */ var localPosition = ToLocalPosition(eventData.position, eventData.pressEventCamera); for (int i = 0; i < linkDataList.Count; i++) { for (int j = 0; j < linkDataList[i].rects.Count; j++) { if (linkDataList[i].rects[j].Contains(localPosition)) { pointerDownEntry = linkDataList[i]; tapTimer = Time.time; break; } } } }
private void OnLinkRemoved(LinkData link) { if (Application.isPlaying && previousSelectedGameObject != null) { currentConstellation.RemoveLink(link); } }
public async Task <PageData> DownloadAsync(LinkData link) { try { var content = await webClient.DownloadStringTaskAsync(link.Url); var page = new PageData() { LinkId = link.Id, Url = link.Url, SiteId = link.SiteId, Page = content }; await repository.Pages.InsertOneAsync(page); downloaded.Add(link.Hash); return(page); } catch (Exception ex) { logger.LogError(ex, $"Unable to download: {link.Id} - {link.Url}"); return(null); } }
private string PrintLinkMessageFragment(LinkData linkData) { string messageFragment = string.Empty; messageFragment += linkData.text; return(messageFragment); }
public NetList <LinkData> GetLinksByLinkId(int linkId) { var response = new NetList <LinkData>(); var linkData = new LinkData(); try { linkData.processes = db.Processes.Where(x => x.LinkId == linkId).ToList(); linkData.peoples = db.Peoples.Where(x => x.LinkId == linkId).ToList(); linkData.tools = db.Tools.Where(x => x.LinkId == linkId).ToList(); response.Collection = new List <LinkData> { linkData }; response.Status = ResponseStatus.Succeed; } catch (Exception ex) { response.Status = ResponseStatus.Failed; response.Message = ex.Message; response.Exception = ex; } return(response); }
private void SendLink(string source, string targetName, string targetType) { LinkData dataLink = new LinkData(source, targetName, targetType); linkCallback(dataLink); LinksCount++; }
public void setLink(LinkData obj) { Attack = obj.Attack; Dodge = obj.Dodge; Idle = obj.Idle; State = obj.Type; }
public BusBridge(LinkData linkData, bool line = false) { InitializeComponent(); DataContext = this; _linkData = linkData; BusInputTooltip.Visibility = Visibility.Visible; PhasesTooltip.Visibility = Visibility.Visible; if (linkData.InvertPhasePosition) { PhasesTooltip.Visibility = Visibility.Collapsed; BackPhasesTooltip.Visibility = Visibility.Visible; } if (line) { BusInputTooltip.Visibility = Visibility.Collapsed; BusLineTooltip.Visibility = Visibility.Visible; } switch (linkData.BusDirection) { case Facade.Up: PhasesTooltip.VerticalAlignment = VerticalAlignment.Top; break; case Facade.Down: PhasesTooltip.VerticalAlignment = VerticalAlignment.Bottom; break; case Facade.Left: PhasesTooltip.HorizontalAlignment = HorizontalAlignment.Left; break; case Facade.Right: PhasesTooltip.HorizontalAlignment = HorizontalAlignment.Right; break; } switch (linkData.BusDirection) { case Facade.Up: BackPhasesTooltip.VerticalAlignment = VerticalAlignment.Top; break; case Facade.Down: BackPhasesTooltip.VerticalAlignment = VerticalAlignment.Bottom; break; case Facade.Left: BackPhasesTooltip.HorizontalAlignment = HorizontalAlignment.Left; break; case Facade.Right: BackPhasesTooltip.HorizontalAlignment = HorizontalAlignment.Right; break; } }
private static IEnumerable <Link> CreateSharedLinks(LinkData linkData) { Console.WriteLine("Creating Shared Links ..."); var links = new Link[] { new Link { SyncPointId = _currentFolder.SyncpointId, VirtualPath = $"{_currentFolder.VirtualPath}{linkData.FileName}", LinkExpireInDays = 90, LinkExpirationPolicy = ShareLinkExpirationPolicy.Enabled, PasswordProtectPolicy = ShareLinkPasswordProtectedPolicy.Disabled, RolId = 1, SharedLinkPolicy = ShareLinkPolicy.IntendedOnly, IrmRoleType = IrmRoleType.Reader, IsIrmProtected = true, Users = new User [] { new User { EmailAddress = linkData.Email } }, Message = linkData.OldMessage } }; return(LinksService.CreateSharedLinks(links)); }
internal LinkData GetLinkData(Item dataSource, string fieldName, string fallbackValue) { LinkData toReturn = new LinkData(); if (dataSource != null && !string.IsNullOrEmpty(fieldName)) { Sitecore.Data.Fields.LinkField linkField = dataSource.Fields[fieldName]; if (linkField != null) { try { toReturn.LinkUrlIsValid = !string.IsNullOrEmpty(linkField.Url); toReturn.LinkText = dataSource.LinkFieldOptions(linkField.InnerField.ID, LinkFieldOption.Text); if (string.IsNullOrEmpty(toReturn.LinkText)) { toReturn.LinkText = fallbackValue; } } catch (Exception ex) { Sitecore.Diagnostics.Log.Error(ProjConstants.Diagnostics.Prefix, ex, this); toReturn.LinkText = fallbackValue; } } } else { Sitecore.Diagnostics.Log.Error(ProjConstants.Diagnostics.Prefix + " GetLinkText. dataSource is null: " + (dataSource == null), this); Sitecore.Diagnostics.Log.Error(ProjConstants.Diagnostics.Prefix + " GetLinkText. fieldName is null: " + string.IsNullOrEmpty(fieldName), this); } return(toReturn); }
protected void InitializeRootDescriptor(RootEntry rootEntry) { RootDescriptor rd = new RootDescriptor(rootEntry) { State = RootDescriptorState.AwaitingDeviceDescription }; lock (_cpData.SyncObj) SetRootDescriptor(rootEntry, rd); try { LinkData preferredLink = rootEntry.PreferredLink; HttpWebRequest request = CreateHttpGetRequest(new Uri(preferredLink.DescriptionLocation), preferredLink.Endpoint.EndPointIPAddress); DescriptionRequestState state = new DescriptionRequestState(rd, request); lock (_cpData.SyncObj) _pendingRequests.Add(state); IAsyncResult result = request.BeginGetResponse(OnDeviceDescriptionReceived, state); NetworkHelper.AddTimeout(request, result, PENDING_REQUEST_TIMEOUT * 1000); } catch (Exception) // Don't log messages at this low protocol level { lock (_cpData.SyncObj) rd.State = RootDescriptorState.Erroneous; } }
protected void OnLinkAdded(LinkData link) { if (Application.isPlaying && previousSelectedGameObject != null) { currentEditableConstellation.AddLink(link); } }
private void OnLinkAdded(LinkData link) { if (Application.isPlaying && previousSelectedGameObject != null) { currentConstellationbehavior.AddLink(link); } }
// this collects connected node data up to LEVEL levels away, and adds the node link data to the model private void CollectLocals(NodeData data, LinkData linkdata, int level, HashSet <NodeData> wanted) { if (data == null) { return; } // stop recursing beyond the number of levels if (level < 0) { return; } // always add the link data (but it might be null, which is OK) this.LocalModel.AddLink(linkdata); // stop if we've already seen the node if (wanted.Contains(data)) { return; } // otherwise add it to our collection wanted.Add(data); this.LocalModel.AddNode(data); // recurse through all connected nodes foreach (LinkData l in this.WholeModel.GetLinksForNode(data)) { CollectLocals(this.WholeModel.GetFromNodeForLink(l), l, level - 1, wanted); CollectLocals(this.WholeModel.GetToNodeForLink(l), l, level - 1, wanted); } }
public IActionResult GetMyPagesColumns() { return(es.Execute(() => { IEnumerable <PageData> result = ps.GetAccountPagesColumns(accountService.Login); LinkData linkData = ps.GetExtensionDataFromCookies(); if (linkData != null) { foreach (PageData pageData in result) { if (linkData.PageId == pageData.Id) { pageData.Default = true; foreach (ColumnData columnData in pageData.Columns) { if (columnData.Id == linkData.ColumnId) { columnData.Default = true; break; } } break; } } } return new JsonResult(new GenericResult(result)); }, true)); }
public void Should_return_HTML_code_representing_a_link_with_all_the_values_set() { var linkData = new LinkData(); const string htmlText = "<a href=''></a>"; linkData.ToString().ShouldBeEqualTo(htmlText); }
void swapLinks(List <LinkData> chain, int index1, int index2) { LinkData temp = chain[index1]; chain[index1] = chain[index2]; chain[index2] = temp; }
private async Task <Presenter> Start(SceneData data) { Func <Task <bool> > task = async() => { if (data.operation == null) { data.operation = await Load(data.name, data.option); } data.operation.allowSceneActivation = true; await data.operation; if (!data.operation.isDone) { throw new Exception("timeout"); } return(data.operation.isDone); }; await Loading.instance.Wrap(task, data.option); var context = new LinkData(); context.path = data.name; context.node = new GameObject($"{data.name}<Root>"); context.presenter = Bridge.instance.component.Link(context, data.args); if (disposable != null) { disposable.Dispose(); } disposable = context.presenter; return(context.presenter); }
public LinkStatus ExtractLinks() { if (String.Empty == m_strUrl) { throw new ArgumentException("No URL specified"); } m_Links = new LinkDataCollection(); CreateParser(); if (m_obParser.Lexer.Page.mSource == null) { return(LinkStatus.Broken); } NodeFilter obFilter = new NodeClassFilter(typeof(ATag)); NodeList collNodes = m_obParser.Parse(obFilter); if (null != collNodes) { PageData obPageData = new PageData(); obPageData.m_strUrl = m_obParser.URL; obPageData.m_iDepth = m_iLevel; for (Int32 i = 0; i < collNodes.Count; i++) { INode obNode = collNodes[i]; LinkData obLinkData = new LinkData(obPageData, obNode as ATag); m_Links.Add(obLinkData); } } return(LinkStatus.Ok); }
private LinkViewModel ToViewModel(LinkData model) { if (model is LinearLinkData lld) { return(new LinearLinkViewModel(lld.LinkId, lld.Variable) { Description = model.Descrition }); } else if (model is TwoPosLinkData tpld) { return(new TwoPosLinkViewModel(tpld.LinkId, tpld.Variable) { Description = model.Descrition, Inverted = tpld.Inverted }); } else if (model is WriteTwoPosData wtpld) { return(new WriteTwoPosLinkViewModel(wtpld.LinkId, wtpld.Variable) { Description = model.Descrition }); } else if (model is PulseTwoPosData ptpld) { return(new PulseTwoPosLinkViewModel(ptpld.LinkId, ptpld.Variable) { Description = model.Descrition }); } else { throw new ArgumentException("Unhandled link data type!"); } }
public void AddLink(LinkData _link) { if (script.Links == null) { script.Links = new List <LinkData> (); } script.Links.Add(_link); }
public void Initialize(RectTransform[] rectTransformst, Sprite simple, Sprite doub, LinkData link) { linkAttached = link; GetComponent <UILineConnector>().transforms = rectTransformst; simpleLineSpr = simple; doubleLineSpr = doub; UpdateSprite(); }
protected void OnLinkRemoved(LinkData link) { if (Application.isPlaying && previousSelectedGameObject != null && ConstellationScript.IsInstance) { currentEditableConstellation.RemoveLink(link); ConstellationScript.IsDifferentThanSource = true; } }
public async Task <string> CreateShortLinkAsync(LinkData linkData) { var result = await this.GetClient().CreateLinkAsync(new GrpcClient.LinkCreateRequest() { Link = linkData.LinkValue }); return(result.Id); }
static public void ChangeCardinality(LinkData link) { ActionData newAction = new ActionData(); newAction.Add("DiagramCode", DiagramKeeper.GetCurrDiagramCode()); newAction.Add("Name", link.name); newAction.Add("New Cardinality", link.nodeState); instance.dataLog.actions.Add(new Tuple <string, ActionData>("ChangeCardinality", newAction)); }
internal PageLink(double p0, double p1, double p2, double p3, LinkData link) : this() { this.P0 = p0; this.P1 = p1; this.P2 = p2; this.P3 = p3; this.Link = link; }
public void Should_return_HTML_code_representing_a_link_with_all_the_values_set() { var linkData = new LinkData() .WithUrl("AdminTest") .WithCssClass("Css") .WithMouseOverText("MouseOver") .WithLinkText("Link") .DisabledIf(false); const string htmlText = "<a href='AdminTest' class='Css' title='MouseOver'>Link</a>"; linkData.ToString().ShouldBeEqualTo(htmlText); }
/// <summary> /// Looks for any paging links that may occur within the document /// </summary> /// <param name="body">Content body</param> /// <param name="url">Url of document</param> internal string FindNextPageLink(XElement body, string url) { var possiblePages = new Dictionary<string, LinkData>(); var allLinks = body.GetElementsByTagName("a"); var articleBaseUrl = FindBaseUrl(url); /* Loop through all links, looking for hints that they may be next-page links. * Things like having "page" in their textContent, className or id, or being a child * of a node with a page-y className or id. * After we do that, assign each page a score. */ foreach (var link in allLinks) { string linkHref = (string)link.Attribute("href"); if (string.IsNullOrEmpty(linkHref)) continue; if (_MailtoHrefRegex.IsMatch(linkHref)) continue; linkHref = Regex.Replace(linkHref, "#.*$", ""); linkHref = Regex.Replace(linkHref, "/$", ""); /* If we've already seen this page, then ignore it. */ // This leaves out an already-checked page check, because // the web transcoder is seperate from the original transcoder if (linkHref == "" || linkHref == articleBaseUrl || linkHref == url) continue; /* If it's on a different domain, skip it. */ Uri linkHrefUri; if (Uri.TryCreate(linkHref, UriKind.Absolute, out linkHrefUri) && linkHrefUri.Host != new Uri(articleBaseUrl).Host) continue; string linkText = GetInnerText(link); /* If the linktext looks like it's not the next page, then skip it */ if (_Extraneous.IsMatch(linkText) || linkText.Length > 25) continue; /* If the leftovers of the URL after removing the base URL don't contain any digits, it's certainly not a next page link. */ string linkHrefLeftover = linkHref.Replace(articleBaseUrl, ""); if (!Regex.IsMatch(linkHrefLeftover, @"\d")) continue; if (!possiblePages.Keys.Contains(linkHref)) { possiblePages[linkHref] = new LinkData { Score = 0, LinkHref = linkHref, LinkText = linkText }; } else { possiblePages[linkHref].LinkText += " | " + linkText; } var linkObj = possiblePages[linkHref]; /* * If the articleBaseUrl isn't part of this URL, penalize this link. It could still be the link, but the odds are lower. * Example: http://www.actionscript.org/resources/articles/745/1/JavaScript-and-VBScript-Injection-in-ActionScript-3/Page1.html */ if (linkHref.IndexOf(articleBaseUrl) == -1) linkObj.Score -= 25; string linkData = linkText + " " + link.GetClass() + " " + link.GetId(); if (_NextLink.IsMatch(linkData)) linkObj.Score += 50; if (Regex.IsMatch(linkData, "pag(e|ing|inat)", RegexOptions.IgnoreCase)) linkObj.Score += 25; /* If we already matched on "next", last is probably fine. If we didn't, then it's bad. Penalize. */ /* -65 is enough to negate any bonuses gotten from a > or � in the text */ if (Regex.IsMatch(linkData, "(first|last)", RegexOptions.IgnoreCase)) if (!_NextLink.IsMatch(linkObj.LinkText)) linkObj.Score -= 65; if (_NegativeWeightRegex.IsMatch(linkData) || _Extraneous.IsMatch(linkData)) linkObj.Score -= 50; if (_PrevLink.IsMatch(linkData)) linkObj.Score -= 200; /* If any ancestor node contains page or paging or paginat */ var parentNode = link.Parent; bool positiveNodeMatch = false; bool negativeNodeMatch = false; while (parentNode != null) { string parentNodeClassAndId = parentNode.GetClass() + " " + parentNode.GetId(); if (!positiveNodeMatch && Regex.IsMatch(parentNodeClassAndId, "pag(e|ing|inat)", RegexOptions.IgnoreCase)) { positiveNodeMatch = true; linkObj.Score += 25; } if (!negativeNodeMatch && _NegativeWeightRegex.IsMatch(parentNodeClassAndId)) { if (!_PositiveWeightRegex.IsMatch(parentNodeClassAndId)) { linkObj.Score -= 25; negativeNodeMatch = true; } } parentNode = parentNode.Parent; } /* * If the URL looks like it has paging in it, add to the score. * Things like /page/2/, /pagenum/2, ?p=3, ?page=11, ?pagination=34 */ if (Regex.IsMatch(linkHref, @"p(a|g|ag)?(e|ing|ination)?(=|\/)[0-9]{1,2}", RegexOptions.IgnoreCase) || Regex.IsMatch(linkHref, @"(page|paging)", RegexOptions.IgnoreCase)) { linkObj.Score += 25; } /* If the URL contains negative values, give a slight decrease. */ if (_Extraneous.IsMatch(linkHref)) { linkObj.Score -= 15; } /* * If the link text can be parsed as a number, give it a minor bonus, with a slight * bias towards lower numbered pages. This is so that pages that might not have 'next' * in their text can still get scored, and sorted properly by score. */ int linkTextAsNumber; bool isInt = int.TryParse(linkText, out linkTextAsNumber); if (isInt) { /* Punish 1 since we're either already there, or it's probably before what we want anyways. */ if (linkTextAsNumber == 1) linkObj.Score -= 10; else linkObj.Score += Math.Max(0, 10 - linkTextAsNumber); } } /* * Loop thrugh all of our possible pages from above and find our top candidate for the next page URL. * Require at least a score of 50, which is a relatively high confidence that this page is the next link. */ LinkData topPage = null; foreach (var page in possiblePages.Keys) { if (possiblePages[page].Score >= 50 && (topPage == null || topPage.Score < possiblePages[page].Score)) topPage = possiblePages[page]; } if (topPage != null) { string nextHref = Regex.Replace(topPage.LinkHref, @"\/$", ""); var nextHrefUri = new Uri(new Uri(articleBaseUrl), nextHref); return nextHrefUri.ToString(); } return null; }
public void Should_return_HTML_code_representing_a_link_with_all_the_values_set() { var linkData = new LinkData() .WithUrl("AdminTest") .WithCssClass("Css") .WithMouseOverText("MouseOver") .WithLinkText("Link") .DisabledIf(false); linkData.AddQueryStringData("key1", "value"); linkData.AddQueryStringData("key2", null); var href = "AdminTest?key1=value&key2=&"; var htmlText = String.Format("<a href='{0}' class='Css' title='MouseOver'>Link</a>", href); linkData.ToString().ShouldBeEqualTo(htmlText); ((ILinkData)linkData).Href.ShouldBeEqualTo(href); }
public void BeforeEachTest() { LinkData = new LinkData(); }