private void initializeUserControls()
 {
     introComponent                = new IntroControl(WM);
     raceComponent                 = new RaceControl(WM);
     alignmentComponent            = new AlignmentControl(WM);
     raceComponent.SubraceChanged += new EventHandler(raceComponent_SubraceChanged);
     ageComponent        = new AgeControl(WM);
     bodyComponent       = new BodyControl(WM);
     appearanceComponent = new AppearanceControl(WM);
     appearanceComponent.AppearanceChanged += new EventHandler(appearanceComponent_AppearanceChanged);
     classComponent = new ClassControl(WM);
     classComponent.ClassChanged       += new EventHandler(classComponent_ClassChanged);
     classComponent.ClassChoiceChanged += new EventHandler(classComponent_ClassChoiceChanged);
     backgroundComponent = new BackgroundControl(WM);
     abilityComponent    = new AbilityControl(WM);
     abilityComponent.AbilityAssigned      += new EventHandler(abilityComponent_AbilityAssigned);
     abilityComponent.AbilityBonusAssigned += new EventHandler(abilityComponent_AbilityBonusAssigned);
     languageComponent = new LanguageControl(WM);
     languageComponent.LanguageSelectionChanged += new EventHandler(languageComponent_LanguageSelectionChanged);
     skillComponent              = new SkillControl(WM);
     skillComponent.SkillChosen += new EventHandler(skillComponent_SkillChosen);
     equipmentComponent          = new EquipmentControl(WM);
     equipmentComponent.EquipmentSelectionChanged += new EventHandler(equipmentComponent_EquipmentSelectionChanged);
     spellComponent              = new SpellControl(WM);
     spellComponent.SpellChosen += new EventHandler(spellComponent_SpellChosen);
     extraRaceChoiceComponent    = new ExtraRaceChoiceControl(WM);
     extraRaceChoiceComponent.ExtraRaceChoiceChanged += new EventHandler(extraRaceChoiceComponent_ExtraRaceChoiceChanged);
     extraClassChoiceComponent = new ExtraClassChoiceControl(WM);
     extraClassChoiceComponent.SubcontrolOptionChosen += new EventHandler(extraClassChoiceComponent_SubcontrolOptionChosen);
     extraSubclassChoiceComponent = new ExtraSubclassChoiceControl(WM);
     extraSubclassChoiceComponent.SubcontrolOptionChosen += new EventHandler(extraSubclassChoiceComponent_SubcontrolOptionChosen);
     nameComponent                          = new NameControl(WM);
     nameComponent.NameChanged             += new EventHandler(nameComponent_NameChanged);
     storyComponent                         = new StoryControl(WM);
     storyComponent.SubcontrolOptionChosen += new EventHandler(storyComponent_SubcontrolOptionChosen);
     exportComponent                        = new ExportControl(WM);
 }
