コード例 #1
0
        /// <summary>
        /// Displays the progress dialog and starts the timer.
        /// </summary>
        /// <param name="parent">The dialog box's parent window.</param>
        public void Show(IWin32Window parent)
        {
            if (_state != ProgressDialogState.Stopped)
            {
                throw new InvalidOperationException("Timer is already running.");
            }

            if (parent == null)
            {
                parent = Form.ActiveForm;
            }
            IntPtr handle = (parent == null) ? IntPtr.Zero : parent.Handle;

            _nativeProgressDialog = (IProgressDialog)Activator.CreateInstance(_progressDialogType);
            _nativeProgressDialog.SetCancelMsg(_cancelMessage, null);
            if (ShowTimeRemaining)
            {
                _nativeProgressDialog.SetLine(3, "Estimating time remaining...", false, IntPtr.Zero);
            }
            //Temporary title for progressbar handler detection
            string guidTitle = Guid.NewGuid().ToString();

            _nativeProgressDialog.SetTitle(guidTitle);
            _nativeProgressDialog.StartProgressDialog(handle, null, _flags, IntPtr.Zero);
            //Workaround to manipulate progressbar style
            IntPtr handler = IntPtr.Zero;

            while (true)
            {
                handler = FindWindow(null, guidTitle);
                if (handler == IntPtr.Zero)
                {
                    Thread.Sleep(25);
                }
                else
                {
                    break;
                }
            }
            handler = FindWindowEx(handler, IntPtr.Zero, "DirectUIHWND", null);
            IntPtr childHandler = FindWindowEx(handler, IntPtr.Zero, "CtrlNotifySink", null);

            childHandler        = FindWindowEx(handler, childHandler, "CtrlNotifySink", null);
            childHandler        = FindWindowEx(handler, childHandler, "CtrlNotifySink", null);
            _progressBarHandler = FindWindowEx(childHandler, IntPtr.Zero, "msctls_progress32", null);
            //Real title
            _nativeProgressDialog.SetTitle(_title);
            _value = 0;
            _state = ProgressDialogState.Running;
            _nativeProgressDialog.Timer(PDTIMER.Reset, null);
        }
コード例 #2
0
        public void ShowDialog(params ProgressDialogBehavior[] flags)
        {
            if (_progressDialog != null)
            {
                return;
            }

            _progressDialog = new Win32ProgressDialog() as IProgressDialog;

            _progressDialog.SetTitle(_title);
            _progressDialog.SetCancelMsg(_cancelMessage, null);
            _progressDialog.SetLine(1, _line1, false, IntPtr.Zero);
            _progressDialog.SetLine(2, _line2, false, IntPtr.Zero);
            _progressDialog.SetLine(3, _line3, false, IntPtr.Zero);

            ProgressDialogBehavior dialogFlags = ProgressDialogBehavior.Normal;

            if (flags.Length != 0)
            {
                dialogFlags = flags[0];
                for (var i = 1; i < flags.Length; i++)
                {
                    dialogFlags = dialogFlags | flags[i];
                }
            }

            _progressDialog.StartProgressDialog(_parentHandle, null, dialogFlags, IntPtr.Zero);
        }
コード例 #3
0
        private void SetupProgressDialog(IKp2aApp app)
        {
            string currentMessage    = "Initializing...";
            string currentSubmessage = "";

            if (_progressDialogStatusLogger != null)
            {
                currentMessage    = _progressDialogStatusLogger.Message;
                currentSubmessage = _progressDialogStatusLogger.SubMessage;
            }

            if (_progressDialog != null)
            {
                var pd = _progressDialog;
                app.UiThreadHandler.Post(() =>
                {
                    pd.Dismiss();
                });
            }

            // Show process dialog
            _progressDialog = app.CreateProgressDialog(_activeActivity);
            _progressDialog.SetTitle(_app.GetResourceString(UiStringKey.progress_title));
            _progressDialogStatusLogger = new ProgressDialogStatusLogger(_app, _handler, _progressDialog);
            _progressDialogStatusLogger.UpdateMessage(currentMessage);
            _progressDialogStatusLogger.UpdateSubMessage(currentSubmessage);
        }
