示例#1
0
 public AskForm(IContext context, ContextState previous, string message, ContextAction yesAction, ContextAction noAction)
     : base(context, previous)
 {
     Message   = message;
     YesAction = yesAction;
     NoAction  = noAction;
 }
示例#2
0
        /// <summary>
        /// 获取默认控制器
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override IAction <IOwinContext, IOwinRequest> GetAction(IOwinContext context, NFinal.Config.Plug.PlugConfig plugConfig)
        {
            ContextAction controller = new ContextAction();

            controller.BaseInitialization(context, null, plugConfig);
            return(controller);
        }
示例#3
0
/*
 *      public AskForm(IContext context, string message, string yesUrl, string noUrl) : base(context)
 *      {
 *          Message = message;
 *          YesUrl = yesUrl;
 *          NoUrl = noUrl;
 *      }
 *
 *      public AskForm(IContext context, ContextState previous, string message, string yesUrl, string noUrl)
 *          : base(context, previous)
 *      {
 *          Message = message;
 *          YesUrl = yesUrl;
 *          NoUrl = noUrl;
 *      }
 */

        public AskForm(IContext context, string message, ContextAction yesAction, ContextAction noAction)
            : base(context)
        {
            Message   = message;
            YesAction = yesAction;
            NoAction  = noAction;
        }
示例#4
0
 private void BuildActionsContextMenu(ProjectView projectView)
 {
     ProjectContextMenuStrip.SuspendLayout();
     ProjectContextMenuStrip.Items.Clear();
     foreach (var contextAction in _actionsList)
     {
         if (!contextAction.IsApplicable(projectView.Project))
         {
             continue;
         }
         contextAction.Source = projectView.Project;
         var button = new ToolStripButton
         {
             DisplayStyle = ToolStripItemDisplayStyle.Text,
             TextAlign    = System.Drawing.ContentAlignment.MiddleLeft,
             Text         = contextAction.Title,
             Width        = 150,
             AutoSize     = true,
         };
         ContextAction cAction = contextAction;
         button.Click += (senderr, er) => cAction.Do();
         ProjectContextMenuStrip.Items.Add(button);
     }
     ProjectContextMenuStrip.ResumeLayout();
 }
示例#5
0
        private void InitCommand()
        {
            CopyPasswordCommand = new RelayCommand(CopyPasswordClick);
            CopyUserNameCommand = new RelayCommand(CopyUserNameClick);
            if (Actions != null && Actions.Count() > 1)
            {
                var copyPassword = new ContextAction()
                {
                    Action    = CopyPasswordCommand,
                    Name      = Application.Current.FindResource("CopyPassword") as string,
                    Icon      = Application.Current.Resources["menuPasswordGrey"] as ImageSource,
                    IconHover = Application.Current.Resources["menuPasswordGreen"] as ImageSource
                };

                var copyUserName = new ContextAction()
                {
                    Action    = CopyUserNameCommand,
                    Name      = Application.Current.FindResource("MenuCopyUsername") as string,
                    Icon      = Application.Current.Resources["menuPersonGrey"] as ImageSource,
                    IconHover = Application.Current.Resources["menuPersonGreen"] as ImageSource
                };
                Actions.Insert(1, copyUserName);
                Actions.Insert(1, copyPassword);
            }
        }
示例#6
0
    void Start()
    {
        ContextAction action = GetComponent <ContextAction>();

        action.TriggerFilter = Filter;
        action.OnTrigger     = Trigger;
    }
示例#7
0
    public void Reset()
    {
        ContextAction action = GetComponent <ContextAction>();

        action.Reset();
        GetComponent <TaskBroadcaster>().Activate();
    }
示例#8
0
        public void AddContextAction(Action <Transform> action, int insID)
        {
            ContextAction ca = new ContextAction();

            ca.CallBack = action;
            ca.InsID    = insID;
            contexts.Add(ca);
        }
示例#9
0
文件: Item.cs 项目: JohnTM/HomeGame
    // Use this for initialization
    void Start()
    {
        m_action = GetComponent <ContextAction>();

        m_action.TriggerFilter = Filter;
        m_action.OnTrigger     = Trigger;
        m_action.Reset();
    }
