Exemple #1
0
        /// <summary>
        /// Executes a chosen image editor from a Trigger to open the last set of screenshots taken with the image editor.
        /// </summary>
        /// <param name="editor">The image editor to execute.</param>
        /// <param name="triggerActionType">The trigger's action type.</param>
        private void RunEditor(Editor editor, TriggerActionType triggerActionType)
        {
            if (editor != null && triggerActionType == TriggerActionType.RunEditor)
            {
                // Assume we're going to be passing in the path of the screenshot image to the program.
                if (editor.Arguments != null && editor.Arguments.Contains("%filepath%"))
                {
                    DateTime dt = _screenCapture.DateTimeScreenshotsTaken;

                    foreach (Screenshot screenshot in _screenshotCollection.GetScreenshots(dt.ToString(_macroParser.DateFormat), dt.ToString(_macroParser.TimeFormat)))
                    {
                        if (screenshot != null && screenshot.Slide != null && !string.IsNullOrEmpty(screenshot.Path))
                        {
                            _log.WriteDebugMessage("Running editor (based on TriggerActionType.RunEditor) \"" + editor.Name + "\" using screenshot path \"" + screenshot.Path + "\"");

                            if (!RunEditor(editor, screenshot))
                            {
                                _log.WriteDebugMessage("Running editor failed. Perhaps the filepath of the screenshot file is no longer available");
                            }
                        }
                    }
                }
                else
                {
                    // Just run the program without passing in the path of the screenshot.
                    if (!RunEditor(editor))
                    {
                        _log.WriteDebugMessage("Running editor failed.");
                    }
                }
            }
        }
Exemple #2
0
        public TriggerBuilder Before(TriggerActionType type)
        {
            _trigger.EventType  = SQLiteTriggerEventType.Before;
            _trigger.ActionType = type;

            return(this);
        }
Exemple #3
0
        public void HandleInput(TriggerActionType type, params object[] inputs)
        {
            if (TriggerActions.Last().Triggered)
            {
                return;
            }

            foreach (var trigger in TriggerActions)
            {
                if (trigger.Triggered)
                {
                    continue;
                }

                trigger.HandleInput(type, inputs);
                break;
            }

            if (TriggerActions.Last().Triggered)
            {
                if (FinalAction != null)
                {
                    FinalAction();
                }
                Reset();
            }
        }
Exemple #4
0
        protected override bool CheckIfTriggered(TriggerActionType type, params object[] inputs)
        {
            if (inputs == null || inputs.Length == 0)
            {
                return(false);
            }

            var packet = inputs[0] as Packet;

            if (packet == null)
            {
                return(false);
            }

            if (packet.Header.Command != Opcode)
            {
                return(false);
            }

            if (PacketChecker != null)
            {
                return(PacketChecker(packet));
            }
            else
            {
                return(true);
            }
        }
Exemple #5
0
        public TriggerBuilder After(TriggerActionType type)
        {
            _trigger.EventType  = SQLiteTriggerEventType.After;
            _trigger.ActionType = type;

            return(this);
        }
        private void EmailScreenshot(TriggerActionType triggerActionType)
        {
            if (triggerActionType == TriggerActionType.EmailScreenshot && _screenCapture.Running)
            {
                Screenshot lastScreenshotOfThisView = _screenshotCollection.GetLastScreenshotOfView(_screenshotCollection.LastViewId);

                if (lastScreenshotOfThisView != null && lastScreenshotOfThisView.Slide != null && !string.IsNullOrEmpty(lastScreenshotOfThisView.Path))
                {
                    if (_screenshotCollection.OptimizeScreenCapture)
                    {
                        if (!string.IsNullOrEmpty(lastScreenshotOfThisView.Hash) && !_screenshotCollection.EmailedScreenshotHashList.Contains(lastScreenshotOfThisView.Hash))
                        {
                            if (EmailScreenshot(lastScreenshotOfThisView, prompt: false))
                            {
                                _screenshotCollection.EmailedScreenshotHashList.Add(lastScreenshotOfThisView.Hash);
                            }
                        }
                    }
                    else
                    {
                        EmailScreenshot(lastScreenshotOfThisView, prompt: false);
                    }
                }
            }
        }
