public bool TryHandleInteractionEvent(IInteractionEvent args)
        {
            if (currentQuery == null)
            {
                return(false);
            }
            switch (args)
            {
            case IMouseEvent margs:
                // todo: calc point correctly (from the hittable to the click index)
                if (!margs.IsLeftClickEvent())
                {
                    break;
                }
                var point   = margs.State.NormalizedPosition;
                var hitRect = optionRects.SelectWithIndex().Where(x => x.Value.ContainsPoint(point)).FirstOrNull();
                if (!hitRect.HasValue)
                {
                    break;
                }
                var option = hitRect.Value.Key;
                currentQuery.Choose(option);
                break;

            case IKeyEvent kargs:
                break;
            }
            return(true);
        }
Beispiel #2
0
 public InteractionCase(IInteractionEvent interactionEvent, string name)
     : base("Case")
 {
     InteractionEvent = interactionEvent;
     _name            = name;
     _actions         = new InteractionActions(this);
 }
Beispiel #3
0
        protected override void DoOnAwake()
        {
            sucessEvent = new BaseInteractionEvent(this, InteractiveEventAction.SUCCESS);
            clickEvent  = new BaseInteractionEvent(this, InteractiveEventAction.CLICK);

            AddInteractiveListener(sucessListener);
            AddInteractiveListener(successAndClickListener);
        }
 public bool TryHandleInput(IInteractionEvent args)
 {
     if (args is IKeyEvent kargs)
     {
         return(TryHandleKeyboard(kargs));
     }
     return(false);
 }
 public bool TryHandleInteractionEvent(IInteractionEvent args)
 {
     if (args is IMouseEvent mouseArgs)
     {
         return(TryHandleMouseEvent(mouseArgs));
     }
     return(true);
 }
Beispiel #6
0
 public bool TryHandleInteractionEvent(IInteractionEvent args)
 {
     if (args is ICoreInterationEvent coreArgs)
     {
         OnCoreInteractionEvent(coreArgs);
     }
     return(false);
 }
Beispiel #7
0
 public bool TryHandleInteractionEvent(IInteractionEvent args)
 {
     if (condition(args))
     {
         action();
         return(true);
     }
     return(false);
 }
Beispiel #8
0
 public bool TryHandleInteractionEvent(IInteractionEvent args)
 {
     if (appModeService.Mode == AppMode.Presentation && args is IMouseEvent margs && margs.IsClickEvent())
     {
         TryHandleMouseEvent(margs);
         return(true);
     }
     return(false);
 }
 public void HandleEvent(IInteractionEvent e)
 {
     if (e.GetEventType() == InteractiveEventAction.CLICK)
     {
         successAndClickListenerText.text = "Click happened";
     }
     else if (e.GetEventType() == InteractiveEventAction.SUCCESS)
     {
         successAndClickListenerText.text = "Success happened";
     }
 }
        public bool TryHandleInteractionEvent(IInteractionEvent args)
        {
            switch (args)
            {
            case IMouseEvent mouseArgs: return(TryHandleMouseEvent(mouseArgs));

            case IKeyEvent keyboardArgs: return(TryHandleKeyEvent(keyboardArgs));

            default: return(false);
            }
        }
Beispiel #11
0
 public EventNode(IInteractionEvent eventitem)
 {
     IsExpanded       = true;
     InteractionEvent = eventitem;
     CaseCollection   = new ObservableCollection <CaseNode>();
     foreach (IInteractionCase item in eventitem.Cases)
     {
         CaseNode node = new CaseNode(item);
         node.Parent = this;
         CaseCollection.Add(node);
     }
 }
 public bool TryHandleInteractionEvent(IInteractionEvent args)
 {
     if (!(args is IMouseEvent cargs))
     {
         return(false);
     }
     if ((cargs.IsLeftClickEvent() || cargs.IsRightClickEvent()) && cargs.KeyModifiers == KeyModifiers.None)
     {
         viewService.SelectedNode = nodeBound.Node;
     }
     return(false);
 }
Beispiel #13
0
 public bool TryHandleInteractionEvent(IInteractionEvent args)
 {
     if (!(args is IMouseEvent cargs))
     {
         return(false);
     }
     if (cargs.IsLeftDoubleClickEvent() && cargs.KeyModifiers == KeyModifiers.None)
     {
         navigationService.GoToSpecific(master.Node.Id);
         return(true);
     }
     return(false);
 }
Beispiel #14
0
 public bool TryHandleInteractionEvent(IInteractionEvent args)
 {
     if (!(args is IMouseEvent cargs))
     {
         return(false);
     }
     if (cargs.IsLeftDoubleClickEvent() && cargs.KeyModifiers == KeyModifiers.None)
     {
         (args.Viewport.View as IFocusableView)?.FocusOn(master.Node.GetComponent <IFocusNodeComponent>());
         return(true);
     }
     return(false);
 }