示例#10
0
 public void AddOnDestroy(ContextAction onDestroy)
 {
     if (m_OnDestroy == null)
     {
         m_OnDestroy = new List <ContextAction>();
     }
     m_OnDestroy.Add(onDestroy);
 }
        public ContextActionCommand(ContextAction contextAction)
        {
            if (contextAction == null)
            {
                throw new ArgumentNullException(nameof(contextAction));
            }

            ContextAction = contextAction;
        }
示例#12
0
		public ContextActionCommand(ContextAction contextAction)
		{
			if (contextAction == null)
			{
				throw new ArgumentNullException(nameof(contextAction));
			}

			ContextAction = contextAction;
		}
        public ContextActionTextEditorCommand(SqlTextEditor textEditor, ContextAction contextAction)
            : base(contextAction)
        {
            if (textEditor == null)
            {
                throw new ArgumentNullException(nameof(textEditor));
            }

            _textEditor = textEditor;
        }
示例#14
0
        protected virtual void Closed(ContextAction result, object data)
        {
            DataContext.IsVisabled = false;
            DataContext.OnCommand?.Invoke(this, ContextResult.Cancel());
            OnResult.InvokeAsync(result?.ContextResult(data));

            //DataContext.Child = new TContext<TNull>();
            LoadDataContext();
            base.Close();
            OnCloseAction?.Invoke();
        }
示例#15
0
 /// <summary>
 /// 添加按钮方法
 /// </summary>
 /// <param name="contextAction"></param>
 /// <returns></returns>
 public TModalContext AddAction(ContextAction contextAction)
 {
     if (contextAction == null)
     {
         throw new NullReferenceException();
     }
     ButtonTypes       |= (int)contextAction.Result;
     contextAction.Text = SetActionTitle(contextAction);
     ContextActions.Add(contextAction);
     return(this);
 }
示例#16
0
文件: Utils.cs 项目: hazzik/Rhino.Net
		/// <summary>Runs the provided action at the given optimization level</summary>
		public static void RunWithOptimizationLevel(ContextFactory contextFactory, ContextAction action, int optimizationLevel)
		{
			Context cx = contextFactory.EnterContext();
			try
			{
				cx.SetOptimizationLevel(optimizationLevel);
				action.Run(cx);
			}
			finally
			{
				Context.Exit();
			}
		}
示例#17
0
文件: Player.cs 项目: JohnTM/HomeGame
    private void CheckForContextActions()
    {
        Collider[]    objects     = Physics.OverlapSphere(transform.position, 1);
        float         minDist     = float.PositiveInfinity;
        int           maxPriority = int.MinValue;
        ContextAction minAction   = null;

        if (m_currentItem)
        {
            minAction   = m_currentItem.GetComponent <ContextAction>();
            minDist     = 0;
            maxPriority = minAction.Priority;
        }

        foreach (Collider c in objects)
        {
            float         dist   = Vector3.Distance(c.gameObject.transform.position, transform.position);
            ContextAction action = c.GetComponentInParent <ContextAction>();

            if (minAction == null || (action && (dist < minDist || action.Priority >= maxPriority)))
            {
                if (action != null && action.isActiveAndEnabled && action.CanTrigger(this))
                {
                    minAction   = action;
                    maxPriority = action.Priority;
                }
            }
        }



        if (minAction)
        {
            m_closestAction         = minAction;
            m_contextImage.enabled  = true;
            m_progressImage.enabled = m_closestAction.Type == ContextAction.TriggerType.OverTime;

            Transform canvasT = m_contextImage.transform.parent;
            canvasT.position = minAction.transform.position + Vector3.up * minAction.Height;

            Vector3 camLook = -(Camera.main.transform.position - canvasT.position).normalized;

            m_contextImage.transform.parent.rotation = Quaternion.LookRotation(camLook);
        }
        else
        {
            m_closestAction         = null;
            m_contextImage.enabled  = false;
            m_progressImage.enabled = false;
        }
    }
示例#18
0
            public Node(GitUICommands uiCommands, TreeNode treeNode = null)
            {
                if (treeNode != null)
                {
                    TreeNode = treeNode;
                }
                UiCommands     = uiCommands;
                Git            = uiCommands.Module;
                IsDraggable    = false;
                ContextActions = new ContextAction[0];
                AllowDrop      = false;

                dragDropActions = new Lazy <IEnumerable <DragDropAction> >(CreateDragDropActions);
            }
