/** * Find the off page connector associated with this one * This is done using the OPC fields on the shape that store * the partner page sheet and shape ids */ private Shadow GetPartnerOffPageRefShadow() { string pageSheetId = Common.GetCellString(shape, ShapeProperties.OffPageConnectorDestinationPageID); string shapeId = Common.GetCellString(shape, ShapeProperties.OffPageConnectorDestinationShapeID); foreach (Page page in shape.Document.Pages) { if (page.PageSheet.get_UniqueID((short)VisUniqueIDArgs.visGetOrMakeGUID).Equals(pageSheetId)) { Shape partner = null; try { partner = page.Shapes[shapeId]; } catch { Common.ErrorMessage("Off page connector \"" + shape.Text + "\" missing partner on page " + shape.ContainingPage.Name + ".\nRenaming to " + Strings.ToBeDeletedLabel + "."); shape.Text = Strings.ToBeDeletedLabel; } if (partner != null) { return(PathMaker.LookupShadowByShape(partner)); } else { return(null); } } } return(null); }
internal void RemoveOutputsIfNotInTableColumn(Table table, int gotoColumn) { List <Connect> connects = GetShapeOutputs(); List <Shadow> shadows = new List <Shadow>(); foreach (Connect connect in connects) { // The 1D connector is always the To and 2D shapes are always the From Shape toShape = connect.FromSheet; Shadow shadow = PathMaker.LookupShadowByShape(toShape); shadows.Add(shadow); } for (int row = 0; row < table.GetNumRows(); row++) { string uid = table.GetData(row, gotoColumn); Shadow shadow = PathMaker.LookupShadowByUID(uid); if (shadow != null) { shadows.Remove(shadow); } } if (shadows.Count > 0) { foreach (Shadow shadow in shadows) { shadow.shape.Delete(); } } }
public override void OnShapeExitTextEdit() { List <Shadow> list = new List <Shadow>(); // These are still only held together by name Page page = shape.ContainingPage; foreach (Shape s in page.Shapes) { if (shape.Text.Equals(s.Text)) { Shadow shadow = PathMaker.LookupShadowByShape(s); if (shadow.GetType() == this.GetType()) { list.Add(shadow); } } } if (list.Count > 1) { Common.ErrorMessage("Error - Incoming On Page Reference \"" + shape.Text + "\" already exists."); shape.Text = Strings.ToBeDeletedLabel; } }
public override List <Shadow> GetSourceTargets() { List <Shadow> list = new List <Shadow>(); List <Connect> connects = GetShapeInputs(); if (connects.Count == 0) { list.Add(this); } else { foreach (Connect c in connects) { Shape sourceShape = c.FromSheet; Shadow sourceShadow = PathMaker.LookupShadowByShape(sourceShape); if (sourceShadow != null) { list.AddRange(sourceShadow.GetSourceTargets()); } else { list.Add(this); } } } return(list); }
public override List <Shadow> GetSourceTargets() { List <Shadow> list = new List <Shadow>(); List <Connect> connects = GetShapeInputs(); if (connects.Count == 0) { // no inbound connectors, find the partner and go from there OffPageRefShadow partnerShadow = GetPartnerOffPageRefShadow() as OffPageRefShadow; if (partnerShadow != null) { List <Connect> partnerConnects = partnerShadow.GetShapeInputs(); if (partnerConnects.Count == 0) { if (GetShapeOutputs().Count == 0) { Common.ErrorMessage("No inputs for off-page connector " + shape.Text + " on page " + shape.ContainingPage.Name); } else { Common.ErrorMessage("No inputs for off-page connector " + partnerShadow.shape.Text + " on page " + partnerShadow.shape.ContainingPage.Name); } list.Add(this); } else { list.AddRange(partnerShadow.GetSourceTargets()); } } else { list.Add(this); } } else { foreach (Connect c in connects) { // always the from sheet = connector (fromsheet = 1D, tosheet = 2D) Shape sourceShape = c.FromSheet; Shadow sourceShadow = PathMaker.LookupShadowByShape(sourceShape); if (sourceShadow != null) { list.AddRange(sourceShadow.GetSourceTargets()); } else { list.Add(this); } } } return(list); }
// this will be an empty list for a connector // it doesn't have any connectors pointing to it internal List <Shadow> GetOutputs() { List <Connect> connects = GetShapeOutputs(); List <Shadow> list = new List <Shadow>(); foreach (Connect connect in connects) { // The 1D connector is always the To and 2D shapes are always the From Shape toShape = connect.FromSheet; Shadow shadow = PathMaker.LookupShadowByShape(toShape); list.Add(shadow.GetDestinationTarget()); } return(list); }
public override Shadow GetDestinationTarget() { Connect c; c = GetConnect(true); if (c != null) { Shadow connectedToShadow = PathMaker.LookupShadowByShape(c.ToSheet); return(connectedToShadow.GetDestinationTarget()); } else { return(this); } }
public override Shadow GetDestinationTarget() { List <Connect> list = GetShapeOutputs(); System.Diagnostics.Debug.WriteLine("offpage - " + shape.Text + " page - " + shape.ContainingPage.Name); if (list.Count == 0 && GetShapeInputs().Count == 0) { // no in or outbound connectors return(this); } else if (list.Count > 0) { // find outbound link (should only be one) if (list.Count != 1) { return(this); } // the FromSheet is the outgoing connector (always from = 1D, to = 2D) Shadow connectedToShadow = PathMaker.LookupShadowByShape(list[0].FromSheet); if (connectedToShadow != null) { return(connectedToShadow.GetDestinationTarget()); } else { return(this); } } else { OffPageRefShadow partnerShadow = GetPartnerOffPageRefShadow() as OffPageRefShadow; if (partnerShadow != null && partnerShadow.GetShapeOutputs().Count > 0) { return(partnerShadow.GetDestinationTarget()); } else { if (partnerShadow != null && partnerShadow.GetShapeInputs().Count > 0) { Common.ErrorMessage("Off page connector " + shape.Text + " on page " + shape.ContainingPage.Name + " and it's partner both have inputs"); } return(this); } } }
/** * Returns a list of all the nicknames of the input target shapes for * this one. For most shadows, this is the NickName of the shape. For * things like connectors, on and off page refs, etc. this will work * backwards to get to the sources. */ virtual public List <string> GetEnteringFromTargetNames() { List <Connect> connects = GetShapeInputs(); List <string> list = new List <string>(); foreach (Connect connect in connects) { Shape input = connect.FromSheet; Shadow shadow = PathMaker.LookupShadowByShape(input); foreach (Shadow s in shadow.GetSourceTargets()) { list.Add(s.GetGotoName()); } } return(list); }
private bool ReadyForConnectorMove(out Cell nonArrowSideCell, out Shape fromShape) { nonArrowSideCell = null; fromShape = null; if (visioControl.Document.Application.ActiveWindow.Selection.Count != 1) { Common.ErrorMessage("A single connector must be selected"); return(false); } Shape connector = visioControl.Document.Application.ActiveWindow.Selection[1]; ShapeTypes type = Common.GetShapeType(connector); if (type != ShapeTypes.Connector) { Common.ErrorMessage("A single connector must be selected"); return(false); } Shadow connectorShadow = PathMaker.LookupShadowByShape(connector); if (connectorShadow == null) { Common.ErrorMessage("Connector is not a valid PathMaker shape"); return(false); } nonArrowSideCell = connector.get_Cells("BeginX"); Connect nonArrowSideConnect = null; foreach (Connect c in connector.Connects) { if (c.FromCell.Name.Equals(Strings.BeginConnectionPointCellName)) { nonArrowSideConnect = c; } } if (nonArrowSideConnect == null) { Common.ErrorMessage("Connector must be connected on the non-arrow side"); return(false); } fromShape = nonArrowSideConnect.ToSheet; return(true); }
public override List <Shadow> GetSourceTargets() { List <Shadow> list = new List <Shadow>(); Connect c; c = GetConnect(false); if (c != null) { Shadow connectedToShadow = PathMaker.LookupShadowByShape(c.ToSheet); list.AddRange(connectedToShadow.GetSourceTargets()); } else { list.Add(this); } return(list); }
/** * This returns the partner on page ref in that is associated with this one */ private Shadow GetPartnerOnPageRefInShadow() { // These are still only held together by name Page page = shape.ContainingPage; foreach (Shape s in page.Shapes) { if (shape.Text.Equals(s.Text)) { Shadow shadow = PathMaker.LookupShadowByShape(s); if (shadow.GetShapeType() == ShapeTypes.OnPageRefIn) { return(shadow); } } } return(null); }
// this will be an empty list for a connector // it doesn't have any connectors pointing to it internal List <Shadow> GetInputs() { List <Connect> connects = GetShapeInputs(); List <Shadow> list = new List <Shadow>(); foreach (Connect connect in connects) { // The 1D connector is always the To and 2D shapes are always the From Shape fromShape = connect.FromSheet; Shadow shadow = PathMaker.LookupShadowByShape(fromShape); foreach (Shadow s in shadow.GetSourceTargets()) { list.Add(s); } } return(list); }
// We need this to handle pasting - when objects are pasted the transitions have the old GUIDs but // visio may have assigned new ones to the pasted objects. We stash the old GUIDs in OnWindowSelectionChange // and we make use of them here to get everyone in sync private void OnExitScope(Microsoft.Office.Interop.Visio.Application application, string moreInformation) { // moreInformation is a standard ;-delimited string from the scope events that contains what we need // 1344 is the Microsoft Scope Id for GotoPage if (moreInformation.StartsWith("1344")) { string pageName = visioControl.Document.Application.ActivePage.Name; int index = visioControl.Document.Pages[pageName].Index; gotoPageComboBox.SelectedIndex = index - 1; } // 1022 is the Microsoft Scope Id for Paste // 1024 is the Microsoft Scope Id for Duplicate else if (moreInformation.StartsWith(((int)VisUICmds.visCmdUFEditPaste).ToString()) || moreInformation.StartsWith(((int)VisUICmds.visCmdUFEditDuplicate).ToString())) { // first make a map of old GUIDs to new Dictionary <string, string> oldGUIDToNewGUIDMap = new Dictionary <string, string>(); foreach (Shape shape in visioControl.Document.Application.ActiveWindow.Selection) { string oldUID = Common.GetCellString(shape, Strings.CutCopyPasteTempCellName); string newUID = shape.get_UniqueID((short)VisUniqueIDArgs.visGetOrMakeGUID); oldGUIDToNewGUIDMap.Add(oldUID, newUID); } // now call each shadow to fix itself foreach (Shape shape in visioControl.Document.Application.ActiveWindow.Selection) { Shadow s = PathMaker.LookupShadowByShape(shape); if (s == null) { continue; } s.FixUIDReferencesAfterPaste(oldGUIDToNewGUIDMap); } // because we halt this when pasting, we now need to go fix all the ones that were pasted foreach (Shape s in visioControl.Document.Application.ActiveWindow.Selection) { string uid = s.get_UniqueID((short)VisUniqueIDArgs.visGetOrMakeGUID); Common.SetCellString(s, Strings.CutCopyPasteTempCellName, uid); } } }
/** * Gets the on page ref in that is associated with this one * this is done using the name of the shape */ private List <Shadow> GetPartnerOnPageRefOutShadow() { List <Shadow> list = new List <Shadow>(); // These are still only held together by name Page page = shape.ContainingPage; foreach (Shape s in page.Shapes) { if (shape.Text.Equals(s.Text)) { Shadow shadow = PathMaker.LookupShadowByShape(s); if (shadow.GetShapeType() == ShapeTypes.OnPageRefOut) { list.Add(shadow); } } } return(list); }
public override Shadow GetDestinationTarget() { List <Connect> connects = GetShapeOutputs(); // find outbound link (should only be one) if (connects.Count != 1) { return(this); } // the FromSheet is the outgoing connector (always from = 1D, to = 2D) Shadow connectedToShadow = PathMaker.LookupShadowByShape(connects[0].FromSheet); if (connectedToShadow != null) { return(connectedToShadow.GetDestinationTarget()); } else { return(this); } }
override public void OnBeforeShapeDelete() { // clean up our connections to other states - ConnectDelete is not called when the shape is deleted Connect c = GetConnect(false); if (c == null) { return; } // determine which end of the connector is connected to the nonConnectorShadow // In this case, it's always the c.FromCell that tells us bool arrowSide = false; if (c.FromCell.Name.Equals(Strings.EndConnectionPointCellName)) { arrowSide = true; } Shadow connectedToShadow = PathMaker.LookupShadowByShape(c.ToSheet); if (connectedToShadow != null) { if (arrowSide) { connectedToShadow.OnConnectDeleteInput(this); } else { connectedToShadow.OnConnectDeleteOutput(this); } } else { Common.ErrorMessage("Connector goes to unknown shape " + c.ToSheet.Name); } }