Exemple #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="name"></param>
 /// <param name="conditionType"></param>
 /// <param name="actionType"></param>
 /// <param name="editor"></param>
 public Trigger(string name, TriggerConditionType conditionType, TriggerActionType actionType, string editor)
 {
     Name          = name;
     ConditionType = conditionType;
     ActionType    = actionType;
     Editor        = editor;
 }
Exemple #8
0
        protected override bool CheckIfTriggered(TriggerActionType type, params object[] inputs)
        {
            if (Checker == null)
            {
                return(false);
            }

            return(Checker(inputs));
        }
Exemple #9
0
        public void OnLoad(ConfigNode node, VesselTriggers triggerConfig)
        {
            bool              dataFound  = false;
            ConfigNode        childNode  = null;
            int               nbItem     = 0;
            TriggerActionType actionType = (TriggerActionType)(-1);

            dataFound = node.TryGetValue(KEY_NB_ACTIONS, ref nbItem);
            if (dataFound)
            {
                for (int i = 0; i < nbItem; i++)
                {
                    TriggerAction action = null;
                    dataFound = node.TryGetNode(KEY_PREF_ACTION + i, ref childNode);
                    if (dataFound)
                    {
                        dataFound = childNode.TryGetEnum <TriggerActionType>("type", ref actionType, (TriggerActionType)(-1));
                        if (dataFound)
                        {
                            switch (actionType)
                            {
                            case TriggerActionType.Part:
                                action = new TriggerActionPart(triggerConfig);
                                break;

                            case TriggerActionType.Flight:
                                action = new TriggerActionFlight(triggerConfig);
                                break;

                            case TriggerActionType.Message:
                                action = new TriggerActionMessage(triggerConfig);
                                break;

                            case TriggerActionType.Timer:
                                action = new TriggerActionTimer(triggerConfig);
                                break;

                            default:
                                break;
                            }
                            if (action != null)
                            {
                                dataFound = ConfigNode.LoadObjectFromConfig(action, childNode);
                                if (dataFound)
                                {
                                    _actions.Add(action);
                                }
                            }
                        }
                    }
                }
            }
        }
        private void FileTransferScreenshot(TriggerActionType triggerActionType)
        {
            if (triggerActionType == TriggerActionType.FileTransferScreenshot && _screenCapture.Running)
            {
                Screenshot lastScreenshotOfThisView = _screenshotCollection.GetLastScreenshotOfView(_screenshotCollection.LastViewId);

                if (lastScreenshotOfThisView != null && lastScreenshotOfThisView.Slide != null && !string.IsNullOrEmpty(lastScreenshotOfThisView.Path))
                {
                    FileTransferScreenshot(lastScreenshotOfThisView);
                }
            }
        }
Exemple #11
0
        private void EmailScreenshot(TriggerActionType triggerActionType)
        {
            if (triggerActionType == TriggerActionType.EmailScreenshot && _screenCapture.Running)
            {
                Screenshot screenshot = _screenshotCollection.Get(_screenshotCollection.Count - 1);

                if (screenshot != null && screenshot.Slide != null && !string.IsNullOrEmpty(screenshot.Path))
                {
                    EmailScreenshot(screenshot, prompt: false);
                }
            }
        }
