private List <string> GetExifList(CoreImageInfo currentImageInfo, Strings s)
        {
            List <string> exifList = new List <string>();

            if (!String.IsNullOrEmpty(currentImageInfo.exifInfo.imageDescription))
            {
                exifList.Add(s.ImagePreviewPanel_EXIF_Tooltip_ImageDescription + currentImageInfo.exifInfo.imageDescription);
            }
            if (!String.IsNullOrEmpty(currentImageInfo.exifInfo.equipMake))
            {
                exifList.Add(s.ImagePreviewPanel_EXIF_Tooltip_EquipMake + currentImageInfo.exifInfo.equipMake);
            }
            if (!String.IsNullOrEmpty(currentImageInfo.exifInfo.equipModel))
            {
                exifList.Add(s.ImagePreviewPanel_EXIF_Tooltip_EquipModel + currentImageInfo.exifInfo.equipModel);
            }
            if (!String.IsNullOrEmpty(currentImageInfo.exifInfo.softwareUsed))
            {
                exifList.Add(s.ImagePreviewPanel_EXIF_Tooltip_SoftwareUsed + currentImageInfo.exifInfo.softwareUsed);
            }
            if (!String.IsNullOrEmpty(currentImageInfo.exifInfo.dateTime))
            {
                exifList.Add(s.ImagePreviewPanel_EXIF_Tooltip_DateTime + currentImageInfo.exifInfo.dateTime);
            }
            if (!String.IsNullOrEmpty(currentImageInfo.exifInfo.artist))
            {
                exifList.Add(s.ImagePreviewPanel_EXIF_Tooltip_Artist + currentImageInfo.exifInfo.artist);
            }
            if (!String.IsNullOrEmpty(currentImageInfo.exifInfo.userComment))
            {
                exifList.Add(s.ImagePreviewPanel_EXIF_Tooltip_UserComment + currentImageInfo.exifInfo.userComment);
            }
            return(exifList);
        }
Exemple #2
0
 public CoreResult(ref CoreDll.adResultW result)
 {
     type       = result.type;
     first      = new CoreImageInfo(ref result.first);
     second     = new CoreImageInfo(ref result.second);
     defect     = result.defect;
     difference = result.difference;
     transform  = result.transform;
     group      = result.group.ToInt32();
     groupSize  = result.groupSize.ToInt32();
     hint       = result.hint;
 }
 /// <summary>
 /// Проверяет, нужно ли обновление текущей информации об изображении.
 /// </summary>
 static private bool UpdateImageInfo(ref CoreImageInfo oldImageInfo, CoreImageInfo newImageInfo)
 {
     if (oldImageInfo == null ||
         oldImageInfo.path.CompareTo(newImageInfo.path) != 0 ||
         oldImageInfo.size != newImageInfo.size ||
         oldImageInfo.time != newImageInfo.time)
     {
         oldImageInfo = newImageInfo;
         return(true);
     }
     return(false);
 }
Exemple #4
0
        private void SetImageInfo()
        {
            CoreImageInfo info = m_group.images[m_index];

            m_fileSizeLabel.Text  = info.GetFileSizeString();
            m_imageSizeLabel.Text = string.Format("{0}×{1}", info.width, info.height);
            m_imageTypeLabel.Text = (info.type == CoreDll.ImageType.None ? "   " : info.GetImageTypeString());
            m_fileNameLabel.Text  = Path.GetFileNameWithoutExtension(info.path);

            bool[] selected = m_core.GetSelection(m_group.id, (uint)m_index, 1);
            m_checkBox.Checked = selected[0];
        }
