Ejemplo n.º 1
0
    private void BottomRight()
    {
        GUI.skin = leftRight;
        GUI.BeginGroup(new Rect(Screen.width - 300, Screen.height - 300, 300, 300));
        GUI.DrawTexture(new Rect(0, 0, 300, 300), bgImage, ScaleMode.StretchToFill);

        if (GameVars.selectedTurret != null)
        {
            Tower selectedTower = GameVars.selectedTurret.GetComponent<Tower>();
            targetMode = (TargetMode)GUI.SelectionGrid(new Rect(40, 40, 180, 50), (int)targetMode, selectionStrings, 2);
            damage = GUI.HorizontalSlider(new Rect(30, 100, 130, 30), selectedTower.Damage, 1.0f, selectedTower.maxPoints);
            speed = GUI.HorizontalSlider(new Rect(30, 130, 130, 30), selectedTower.Speed, 1.0f, selectedTower.maxPoints);
            range = GUI.HorizontalSlider(new Rect(30, 160, 130, 30), selectedTower.Range, 1.0f, selectedTower.maxPoints);
            GUI.Label(new Rect(170, 90, 200, 100), "Damage: " + (int)damage);
            GUI.Label(new Rect(170, 120, 200, 100), "Speed: " + (int)speed);
            GUI.Label(new Rect(170, 150, 200, 100), "Range: " + (int)range);

            //if anything has changed, update it
            if (damage != selectedTower.Damage) { GameVars.selectedTurret.GetComponent<Tower>().Damage = damage; }
            if (speed != selectedTower.Speed) { GameVars.selectedTurret.GetComponent<Tower>().Speed = speed; }
            if (range != selectedTower.Range) { GameVars.selectedTurret.GetComponent<Tower>().Range = range; }
            if (targetMode != selectedTower.targetingMode) { GameVars.selectedTurret.GetComponent<Tower>().targetingMode = targetMode; }
        }
        GUI.EndGroup();
    }
Ejemplo n.º 2
0
        internal override ZipPackageRelationship CreateRelationship(Uri targetUri, TargetMode targetMode, string relationshipType)
        {

            var rel = base.CreateRelationship(targetUri, targetMode, relationshipType);
            rel.SourceUri = Uri;
            return rel;
        }
		protected void OnEnable()
		{
#if UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9 || UNITY_5_0
			this.title = "SP Reference Replacer";
#else
            this.titleContent = new GUIContent("SP Reference Replacer");
#endif
            if (EditorPrefs.HasKey(SPTools.Settings_SavedInstanceIDKey))
			{
				string instancePath = AssetDatabase.GetAssetPath(EditorPrefs.GetInt(SPTools.Settings_SavedInstanceIDKey, 0));
				
				if (!string.IsNullOrEmpty(instancePath))
				{
					this.m_Instance = AssetDatabase.LoadAssetAtPath(instancePath, typeof(SPInstance)) as SPInstance;
				}
			}
			
			// Default prefs
			if (!EditorPrefs.HasKey(SPReferenceReplacerWindow.PrefsKey_TargetMode))
			{
				EditorPrefs.SetInt(SPReferenceReplacerWindow.PrefsKey_TargetMode, (int)this.m_TargetMode);
			}
			
			// Load target mode setting
			this.m_TargetMode = (TargetMode)EditorPrefs.GetInt(SPReferenceReplacerWindow.PrefsKey_TargetMode);
		}
Ejemplo n.º 4
0
 public Transform GetTarget(TargetMode mode)
 {
     if (mode == TargetMode.Single) {
         return primaryTarget;
     } else {
         return targetList.RandomOrDefault ();
     }
 }
Ejemplo n.º 5
0
    public void Fire(TargetMode mode, MagicSpawner magazine)
    {
        if (!isActive) return;

        if (magazine.IsLoaded) {
            magazine.Fire (GetTarget (mode));
        }
    }
Ejemplo n.º 6
0
    public void Fire(TargetMode mode)
    {
        if (!isActive) return;

        magazines
            .Where (m => m.IsLoaded)
            .ToList ()
            .ForEach (m => m.Fire (GetTarget(mode)));
    }
 internal virtual ZipPackageRelationship CreateRelationship(Uri targetUri, TargetMode targetMode, string relationshipType)
 {
     var rel = new ZipPackageRelationship();
     rel.TargetUri = targetUri;
     rel.TargetMode = targetMode;
     rel.RelationshipType = relationshipType;
     rel.Id = "rId" + (maxRId++).ToString();
     _rels.Add(rel);
     return rel;
 }
Ejemplo n.º 8
0
    // Use this for initialization
    void Start()
    {
        if(targetMode==TargetMode.Transform&&targetTransform==null)targetMode = TargetMode.Point;
        trans = transform;

        #if UNITY_EDITOR
        curPosA = new Vector3[numPoints+1];
        firstAxisA = new Vector3[numPoints+1];
        secondAxisA = new Vector3[numPoints+1];
        #endif
    }
Ejemplo n.º 9
0
        internal PackageRelationship(string id, Package package, string relationshipType,
                                      Uri sourceUri, TargetMode targetMode, Uri targetUri)
        {
            Check.IdIsValid(id);
            Check.Package(package);
            Check.RelationshipTypeIsValid(relationshipType);
            Check.SourceUri(sourceUri);
            Check.TargetUri(targetUri);

            Id = id;
            Package = package;
            RelationshipType = relationshipType;
            SourceUri = sourceUri;
            TargetMode = targetMode;
            TargetUri = targetUri;
        }
Ejemplo n.º 10
0
    public void Slam(Vector3 target)
    {
        if (hasTarget) return;

        targetMode = TargetMode.SLAM;
        Vector3 start = transform.position;
        start.x = Mathf.Clamp(start.x, transform.parent.position.x + minX, transform.parent.position.x + maxX);
        Vector3 end = target;
        end.x = Mathf.Clamp(end.x, transform.parent.position.x + minX, transform.parent.position.x + maxX);
        end.y = start.y;
        Vector3 b = new Vector3(start.x, start.y + maxHeight * 0.5f);
        Vector3 c = new Vector3(end.x, start.y + maxHeight);
        Vector3[] points = new Vector3[] { start, b, c, end };
        bezier = new CubicBezier(points);
        hasTarget = true;
        progress = 0.01f;
    }
Ejemplo n.º 11
0
        /**
         * Constructor.
         * 
         * @param pkg
         * @param sourcePart
         * @param targetUri
         * @param targetMode
         * @param relationshipType
         * @param id
         */
        public PackageRelationship(OPCPackage pkg, PackagePart sourcePart,
                Uri targetUri, TargetMode targetMode, String relationshipType,
                String id)
        {
            if (pkg == null)
                throw new ArgumentException("pkg");
            if (targetUri == null)
                throw new ArgumentException("targetUri");
            if (relationshipType == null)
                throw new ArgumentException("relationshipType");
            if (id == null)
                throw new ArgumentException("id");

            this.container = pkg;
            this.source = sourcePart;
            this.targetUri = targetUri;
            this.targetMode = targetMode;
            this.relationshipType = relationshipType;
            this.id = id;
        }
Ejemplo n.º 12
0
 public void Sweep(Vector3 target)
 {
     targetMode = TargetMode.SWEEP;
     sweepStart = transform.position;
     sweepStart.y = minY;
     sweepTarget = target;
     sweepTarget.y = minY;
     hasTarget = true;
     progress = 0.01f;
 }
