示例#1
0
        /// <summary>
        /// Creates a new tab, optionally selects it then erturns it
        /// </summary>
        /// <param name="DefPath">The <see cref="IListItemEx"/> that represents the location of this tab</param>
        /// <param name="IsNavigate">Do you want the new tab to be selected?</param>
        /// <returns></returns>
        public TabItem NewTab(IListItemEx DefPath, bool IsNavigate)
        {
            this.IsInTabDragDrop = false;
            var newt = new TabItem(DefPath)
            {
                Header    = DefPath.DisplayName,
                Icon      = DefPath.ThumbnailSource(16, BExplorer.Shell.Interop.ShellThumbnailFormatOption.IconOnly, BExplorer.Shell.Interop.ShellThumbnailRetrievalOption.Default),
                ToolTip   = DefPath.ParsingName.Replace("%20", " ").Replace("%3A", ":").Replace("%5C", @"\"),
                AllowDrop = true
            };

            newt.DragEnter        += new DragEventHandler(newt_DragEnter);
            newt.DragOver         += new DragEventHandler(newt_DragOver);
            newt.PreviewMouseMove += new MouseEventHandler(newt_PreviewMouseMove);
            newt.PreviewMouseUp   += newt_PreviewMouseDown;
            newt.Drop             += new DragEventHandler(newt_Drop);
            newt.DragLeave        += newt_Leave;
            newt.GiveFeedback     += newt_GiveFeedback;

            //TODO: Try to remove this Try Catch
            try {
                Items.Add(newt);
                if (IsNavigate)
                {
                    this.SelectedItem = newt;
                }
            } catch (Exception) {
            }

            ConstructMoveToCopyToMenu();
            this.IsInTabDragDrop = true;
            return(newt);
        }
示例#2
0
        private void DrawComputerTiledModeView(IListItemEx sho, Graphics g, RectangleF lblrectTiles, StringFormat fmt)
        {
            var driveInfo = new DriveInfo(sho.ParsingName);

            if (driveInfo.IsReady)
            {
                ProgressBarRenderer.DrawHorizontalBar(g, new Rectangle((Int32)lblrectTiles.Left, (Int32)lblrectTiles.Bottom + 4, (Int32)lblrectTiles.Width - 10, 10));
                var fullProcent  = (100 * (driveInfo.TotalSize - driveInfo.AvailableFreeSpace)) / driveInfo.TotalSize;
                var barWidth     = (lblrectTiles.Width - 12) * fullProcent / 100;
                var rec          = new Rectangle((Int32)lblrectTiles.Left + 1, (Int32)lblrectTiles.Bottom + 5, (Int32)barWidth, 8);
                var gradRec      = new Rectangle(rec.Left, rec.Top - 1, rec.Width, rec.Height + 2);
                var criticalUsed = fullProcent >= 90;
                var warningUsed  = fullProcent >= 75;
                var averageUsed  = fullProcent >= 50;
                var brush        = new LinearGradientBrush(gradRec, criticalUsed ? Color.FromArgb(255, 0, 0) : warningUsed ? Color.FromArgb(255, 224, 0) : averageUsed ? Color.FromArgb(0, 220, 255) : Color.FromArgb(199, 248, 165),
                                                           criticalUsed ? Color.FromArgb(150, 0, 0) : warningUsed ? Color.FromArgb(255, 188, 0) : averageUsed ? Color.FromArgb(43, 84, 235) : Color.FromArgb(101, 247, 0), LinearGradientMode.Vertical);
                g.FillRectangle(brush, rec);
                brush.Dispose();
                var  lblrectSubiTem3  = new RectangleF(lblrectTiles.Left, lblrectTiles.Bottom + 16, lblrectTiles.Width, 15);
                Font subItemFont      = SystemFonts.IconTitleFont;
                var  subItemTextBrush = new SolidBrush(SystemColors.ControlDarkDark);
                g.DrawString($"{ShlWapi.StrFormatByteSize(driveInfo.AvailableFreeSpace)} free of {ShlWapi.StrFormatByteSize(driveInfo.TotalSize)}", subItemFont, subItemTextBrush, lblrectSubiTem3, fmt);

                subItemFont.Dispose();
                subItemTextBrush.Dispose();
            }
        }
        public static void Open(IListItemEx file)
        {
            var f = new ResizeImage();

            f.InitializeComponent();

            f.textBlock1.Text = f.FindResource("txtFilename") + ": " + file.GetDisplayName(SIGDN.NORMALDISPLAY);
            f.cvt             = new Bitmap(file.ParsingName);
            f.textBlock2.Text = f.FindResource("lblHeightCP") + ": " + f.cvt.Height.ToString();
            f.textBlock3.Text = f.FindResource("lblWidthCP") + ": " + f.cvt.Width.ToString();

            f.spinner1.Value = 100;

            f.percsetting = true;

            f.textBox1.Text = f.cvt.Width.ToString();
            f.textBox2.Text = f.cvt.Height.ToString();

            f.percsetting = false;

            f.ShowDialog();


            if (f.Confirm)
            {
                System.Drawing.Bitmap cvt = new Bitmap(file.ParsingName);
                System.Drawing.Bitmap cst = ChangeImageSize(cvt, f.newwidth, f.newheight);

                string ext = file.Extension;

                cst.Save(file.ParsingName + " (" + f.newwidth + " X " + f.newheight + ")" + ext);
                cvt.Dispose();
                cst.Dispose();
            }
        }
 public bool Equals(IListItemEx other)
 {
     if (other == null)
     {
         return(false);
     }
     return(other.ParsingName.Equals(this.ParsingName, StringComparison.InvariantCultureIgnoreCase));
 }
示例#5
0
        public bool GetNewContextMenu(IListItemEx item, out IntPtr iContextMenuPtr, out IContextMenu iContextMenu)
        {
            Guid CLSID_NewMenu = new Guid("{D969A300-E7FF-11d0-A93B-00A0C90F2719}");
            Guid iicm          = typeof(IContextMenu).GUID;
            Guid iise          = typeof(IShellExtInit).GUID;

            if (Ole32.CoCreateInstance(
                    ref CLSID_NewMenu,
                    IntPtr.Zero,
                    Ole32.CLSCTX.INPROC_SERVER,
                    ref iicm,
                    out iContextMenuPtr) == (int)HResult.S_OK)
            {
                iContextMenu = Marshal.GetObjectForIUnknown(iContextMenuPtr) as IContextMenu;

                IntPtr iShellExtInitPtr;
                if (Marshal.QueryInterface(
                        iContextMenuPtr,
                        ref iise,
                        out iShellExtInitPtr) == (int)HResult.S_OK)
                {
                    IShellExtInit iShellExtInit = Marshal.GetTypedObjectForIUnknown(
                        iShellExtInitPtr, typeof(IShellExtInit)) as IShellExtInit;

                    try {
                        iShellExtInit.Initialize(item.PIDL, null, 0);

                        Marshal.ReleaseComObject(iShellExtInit);
                        Marshal.Release(iShellExtInitPtr);
                        return(true);
                    } finally {
                    }
                }
                else
                {
                    if (iContextMenu != null)
                    {
                        Marshal.ReleaseComObject(iContextMenu);
                        iContextMenu = null;
                    }

                    if (iContextMenuPtr != IntPtr.Zero)
                    {
                        Marshal.ReleaseComObject(iContextMenuPtr);
                        iContextMenuPtr = IntPtr.Zero;
                    }

                    return(false);
                }
            }
            else
            {
                iContextMenuPtr = IntPtr.Zero;
                iContextMenu    = null;
                return(false);
            }
        }
示例#6
0
 /// <summary>
 /// Copies items to a destination
 /// </summary>
 /// <param name="source">The items you want to copy</param>
 /// <param name="destination">The destination you want to copy the <paramref name="source"/> items</param>
 public void CopyItems(IShellItemArray source, IListItemEx destination)
 {
     this.ThrowIfDisposed();
     if (this._IsCopyInSameFolder)
     {
         this._FileOperation.SetOperationFlags(FileOperationFlags.FOF_RENAMEONCOLLISION | FileOperationFlags.FOF_ALLOWUNDO | FileOperationFlags.FOF_NOCONFIRMMKDIR);
     }
     this._FileOperation.CopyItems(source, destination.ComInterface);
 }
示例#7
0
        /// <summary>
        /// Creates initial tab
        /// </summary>
        /// <param name="win">The main window</param>
        /// <param name="sho">The shell object used for tab creation</param>
        private void CreateInitialTab(MainWindow win, IListItemEx sho)
        {
            var bmpSource = sho.ThumbnailSource(16, ShellThumbnailFormatOption.IconOnly, ShellThumbnailRetrievalOption.Default);
            var newt      = new Wpf.Controls.TabItem(sho)
            {
                Header = sho.DisplayName,
                Icon   = bmpSource
            };

            newt.PreviewMouseMove += this.Newt_PreviewMouseMove;
            newt.ToolTip           = sho.ParsingName.Replace("%20", " ").Replace("%3A", ":").Replace("%5C", @"\");
            win.tcMain.CloneTabItem(newt);
        }
示例#8
0
 private void DrawDefaultIcons(IntPtr hdc, IListItemEx sho, User32.RECT iconBounds)
 {
     if (this._CurrentSize == 16)
     {
         this._Small.DrawIcon(hdc, this._ExeFallBackIndex, new Point(iconBounds.Left + (iconBounds.Right - iconBounds.Left - this._CurrentSize) / 2, iconBounds.Top + (iconBounds.Bottom - iconBounds.Top - this._CurrentSize) / 2), this._CurrentSize);
     }
     else if (this._CurrentSize <= 48)
     {
         this._Extra.DrawIcon(hdc, this._ExeFallBackIndex, new Point(iconBounds.Left + (iconBounds.Right - iconBounds.Left - this._CurrentSize) / 2, iconBounds.Top + (iconBounds.Bottom - iconBounds.Top - this._CurrentSize) / 2), this._CurrentSize);
     }
     else if (this._CurrentSize <= 256)
     {
         this._Jumbo.DrawIcon(hdc, this._ExeFallBackIndex, new Point(iconBounds.Left + (iconBounds.Right - iconBounds.Left - this._CurrentSize) / 2, iconBounds.Top + (iconBounds.Bottom - iconBounds.Top - this._CurrentSize) / 2), this._CurrentSize);
     }
 }
示例#9
0
        void Initialize(IListItemEx[] items)
        {
            this._Items = items;
            IntPtr[]    pidls  = new IntPtr[items.Length];
            IListItemEx parent = null;

            for (int n = 0; n < items.Length; ++n)
            {
                pidls[n] = items[n].ILPidl;

                if (parent == null)
                {
                    if (items[n].ParsingName.Equals(ShellItem.Desktop.ParsingName))
                    {
                        parent = FileSystemListItem.ToFileSystemItem(IntPtr.Zero, ShellItem.Desktop.Pidl);
                    }
                    else
                    {
                        parent = items[n].Parent;
                    }
                }
                else if (!items[n].Parent.Equals(parent))
                {
                    throw new Exception("All shell items must have the same parent");
                }
            }

            if (items.Length == 0)
            {
                var desktop       = KnownFolders.Desktop as ShellItem;
                var ishellViewPtr = desktop.GetIShellFolder().CreateViewObject(IntPtr.Zero, typeof(IShellView).GUID);
                var view          = Marshal.GetObjectForIUnknown(ishellViewPtr) as IShellView;
                view.GetItemObject(SVGIO.SVGIO_BACKGROUND, typeof(IContextMenu).GUID, out _Result);
                Marshal.ReleaseComObject(view);
            }
            else
            {
                parent.GetIShellFolder().GetUIObjectOf(IntPtr.Zero, (uint)pidls.Length, pidls, typeof(IContextMenu).GUID, 0, out _Result);
            }

            m_ComInterface  = (IContextMenu)Marshal.GetTypedObjectForIUnknown(_Result, typeof(IContextMenu));
            m_ComInterface2 = m_ComInterface as IContextMenu2;
            m_ComInterface3 = m_ComInterface as IContextMenu3;
            m_MessageWindow = new MessageWindow(this);
        }
示例#10
0
        private Int32 GetAddornerType(IListItemEx sho)
        {
            var result           = 0;
            var extensionRootKey = Registry.ClassesRoot.OpenSubKey(sho.Extension);

            if (extensionRootKey != null)
            {
                var perceivedType = extensionRootKey.GetValue("PerceivedType");
                extensionRootKey.Close();
                if (perceivedType != null)
                {
                    var perceiveTypeKey = Registry.ClassesRoot.OpenSubKey(perceivedType.ToString());
                    if (perceiveTypeKey != null)
                    {
                        var threatment = perceiveTypeKey.GetValue("Treatment");
                        if (threatment != null)
                        {
                            result = (Int32)threatment;
                        }
                        perceiveTypeKey.Close();
                        perceiveTypeKey.Dispose();
                    }
                    else
                    {
                        var systemFileAssociationsKey = Registry.ClassesRoot.OpenSubKey(@"SystemFileAssociations\" + perceivedType);
                        if (systemFileAssociationsKey != null)
                        {
                            var threatment = systemFileAssociationsKey.GetValue("Treatment");
                            if (threatment != null)
                            {
                                result = (Int32)threatment;
                            }
                            systemFileAssociationsKey.Close();
                            systemFileAssociationsKey.Dispose();
                        }
                    }
                }
            }

            return(result);
        }
示例#11
0
        /// <summary>
        /// Is the current <paramref name="checkedItem">Item</paramref> in the <paramref name="currentFolder">Folder</paramref>?
        /// </summary>
        /// <param name="checkedItem">The current item who's container/parent you want to check</param>
        /// <param name="currentFolder">The folder you are looking for</param>
        /// <returns>Is the current <paramref name="checkedItem">Item</paramref> in the <paramref name="currentFolder">Folder</paramref>?</returns>
        /// <remarks>
        /// 1. Special Logic for Library folders (.library-ms)
        /// </remarks>
        public static Boolean IsInCurrentFolder(this IListItemEx checkedItem, IListItemEx currentFolder)
        {
            var isLibraryContainer = currentFolder?.Extension == ".library-ms";

            if (isLibraryContainer)
            {
                var library        = ShellLibrary.Load(currentFolder.DisplayName, true);
                var libraryFolders = library.Select(w => w).ToArray();
                if (libraryFolders.Count(
                        c => c.ParsingName.Equals(checkedItem.Parent?.ParsingName, StringComparison.InvariantCultureIgnoreCase)) > 0)
                {
                    library.Close();
                    return(true);
                }
                library.Close();
                return(false);
            }
            else
            {
                return(checkedItem?.Parent?.ParsingName == currentFolder.ParsingName);
            }
        }
示例#12
0
        public static void Open(IListItemEx file)
        {
            var f = new ResizeImage();

            f.InitializeComponent();

            f.textBlock1.Text = f.FindResource("txtFilename") + ": " + file.GetDisplayName(SIGDN.NORMALDISPLAY);
            f.cvt = new Bitmap(file.ParsingName);
            f.textBlock2.Text = f.FindResource("lblHeightCP") + ": " + f.cvt.Height.ToString();
            f.textBlock3.Text = f.FindResource("lblWidthCP") + ": " + f.cvt.Width.ToString();

            f.spinner1.Value = 100;

            f.percsetting = true;

            f.textBox1.Text = f.cvt.Width.ToString();
            f.textBox2.Text = f.cvt.Height.ToString();

            f.percsetting = false;

            f.ShowDialog();


            if (f.Confirm)
            {
                System.Drawing.Bitmap cvt = new Bitmap(file.ParsingName);
                System.Drawing.Bitmap cst = ChangeImageSize(cvt, f.newwidth, f.newheight);

                string ext = file.Extension;

                cst.Save(file.ParsingName + " (" + f.newwidth + " X " + f.newheight + ")" + ext);
                cvt.Dispose();
                cst.Dispose();
            }

        }
示例#13
0
    /// <summary>
    /// Creates a new tab, optionally selects it then erturns it
    /// </summary>
    /// <param name="DefPath">The <see cref="IListItemEx"/> that represents the location of this tab</param>
    /// <param name="IsNavigate">Do you want the new tab to be selected?</param>
    /// <returns></returns>
    public TabItem NewTab(IListItemEx DefPath, bool IsNavigate) {
      this.IsInTabDragDrop = false;
      SelectNewTabOnCreate = false;
      var newt = new TabItem(DefPath) {
        Header = DefPath.DisplayName,
        Icon = DefPath.ThumbnailSource(16, BExplorer.Shell.Interop.ShellThumbnailFormatOption.IconOnly, BExplorer.Shell.Interop.ShellThumbnailRetrievalOption.Default),
        ToolTip = DefPath.ParsingName.Replace("%20", " ").Replace("%3A", ":").Replace("%5C", @"\"),
        AllowDrop = true
      };

      newt.DragEnter += new DragEventHandler(newt_DragEnter);
      newt.DragOver += new DragEventHandler(newt_DragOver);
      newt.PreviewMouseMove += new MouseEventHandler(newt_PreviewMouseMove);
      newt.PreviewMouseUp += newt_PreviewMouseDown;
      newt.Drop += new DragEventHandler(newt_Drop);
      newt.DragLeave += newt_Leave;
      newt.GiveFeedback += newt_GiveFeedback;

      //TODO: Try to remove this Try Catch
      try {
        Items.Add(newt);
        //IsSelectionHandled = false;
        if (IsNavigate) {
          SelectNewTabOnCreate = true;
          this.SelectedItem = newt;
        }
      } catch (Exception) {

      }

      ConstructMoveToCopyToMenu();
      this.IsInTabDragDrop = true;
      return newt;
    }
示例#14
0
		public TabItem(IListItemEx ShellObject) {
			this.ShellObject = ShellObject;
			log = new NavigationLog(ShellObject);
		}
示例#15
0
 /// <summary>
 /// A generic constructor
 /// </summary>
 /// <param name="StartingLocation">This location will be added as the first item in <see cref="HistoryItemsList"/></param>
 public NavigationLog(IListItemEx StartingLocation)
 {
     HistoryItemsList = new List<IListItemEx>(new[] { StartingLocation });
     CurrentLocPos = 0; //-1;
 }
示例#16
0
	/// <summary>
	/// Initializes a new instance of the <see cref="ShellContextMenu"/> 
	/// class.
	/// </summary>
	/// 
	/// <param name="shellView">The <see cref="ShellView">ShellView</see> for this context menu</param>
	/// <param name="item">
	/// The item to which the context menu should refer.
	/// </param>
	public ShellContextMenu(ShellView shellView, IListItemEx item) {
      this._ShellView = shellView;
      Initialize(new IListItemEx[] { item });
    }
示例#17
0
    public bool GetOpenWithContextMenu(IListItemEx[] itemArray, out IntPtr iContextMenuPtr, out IContextMenu iContextMenu) {
      Guid CLSID_OpenWith = new Guid(0x09799AFB, 0xAD67, 0x11d1, 0xAB, 0xCD, 0x00, 0xC0, 0x4F, 0xC3, 0x09, 0x36);
      Guid iicm = typeof(IContextMenu).GUID;
      Guid iise = typeof(IShellExtInit).GUID;
      if (Ole32.CoCreateInstance(
              ref CLSID_OpenWith,
              IntPtr.Zero,
              Ole32.CLSCTX.INPROC_SERVER,
              ref iicm,
              out iContextMenuPtr) == (int)HResult.S_OK) {
        iContextMenu = Marshal.GetObjectForIUnknown(iContextMenuPtr) as IContextMenu;

        IntPtr iShellExtInitPtr;
        if (Marshal.QueryInterface(
            iContextMenuPtr,
            ref iise,
            out iShellExtInitPtr) == (int)HResult.S_OK) {
          IShellExtInit iShellExtInit = Marshal.GetTypedObjectForIUnknown(iShellExtInitPtr, typeof(IShellExtInit)) as IShellExtInit;

          try {
            IntPtr doPtr;
            iShellExtInit.Initialize(IntPtr.Zero, itemArray.GetIDataObject(out doPtr), 0);

            Marshal.ReleaseComObject(iShellExtInit);
            Marshal.Release(iShellExtInitPtr);
            return true;
          } finally {

          }
        } else {
          if (iContextMenu != null) {
            Marshal.ReleaseComObject(iContextMenu);
            iContextMenu = null;
          }

          return false;
        }
      } else {
        iContextMenuPtr = IntPtr.Zero;
        iContextMenu = null;
        return false;
      }
    }
示例#18
0
		private void AddItem(IListItemEx item) {
			TreeNode itemNode = null;
			foreach (TreeNode node in this.ShellTreeView.Nodes) {
				try {
					itemNode = this.FromItem(item.Parent, node);
				} catch (Exception) {
					continue;
				}
				if (itemNode != null) break;
			}

			if (itemNode != null) {
				var node = new TreeNode(item.DisplayName);
				IListItemEx itemReal = FileSystemListItem.ToFileSystemItem(IntPtr.Zero, item.ParsingName.ToShellParsingName());
				node.Tag = itemReal;
				var oldnodearray = itemNode.Nodes.OfType<TreeNode>().ToList();
				if (!oldnodearray.Any(s => s.Tag != null && (s.Tag as IListItemEx).Equals(itemReal))) oldnodearray.Add(node);
				//var newArray = oldnodearray.OrderBy(o => o.Text).ToArray();
				this.ShellTreeView.BeginUpdate();
				itemNode.Nodes.Clear();
				itemNode.Nodes.AddRange(oldnodearray.OrderBy(o => o.Text).ToArray());
				this.ShellTreeView.EndUpdate();
				//if (itemNode != null && itemNode.Nodes.Count > 0) {
				if (itemNode?.Nodes?.Count > 0) {
					var newNode = itemNode.Nodes.OfType<TreeNode>().FirstOrDefault(s => (s?.Tag as IListItemEx).Equals(itemReal));
					if (newNode != null) {
						SetNodeImage(newNode.Handle, itemReal.PIDL, this.ShellTreeView.Handle, !(newNode.Parent != null && (newNode.Parent.Tag as IListItemEx).ParsingName == KnownFolders.Links.ParsingName));
					}
				}
			}
		}
示例#19
0
    /// <summary>
    /// Sets up each ribbon tab after select or navigate in ShellListView
    /// </summary>
    /// <param name="selectedItemsCount">The number of items selected</param>
    /// <param name="selectedItem">The last selected item</param>
    /// <remarks>
    /// Only used in SetupUIOnSelectOrNavigate
    /// </remarks>
    private void SetUpRibbonTabsVisibilityOnSelectOrNavigate(int selectedItemsCount, IListItemEx selectedItem) {
      #region Search Contextual Tab
      ctgSearch.Visibility = BooleanToVisibiliy(_ShellListView.CurrentFolder.IsSearchFolder);
      if (ctgSearch.Visibility == Visibility.Visible && !_ShellListView.CurrentFolder.IsSearchFolder) {
        ctgSearch.Visibility = Visibility.Collapsed;
        TheRibbon.SelectedTabItem = HomeTab;
      }
      #endregion

      #region Folder Tools Context Tab
      ctgFolderTools.Visibility = BooleanToVisibiliy((selectedItemsCount == 1 && selectedItem.IsFolder && selectedItem.IsFileSystem && !selectedItem.IsDrive && !selectedItem.IsNetworkPath));

      if (_AsFolder && ctgFolderTools.Visibility == Visibility.Visible) {
        TheRibbon.SelectedTabItem = ctgFolderTools.Items[0];
      }
      #endregion

      #region Drive Contextual Tab
      ctgDrive.Visibility = BooleanToVisibiliy(_ShellListView.CurrentFolder.IsDrive || (selectedItemsCount == 1 && (selectedItem.IsDrive || (selectedItem.Parent != null && selectedItem.Parent.IsDrive))));
      if (asDrive && ctgDrive.Visibility == Visibility.Visible && selectedItemsCount == 1 && selectedItem.IsDrive) {
        TheRibbon.SelectedTabItem = ctgDrive.Items[0];
      }
      #endregion

      #region Library Context Tab
      ctgLibraries.Visibility = BooleanToVisibiliy((selectedItemsCount == 1 && _ShellListView.CurrentFolder.ParsingName.Equals(KnownFolders.Libraries.ParsingName)) || (selectedItemsCount == 1 && selectedItem.Parent != null && selectedItem.Parent.ParsingName.Equals(KnownFolders.Libraries.ParsingName)));

      if (ctgLibraries.Visibility == Visibility.Visible && asLibrary) {
        TheRibbon.SelectedTabItem = ctgLibraries.Items[0];
      }

      /*
        if (ctgLibraries.Visibility == Visibility.Visible && _ShellListView.CurrentFolder.ParsingName.Equals(KnownFolders.Libraries.ParsingName)) {
          if (selectedItem != null && selectedItemsCount == 1)
            SetupLibrariesTab(ShellLibrary.Load(Path.GetFileNameWithoutExtension(selectedItem.ParsingName), false));
        } else if (ctgLibraries.Visibility == Visibility.Visible && _ShellListView.CurrentFolder.Parent.ParsingName.Equals(KnownFolders.Libraries.ParsingName)) {
          if (selectedItemsCount == 1)
            SetupLibrariesTab(ShellLibrary.Load(Path.GetFileNameWithoutExtension(_ShellListView.CurrentFolder.ParsingName), false));
        }
        if (selectedItemsCount == 0) {
          ctgLibraries.Visibility = Visibility.Collapsed;
        }
      */
      if (selectedItemsCount == 0)
        ctgLibraries.Visibility = Visibility.Collapsed;
      else if (selectedItemsCount > 1) { } else if (ctgLibraries.Visibility == Visibility.Visible && _ShellListView.CurrentFolder.ParsingName.Equals(KnownFolders.Libraries.ParsingName))
        SetupLibrariesTab(ShellLibrary.Load(Path.GetFileNameWithoutExtension(selectedItem.ParsingName), false));
      else if (ctgLibraries.Visibility == Visibility.Visible && _ShellListView.CurrentFolder.Parent.ParsingName.Equals(KnownFolders.Libraries.ParsingName))
        SetupLibrariesTab(ShellLibrary.Load(Path.GetFileNameWithoutExtension(_ShellListView.CurrentFolder.ParsingName), false));

      #endregion

      #region Archive Contextual Tab
      ctgArchive.Visibility = WIN.Visibility.Collapsed; //TODO: Restore this: BooleanToVisibiliy(selectedItemsCount == 1 && Archives.Contains(Path.GetExtension(selectedItem.ParsingName).ToLowerInvariant()));
      if (asArchive && ctgArchive.Visibility == Visibility.Visible)
        TheRibbon.SelectedTabItem = ctgArchive.Items[0];

      #endregion

      #region Application Context Tab
      ctgExe.Visibility = BooleanToVisibiliy(selectedItemsCount == 1 && !selectedItem.IsFolder && (Path.GetExtension(selectedItem.ParsingName).ToLowerInvariant() == ".exe" || Path.GetExtension(selectedItem.ParsingName).ToLowerInvariant() == ".msi"));
      if (asApplication && ctgExe.Visibility == Visibility.Visible) {
        TheRibbon.SelectedTabItem = ctgExe.Items[0];
      }
      #endregion

      #region Image Context Tab
      ctgImage.Visibility = BooleanToVisibiliy(selectedItemsCount == 1 && !selectedItem.IsFolder && Images.Contains(Path.GetExtension(selectedItem.ParsingName).ToLowerInvariant()));
      if (ctgImage.Visibility == Visibility.Visible) {
        try {
          if (new FileInfo(selectedItem.ParsingName).Length != 0) {
            using (var cvt = new Bitmap(selectedItem.ParsingName)) {
              imgSizeDisplay.WidthData = cvt.Width.ToString();
              imgSizeDisplay.HeightData = cvt.Height.ToString();

              if (asImage) TheRibbon.SelectedTabItem = ctgImage.Items[0];
            }
          }
        } catch (Exception) {
          MessageBox.Show("Image was invalid");
        }
      }
      #endregion

      #region Virtual Disk Context Tab
      ctgVirtualDisk.Visibility = BooleanToVisibiliy(selectedItemsCount == 1 && !selectedItem.IsFolder && Path.GetExtension(selectedItem.ParsingName).ToLowerInvariant() == ".iso");
      if (asVirtualDrive && ctgVirtualDisk.Visibility == Visibility.Visible) {
        TheRibbon.SelectedTabItem = ctgVirtualDisk.Items[0];
      }
      #endregion

    }
示例#20
0
 private void OnBreadcrumbbarNavigate(IListItemEx Destination) {
   this.IsNeedEnsureVisible = true;
   this.NavigationController(Destination);
 }
示例#21
0
 /// <summary>
 /// Navigates to the <paramref name="Destination"/> When Destination != Current Folder
 /// </summary>
 /// <param name="Destination">The folder you want to navigate to</param>
 private void NavigationController(IListItemEx Destination) {
   if (!Destination.Equals(this._ShellListView.CurrentFolder)) this._ShellListView.Navigate_Full(Destination, true);
 }
 public int GetHashCode(IListItemEx obj) => 0;
 public bool Equals(IListItemEx x, IListItemEx y) => x.Equals(y);
 public bool Equals(IListItemEx other) => other == null ? false : other.ParsingName.Equals(this.ParsingName, StringComparison.InvariantCultureIgnoreCase);
示例#25
0
    void Initialize(IListItemEx item) {
      Guid iise = typeof(IShellExtInit).GUID;
      var ishellViewPtr = (item.IsDrive || !item.IsFileSystem || item.IsNetworkPath) ? item.GetIShellFolder().CreateViewObject(IntPtr.Zero, typeof(IShellView).GUID) : item.Parent.GetIShellFolder().CreateViewObject(IntPtr.Zero, typeof(IShellView).GUID);
      var view = Marshal.GetObjectForIUnknown(ishellViewPtr) as IShellView;
      view?.GetItemObject(SVGIO.SVGIO_BACKGROUND, typeof(IContextMenu).GUID, out _Result);
      if (view != null) Marshal.ReleaseComObject(view);
      m_ComInterface = (IContextMenu)Marshal.GetTypedObjectForIUnknown(_Result, typeof(IContextMenu));
      m_ComInterface2 = m_ComInterface as IContextMenu2;
      m_ComInterface3 = m_ComInterface as IContextMenu3;
      IntPtr iShellExtInitPtr;
      if (Marshal.QueryInterface(_Result, ref iise, out iShellExtInitPtr) == (int)HResult.S_OK) {
        var iShellExtInit = Marshal.GetTypedObjectForIUnknown(iShellExtInitPtr, typeof(IShellExtInit)) as IShellExtInit;

        try {
          var hhh = IntPtr.Zero;
          iShellExtInit?.Initialize(_ShellView.CurrentFolder.PIDL, null, 0);
          if (iShellExtInit != null) Marshal.ReleaseComObject(iShellExtInit);
          Marshal.Release(iShellExtInitPtr);
        } catch {

        }
      }
      m_MessageWindow = new MessageWindow(this);
    }
示例#26
0
		private TreeNode FromItem(IListItemEx item) {
			foreach (TreeNode node in this.ShellTreeView.Nodes.OfType<TreeNode>().Where(w => {
				var nodeItem = w.Tag as IListItemEx;
				return nodeItem != null && (w.Tag != null && !nodeItem.ParsingName.Equals(KnownFolders.Links.ParsingName));
			})) 
			{
				if ((node.Tag as IListItemEx)?.Equals(item) == true) return node;
				TreeNode next = FromItem(item, node);
				if (next != null) return next;
			}
			return null;
		}
示例#27
0
		private void SelItem(IListItemEx item) {
			var node = this.FromItem(item);
			if(node == null) 
				this.FindItem(item.Clone());			
			else
				this.BeginInvoke((Action)(() => { this.ShellTreeView.SelectedNode = node; }));
		}
示例#28
0
    private void SetUpButtonsStateOnSelectOrNavigate(int selectedItemsCount, IListItemEx selectedItem) {
      btnBadges.IsEnabled = selectedItemsCount > 0;
      btnCopy.IsEnabled = selectedItemsCount > 0;
      btnCopyto.IsEnabled = selectedItemsCount > 0;
      btnMoveto.IsEnabled = selectedItemsCount > 0;
      btnCut.IsEnabled = selectedItemsCount > 0;
      btnDelete.IsEnabled = selectedItem != null && selectedItem.IsFileSystem;
      btnRename.IsEnabled = selectedItem != null && (selectedItem.IsFileSystem || (selectedItem.Parent != null && selectedItem.Parent.Equals(KnownFolders.Libraries)));
      btnProperties3.IsEnabled = selectedItemsCount > 0;
      if (selectedItem != null) {
        var rg = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" + Path.GetExtension(selectedItem.ParsingName) + @"\OpenWithProgids");
        if (rg == null)
          btnEdit.IsEnabled = false;
        else {
          string filetype = rg.GetValueNames()[0];
          rg.Close();

          using (var rgtype = Registry.ClassesRoot.OpenSubKey(filetype + @"\shell\edit\command")) {
            btnEdit.IsEnabled = !(rgtype == null);
          }
        }
      }

      btnSelAll.IsEnabled = selectedItemsCount != _ShellListView.Items.Count;
      btnSelNone.IsEnabled = selectedItemsCount > 0;
      btnShare.IsEnabled = selectedItemsCount == 1 && selectedItem.IsFolder;
      btnAdvancedSecurity.IsEnabled = selectedItemsCount == 1;
      btnHideSelItems.IsEnabled = _ShellListView.CurrentFolder.IsFileSystem;
    }
示例#29
0
		/// <summary>
		/// Moves the selected items to the destination on a separate thread
		/// </summary>
		/// <param name="dataObject">Contains the items you want to moe</param>
		/// <param name="destination">The place you want to move the items to</param>
		private void DoMove(IDataObject dataObject, IListItemEx destination) {
			var handle = this.Handle;
			var thread = new Thread(() => {
				IShellItem[] items =
					dataObject.GetDataPresent("FileDrop") ?
					items = ((F.DataObject)dataObject).GetFileDropList().OfType<String>().Select(s => FileSystemListItem.ToFileSystemItem(IntPtr.Zero, s.ToShellParsingName()).ComInterface).ToArray()
					:
					dataObject.ToShellItemArray().ToArray();

				try {
					var fo = new IIFileOperation(handle);
					foreach (var item in items) {
						fo.MoveItem(item, destination, null);
					}

					fo.PerformOperations();
				}
				catch (SecurityException) {
					throw;
				}
			});

			thread.SetApartmentState(ApartmentState.STA);
			thread.Start();
		}
示例#30
0
    private void miCreateSymlink_Click(object sender, RoutedEventArgs e) {
      var items = new IListItemEx[0];
      items = Clipboards.ContainsData("Shell IDList Array") ? Clipboards.GetDataObject().ToShellItemArray().ToArray().Select(s => FileSystemListItem.InitializeWithIShellItem(this._ShellListView.LVHandle, s)).ToArray() : Clipboards.GetFileDropList().OfType<string>().ToArray().Select(s => FileSystemListItem.ToFileSystemItem(this._ShellListView.LVHandle, s)).ToArray();
      var pathForDrop = _ShellListView.CurrentFolder.ParsingName.Replace(@"\\", @"\");
      var exePath = Utilities.AppDirectoryItem("BetterExplorerOperations.exe");
      var linkItems = items.Select(s => new LinkItem() {
        IsDirectory = s.IsFolder,
        DestinationData = pathForDrop + @"\" + s.DisplayName,
        SourceData = s.ParsingName
      }).ToArray();

      Task.Run(() => {
        using (var proc = new Process()) {
          proc.StartInfo = new ProcessStartInfo {
            FileName = exePath,
            Verb = "runas",
            UseShellExecute = true,
            Arguments = $"/env /user:Administrator \"{exePath}\""
          };

          proc.Start();
          ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3;
          var address = new EndpointAddress(new Uri("net.tcp://localhost:60000/BEComChannel"));
          var binding = new NetTcpBinding() { MaxReceivedMessageSize = 4000000, MaxBufferPoolSize = 4000000, MaxBufferSize = 4000000 };
          binding.Security = new NetTcpSecurity() { Mode = SecurityMode.Message };
          var factory = new ChannelFactory<IBetterExplorerCommunication>(binding, address);
          var beSvc = factory.CreateChannel();
          try {
            beSvc.CreateLink(new LinkData() { Items = linkItems });
          } finally {
            Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => this._ShellListView.UnvalidateDirectory()));
          }

          proc.WaitForExit();
          if (proc.ExitCode == 1)
            MessageBox.Show("Error in creating symlink", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
          else {
            Thread.Sleep(1000);
            Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => this._ShellListView.UnvalidateDirectory()));
          }
        }
      });

    }
示例#31
0
 public TabItem(IListItemEx ShellObject)
 {
     this.ShellObject = ShellObject;
     log = new NavigationLog(ShellObject);
 }
示例#32
0
 private void SetFOperation(IListItemEx obj, OperationType opType) {
   if (opType == OperationType.Copy)
     _ShellListView.DoCopy(obj);
   else if (opType == OperationType.Move)
     _ShellListView.DoMove(obj);
 }
示例#33
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ShellContextMenu"/>
 /// class.
 /// </summary>
 ///
 /// <param name="shellView">The <see cref="ShellView">ShellView</see> for this context menu</param>
 /// <param name="item">
 /// The item to which the context menu should refer.
 /// </param>
 public ShellContextMenu(ShellView shellView, IListItemEx item)
 {
     this._ShellView = shellView;
     Initialize(new IListItemEx[] { item });
 }
示例#34
0
    void Initialize(IListItemEx[] items) {
      this._Items = items;
      IntPtr[] pidls = new IntPtr[items.Length];
      IListItemEx parent = null;

      for (int n = 0; n < items.Length; ++n) {
        pidls[n] = Shell32.ILFindLastID(items[n].PIDL);

        if (parent == null) {
          if (items[n].ParsingName.Equals(ShellItem.Desktop.ParsingName)) {
            parent = FileSystemListItem.ToFileSystemItem(IntPtr.Zero, ShellItem.Desktop.Pidl);
          } else {
            parent = items[n].Parent;
          }
        } else if (!items[n].Parent.Equals(parent)) {
          throw new Exception("All shell items must have the same parent");
        }
      }

      if (items.Length == 0) {
        var desktop = KnownFolders.Desktop as ShellItem;
        var ishellViewPtr = desktop.GetIShellFolder().CreateViewObject(IntPtr.Zero, typeof(IShellView).GUID);
        var view = Marshal.GetObjectForIUnknown(ishellViewPtr) as IShellView;
        view.GetItemObject(SVGIO.SVGIO_BACKGROUND, typeof(IContextMenu).GUID, out _Result);
        Marshal.ReleaseComObject(view);
      } else {
        parent.GetIShellFolder().GetUIObjectOf(IntPtr.Zero, (uint)pidls.Length, pidls, typeof(IContextMenu).GUID, 0, out _Result);
      }

      m_ComInterface = (IContextMenu)Marshal.GetTypedObjectForIUnknown(_Result, typeof(IContextMenu));
      m_ComInterface2 = m_ComInterface as IContextMenu2;
      m_ComInterface3 = m_ComInterface as IContextMenu3;
      m_MessageWindow = new MessageWindow(this);
    }
示例#35
0
 public FOperationProgressSink(ShellView view)
 {
     this._View         = view;
     this.CurrentFolder = view.CurrentFolder;
 }
 public int GetHashCode(IListItemEx obj)
 {
     return(0);
 }
示例#37
0
 /// <summary>
 /// Creates initial tab
 /// </summary>
 /// <param name="win">The main window</param>
 /// <param name="sho">The shell object used for tab creation</param>
 private void CreateInitialTab(MainWindow win, IListItemEx sho) {
   var bmpSource = sho.ThumbnailSource(16, ShellThumbnailFormatOption.IconOnly, ShellThumbnailRetrievalOption.Default);
   var newt = new Wpf.Controls.TabItem(sho) {
     Header = sho.DisplayName,
     Icon = bmpSource
   };
   newt.PreviewMouseMove += this.Newt_PreviewMouseMove;
   newt.ToolTip = sho.ParsingName.Replace("%20", " ").Replace("%3A", ":").Replace("%5C", @"\");
   win.tcMain.CloneTabItem(newt);
 }
示例#38
0
 /// <summary>
 /// Declares a new item that is to be created in a specified location. Does this silently and automatically renames items if needed.
 /// </summary>
 /// <param name="destinationFolder">The destination folder that will contain the new item.</param>
 /// <param name="name">The new item name</param>
 /// <param name="attributes">A bitwise value that specifies the file system attributes for the file or folder. See GetFileAttributes for possible values</param>
 public void NewItem(IListItemEx destinationFolder, String name, FileAttributes attributes)
 {
     this._FileOperation.SetOperationFlags(FileOperationFlags.FOF_RENAMEONCOLLISION | FileOperationFlags.FOF_SILENT);
     this._FileOperation.NewItem(destinationFolder.ComInterface, attributes, name, null, null);
 }
示例#39
0
 public bool Equals(IListItemEx x, IListItemEx y) => x.Equals(y);
示例#40
0
    /// <summary>
    /// Initializes a new instance of the <see cref="ShellContextMenu"/> class.
    /// </summary>
    /// 
    /// <param name="items">
    /// The items to which the context menu should refer.
    /// </param>
    /// <param name="svgio"></param>
    /// <param name="view">The ShellView the ContextMenu is associated with</param>
    public ShellContextMenu(IListItemEx[] items, SVGIO svgio = SVGIO.SVGIO_SELECTION, ShellView view = null) {
      this._ShellView = view;

      if (svgio == SVGIO.SVGIO_BACKGROUND)
        Initialize(items[0]);
      else
        Initialize(items);
    }
示例#41
0
		private TreeNode FromItem(IListItemEx item, TreeNode rootNode) {
			foreach (TreeNode node in rootNode.Nodes) {
				if ((node.Tag as IListItemEx)?.Equals(item) == true) return node;
				TreeNode next = FromItem(item, node);
				if (next != null) return next;
			}
			return null;
		}
示例#42
0
        public ImageListEx(Int32 size)
        {
            var ptr = IntPtr.Zero;

            this._CurrentSize = size;
            ptr = ComCtl32.ImageList_Create(size, size, 0x00000020 | 0x00010000 | 0x00020000, 0, 1);
            this._IImageList        = (IImageList2)Marshal.GetObjectForIUnknown(ptr);
            this.Handle             = ptr;
            this._IconLoadingThread = new Thread(_IconsLoadingThreadRun)
            {
                IsBackground = true, Priority = ThreadPriority.Normal
            };
            this._IconLoadingThread.IsBackground = true;
            this._IconLoadingThread.SetApartmentState(ApartmentState.STA);
            this._IconLoadingThread.Start();
            this._IconCacheLoadingThread = new Thread(_IconCacheLoadingThreadRun)
            {
                IsBackground = true, Priority = ThreadPriority.BelowNormal
            };
            this._IconCacheLoadingThread.SetApartmentState(ApartmentState.STA);
            this._IconCacheLoadingThread.IsBackground = true;
            this._IconCacheLoadingThread.Start();
            this._OverlaysLoadingThread = new Thread(_OverlaysLoadingThreadRun)
            {
                IsBackground = true, Priority = ThreadPriority.BelowNormal
            };
            this._OverlaysLoadingThread.SetApartmentState(ApartmentState.STA);
            this._OverlaysLoadingThread.IsBackground = true;
            this._OverlaysLoadingThread.Start();
            this._UpdateSubitemValuesThread = new Thread(_UpdateSubitemValuesThreadRun)
            {
                Priority = ThreadPriority.BelowNormal
            };
            this._UpdateSubitemValuesThread.SetApartmentState(ApartmentState.STA);
            this._UpdateSubitemValuesThread.IsBackground = true;
            this._UpdateSubitemValuesThread.Start();
            this._RedrawingThread = new Thread(_RedrawingThreadRun)
            {
                IsBackground = true, Priority = ThreadPriority.Normal
            };
            this._RedrawingThread.SetApartmentState(ApartmentState.STA);
            this._RedrawingThread.IsBackground = true;
            this._RedrawingThread.Start();
            var defIconInfo = new Shell32.SHSTOCKICONINFO()
            {
                cbSize = (UInt32)Marshal.SizeOf(typeof(Shell32.SHSTOCKICONINFO))
            };

            Shell32.SHGetStockIconInfo(Shell32.SHSTOCKICONID.SIID_APPLICATION, Shell32.SHGSI.SHGSI_SYSICONINDEX, ref defIconInfo);
            this._ExeFallBackIndex = defIconInfo.iSysIconIndex;
            Shell32.SHGetStockIconInfo(Shell32.SHSTOCKICONID.SIID_SHIELD, Shell32.SHGSI.SHGSI_SYSICONINDEX, ref defIconInfo);
            this._ShieldIconIndex = defIconInfo.iSysIconIndex;

            Shell32.SHGetStockIconInfo(Shell32.SHSTOCKICONID.SIID_SHARE, Shell32.SHGSI.SHGSI_SYSICONINDEX, ref defIconInfo);
            this._SharedIconIndex = defIconInfo.iSysIconIndex;

            Shell32.SHGetStockIconInfo(Shell32.SHSTOCKICONID.SIID_FOLDER, Shell32.SHGSI.SHGSI_SYSICONINDEX, ref defIconInfo);
            this._FolderFallBackIndex = defIconInfo.iSysIconIndex;

            Shell32.SHGetStockIconInfo(Shell32.SHSTOCKICONID.SIID_DOCNOASSOC, Shell32.SHGSI.SHGSI_SYSICONINDEX, ref defIconInfo);
            this._DefaultFallBackIndex = defIconInfo.iSysIconIndex;
            var basePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            this._VideAddornerWide = FileSystemListItem.ToFileSystemItem(IntPtr.Zero, Path.Combine(basePath, "video_addorner_wide.png"));
            this._VideAddorner     = FileSystemListItem.ToFileSystemItem(IntPtr.Zero, Path.Combine(basePath, "video_addorner.png"));
        }
示例#43
0
		private void FindItem(IListItemEx item) {
			var nodeNext = this.ShellTreeView.Nodes.OfType<TreeNode>().FirstOrDefault(s => s.Tag != null && (s.Tag as IListItemEx).Equals(item));
			if (nodeNext == null) {
				parents.Push(item);
				if (item.Parent != null) {
					this.FindItem(item.Parent.Clone());
				}
			} else {
				while (parents.Count > 0) {
					var obj = parents.Pop();
					this.BeginInvoke((Action)(() => {
						var newNode = this.FromItem(obj);
						if (newNode != null && !newNode.IsExpanded) {
							newNode.Expand();
						}
					}));
				}
			}
		}
		public FOperationProgressSink(ShellView view) {
			this._View = view;
			this.CurrentFolder = view.CurrentFolder;
		}
示例#45
0
		private void DeleteItem(IListItemEx item) {
			TreeNode itemNode = null;
			foreach (TreeNode node in this.ShellTreeView.Nodes) {
				itemNode = this.FromItem(item, node);
				if (itemNode != null) break;
			}

			itemNode?.Remove();
		}
示例#46
0
 /// <summary>
 /// A generic constructor
 /// </summary>
 /// <param name="StartingLocation">This location will be added as the first item in <see cref="HistoryItemsList"/></param>
 public NavigationLog(IListItemEx StartingLocation)
 {
     HistoryItemsList = new List <IListItemEx>(new[] { StartingLocation });
     CurrentLocPos    = 0; //-1;
 }
示例#47
0
		private void RenameItem(IListItemEx prevItem, IListItemEx newItem) {
		  if (!newItem.Equals(prevItem)) {
		    this.DeleteItem(prevItem);
		    this.AddItem(newItem);
		  }
		}
示例#48
0
        /// <summary>
        /// Single instance callback handler.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="SingleInstanceApplication.InstanceCallbackEventArgs"/> instance containing the event data.</param>
        ///
        private void SingleInstanceCallback(Object sender, InstanceCallbackEventArgs args)
        {
            if (args == null || Dispatcher == null)
            {
                return;
            }
            var startUpLocation = Utilities.GetRegistryValue("StartUpLoc", KnownFolders.Libraries.ParsingName).ToString();

            Action <Boolean> d = x => {
                var win             = MainWindow as MainWindow;
                var windowsActivate = new CombinedWindowActivator();
                if (!x)
                {
                    return;
                }
                if (win == null)
                {
                    return;
                }
                win.StateChanged += Win_StateChanged;
                if (args?.CommandLineArgs == null || !args.CommandLineArgs.Any())
                {
                    return;
                }
                if (args.CommandLineArgs.Length == 1)
                {
                    win.Visibility = Visibility.Visible;
                    //if (win.WindowState == WindowState.Minimized) {
                    //	User32.ShowWindow((PresentationSource.FromVisual(win) as HwndSource).Handle, User32.ShowWindowCommands.Restore);
                    //}
                    //User32.ForceForegroundWindow(win);
                    windowsActivate.ActivateForm(win, null, IntPtr.Zero);
                }
                else
                {
                    if (args.CommandLineArgs[1] == "/nw")
                    {
                        new MainWindow()
                        {
                            IsMultipleWindowsOpened = true
                        }.Show();
                    }
                    else
                    {
                        IListItemEx sho = null;
                        if (args.CommandLineArgs[1] == "t")
                        {
                            win.Visibility = Visibility.Visible;
                            //if (win.WindowState == WindowState.Minimized)
                            //	User32.ShowWindow((PresentationSource.FromVisual(win) as HwndSource).Handle,
                            //		User32.ShowWindowCommands.Restore);
                            windowsActivate.ActivateForm(win, null, IntPtr.Zero);

                            sho = FileSystemListItem.ToFileSystemItem(IntPtr.Zero, startUpLocation.ToShellParsingName());
                        }
                        else
                        {
                            sho = FileSystemListItem.ToFileSystemItem(IntPtr.Zero, args.CommandLineArgs[1].ToShellParsingName());
                        }

                        if (!IsStartMinimized || win.tcMain.Items.Count == 0)
                        {
                            CreateInitialTab(win, sho);
                        }
                        else if ((Int32)Utilities.GetRegistryValue("IsRestoreTabs", "1") == 0)
                        {
                            win.tcMain.Items.Clear();
                            CreateInitialTab(win, sho);
                        }
                        else if (args.CommandLineArgs.Length > 1 && args.CommandLineArgs[1] != null)
                        {
                            if (args.CommandLineArgs[1] == "t")
                            {
                                CreateInitialTab(win, sho);
                            }
                            else
                            {
                                var cmd = args.CommandLineArgs[1];
                                sho = FileSystemListItem.ToFileSystemItem(IntPtr.Zero, cmd.ToShellParsingName());
                                CreateInitialTab(win, sho);
                            }
                        }
                        else
                        {
                            CreateInitialTab(win, sho);
                        }
                    }
                    //User32.ForceForegroundWindow(win);

                    windowsActivate.ActivateForm(win, null, IntPtr.Zero);
                }
            };

            Dispatcher.BeginInvoke(d, true);
        }
示例#49
0
 public bool Equals(IListItemEx other) => other == null ? false : other.ParsingName.Equals(this.ParsingName, StringComparison.InvariantCultureIgnoreCase);
示例#50
0
    public bool GetNewContextMenu(IListItemEx item, out IntPtr iContextMenuPtr, out IContextMenu iContextMenu) {
      Guid CLSID_NewMenu = new Guid("{D969A300-E7FF-11d0-A93B-00A0C90F2719}");
      Guid iicm = typeof(IContextMenu).GUID;
      Guid iise = typeof(IShellExtInit).GUID;
      if (Ole32.CoCreateInstance(
              ref CLSID_NewMenu,
              IntPtr.Zero,
              Ole32.CLSCTX.INPROC_SERVER,
              ref iicm,
              out iContextMenuPtr) == (int)HResult.S_OK) {
        iContextMenu = Marshal.GetObjectForIUnknown(iContextMenuPtr) as IContextMenu;

        IntPtr iShellExtInitPtr;
        if (Marshal.QueryInterface(
            iContextMenuPtr,
            ref iise,
            out iShellExtInitPtr) == (int)HResult.S_OK) {
          IShellExtInit iShellExtInit = Marshal.GetTypedObjectForIUnknown(
              iShellExtInitPtr, typeof(IShellExtInit)) as IShellExtInit;

          try {
            iShellExtInit.Initialize(item.PIDL, null, 0);

            Marshal.ReleaseComObject(iShellExtInit);
            Marshal.Release(iShellExtInitPtr);
            return true;
          } finally {

          }
        } else {
          if (iContextMenu != null) {
            Marshal.ReleaseComObject(iContextMenu);
            iContextMenu = null;
          }

          if (iContextMenuPtr != IntPtr.Zero) {
            Marshal.ReleaseComObject(iContextMenuPtr);
            iContextMenuPtr = IntPtr.Zero;
          }

          return false;
        }
      } else {
        iContextMenuPtr = IntPtr.Zero;
        iContextMenu = null;
        return false;
      }
    }
示例#51
0
 public int GetHashCode(IListItemEx obj) => 0;
示例#52
0
 /// <summary>
 /// Moves the source item into the destination with a new name
 /// </summary>
 /// <param name="source">The item being moved</param>
 /// <param name="destination">The location to be moved to</param>
 /// <param name="newName">The new name of the file</param>
 public void MoveItem(IShellItem source, IListItemEx destination, string newName)
 {
     this.ThrowIfDisposed();
     this._FileOperation.MoveItem(source, destination.ComInterface, newName, null);
 }
示例#53
0
        public void DrawIcon(IntPtr hdc, Int32 index, IListItemEx sho, User32.RECT iconBounds, Boolean isGhosted, Boolean isHot)
        {
            if (sho.OverlayIconIndex == -1)
            {
                this._OverlayQueue.Enqueue(index);
            }

            var isPerInstance = (sho.IconType & IExtractIconPWFlags.GIL_PERINSTANCE) == IExtractIconPWFlags.GIL_PERINSTANCE;

            if (this._CurrentSize != 16)
            {
                Int32  width        = 0;
                Int32  height       = 0;
                var    addornerType = this.GetAddornerType(sho);
                IntPtr hThumbnail   = IntPtr.Zero;
                if ((!sho.IsThumbnailLoaded && sho.IsIconLoaded) || (sho.IsThumbnailLoaded && !sho.IsIconLoaded) || (sho.IsThumbnailLoaded && sho.IsIconLoaded) || (!sho.IsThumbnailLoaded && !sho.IsIconLoaded))
                {
                    hThumbnail = sho.GetHBitmap(addornerType == 2 ? this._CurrentSize - 7 : this._CurrentSize, true);
                    if (hThumbnail != IntPtr.Zero)
                    {
                        Gdi32.ConvertPixelByPixel(hThumbnail, out width, out height);
                        if (addornerType > 0)
                        {
                            this.DrawWithAddorner(hdc, iconBounds, isGhosted, width, height, hThumbnail, addornerType);
                        }
                        else
                        {
                            Gdi32.NativeDraw(hdc, hThumbnail, iconBounds.Left + (iconBounds.Right - iconBounds.Left - width) / 2, iconBounds.Top + (iconBounds.Bottom - iconBounds.Top - height) / 2, width, height, isGhosted);
                        }
                        if (addornerType == 2)
                        {
                            width  = width + 7;
                            height = height + 7;
                        }
                        sho.IsNeedRefreshing = ((width > height && width != this._CurrentSize) || (width < height && height != this._CurrentSize) || (width == height && width != this._CurrentSize)) && !sho.IsOnlyLowQuality;
                        if (!sho.IsNeedRefreshing)
                        {
                            sho.IsThumbnailLoaded = true;
                            sho.IsIconLoaded      = true;
                        }
                    }
                }

                if (hThumbnail == IntPtr.Zero && !sho.IsThumbnailLoaded && !sho.IsIconLoaded || sho.IsNeedRefreshing)
                {
                    Task.Run(() => { this._ThumbnailsForCacheLoad.Enqueue(index); });
                }

                if (hThumbnail == IntPtr.Zero && !sho.IsIconLoaded && isPerInstance)
                {
                    Task.Run(() => { this._IconsForRetreval.Enqueue(index); });
                    this.DrawDefaultIcons(hdc, sho, iconBounds);
                }

                if (hThumbnail == IntPtr.Zero && (sho.IsIconLoaded || !isPerInstance))
                {
                    if (!sho.IsRCWSet && isPerInstance)
                    {
                        Task.Run(() => { this._IconsForRetreval.Enqueue(index); });
                        this.DrawDefaultIcons(hdc, sho, iconBounds);
                    }
                    else
                    {
                        hThumbnail = sho.GetHBitmap(this._CurrentSize, false);
                        Gdi32.ConvertPixelByPixel(hThumbnail, out width, out height);
                        Gdi32.NativeDraw(hdc, hThumbnail, iconBounds.Left + (iconBounds.Right - iconBounds.Left - width) / 2, iconBounds.Top + (iconBounds.Bottom - iconBounds.Top - height) / 2, width, height, isGhosted);
                    }
                }

                Gdi32.DeleteObject(hThumbnail);
                using (var g = Graphics.FromHdc(hdc)) {
                    if (this._ShellViewEx.ShowCheckboxes && this._ShellViewEx.View != ShellViewStyle.Details && this._ShellViewEx.View != ShellViewStyle.List)
                    {
                        /*
                         * var lvi = new LVITEMINDEX();
                         * lvi.iItem = index;
                         * lvi.iGroup = this._ShellViewEx.GetGroupIndex(index);
                         */
                        var iGroup = this._ShellViewEx.GetGroupIndex(index);
                        var lvItem = new LVITEM()
                        {
                            iItem = index, iGroupId = iGroup, iGroup = iGroup, mask = LVIF.LVIF_STATE, stateMask = LVIS.LVIS_SELECTED
                        };
                        var lvItemImageMask = new LVITEM()
                        {
                            iItem = index, iGroupId = iGroup, iGroup = iGroup, mask = LVIF.LVIF_STATE, stateMask = LVIS.LVIS_STATEIMAGEMASK
                        };
                        var res = User32.SendMessage(this._ShellViewEx.LVHandle, MSG.LVM_GETITEMW, 0, ref lvItemImageMask);

                        if (isHot || (UInt32)lvItemImageMask.state == (2 << 12))
                        {
                            res = User32.SendMessage(this._ShellViewEx.LVHandle, MSG.LVM_GETITEMW, 0, ref lvItem);
                            var checkboxOffsetH = 14;
                            var checkboxOffsetV = 2;
                            if (this._ShellViewEx.View == ShellViewStyle.Tile || this._ShellViewEx.View == ShellViewStyle.SmallIcon)
                            {
                                checkboxOffsetH = 2;
                            }
                            if (this._ShellViewEx.View == ShellViewStyle.Tile)
                            {
                                checkboxOffsetV = 5;
                            }

                            CheckBoxRenderer.DrawCheckBox(g, new Point(iconBounds.Left + checkboxOffsetH, iconBounds.Top + checkboxOffsetV),
                                                          lvItem.state != 0 ? System.Windows.Forms.VisualStyles.CheckBoxState.CheckedNormal : System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal);
                        }
                    }
                }
                if (sho.OverlayIconIndex > 0)
                {
                    if (this._CurrentSize > 180)
                    {
                        this._Jumbo.DrawOverlay(hdc, sho.OverlayIconIndex, new Point(iconBounds.Left, iconBounds.Bottom - (this._ShellViewEx.View == ShellViewStyle.Tile ? 5 : 0) - this._CurrentSize / 3), this._CurrentSize / 3);
                    }
                    else if (this._CurrentSize > 64)
                    {
                        this._Extra.DrawOverlay(hdc, sho.OverlayIconIndex, new Point(iconBounds.Left + 10 - (this._ShellViewEx.View == ShellViewStyle.Tile ? 5 : 0), iconBounds.Bottom - 50));
                    }
                    else
                    {
                        this._Large.DrawOverlay(hdc, sho.OverlayIconIndex, new Point(iconBounds.Left + 10 - (this._ShellViewEx.View == ShellViewStyle.Tile ? 5 : 0), iconBounds.Bottom - 32));
                    }
                }
                if (sho.ShieldedIconIndex > 0)
                {
                    if (this._CurrentSize > 180)
                    {
                        this._Jumbo.DrawIcon(hdc, sho.ShieldedIconIndex, new Point(iconBounds.Right - this._CurrentSize / 3 - 3, iconBounds.Bottom - this._CurrentSize / 3), this._CurrentSize / 3);
                    }
                    else if (this._CurrentSize > 64)
                    {
                        this._Extra.DrawIcon(hdc, sho.ShieldedIconIndex, new Point(iconBounds.Right - 43, iconBounds.Bottom - 50));
                    }
                    else
                    {
                        this._Large.DrawIcon(hdc, sho.ShieldedIconIndex, new Point(iconBounds.Right - 33, iconBounds.Bottom - 32));
                    }
                }
                if (sho.IsShared)
                {
                    if (this._CurrentSize > 180)
                    {
                        this._Jumbo.DrawIcon(hdc, this._SharedIconIndex, new Point(iconBounds.Right - this._CurrentSize / 3, iconBounds.Bottom - this._CurrentSize / 3), this._CurrentSize / 3);
                    }
                    else if (this._CurrentSize > 64)
                    {
                        this._Extra.DrawIcon(hdc, this._SharedIconIndex, new Point(iconBounds.Right - 40, iconBounds.Bottom - 50));
                    }
                    else
                    {
                        this._Large.DrawIcon(hdc, this._SharedIconIndex, new Point(iconBounds.Right - 30, iconBounds.Bottom - 32));
                    }
                }
                IListItemEx badge = this.GetBadgeForPath(sho.ParsingName);
                if (badge != null)
                {
                    var badgeIco = badge.GetHBitmap(this._CurrentSize, false, false, true);
                    Gdi32.ConvertPixelByPixel(badgeIco, out width, out height);
                    Gdi32.NativeDraw(hdc, badgeIco, iconBounds.Left + (iconBounds.Right - iconBounds.Left - _CurrentSize) / 2, iconBounds.Top + (iconBounds.Bottom - iconBounds.Top - _CurrentSize) / 2, _CurrentSize, isGhosted);
                    Gdi32.DeleteObject(badgeIco);
                    badge.Dispose();
                }

                if (this._ShellViewEx.View == ShellViewStyle.Tile)
                {
                    var lvi = new LVITEMINDEX();
                    lvi.iItem  = index;
                    lvi.iGroup = this._ShellViewEx.GetGroupIndex(index);
                    var lableBounds = new User32.RECT()
                    {
                        Left = 2
                    };
                    User32.SendMessage(this._ShellViewEx.LVHandle, MSG.LVM_GETITEMINDEXRECT, ref lvi, ref lableBounds);
                    using (var g = Graphics.FromHdc(hdc)) {
                        var lblrectTiles = new RectangleF(lableBounds.Left, iconBounds.Top + 6, lableBounds.Right - lableBounds.Left, 15);
                        if (this._ShellViewEx.RequestedCurrentLocation.ParsingName.Equals(KnownFolders.Computer.ParsingName) && (sho.IsDrive || sho.IsNetworkPath))
                        {
                            var fmt = new StringFormat();
                            fmt.Trimming      = StringTrimming.EllipsisCharacter;
                            fmt.Alignment     = StringAlignment.Center;
                            fmt.Alignment     = StringAlignment.Near;
                            fmt.FormatFlags   = StringFormatFlags.NoWrap | StringFormatFlags.FitBlackBox;
                            fmt.LineAlignment = StringAlignment.Center;

                            this.DrawComputerTiledModeView(sho, g, lblrectTiles, fmt);
                        }
                    }
                }
            }
            else
            {
                sho.IsThumbnailLoaded = true;
                Int32 width = 0, height = 0;
                if ((sho.IconType & IExtractIconPWFlags.GIL_PERCLASS) == IExtractIconPWFlags.GIL_PERCLASS)
                {
                    var hIconExe = sho.GetHBitmap(this._CurrentSize, false);
                    if (hIconExe != IntPtr.Zero)
                    {
                        sho.IsIconLoaded = true;
                        Gdi32.ConvertPixelByPixel(hIconExe, out width, out height);
                        Gdi32.NativeDraw(hdc, hIconExe, iconBounds.Left + (iconBounds.Right - iconBounds.Left - this._CurrentSize) / 2, iconBounds.Top + (iconBounds.Bottom - iconBounds.Top - this._CurrentSize) / 2,
                                         this._CurrentSize, isGhosted);
                        Gdi32.DeleteObject(hIconExe);
                    }
                }
                else if ((sho.IconType & IExtractIconPWFlags.GIL_PERINSTANCE) == IExtractIconPWFlags.GIL_PERINSTANCE)
                {
                    if (!sho.IsIconLoaded)
                    {
                        /*
                         * if (sho.IsNetworkPath || this._ShellViewEx.IsSearchNavigating) {
                         * Task.Run(() => {
                         *  this._IconsForRetreval.Enqueue(index);
                         * });
                         * } else {
                         * Task.Run(() => {
                         *  this._IconsForRetreval.Enqueue(index);
                         * });
                         * }
                         */
                        //Task.Run(() => {
                        this._IconsForRetreval.Enqueue(index);
                        //});

                        this._Small.DrawIcon(hdc, this._ExeFallBackIndex,
                                             new Point(iconBounds.Left + (iconBounds.Right - iconBounds.Left - this._CurrentSize) / 2, iconBounds.Top + (iconBounds.Bottom - iconBounds.Top - this._CurrentSize) / 2));
                    }
                    else
                    {
                        var hIconExe = sho.GetHBitmap(this._CurrentSize, false);
                        if (hIconExe != IntPtr.Zero)
                        {
                            sho.IsIconLoaded = true;
                            Gdi32.ConvertPixelByPixel(hIconExe, out width, out height);
                            Gdi32.NativeDraw(hdc, hIconExe, iconBounds.Left + (iconBounds.Right - iconBounds.Left - this._CurrentSize) / 2, iconBounds.Top + (iconBounds.Bottom - iconBounds.Top - this._CurrentSize) / 2,
                                             this._CurrentSize, isGhosted);
                            Gdi32.DeleteObject(hIconExe);
                        }
                    }
                }
                if (sho.OverlayIconIndex > 0)
                {
                    this._Small.DrawOverlay(hdc, sho.OverlayIconIndex, new Point(iconBounds.Left, iconBounds.Bottom - 16));
                }
                if (sho.ShieldedIconIndex > 0)
                {
                    this._Small.DrawIcon(hdc, sho.ShieldedIconIndex, new Point(iconBounds.Right - 9, iconBounds.Bottom - 10), 10);
                }
                if (sho.IsShared)
                {
                    this._Small.DrawIcon(hdc, this._SharedIconIndex, new Point(iconBounds.Right - 9, iconBounds.Bottom - 16));
                }

                IListItemEx badge = this.GetBadgeForPath(sho.ParsingName);
                if (badge != null)
                {
                    var badgeIco = badge.GetHBitmap(16, false, false, true);
                    Gdi32.ConvertPixelByPixel(badgeIco, out width, out height);
                    Gdi32.NativeDraw(hdc, badgeIco, iconBounds.Left, iconBounds.Top, 16, isGhosted);
                    Gdi32.DeleteObject(badgeIco);
                }
            }
        }
示例#54
0
 /// <summary>
 /// Moves items to a destination
 /// </summary>
 /// <param name="source">The item being moved</param>
 /// <param name="destination">The location to be moved to</param>
 public void MoveItems(IShellItemArray source, IListItemEx destination)
 {
     this.ThrowIfDisposed();
     this._FileOperation.MoveItems(source, destination.ComInterface);
 }
示例#55
0
 /// <summary>
 /// Declares a single item that is to be deleted. (Exception when <see cref="_Disposed"/> is <c>True</c>)
 /// </summary>
 /// <param name="source">The item to be deleted</param>
 /// <exception cref="ObjectDisposedException">When <see cref="_Disposed"/> is <c>True</c></exception>
 public void DeleteItem(IListItemEx source)
 {
     this.ThrowIfDisposed();
     this._FileOperation.DeleteItem(source.ComInterface, null);
 }
示例#56
0
    private void DrawComputerTiledModeView(IListItemEx sho, Graphics g, RectangleF lblrectTiles, StringFormat fmt) {
      var driveInfo = new DriveInfo(sho.ParsingName);
      if (driveInfo.IsReady) {
        ProgressBarRenderer.DrawHorizontalBar(g, new Rectangle((Int32)lblrectTiles.Left, (Int32)lblrectTiles.Bottom + 4, (Int32)lblrectTiles.Width - 10, 10));
        var fullProcent = (100 * (driveInfo.TotalSize - driveInfo.AvailableFreeSpace)) / driveInfo.TotalSize;
        var barWidth = (lblrectTiles.Width - 12) * fullProcent / 100;
        var rec = new Rectangle((Int32)lblrectTiles.Left + 1, (Int32)lblrectTiles.Bottom + 5, (Int32)barWidth, 8);
        var gradRec = new Rectangle(rec.Left, rec.Top - 1, rec.Width, rec.Height + 2);
        var criticalUsed = fullProcent >= 90;
        var warningUsed = fullProcent >= 75;
        var averageUsed = fullProcent >= 50;
        var brush = new LinearGradientBrush(gradRec,
                                                                        criticalUsed ? Color.FromArgb(255, 0, 0) : warningUsed ? Color.FromArgb(255, 224, 0) : averageUsed ? Color.FromArgb(0, 220, 255) : Color.FromArgb(199, 248, 165),
                                                                        criticalUsed ? Color.FromArgb(150, 0, 0) : warningUsed ? Color.FromArgb(255, 188, 0) : averageUsed ? Color.FromArgb(43, 84, 235) : Color.FromArgb(101, 247, 0),
                                                                        LinearGradientMode.Vertical);
        g.FillRectangle(brush, rec);
        brush.Dispose();
        var lblrectSubiTem3 = new RectangleF(lblrectTiles.Left, lblrectTiles.Bottom + 16, lblrectTiles.Width, 15);
        Font subItemFont = System.Drawing.SystemFonts.IconTitleFont;
        var subItemTextBrush = new SolidBrush(System.Drawing.SystemColors.ControlDarkDark);
        g.DrawString($"{ShlWapi.StrFormatByteSize(driveInfo.AvailableFreeSpace)} free of {ShlWapi.StrFormatByteSize(driveInfo.TotalSize)}",
                                                                        subItemFont, subItemTextBrush, lblrectSubiTem3, fmt);

        subItemFont.Dispose();
        subItemTextBrush.Dispose();
      }
    }
示例#57
-1
        void Initialize(IListItemEx item)
        {
            Guid iise          = typeof(IShellExtInit).GUID;
            var  ishellViewPtr = (item.IsDrive || !item.IsFileSystem || item.IsNetworkPath) ? item.GetIShellFolder().CreateViewObject(IntPtr.Zero, typeof(IShellView).GUID) : item.Parent.GetIShellFolder().CreateViewObject(IntPtr.Zero, typeof(IShellView).GUID);
            var  view          = Marshal.GetObjectForIUnknown(ishellViewPtr) as IShellView;

            view?.GetItemObject(SVGIO.SVGIO_BACKGROUND, typeof(IContextMenu).GUID, out _Result);
            if (view != null)
            {
                Marshal.ReleaseComObject(view);
            }
            m_ComInterface  = (IContextMenu)Marshal.GetTypedObjectForIUnknown(_Result, typeof(IContextMenu));
            m_ComInterface2 = m_ComInterface as IContextMenu2;
            m_ComInterface3 = m_ComInterface as IContextMenu3;
            IntPtr iShellExtInitPtr;

            if (Marshal.QueryInterface(_Result, ref iise, out iShellExtInitPtr) == (int)HResult.S_OK)
            {
                var iShellExtInit = Marshal.GetTypedObjectForIUnknown(iShellExtInitPtr, typeof(IShellExtInit)) as IShellExtInit;

                try {
                    var hhh = IntPtr.Zero;
                    iShellExtInit?.Initialize(_ShellView.CurrentFolder.PIDL, null, 0);
                    if (iShellExtInit != null)
                    {
                        Marshal.ReleaseComObject(iShellExtInit);
                    }
                    Marshal.Release(iShellExtInitPtr);
                } catch {
                }
            }
            m_MessageWindow = new MessageWindow(this);
        }