Exemple #5
0
        public void UpdateImage(CoreImageInfo currentImageInfo)
        {
            if (m_originalBitmap != null)
            {
                m_originalBitmap.Dispose();
                m_originalBitmap = null;
            }
            m_currentImageInfo = currentImageInfo;
            if (currentImageInfo != null)
            {
                StopAnimate();
                if (m_currentImageInfo.type != CoreDll.ImageType.None)
                {
                    if (m_currentImageInfo.path.Length < MAX_PATH && m_currentImageInfo.type <= CoreDll.ImageType.Icon)
                    {
                        try
                        {
                            if (LoadFileToMemoryStream(ref m_memoryStream, m_currentImageInfo.path))
                            {
                                m_bitmap          = new Bitmap(m_memoryStream);
                                m_animationEnable = ImageAnimator.CanAnimate(m_bitmap);
                                if (m_animationEnable)
                                {
                                    m_currentlyAnimating = false;
                                }
                            }
                            else
                            {
                                m_bitmap = null;
                            }
                        }
                        catch
                        {
                            m_bitmap = m_core.LoadBitmap(m_currentImageInfo);
                        }
                    }
                    else
                    {
                        m_bitmap = m_core.LoadBitmap(m_currentImageInfo);
                    }
                }
                else
                {
                    m_bitmap = null;
                }

                if (m_options.resultsOptions.ShowNeighboursImages)
                {
                    ShowNeighboursImages(true);
                }
            }
        }
Exemple #6
0
        private Size GetThumbnailSize(CoreImageInfo imageInfo)
        {
            Size sizeMax = m_options.resultsOptions.thumbnailSizeMax;

            if (sizeMax.Width * imageInfo.height > sizeMax.Height * imageInfo.width)
            {
                return(new Size(sizeMax.Width, (int)(sizeMax.Height * imageInfo.height / imageInfo.width)));
            }
            else
            {
                return(new Size((int)(sizeMax.Width * imageInfo.width / imageInfo.height), sizeMax.Height));
            }
        }
Exemple #7
0
        /// <summary>
        /// Загружаем в хранилише уменьшенное изображение по переданному пути.
        /// </summary>
        /// <param name="imageInfo"></param>
        /// <returns></returns>
        public Bitmap Get(CoreImageInfo imageInfo)
        {
            Bitmap bitmap = null;
            Size   size   = GetThumbnailSize(imageInfo);

            m_mutex.WaitOne();
            m_storage.TryGetValue(imageInfo.id, out bitmap);
            if (bitmap == null || bitmap.Height != size.Height || bitmap.Width != size.Width)
            {
                m_mutex.ReleaseMutex(); // поток может работать дальше
                bitmap = m_core.LoadBitmap(size, imageInfo.path);
                m_mutex.WaitOne();
                m_storage[imageInfo.id] = bitmap;
            }
            m_mutex.ReleaseMutex();
            return(bitmap);
        }
Exemple #8
0
        /// <summary>
        /// Существует ли в хранилише изображение по переданному изображению.
        /// </summary>
        /// <param name="imageInfo"></param>
        /// <returns></returns>
        public bool Exists(CoreImageInfo imageInfo)
        {
            bool result = false;

            m_mutex.WaitOne();
            if (m_storage.ContainsKey(imageInfo.id))
            {
                Bitmap bitmap = m_storage[imageInfo.id];
                if (bitmap != null)
                {
                    Size size = GetThumbnailSize(imageInfo);
                    result = (bitmap.Height == size.Height && bitmap.Width == size.Width);
                }
            }
            m_mutex.ReleaseMutex();
            return(result);
        }
        /// <summary>
        /// Устанавливает значение подсказки tooltip для надписи EXIF.
        /// </summary>
        private void SetExifTooltip(CoreImageInfo currentImageInfo)
        {
            Strings s         = Resources.Strings.Current;
            string  exifSting = String.Empty;

            List <string> exifList = GetExifList(currentImageInfo, s);

            if (exifList.Count > 0)
            {
                for (int i = 0; i < exifList.Count - 1; i++)
                {
                    exifSting = exifSting + exifList[i];
                    exifSting = exifSting + Environment.NewLine;
                }
                exifSting = exifSting + exifList[exifList.Count - 1];

                m_toolTip.SetToolTip(m_imageExifLabel, exifSting);
            }
        }
Exemple #10
0
 static public void OpenContainingFolder(CoreImageInfo imageInfo)
 {
     try
     {
         if (m_canOpenFolderWithExplorer)
         {
             Process.Start("explorer.exe", string.Format("/e, /select, \"{0}\"", imageInfo.path));
         }
         else
         {
             ProcessStartInfo startInfo = new ProcessStartInfo();
             startInfo.FileName = imageInfo.GetDirectoryString();
             Process.Start(startInfo);
         }
     }
     catch (System.Exception exeption)
     {
         MessageBox.Show(exeption.Message);
     }
 }
