/// <summary>
        ///     Get the file selected by user.
        /// </summary>
        /// <returns><see cref="ShellFile" />.</returns>
        public ShellFile GetShellFile()
        {
            var        fileDialogNative = (IFileSaveDialog)this.FileDialogInternal.FileDialogNative;
            IShellItem shellItem;

            fileDialogNative.GetResult(out shellItem);
            if (shellItem == null)
            {
                return(null);
            }
            return(ShellFactory.FromShellItem(new ShellItem((IShellItem2)shellItem)) as ShellFile);
        }
        /// <summary>
        ///     Create a new instance of the <see cref="ShellObject" /> class.
        /// </summary>
        /// <param name="pidl"><c>PIDL</c>。</param>
        /// <param name="riid"><c>GUID</c>。</param>
        /// <returns></returns>
        private static ShellObject CreateShellObject(IntPtr pidl, ref Guid riid)
        {
            IShellItem2 shellItem2;
            var         code = ShellNativeMethods.SHCreateItemFromIDList(pidl, ref riid, out shellItem2);

            if (HRESULT.Failed(code))
            {
                return(null);
            }

            return(ShellFactory.FromShellItem(new ShellItem(shellItem2)));
        }
Beispiel #3
0
        public HRESULT OnFolderChanging(IFileDialog pfd, IShellItem psiFolder)
        {
            var shellFolder = ShellFactory.FromShellItem(new ShellItem(psiFolder)) as ShellFolder;

            var change = true;

            if (!this.firstFolderChanged)
            {
                change = this.Dialog.RaiseFolderChangingEvent(shellFolder);
            }

            return(change ? COMErrorCodes.S_OK : COMErrorCodes.S_FALSE);
        }
Beispiel #4
0
 public void ReachServer()
 {
     try
     {
         var shell = new ShellFactory().Create();
         shell.ReachServer();
     }
     catch (Exception ex)
     {
         this.Logger.WriteException(ex);
         throw;
     }
 }
        HRESULT IExplorerBrowserEvents.OnNavigationComplete(IntPtr pidlFolder)
        {
            using (var folderView = FolderView.Create(this))
            {
                this.FolderSettings.ViewMode = folderView.ViewMode;
            }

            var newLocation = ShellFactory.FromShellItem(ShellItem.FromPIDL((PIDL)pidlFolder));
            var args        = new NavigationCompletedEventArgs(newLocation);

            OnNavigationCompleted(args);

            return(COMErrorCodes.S_OK);
        }
Beispiel #6
0
            public SimpleSession(SecuritySystem security, FileSystem filesystem, ShellFactory shells, Terminal terminal, int userID)
            {
                this.security   = security;
                this.filesystem = filesystem;
                this.shells     = shells;
                this.terminal   = terminal;
                this.userID     = userID;


                // get user's home directory
                homeDir = (Directory)filesystem.Find(security.UserHomeDirectory(userID));

                // identify user's shell
                shell = shells.CreateShell(security.UserPreferredShell(UserID), this);
            }
        public IEnumerable <ShellObject> GetSelectedItems()
        {
            var shellItemArray = GetSelectedItemsArray();

            var count = ShellItemArray.GetShellItemCount(shellItemArray);

            for (var index = 0; index < count; ++index)
            {
                var shellItem   = ShellItemArray.GetShellItemAt(shellItemArray, index);
                var shellObject = ShellFactory.FromShellItem(new ShellItem((IShellItem2)shellItem));
                if (shellObject != null)
                {
                    yield return(shellObject);
                }
            }
        }
Beispiel #8
0
        public bool MoveNext()
        {
            if (this.enumIdList == null)
            {
                return(false);
            }

            const uint itemsRequested = 1;
            IntPtr     item;
            uint       numItemsReturned;
            var        hr = this.enumIdList.Next(itemsRequested, out item, out numItemsReturned);

            if (HRESULT.Failed(hr) || numItemsReturned < itemsRequested)
            {
                return(false);
            }

            this.Current = ShellFactory.FromShellItem(ShellItem.FromIdList(item, this.Parent.ShellFolderItem));
            return(true);
        }
        /// <summary>
        ///     Gets a collection of files selected by the user.
        /// </summary>
        /// <returns>A collection of files.</returns>
        public IEnumerable <ShellFile> GetShellFiles()
        {
            var fileDialogNative = (IFileOpenDialog)this.FileDialogInternal.FileDialogNative;

            IShellItemArray shellItemArray;

            fileDialogNative.GetResults(out shellItemArray);

            var count = ShellItemArray.GetShellItemCount(shellItemArray);

            for (var index = 0; index < count; ++index)
            {
                var shellItem = ShellItemArray.GetShellItemAt(shellItemArray, index);
                var shellFile = ShellFactory.FromShellItem(new ShellItem((IShellItem2)shellItem)) as ShellFile;
                if (shellFile != null)
                {
                    yield return(shellFile);
                }
            }
        }
            public ClientRt(TcpClient client, X509Certificate2 certificate, ShellFactory factory)
            {
                //client disposed in caller on throw
                this.client      = client;
                this.certificate = certificate;
                using (var disposer = new Disposer())
                {
                    start    = DateTime.Now;
                    last     = DateTime.Now;
                    shell    = factory.Create();
                    endpoint = client.Client.RemoteEndPoint as IPEndPoint;
                    reader   = new Runner(new Runner.Args {
                        ThreadName = string.Format("Client_{0}", endpoint)
                    });
                    disposer.Push(reader);

                    disposer.Push(Dispose); //ensure cleanup order
                    reader.Run(ReadLoop);
                    disposer.Clear();
                }
            }
Beispiel #11
0
 public SimpleSessionManager(SecuritySystem security, FileSystem filesystem, ShellFactory shells)
 {
     this.security   = security;
     this.filesystem = filesystem;
     this.shells     = shells;
 }
Beispiel #12
0
        static void Main(string[] args)
        {
            var shell = ShellFactory.DefaultShell();

            shell.Start();
        }