コード例 #1
0
ファイル: User32.cs プロジェクト: Gainedge/BetterExplorer
		public static extern int SendMessage(IntPtr hWnd, MSG Msg, ref LVITEMINDEX wparam, ref Shell.LVITEM lParam);
コード例 #2
0
		void DelayTimer_Tick(object sender, EventArgs e) {
			_DelayTimer.Stop();

			var t = new Thread(() => {
				var clonedCurrentItem = this.CurrentItem.Clone();
				var tooltip = clonedCurrentItem.ToolTipText;
				if (String.IsNullOrEmpty(tooltip) && Type == 1) {
					Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, (ThreadStart)(this.Hide));
					return;
				}
				Contents = Type == 0 ? $"{clonedCurrentItem.DisplayName}\r\n{clonedCurrentItem.ToolTipText}" : clonedCurrentItem.ToolTipText;
				RaisePropertyChanged("Contents");

				// BE-557: clonedCurrentItem.GetPropertyValue returned VT_EMPTY, edge case included to handle this
				var perceivedTypeProperty = clonedCurrentItem.GetPropertyValue(
					SystemProperties.PerceivedType,
					typeof(PerceivedType));
				if (perceivedTypeProperty.VarType != VarEnum.VT_EMPTY
					&& ((PerceivedType)perceivedTypeProperty.Value) == PerceivedType.Image && !clonedCurrentItem.IsFolder)
				{
					var image = clonedCurrentItem.ThumbnailSource(
						350,
						ShellThumbnailFormatOption.Default,
						ShellThumbnailRetrievalOption.Default);
					image.Freeze();
					this.Image = image;
					RaisePropertyChanged("Image");
					this.FileNameWidth = this.Image.Width - 110;
					RaisePropertyChanged("FileNameWidth");

					try
					{
						var ratingValue = clonedCurrentItem.GetPropertyValue(MediaProperties.Rating, typeof(Double)).Value;
						var rating = ratingValue == null ? 0 : Convert.ToDouble(ratingValue) / 20D;
						this.Rating = rating;
						RaisePropertyChanged("Rating");
						this.Dimentions =
							((Math.Ceiling(
									Convert.ToDouble(clonedCurrentItem.GetPropertyValue(SystemProperties.FileSize, typeof(double)).Value))
								/ 1024).ToString("# ### ### ##0") + " KB ("
								+ clonedCurrentItem.GetPropertyValue(MediaProperties.Dimensions, typeof(String)).Value.ToString()
								+ " px )").Trim();
						RaisePropertyChanged("Dimentions");
					}
					catch (NullReferenceException)
					{
					}
					this.FileName = Path.GetFileName(clonedCurrentItem.ParsingName)?.Trim();
					RaisePropertyChanged("FileName");
				}
				else
				{
					var image = clonedCurrentItem.ThumbnailSource(
						64,
						ShellThumbnailFormatOption.Default,
						ShellThumbnailRetrievalOption.Default);
					image.Freeze();
					this.Image = image;
					RaisePropertyChanged("Image");
				}


				Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, (ThreadStart)(() => {
					var lvi = new LVITEMINDEX();
					lvi.iItem = this.ItemIndex;
					lvi.iGroup = this._View.GetGroupIndex(this.ItemIndex);
					var bounds = new User32.RECT();
					User32.SendMessage(this._View.LVHandle, MSG.LVM_GETITEMINDEXRECT, ref lvi, ref bounds);
					var rect = new System.Drawing.Rectangle(bounds.Left, bounds.Top, bounds.Right - bounds.Left, bounds.Bottom - bounds.Top);
					var posm = User32.GetCursorPosition();
					var mousePos = this._View.PointToClient(posm);
					var isInsideItem = rect.Contains(mousePos);

					if (isInsideItem)
						this.Show();
					else
						this.Hide();

				}));
			});
			t.SetApartmentState(ApartmentState.STA);
			t.Start();
		}
コード例 #3
0
ファイル: User32.cs プロジェクト: Gainedge/BetterExplorer
		public static extern int SendMessage(IntPtr hWnd, int Msg, ref LVITEMINDEX wParam, LVNI lParam);
コード例 #4
0
ファイル: User32.cs プロジェクト: Gainedge/BetterExplorer
		public static extern int SendMessage(IntPtr hWnd, MSG Msg, ref LVITEMINDEX wParam, ref RECT lparam);
コード例 #5
0
 public void OnCacheHint(Interop.LVITEMINDEX i, Interop.LVITEMINDEX j)
 {
 }