コード例 #4
0
        public HRESULT CreatePlaylist(IShellItemArray psia)
        {
            _ppd = new IProgressDialog();
            _ppd.StartProgressDialog(dwFlags: PROGDLG.PROGDLG_AUTOTIME);
            _ppd.SetTitle("Building Playlist");
            _ppd.SetLine(1, "Finding music files...", false);

            var pnsw = new INamespaceWalk();

            pnsw.Walk(psia, NAMESPACEWALKFLAG.NSWF_TRAVERSE_STREAM_JUNCTIONS | NAMESPACEWALKFLAG.NSWF_DONT_ACCUMULATE_RESULT, 4, this);
            _fCountingFiles = false;
            _ppd.SetLine(1, "Adding files...", false);
            _pstm = _GetPlaylistStream();
            var hr = WriteHeader();

            if (hr.Succeeded)
            {
                pnsw.Walk(psia, NAMESPACEWALKFLAG.NSWF_TRAVERSE_STREAM_JUNCTIONS | NAMESPACEWALKFLAG.NSWF_DONT_ACCUMULATE_RESULT | NAMESPACEWALKFLAG.NSWF_SHOW_PROGRESS, 4, this);
                hr = WriteFooter();
            }

            _pstm.Commit(0);

            if (hr.Succeeded)
            {
                var psiCreated = _GetPlaylistItem <IShellItem>();
                hr = OpenFolderAndSelectItem(psiCreated);
            }
            _ppd.StopProgressDialog();
            _ExitMessageLoop();
            return(0);
        }
コード例 #5
0
        /// <summary>
        /// Displays the progress dialog and starts the timer.
        /// </summary>
        /// <param name="parent">The dialog box's parent window.</param>
        public void Show(IWin32Window parent)
        {
            // Throw an exception if we are already running
            if (_state != ProgressDialogState.Stopped)
            {
                throw new InvalidOperationException("Timer is already running.");
            }

            // Get parent window handle
            if (parent == null)
            {
                parent = Form.ActiveForm;
            }
            IntPtr handle = (parent == null) ? IntPtr.Zero : parent.Handle;

            // Setup the window
            _nativeProgressDialog = (IProgressDialog)Activator.CreateInstance(_progressDialogType);
            _nativeProgressDialog.SetTitle(_title);
            _nativeProgressDialog.SetCancelMsg(_cancelMessage, null);
            if (ShowTimeRemaining)
            {
                _nativeProgressDialog.SetLine(3, "Estimating time remaining...", false, IntPtr.Zero);
            }

            // Create Window
            _nativeProgressDialog.StartProgressDialog(handle, null, _flags, IntPtr.Zero);

            _value = 0;
            _state = ProgressDialogState.Running;
            _nativeProgressDialog.Timer(PDTIMER.Reset, null);
        }
コード例 #6
0
ファイル: Main.cs プロジェクト: station7/NX_Game_Info
        internal static void StartProgressDialog(this IProgressDialog progressDialog, IntPtr hwndParent, string pwzString)
        {
            progressDialog.SetTitle(Application.ProductName);
            progressDialog.SetCancelMsg("Please wait until the current process is finished", IntPtr.Zero);
            progressDialog.SetLine(1, pwzString, false, IntPtr.Zero);

            progressDialog.StartProgressDialog(hwndParent, null, (uint)(IPD_Flags.Modal | IPD_Flags.AutoTime | IPD_Flags.NoMinimize), IntPtr.Zero);
            progressDialog.SetProgress(0, 100);
        }
