예제 #1
0
        private void LoadGestureIntents(AbstractApp app)
        {
            //禁用删除和修改按钮
            btn_modifyGesture.Enabled = false;
            btn_RemoveGesture.Enabled = false;

            listGestureIntents.BeginUpdate();

            //每次加载新的列表,则保存原列表元素的顺序
            ApplyListIntentsOrder();

            listGestureIntents.Items.Clear();

            if (app.GestureIntents.Count == 0)
            {
                AdjustListGestureIntentsColumnSize();

                listGestureIntents.EndUpdate();
                return;
            }

            var orderedIntents = (from i in app.GestureIntents select new OrderableIntent(i.Value)).OrderBy((o) => o.Order).ToArray();

            app.GestureIntents.Import(orderedIntents, true);

            foreach (var gest in app.GestureIntents)//app.GestureIntents)
            {
                AddGestureIntent(gest.Value);
            }
            Debug.WriteLine("LoadGestureIntents");
            //listGestureIntents.Items[0].Selected = true;
            AdjustListGestureIntentsColumnSize();

            listGestureIntents.EndUpdate();
        }
예제 #2
0
        private void LoadGestureIntents(AbstractApp app)
        {
            //禁用删除和修改按钮
            btn_modifyGesture.Enabled = false;
            btn_RemoveGesture.Enabled = false;

            listGestureIntents.BeginUpdate();

            listGestureIntents.Items.Clear();

            if (app.GestureIntents.Count == 0)
            {
                AdjustListGestureIntentsColumnSize();

                listGestureIntents.EndUpdate();
                return;
            }

            foreach (var gest in app.GestureIntents)
            {
                AddGestureIntent(gest.Value);
            }
            Debug.WriteLine("LoadGestureIntents");
            //listGestureIntents.Items[0].Selected = true;
            AdjustListGestureIntentsColumnSize();

            listGestureIntents.EndUpdate();
        }
예제 #3
0
	void Start() {
		existingApps = new Dictionary<string, AbstractApp>();
		//Find every GameObject under AppContainer that has an AbstractApp component that is enabled,
		// and add it to the list of existing apps.
		foreach (Transform t in GameObject.Find("AppContainer").transform) {
			AbstractApp abstractAppComponent = t.GetComponent<AbstractApp>();

			//Don't add elements that don't have an AbstractApp component
			if (abstractAppComponent == null)
				continue;

			//Don't add the elements that have a disabled AbstractApp
			if (!abstractAppComponent.enabled)
				continue;

			existingApps.Add(abstractAppComponent.name, abstractAppComponent);
		}

		stack = new List<AbstractApp>();

		realDate = DateTime.Now;
		gameDate = new System.DateTime(2017, 6, 6, 14, 0, 0);
		dateOffset = (realDate - gameDate);

		LoadApp("home");
	}
        protected virtual bool handleTouch(int touchFingerId, Vector3 touchPosition, TouchPhase touchPhase)
        {
            if (touchPhase != TouchPhase.Began)
            {
                return(false);
            }
            if (AbstractApp.IsPointerOverUI(touchPosition, touchFingerId) || AbstractApp.MainCamera == null)
            {
                return(false);
            }
            _hasRaycastHit = false;
            //摄像机到点击位置的的射线
            Ray ray = AbstractApp.MainCamera.ScreenPointToRay(touchPosition);

            if (raycast(ray, out _raycastHit))
            {
                IRayHitReceiver receiver = null;
                GameObject      go       = _raycastHit.collider.gameObject;
                if (go != null)
                {
                    Transform parent = go.transform;
                    while (parent)
                    {
                        receiver = parent.GetComponent <IRayHitReceiver>();
                        if (receiver != null)
                        {
                            break;
                        }
                        parent = parent.parent;
                    }
                    if (receiver != null)
                    {
                        //检测是否选择了自己
                        _hasRaycastHit = receiver.OnRayHit(_raycastHit);
                        if (_hasRaycastHit)
                        {
                            //尝试选择更多,包括自己周围的重叠的一些单位
                            if (receiver.TryRayHitMore(_raycastHit) == false)
                            {
                                //如果没有更多,那么就选择自己
                                receiver.OnRayHitSelf();
                            }
                        }
                    }
                    _currentCollidingObject = go;
                    _currentReceiver        = receiver;

                    handleTouch(_raycastHit, touchPhase);
                }
            }

            return(_hasRaycastHit);
        }
예제 #5
0
        public static void Execute(AbstractApp app, AppEvent appEvent, object eventObject)
        {
            if (app == null)
            {
                throw new ArgumentNullException("app");
            }

            if (appEvent == AppEvent.None)
            {
                logger.Log(LogLevel.Info, "Ignoring execution on {0} as event is none", app);
                return;
            }

            Comment comment;
            FormEntry formEntry;

            logger.Log(LogLevel.Info, "Executing [{0}] for event - [{1}]", app, appEvent);

            switch (appEvent)
            {
                case AppEvent.CommentSaved:
                    comment = eventObject as Comment;
                    app.CommentSaved(comment);
                    break;

                case AppEvent.CommentSaving:
                    comment = eventObject as Comment;
                    app.CommentSaving(comment);
                    break;

                case AppEvent.CommentSpammed:
                    comment = eventObject as Comment;
                    app.CommentSpamed(comment);
                    break;

                case AppEvent.FormEntrySaving:
                    formEntry = eventObject as FormEntry;
                    app.FormEntrySaving(formEntry);
                    break;

                case AppEvent.FormEntrySaved:
                    formEntry = eventObject as FormEntry;
                    app.FormEntrySaved(formEntry);
                    break;

                case AppEvent.ImageUploaded:
                    app.ImageUploaded(eventObject as string);
                    break;
            }

            logger.Log(LogLevel.Info, "Execution [{0}] for event - [{1}] done", app, appEvent);
        }