Ejemplo n.º 13
0
 public Relationship AddExternalPartToTree(string relationshipType, string externalLocation, XmlPart parent, TargetMode targetMode)
 {
     return(AddRelationship(externalLocation, relationshipType, parent.Location, targetMode));
 }
Ejemplo n.º 14
0
 private static extern void VertexAnimationTrack_setTargetMode(IntPtr animTrack, TargetMode m);
Ejemplo n.º 15
0
		private PackageRelationship CreateRelationship (Uri targetUri, TargetMode targetMode, string relationshipType, string id, bool loading)
		{
			Package.CheckIsReadOnly ();
			Check.TargetUri (targetUri);
			Check.RelationshipTypeIsValid (relationshipType);
			Check.IdIsValid (id);

			if (id == null)
				id = NextId ();

			if (Relationships.ContainsKey (id))
				throw new XmlException ("A relationship with this ID already exists");
			
			PackageRelationship r = new PackageRelationship (id, Package, relationshipType, Uri, targetMode, targetUri);
			Relationships.Add (r.Id, r);

			if (!loading)
				WriteRelationships ();
			return r;
		}
 public void SetCameraTargetMode(TargetMode mode)
 {
     //GameManger._instance.cameraCtrl.camTarget.mode
     gameManager.Write(Program, (int)mode, 0x0, cameraCtrl, camTarget, 0x20);
 }
Ejemplo n.º 17
0
        //------------------------------------------------------
        //
        //  Public Methods
        //
        //------------------------------------------------------
        // None
        //------------------------------------------------------
        //
        //  Public Events
        //
        //------------------------------------------------------
        // None
        //------------------------------------------------------
        //
        //  Internal Constructors
        //
        //------------------------------------------------------

        #region Internal Constructor

        /// <summary>
        /// PackageRelationship constructor
        /// </summary>
        /// <param name="package">Owning Package object for this relationship</param>
        /// <param name="sourcePart">owning part - will be null if the owner is the container</param>
        /// <param name="targetUri">target of relationship</param>
        /// <param name="targetMode">enum specifying the interpretation of the base uri for the target uri</param>
        /// <param name="relationshipType">type name</param>
        /// <param name="id">unique identifier</param>
        internal PackageRelationship(Package package, PackagePart sourcePart, Uri targetUri, TargetMode targetMode, string relationshipType, string id)
        {
            //sourcePart can be null to represent that the relationships are at the package level

            if (package == null)
                throw new ArgumentNullException("package");

            if (targetUri == null)
                throw new ArgumentNullException("targetUri");

            if (relationshipType == null)
                throw new ArgumentNullException("relationshipType");

            if (id == null)
                throw new ArgumentNullException("id");
            // The ID is guaranteed to be an XML ID by the caller (InternalRelationshipCollection).
            // The following check is a precaution against future bug introductions.
#if DEBUG
            try
            {
                // An XSD ID is an NCName that is unique. We can't check uniqueness at this level.
                XmlConvert.VerifyNCName(id);
            }
            catch (XmlException exception)
            {
                throw new XmlException(Formatter.Format(Resources.NotAValidXmlIdString, id), exception);
            }
#endif

            // Additional check - don't accept absolute Uri's if targetMode is Internal.
            Debug.Assert((targetMode == TargetMode.External || !targetUri.IsAbsoluteUri),
                "PackageRelationship target must be relative if the TargetMode is Internal");

            // Additional check - Verify if the Enum value is valid
            Debug.Assert((targetMode >= TargetMode.Internal || targetMode <= TargetMode.External),
                "TargetMode enum value is out of Range");

            // Look for empty string or string with just spaces
            Debug.Assert(relationshipType.Trim() != String.Empty,
                "RelationshipType cannot be empty string or a string with just spaces");

            _package = package;
            _source = sourcePart;
            _targetUri = targetUri;
            _relationshipType = relationshipType;
            _targetMode = targetMode;
            _id = id;
        }
Ejemplo n.º 18
0
 public PackageRelationship CreateRelationship(Uri targetUri, TargetMode targetMode, string relationshipType)
 {
     return(CreateRelationship(targetUri, targetMode, relationshipType, null));
 }
Ejemplo n.º 19
0
 public PackageRelationship CreateRelationship(Uri targetUri, TargetMode targetMode, string relationshipType, string id)
 {
     this.CheckInvalidState();
     this._container.ThrowIfReadOnly();
     this.EnsureRelationships();
     return this._relationships.Add(targetUri, targetMode, relationshipType, id);
 }
Ejemplo n.º 20
0
        /// <summary>
        /// PackageRelationship constructor
        /// </summary>
        /// <param name="package">Owning Package object for this relationship</param>
        /// <param name="sourcePart">owning part - will be null if the owner is the container</param>
        /// <param name="targetUri">target of relationship</param>
        /// <param name="targetMode">enum specifying the interpretation of the base uri for the target uri</param>
        /// <param name="relationshipType">type name</param>
        /// <param name="id">unique identifier</param>
        internal PackageRelationship(Package package, PackagePart sourcePart, Uri targetUri, TargetMode targetMode, string relationshipType, string id)
        {
            //sourcePart can be null to represent that the relationships are at the package level

            if (package == null)
            {
                throw new ArgumentNullException(nameof(package));
            }

            if (targetUri == null)
            {
                throw new ArgumentNullException(nameof(targetUri));
            }

            if (relationshipType == null)
            {
                throw new ArgumentNullException(nameof(relationshipType));
            }

            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }
            // The ID is guaranteed to be an XML ID by the caller (InternalRelationshipCollection).
            // The following check is a precaution against future bug introductions.
#if DEBUG
            try
            {
                // An XSD ID is an NCName that is unique. We can't check uniqueness at this level.
                XmlConvert.VerifyNCName(id);
            }
            catch (XmlException exception)
            {
                throw new XmlException(SR.Format(SR.NotAValidXmlIdString, id), exception);
            }
#endif

            // Additional check - don't accept absolute Uri's if targetMode is Internal.
            Debug.Assert((targetMode == TargetMode.External || !targetUri.IsAbsoluteUri),
                         "PackageRelationship target must be relative if the TargetMode is Internal");

            // Additional check - Verify if the Enum value is valid
            Debug.Assert((targetMode >= TargetMode.Internal || targetMode <= TargetMode.External),
                         "TargetMode enum value is out of Range");

            // Look for empty string or string with just spaces
            Debug.Assert(relationshipType.Trim() != string.Empty,
                         "RelationshipType cannot be empty string or a string with just spaces");

            _package          = package;
            _source           = sourcePart;
            _targetUri        = targetUri;
            _relationshipType = relationshipType;
            _targetMode       = targetMode;
            _id = id;
        }