コード例 #7
0
        public void ShowDialog(IWin32Window Parent, DialogFlags flags)
        {
            if (_ProgressDialog == null)
            {
                _ProgressDialog = (IProgressDialog) new ProgressDialogClass();

                _ProgressDialog.SetTitle(this._Title);
                _ProgressDialog.SetCancelMsg(this._CancelMessage, null);
                _ProgressDialog.SetLine(1, this._Line1, false, IntPtr.Zero);
                _ProgressDialog.SetLine(2, this._Line2, false, IntPtr.Zero);
                _ProgressDialog.SetLine(3, this._Line3, false, IntPtr.Zero);

                _ProgressDialog.StartProgressDialog(Parent.Handle, null, flags, IntPtr.Zero);
            }
        }
コード例 #8
0
ファイル: ProgressTask.cs プロジェクト: pythe/wristpass
        public ProgressTask(IKp2aApp app, Context ctx, RunnableOnFinish task)
        {
            _task = task;
            _handler = app.UiThreadHandler;
            _app = app;

            // Show process dialog
            _progressDialog = app.CreateProgressDialog(ctx);
            _progressDialog.SetTitle(_app.GetResourceString(UiStringKey.progress_title));
            _progressDialog.SetMessage("Initializing...");

            // Set code to run when this is finished
            _task.OnFinishToRun = new AfterTask(task.OnFinishToRun, _handler, _progressDialog);
            _task.SetStatusLogger(new ProgressDialogStatusLogger(_app, _handler, _progressDialog));
        }
コード例 #9
0
        public ProgressTask(IKp2aApp app, Context ctx, RunnableOnFinish task)
        {
            _task    = task;
            _handler = app.UiThreadHandler;
            _app     = app;

            // Show process dialog
            _progressDialog = app.CreateProgressDialog(ctx);
            _progressDialog.SetTitle(_app.GetResourceString(UiStringKey.progress_title));
            _progressDialog.SetMessage("Initializing...");

            // Set code to run when this is finished
            _task.OnFinishToRun = new AfterTask(task.OnFinishToRun, _handler, _progressDialog);
            _task.SetStatusLogger(new ProgressDialogStatusLogger(_app, _handler, _progressDialog));
        }
コード例 #10
0
ファイル: Main.cs プロジェクト: chrisatkins/NX_Game_Info
        private void openFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (backgroundWorkerProcess.IsBusy)
            {
                MessageBox.Show("Please wait until the current process is finished and try again.", Application.ProductName);
                return;
            }

            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Title            = "Open NX Game Files";
            openFileDialog.Filter           = "NX Game Files (*.xci;*.nsp;*.nro)|*.xci;*.nsp;*.nro|Gamecard Files (*.xci)|*.xci|Package Files (*.nsp)|*.nsp|Homebrew Files (*.nro)|*.nro|All Files (*.*)|*.*";
            openFileDialog.Multiselect      = true;
            openFileDialog.RestoreDirectory = true;
            openFileDialog.InitialDirectory = !String.IsNullOrEmpty(Properties.Settings.Default.InitialDirectory) && Directory.Exists(Properties.Settings.Default.InitialDirectory) ? Properties.Settings.Default.InitialDirectory : Directory.GetDirectoryRoot(Directory.GetCurrentDirectory());

            Process.log?.WriteLine("\nOpen File");

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                objectListView.Items.Clear();
                toolStripStatusLabel.Text = "";

                Properties.Settings.Default.InitialDirectory = Path.GetDirectoryName(openFileDialog.FileNames.First());
                Properties.Settings.Default.Save();

                progressDialog = (IProgressDialog) new ProgressDialog();
                progressDialog.StartProgressDialog(Handle, "Opening files");

                List <string> filenames = openFileDialog.FileNames.ToList();
                filenames.Sort();

                Process.log?.WriteLine("{0} files selected", filenames.Count);

                progressDialog.SetTitle(String.Format("Opening {0} files", filenames.Count));

                backgroundWorkerProcess.RunWorkerAsync(filenames);
            }
        }