示例#19
0
        internal ActionResult RedirectTo(ContextAction action)
        {
            if (String.IsNullOrEmpty(action.ControllerName))
            {
                return(action.RouteValues != null?
                       RedirectToAction(action.ActionName, action.RouteValues) : RedirectToAction(action.ActionName));
            }

            if (action.RouteValues != null)
            {
                return(RedirectToAction(action.ActionName, action.ControllerName, action.RouteValues));
            }

            return(RedirectToAction(action.ActionName, action.ControllerName));
        }
示例#20
0
 protected virtual void Close(ContextAction result, object data)
 {
     if (result != null)
     {
         result.ContinueAction = (result, data) => Closed(result, data);
     }
     result?.Action?.Invoke(result);
     if (!result.Disposed)
     {
         return;
     }
     OnClosing = o =>
     {
         Disposed = result?.Disposed ?? true;
     };
     Closed(result, data);
 }
示例#21
0
        void uv_ContextMenuClick(object sender, EventArgs e, ContextAction action, List<string> videos)
        {
            if (action == ContextAction.Preview && videos.Count > 0)
            {
                /*MainWindow player = new MainWindow(videos, false);
                player.Topmost = true;
                player.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
                player.ShowDialog();*/
                // TODO: Replace with AxPlayer

                VideoFromStream player = new VideoFromStream(true);
                player.LoadVideos(videos);
                player.Topmost = true;
                player.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
                player.ShowDialog();

            }
        }
示例#22
0
        protected static string SetActionTitle(ContextAction contextAction)
        {
            if (!string.IsNullOrWhiteSpace(contextAction?.Text))
            {
                return(contextAction.Text);
            }
            string v = contextAction !.Result switch
            {
                ContextResultValue.OK => "确定",
                ContextResultValue.Cancel => "取消",
                ContextResultValue.Yes => "是",
                ContextResultValue.No => "否",
                ContextResultValue.Close => "关闭",
                _ => ""
            };

            return(v);
        }
    }
示例#23
0
        private List <ContextAction> GetActions()
        {
            List <ContextAction> actionsList = new List <ContextAction>();
            ContextAction        action      = new ContextAction
            {
                IsApplicable    = p => true,
                DelegatedAction = source =>
                {
                    var proj = ProjectsRepo.FindFirstProject(source);
                    using (PomTextEditorForm form = new PomTextEditorForm((Project)proj))
                    {
                        form.ShowDialog();
                    }
                    RefreshPropertyGrid();
                },
                Title = "Edit as text",
            };

            actionsList.Add(action);
            action = new ContextAction
            {
                IsApplicable    = p => true,
                DelegatedAction = source =>
                {
                    var proj = ProjectsRepo.FindFirstProject(source);
                    using (PomAdvancedEditor form = new PomAdvancedEditor(CurrentProjectView, ProjectsRepo))
                    {
                        form.ShowDialog();
                    }
                    RefreshPropertyGrid();
                },
                Title = "Advanced editor",
            };
            actionsList.Add(action);

            return(actionsList);

            // REVIEW: add cascade switch to snapshot for release projects
        }
示例#24
0
		private void DoTest(int optimizationLevel, string expected, ContextAction action)
		{
			object o = new ContextFactory().Call(new _ContextAction_128(optimizationLevel, action));
			NUnit.Framework.Assert.AreEqual(expected, o);
		}
示例#25
0
 private bool IsSet(ContextAction contextAction)
 {
     return((SaveChangesOn & contextAction) == contextAction);
 }
示例#26
0
文件: Utils.cs 项目: hazzik/Rhino.Net
		/// <summary>Runs the action successively with all available optimization levels</summary>
		public static void RunWithAllOptimizationLevels(ContextFactory contextFactory, ContextAction action)
		{
			RunWithOptimizationLevel(contextFactory, action, -1);
			RunWithOptimizationLevel(contextFactory, action, 0);
			RunWithOptimizationLevel(contextFactory, action, 1);
		}
示例#27
0
 internal static void Register(string name, Action action)
 {
     _contextActions[name] = new ContextAction(name, action);
 }