Ejemplo n.º 21
0
        /**
         * Adds a picture to the document.
         *
         * @param pictureData       The picture data
         * @param format            The format of the picture.
         *
         * @return the index to this picture (0 based), the Added picture can be obtained from {@link #getAllPictures()} .
         * @throws InvalidFormatException
         */
        public String AddPictureData(byte[] pictureData, int format)
        {
            XWPFPictureData xwpfPicData = document.FindPackagePictureData(pictureData, format);
            POIXMLRelation  relDesc     = XWPFPictureData.RELATIONS[format];

            if (xwpfPicData == null)
            {
                /* Part doesn't exist, create a new one */
                int idx = document.GetNextPicNameNumber(format);
                xwpfPicData = (XWPFPictureData)CreateRelationship(relDesc, XWPFFactory.GetInstance(), idx);
                /* write bytes to new part */
                PackagePart picDataPart = xwpfPicData.GetPackagePart();
                Stream      out1        = null;
                try
                {
                    out1 = picDataPart.GetOutputStream();
                    out1.Write(pictureData, 0, pictureData.Length);
                }
                catch (IOException e)
                {
                    throw new POIXMLException(e);
                }
                finally
                {
                    try
                    {
                        out1.Close();
                    }
                    catch (IOException)
                    {
                        // ignore
                    }
                }

                document.RegisterPackagePictureData(xwpfPicData);
                pictures.Add(xwpfPicData);
                return(GetRelationId(xwpfPicData));
            }
            else if (!GetRelations().Contains(xwpfPicData))
            {
                /*
                 * Part already existed, but was not related so far. Create
                 * relationship to the already existing part and update
                 * POIXMLDocumentPart data.
                 */
                PackagePart picDataPart = xwpfPicData.GetPackagePart();
                // TODO add support for TargetMode.EXTERNAL relations.
                TargetMode          targetMode = TargetMode.Internal;
                PackagePartName     partName   = picDataPart.PartName;
                String              relation   = relDesc.Relation;
                PackageRelationship relShip    = GetPackagePart().AddRelationship(partName, targetMode, relation);
                String              id         = relShip.Id;
                AddRelation(id, xwpfPicData);
                pictures.Add(xwpfPicData);
                return(id);
            }
            else
            {
                /* Part already existed, Get relation id and return it */
                return(GetRelationId(xwpfPicData));
            }
        }
Ejemplo n.º 22
0
        internal sealed override PackageRelationship CreateRelationship(Uri targetUri, TargetMode targetMode, string relationshipType, string id)
        {
            ThrowIfObjectDisposed();

            return(_packagePart.CreateRelationship(targetUri, targetMode, relationshipType, id));
        }
Ejemplo n.º 23
0
        protected void OnGUI()
        {
            EditorGUIUtility.labelWidth = 100f;

            GUILayout.BeginVertical();
            GUILayout.Space((float)SPReferenceReplacerWindow.padding.top);
            GUILayout.BeginHorizontal();
            GUILayout.Space((float)SPReferenceReplacerWindow.padding.left);
            GUILayout.BeginVertical();

            GUI.changed     = false;
            this.m_Instance = EditorGUILayout.ObjectField("Sprite Packer", this.m_Instance, typeof(SPInstance), false) as SPInstance;
            if (GUI.changed)
            {
                // Save the instance id
                EditorPrefs.SetInt(SPTools.Settings_SavedInstanceIDKey, (this.m_Instance == null) ? 0 : this.m_Instance.GetInstanceID());
            }

            GUILayout.Space(6f);

            GUILayout.BeginVertical(GUI.skin.box);
            GUILayout.Space(6f);

            GUILayout.BeginHorizontal();
            GUILayout.Space(6f);

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.LabelField("Replace references in", GUILayout.Width(130f));
            this.m_TargetMode = (TargetMode)EditorGUILayout.EnumPopup(this.m_TargetMode);
            if (EditorGUI.EndChangeCheck())
            {
                EditorPrefs.SetInt(SPReferenceReplacerWindow.PrefsKey_TargetMode, (int)this.m_TargetMode);
            }

            GUILayout.Space(6f);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(6f);
            GUI.changed = false;
            bool spriteRenderersOnly = GUILayout.Toggle(EditorPrefs.GetBool(SPReferenceReplacerWindow.PrefsKey_SpriteRenderersOnly), " Replace references in Sprite Renderers only ?");

            if (GUI.changed)
            {
                EditorPrefs.SetBool(SPReferenceReplacerWindow.PrefsKey_SpriteRenderersOnly, spriteRenderersOnly);
            }
            GUILayout.Space(6f);
            GUILayout.EndHorizontal();

            GUILayout.Space(6f);
            GUILayout.EndVertical();

            GUILayout.Space(6f);

            if (this.m_Instance == null)
            {
                EditorGUILayout.HelpBox("Please set the sprite packer instance reference in order to use this feature.", MessageType.Info);
            }
            else
            {
                if (GUILayout.Button("Replace"))
                {
                    int replacedCount = 0;

                    switch (this.m_TargetMode)
                    {
                    case TargetMode.CurrentScene:
                    {
                        replacedCount += SPTools.ReplaceReferencesInScene(this.m_Instance.copyOfSprites, spriteRenderersOnly);
                        break;
                    }

                    case TargetMode.ProjectOnly:
                    {
                        replacedCount += SPTools.ReplaceReferencesInProject(this.m_Instance.copyOfSprites, spriteRenderersOnly);
                        break;
                    }

                    case TargetMode.CurrentSceneAndProject:
                    {
                        replacedCount += SPTools.ReplaceReferencesInProject(this.m_Instance.copyOfSprites, spriteRenderersOnly);
                        replacedCount += SPTools.ReplaceReferencesInScene(this.m_Instance.copyOfSprites, spriteRenderersOnly);
                        break;
                    }

                    case TargetMode.AllScenes:
                    {
                        replacedCount += SPTools.ReplaceReferencesInAllScenes(this.m_Instance.copyOfSprites, spriteRenderersOnly, false);
                        break;
                    }

                    case TargetMode.AllScenesAndProject:
                    {
                        replacedCount += SPTools.ReplaceReferencesInProject(this.m_Instance.copyOfSprites, spriteRenderersOnly);
                        replacedCount += SPTools.ReplaceReferencesInScene(this.m_Instance.copyOfSprites, spriteRenderersOnly);
                        EditorSceneManager.SaveOpenScenes();
                        replacedCount += SPTools.ReplaceReferencesInAllScenes(this.m_Instance.copyOfSprites, spriteRenderersOnly, true);
                        break;
                    }
                    }

                    EditorUtility.DisplayDialog("Reference Replacer", "Replaced references count: " + replacedCount.ToString(), "Okay");
                }
            }

            GUILayout.EndVertical();
            GUILayout.Space((float)SPReferenceReplacerWindow.padding.right);
            GUILayout.EndHorizontal();
            GUILayout.Space((float)SPReferenceReplacerWindow.padding.bottom);
            GUILayout.EndVertical();
        }
