/// <summary>
        /// Set the relative crop coordinates of the specified source item
        /// </summary>
        /// <param name="sceneItemName">Name of the scene item</param>
        /// <param name="cropInfo">Crop coordinates</param>
        /// <param name="sceneName">(optional) parent scene name of the specified source</param>
        public void SetSceneItemCrop(string sceneItemName,
                                     SceneItemCropInfo cropInfo, string sceneName = null)
        {
            var requestFields = new JObject();

            if (sceneName != null)
            {
                requestFields.Add("scene-name");
            }

            requestFields.Add("item", sceneItemName);
            requestFields.Add("top", cropInfo.Top);
            requestFields.Add("bottom", cropInfo.Bottom);
            requestFields.Add("left", cropInfo.Left);
            requestFields.Add("right", cropInfo.Right);

            SyncRequest("SetSceneItemCrop", requestFields);
        }
Exemple #2
0
        public SceneItemProperty(JObject data)
        {
            SceneName  = (string)data["scene-name"];
            SourceName = (string)data["name"];
            Rotation   = (float)data["rotation"];
            Position   = new SceneItemPropertyPosition
            {
                X         = (float)data["position"]["x"],
                Y         = (float)data["position"]["y"],
                Alignment = (int)data["position"]["alignment"],
                Type      = SceneItemPropertyPType.SET
            };

            Scale = new SceneItemPropertyPosition
            {
                X         = (float)data["scale"]["x"],
                Y         = (float)data["scale"]["y"],
                Alignment = 0,
                Type      = SceneItemPropertyPType.SET
            };

            Crop = new SceneItemCropInfo();
            if (data["crop"] != null)
            {
                Crop.Top    = (int)data["crop"]["top"];
                Crop.Bottom = (int)data["crop"]["bottom"];
                Crop.Right  = (int)data["crop"]["right"];
                Crop.Left   = (int)data["crop"]["left"];
            }

            Bounds = new SceneItemPropertyPosition();
            if ((string)data["bounds"]["type"] == "OBS_BOUNDS_NONE")
            {
                Bounds.Type = SceneItemPropertyPType.NONE;
            }
            else
            {
                Bounds.X         = (float)data["bounds"]["x"];
                Bounds.Y         = (float)data["bounds"]["y"];
                Bounds.Alignment = (int)data["bounds"]["alignment"];
            }
            Status  = (string)data["status"];
            Visible = (bool)data["visible"];
        }
 /// <summary>
 /// Set the relative crop coordinates of the specified source item
 /// </summary>
 /// <param name="sceneItem">Scene item object</param>
 /// <param name="cropInfo">Crop coordinates</param>
 /// <param name="scene">Parent scene of scene item</param>
 public void SetSceneItemCrop(SceneItem sceneItem,
                              SceneItemCropInfo cropInfo, OBSScene scene)
 {
     SetSceneItemCrop(sceneItem.SourceName, cropInfo, scene.Name);
 }