public bool ShowDialog(ref Color?wpfColor)
        {
            var wpfMainWindowHandle = new WindowInteropHelper(Application.Current.MainWindow).Handle;
            var win32Parent         = new System.Windows.Forms.NativeWindow();

            win32Parent.AssignHandle(wpfMainWindowHandle);

            var colorDialog = new System.Windows.Forms.ColorDialog();

            if (wpfColor != null)
            {
                colorDialog.Color = System.Drawing.Color.FromArgb(
                    wpfColor.Value.A, wpfColor.Value.R, wpfColor.Value.G, wpfColor.Value.B);
            }

            var dialogResult = colorDialog.ShowDialog(win32Parent);

            var result = false;

            if (dialogResult == System.Windows.Forms.DialogResult.OK)
            {
                var drawingColor = colorDialog.Color;
                wpfColor = Color.FromArgb(drawingColor.A, drawingColor.R, drawingColor.G, drawingColor.B);
                result   = true;
            }

            return(result);
        }
Exemplo n.º 2
0
        private System.Windows.Forms.IWin32Window GetWinFormsIWin32WindowFromWpfWindow(Window window)
        {
            var windowHandle = (new System.Windows.Interop.WindowInteropHelper(window)).Handle;

            var win32Window = new System.Windows.Forms.NativeWindow();

            win32Window.AssignHandle(windowHandle);

            return(win32Window);
        }
Exemplo n.º 3
0
        private void accept_Click(object sender, RoutedEventArgs e)
        {
            string name = nameTextBox.Text;
            DateTime born = birthday.Value;

            MyWindowsFormsLibrary.BirthdayDetails dlg = new MyWindowsFormsLibrary.BirthdayDetails();
            dlg.SetDetails(name + " was born on " + born.ToLongDateString());

            WindowInteropHelper helper = new WindowInteropHelper(this);

            System.Windows.Forms.NativeWindow nw = new System.Windows.Forms.NativeWindow();
            nw.AssignHandle(helper.Handle);

            dlg.Show(nw);
        }
Exemplo n.º 4
0
        private void AddFolder()
        {
            var openFolderDialog = new System.Windows.Forms.FolderBrowserDialog()
            {
                ShowNewFolderButton = false,
                Description         = Resources.Strings.AddFolderDescription,
            };

            var win32Window = new System.Windows.Forms.NativeWindow();

            win32Window.AssignHandle(new System.Windows.Interop.WindowInteropHelper(Application.Current.MainWindow).Handle);

            if (openFolderDialog.ShowDialog(win32Window) == System.Windows.Forms.DialogResult.OK)
            {
                var paths = System.IO.SafeDirectory.SafeEnumerateFiles(openFolderDialog.SelectedPath, "*.exe", System.IO.SearchOption.AllDirectories);
                this.AddPaths(paths);
            }
        }