Ejemplo n.º 24
0
 internal override void ReplaceRelationship(Uri targetUri, TargetMode targetMode, string strRelationshipType, string strId)
 {
     this.BasePackage.DeleteRelationship(strId);
     this.BasePackage.CreateRelationship(targetUri, targetMode, strRelationshipType, strId);
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Creates a relationship at the Package level with the Target PackagePart specified as the Uri
 /// </summary>
 /// <param name="targetUri">Target's URI</param>
 /// <param name="targetMode">Enumeration indicating the base uri for the target uri</param>
 /// <param name="relationshipType">PackageRelationship type, having uri like syntax that is used to
 /// uniquely identify the role of the relationship</param>
 /// <param name="id">String that conforms to the xsd:ID datatype. Unique across the source's
 /// relationships. Null is OK (ID will be generated). An empty string is an invalid XML ID.</param>
 /// <returns></returns>
 /// <exception cref="ObjectDisposedException">If this Package object has been disposed</exception>
 /// <exception cref="IOException">If the package is readonly, it cannot be modified</exception>
 /// <exception cref="ArgumentNullException">If parameter "targetUri" is null</exception>
 /// <exception cref="ArgumentNullException">If parameter "relationshipType" is null</exception>
 /// <exception cref="ArgumentOutOfRangeException">If parameter "targetMode" enumeration does not have a valid value</exception>
 /// <exception cref="ArgumentException">If TargetMode is TargetMode.Internal and the targetUri is an absolute Uri </exception>
 /// <exception cref="ArgumentException">If relationship is being targeted to a relationship part</exception>
 /// <exception cref="System.Xml.XmlException">If parameter "id" is not a valid Xsd Id</exception>
 /// <exception cref="System.Xml.XmlException">If an id is provided in the method, and its not unique</exception>
 public PackageRelationship CreateRelationship(Uri targetUri, TargetMode targetMode, string relationshipType, String id)
 {
     ThrowIfObjectDisposed();
     ThrowIfReadOnly();
     EnsureRelationships();
     //All parameter validation is done in the following call
     return _relationships.Add(targetUri, targetMode, relationshipType, id);
 }
Ejemplo n.º 26
0
 public PackageRelationship CreateRelationship(Uri targetUri, TargetMode targetMode, string relationshipType, string id)
 {
     return(CreateRelationship(targetUri, targetMode, relationshipType, id, false));
 }
Ejemplo n.º 27
0
 /**
  * Add a relationship to a part (except relationships part).
  *
  * @param targetURI
  *            URI the target part. Must be relative to the source root
  *            directory of the part.
  * @param targetMode
  *            Mode [Internal|External].
  * @param relationshipType
  *            Type of relationship.
  * @return The newly created and added relationship
  * @see org.apache.poi.OpenXml4Net.opc.RelationshipSource#AddRelationship(org.apache.poi.OpenXml4Net.opc.PackagePartName,
  *      org.apache.poi.OpenXml4Net.opc.TargetMode, java.lang.String)
  */
 public PackageRelationship AddRelationship(Uri targetURI,
                                            TargetMode targetMode, String relationshipType)
 {
     return(AddRelationship(targetURI, targetMode, relationshipType, null));
 }
Ejemplo n.º 28
0
        public static bool ModifyIndividual(IBaseWindow baseWin, ref GDMIndividualRecord indivRec,
                                            GDMIndividualRecord target, TargetMode targetMode, GDMSex needSex)
        {
            bool result;

            try {
                baseWin.Context.BeginUpdate();
                GDMTree tree = baseWin.Context.Tree;

                using (var dlg = AppHost.ResolveDialog <IPersonEditDlg>(baseWin)) {
                    bool exists = (indivRec != null);
                    if (!exists)
                    {
                        indivRec = new GDMIndividualRecord(tree);
                        indivRec.InitNew();

                        indivRec.AddPersonalName(new GDMPersonalName(indivRec));
                        baseWin.Context.CreateEventEx(indivRec, GEDCOMTagName.BIRT, "", "");
                    }

                    try {
                        baseWin.Context.LockRecord(indivRec);

                        dlg.Person = indivRec;

                        if (targetMode != TargetMode.tmNone)
                        {
                            if (needSex == GDMSex.svMale || needSex == GDMSex.svFemale)
                            {
                                dlg.SetNeedSex(needSex);
                            }
                            dlg.TargetMode = targetMode;
                            dlg.Target     = target;
                        }

                        result = (AppHost.Instance.ShowModalX(dlg, false));
                    } finally {
                        baseWin.Context.UnlockRecord(indivRec);
                    }

                    if (!exists)
                    {
                        if (result)
                        {
                            PostProcessPerson(baseWin, indivRec);

                            tree.AddRecord(indivRec);
                        }
                        else
                        {
                            indivRec.Clear();
                            indivRec.Dispose();
                            indivRec = null;
                        }
                    }
                }
            } finally {
                baseWin.Context.EndUpdate();
            }

            return(result);
        }
Ejemplo n.º 29
0
        /**
         * Add a relationship to a part (except relationships part).
         * <p>
         * Check rule M1.25: The Relationships part shall not have relationships to
         * any other part. Package implementers shall enforce this requirement upon
         * the attempt to create such a relationship and shall treat any such
         * relationship as invalid.
         * </p>
         * @param targetPartName
         *            Name of the target part. This one must be relative to the
         *            source root directory of the part.
         * @param targetMode
         *            Mode [Internal|External].
         * @param relationshipType
         *            Type of relationship.
         * @param id
         *            Relationship unique id.
         * @return The newly created and added relationship
         * 
         * @throws InvalidFormatException
         *             If the URI point to a relationship part URI.
         * @see org.apache.poi.OpenXml4Net.opc.RelationshipSource#AddRelationship(org.apache.poi.OpenXml4Net.opc.PackagePartName,
         *      org.apache.poi.OpenXml4Net.opc.TargetMode, java.lang.String, java.lang.String)
         */
        public PackageRelationship AddRelationship(PackagePartName targetPartName,
                TargetMode targetMode, String relationshipType, String id)
        {
            _container.ThrowExceptionIfReadOnly();

            if (targetPartName == null)
            {
                throw new ArgumentException("targetPartName");
            }
            //if (targetMode == null)
            //{
            //    throw new ArgumentException("targetMode");
            //}
            if (relationshipType == null)
            {
                throw new ArgumentException("relationshipType");
            }

            if (this.IsRelationshipPart || targetPartName.IsRelationshipPartURI())
            {
                throw new InvalidOperationException(
                        "Rule M1.25: The Relationships part shall not have relationships to any other part.");
            }

            if (_relationships == null)
            {
                _relationships = new PackageRelationshipCollection();
            }

            return _relationships.AddRelationship(targetPartName.URI,
                    targetMode, relationshipType, id);
        }
Ejemplo n.º 30
0
        /**
         * Add a relationship to the package (except relationships part).
         * 
         * Check rule M4.1 : The format designer shall specify and the format
         * producer shall Create at most one core properties relationship for a
         * package. A format consumer shall consider more than one core properties
         * relationship for a package to be an error. If present, the relationship
         * shall target the Core Properties part.
         * 
         * Check rule M1.25: The Relationships part shall not have relationships to
         * any other part. Package implementers shall enforce this requirement upon
         * the attempt to Create such a relationship and shall treat any such
         * relationship as invalid.
         * 
         * @param targetPartName
         *            Target part name.
         * @param targetMode
         *            Target mode, either Internal or External.
         * @param relationshipType
         *            Relationship type.
         * @param relID
         *            ID of the relationship.
         * @see PackageRelationshipTypes
         */
        public PackageRelationship AddRelationship(PackagePartName targetPartName,
                TargetMode targetMode, String relationshipType, String relID)
        {
            /* Check OPC compliance */

            // Check rule M4.1 : The format designer shall specify and the format
            // producer
            // shall Create at most one core properties relationship for a package.
            // A format consumer shall consider more than one core properties
            // relationship for a package to be an error. If present, the
            // relationship shall target the Core Properties part.
            if (relationshipType.Equals(PackageRelationshipTypes.CORE_PROPERTIES)
                    && this.packageProperties != null)
                throw new InvalidOperationException(
                        "OPC Compliance error [M4.1]: can't add another core properties part ! Use the built-in package method instead.");

            /*
             * Check rule M1.25: The Relationships part shall not have relationships
             * to any other part. Package implementers shall enforce this
             * requirement upon the attempt to Create such a relationship and shall
             * treat any such relationship as invalid.
             */
            if (targetPartName.IsRelationshipPartURI())
            {
                throw new InvalidOperationException(
                        "Rule M1.25: The Relationships part shall not have relationships to any other part.");
            }

            /* End OPC compliance */

            EnsureRelationships();
            PackageRelationship retRel = relationships.AddRelationship(
                    targetPartName.URI, targetMode, relationshipType, relID);
            this.isDirty = true;
            return retRel;
        }
        protected void OnGUI()
        {
            EditorGUIUtility.labelWidth = 100f;

            GUILayout.BeginVertical();
            GUILayout.Space((float)SPReferenceReplacerWindow.padding.top);
            GUILayout.BeginHorizontal();
            GUILayout.Space((float)SPReferenceReplacerWindow.padding.left);
            GUILayout.BeginVertical();

            GUI.changed = false;
            this.m_Instance = EditorGUILayout.ObjectField("Sprite Packer", this.m_Instance, typeof(SPInstance), false) as SPInstance;
            if (GUI.changed)
            {
                // Save the instance id
                EditorPrefs.SetInt(SPTools.Settings_SavedInstanceIDKey, (this.m_Instance == null) ? 0 : this.m_Instance.GetInstanceID());
            }

            GUILayout.Space(6f);

            GUILayout.BeginVertical(GUI.skin.box);
            GUILayout.Space(6f);

            GUILayout.BeginHorizontal();
            GUILayout.Space(6f);

            EditorGUILayout.LabelField("Replace mode", GUILayout.Width(130f));
            this.m_ReplaceMode = (ReplaceMode)EditorGUILayout.EnumPopup(this.m_ReplaceMode);

            GUILayout.Space(6f);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(6f);

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.LabelField("Replace references in", GUILayout.Width(130f));
            this.m_TargetMode = (TargetMode)EditorGUILayout.EnumPopup(this.m_TargetMode);
            if (EditorGUI.EndChangeCheck())
            {
                EditorPrefs.SetInt(SPReferenceReplacerWindow.PrefsKey_TargetMode, (int)this.m_TargetMode);
            }

            GUILayout.Space(6f);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(6f);
            GUI.changed = false;
            bool spriteRenderersOnly = GUILayout.Toggle(EditorPrefs.GetBool(SPReferenceReplacerWindow.PrefsKey_SpriteRenderersOnly), " Replace references in Sprite Renderers only ?");
            if (GUI.changed)
            {
                EditorPrefs.SetBool(SPReferenceReplacerWindow.PrefsKey_SpriteRenderersOnly, spriteRenderersOnly);
            }
            GUILayout.Space(6f);
            GUILayout.EndHorizontal();

            GUILayout.Space(6f);
            GUILayout.EndVertical();

            GUILayout.Space(6f);

            if (this.m_Instance == null)
            {
                EditorGUILayout.HelpBox("Please set the sprite packer instance reference in order to use this feature.", MessageType.Info);
            }
            else
            {
                if (GUILayout.Button("Replace"))
                {
                    int replacedCount = 0;

                    switch (this.m_TargetMode)
                    {
                    case TargetMode.CurrentScene:
                    {
                        replacedCount += SPTools.ReplaceReferencesInScene(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly);
                        break;
                    }
                    case TargetMode.ProjectOnly:
                    {
                        replacedCount += SPTools.ReplaceReferencesInProject(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly);
                        break;
                    }
                    case TargetMode.CurrentSceneAndProject:
                    {
                        replacedCount += SPTools.ReplaceReferencesInProject(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly);
                        replacedCount += SPTools.ReplaceReferencesInScene(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly);
                        break;
                    }
                    case TargetMode.AllScenes:
                    {
                        replacedCount += SPTools.ReplaceReferencesInAllScenes(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly, false);
                        break;
                    }
                    case TargetMode.AllScenesAndProject:
                    {
                        replacedCount += SPTools.ReplaceReferencesInProject(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly);
                        replacedCount += SPTools.ReplaceReferencesInScene(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly);
                        EditorApplication.SaveScene();
                        replacedCount += SPTools.ReplaceReferencesInAllScenes(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly, true);
                        break;
                    }
                    }

                    EditorUtility.DisplayDialog("Reference Replacer", "Replaced references count: " + replacedCount.ToString(), "Okay");
                }
            }

            GUILayout.EndVertical();
            GUILayout.Space((float)SPReferenceReplacerWindow.padding.right);
            GUILayout.EndHorizontal();
            GUILayout.Space((float)SPReferenceReplacerWindow.padding.bottom);
            GUILayout.EndVertical();
        }
Ejemplo n.º 32
0
        private Relationship AddRelationship(string location, string relationshipType, string parentLocation, TargetMode mode)
        {
            if (!_relationships.ContainsKey(parentLocation) || _relationships[parentLocation] == null)
            {
                _relationships[parentLocation] = new List <Relationship>();
            }
            else
            {
                foreach (Relationship item in _relationships[parentLocation])
                {
                    if (item.RelatedPart == location)
                    {
                        return(item);
                    }
                }
            }
            Relationship relationship = new Relationship();

            relationship.RelatedPart      = location;
            relationship.RelationshipId   = NextRelationshipId();
            relationship.RelationshipType = relationshipType;
            relationship.Mode             = mode;
            _relationships[parentLocation].Add(relationship);
            Uri targetUri = (relationship.Mode != 0) ? new Uri(relationship.RelatedPart, UriKind.Absolute) : new Uri(Utils.CleanName(relationship.RelatedPart), UriKind.Relative);

            if (parentLocation == "/")
            {
                _package.CreateRelationship(targetUri, relationship.Mode, relationship.RelationshipType, relationship.RelationshipId);
            }
            else
            {
                _package.GetPart(new Uri(Utils.CleanName(parentLocation), UriKind.Relative)).CreateRelationship(targetUri, relationship.Mode, relationship.RelationshipType, relationship.RelationshipId);
            }
            return(relationship);
        }
Ejemplo n.º 33
0
        public static bool ModifyFamily(IBaseWindow baseWin, ref GDMFamilyRecord familyRec, TargetMode targetType, GDMIndividualRecord target)
        {
            bool result;

            try {
                baseWin.Context.BeginUpdate();
                GDMTree tree = baseWin.Context.Tree;

                if (targetType == TargetMode.tmSpouse && target != null)
                {
                    GDMSex sex = target.Sex;
                    if (sex < GDMSex.svMale || sex > GDMSex.svFemale)
                    {
                        AppHost.StdDialogs.ShowError(LangMan.LS(LSID.LSID_IsNotDefinedSex));
                        return(false);
                    }
                }

                using (var dlg = AppHost.ResolveDialog <IFamilyEditDlg>(baseWin)) {
                    bool exists = (familyRec != null);
                    if (!exists)
                    {
                        familyRec = new GDMFamilyRecord(tree);
                        familyRec.InitNew();
                    }

                    try {
                        baseWin.Context.LockRecord(familyRec);

                        dlg.Family = familyRec;
                        dlg.SetTarget(targetType, target);

                        result = (AppHost.Instance.ShowModalX(dlg, false));
                    } finally {
                        baseWin.Context.UnlockRecord(familyRec);
                    }

                    if (!exists)
                    {
                        if (result)
                        {
                            tree.AddRecord(familyRec);
                        }
                        else
                        {
                            familyRec.Clear();
                            familyRec.Dispose();
                            familyRec = null;
                        }
                    }
                }
            } finally {
                baseWin.Context.EndUpdate();
            }

            return(result);
        }
Ejemplo n.º 34
0
 /// <summary>
 /// Set the target mode.
 /// </summary>
 /// <param name="m">The mode to set.</param>
 public void setTargetMode(TargetMode m)
 {
     VertexAnimationTrack_setTargetMode(animationTrack, m);
 }
Ejemplo n.º 35
0
		internal PackageRelationship CreateRelationship (Uri targetUri, TargetMode targetMode, string relationshipType, string id, bool loading)
		{
			if (!loading)
				CheckIsReadOnly ();
			
			Check.TargetUri (targetUri);
			if (targetUri.IsAbsoluteUri && targetMode == TargetMode.Internal)
				throw new ArgumentException ("TargetUri cannot be absolute for an internal relationship");
			
			Check.RelationshipTypeIsValid (relationshipType);
			Check.IdIsValid (id);

			if (id == null)
				id = NextId ();

			PackageRelationship r = new PackageRelationship (id, this, relationshipType, Uri, targetMode, targetUri);

			if (!PartExists (RelationshipUri))
				CreatePartCore (RelationshipUri, RelationshipContentType, CompressionOption.NotCompressed).IsRelationship = true;
			
			Relationships.Add (r.Id, r);
			relationshipsCollection.Relationships.Add (r);

			if (!loading) {
				using (Stream s = GetPart (RelationshipUri).GetStream ())
					WriteRelationships (relationships, s);
			}
			
			return r;
		}
Ejemplo n.º 36
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
            [CosmosDB("vnaaats-net", "flights",
                      ConnectionStringSetting = "DbConnectionString")] IAsyncCollector <object> flights,
            ILogger log)
        {
            try {
                // Deserialise the request
                string callsign      = req.Query["callsign"];
                string ac_type       = req.Query["type"];
                int    assignedLevel = Convert.ToInt32(req.Query["level"]);
                int    assignedMach  = Convert.ToInt32(req.Query["mach"]);
                string track         = req.Query["track"];
                string route         = req.Query["route"];
                string routeEtas     = req.Query["routeEtas"];
                string departure     = req.Query["departure"];
                string arrival       = req.Query["arrival"];
                bool   direction     = req.Query["direction"] == "1" ? true : false;
                string etd           = req.Query["etd"];
                string selcal        = req.Query["selcal"];
                bool   datalink      = req.Query["connected_datalink"] == "1" ? true : false;
                if (string.IsNullOrWhiteSpace(req.Query["connectedDatalink"]))
                {
                    datalink = false;
                }
                else
                {
                    datalink = req.Query["datalink"] == "1" ? true : false;
                }
                bool   isEquipped = req.Query["isEquipped"] == "1" ? true : false;
                string state      = req.Query["state"];

                bool       relevant   = req.Query["relevant"] == "1" ? true : false;
                TargetMode targetMode = (TargetMode)Convert.ToInt32(req.Query["targetMode"]);
                string     trackedBy  = req.Query["trackedBy"];
                string     trackedId  = req.Query["trackedById"];

                // Create data object
                FlightData fdata = new FlightData
                {
                    callsign          = callsign,
                    type              = ac_type,
                    etd               = etd,
                    assignedLevel     = assignedLevel,
                    assignedMach      = assignedMach,
                    track             = track,
                    route             = route,
                    routeEtas         = routeEtas,
                    departure         = departure,
                    arrival           = arrival,
                    direction         = direction,
                    selcal            = selcal,
                    datalinkConnected = datalink,
                    isEquipped        = isEquipped,
                    state             = state,
                    relevant          = relevant,
                    targetMode        = targetMode,
                    trackedBy         = trackedBy,
                    trackedById       = trackedId,
                    lastUpdated       = DateTime.UtcNow
                };

                // Add data object
                await flights.AddAsync(fdata);

                // Log and return success code
                log.LogInformation($"Item {fdata.callsign} inserted successfully.");
                return(new StatusCodeResult(StatusCodes.Status200OK));
            }
            catch (Exception ex)
            {
                // Catch any errors
                log.LogError($"Could not insert flight data. Exception thrown: {ex.Message}.");
                return(new StatusCodeResult(StatusCodes.Status500InternalServerError));
            }
        }