示例#28
0
文件: Utils.cs 项目: hazzik/Rhino.Net
		/// <summary>Runs the provided action at the given optimization level</summary>
		public static void RunWithOptimizationLevel(ContextAction action, int optimizationLevel)
		{
			RunWithOptimizationLevel(new ContextFactory(), action, optimizationLevel);
		}
 public ContextActionCommand(ContextAction contextAction)
 {
     ContextAction = contextAction ?? throw new ArgumentNullException(nameof(contextAction));
 }
示例#30
0
 protected virtual void OnContextAction(ContextActionEventArgs e)
 {
     ContextAction?.Invoke(this, e);
 }
示例#31
0
 void uv_ContextMenuClick(object sender, EventArgs e, ContextAction action, List<string> videos)
 {
     if (action == ContextAction.Preview && videos.Count > 0)
     {
         frmMediaPlayerPopup mediaPlayerPopup = new frmMediaPlayerPopup();
         mediaPlayerPopup.LoadVideos(videos);
         mediaPlayerPopup.StartPosition = FormStartPosition.CenterParent;
         mediaPlayerPopup.ShowDialog(this);
     }
 }
示例#32
0
 public virtual void ContextAction(ContextAction contextAction)
 {
 }
示例#33
0
		public ContextActionTextEditorCommand(SqlTextEditor textEditor, ContextAction contextAction)
			: base(contextAction)
		{
			if (textEditor == null)
			{
				throw new ArgumentNullException(nameof(textEditor));
			}

			_textEditor = textEditor;
		}
示例#34
0
        void uv_ContextMenuClick(object sender, EventArgs e, ContextAction action, List<string> videos)
        {
            if (action == ContextAction.Preview && videos.Count > 0)
            {
                List<FileFromDB> selectedFiles = new List<FileFromDB>();

                List<string> urls = new List<string>();
                foreach (CodeITBL.FileFromDB selectedFile in ucUserVideos.lvItemsContainer.SelectedItems)
                {					
					if(CodeITLicence.Licence.StorageType == CodeITLicence.StorageType.Cloud && selectedFile.IsCloudFileSystem == false)
					{
						System.Windows.MessageBox.Show(string.Format("Video {0} is stored local, please use local license", selectedFile.NewFileName), "Info", MessageBoxButton.OK, MessageBoxImage.Information);
					}
					if (CodeITLicence.Licence.StorageType == CodeITLicence.StorageType.Local && selectedFile.IsCloudFileSystem == true)
					{
						System.Windows.MessageBox.Show(string.Format("Video {0} is stored on cloud, please use cloud license", selectedFile.NewFileName), "Info", MessageBoxButton.OK, MessageBoxImage.Information);
					}
					else
						selectedFiles.Add(selectedFile);
                }

				if (selectedFiles.Count > 0)
				{
					VideoFromStream player = new VideoFromStream();
					player.LoadVideos(selectedFiles);
					player.Topmost = true;
					player.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
					player.ShowDialog();
				}
            }
        }
示例#35
0
		private void DoTest(string expected, ContextAction action)
		{
			DoTest(-1, expected, action);
			DoTest(0, expected, action);
			DoTest(1, expected, action);
		}
示例#36
0
        void uv_ContextMenuClick(object sender, EventArgs e, ContextAction action, List<string> videos)
        {
            if (action == ContextAction.Preview && videos.Count > 0)
            {
                //axWindowsMediaPlayer1.URL = @"C:\GOPR0007.MP4";
                axWindowsMediaPlayer1.URL = videos[0];
                if (videos.Count == 1)
                {
                    return;
                }
                else
                {

                    for (int i = 1; i < videos.Count; i++)
                    {
                        WMPLib.IWMPMedia media = axWindowsMediaPlayer1.newMedia(videos[i]);
                        axWindowsMediaPlayer1.currentPlaylist.appendItem(media);
                    }
                }
            }
            //throw new NotImplementedException();
        }
示例#37
0
		public static object Call(ContextAction action)
		{
			return Call(ContextFactory.GetGlobal(), action);
		}
示例#38
0
 /// <summary>
 /// Adds an action to this context
 /// </summary>
 /// <param name="action">Action to be added</param>
 public void AddRoutingAction(ContextAction action)
 {
     this.RoutingAction |= action;
 }
