Inheritance: System.Windows.Controls.UserControl
コード例 #1
0
ファイル: SurfaceWindow1.xaml.cs プロジェクト: hcilab-um/STim
        void LoadItems()
        {
            //images = Directory.GetFiles("C:\\Users\\Public\\Pictures\\Sample Pictures", "*.*", SearchOption.AllDirectories)
            images = Directory.GetFiles("C:\\museumNum", "*.*", SearchOption.AllDirectories)
                         .Where(s => s.EndsWith(".jpg")
                             || s.EndsWith(".jpeg")
                             || s.EndsWith(".png")
                             || s.EndsWith(".gif")
                             || s.EndsWith(".tif"));
            if (images.Count() % num_img_per_load == 0)
                total_rounds = images.Count() / num_img_per_load;
            else
                total_rounds = images.Count() / num_img_per_load + 1;

            /*
            var videos = Directory.GetFiles("C:\\Users\\Public\\Videos\\Sample Videos", "*.*", SearchOption.AllDirectories)
                         .Where(s => s.EndsWith(".wmv")
                             || s.EndsWith(".mp4"));
            */
            /*
            foreach (var imagePath in images)
            {
                var imageControl = new ImageViewer();
                var myBitmapImage = new BitmapImage();
                myBitmapImage.BeginInit();
                myBitmapImage.UriSource = new Uri(imagePath);
                myBitmapImage.EndInit();
                imageControl.Source = myBitmapImage;
                imageControl.file_name = imagePath.Substring(imagePath.LastIndexOf("\\") + 1, imagePath.IndexOf(".") - (imagePath.LastIndexOf("\\") + 1));
                //Console.WriteLine("file name: " + imageControl.file_name);
                if (descriptions.ContainsKey(imageControl.file_name))
                    imageControl.TextLabel.Content = descriptions[imageControl.file_name];
                else
                    imageControl.TextLabel.Content = "No Description";

                ScatterViewItem scatterViewItem = new ScatterViewItem();
                scatterViewItem.Content = imageControl;
                ScatterContainer.Items.Add(scatterViewItem);
            }*/
            for (int i = round; i < num_img_per_load; i++)
            {
                var imagePath = images.ElementAt(i);
                var imageControl = new ImageViewer();
                var myBitmapImage = new BitmapImage();
                myBitmapImage.BeginInit();
                myBitmapImage.UriSource = new Uri(imagePath);
                myBitmapImage.EndInit();
                imageControl.Source = myBitmapImage;
                imageControl.file_name = imagePath.Substring(imagePath.LastIndexOf("\\") + 1, imagePath.IndexOf(".") - (imagePath.LastIndexOf("\\") + 1));
                //Console.WriteLine("file name: " + imageControl.file_name);
                if (descriptions.ContainsKey(imageControl.file_name))
                    imageControl.TextLabel.Content = descriptions[imageControl.file_name];
                else
                    imageControl.TextLabel.Content = "No Description";

                ScatterViewItem scatterViewItem = new ScatterViewItem();
                scatterViewItem.Content = imageControl;
                ScatterContainer.Items.Add(scatterViewItem);
            }
            round++;

            /*
            foreach (var videoPath in videos)
            {
                var videoControl = new VideoPlayer { Source = videoPath, parent = this};
                var scatterView = new ScatterViewItem();
                scatterView.Content = videoControl;
                videoControl.OnVideoPlayerPlayed += videoControl_OnVideoPlayerPlayed;
                videoControl.OnVideoPlayerStopped += videoControl_VideoStopped;

                ScatterContainer.Items.Add(scatterView);
                _videoPlayers.Add(videoControl);
            }*/
        }
コード例 #2
0
ファイル: SurfaceWindow1.xaml.cs プロジェクト: hcilab-um/STim
        private void LoadButton_Click(object sender, RoutedEventArgs e)
        {
            ScatterContainer.Items.Clear();
            int n;
            if (round * num_img_per_load + num_img_per_load < images.Count())
                n = round * num_img_per_load + num_img_per_load;
            else
                n = images.Count();
            for (int i = round * num_img_per_load; i < n; i++)
            {
                var imagePath = images.ElementAt(i);
                var imageControl = new ImageViewer();
                var myBitmapImage = new BitmapImage();
                myBitmapImage.BeginInit();
                myBitmapImage.UriSource = new Uri(imagePath);
                myBitmapImage.EndInit();
                imageControl.Source = myBitmapImage;
                imageControl.file_name = imagePath.Substring(imagePath.LastIndexOf("\\") + 1, imagePath.IndexOf(".") - (imagePath.LastIndexOf("\\") + 1));
                //Console.WriteLine("file name: " + imageControl.file_name);
                if (descriptions.ContainsKey(imageControl.file_name))
                    imageControl.TextLabel.Content = descriptions[imageControl.file_name];

                else
                    imageControl.TextLabel.Content = "No Description";

                ScatterViewItem scatterViewItem = new ScatterViewItem();
                scatterViewItem.Content = imageControl;
                ScatterContainer.Items.Add(scatterViewItem);
            }
            round++;
            if (round >= total_rounds)
                round = 0;
        }