Ejemplo n.º 37
0
		public PackageRelationship CreateRelationship (Uri targetUri, TargetMode targetMode, string relationshipType, string id)
		{
			return CreateRelationship (targetUri, targetMode, relationshipType, id, false);
		}
Ejemplo n.º 38
0
 public void SetDirection(Vector2 direction)
 {
     m_direction = direction;
     m_mode      = TargetMode.DIRECTION;
 }
Ejemplo n.º 39
0
 public Relationship()
 {
     this._targetMode = TargetMode.Internal;
 }
Ejemplo n.º 40
0
 public static void SetTarget(WoWUnit target, TargetMode targetMode)
 {
     if ( target == null || ActiveTarget == target ) return;
     ActiveTargetMode = targetMode;
     ActiveTarget = target;
 }
Ejemplo n.º 41
0
 /**
  * Add a relationship to a part (except relationships part).
  * 
  * @param targetURI
  *            URI the target part. Must be relative to the source root
  *            directory of the part.
  * @param targetMode
  *            Mode [Internal|External].
  * @param relationshipType
  *            Type of relationship.
  * @return The newly created and added relationship
  * @see org.apache.poi.OpenXml4Net.opc.RelationshipSource#AddRelationship(org.apache.poi.OpenXml4Net.opc.PackagePartName,
  *      org.apache.poi.OpenXml4Net.opc.TargetMode, java.lang.String)
  */
 public PackageRelationship AddRelationship(Uri targetURI,
         TargetMode targetMode, String relationshipType)
 {
     return AddRelationship(targetURI, targetMode, relationshipType, null);
 }