示例#39
0
		/// <summary>
		/// The method implements
		/// <see cref="ContextFactory.Call(ContextAction)">ContextFactory.Call(ContextAction)</see>
		/// logic.
		/// </summary>
		internal static object Call(ContextFactory factory, ContextAction action)
		{
			Rhino.Context cx = Enter(null, factory);
			try
			{
				return action.Run(cx);
			}
			finally
			{
				Exit();
			}
		}
 public virtual void ContextAction(ContextAction contextAction)
 {
 }
示例#41
0
			public _ContextAction_128(int optimizationLevel, ContextAction action)
			{
				this.optimizationLevel = optimizationLevel;
				this.action = action;
			}
示例#42
0
            ///Display curves that belong to serializeContext and transformContext parent, at time and with timeSpan.
            public void Draw3DCurve(IAnimatableData animatable, IKeyable keyable, Transform transformContext, float time, float timeSpan = 50f)
            {
                this.animatable = animatable;
                // this.keyable = keyable;

                var curves = animatable.GetCurves();

                if (curves == null || curves.Length != 3)
                {
                    return;
                }

                var curveX = curves[0];
                var curveY = curves[1];
                var curveZ = curves[2];

                if (curveX.length < 2 || curveY.length < 2 || curveZ.length < 2)
                {
                    return;
                }

                if (curveX.length != curveY.length || curveY.length != curveZ.length)
                {
                    return;
                }


                var serializeContext = keyable as Object;
                var e = Event.current;

                var start = (float)Mathf.FloorToInt(time - (timeSpan / 2));
                var end   = (float)Mathf.CeilToInt(time + (timeSpan / 2));

                start = Mathf.Max(start, Mathf.Min(curveX[0].time, curveY[0].time, curveZ[0].time));
                end   = Mathf.Min(end, Mathf.Max(curveX[curveX.length - 1].time, curveY[curveY.length - 1].time, curveZ[curveZ.length - 1].time));

                if (curveX.length != lastCurveLength)
                {
                    lastCurveLength = curveX.length;
                    kIndex          = -1;
                }

                //1. Keyframes.
                for (var k = 0; k < curveX.length; k++)
                {
                    EditorGUI.BeginChangeCheck();
                    var forceChanged = false;

                    var keyX = curveX[k];
                    var keyY = curveY[k];
                    var keyZ = curveZ[k];

                    if (keyX.time < start)
                    {
                        continue;
                    }
                    if (keyX.time > end)
                    {
                        break;
                    }

                    var tangentModeX     = CurveUtility.GetKeyTangentMode(keyX);
                    var tangentModeY     = CurveUtility.GetKeyTangentMode(keyY);
                    var tangentModeZ     = CurveUtility.GetKeyTangentMode(keyZ);
                    var haveSameTangents = tangentModeX == tangentModeY && tangentModeY == tangentModeZ;
                    var tangentMode      = haveSameTangents ? tangentModeX : TangentMode.Editable;
                    var isBroken         = CurveUtility.GetKeyBroken(keyX) && CurveUtility.GetKeyBroken(keyY) && CurveUtility.GetKeyBroken(keyZ);

                    var pos = new Vector3(keyX.value, keyY.value, keyZ.value);

                    if (transformContext != null)
                    {
                        pos = transformContext.TransformPoint(pos);
                    }

                    Handles.Label(pos, keyX.time.ToString("0.00"));

                    ///MOUSE EVENTS
                    var screenPos = HandleUtility.WorldToGUIPoint(pos);
                    if (((Vector2)screenPos - e.mousePosition).magnitude < 10)
                    {
                        if (e.type == EventType.MouseDown)
                        {
                            if (e.button == 0 && kIndex != k)
                            {
                                kIndex = k;
                                GUIUtility.hotControl = 0;
                                SceneView.RepaintAll();
                                e.Use();
                            }

                            if (e.button == 1 && kIndex == k)
                            {
                                var menu = new GenericMenu();
                                menu.AddItem(new GUIContent("Jump Time Here"), false, () => { keyable.root.currentTime = curveX[kIndex].time + keyable.startTime; });
                                menu.AddItem(new GUIContent("Smooth"), tangentMode == TangentMode.Smooth, () => { contextAction = ContextAction.SetTangentMode; contextTangentMode = TangentMode.Smooth; });
                                menu.AddItem(new GUIContent("Linear"), tangentMode == TangentMode.Linear, () => { contextAction = ContextAction.SetTangentMode; contextTangentMode = TangentMode.Linear; });
                                menu.AddItem(new GUIContent("Constant"), tangentMode == TangentMode.Constant, () => { contextAction = ContextAction.SetTangentMode; contextTangentMode = TangentMode.Constant; });
                                menu.AddItem(new GUIContent("Editable"), tangentMode == TangentMode.Editable, () => { contextAction = ContextAction.SetTangentMode; contextTangentMode = TangentMode.Editable; });
                                if (tangentMode == TangentMode.Editable)
                                {
                                    menu.AddItem(new GUIContent("Tangents/Connected"), !isBroken, () => { contextAction = ContextAction.SetBrokenMode; contextBrokenMode = false; });
                                    menu.AddItem(new GUIContent("Tangents/Broken"), isBroken, () => { contextAction = ContextAction.SetBrokenMode; contextBrokenMode = true; });
                                }
                                menu.AddSeparator("/");
                                menu.AddItem(new GUIContent("Delete"), false, () => { contextAction = ContextAction.Delete; });
                                menu.ShowAsContext();
                                e.Use();
                            }
                        }
                    }

                    ///APPLY CONTEXT ACTIONS
                    if (contextAction != ContextAction.None && k == kIndex)
                    {
                        var _contextAction = contextAction;
                        contextAction = ContextAction.None;
                        forceChanged  = true;
                        if (_contextAction == ContextAction.SetBrokenMode)
                        {
                            Undo.RecordObject(serializeContext, "Animation Curve Change");
                            curveX.SetKeyBroken(kIndex, contextBrokenMode);
                            curveY.SetKeyBroken(kIndex, contextBrokenMode);
                            curveZ.SetKeyBroken(kIndex, contextBrokenMode);

                            NotifyChange();
                            return;
                        }

                        if (_contextAction == ContextAction.SetTangentMode)
                        {
                            Undo.RecordObject(serializeContext, "Animation Curve Change");
                            curveX.SetKeyTangentMode(kIndex, contextTangentMode);
                            curveY.SetKeyTangentMode(kIndex, contextTangentMode);
                            curveZ.SetKeyTangentMode(kIndex, contextTangentMode);

                            NotifyChange();
                            return;
                        }

                        if (_contextAction == ContextAction.Delete)
                        {
                            Undo.RecordObject(serializeContext, "Animation Curve Change");
                            curveX.RemoveKey(k);
                            curveY.RemoveKey(k);
                            curveZ.RemoveKey(k);
                            kIndex = -1;

                            NotifyChange();
                            return;
                        }
                    }


                    ///POSITION
                    var pointSize = HandleUtility.GetHandleSize(pos) * 0.05f;
                    var newValue  = pos;
                    if (kIndex == k)
                    {
                        if (Tools.current == Tool.Move)
                        {
                            newValue = Handles.PositionHandle(pos, Quaternion.identity);
                        }
                        else
                        {
                            newValue = Handles.FreeMoveHandle(pos, Quaternion.identity, pointSize, Vector3.zero, Handles.RectangleCap);
                        }
                    }
                    var cam = SceneView.lastActiveSceneView.camera;
                    Handles.RectangleCap(0, pos, cam.transform.rotation, pointSize);

                    if (transformContext != null)
                    {
                        newValue = transformContext.InverseTransformPoint(newValue);
                    }

                    keyX.value = newValue.x;
                    keyY.value = newValue.y;
                    keyZ.value = newValue.z;


                    ///TANGENTS
                    if (haveSameTangents && tangentMode == TangentMode.Editable)
                    {
                        if (kIndex == k)
                        {
                            if (k != 0)
                            {
                                var inHandle = new Vector3(-keyX.inTangent, -keyY.inTangent, -keyZ.inTangent);
                                inHandle /= HANDLE_DISTANCE_COMPENSATION;
                                inHandle  = newValue + inHandle;
                                if (transformContext != null)
                                {
                                    inHandle = transformContext.TransformPoint(inHandle);
                                }
                                var handleSize  = HandleUtility.GetHandleSize(inHandle) * 0.05f;
                                var newInHandle = Handles.FreeMoveHandle(inHandle, Quaternion.identity, handleSize, Vector3.zero, Handles.CircleCap);
                                Handles.DrawLine(pos, newInHandle);
                                if (transformContext != null)
                                {
                                    newInHandle = transformContext.InverseTransformPoint(newInHandle);
                                }

                                newInHandle   -= newValue;
                                newInHandle   *= HANDLE_DISTANCE_COMPENSATION;
                                keyX.inTangent = -newInHandle.x;
                                keyY.inTangent = -newInHandle.y;
                                keyZ.inTangent = -newInHandle.z;
                                if (!isBroken)
                                {
                                    keyX.outTangent = keyX.inTangent;
                                    keyY.outTangent = keyY.inTangent;
                                    keyZ.outTangent = keyZ.inTangent;
                                }
                            }

                            if (k < curveX.length - 1)
                            {
                                var outHandle = new Vector3(keyX.outTangent, keyY.outTangent, keyZ.outTangent);
                                outHandle /= HANDLE_DISTANCE_COMPENSATION;
                                outHandle  = newValue + outHandle;
                                if (transformContext != null)
                                {
                                    outHandle = transformContext.TransformPoint(outHandle);
                                }
                                var handleSize   = HandleUtility.GetHandleSize(outHandle) * 0.05f;
                                var newOutHandle = Handles.FreeMoveHandle(outHandle, Quaternion.identity, handleSize, Vector3.zero, Handles.CircleCap);
                                Handles.DrawLine(pos, newOutHandle);
                                if (transformContext != null)
                                {
                                    newOutHandle = transformContext.InverseTransformPoint(newOutHandle);
                                }
                                newOutHandle   -= newValue;
                                newOutHandle   *= HANDLE_DISTANCE_COMPENSATION;
                                keyX.outTangent = newOutHandle.x;
                                keyY.outTangent = newOutHandle.y;
                                keyZ.outTangent = newOutHandle.z;
                                if (!isBroken)
                                {
                                    keyX.inTangent = keyX.outTangent;
                                    keyY.inTangent = keyY.outTangent;
                                    keyZ.inTangent = keyZ.outTangent;
                                }
                            }
                        }
                    }

                    ///APPLY
                    if (EditorGUI.EndChangeCheck() || forceChanged)
                    {
                        Undo.RecordObject(serializeContext, "Animation Curve Change");
                        curveX.MoveKey(k, keyX);
                        curveY.MoveKey(k, keyY);
                        curveZ.MoveKey(k, keyZ);
                        EditorUtility.SetDirty(serializeContext);
                        NotifyChange();
                    }
                }


                ///2. Motion Path
                Handles.color = Prefs.motionPathsColor;
                var lastDrawnPos = Vector3.zero;

                for (var t = start; t <= end; t += DRAW_RESOLUTION)
                {
                    var pos     = new Vector3(curveX.Evaluate(t), curveY.Evaluate(t), curveZ.Evaluate(t));
                    var nextPos = new Vector3(curveX.Evaluate(t + DRAW_RESOLUTION), curveY.Evaluate(t + DRAW_RESOLUTION), curveZ.Evaluate(t + DRAW_RESOLUTION));

                    if (transformContext != null)
                    {
                        pos     = transformContext.TransformPoint(pos);
                        nextPos = transformContext.TransformPoint(nextPos);
                    }

                    if ((pos - lastDrawnPos).magnitude > DRAW_THRESHOLD)
                    {
                        lastDrawnPos = pos;
                        Handles.SphereCap(0, pos, Quaternion.identity, 0.02f);
                        Handles.DrawLine(pos, nextPos);
                    }
                }
                Handles.color = Color.white;


                ///3. GUI
                if (kIndex >= 0)
                {
                    var guiRect = new Rect(Screen.width - 300, Screen.height - 170, 280, 130);
                    var kx      = curveX[kIndex];
                    var ky      = curveY[kIndex];
                    var kz      = curveZ[kIndex];
                    EditorGUI.BeginChangeCheck();
                    {
                        Handles.BeginGUI();
                        GUILayout.BeginArea(guiRect);
                        EditorTools.BeginBody("Keyframe Parameters");
                        kx.value = EditorGUILayout.FloatField("X", kx.value);
                        ky.value = EditorGUILayout.FloatField("Y", ky.value);
                        kz.value = EditorGUILayout.FloatField("Z", kz.value);

                        GUI.enabled = CurveUtility.GetKeyTangentMode(kx) == TangentMode.Editable;
                        var inTangent = new Vector3(kx.inTangent, ky.inTangent, kz.inTangent);
                        inTangent    = EditorGUILayout.Vector3Field("", inTangent);
                        kx.inTangent = inTangent.x;
                        ky.inTangent = inTangent.y;
                        kz.inTangent = inTangent.z;

                        GUI.enabled = CurveUtility.GetKeyBroken(kx);
                        var outTangent = new Vector3(kx.outTangent, ky.outTangent, kz.outTangent);
                        outTangent    = EditorGUILayout.Vector3Field("", outTangent);
                        kx.outTangent = outTangent.x;
                        ky.outTangent = outTangent.y;
                        kz.outTangent = outTangent.z;

                        GUI.enabled = true;

                        EditorTools.EndBody();
                        GUILayout.EndArea();
                        Handles.EndGUI();
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(serializeContext, "Animation Curve Change");
                        curveX.MoveKey(kIndex, kx);
                        curveY.MoveKey(kIndex, ky);
                        curveZ.MoveKey(kIndex, kz);
                        EditorUtility.SetDirty(serializeContext);
                        NotifyChange();
                    }
                }


                /*
                 *              for (var k = 0; k < curveX.length - 1; k++){
                 *                  var keyX = curveX[k];
                 *                  var keyY = curveY[k];
                 *                  var keyZ = curveZ[k];
                 *                  var nextKeyX = curveX[k+1];
                 *                  var nextKeyY = curveY[k+1];
                 *                  var nextKeyZ = curveZ[k+1];
                 *
                 *                  var t = new Vector3(keyX.time, keyY.time, keyZ.time);
                 *                  var nextT = new Vector3(nextKeyX.time, nextKeyY.time, nextKeyZ.time);
                 *
                 *                  var tangent = new Vector3( keyX.outTangent, keyY.outTangent, keyZ.outTangent );
                 *                  var nextTangent = new Vector3( nextKeyX.inTangent, nextKeyY.inTangent, nextKeyZ.inTangent );
                 *
                 *                  var pos = new Vector3( keyX.value, keyY.value, keyZ.value );
                 *                  var nextPos = new Vector3( nextKeyX.value, nextKeyY.value, nextKeyZ.value );
                 *
                 *                  if (transformContext != null){
                 *                      pos = transformContext.TransformPoint(pos);
                 *                      nextPos = transformContext.TransformPoint(nextPos);
                 *                  }
                 *
                 *                  var num = (nextT - t) * 0.333333f;
                 *                  var tangentPos = new Vector3( pos.x + num.x * tangent.x, pos.y + num.y * tangent.y, pos.z + num.z * tangent.z );
                 *                  var nextTangentPos = new Vector3( nextPos.x - num.x * nextTangent.x, nextPos.y - num.y * nextTangent.y, nextPos.z - num.z * nextTangent.z );
                 *
                 *                  Handles.DrawBezier(pos, nextPos, tangentPos, nextTangentPos, Prefs.motionPathsColor, null, 1.5f);
                 *              }
                 */
            }
示例#43
0
		void uv_ContextMenuClick(object sender, EventArgs e, ContextAction action, List<string> videos)
		{
			if (action == ContextAction.Preview && videos.Count > 0)
			{
				string folderName = Guid.NewGuid().ToString().Replace("-", string.Empty);
				string folderPath = Properties.Settings.Default.TempVideoLocation.TrimEnd('\\') + "\\" + folderName;
				if (!System.IO.Directory.Exists(folderPath))
					System.IO.Directory.CreateDirectory(folderPath);

				List<string> allVideos = new List<string>();
				SelectedItems();
				DownloadVideoFromMTPDevice(_selectedFiles, _goproDevice, folderPath);

				foreach (var item in _selectedFiles)
				{
					allVideos.Add(System.IO.Path.Combine(folderPath, item.Name));
				}

                VideoFromStream player = new VideoFromStream(true);
                player.LoadVideos(allVideos);
                player.Topmost = true;
                player.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
                player.ShowDialog();
			}
		}