Exemple #11
0
 static public void OpenContainingFolder(CoreImageInfo imageInfo)
 {
     try
     {
         ProcessStartInfo startInfo = new ProcessStartInfo();
         if (m_canOpenFolderWithExplorer)
         {
             startInfo.FileName  = "explorer.exe";
             startInfo.Arguments = string.Format("/e, /select, \"{0}\"", imageInfo.path);
         }
         else
         {
             startInfo.FileName = imageInfo.GetDirectoryString();
         }
         var process = Process.Start(startInfo);
         Thread.Sleep(System.TimeSpan.FromMilliseconds(100));
     }
     catch (System.Exception exeption)
     {
         MessageBox.Show(exeption.Message);
     }
 }
Exemple #12
0
        /// <summary>
        /// Возврашает массив CoreImageInfo содержащихся в переданной группе.
        /// </summary>
        /// <param name="groupId"></param>
        /// <param name="startFrom"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        public CoreImageInfo[] GetImageInfo(int groupId, uint startFrom, uint size)
        {
            uint imageInfoSize = GetImageInfoSize(groupId);

            if (imageInfoSize > startFrom)
            {
                object imageInfoObject = new CoreDll.adImageInfoW();
                int    sizeOfImageInfo = Marshal.SizeOf(imageInfoObject);
                byte[] buffer          = new byte[sizeOfImageInfo * PAGE_SIZE];
                size = Math.Min(imageInfoSize - startFrom, size);
                CoreImageInfo[] imageInfos = new CoreImageInfo[size];
                uint            pageCount  = (uint)(size / PAGE_SIZE + (size % PAGE_SIZE > 0 ? 1 : 0));
                for (uint page = 0; page < pageCount; ++page)
                {
                    UIntPtr[] pStartFrom = new UIntPtr[1];
                    pStartFrom[0] = new UIntPtr(startFrom + page * PAGE_SIZE);

                    UIntPtr[] pSize = new UIntPtr[1];
                    pSize[0] = new UIntPtr(PAGE_SIZE);

                    if (m_dll.adImageInfoGetW(m_handle, new IntPtr(groupId), Marshal.UnsafeAddrOfPinnedArrayElement(pStartFrom, 0),
                                              Marshal.UnsafeAddrOfPinnedArrayElement(buffer, 0),
                                              Marshal.UnsafeAddrOfPinnedArrayElement(pSize, 0)) == CoreDll.Error.Ok)
                    {
                        for (uint i = 0; i < pSize[0].ToUInt32(); ++i)
                        {
                            IntPtr pImageInfo = Marshal.UnsafeAddrOfPinnedArrayElement(buffer, (int)(i * sizeOfImageInfo));
                            CoreDll.adImageInfoW imageInfo = (CoreDll.adImageInfoW)Marshal.PtrToStructure(pImageInfo, imageInfoObject.GetType());
                            imageInfos[page * PAGE_SIZE + i] = new CoreImageInfo(ref imageInfo);
                        }
                    }
                }
                return(imageInfos);
            }
            return(null);
        }