Ejemplo n.º 42
0
 public void SetTarget(TargetMode mode, GDMIndividualRecord target, GDMSex needSex)
 {
     fController.SetTarget(mode, target, needSex);
 }
Ejemplo n.º 43
0
        public static GDMRecord AddRecord(IBaseWindow baseWin, GDMRecordType rt, Target target)
        {
            bool      result = false;
            GDMRecord rec    = null;

            switch (rt)
            {
            case GDMRecordType.rtIndividual:
            {
                // FIXME: legacy code, checkit
                if (target == null)
                {
                    target            = new Target();
                    target.TargetMode = TargetMode.tmParent;
                }

                GDMIndividualRecord indivRec = null;
                result = ModifyIndividual(baseWin, ref indivRec, target.TargetIndividual, target.TargetMode, target.NeedSex);
                rec    = indivRec;
                break;
            }

            case GDMRecordType.rtFamily:
            {
                if (target == null)
                {
                    target = new Target();
                }

                TargetMode famTarget = (target.TargetMode != TargetMode.tmFamilyChild) ? TargetMode.tmNone : target.TargetMode;

                GDMFamilyRecord fam = null;
                result = ModifyFamily(baseWin, ref fam, famTarget, target.TargetIndividual);
                rec    = fam;
                break;
            }

            case GDMRecordType.rtNote:
            {
                GDMNoteRecord note = null;
                result = ModifyNote(baseWin, ref note);
                rec    = note;
                break;
            }

            case GDMRecordType.rtMultimedia:
            {
                GDMMultimediaRecord mmRec = null;
                result = ModifyMedia(baseWin, ref mmRec);
                rec    = mmRec;
                break;
            }

            case GDMRecordType.rtSource:
            {
                GDMSourceRecord src = null;
                result = ModifySource(baseWin, ref src);
                rec    = src;
                break;
            }

            case GDMRecordType.rtRepository:
            {
                GDMRepositoryRecord rep = null;
                result = ModifyRepository(baseWin, ref rep);
                rec    = rep;
                break;
            }

            case GDMRecordType.rtGroup:
            {
                GDMGroupRecord grp = null;
                result = ModifyGroup(baseWin, ref grp);
                rec    = grp;
                break;
            }

            case GDMRecordType.rtResearch:
            {
                GDMResearchRecord rsr = null;
                result = ModifyResearch(baseWin, ref rsr);
                rec    = rsr;
                break;
            }

            case GDMRecordType.rtTask:
            {
                GDMTaskRecord tsk = null;
                result = ModifyTask(baseWin, ref tsk);
                rec    = tsk;
                break;
            }

            case GDMRecordType.rtCommunication:
            {
                GDMCommunicationRecord comm = null;
                result = ModifyCommunication(baseWin, ref comm);
                rec    = comm;
                break;
            }

            case GDMRecordType.rtLocation:
            {
                GDMLocationRecord loc = null;
                result = ModifyLocation(baseWin, ref loc);
                rec    = loc;
                break;
            }
            }

            return((result) ? rec : null);
        }
