Exemplo n.º 1
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Application.Startup"/> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.StartupEventArgs"/> that contains the event data.</param>
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            var args = e.Args;
            var mode = ParseMode(args.FirstOrDefault());

            switch (mode)
            {
            case DatabaseAction.Attach:
                var attachWindow = new AttachWindow();
                attachWindow.ShowDialog();
                return;

            case DatabaseAction.Detach:
                if (!args.Skip(1).Any())
                {
                    MessageBox.Show("The database file path is not specified.", "Database Management Tool", MessageBoxButton.OK, MessageBoxImage.Error);
                    CloseApplication();
                    return;
                }

                var detachDatabaseWindow = new DetachWindow();
                detachDatabaseWindow.ShowDialog();
                return;

            default:
                CloseApplication();
                return;
            }
        }
Exemplo n.º 2
0
        // private void UpdatePos(object sender, RoutedEventArgs e)
        // {
        //     XYpos.Content = Mouse.GetPosition(this).X.ToString() + " "+Mouse.GetPosition(this).Y.ToString();
        // }

        private void Find(object sender, RoutedEventArgs e)
        {
            hWnd = FindWindow(null, TextBox0.Text);
            if (hWnd.ToInt32() != 0)
            {
                int           length     = GetWindowTextLength(hWnd);
                StringBuilder windowName = new StringBuilder(length + 1);
                GetWindowText(hWnd, windowName, windowName.Capacity);
                this.InfoText.Content = "获取到窗口句柄 : [" + hWnd.ToString() + "] (" + windowName.ToString() + ")";
                btnCtl.btnEnable      = true;

                AttachWindow subWin = new AttachWindow();
                subWin.hWnd = hWnd;
                subWin.Show();
            }
            else
            {
                this.InfoText.Content = "没有找到窗口!";
                btnCtl.btnEnable      = false;
            }
        }