예제 #6
0
	//Loads a view/screen, scrolls the view to the bottom if scrollTo is set to 0.0f, scrolls to a given position otherwise, default value scrolls to 1.0f (top)
	public void LoadApp(string appName, bool openOnTop = true)
	{
		//Always compare lowercase names
		appName = appName.ToLower();

		AbstractApp app = existingApps[appName];

		//If the app is not on top of the stack
		if (GetCurrentAppName() != appName) {
			//Find if it's somewhere else in the stack
			int index = stack.FindLastIndex(a => a.name == app.name);
			if (index != -1) {
				//If yes: remove it so it can be added on top of the stack
				stack.RemoveAt(index);
			}

			//Add the app to the stack
			stack.Add(app);
		} else {
			//The app is already on top of the stack: make sure we're not putting it on the top layer again by accident :o
			openOnTop = false;
		}

		//Move the app on the top layer if needed
		if (openOnTop) {
			app.transform.SetAsLastSibling();
		}

		//If there is an app on the stack already, we'll need to remember it so we can hide it when the new app opens
		AbstractApp previousApp = null;
		if (stack.Count > 1) {
			previousApp = stack[stack.Count - 2];
		}

		//Resume the app (and animate it, if it's being moved to the top layer, meaning it wasn't already visible)
		app.ResumeApp();

		//Hide the previous app (if it exists) once the new one has finished its animation
		if (previousApp != null)
		{
			previousApp.PauseApp();
		}
	}
예제 #7
0
        //如果inApp不为null, 则为编辑模式
        public EditGestureForm(GestureParser gestureParser, AbstractApp inApp, GestureIntent intent = null)
        {
            _gestureParser = gestureParser;
            _app           = inApp;
            _intent        = intent;

            InitializeComponent();

            if (_intent != null)
            {
                if (inApp.Find(intent.Gesture) != intent)
                {
                    throw new InvalidOperationException("intent必须是inApp中的");
                }
                Text                = "编辑手势";
                lb_mnemonic.Text    = _intent.Gesture.ToString();
                tb_gestureName.Text = _intent.Name;
            }
            BeginCapture();
        }
예제 #8
0
	//Back button action
	public void Back()
	{

		if (GetCurrentApp ().Back ()) {
			return;
		}

		//if there's an app to close and an app to go back to
		if (stack.Count >= 2) {
			//Close it
			GetCurrentApp().PauseApp ();
			stack.RemoveAt(stack.Count - 1);
			//Load the previous app
			AbstractApp previous = stack[stack.Count - 1];
			LoadApp (previous.name, false);
			return;
		}

		//Otherwise... Enjoy the homescreen ¯\_(ツ)_/¯
	}
예제 #9
0
        //如果inApp不为null, 则为编辑模式
        public EditGestureForm(GestureParser gestureParser, AbstractApp inApp, GestureIntent intent = null)
        {
            _gestureParser = gestureParser;
            _app = inApp;
            _intent = intent;

            InitializeComponent();

            if (_intent != null)
            {
                if (inApp.Find(intent.Gesture) != intent)
                {
                    throw new InvalidOperationException("intent必须是inApp中的");
                }
                Text = "编辑手势";
                lb_mnemonic.Text = _intent.Gesture.ToString();
                tb_gestureName.Text = _intent.Name;
            }
            BeginCapture();

        }
예제 #10
0
        private void LoadGestureIntents(AbstractApp app)
        {
            //禁用删除和修改按钮
            btn_modifyGesture.Enabled = false;
            btn_RemoveGesture.Enabled = false;

            listGestureIntents.BeginUpdate();

            //每次加载新的列表,则保存原列表元素的顺序
            ApplyListIntentsOrder();

            listGestureIntents.Items.Clear();

            if (app.GestureIntents.Count == 0)
            {
                AdjustListGestureIntentsColumnSize();

                listGestureIntents.EndUpdate();
                return;
            }

            var orderedIntents = (from i in app.GestureIntents select new OrderableIntent(i.Value)).OrderBy((o)=>o.Order).ToArray();
            app.GestureIntents.Import(orderedIntents, true);

            foreach (var gest in app.GestureIntents)//app.GestureIntents)
            {
                AddGestureIntent(gest.Value);
            }
            Debug.WriteLine("LoadGestureIntents");
            //listGestureIntents.Items[0].Selected = true;
            AdjustListGestureIntentsColumnSize();

            listGestureIntents.EndUpdate();

        }