Ejemplo n.º 44
0
 public void SetTarget(TargetMode targetType, GDMIndividualRecord target)
 {
     fController.SetTarget(targetType, target);
 }
Ejemplo n.º 45
0
 /**
  * Add a relationship to a part (except relationships part).
  * 
  * @param targetPartName
  *            Name of the target part. This one must be relative to the
  *            source root directory of the part.
  * @param targetMode
  *            Mode [Internal|External].
  * @param relationshipType
  *            Type of relationship.
  * @return The newly created and added relationship
  * @see org.apache.poi.OpenXml4Net.opc.RelationshipSource#AddRelationship(org.apache.poi.OpenXml4Net.opc.PackagePartName,
  *      org.apache.poi.OpenXml4Net.opc.TargetMode, java.lang.String)
  */
 public PackageRelationship AddRelationship(PackagePartName targetPartName,
         TargetMode targetMode, String relationshipType)
 {
     return AddRelationship(targetPartName, targetMode, relationshipType,
             null);
 }
Ejemplo n.º 46
0
        /// <summary>
        /// Add new relationship to the Collection
        /// </summary>
        /// <param name="targetUri">target</param>
        /// <param name="targetMode">Enumeration indicating the base uri for the target uri</param>
        /// <param name="relationshipType">relationship type that uniquely defines the role of the relationship</param>
        /// <param name="id">String that conforms to the xsd:ID datatype. Unique across the source's relationships.
        /// Null OK (ID will be generated).</param>
        /// <param name="parsing">Indicates whether the add call is made while parsing existing relationships
        /// from a relationship part, or we are adding a new relationship</param>
        private PackageRelationship Add(Uri targetUri, TargetMode targetMode, string relationshipType, string id, bool parsing)
        {
            if (targetUri == null)
            {
                throw new ArgumentNullException(nameof(targetUri));
            }

            if (relationshipType == null)
            {
                throw new ArgumentNullException(nameof(relationshipType));
            }

            ThrowIfInvalidRelationshipType(relationshipType);

            //Verify if the Enum value is valid
            if (targetMode < TargetMode.Internal || targetMode > TargetMode.External)
            {
                throw new ArgumentOutOfRangeException(nameof(targetMode));
            }

            // don't accept absolute Uri's if targetMode is Internal.
            if (targetMode == TargetMode.Internal && targetUri.IsAbsoluteUri)
            {
                throw new ArgumentException(SR.RelationshipTargetMustBeRelative, nameof(targetUri));
            }

            // don't allow relationships to relationships
            //  This check should be made for following cases
            //      1. Uri is absolute and it is pack Uri
            //      2. Uri is NOT absolute and its target mode is internal (or NOT external)
            //      Note: if the target is absolute uri and its not a pack scheme then we cannot determine if it is a rels part
            //      Note: if the target is relative uri and target mode is external, we cannot determine if it is a rels part
            if ((!targetUri.IsAbsoluteUri && targetMode != TargetMode.External) ||
                (targetUri.IsAbsoluteUri && targetUri.Scheme == PackUriHelper.UriSchemePack))
            {
                Uri resolvedUri = GetResolvedTargetUri(targetUri, targetMode);
                //GetResolvedTargetUri returns a null if the target mode is external and the
                //target Uri is a packUri with no "part" component, so in that case we know that
                //its not a relationship part.
                if (resolvedUri != null)
                {
                    if (PackUriHelper.IsRelationshipPartUri(resolvedUri))
                    {
                        throw new ArgumentException(SR.RelationshipToRelationshipIllegal, nameof(targetUri));
                    }
                }
            }

            // Generate an ID if id is null. Throw exception if neither null nor a valid unique xsd:ID.
            if (id == null)
            {
                id = GenerateUniqueRelationshipId();
            }
            else
            {
                ValidateUniqueRelationshipId(id);
            }

            //Ensure the relationship part
            EnsureRelationshipPart();

            // create and add
            PackageRelationship relationship = new PackageRelationship(_package, _sourcePart, targetUri, targetMode, relationshipType, id);

            _relationships.Add(relationship);

            //If we are adding relationships as a part of Parsing the underlying relationship part, we should not set
            //the dirty flag to false.
            _dirty = !parsing;

            return(relationship);
        }
Ejemplo n.º 47
0
        /**
         * Add a relationship to a part (except relationships part).
         * <p>
         * Check rule M1.25: The Relationships part shall not have relationships to
         * any other part. Package implementers shall enforce this requirement upon
         * the attempt to create such a relationship and shall treat any such
         * relationship as invalid.
         * </p>
         * @param targetURI
         *            URI of the target part. Must be relative to the source root
         *            directory of the part.
         * @param targetMode
         *            Mode [Internal|External].
         * @param relationshipType
         *            Type of relationship.
         * @param id
         *            Relationship unique id.
         * @return The newly created and added relationship
         * 
         * @throws InvalidFormatException
         *             If the URI point to a relationship part URI.
         * @see org.apache.poi.OpenXml4Net.opc.RelationshipSource#AddRelationship(org.apache.poi.OpenXml4Net.opc.PackagePartName,
         *      org.apache.poi.OpenXml4Net.opc.TargetMode, java.lang.String, java.lang.String)
         */
        public PackageRelationship AddRelationship(Uri targetURI,
                TargetMode targetMode, String relationshipType, String id)
        {
            container.ThrowExceptionIfReadOnly();

            if (targetURI == null)
            {
                throw new ArgumentException("targetPartName");
            }
            //if (targetMode == null)
            //{
            //    throw new ArgumentException("targetMode");
            //}
            if (relationshipType == null)
            {
                throw new ArgumentException("relationshipType");
            }

            // Try to retrieve the target part

            if (this.IsRelationshipPart
                    || PackagingUriHelper.IsRelationshipPartURI(targetURI))
            {
                throw new InvalidOperationException(
                        "Rule M1.25: The Relationships part shall not have relationships to any other part.");
            }

            if (relationships == null)
            {
                relationships = new PackageRelationshipCollection();
            }

            return relationships.AddRelationship(targetURI,
                    targetMode, relationshipType, id);
        }