コード例 #11
0
        public void InitTest()
        {
            var idlg = new IProgressDialog();

            idlg.SetTitle("Testing progress");
            idlg.SetCancelMsg("Don't like this?");
            idlg.SetLine(1, "Doing something really slow.", false);
            idlg.SetLine(2, @"C:\Users\you\Documents\GitHubRepos\Vanara\UnitTests\PInvoke\Shell32\ProgressDialogTests.cs", true);

            idlg.StartProgressDialog(IntPtr.Zero, null, PROGDLG.PROGDLG_AUTOTIME);
            var rnd = new Random();

            for (uint i = 0; i < 100; i++)
            {
                if (idlg.HasUserCancelled())
                {
                    break;
                }
                idlg.SetProgress(i, 100);
                Thread.Sleep(rnd.Next(50, 750));
            }
            idlg.StopProgressDialog();
        }
コード例 #12
0
ファイル: Main.cs プロジェクト: chrisatkins/NX_Game_Info
        private void openDirectoryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (backgroundWorkerProcess.IsBusy)
            {
                MessageBox.Show("Please wait until the current process is finished and try again.", Application.ProductName);
                return;
            }

            FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();

            folderBrowserDialog.SelectedPath = !String.IsNullOrEmpty(Properties.Settings.Default.InitialDirectory) && Directory.Exists(Properties.Settings.Default.InitialDirectory) ? Properties.Settings.Default.InitialDirectory : Directory.GetDirectoryRoot(Directory.GetCurrentDirectory());

            Process.log?.WriteLine("\nOpen Directory");

            if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                objectListView.Items.Clear();
                toolStripStatusLabel.Text = "";

                Properties.Settings.Default.InitialDirectory = folderBrowserDialog.SelectedPath;
                Properties.Settings.Default.Save();

                progressDialog = (IProgressDialog) new ProgressDialog();
                progressDialog.StartProgressDialog(Handle, String.Format("Opening files from directory {0}", folderBrowserDialog.SelectedPath));

                List <string> filenames = Directory.EnumerateFiles(folderBrowserDialog.SelectedPath, "*.*", SearchOption.AllDirectories)
                                          .Where(filename => filename.ToLower().EndsWith(".xci") || filename.ToLower().EndsWith(".nsp") || filename.ToLower().EndsWith(".nro")).ToList();
                filenames.Sort();

                Process.log?.WriteLine("{0} files selected", filenames.Count);

                progressDialog.SetTitle(String.Format("Opening {0} files from directory {1}", filenames.Count, folderBrowserDialog.SelectedPath));

                backgroundWorkerProcess.RunWorkerAsync(filenames);
            }
        }
コード例 #13
0
ファイル: ProgressDialog.cs プロジェクト: sverrirs/Rectify
        /// <summary>
        /// Displays the progress dialog and starts the timer.
        /// </summary>
        /// <param name="parent">The dialog box's parent window.</param>
        public void Show(IWin32Window parent)
        {
            if (_state != ProgressDialogState.Stopped)
                throw new InvalidOperationException("Timer is already running.");

            if (_parentForm == null)
                _parentForm = Form.ActiveForm;

            IntPtr handle = parent?.Handle ?? IntPtr.Zero;

            //_nativeProgressDialog = (IProgressDialog)Activator.CreateInstance(_progressDialogType);
            _nativeProgressDialog = (IProgressDialog) new ProgressDialogImpl();
            _nativeProgressDialog.SetTitle(_title);
            _nativeProgressDialog.SetCancelMsg(_cancelMessage, null);
            if (ShowTimeRemaining)
                _nativeProgressDialog.SetLine(3, "Estimating time remaining...", false, IntPtr.Zero);

            _nativeProgressDialog.StartProgressDialog(handle, null, _flags, IntPtr.Zero);

            _value = 0;
            _state = ProgressDialogState.Running;
            _nativeProgressDialog.Timer(PDTIMER.Reset, null);
            _statePollingTimer.Change(TimeSpan.FromMilliseconds(250), TimeSpan.FromMilliseconds(250));
        }