Beispiel #15
0
 // Interaction
 public bool TryHandleInteractionEvent(IInteractionEvent args)
 {
     if (appModeServiceLazy.Value.Mode == AppMode.Presentation)
     {
         foreach (var element in presentationInteractionElems)
         {
             if (element.TryHandleInteractionEvent(args))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
        // Interaction
        public bool TryHandleInteractionEvent(IInteractionEvent args)
        {
            if (!(args is IMouseEvent margs))
            {
                return(false);
            }

            if (margs.IsLeftDoubleClickEvent() && margs.KeyModifiers == KeyModifiers.None)
            {
                viewService.MainView.FocusOn(ReferencedNode.GetComponent <IFocusNodeComponent>());
                return(true);
            }

            if ((margs.IsLeftClickEvent() || margs.IsRightClickEvent()) && margs.KeyModifiers == KeyModifiers.None)
            {
                viewService.SelectedNode = ReferencedNode;
                return(true);
            }

            return(false);
        }
 public bool TryHandleInteractionEvent(IInteractionEvent args)
 {
     if (!(args is IMouseEvent margs))
     {
         return(false);
     }
     if (margs.ComplexEventType != MouseEventType.Wheel || margs.KeyModifiers != KeyModifiers.Control)
     {
         return(false);
     }
     RealScrollAmount += margs.WheelDelta * 0.01f;
     if (RealScrollAmount < 0.2f)
     {
         RealScrollAmount = 0.2f;
     }
     if (RealScrollAmount > 0.8f)
     {
         RealScrollAmount = 0.8f;
     }
     return(true);
 }
        public bool TryHandleInteractionEvent(IInteractionEvent args)
        {
            if (active)
            {
                return(true);
            }

            if (!(args is IMouseEvent margs))
            {
                return(false);
            }

            if (!margs.IsLeftDoubleClickEvent() || margs.KeyModifiers != KeyModifiers.None)
            {
                return(false);
            }

            originalTransform = Node.Transform;
            startTime         = lastTime;
            active            = true;
            return(true);
        }
 // Interaction
 public bool TryHandleInteractionEvent(IInteractionEvent args)
 {
     return(appModeServiceLazy.Value.Mode == AppMode.Editing &&
            selectInteractionELement.TryHandleInteractionEvent(args));
 }
 // Interaction
 public bool TryHandleInteractionEvent(IInteractionEvent args)
 {
     return(appModeServiceLazy.Value.Mode == AppMode.Editing &&
            editInteractionElems.Any(element => element.TryHandleInteractionEvent(args)));
 }
 // Interaction
 public bool TryHandleInteractionEvent(IInteractionEvent args) => interactionElement.TryHandleInteractionEvent(args);
 // Interaction
 public bool TryHandleInteractionEvent(IInteractionEvent args)
 {
     return(interactionElems.Any(elem => elem.TryHandleInteractionEvent(args)));
 }
Beispiel #23
0
 public JsEvent(HtmlServiceProvider service, IInteractionEvent iEvent)
 {
     _service = service;
     _event   = iEvent;
 }
Beispiel #24
0
 public void HandleEvent(IInteractionEvent e)
 {
     successListenerText.text = "Success happened";
 }
Beispiel #25
0
        private void OnEvent(IInteractionEvent interactionEvent)
        {
            if (!(interactionEvent is IInputEvent inputEvent))
            {
                return;
            }
            locksToRelease.Clear();
            foreach (var inputLock in inputLocks)
            {
                var result = inputLock.ProcessEvent(inputEvent);
                if ((result & InputEventProcessResult.StopPropagating) != 0)
                {
                    return;
                }
                if ((result & InputEventProcessResult.ReleaseLock) != 0)
                {
                    locksToRelease.Add(inputLock);
                }
            }
            foreach (var inputLock in locksToRelease)
            {
                inputLocks.Remove(inputLock);
            }

            if (toolService.CurrentTool != null)
            {
                var tool = toolService.CurrentTool;
                if (tool.TryHandleInputEvent(inputEvent))
                {
                    return;
                }
            }

            if (dirtyHackServiceLazy.Value.TryHandleInput(inputEvent))
            {
                return;
            }

            //if (abstractArgs is IMouseEventArgs mouseArgs)
            //    OnMouseEvent(mouseArgs);
            //else if (abstractArgs is IKeyEventArgs keyboardArgs)
            //    OnKeyEvent(keyboardArgs);
            // todo: return if handled

            if (inputEvent.Viewport?.View.TryHandleInput(inputEvent) ?? false)
            {
                return;
            }

            if (inputEvent.Viewport != null && inputEvent is IMouseEvent margs)
            {
                var hitSomething = false;
                foreach (var layer in inputEvent.Viewport.View.Layers)
                {
                    var clickInfo  = new RayCastInfo(margs.Viewport, layer, margs.State.Position);
                    var hitResults = rayHitIndex.CastRay(clickInfo);
                    // todo: introduce different levels of stopping propagation and remove '.Take(1)'
                    foreach (var hitResult in hitResults.Take(1))
                    {
                        hitSomething       = true;
                        margs.RayHitResult = hitResult;
                        foreach (var interactionElement in hitResult.Node.SearchComponents <IInteractionComponent>())
                        {
                            if (interactionElement.TryHandleInteractionEvent(margs))
                            {
                                return;
                            }
                        }
                    }
                    margs.RayHitResult = null;
                    if (layer.Camera is IControlledCamera controlledCamera && controlledCamera.TryHandleInput(inputEvent))
                    {
                        return;
                    }
                }
                if (margs.IsLeftClickEvent() && margs.KeyModifiers == KeyModifiers.None && !hitSomething)
                {
                    viewService.SelectedNode = null;
                }
            }

            if (inputEvent is IKeyEvent kargs && viewService.SelectedNode != null)
            {
                foreach (var interactionElement in viewService.SelectedNode.Node.SearchComponents <IInteractionComponent>())
                {
                    if (interactionElement.TryHandleInteractionEvent(kargs))
                    {
                        return;
                    }
                }
            }

            navigationService.TryHandleInput(inputEvent);
        }
Beispiel #26
0
        private void LoadActions()
        {
            List <IWidgetPropertyData> list = SelectionService.GetSelectedWidgets();

            if (_currentPage == null ||
                list == null ||
                list.Count != 1 ||
                !(list.ElementAt(0) is WidgetViewModBase) ||
                (list.ElementAt(0) as WidgetViewModBase).IsGroup ||
                (list.ElementAt(0) as WidgetViewModBase).Type == ObjectType.Master)
            {
                // Only support one selected widget.
                DisableInteraction();
                return;
            }

            IWidget widget = _currentPage.Widgets.GetWidget(list[0].WidgetID);

            if (widget == null || _selectedWidget == widget ||
                widget.WidgetType == WidgetType.HamburgerMenu ||
                widget.WidgetType == WidgetType.DynamicPanel ||
                widget.WidgetType == WidgetType.Toast)
            {
                // Selected item is not widget, or the same widget
                DisableInteraction();
                return;
            }

            CanEdit = true;
            // Selected widget changed, get or create action from new widget.
            _widgetOpenAction     = null;
            _widgetShowHideAction = null;
            _selectedWidget       = widget;

            IInteractionEvent clickEvent = widget.Events[EventType.OnClick];

            if (clickEvent == null)
            {
                return;
            }

            //Create action
            IInteractionCase clickCase = clickEvent.Cases["clickCase"];

            if (clickCase == null)
            {
                clickCase = clickEvent.CreateCase("clickCase");
            }

            // For now, we only have a open action in exsiting case
            foreach (IInteractionAction action in clickCase.Actions)
            {
                if (action != null)
                {
                    if (action.ActionType == ActionType.OpenAction)
                    {
                        _widgetOpenAction = action as IInteractionOpenAction;
                        LoadWidgetInteraction();
                    }
                    else if (action.ActionType == ActionType.ShowHideAction)
                    {
                        _widgetShowHideAction = action as IInteractionShowHideAction;
                        LoadPageWidgets();
                    }
                }
            }

            if (_widgetOpenAction == null)
            {
                _widgetOpenAction = clickCase.CreateAction(ActionType.OpenAction) as IInteractionOpenAction;
                LoadWidgetInteraction();
            }

            if (_widgetShowHideAction == null)
            {
                _widgetShowHideAction = clickCase.CreateAction(ActionType.ShowHideAction) as IInteractionShowHideAction;
                //_widgetShowHideAction.AddTargetObject(widget.Guid); // Add the widget to the target list by default.
                LoadPageWidgets();
            }
        }
 public void HandleEvent(IInteractionEvent e)
 {
     ResetInteractive();
 }
 // Interaction
 public bool TryHandleInteractionEvent(IInteractionEvent args)
 {
     return(false);
 }
 public bool TryHandleInteractionEvent(IInteractionEvent args)
 {
     return(tryHandle(args));
 }
Beispiel #30
0
        protected override void RunInternal()
        {
            Program.Service.NewDocument(DocumentType.Standard);
            IDocument document = Program.Service.Document;

            IMasterPage masterPage     = document.CreateMasterPage("Master 1");
            ITreeNode   masterPageNode = document.DocumentSettings.LayoutSetting.MasterPageTree.AddChild(TreeNodeType.MasterPage);

            masterPageNode.AttachedObject = masterPage;
            masterPage.Open();
            IPageView masterBaseView = masterPage.PageViews[document.AdaptiveViewSet.Base.Guid];

            IButton button = masterBaseView.CreateWidget(WidgetType.Button) as IButton;

            button.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString());

            // Size
            button.WidgetStyle.Height = 30;
            button.WidgetStyle.Width  = 100;

            // Location
            button.WidgetStyle.X = 0;
            button.WidgetStyle.Y = 0;
            button.WidgetStyle.Z = 0;

            // Text things
            button.Name    = "Button 1";
            button.Text    = "Button";
            button.Tooltip = "Html button.";

            IImage image = masterBaseView.CreateWidget(WidgetType.Image) as IImage;

            image.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString());
            image.WidgetStyle.Height = 267;
            image.WidgetStyle.Width  = 116;
            image.WidgetStyle.X      = 150;
            image.WidgetStyle.Y      = 100;
            image.WidgetStyle.Z      = 5;
            image.Name    = "4.png";
            image.Tooltip = "A png image has 116 x 267 in size";

            // It is a png image by default. Set image stream
            string imageFile = Path.Combine(Program.WORKING_IMAGES_DIRECTORY, "HangGame", "4.png");

            if (File.Exists(imageFile))
            {
                using (FileStream fileStream = new FileStream(imageFile, FileMode.Open, FileAccess.Read))
                {
                    MemoryStream imageStream = new MemoryStream();
                    fileStream.CopyTo(imageStream);
                    image.ImageStream = imageStream;
                }
            }

            IShape lable = masterBaseView.CreateWidget(WidgetType.Shape) as IShape;

            lable.ShapeType = ShapeType.Paragraph;
            lable.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString());
            lable.WidgetStyle.Height = 100;
            lable.WidgetStyle.Width  = 200;
            lable.WidgetStyle.X      = 350;
            lable.WidgetStyle.Y      = 300;
            lable.WidgetStyle.Z      = 9;
            lable.Name    = "Label 1";
            lable.Tooltip = "A label.";
            lable.SetRichText("Label");

            List <Guid> guidList = new List <Guid>();

            guidList.Add(image.Guid);
            guidList.Add(lable.Guid);
            masterBaseView.CreateGroup(guidList);

            IDocumentPage page     = document.CreatePage("Page 1");
            ITreeNode     pageNode = document.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page);

            pageNode.AttachedObject = page;
            page.Open();
            IPageView baseView = page.PageViews[document.AdaptiveViewSet.Base.Guid];

            IMaster master = baseView.CreateMaster(masterPage.Guid);

            IShape triangle = baseView.CreateWidget(WidgetType.Shape) as IShape;

            triangle.ShapeType = ShapeType.Triangle;
            triangle.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString());
            triangle.WidgetStyle.Height = 100;
            triangle.WidgetStyle.Width  = 100;
            triangle.WidgetStyle.X      = 650;
            triangle.WidgetStyle.Y      = 300;
            triangle.WidgetStyle.Z      = 11;
            triangle.Name    = "Triangle_Show_Hide";
            triangle.Tooltip = "A Triangle to triger Show or Hide.";
            triangle.SetRichText("Triangle_Show_Hide");

            IInteractionEvent          iEvent = triangle.Events[EventType.OnClick];
            IInteractionCase           iCase  = iEvent.CreateCase("clickCase");
            IInteractionShowHideAction action = iCase.CreateAction(ActionType.ShowHideAction) as IInteractionShowHideAction;

            action.AddTargetObject(master.Guid);
            action.SetAllVisibilityType(VisibilityType.Toggle);
            action.SetAllAnimateType(ShowHideAnimateType.SlideRight);
            action.SetAllAnimateTime(500);

            ISerializeWriter writer = document.CreateSerializeWriter(document.AdaptiveViewSet.Base.Guid);

            writer.AddWidget(triangle);
            writer.AddMaster(master);
            Stream stream = writer.WriteToStream();

            // Create another document
            DocumentService Service = new DocumentService();

            Service.NewDocument(DocumentType.Standard);
            IDocument document2 = Service.Document;

            IDocumentPage page2     = document2.CreatePage("Page 1");
            ITreeNode     pageNode2 = document2.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page);

            pageNode2.AttachedObject = page2;
            page2.Open();
            IPageView baseView2 = page2.PageViews[document2.AdaptiveViewSet.Base.Guid];

            baseView2.AddObjects(stream);

            string target = Path.Combine(Program.WORKING_DIRECTORY, _caseName + "_Target.pn");

            Service.Save(target);
            Service.Close();

            string source = Path.Combine(Program.WORKING_DIRECTORY, _caseName + "_Source.pn");

            Program.Service.Save(source);
            Program.Service.Close();
        }