Ejemplo n.º 48
0
 /// <summary>
 /// Add new relationship
 /// </summary>
 /// <param name="targetUri">target</param>
 /// <param name="targetMode">Enumeration indicating the base uri for the target uri</param>
 /// <param name="relationshipType">relationship type that uniquely defines the role of the relationship</param>
 /// <param name="id">String that conforms to the xsd:ID datatype. Unique across the source's relationships.
 /// Null OK (ID will be generated).</param>
 internal PackageRelationship Add(Uri targetUri, TargetMode targetMode, string relationshipType, string id)
 {
     return(Add(targetUri, targetMode, relationshipType, id, parsing: false));
 }
Ejemplo n.º 49
0
 /// <summary>
 /// Adds a relationship to this PackagePart with the Target PackagePart specified as the Uri
 /// Initial and trailing spaces in the name of the PackageRelationship are trimmed.
 /// </summary>
 /// <param name="targetUri"></param>
 /// <param name="targetMode">Enumeration indicating the base uri for the target uri</param>
 /// <param name="relationshipType">PackageRelationship type, having uri like syntax that is used to 
 /// uniquely identify the role of the relationship</param>
 /// <param name="id">String that conforms to the xsd:ID datatype. Unique across the source's
 /// relationships. Null is OK (ID will be generated). An empty string is an invalid XML ID.</param>
 /// <returns></returns>
 /// <exception cref="InvalidOperationException">If this part has been deleted</exception>
 /// <exception cref="InvalidOperationException">If the parent package has been closed or disposed</exception>
 /// <exception cref="IOException">If the package is readonly, it cannot be modified</exception>
 /// <exception cref="ArgumentNullException">If parameter "targetUri" is null</exception>
 /// <exception cref="ArgumentNullException">If parameter "relationshipType" is null</exception>
 /// <exception cref="ArgumentOutOfRangeException">If parameter "targetMode" enumeration does not have a valid value</exception>
 /// <exception cref="ArgumentException">If TargetMode is TargetMode.Internal and the targetUri is an absolute Uri </exception>
 /// <exception cref="ArgumentException">If relationship is being targeted to a relationship part</exception>
 /// <exception cref="System.Xml.XmlException">If parameter "id" is not a valid Xsd Id</exception>
 /// <exception cref="System.Xml.XmlException">If an id is provided in the method, and its not unique</exception>
 public PackageRelationship CreateRelationship(Uri targetUri, TargetMode targetMode, string relationshipType, String id)
 {
     CheckInvalidState();
     _container.ThrowIfReadOnly();
     EnsureRelationships();
     //All parameter validation is done in the following method
     return _relationships.Add(targetUri, targetMode, relationshipType, id);
 }
Ejemplo n.º 50
0
        public void CleanProject(TargetMode target)
        {
            MainForm mainForm = FindForm() as MainForm;
            if (mainForm == null || mainForm.SettingsModel == null || mainForm.ProjectModel == null)
                return;

            if (m_runningProcess != null && !m_runningProcess.HasExited)
            {
                MetroMessageBox.Show(mainForm, "Cannot clean " + target.ToString() + " " + " because another operation is running!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string path = Path.Combine(Path.GetFullPath(mainForm.ProjectModel.WorkingDirectory), "bin", target.ToString());
            if (Directory.Exists(path))
            {
                Directory.Delete(path, true);
                MetroMessageBox.Show(mainForm, target.ToString() + " build cleaned!", "Operation Complete!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
                MetroMessageBox.Show(mainForm, target.ToString() + " build does not exists!", "Operation Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
Ejemplo n.º 51
0
 /// <summary>
 /// Creates a relationship at the Package level with the Target PackagePart specified as the Uri
 /// </summary>
 /// <param name="targetUri">Target's URI</param>
 /// <param name="targetMode">Enumeration indicating the base uri for the target uri</param>
 /// <param name="relationshipType">PackageRelationship type, having uri like syntax that is used to
 /// uniquely identify the role of the relationship</param>
 /// <returns></returns>
 /// <exception cref="ObjectDisposedException">If this Package object has been disposed</exception>
 /// <exception cref="IOException">If the package is readonly, it cannot be modified</exception>
 /// <exception cref="ArgumentNullException">If parameter "targetUri" is null</exception>
 /// <exception cref="ArgumentNullException">If parameter "relationshipType" is null</exception>
 /// <exception cref="ArgumentOutOfRangeException">If parameter "targetMode" enumeration does not have a valid value</exception>
 /// <exception cref="ArgumentException">If TargetMode is TargetMode.Internal and the targetUri is an absolute Uri </exception>
 /// <exception cref="ArgumentException">If relationship is being targeted to a relationship part</exception>
 public PackageRelationship CreateRelationship(Uri targetUri, TargetMode targetMode, string relationshipType)
 {
     return CreateRelationship(targetUri, targetMode, relationshipType, null);
 }
Ejemplo n.º 52
0
        public void RunProject(TargetMode target)
        {
            MainForm mainForm = FindForm() as MainForm;
            if (mainForm == null || mainForm.SettingsModel == null)
                return;

            Process.Start("http://localhost:" + mainForm.SettingsModel.RunnerHttpServerPort.ToString() + '/' + target.ToString());
        }
Ejemplo n.º 53
0
		/// <summary>
		/// Broadcasts SetCombatTarget in range of creature.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="targetEntityId"></param>
		/// <param name="mode"></param>
		public static void SetCombatTarget(Creature creature, long targetEntityId, TargetMode mode)
		{
			var packet = new Packet(Op.SetCombatTarget, creature.EntityId);
			packet.PutLong(targetEntityId);
			packet.PutByte((byte)mode);
			packet.PutString("");

			creature.Region.Broadcast(packet, creature);
		}
Ejemplo n.º 54
0
 /**
  * Add a relationship to a part (except relationships part).
  *
  * @param targetPartName
  *            Name of the target part. This one must be relative to the
  *            source root directory of the part.
  * @param targetMode
  *            Mode [Internal|External].
  * @param relationshipType
  *            Type of relationship.
  * @return The newly created and added relationship
  * @see org.apache.poi.OpenXml4Net.opc.RelationshipSource#AddRelationship(org.apache.poi.OpenXml4Net.opc.PackagePartName,
  *      org.apache.poi.OpenXml4Net.opc.TargetMode, java.lang.String)
  */
 public PackageRelationship AddRelationship(PackagePartName targetPartName,
                                            TargetMode targetMode, String relationshipType)
 {
     return(AddRelationship(targetPartName, targetMode, relationshipType,
                            null));
 }