Ejemplo n.º 1
0
        private void UpdateClassifier(TextBlock txtClassifier, TextBlock txtClassifierValue,
                                      TextBlock txtClassifierValueBackground, String classifierName, int classifierIndex)
        {
            try
            {
                UpperCaseConverter conv = new UpperCaseConverter();
                txtClassifier.Text = (String)conv.Convert(classifierName, null, null, null);
                int classifierValue = mAffdexClassifierValues[(int)classifierIndex];

                // Calculate the width
                double width = ClassiferValueDisplayLength * Math.Abs(classifierValue) / 100;

                var backgroundColor = Colors.Transparent;

                if (classifierValue > 0)
                {
                    backgroundColor = Colors.LimeGreen;
                }
                else if (classifierValue < 0)
                {
                    backgroundColor = Colors.Red;
                }

                txtClassifierValueBackground.Background = new SolidColorBrush(backgroundColor);
                txtClassifierValueBackground.Width      = width;
                txtClassifierValue.Text = String.Format("{0}%", classifierValue);
            }
            catch (Exception ex)
            {
                String message = String.IsNullOrEmpty(ex.Message) ? "AffdexMe error encountered." : ex.Message;
                ShowExceptionAndShutDown(message);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DrawingCanvas"/> class.
        /// </summary>
        public DrawingCanvas()
        {

            DrawMetrics = true;
            DrawPoints = true;
            DrawAppearance = true;
            DrawEmojis = true;
            boundingBrush = new SolidColorBrush(Colors.LightGray);
            pointBrush = new SolidColorBrush(Colors.Cornsilk);
            emojiBrush = new SolidColorBrush(Colors.Black);
            pozMetricBrush = new SolidColorBrush(Colors.LimeGreen);
            negMetricBrush = new SolidColorBrush(Colors.Red);
            boundingPen = new Pen(boundingBrush, 1);

            NameToResourceConverter conv = new NameToResourceConverter();
            metricTypeFace = Fonts.GetTypefaces((Uri)conv.Convert("Square", null, "ttf", null)).First();
            
            Faces = new Dictionary<int, Affdex.Face>();
            emojiImages = new Dictionary<Affdex.Emoji, BitmapImage>();
            appImgs = new Dictionary<string, BitmapImage>();
            MetricNames = new StringCollection();
            upperConverter = new UpperCaseConverter();
            maxTxtWidth = 0;
            maxTxtHeight = 0;

            var emojis = Enum.GetValues(typeof(Affdex.Emoji));
            foreach (int emojiVal in emojis)
            {
                BitmapImage img = loadImage(emojiVal.ToString());
                emojiImages.Add((Affdex.Emoji) emojiVal, img);
            }

            var gender = Enum.GetValues(typeof(Affdex.Gender));
            foreach (int genderVal in gender)
            {
                for (int g = 0; g <= 1 ; g++)
                {
                    string name = ConcatInt(genderVal, g);
                    BitmapImage img = loadImage(name);
                    appImgs.Add(name, img);
                }
                
            }
 

        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DrawingCanvas"/> class.
        /// </summary>
        public DrawingCanvas()
        {
            DrawMetrics    = true;
            DrawPoints     = true;
            DrawAppearance = true;
            DrawEmojis     = true;
            boundingBrush  = new SolidColorBrush(Colors.LightGray);
            pointBrush     = new SolidColorBrush(Colors.Cornsilk);
            emojiBrush     = new SolidColorBrush(Colors.Black);
            pozMetricBrush = new SolidColorBrush(Colors.LimeGreen);
            negMetricBrush = new SolidColorBrush(Colors.Red);
            boundingPen    = new Pen(boundingBrush, 1);

            NameToResourceConverter conv = new NameToResourceConverter();

            metricTypeFace = Fonts.GetTypefaces((Uri)conv.Convert("Square", null, "ttf", null)).First();

            Faces          = new Dictionary <int, Affdex.Face>();
            emojiImages    = new Dictionary <Affdex.Emoji, BitmapImage>();
            appImgs        = new Dictionary <string, BitmapImage>();
            MetricNames    = new StringCollection();
            upperConverter = new UpperCaseConverter();
            maxTxtWidth    = 0;
            maxTxtHeight   = 0;

            var emojis = Enum.GetValues(typeof(Affdex.Emoji));

            foreach (int emojiVal in emojis)
            {
                BitmapImage img = loadImage(emojiVal.ToString());
                emojiImages.Add((Affdex.Emoji)emojiVal, img);
            }

            var gender = Enum.GetValues(typeof(Affdex.Gender));

            foreach (int genderVal in gender)
            {
                for (int g = 0; g <= 1; g++)
                {
                    string      name = ConcatInt(genderVal, g);
                    BitmapImage img  = loadImage(name);
                    appImgs.Add(name, img);
                }
            }
        }
Ejemplo n.º 4
0
        private void UpdateClassifier(TextBlock txtClassifier, TextBlock txtClassifierValue, 
                                      TextBlock txtClassifierValueBackground, String classifierName, int classifierIndex)
        {
            try
            {
                UpperCaseConverter conv = new UpperCaseConverter();
                txtClassifier.Text = (String)conv.Convert(classifierName, null, null, null);
                int classifierValue = mAffdexClassifierValues[(int)classifierIndex];

                // Calculate the width
                double width = ClassiferValueDisplayLength * Math.Abs(classifierValue) / 100;

                var backgroundColor = Colors.Transparent;

                if (classifierValue > 0)
                {
                    backgroundColor = Colors.LimeGreen;
                }
                else if (classifierValue < 0)
                {
                    backgroundColor = Colors.Red;
                }

                txtClassifierValueBackground.Background = new SolidColorBrush(backgroundColor);
                txtClassifierValueBackground.Width = width;
                txtClassifierValue.Text = String.Format("{0}%", classifierValue);
            }
            catch (Exception ex)
            {
                String message = String.IsNullOrEmpty(ex.Message) ? "AffdexMe error encountered." : ex.Message;
                ShowExceptionAndShutDown(message);
            }
        }