コード例 #1
0
      ///// <summary>
      ///// Handles the Deactivated event of the Window control.
      ///// </summary>
      ///// <param name="sender">The source of the event.</param>
      ///// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
      //private void OnWindowDeactivated(object sender, EventArgs e)
      //{
      //   if ((_host == null || !_host.IsClosing) && Properties.Settings.Default..AutoHide)
      //   {
      //      HideWindow();
      //   }
      //}

      /// <summary>
      /// Handles the Loaded event of the Window control.
      /// </summary>
      /// <param name="sender">The source of the event.</param>
      /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
      private void OnWindowLoaded(object sender, RoutedEventArgs e)
      {
         //buffer.Document.IsColumnWidthFlexible = false;
         try
         {
            _host = new PoshHost((IPSUI)this);
         }
         catch (Exception ex)
         {
            MessageBox.Show("Can't create PowerShell interface, are you sure PowerShell is installed? \n" + ex.Message + "\nAt:\n" + ex.Source, "Error Starting PoshConsole", MessageBoxButton.OK, MessageBoxImage.Stop);
            Application.Current.Shutdown(1);
         }

         // TODO: put back the (extra) user-settable object ...
         // note that it ought to just be an "object" so you could set it to anything
         //Binding statusBinding = new Binding("StatusText"){ Source = _host.Options };
         //statusTextBlock.SetBinding(TextBlock.TextProperty, statusBinding);


         if (PoshConsole.Interop.NativeMethods.IsUserAnAdmin())
         {
            // StatusBarItems:: Title, Separator, Admin, Separator, Status
            ElevatedButton.ToolTip = "PoshConsole is running as Administrator";
            ElevatedButton.IsEnabled = false;
            ElevatedButton.IsChecked = true;
            //el = status.Items[2] as StatusBarItem;
            //if (el != null)
            //{
            //   el.Content = "Elevated!";
            //   el.Foreground = new SolidColorBrush(Color.FromRgb((byte)204, (byte)119, (byte)17));
            //   el.ToolTip = "PoshConsole is running as Administrator";
            //   el.Cursor = this.Cursor;
            //}
         }
         Cursor = Cursors.IBeam;
      }
コード例 #2
0
ファイル: PoshOptions.cs プロジェクト: ForNeVeR/PoshConsole
 public PoshOptions(PoshHost host, IPoshConsoleControl console)
 {
    _host = host;
    _console = console;
    _xamlUI = new PoshWpfConsole(console);
 }