Exemple #2
0
    protected virtual void LateUpdate()
    {
        if (Application.isPlaying && this.rendererTransforms == null)
        {
            return;
        }
        if (Application.isPlaying && (this.RenderInfo.RenderArea.width != (float)Screen.width || this.RenderInfo.RenderArea.height != (float)Screen.height))
        {
            this.OnResolutionChanged();
        }
        if (Application.isPlaying && AgeManager.AutoInit)
        {
            GL.Viewport(this.RenderInfo.RenderArea);
            GL.Clear(true, true, Color.gray);
        }
        Vector2 cursor = this.Cursor;

        if (this.ForceCursorPosition)
        {
            this.Cursor = this.ForcedCursorPosition;
        }
        else
        {
            this.Cursor   = Input.mousePosition;
            this.Cursor.y = this.RenderInfo.RenderArea.height - 1f - this.Cursor.y;
        }
        if (this.ApplicationHasFocus)
        {
            bool flag = true;
            if (this.Cursor.x < 0f || this.Cursor.x >= this.RenderInfo.RenderArea.width || this.Cursor.y < 0f || this.Cursor.y >= this.RenderInfo.RenderArea.height)
            {
                flag = false;
            }
            if (flag)
            {
                AgeControl activeControl = this.ActiveControl;
                this.ActiveControl          = null;
                this.ActiveParentTransform  = null;
                this.OverrolledTransform    = null;
                this.MouseCovered           = false;
                this.WheelGrabbed           = false;
                this.RenderInfo.LocalMatrix = false;
                if (Application.isPlaying)
                {
                    for (int i = 0; i < this.rendererTransforms.Count; i++)
                    {
                        float   num = 0f;
                        Vector2 positionOffset;
                        positionOffset.x = this.rendererTransforms[i].Position.x;
                        positionOffset.y = this.rendererTransforms[i].Position.y;
                        this.rendererTransforms[i].UpdateInteractivity(this.Cursor, positionOffset, this.rendererTransforms[i].Position, this.RenderInfo, 0f, ref num, ref this.ActiveControl, ref this.OverrolledTransform, ref this.MouseCovered, ref this.WheelGrabbed, true, false);
                        if (this.IsDebugMode)
                        {
                            Diagnostics.Log("AgeManager - ActiveControl: {0}", new object[]
                            {
                                this.ActiveControl
                            });
                            Diagnostics.Log("AgeManager - OverrolledTransform: {0}", new object[]
                            {
                                this.OverrolledTransform
                            });
                        }
                    }
                }
                if (this.ActiveControl != null && this.ActiveControl.AgeTransform != null && this.ActiveControl.AgeTransform.GetParent() != null)
                {
                    this.ActiveParentTransform = this.ActiveControl.AgeTransform.GetParent();
                }
                if (this.ActiveControl != activeControl)
                {
                    if (activeControl != null)
                    {
                        if (this.ActiveControl != null)
                        {
                            if (!this.ActiveControl.AgeTransform.IsChildOf(activeControl.AgeTransform))
                            {
                                activeControl.SendMessage("MouseLeave", this.Cursor);
                            }
                        }
                        else
                        {
                            activeControl.SendMessage("MouseLeave", this.Cursor);
                        }
                    }
                    if (this.ActiveControl != null)
                    {
                        this.ActiveControl.SendMessage("MouseEnter", this.Cursor);
                    }
                }
                this.currentMouseEventData.Cursor = this.Cursor;
                for (int j = 0; j <= 2; j++)
                {
                    this.currentMouseEventData.MouseButtonIndex = j;
                    if (Input.GetMouseButtonDown(j))
                    {
                        if (this.ActiveControl != null)
                        {
                            this.ActiveControl.SendMessage("MouseDown", this.currentMouseEventData);
                            if (j == 0)
                            {
                                this.FocusedControl = this.ActiveControl;
                            }
                        }
                        else if (j == 0)
                        {
                            this.FocusedControl = null;
                        }
                    }
                    if (Input.GetMouseButtonUp(j))
                    {
                        if (this.ActiveControl != null)
                        {
                            this.ActiveControl.SendMessage("MouseUp", this.currentMouseEventData);
                        }
                        if (this.FocusedControl != null && this.FocusedControl != this.ActiveControl)
                        {
                            this.FocusedControl.SendMessage("MouseUp", this.currentMouseEventData);
                        }
                    }
                }
                if (this.Cursor != cursor)
                {
                    if (this.ActiveControl != null)
                    {
                        this.ActiveControl.SendMessage("MouseDrag", this.Cursor - cursor);
                    }
                    if (this.FocusedControl != null && this.FocusedControl != this.ActiveControl)
                    {
                        this.FocusedControl.SendMessage("MouseDrag", this.Cursor - cursor);
                    }
                }
                float axis = Input.GetAxis(this.mouseWheelAxis);
                if (axis != 0f && this.ActiveControl != null)
                {
                    this.ActiveControl.SendMessage("MouseWheel", axis);
                }
                if (Input.anyKeyDown)
                {
                    if (this.FocusedControl != null)
                    {
                        this.FocusedControl.SendMessage("KeyDown");
                    }
                    else if (this.ActiveControl != null)
                    {
                        this.ActiveControl.SendMessage("KeyDown");
                    }
                }
                if (this.FocusedControl != null && !string.IsNullOrEmpty(Input.inputString))
                {
                    this.FocusedControl.SendMessage("KeyInput");
                }
                if (this.FocusedControl != null)
                {
                    this.FocusedControl.UpdateFocused();
                }
            }
        }
        if (Application.isPlaying)
        {
            if (this.rendererTransforms == null)
            {
                return;
            }
            for (int k = 0; k < this.rendererTransforms.Count; k++)
            {
                if (this.previousRenderArea != this.RenderInfo.RenderArea)
                {
                    this.rendererTransforms[k].DirtyPosition = true;
                    this.previousRenderArea = this.RenderInfo.RenderArea;
                }
                this.rendererTransforms[k].UpdateHierarchy(this.RenderInfo.RenderArea, false);
            }
        }
        AgeManager.LastRealtimeSinceStartup = Time.realtimeSinceStartup;
    }
 public void UpdateAge()
 {
     report.PatientData.UpdateAgeResult();
     AgeControl.UpdateValue();
 }
        public void UpdateEvent(CognitiveEvent mainEvent)
        {
            var faces = mainEvent.Faces;

            try
            {
                var task = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
                {
                    try
                    {
                        if (faces.Count() == 0)
                        {
                            textFaceTotal.Text = $"I don't see anyone!  Smile!";
                        }
                        else
                        {
                            textFaceTotal.Text = $"{faces.Count.ToString()} faces with {faces.Average(x => x.FaceAttributes.Emotion.Happiness).ToString("0.0%")} happiness";
                        }
                    }
                    catch (Exception)
                    {
                        textFaceTotal.Text = "";
                    }

                    textFaces1.Text = "";
                    textFaces2.Text = "";
                    textFaces3.Text = "";

                    if (faces.Count() >= 3)
                    {
                        ageControl1.Visibility = Visibility.Visible;
                        ageControl2.Visibility = Visibility.Visible;
                        ageControl3.Visibility = Visibility.Visible;
                    }
                    else if (faces.Count() >= 2)
                    {
                        ageControl1.Visibility = Visibility.Visible;
                        ageControl2.Visibility = Visibility.Visible;
                        ageControl3.Visibility = Visibility.Collapsed;
                    }
                    else if (faces.Count() >= 1)
                    {
                        ageControl1.Visibility = Visibility.Visible;
                        ageControl2.Visibility = Visibility.Collapsed;
                        ageControl3.Visibility = Visibility.Collapsed;
                    }
                    else if (faces.Count() >= 0)
                    {
                        ageControl1.Visibility = Visibility.Collapsed;
                        ageControl2.Visibility = Visibility.Collapsed;
                        ageControl3.Visibility = Visibility.Collapsed;
                    }
                    var facesSorted = faces.Take(3).OrderBy(x => x.FaceRectangle.Left).ToList();
                    for (int i = 0; i < facesSorted.Count(); i++)
                    {
                        var face = facesSorted[i];

                        int convertedTop  = ((face.FaceRectangle.Top * (int)captureControl.ActualHeight) / mainEvent.ImageHeight) - ((int)captureControl.Margin.Top) - ((int)ageControl1.ActualHeight);
                        int convertedLeft = (((face.FaceRectangle.Left + (face.FaceRectangle.Width / 4)) * (int)captureControl.ActualWidth) / mainEvent.ImageWidth);

                        double maxEmotion     = face.FaceAttributes.Emotion.Anger;
                        string choosenEmotion = "Anger";

                        if (face.FaceAttributes.Emotion.Contempt > maxEmotion)
                        {
                            maxEmotion     = face.FaceAttributes.Emotion.Contempt;
                            choosenEmotion = "Contempt";
                        }

                        if (face.FaceAttributes.Emotion.Disgust > maxEmotion)
                        {
                            maxEmotion     = face.FaceAttributes.Emotion.Disgust;
                            choosenEmotion = "Disgust";
                        }

                        if (face.FaceAttributes.Emotion.Fear > maxEmotion)
                        {
                            maxEmotion     = face.FaceAttributes.Emotion.Fear;
                            choosenEmotion = "Fear";
                        }

                        if (face.FaceAttributes.Emotion.Happiness > maxEmotion)
                        {
                            maxEmotion     = face.FaceAttributes.Emotion.Happiness;
                            choosenEmotion = "Happiness";
                        }

                        if (face.FaceAttributes.Emotion.Neutral > maxEmotion)
                        {
                            maxEmotion     = face.FaceAttributes.Emotion.Neutral;
                            choosenEmotion = "Neutral";
                        }

                        if (face.FaceAttributes.Emotion.Sadness > maxEmotion)
                        {
                            maxEmotion     = face.FaceAttributes.Emotion.Sadness;
                            choosenEmotion = "Sadness";
                        }

                        if (face.FaceAttributes.Emotion.Surprise > maxEmotion)
                        {
                            maxEmotion     = face.FaceAttributes.Emotion.Surprise;
                            choosenEmotion = "Surprise";
                        }
                        string hair = "";
                        if (face.FaceAttributes.Hair.Bald > .6)
                        {
                            hair = "bald";
                        }
                        else
                        {
                            if (face.FaceAttributes.Hair.HairColor.Count > 0)
                            {
                                hair = face.FaceAttributes.Hair.HairColor.First().Color.ToString();
                            }
                        }
                        string userInfo = $"Emotion: {choosenEmotion} \nGlasses: {face.FaceAttributes.Glasses.ToString()} \nSmile: {face.FaceAttributes.Smile.ToString()} \nHair: {hair} ";

                        AgeControl ageControl = null;

                        switch (i)
                        {
                        case 0:
                            ageControl      = ageControl1;
                            textFaces1.Text = userInfo;
                            break;

                        case 1:
                            ageControl      = ageControl2;
                            textFaces2.Text = userInfo;
                            break;

                        case 2:
                            ageControl      = ageControl3;
                            textFaces3.Text = userInfo;
                            break;
                        }

                        if (ageControl == null)
                        {
                            break;
                        }

                        ageControl.Margin     = new Thickness(convertedLeft, convertedTop, 0, 0);
                        ageControl.Visibility = Visibility;
                        ageControl.SetUserInfo(i + 1, face.FaceAttributes.Gender.ToString(), face.FaceAttributes.Age, choosenEmotion);
                    }
                });
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                //Eat excepiton
            }
        }