Exemple #12
0
        public void HandleInput(TriggerActionType type, params object[] inputs)
        {
            if (type != Type)
            {
                return;
            }

            if (CheckIfTriggered(type, inputs))
            {
                Triggered = true;
                if (IntermediateAction != null)
                {
                    IntermediateAction();
                }
            }
        }
        private string GetTriggerActionString(TriggerActionType type)
        {
            switch (type)
            {
            case TriggerActionType.Update:
                return("UPDATE");

            case TriggerActionType.Insert:
                return("INSERT");

            case TriggerActionType.Delete:
                return("DELETE");

            default:
                throw new NotImplementedException();
            }
        }
        /// <summary>
        /// Executes a chosen image editor from a Trigger to open the last set of screenshots taken with the image editor.
        /// </summary>
        /// <param name="editor">The image editor to execute.</param>
        /// <param name="triggerActionType">The trigger's action type.</param>
        private void RunEditor(Editor editor, TriggerActionType triggerActionType)
        {
            if (editor != null && triggerActionType == TriggerActionType.RunEditor)
            {
                DateTime dt = _screenCapture.DateTimeScreenshotsTaken;

                foreach (Screenshot screenshot in _screenshotCollection.GetScreenshots(dt.ToString(MacroParser.DateFormat), dt.ToString(MacroParser.TimeFormat)))
                {
                    if (screenshot != null && screenshot.Slide != null && !string.IsNullOrEmpty(screenshot.Path))
                    {
                        Log.WriteDebugMessage("Running editor (based on TriggerActionType.RunEditor) \"" + editor.Name + "\" using screenshot path \"" + screenshot.Path + "\"");

                        RunEditor(editor, screenshot);
                    }
                }
            }
        }
Exemple #15
0
        public void HandleInput(TriggerActionType type, params object[] inputs)
        {
            if (TriggerActions.Last().Triggered)
                return;

            foreach (var trigger in TriggerActions)
            {
                if (trigger.Triggered)
                    continue;

                trigger.HandleInput(type, inputs);
                break;
            }

            if (TriggerActions.Last().Triggered)
            {
                if (FinalAction != null)
                    FinalAction();
                Reset();
            }
        }
Exemple #16
0
        protected override bool CheckIfTriggered(TriggerActionType type, params object[] inputs)
        {
            if (inputs == null || inputs.Length == 0 || inputs[0] == null || inputs[0].GetType() != typeof(UpdateFieldEventArg))
            {
                return(false);
            }

            var updateFieldArgs = (UpdateFieldEventArg)inputs[0];

            if (updateFieldArgs.Index != Index)
            {
                return(false);
            }

            if (updateFieldArgs.NewValue != Value)
            {
                return(false);
            }

            return(true);
        }
Exemple #17
0
 public AlwaysTrueTriggerAction(TriggerActionType Type, Action IntermediateAction = null)
     : base(Type, IntermediateAction)
 { }
Exemple #18
0
        protected override bool CheckIfTriggered(TriggerActionType type, params object[] inputs)
        {
            if (Checker == null)
                return false;

            return Checker(inputs);
        }
Exemple #19
0
 public CustomTriggerAction(TriggerActionType Type, Func<object[], bool> Checker, Action IntermediateAction = null)
     : base(Type, IntermediateAction)
 {
     this.Checker = Checker;
 }
Exemple #20
0
 public void HandleTriggerInput(TriggerActionType type, params object[] inputs)
 {
     Triggers.ForEach(trigger => trigger.HandleInput(type, inputs));
 }
