Ejemplo n.º 1
0
        public bool GetFileList(string directory, string searchPattern)
        {
            bool success = true;

            m_vm.files.Clear();

            try
            {
                string[] allFiles = Directory.GetFiles(directory, searchPattern);
                foreach (string filename in allFiles)
                {
                    ImageFileViewer_Struct item = new ImageFileViewer_Struct(filename, System.IO.Path.GetFileNameWithoutExtension(filename));
                    m_vm.files.Add(item);
                }
            }
            catch (Exception ex)
            {
                success        = false;
                m_lastErrorMsg = ex.Message;
            }

            return(success);
        }
Ejemplo n.º 2
0
        private void FileListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (FileListBox.SelectedItem.GetType() == typeof(ImageFileViewer_Struct))
            {
                ImageFileViewer_Struct item = (ImageFileViewer_Struct)FileListBox.SelectedItem;
                string filename             = item.fullPath;
                string display = item.displayName;

                m_imageData = Zip.Decompress_File(filename);

                if (m_imageData != null)
                {
                    ushort width  = (ushort)Math.Sqrt(m_imageData.Length);
                    ushort height = width;

                    if (width != m_vm.width || height != m_vm.height)
                    {
                        m_vm.width  = width;
                        m_vm.height = height;
                        m_vm.bitmap = BitmapFactory.New(m_vm.width, m_vm.height);
                    }

                    m_imageTool.PostFullGrayscaleImage(m_imageData, width, height);

                    m_imageTool.Convert_GrayscaleToColor(m_rangeLower, m_rangeUpper);

                    m_imageTool.Download_ColorImage(out m_colorImageData, m_vm.width, m_vm.height);

                    // display the image
                    Int32Rect displayRect = new Int32Rect(0, 0, m_vm.width, m_vm.height);
                    m_vm.bitmap.Lock();
                    m_vm.bitmap.WritePixels(displayRect, m_colorImageData, m_vm.width * 4, 0);
                    m_vm.bitmap.Unlock();
                }
            }
        }