コード例 #6
0
    private void ProcessCustomDrawPostPaint(ref Message m, User32.NMLVCUSTOMDRAW nmlvcd, Int32 index, IntPtr hdc, IListItemEx sho, Color? textColor) {
      if (nmlvcd.clrTextBk != 0 && nmlvcd.dwItemType == 0 && this._CurrentDrawIndex == -1) {
        //var perceivedType = (PerceivedType)sho.GetPropertyValue(SystemProperties.PerceivedType, typeof(PerceivedType)).Value;
        this._CurrentDrawIndex = index;
        var itemBounds = nmlvcd.nmcd.rc;
        var lvi = new LVITEMINDEX();
        lvi.iItem = index;
        lvi.iGroup = this.GetGroupIndex(index);
        var iconBounds = new User32.RECT() { Left = 1 };
        User32.SendMessage(this.LVHandle, MSG.LVM_GETITEMINDEXRECT, ref lvi, ref iconBounds);
        var lvItem = new LVITEM() {
          iItem = index,
          iGroupId = lvi.iGroup,
          iGroup = lvi.iGroup,
          mask = LVIF.LVIF_STATE,
          stateMask = LVIS.LVIS_SELECTED
        };
        var lvItemImageMask = new LVITEM() {
          iItem = index,
          iGroupId = lvi.iGroup,
          iGroup = lvi.iGroup,
          mask = LVIF.LVIF_STATE,
          stateMask = LVIS.LVIS_STATEIMAGEMASK
        };

        if (sho != null) {
          var cutFlag = (User32.SendMessage(this.LVHandle, MSG.LVM_GETITEMSTATE, index, LVIS.LVIS_CUT) & LVIS.LVIS_CUT) ==
                                                                  LVIS.LVIS_CUT;
          if (this.IconSize == 16) {
            this.SmallImageList.DrawIcon(hdc, index, sho, iconBounds,
                    sho.IsHidden || cutFlag || this._CuttedIndexes.Contains(index), (nmlvcd.nmcd.uItemState & CDIS.HOT) == CDIS.HOT);
          } else {
            this.LargeImageList.DrawIcon(hdc, index, sho, iconBounds,
                    sho.IsHidden || cutFlag || this._CuttedIndexes.Contains(index), (nmlvcd.nmcd.uItemState & CDIS.HOT) == CDIS.HOT);
          }

          if (!sho.IsInitialised) sho.IsInitialised = true;
        }
        m.Result = (IntPtr)CustomDraw.CDRF_SKIPDEFAULT;
      } else {
        m.Result = IntPtr.Zero;
      }

      this._CurrentDrawIndex = -1;
    }
コード例 #7
0
    public void RedrawItem(Int32 index, Int32 delay = -1) {
      if (delay > -1) {
        Thread.Sleep(delay);
      }
      var itemBounds = new User32.RECT() { Left = 1 };
      var lvi = new LVITEMINDEX() { iItem = index, iGroup = this.GetGroupIndex(index) };
      User32.SendMessage(this.LVHandle, MSG.LVM_GETITEMINDEXRECT, ref lvi, ref itemBounds);
      itemBounds.Left -= 2;
      itemBounds.Top -= 2;
      itemBounds.Bottom += 2;
      itemBounds.Right += 2;
      this.Invoke(new MethodInvoker(() => this._IIListView.RedrawItems(index, index)));

      //TODO: Find out why we have this loop
      for (Int32 i = 0; i < 1; i++) {
        if (IsGroupsEnabled) RedrawWindow(itemBounds);
      }
    }
コード例 #8
0
    private async void RetrieveThumbnailByIndex(Int32 index) {
      await Task.Run(() => {
        if (this.IsCancelRequested) return;

        //F.Application.DoEvents();
        var itemBounds = new User32.RECT();
        var lvi = new LVITEMINDEX() { iItem = index, iGroup = this.GetGroupIndex(index) };
        User32.SendMessage(this.LVHandle, MSG.LVM_GETITEMINDEXRECT, ref lvi, ref itemBounds);

        var r = new Rectangle(itemBounds.Left, itemBounds.Top, itemBounds.Right - itemBounds.Left, itemBounds.Bottom - itemBounds.Top);

        if (r.IntersectsWith(this.ClientRectangle)) {
          var sho = Items[index];
          var icon = sho.GetHBitmap(IconSize, true, true);
          sho.IsThumbnailLoaded = true;
          sho.IsNeedRefreshing = false;
          if (icon != IntPtr.Zero) {
            Int32 width = 0, height = 0;
            Gdi32.ConvertPixelByPixel(icon, out width, out height);
            sho.IsOnlyLowQuality = (width > height && width != IconSize) || (width < height && height != IconSize) || (width == height && width != IconSize);
            Gdi32.DeleteObject(icon);
            this.RedrawItem(index);
          }
        }
      });
    }
コード例 #9
0
    /// <summary>
    /// Selects only the specified items. First runs <see cref="DeSelectAllItems">DeSelectAllItems</see> Then selects all items on a separate thread.
    /// </summary>
    /// <param name="shellObjectArray"></param>
    public void SelectItems(IListItemEx[] shellObjectArray) {
      this.DeSelectAllItems();
      var selectionThread = new Thread(() => {
        foreach (var item in shellObjectArray) {
          try {
            var exestingItem = this.Items.FirstOrDefault(s => s.Equals(item));
            var itemIndex = exestingItem?.ItemIndex ?? -1;
            var lvii = new LVITEMINDEX() { iItem = itemIndex, iGroup = this.GetGroupIndex(itemIndex) };
            var lvi = new LVITEM() { mask = LVIF.LVIF_STATE, stateMask = LVIS.LVIS_SELECTED, state = LVIS.LVIS_SELECTED };
            User32.SendMessage(this.LVHandle, MSG.LVM_SETITEMINDEXSTATE, ref lvii, ref lvi);
          } catch (Exception) {
            //catch the given key was not found. It happen on fast delete of items
          }
        }
        this.Focus();
      });

      selectionThread.SetApartmentState(ApartmentState.STA);
      selectionThread.Start();
    }