Exemple #21
0
        public void HandleInput(TriggerActionType type, params object[] inputs)
        {
            if (type != Type)
                return;

            if (CheckIfTriggered(type, inputs))
            {
                Triggered = true;
                if (IntermediateAction != null)
                    IntermediateAction();
            }
        }
        // Draw the property inside the given rect
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            AddSeparator();
            float defaultWidth = EditorGUIUtility.labelWidth;

            // Using BeginProperty / EndProperty on the parent property means that
            // prefab override logic works on the entire property.
            EditorGUI.BeginProperty(position, label, property);

            SerializedProperty actionTiming = property.FindPropertyRelative("actionTiming");
            SerializedProperty action       = property.FindPropertyRelative("action");

            SerializedProperty objectsToEnable  = property.FindPropertyRelative("objectsToEnable");
            SerializedProperty objectsToDisable = property.FindPropertyRelative("objectsToDisable");

            SerializedProperty scriptsToEnable  = property.FindPropertyRelative("scriptsToEnable");
            SerializedProperty scriptsToDisable = property.FindPropertyRelative("scriptsToDisable");

            SerializedProperty levelForward  = property.FindPropertyRelative("levelForward");
            SerializedProperty levelBackward = property.FindPropertyRelative("levelBackward");

            SerializedProperty forwardSameScenePillar  = property.FindPropertyRelative("forwardSameScenePillar");
            SerializedProperty backwardSameScenePillar = property.FindPropertyRelative("backwardSameScenePillar");
            SerializedProperty forwardPillar           = property.FindPropertyRelative("forwardPillar");
            SerializedProperty backwardPillar          = property.FindPropertyRelative("backwardPillar");
            SerializedProperty forwardPillarLevel      = property.FindPropertyRelative("forwardPillarLevel");
            SerializedProperty forwardPillarName       = property.FindPropertyRelative("forwardPillarName");
            SerializedProperty backwardPillarLevel     = property.FindPropertyRelative("backwardPillarLevel");
            SerializedProperty backwardPillarName      = property.FindPropertyRelative("backwardPillarName");

            SerializedProperty powerTrail   = property.FindPropertyRelative("powerTrail");
            SerializedProperty setPowerIsOn = property.FindPropertyRelative("setPowerIsOn");

            SerializedProperty dimensionObjects = property.FindPropertyRelative("dimensionObjects");
            SerializedProperty visibilityState  = property.FindPropertyRelative("visibilityState");

            SerializedProperty flythroughCameraLevel = property.FindPropertyRelative("flythroughCameraLevel");

            GUIContent scriptsToEnableLabel         = new GUIContent("Scripts to Enable:");
            GUIContent scriptsToDisableLabel        = new GUIContent("Scripts to Disable:");
            GUIContent objectsToEnableLabel         = new GUIContent("Objects to Enable:");
            GUIContent objectsToDisableLabel        = new GUIContent("Objects to Disable:");
            GUIContent forwardLevelLabel            = new GUIContent("Forward Level:");
            GUIContent backwardLevelLabel           = new GUIContent("Backward Level:");
            GUIContent forwardSameScenePillarLabel  = new GUIContent("Forward Pillar is in same scene?");
            GUIContent backwardSameScenePillarLabel = new GUIContent("Backward Pillar is in same scene?");
            GUIContent forwardPillarLabel           = new GUIContent("Forward Pillar:");
            GUIContent backwardPillarLabel          = new GUIContent("Backward Pillar:");
            GUIContent levelOfPillarLabel           = new GUIContent("Level of Pillar:");
            GUIContent nameOfPillarLabel            = new GUIContent("Name of Pillar:");
            GUIContent powerTrailLabel       = new GUIContent("Power trail:");
            GUIContent setPowerIsOnLabel     = new GUIContent("Power On/Off:");
            GUIContent dimensionObjectsLabel = new GUIContent("Dimension Objects:");
            GUIContent visibilityStateLabel  = new GUIContent("Visibility State:");
            GUIContent flythroughCameraLabel = new GUIContent("Flythrough Camera Level:");

            EditorGUILayout.PropertyField(action);
            EditorGUILayout.PropertyField(actionTiming);

            TriggerActionType currentAction =
                (TriggerActionType)Enum.GetValues(typeof(TriggerActionType)).GetValue(action.enumValueIndex);

            EditorGUILayout.Space();

            switch (currentAction)
            {
            case TriggerActionType.DisableSelfScript:
            case TriggerActionType.DisableSelfGameObject:
                break;

            case TriggerActionType.ToggleScripts:
            case TriggerActionType.EnableDisableScripts:
                EditorGUILayout.PropertyField(scriptsToEnable, scriptsToEnableLabel, true);
                EditorGUILayout.PropertyField(scriptsToDisable, scriptsToDisableLabel, true);
                break;

            case TriggerActionType.ToggleGameObjects:
            case TriggerActionType.EnableDisableGameObjects:
                EditorGUILayout.PropertyField(objectsToEnable, objectsToEnableLabel, true);
                EditorGUILayout.PropertyField(objectsToDisable, objectsToDisableLabel, true);
                break;

            case TriggerActionType.ChangeLevel:
                EditorGUILayout.PropertyField(levelForward, forwardLevelLabel);
                EditorGUILayout.PropertyField(levelBackward, backwardLevelLabel);
                break;

            case TriggerActionType.PowerOrDepowerPowerTrail:
                EditorGUILayout.PropertyField(powerTrail, powerTrailLabel);
                EditorGUILayout.PropertyField(setPowerIsOn, setPowerIsOnLabel);
                break;

            case TriggerActionType.ChangeVisibilityState:
                EditorGUILayout.PropertyField(dimensionObjects, dimensionObjectsLabel);
                EditorGUILayout.PropertyField(visibilityState, visibilityStateLabel);
                break;

            case TriggerActionType.PlayCameraFlythrough:
                EditorGUILayout.PropertyField(flythroughCameraLevel, flythroughCameraLabel);
                break;

            default:
                break;
            }

            EditorGUI.EndProperty();

            EditorGUILayout.Space();
        }
