- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个更大的 powershell 应用程序,它使用拖放来处理引号。一切正常,但仅在 ISE 中。当我通过桌面上的快捷方式使用脚本时 (C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -NoProfile -file "D:\Powershell\test\dragndrop.ps1") 拖放是不工作。
错误信息是:
找不到类型 [System.Windows.DragDropEffects]
我的PowerShell版本:
Name Value
---- -----
PSVersion 5.1.18362.145
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.18362.145
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Add-Type -AssemblyName System.Collections
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
Add-Type -AssemblyName Microsoft.Office.Interop.Excel
[System.Windows.Forms.Application]::EnableVisualStyles();
$form = New-Object System.Windows.Forms.Form
$form.Visible = $false
[void]$form.SuspendLayout()
$form.ClientSize = New-Object System.Drawing.Size(320,380)
$form.StartPosition = 'CenterScreen'
$form.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedSingle
$form.MaximizeBox = $false
$form.MinimizeBox = $false
$form.HelpButton = $true
$CTRL_TabCtrl = New-Object System.Windows.Forms.TabControl
$CTRL_TabCtrl.Location = New-Object System.Drawing.Point(5,5)
$CTRL_TabCtrl.Size = New-Object System.Drawing.Size(310,370)
[void]$form.Controls.Add($CTRL_TabCtrl)
$CTRL_Tab1 = New-Object System.Windows.Forms.TabPage
$CTRL_Tab1.AutoSize = $true
$CTRL_Tab1.Text = 'Chose Quote'
$CTRL_Tab1.TabIndex = 1
[void]$CTRL_TabCtrl.Controls.Add($CTRL_Tab1)
$CTRL_Tab2 = New-Object System.Windows.Forms.TabPage
$CTRL_Tab2.AutoSize = $true
$CTRL_Tab2.Text = 'Settings'
$CTRL_Tab2.TabIndex = 2
[void]$CTRL_TabCtrl.Controls.Add($CTRL_Tab2)
$CTRL_label1 = New-Object System.Windows.Forms.Label
$CTRL_label1.Location = New-Object System.Drawing.Point(10,10)
$CTRL_label1.Size = New-Object System.Drawing.Size(280,20)
$CTRL_label1.Text = 'Please select quote (PDF or Excel):'
$CTRL_label1.Name = 'Label1'
$CTRL_label1.Add_MouseHover( $showHelp )
[void]$CTRL_Tab1.Controls.Add($CTRL_label1)
$CTRL_PathQuote = New-Object System.Windows.Forms.TextBox
$CTRL_PathQuote.Location = New-Object System.Drawing.Point(10,30)
$CTRL_PathQuote.Size = New-Object System.Drawing.Size(275,20)
$CTRL_PathQuote.MaxLength = 250
$CTRL_PathQuote.Name = 'PathQuote'
$CTRL_PathQuote.Add_MouseHover( $showHelp )
[void]$CTRL_Tab1.Controls.Add($CTRL_PathQuote)
$CTRL_UploadButton = New-Object System.Windows.Forms.Button
$CTRL_UploadButton.Location = New-Object System.Drawing.Point(10,60)
$CTRL_UploadButton.Size = New-Object System.Drawing.Size(120,23)
$CTRL_UploadButton.Text = 'Select File...'
$CTRL_UploadButton.Name = 'UploadButton'
$CTRL_UploadButton.Add_MouseHover( $showHelp )
#$CTRL_UploadButton.Add_Click( { Get-FileName-Dialog -textBox $CTRL_PathQuote } )
[void]$CTRL_Tab1.Controls.Add($CTRL_UploadButton)
$CTRL_label3 = New-Object System.Windows.Forms.Label
$CTRL_label3.Location = New-Object System.Drawing.Point(10,100)
$CTRL_label3.Size = New-Object System.Drawing.Size(280,20)
$CTRL_label3.Text = 'Or drop quote here: (drag && drop):'
$CTRL_label3.Name = 'Label3'
$CTRL_label3.Add_MouseHover( $showHelp )
[void]$CTRL_Tab1.Controls.Add($CTRL_label3)
$CTRL_PictureBox = New-Object Windows.Forms.PictureBox
$CTRL_PictureBox.Location = New-Object System.Drawing.Point(10,120)
$CTRL_PictureBox.Size = New-Object System.Drawing.Size(280,174)
$CTRL_PictureBox.BorderStyle = [System.Windows.Forms.BorderStyle]::FixedSingle
$CTRL_PictureBox.AllowDrop = $true
$CTRL_PictureBox.Add_DragOver({
if ($_.Data.GetDataPresent([System.Windows.Forms.DataFormats]::FileDrop)) {
foreach ($filename in $_.Data.GetData([System.Windows.Forms.DataFormats]::FileDrop)) {
if( @( '.pdf', '.xlsx').Contains( [System.IO.Path]::GetExtension($filename).ToLower() ) ) {
$_.Effect = [System.Windows.DragDropEffects]::Copy
$CTRL_PictureBox.BackColor = [System.Drawing.Color]::DarkGray
}
else {
$_.Effect = [System.Windows.DragDropEffects]::None
$CTRL_PictureBox.BackColor = [System.Drawing.Color]::Transparent
}
break #only first file
}
}
})
$CTRL_PictureBox.Add_DragDrop({
if ($_.Data.GetDataPresent([System.Windows.Forms.DataFormats]::FileDrop)) {
foreach ($filename in $_.Data.GetData([System.Windows.Forms.DataFormats]::FileDrop)) {
if( @( '.pdf', '.xlsx').Contains( [System.IO.Path]::GetExtension($filename).ToLower() ) ) {
$_.Effect = [System.Windows.DragDropEffects]::All
$CTRL_PathQuote.Text = $filename
}
else {
$_.Effect = [System.Windows.DragDropEffects]::None
}
break #only first file
}
}
})
[void]$CTRL_Tab1.Controls.Add($CTRL_PictureBox)
$CTRL_OKButton1 = New-Object System.Windows.Forms.Button
$CTRL_OKButton1.Location = New-Object System.Drawing.Point(70,310)
$CTRL_OKButton1.Size = New-Object System.Drawing.Size(75,23)
$CTRL_OKButton1.Text = 'Start'
$CTRL_OKButton1.DialogResult = [System.Windows.Forms.DialogResult]::OK
$form.AcceptButton = $CTRL_OKButton1
[void]$CTRL_Tab1.Controls.Add($CTRL_OKButton1)
$CTRL_OKButton1.Enabled = $false
$CTRL_CancelButton1 = New-Object System.Windows.Forms.Button
$CTRL_CancelButton1.Location = New-Object System.Drawing.Point(150,310)
$CTRL_CancelButton1.Size = New-Object System.Drawing.Size(75,23)
$CTRL_CancelButton1.Text = 'Abbrechen'
$CTRL_CancelButton1.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
$form.CancelButton = $CTRL_CancelButton1
[void]$CTRL_Tab1.Controls.Add($CTRL_CancelButton1)
$scriptBlock_OkButton1 = { $CTRL_PathQuote.Text.Trim().Length -gt 0 -and (Test-Path -Path $CTRL_PathQuote.Text -PathType leaf) }
$scriptBlock_PathQuoteChanged = {
$CTRL_OKButton1.Enabled = & $scriptBlock_OkButton1;
$CTRL_PictureBox.BackColor = [System.Drawing.Color]::Transparent
if( !$CTRL_OKButton1.Enabled ) {
$CTRL_PictureBox.Image = $dragnDropImg
}
else {
$CTRL_PictureBox.Image = $dragnDropOkImg
}
}
$CTRL_OKButton1.Enabled = & $scriptBlock_OkButton1
[void]$CTRL_PathQuote.Add_TextChanged( { & $scriptBlock_PathQuoteChanged } )
[void]$CTRL_PictureBox.Add_DragLeave( { & $scriptBlock_PathQuoteChanged } )
[void]$form.ResumeLayout()
$userInput = $form.ShowDialog()
最佳答案
使用这个[System.Windows.Forms.DragDropEffects]
而不是 [System.Windows.DragDropEffects]
在你使用它的所有地方..
关于powershell - 为什么拖放只能在 ISE 中工作,我会错过装配吗? (PowerShell 中的 Windows 窗体),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56747543/
我正在使用 Azure 函数处理来自 IOT 中心的消息并将其输出到 Blob 存储。 enter image description here 但是当我高频发送时,该功能丢失了 IOT 消息。例如,
我正在尝试使用 mediasoup 通过 room.createRtpStreamer 转发 RTP 流 我的问题是我从 producer.rtpParameters.codecs[i].payloa
我正在尝试使用 mediasoup 通过 room.createRtpStreamer 转发 RTP 流 我的问题是我从 producer.rtpParameters.codecs[i].payloa
我正在使用 Spring 应用程序事件将信息发送到其他 bean。有一个 bean A,一旦 A 初始化,它就会发布一个事件。并且有一个 bean B 监听 A 发送的事件。 根据 A 在其他 Bea
CMake 有 Qt4 的特殊变量 ${QT_DEFINITIONS},其中包含 QT 定义,例如 QT_NO_DEBUG 和 QT_DEBUG。 Qt5 没有这样的选项。 如何在 cmake 中添加
我是一名优秀的程序员,十分优秀!