void OriginatingLineStyle_MouseOverMiddleImage1(object sender, MouseEventArgs e, Rectangle endBounds) { LinkLine line = (LinkLine)sender; Relationship relationship = (Relationship)line.DataObject; ProcessMouseOverMiddleImage(sender, e.Location, relationship, true); }
void OriginatingLineStyle_MiddleImageClick2(object sender, MouseEventArgs e) { LinkLine line = (LinkLine)sender; Relationship relationship = (Relationship)line.DataObject; ProcessMouseOverMiddleImage(sender, e.Location, relationship, false); }
// 断开当前的线,并握住这根线的这一头 public void ChangeLink(LinkNodeData node) { OperatorLink input_node, output_node; int input_idx; GameObject input_anchor, output_anchor; GetLinkData(node, out input_node, out input_idx, out output_node); output_node.RemoveOutputLink(input_node, input_idx); input_node.RemoveInputLink(input_idx); LinkLine line = RemoveLinkLine(input_node, input_idx, output_node); m_curLine = line; if (node.isInput) { output_anchor = output_node.FindOutputAnchor(); line.SetNode(output_anchor, null); m_matchingObj = new LinkNodeData(output_node, output_anchor, false, -1, -1); } else { input_anchor = input_node.FindInputAnchor(input_idx); line.SetNode(null, input_anchor); m_matchingObj = new LinkNodeData(input_node, input_anchor, true, input_idx, -1); } OnLinkChange(); }
public LinkData(LinkLine l, OperatorLink i, int ii, OperatorLink o) { lineObj = l; inputObj = i; inputObjIdx = ii; outputObj = o; }
// 寻找另一条线让两直线和它相交 int LineCrossOther(LinkLine l1, LinkLine l2) { for (int i = Mathf.Max(l1.start, l2.start); i <= Mathf.Min(l1.end, l2.end); ++i) { bool ok = true; for (int j = Mathf.Min(l1.other, l2.other); j <= Mathf.Max(l1.other, l2.other); ++j) { if (l1.verticle) { if (map[i, j] == 1) { ok = false; break; } } else { if (map[j, i] == 1) { ok = false; break; } } } if (ok) { return(i); } } return(-1); }
void ChildOriginatingLineStyle_MiddleImageClick(object sender, MouseEventArgs e) { LinkLine line = (LinkLine)sender; UserControls.FormInheritanceInfo form = new UserControls.FormInheritanceInfo(Entity, (Entity)line.Parent.Tag); Point pt = line.MidPoint; pt.Offset(-1 * form.Width / 2, -1 * form.Height / 2); if (pt.Y < 2) { pt.Offset(0, 5 - pt.Y); } pt.Offset(this.Parent.Parent.Parent.Left, this.Parent.Top); form.Location = pt; //MappingEditor.BringToFront(); //MappingEditor.Visible = true; //MappingEditor.Refresh(); if (form.ShowDialog(this) == DialogResult.OK) { //Populate(); } Populate(); }
private void OriginatingLineStyle_MiddleImageClick(object sender, MouseEventArgs e) { LinkLine line = (LinkLine)sender; ComponentImpl component = (ComponentImpl)line.DataObject; List <Entity> unavailableEntities = new List <Entity>(); UserControls.FormComponentMappingEditor MappingEditor = new ArchAngel.Providers.EntityModel.UI.Editors.UserControls.FormComponentMappingEditor(); MappingEditor.Fill(ComponentSpecification, component.ParentEntity); Point pt = line.MidPoint; pt.Offset(-1 * MappingEditor.Width / 2, -1 * MappingEditor.Height / 2); if (pt.Y < 2) { pt.Offset(0, 5 - pt.Y); } MappingEditor.Location = pt; //MappingEditor.BringToFront(); //MappingEditor.Visible = true; //MappingEditor.Refresh(); if (MappingEditor.ShowDialog(this) == DialogResult.OK) { //Populate(); } Populate(); }
void OriginatingLineStyle_MouseClick(object sender, MouseEventArgs e) { SelectedLinkLine = (LinkLine)sender; //if (e.Button == MouseButtons.Right) // ShowContextMenuForDiscriminator(); }
protected override void Activate(ModelItem item) { myLinkLine = item.GetCurrentValue() as LinkLine; brush = myLinkLine.LineBrush; Panel.SetZIndex(myLinkLine, 1000); myLinkLine.LineBrush = Brushes.Yellow; base.Activate(item); }
public void AddFeedbackForOrder(RegisteredCmderOrder order) { if (order.orderType == RegisteredCmderOrder.OrderType.createCmder || order.orderType == RegisteredCmderOrder.OrderType.move) { Zone targetZone = null; if (order.zoneTargetID != -1) { targetZone = GameController.GetZoneByID(order.zoneTargetID); if (targetZone == null) { return; } } if (order.orderType == RegisteredCmderOrder.OrderType.createCmder) { WorldVisualFeedbacks.instance.createCmderFBCycler.PlaceObjAt(targetZone.MyZoneSpot.transform); } else { Commander targetCmder = GameController.GetCmderByID(order.orderedActorID); if (targetCmder == null) { return; } Faction ownerFac = GameController.GetFactionByID(targetCmder.ownerFaction); if (ownerFac == null) { return; } LinkLine line = WorldVisualFeedbacks.instance.moveFBCycler.GetAnObj().GetComponent <LinkLine>(); line.SetLink(targetCmder.MeIn3d, targetZone.MyZoneSpot, ownerFac.color, 0.3f); } } else { Commander targetCmder = GameController.GetCmderByID(order.orderedActorID); if (targetCmder == null) { return; } if (order.orderType == RegisteredCmderOrder.OrderType.recruit) { WorldVisualFeedbacks.instance.recruitFBCycler.PlaceObjAt(targetCmder.MeIn3d.transform); } else { WorldVisualFeedbacks.instance.trainingFBCycler.PlaceObjAt(targetCmder.MeIn3d.transform); } } }
private LinkLine CreateLine() { if (m_curLine == null) { GameObject new_line = GameObject.Instantiate(m_lineSample); new_line.transform.parent = this.transform; new_line.transform.localScale = Vector3.one; m_curLine = new_line.GetComponent <LinkLine>(); } return(m_curLine); }
/// <summary> /// destroys (pools) the link line between two zones, optionally updating both their linkedZones list /// </summary> /// <param name="z1"></param> /// <param name="z2"></param> /// <param name="alsoUpdateTheirLinkedList"></param> public static void RemoveZoneLink(Zone z1, Zone z2, bool alsoUpdateTheirLinkedList = false) { LinkLine theLink = GetLinkLineBetween(z1, z2); LinkLineRecycler.instance.cycler.PoolObj(theLink.gameObject); instance.linkLines.Remove(theLink); if (alsoUpdateTheirLinkedList) { z1.linkedZones.Remove(z2.ID); z2.linkedZones.Remove(z1.ID); } }
public static void PlaceZoneLink(Zone z1, Zone z2, bool alsoUpdateTheirLinkedList = false) { LinkLine theLink = LinkLineRecycler.GetALine(); theLink.SetLink(z1.MyZoneSpot, z2.MyZoneSpot); instance.linkLines.Add(theLink); if (alsoUpdateTheirLinkedList) { z1.linkedZones.Add(z2.ID); z2.linkedZones.Add(z1.ID); } }
public static void PlaceZoneLink(ZoneSpot zs1, ZoneSpot zs2, bool alsoUpdateTheirLinkedList = false) { LinkLine theLink = LinkLineRecycler.GetALine(); Zone z1 = zs1.data as Zone, z2 = zs2.data as Zone; theLink.SetLink(zs1, zs2); instance.linkLines.Add(theLink); if (alsoUpdateTheirLinkedList) { z1.linkedZones.Add(z2.ID); z2.linkedZones.Add(z1.ID); } }
// 删除并返回留下的line对象 public LinkLine RemoveLinkLine(OperatorLink input_node, int input_idx, OperatorLink output_node) { for (int i = 0; i != m_links.Count; ++i) { if (m_links[i].inputObj == input_node && m_links[i].outputObj == output_node && m_links[i].inputObjIdx == input_idx) { LinkLine line = m_links[i].lineObj; m_links.RemoveAt(i); return(line); } } return(null); }
// 创建一条线 public void StartMatch(LinkNodeData src) { m_matchingObj = src; m_curLine = CreateLine(); if (src.isInput) { m_curLine.SetNode(null, src.anchorObj); } else { m_curLine.SetNode(src.anchorObj, null); } }
// 放弃当前的线 public void CancelMatch() { if (m_matchingObj == null) { return; } m_matchingObj = null; if (m_curLine != null) { GameObject.Destroy(m_curLine.gameObject); m_curLine = null; } }
// 删除一个link public void RemoveLink(LinkNodeData node) { OperatorLink input_node, output_node; int input_idx; GetLinkData(node, out input_node, out input_idx, out output_node); output_node.RemoveOutputLink(input_node, input_idx); input_node.RemoveInputLink(input_idx); LinkLine line = RemoveLinkLine(input_node, input_idx, output_node); GameObject.Destroy(line.gameObject); OnLinkChange(); }
void DrawLinkLine(LinkLine line) { if (line.verticle) { for (int i = line.start; i <= line.end; ++i) { Instantiate(prefab_end, new Vector3(line.other, 1.0f, i), Quaternion.identity); } } else { for (int i = line.start; i <= line.end; ++i) { Instantiate(prefab_end, new Vector3(i, 1.0f, line.other), Quaternion.identity); } } }
void MapLine_MiddleImageClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { SelectedLinkLine = (LinkLine)sender; EntityImpl entity = (EntityImpl)SelectedLinkLine.DataObject; //UserControls.FormDiscriminator form = new UserControls.FormDiscriminator(entity); //form.StartPosition = FormStartPosition.CenterParent;//.Manual; //form.ShowDialog(this); //SelectedLinkLine.MiddleText = GetDiscriminatorText(entity); //if (string.IsNullOrEmpty(SelectedLinkLine.MiddleText)) //{ // SelectedLinkLine.MiddleImage = FilterImageDisabled; // SelectedLinkLine.MiddleImageFocused = FilterImageDisabled; //} //else //{ // SelectedLinkLine.MiddleImage = FilterImage; // SelectedLinkLine.MiddleImageFocused = FilterImageFocused; //} Point pt = ((LinkLine)sender).MidPoint; pt.Offset(-1 * MappingEditor.Width / 2, -1 * MappingEditor.Height / 2); if (pt.Y < 2) { pt.Offset(0, 5 - pt.Y); } MappingEditor.EntityOnLeft = false; MappingEditor.Entity = entity; MappingEditor.Table = Table; MappingEditor.Location = pt; MappingEditor.BringToFront(); MappingEditor.Visible = true; MappingEditor.Refresh(); } //else //{ // ShowContextMenuForDiscriminator(); //} }
public void clearContents(bool includeLinks) { if (includeLinks) { this.linkList.Clear(); } this.playerSearchList.populate(new List<CustomSelfDrawPanel.CSDListItem>()); this.villageSearchList.populate(new List<CustomSelfDrawPanel.CSDListItem>()); this.regionSearchList.populate(new List<CustomSelfDrawPanel.CSDListItem>()); this.villageTabButton.Active = false; this.villageTabButton.Alpha = 0.5f; this.villageTabButton.CustomTooltipID = 0x206; this.playerAddButton.Enabled = false; this.villageAddButton.Enabled = false; this.regionAddButton.Enabled = false; this.selectedVillage = null; this.selectedLine = null; this.changeTabIcons(-1); }
LinkLine VLine(Pos p) { int up = p.y; int down = p.y; while (up > 0 && map[up - 1, p.x] != 1) { up -= 1; } while (down < H - 1 && map[down + 1, p.x] != 1) { down += 1; } LinkLine line = new LinkLine(); line.verticle = true; line.start = up; line.end = down; line.other = p.x; return(line); }
LinkLine HLine(Pos p) { int left = p.x; int right = p.x; while (left > 0 && map[p.y, left - 1] != 1) { left -= 1; } while (right < W - 1 && map[p.y, right + 1] != 1) { right += 1; } LinkLine line = new LinkLine(); line.verticle = false; line.start = left; line.end = right; line.other = p.y; return(line); }
void pinAdorner_MouseUp(object sender, MouseButtonEventArgs e) { var pinAdorner = sender as PinAdorner; if (pinAdorner.HitPin != null) { LinkableControl targetObject = pinAdorner.HitLinkableControl; LinkPin lp1 = pinAdorner.SourcePin; LinkPin lp2 = pinAdorner.HitPin; ConnectInfo info1 = lp1.GetInfo(); ConnectInfo info2 = lp2.GetInfo(); LinkLine line = new LinkLine(info1, info2); //Panel.SetZIndex(line, designCanvas.Children.Count); Binding bi1 = new Binding(omap[info1.Orient]); bi1.ElementName = designObject.Name; line.SetBinding(LinkLine.OriginInfoProperty, bi1); Binding bi2 = new Binding(omap[info2.Orient]); bi2.ElementName = targetObject.Name; line.SetBinding(LinkLine.TargetInfoProperty, bi2); var CanvasModelItem = AdornerProperties.GetModel(adorner).Parent; ModelItemCollection myControls = CanvasModelItem.Properties["Children"].Collection; ModelItem myLinkLine = myControls.Add(line); } if (pinAdorner.HitLinkableControl != null) { pinAdorner.HitLinkableControl.IsLinkDragOver = false; } hitPin = null; if (adorner.IsMouseCaptured) { adorner.ReleaseMouseCapture(); } _panel.Children.Remove(pinAdorner); }
bool LineCross(LinkLine l1, LinkLine l2) { if (l1.verticle == l2.verticle) { // 平行线 if (l1.other == l2.other) { if (l1.end < l2.start || l2.end < l1.start) { return(false); } return(true); } } else { if ((l1.start <= l2.other && l1.end >= l2.other) && (l2.start <= l1.other && l2.end >= l1.other)) { return(true); } } return(false); }
void ParentOriginatingLineStyle_MiddleImageClick(object sender, MouseEventArgs e) { LinkLine line = (LinkLine)sender; UserControls.FormInheritanceInfo form = new UserControls.FormInheritanceInfo((Entity)line.Parent.Tag, Entity); Point pt = line.MidPoint; pt.Offset(-1 * form.Width / 2, -1 * form.Height / 2); pt = this.PointToScreen(pt); if (pt.Y < 2) { pt.Offset(0, 5 - pt.Y); } form.Location = pt; //if (form.ShowDialog(this) == DialogResult.OK) //{ // //Populate(); //} Populate(); }
private void ProcessMouseOverEndOfLine(object sender, MouseEventArgs e, Rectangle endRectangle, bool isEnd1) { int offset = 0; Point pt = new Point(endRectangle.X, endRectangle.Y + endRectangle.Height);// PointToClient(Cursor.Position);// e.Location; pt.Offset(offset, offset); if (endRectangle != CurrentEndRectangle || !RefEditorForm.Visible) { CurrentEndRectangle = endRectangle; LinkLine line = (LinkLine)sender; ReferenceImpl reference = (ReferenceImpl)line.DataObject; RefEditorForm.Fill(reference, isEnd1); //RefEditorForm.Fill((ReferenceImpl)lineEndWithFocus.Line.DataObject, lineEndWithFocus.EndType == ShapeCanvas.LineEndWithFocus.EndTypes.Start); if (pt.X + RefEditorForm.Width < this.Width) { RefEditorForm.Location = pt; } else { pt.Offset(-1 * RefEditorForm.Width + endRectangle.Width + offset * 2, 0); RefEditorForm.Location = pt; } if (pt.Y + RefEditorForm.Height < this.Height) { RefEditorForm.Location = pt; } else { pt.Offset(0, -1 * RefEditorForm.Height - endRectangle.Height + offset * 2); RefEditorForm.Location = pt; } RefEditorForm.Visible = true; RefEditorForm.Refresh(); } }
void OriginatingLineStyle_MiddleImageClick(object sender, MouseEventArgs e) { int offset = 0; Point pt = e.Location; pt.Offset(offset, offset); //if (endRectangle != CurrentEndRectangle || !RelationshipEditorForm.Visible) //{ //CurrentEndRectangle = endRectangle; LinkLine line = (LinkLine)sender; Relationship relationship = (Relationship)line.DataObject; RelationshipEditorForm.Fill(relationship); //RelationshipEditorForm.Fill((ReferenceImpl)lineEndWithFocus.Line.DataObject, lineEndWithFocus.EndType == ShapeCanvas.LineEndWithFocus.EndTypes.Start); //if (pt.X + RelationshipEditorForm.Width < this.Width) // RelationshipEditorForm.Location = pt; //else //{ // pt.Offset(-1 * RelationshipEditorForm.Width + endRectangle.Width + offset * 2, 0); // RelationshipEditorForm.Location = pt; //} //if (pt.Y + RelationshipEditorForm.Height < this.Height) // RelationshipEditorForm.Location = pt; //else //{ // pt.Offset(0, -1 * RelationshipEditorForm.Height - endRectangle.Height + offset * 2); // RelationshipEditorForm.Location = pt; //} pt = ((LinkLine)sender).MidPoint; pt.Offset(-1 * RelationshipEditorForm.Width / 2, -1 * RelationshipEditorForm.Height / 2); RelationshipEditorForm.Location = pt; RelationshipEditorForm.Visible = true; RelationshipEditorForm.Refresh(); //} }
// 决定当前的线 public void SettleMatch(LinkNodeData dst) { if (!CanMatch(dst)) { return; } OperatorLink input_node = (dst.isInput ? dst : m_matchingObj).obj; OperatorLink output_node = (!dst.isInput ? dst : m_matchingObj).obj; GameObject input_anchor = (dst.isInput ? dst : m_matchingObj).anchorObj; GameObject output_anchor = (!dst.isInput ? dst : m_matchingObj).anchorObj; int input_idx = dst.isInput ? dst.inputIdx : m_matchingObj.inputIdx; input_node.AddInputLink(output_node, input_idx); output_node.AddOutputLink(input_node, input_idx); m_links.Add(new LinkData(m_curLine, input_node, input_idx, output_node)); m_curLine.SetNode(output_anchor, input_anchor); m_matchingObj = null; m_curLine = null; OnLinkChange(); }
public void setSelectedLine(LinkLine inputLine) { this.selectedLine = inputLine; foreach (LinkLine line in this.lineList) { line.isSelected(line == inputLine); line.invalidate(); } this.removeLinkButton.Enabled = this.selectedLine != null; }
public void initCurrentAttachments() { this.lineList.Clear(); this.currentAttachmentScrollArea.clearControls(); this.currentAttachmentArea.invalidate(); int y = 0; int position = 0; foreach (MailLink link in this.linkList) { LinkLine control = new LinkLine(); if (y != 0) { y += 2; } control.Position = new Point(3, y); control.init(link, position, this.currentAttachmentScrollArea.Width - 6, this.readOnly, this); this.currentAttachmentScrollArea.addControl(control); y += control.Height; this.lineList.Add(control); position++; } this.removeLinkButton.Enabled = this.linkList.Count > 0; this.currentAttachmentScrollArea.Size = new Size(this.currentAttachmentScrollArea.Width, y); if (y < this.currentAttachmentBar.Height) { this.currentAttachmentBar.Visible = false; } else { this.currentAttachmentBar.Visible = true; this.currentAttachmentBar.NumVisibleLines = this.currentAttachmentBar.Height; this.currentAttachmentBar.Max = y - this.currentAttachmentBar.Height; } this.currentAttachmentScrollArea.invalidate(); this.currentAttachmentBar.invalidate(); }
void LinkSearch() { linkResult = new List <LinkLine>(); LinkLine line_h1 = HLine(startPos); LinkLine line_v1 = VLine(startPos); LinkLine line_h2 = HLine(endPos); LinkLine line_v2 = VLine(endPos); if (LineCross(line_h1, line_h2)) { // 0折 Debug.Log("========h" + 0); var line = new LinkLine(); line.verticle = false; line.other = startPos.y; line.start = Mathf.Min(startPos.x, endPos.x); line.end = Mathf.Max(startPos.x, endPos.x); linkResult.Add(line); } else if (LineCross(line_v1, line_v2)) { // 0折 Debug.Log("========v" + 0); var line = new LinkLine(); line.verticle = true; line.other = startPos.x; line.start = Mathf.Min(startPos.y, endPos.y); line.end = Mathf.Max(startPos.y, endPos.y); linkResult.Add(line); } else if (LineCross(line_h1, line_v2)) { // 1折 Debug.Log("========h" + 1); var line1 = new LinkLine(); line1.verticle = false; line1.other = startPos.y; line1.start = Mathf.Min(startPos.x, endPos.x); line1.end = Mathf.Max(startPos.x, endPos.x); var line2 = new LinkLine(); line2.verticle = true; line2.other = endPos.x; line2.start = Mathf.Min(startPos.y, endPos.y); line2.end = Mathf.Max(startPos.y, endPos.y); linkResult.Add(line1); linkResult.Add(line2); } else if (LineCross(line_v1, line_h2)) { // 1折 Debug.Log("========v" + 1); var line1 = new LinkLine(); line1.verticle = true; line1.other = startPos.x; line1.start = Mathf.Min(startPos.y, endPos.y); line1.end = Mathf.Max(startPos.y, endPos.y); var line2 = new LinkLine(); line2.verticle = false; line2.other = endPos.y; line2.start = Mathf.Min(startPos.x, endPos.x); line2.end = Mathf.Max(startPos.x, endPos.x); linkResult.Add(line1); linkResult.Add(line2); } else { // 2折以上 int p = LineCrossOther(line_v1, line_v2); if (p != -1) { Debug.Log("========v2"); var line1 = new LinkLine(); line1.verticle = true; line1.other = startPos.x; line1.start = Mathf.Min(startPos.y, p); line1.end = Mathf.Max(startPos.y, p); var line2 = new LinkLine(); line2.verticle = false; line2.other = p; line2.start = Mathf.Min(startPos.x, endPos.x); line2.end = Mathf.Max(startPos.x, endPos.x); var line3 = new LinkLine(); line3.verticle = true; line3.other = endPos.x; line3.start = Mathf.Min(endPos.y, p); line3.end = Mathf.Max(endPos.y, p); linkResult.Add(line1); linkResult.Add(line2); linkResult.Add(line3); } else { p = LineCrossOther(line_h1, line_h2); if (p != -1) { Debug.Log("========h2"); var line1 = new LinkLine(); line1.verticle = false; line1.other = startPos.y; line1.start = Mathf.Min(startPos.x, p); line1.end = Mathf.Max(startPos.x, p); var line2 = new LinkLine(); line2.verticle = true; line2.other = p; line2.start = Mathf.Min(startPos.y, endPos.y); line2.end = Mathf.Max(startPos.y, endPos.y); var line3 = new LinkLine(); line3.verticle = false; line3.other = endPos.y; line3.start = Mathf.Min(endPos.x, p); line3.end = Mathf.Max(endPos.x, p); linkResult.Add(line1); linkResult.Add(line2); linkResult.Add(line3); } else { Debug.Log("========3!"); return; } } } return; }