コード例 #14
0
        private void RunProgressDialog(IntPtr owner, object argument)
        {
            if (_backgroundWorker.IsBusy)
            {
                throw new InvalidOperationException(Resources.ProgressDialogRunning);
            }

            if (Animation != null)
            {
                try
                {
                    _currentAnimationModuleHandle = Animation.LoadLibrary();
                }
                catch (Win32Exception ex)
                {
                    throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Resources.AnimationLoadErrorFormat, ex.Message), ex);
                }
                catch (FileNotFoundException ex)
                {
                    throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Resources.AnimationLoadErrorFormat, ex.Message), ex);
                }
            }

            _cancellationPending = false;
            _dialog = new Interop.ProgressDialog();
            _dialog.SetTitle(WindowTitle);
            if (Animation != null)
            {
                _dialog.SetAnimation(_currentAnimationModuleHandle, (ushort)Animation.ResourceId);
            }

            if (CancellationText.Length > 0)
            {
                _dialog.SetCancelMsg(CancellationText, null);
            }
            _dialog.SetLine(1, Text, UseCompactPathsForText, IntPtr.Zero);
            _dialog.SetLine(2, Description, UseCompactPathsForDescription, IntPtr.Zero);

            ProgressDialogFlags flags = ProgressDialogFlags.Normal;

            if (owner != IntPtr.Zero)
            {
                flags |= ProgressDialogFlags.Modal;
            }
            switch (ProgressBarStyle)
            {
            case ProgressBarStyle.None:
                flags |= ProgressDialogFlags.NoProgressBar;
                break;

            case ProgressBarStyle.MarqueeProgressBar:
                if (NativeMethods.IsWindowsVistaOrLater)
                {
                    flags |= ProgressDialogFlags.MarqueeProgress;
                }
                else
                {
                    flags |= ProgressDialogFlags.NoProgressBar; // Older than Vista doesn't support marquee.
                }
                break;
            }
            if (ShowTimeRemaining)
            {
                flags |= ProgressDialogFlags.AutoTime;
            }
            if (!ShowCancelButton)
            {
                flags |= ProgressDialogFlags.NoCancel;
            }
            if (!MinimizeBox)
            {
                flags |= ProgressDialogFlags.NoMinimize;
            }

            _dialog.StartProgressDialog(owner, null, flags, IntPtr.Zero);
            _backgroundWorker.RunWorkerAsync(argument);
        }
コード例 #15
0
        /// <summary>
        /// Displays the progress dialog and starts the timer.
        /// </summary>
        /// <param name="parent">The dialog box's parent window.</param>
        public void Show(IWin32Window parent)
        {
            // Throw an exception if we are already running
            if (_state != ProgressDialogState.Stopped)
                throw new InvalidOperationException("Timer is already running.");

            // Get parent window handle
            if (parent == null) parent = Form.ActiveForm;
            IntPtr handle = (parent == null) ? IntPtr.Zero : parent.Handle;

            // Setup the window
            _nativeProgressDialog = (IProgressDialog)Activator.CreateInstance(_progressDialogType);
            _nativeProgressDialog.SetTitle(_title);
            _nativeProgressDialog.SetCancelMsg(_cancelMessage, null);
            if (ShowTimeRemaining)
                _nativeProgressDialog.SetLine(3, "Estimating time remaining...", false, IntPtr.Zero);

            // Create Window
            _nativeProgressDialog.StartProgressDialog(handle, null, _flags, IntPtr.Zero);

            _value = 0;
            _state = ProgressDialogState.Running;
            _nativeProgressDialog.Timer(PDTIMER.Reset, null);
        }