Exemple #23
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="type"></param>
 /// <param name="description"></param>
 public TriggerAction(TriggerActionType type, string description)
 {
     Type        = type;
     Description = description;
 }
Exemple #24
0
 public CustomTriggerAction(TriggerActionType Type, Func <object[], bool> Checker, Action IntermediateAction = null)
     : base(Type, IntermediateAction)
 {
     this.Checker = Checker;
 }
Exemple #25
0
 protected abstract bool CheckIfTriggered(TriggerActionType type, params object[] inputs);
Exemple #26
0
 protected override bool CheckIfTriggered(TriggerActionType type, params object[] inputs)
 {
     return true;
 }
Exemple #27
0
 public TriggerAction(TriggerActionType Type, Action IntermediateAction = null)
 {
     this.Type = Type;
     this.IntermediateAction = IntermediateAction;
 }
Exemple #28
0
 public TriggerAction(TriggerAction other)
 {
     _vesselTriggers = other._vesselTriggers;
     _type           = (TriggerActionType)(-1);
     _modified       = false;
 }
Exemple #29
0
 protected abstract bool CheckIfTriggered(TriggerActionType type, params object[] inputs);
Exemple #30
0
 protected override bool CheckIfTriggered(TriggerActionType type, params object[] inputs)
 {
     return(true);
 }
Exemple #31
0
        protected override bool CheckIfTriggered(TriggerActionType type, params object[] inputs)
        {
            if (inputs == null || inputs.Length == 0)
                return false;

            var packet = inputs[0] as Packet;
            if (packet == null)
                return false;

            if (packet.Header.Command != Opcode)
                return false;

            if (PacketChecker != null)
                return PacketChecker(packet);
            else
                return true;
        }
Exemple #32
0
        protected override bool CheckIfTriggered(TriggerActionType type, params object[] inputs)
        {
            if (inputs == null || inputs.Length == 0 || inputs[0] == null || inputs[0].GetType() != typeof(UpdateFieldEventArg))
                return false;

            var updateFieldArgs = (UpdateFieldEventArg)inputs[0];
            if (updateFieldArgs.Index != Index)
                return false;

            if (updateFieldArgs.NewValue != Value)
                return false;

            return true;
        }
Exemple #33
0
 public AlwaysTrueTriggerAction(TriggerActionType Type, Action IntermediateAction = null)
     : base(Type, IntermediateAction)
 {
 }
Exemple #34
0
 public TriggerAction(TriggerActionType Type, Action IntermediateAction = null)
 {
     this.Type = Type;
     this.IntermediateAction = IntermediateAction;
 }
Exemple #35
0
 public void HandleTriggerInput(TriggerActionType type, params object[] inputs)
 {
     Triggers.ForEach(trigger => trigger.HandleInput(type, inputs));
 }
Exemple #36
0
 public TriggerAction(VesselTriggers vesselTriggers)
 {
     _vesselTriggers = vesselTriggers;
     _type           = (TriggerActionType)(-1);
     _modified       = true;
 }