Наследование: System.Windows.Data.IValueConverter
        private void StackPanel_MouseLeave(object sender, MouseEventArgs e)
        {
            Border border = (Border)((StackPanel)sender).Parent;
            var    image  = ((StackPanel)sender).Children.OfType <Image>().FirstOrDefault();
            NameToResourceConverter conv = new NameToResourceConverter();

            stopGif(image);
            var img = new BitmapImage();

            img.BeginInit();
            img.UriSource = (Uri)conv.Convert(((StackPanel)sender).Name, null, "jpg", null);
            img.EndInit();
            ImageBehavior.SetAnimatedSource(image, img);

            if (!isStackPanelSelected(border))
            {
                border.BorderBrush = Brushes.White;
            }

            int classifersCount = Classifiers.Count;

            if (classifersCount == 6)
            {
                txtBlkInfo.Text = String.Format(DONEMSG, classifersCount);
            }
            else
            {
                txtBlkInfo.Text = String.Format(ACTIVEMSG, classifersCount, 6 - classifersCount);
            }
        }
Пример #2
0
        private BitmapImage loadImage(string name, string extension = "png")
        {
            NameToResourceConverter conv = new NameToResourceConverter();
            var pngURI = conv.Convert(name, null, extension, null);
            var img    = new BitmapImage();

            img.BeginInit();
            img.UriSource = (Uri)pngURI;
            img.EndInit();
            return(img);
        }
        private void StackPanel_MouseEnter(object sender, MouseEventArgs e)
        {
            Border border = (Border)((StackPanel)sender).Parent;
            if (!isStackPanelSelected(border)) 
                border.BorderBrush = Brushes.Coral;
            var image = ((StackPanel)sender).Children.OfType<Image>().FirstOrDefault();
            NameToResourceConverter conv = new NameToResourceConverter();
            var gifUri = conv.Convert(((StackPanel)sender).Name, null, "gif", null);

            var img = new BitmapImage();
            img.BeginInit();
            img.UriSource = (Uri) gifUri;
            img.EndInit();
            ImageBehavior.SetAnimatedSource(image, img);
            playGif(image);
        }
Пример #4
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);
                }
                
            }
 

        }
Пример #5
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);
                }
            }
        }
        private void StackPanel_MouseLeave(object sender, MouseEventArgs e)
        {
            Border border = (Border)((StackPanel)sender).Parent;
            var image = ((StackPanel)sender).Children.OfType<Image>().FirstOrDefault();
            NameToResourceConverter conv = new NameToResourceConverter();
            stopGif(image);
            var img = new BitmapImage();
            img.BeginInit();
            img.UriSource = (Uri)conv.Convert(((StackPanel)sender).Name, null, "jpg", null);
            img.EndInit();
            ImageBehavior.SetAnimatedSource(image, img);

            if (!isStackPanelSelected(border)) 
                border.BorderBrush = Brushes.White;

            //int classifersCount = Classifiers.Count;
            //if (classifersCount == 6) txtBlkInfo.Text = String.Format(DONEMSG, classifersCount);
            //else txtBlkInfo.Text = String.Format(ACTIVEMSG, classifersCount, 6 - classifersCount);
        }
        private void StackPanel_MouseEnter(object sender, MouseEventArgs e)
        {
            Border border = (Border)((StackPanel)sender).Parent;

            if (!isStackPanelSelected(border))
            {
                border.BorderBrush = Brushes.Coral;
            }
            var image = ((StackPanel)sender).Children.OfType <Image>().FirstOrDefault();
            NameToResourceConverter conv = new NameToResourceConverter();
            var gifUri = conv.Convert(((StackPanel)sender).Name, null, "gif", null);

            var img = new BitmapImage();

            img.BeginInit();
            img.UriSource = (Uri)gifUri;
            img.EndInit();
            ImageBehavior.SetAnimatedSource(image, img);
            playGif(image);
        }
Пример #8
0
 private BitmapImage loadImage(string name, string extension="png")
 {
     NameToResourceConverter conv = new NameToResourceConverter();
     var pngURI = conv.Convert(name, null, extension, null);
     var img = new BitmapImage();
     img.BeginInit();
     img.UriSource = (Uri)pngURI;
     img.EndInit();
     return img;
 }