Exemple #13
0
 public System.Drawing.Bitmap LoadBitmap(CoreImageInfo imageInfo)
 {
     return(LoadBitmap((int)imageInfo.width, (int)imageInfo.height, imageInfo.path));
 }
        /// <summary>
        /// Set information in image panel.
        /// Установка информации в панели изображения.
        /// </summary>
        private void SetImageInfo(CoreImageInfo currentImageInfo, CoreImageInfo neighbourImageInfo)
        {
            /*bool updateCurrent = UpdateImageInfo(ref m_currentImageInfo, currentImageInfo);
             * bool updateNeighbour = UpdateImageInfo(ref m_neighbourImageInfo, neighbourImageInfo);*/
            bool updateCurrent   = true;
            bool updateNeighbour = true;

            if (!m_options.resultsOptions.ShowNeighboursImages)
            {
                m_currentImageInfo   = currentImageInfo;
                m_neighbourImageInfo = neighbourImageInfo;
            }
            else
            {
                updateCurrent   = UpdateImageInfo(ref m_currentImageInfo, currentImageInfo);
                updateNeighbour = UpdateImageInfo(ref m_neighbourImageInfo, neighbourImageInfo);
            }
            if (updateCurrent)
            {
                m_pictureBoxPanel.UpdateImage(currentImageInfo);
                m_fileSizeLabel.Text       = m_currentImageInfo.GetFileSizeString();
                m_imageSizeLabel.Text      = m_currentImageInfo.GetImageSizeString();
                m_imageBlocknessLabel.Text = m_currentImageInfo.GetBlockinessString();
                m_imageBlurringLabel.Text  = m_currentImageInfo.GetBlurringString();
                m_imageTypeLabel.Text      = m_currentImageInfo.type == CoreDll.ImageType.None ? "   " : m_currentImageInfo.GetImageTypeString();
                if (currentImageInfo.exifInfo.isEmpty == CoreDll.FALSE)
                {
                    m_imageExifLabel.Visible = true;
                    SetExifTooltip(currentImageInfo);
                }
                else
                {
                    m_imageExifLabel.Visible = false;
                }
                m_pathLabel.Text = m_currentImageInfo.path;
                if (m_neighbourImageInfo != null) //подсветка highlight
                {
                    m_imageSizeLabel.ForeColor =
                        m_currentImageInfo.height * m_currentImageInfo.width < m_neighbourImageInfo.height * m_neighbourImageInfo.width ?
                        Color.Red : TableLayoutPanel.DefaultForeColor;
                    m_imageTypeLabel.ForeColor = m_currentImageInfo.type != m_neighbourImageInfo.type ?
                                                 Color.Red : TableLayoutPanel.DefaultForeColor;
                    m_fileSizeLabel.ForeColor = m_currentImageInfo.size < m_neighbourImageInfo.size ?
                                                Color.Red : TableLayoutPanel.DefaultForeColor;
                    m_imageBlocknessLabel.ForeColor = m_currentImageInfo.blockiness > m_neighbourImageInfo.blockiness ?
                                                      Color.Red : TableLayoutPanel.DefaultForeColor;
                    m_imageBlurringLabel.ForeColor = m_currentImageInfo.blurring > m_neighbourImageInfo.blurring ?
                                                     Color.Red : TableLayoutPanel.DefaultForeColor;
                    m_imageExifLabel.ForeColor = ExifEqual(m_currentImageInfo.exifInfo, m_neighbourImageInfo.exifInfo) ?
                                                 TableLayoutPanel.DefaultForeColor : Color.Red;
                }
            }
            else if (m_neighbourImageInfo != null)
            {
                m_imageSizeLabel.ForeColor = m_currentImageInfo.height * m_currentImageInfo.width < m_neighbourImageInfo.height * m_neighbourImageInfo.width ?
                                             Color.Red : TableLayoutPanel.DefaultForeColor;
                m_imageTypeLabel.ForeColor = m_currentImageInfo.type != m_neighbourImageInfo.type ?
                                             Color.Red : TableLayoutPanel.DefaultForeColor;
                m_fileSizeLabel.ForeColor = m_currentImageInfo.size < m_neighbourImageInfo.size ?
                                            Color.Red : TableLayoutPanel.DefaultForeColor;
                m_imageBlocknessLabel.ForeColor = m_currentImageInfo.blockiness > m_neighbourImageInfo.blockiness ?
                                                  Color.Red : TableLayoutPanel.DefaultForeColor;
                m_imageBlurringLabel.ForeColor = m_currentImageInfo.blurring > m_neighbourImageInfo.blurring ?
                                                 Color.Red : TableLayoutPanel.DefaultForeColor;
                m_imageExifLabel.ForeColor = ExifEqual(m_currentImageInfo.exifInfo, m_neighbourImageInfo.exifInfo) ?
                                             TableLayoutPanel.DefaultForeColor : Color.Red;
            }
            if (updateCurrent || updateNeighbour)
            {
                Size neighbourSizeMax = new Size(0, 0);
                if (m_neighbourImageInfo != null)
                {
                    neighbourSizeMax = new Size((int)m_neighbourImageInfo.width, (int)m_neighbourImageInfo.height);
                }
                m_pictureBoxPanel.UpdateImagePadding(neighbourSizeMax);
                Refresh();
            }
        }