我正在尝试使用GreaseMonkey编写网页脚本.(我正在使用Firebug来帮助开发.)该页面包含少量JavaScript代码,但该代码从站点中提取其他JS文件.整个JS文件集合是存储在客户端的某个地方(即在某个文件系统上),以便我可以查看它们吗?或者更好的是,有没有办法在Firebug中查看它们?我对Firebug有点不知所措,但能够遵循指示.非常感谢.(我关于SO的第一个问题!)
-Todd
我有以下事件处理程序:
private void rtb_MouseDown(object sender, MouseEventArgs e)
{
if (e.RightButton == MouseButtonState.Pressed)
{
// Get the nearest TextPointer to the mouse position.
TextPointer location = rtb.GetPositionFromPoint(Mouse.GetPosition(rtb), true);
// Get the nearest word using this TextPointer.
TextRange word = GetWordRange(location);
// Display the word.
tb.Text = word.Text;
e.Handled = true;
}
}
Run Code Online (Sandbox Code Playgroud)
这连接到RichTextBox的PreviewMouseDown事件.触发此事件并调用上述方法,并且光标下的单词显示在单独的TextBox(称为tb)中.
问题是,之后还会显示鼠标右键单击事件的默认上下文菜单(包含剪切/复制/粘贴选项).将Handled属性设置为true似乎没有帮助.如何禁用此上下文菜单?
编辑:Xaml代码:
<Window x:Class="rtbTest1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<RichTextBox Height="175" HorizontalAlignment="Left" Margin="10,127,0,0" Name="rtb" VerticalAlignment="Top" Width="483" PreviewMouseDown="rtb_MouseDown" />
<TextBox Height="59" HorizontalAlignment="Left" Margin="286,24,0,0" Name="tb" VerticalAlignment="Top" Width="186" />
<Button …Run Code Online (Sandbox Code Playgroud) 我试图读取XML文件,但type of the expression in the select clause is incorrect. Type inference failed in the call to 'Select'由于以下查询而收到错误:
List<Data> dogs = (from q in doc.Descendants("dog")
where (string)q.Attribute("name") == dogName
select new Data
{
name = q.Attribute("name").Value,
breed = q.Element("breed").Value,
sex = q.Element("sex").Value
}.ToList<Data>);
Run Code Online (Sandbox Code Playgroud)
数据类:
public class Data
{
public string name { get; set; }
public string breed { get; set; }
public string sex { get; set; }
public List<string> dogs { get; set; }
}
Run Code Online (Sandbox Code Playgroud) 我正在使用ASP.NET开发一个网站.
当我开始编写代码时,我没有设计视图来设计网站(请参阅下面的链接中的屏幕截图).我真的需要帮助.
http://www.4shared.com/download/CZTzYSUu/18-09-34_06-13-06_.png?tsid=20130726-032036-c925f200
我想修复 Microsoft 文档存储库中的一些拼写错误。我点击了它的新拉取请求按钮。这导致显示以下页面:
如您所见,绿色的Create pull request按钮被禁用。我如何从这里开始?在其他存储库(例如 Amazon 文档)中,该过程的工作方式有所不同,我可以直接创建拉取请求。
我可以向编辑器添加字形,但无法删除和编辑字形。你能给我正确的方法吗?
<h2>Monaco Editor Sample</h2>
<div id="container" style="width:80%;height:600px;border:1px solid grey"></div>
<!-- OR ANY OTHER AMD LOADER HERE INSTEAD OF loader.js -->
<script src="../node_modules/monaco-editor/min/vs/loader.js"></script>
<script>
var editor,decorations;
require.config({ paths: { 'vs': '../node_modules/monaco-editor/min/vs' }});
require(['vs/editor/editor.main'], function() {
editor = monaco.editor.create(document.getElementById('container'), {
value: [
'function x() {',
'\tconsole.log("Hello world!");',
'}',
].join('\n'),
language: 'javascript',
theme: "myCustomTheme",
automaticLayout: true,
readOnly: false,
mouseWheelZoom:true,
glyphMargin:true,
fontSize:'20px'
});
//below is the glyph I am calling
var decorations = editor.deltaDecorations([], [
{
range: new monaco.Range(3,1,3,1),
options: …Run Code Online (Sandbox Code Playgroud) 在 Postman 桌面中,我尝试渲染 Bing 图像搜索返回的图像。(查询本身有效。)
我从 Bing API 查询得到以下响应,在桌面 Postman 中格式化为 JSON:
{
"_type": "Images",
"instrumentation": {
"_type": "ResponseInstrumentation"
},
"readLink": "https://arama.cognitiveservices.azure.com/api/v7/images/search?q=jfk",
"webSearchUrl": "https://www.bing.com/images/search?q=jfk&FORM=OIIARP",
"queryContext": {
"originalQuery": "jfk",
"alterationDisplayQuery": "jfk",
"alterationOverrideQuery": "+jfk",
"alterationMethod": "AM_JustChangeIt",
"alterationType": "CombinedAlterations"
},
"totalEstimatedMatches": 910,
"nextOffset": 1,
"currentOffset": 0,
"value": [
{
"webSearchUrl": "https://www.bing.com/images/search?view=detailv2&FORM=OIIRPO&q=jfk&id=23716A341D61409DE7D5D19724937DD5340BBB06&simid=608036166471451494",
"name": "Reactions to the assassination of John F. Kennedy - Wikipedia",
"thumbnailUrl": "https://tse1.mm.bing.net/th?id=OIP.9dNMVRmk1a3edFYrwzcFeQHaIi&pid=Api",
"isFamilyFriendly": true,
"contentUrl": "https://upload.wikimedia.org/wikipedia/commons/7/70/Jfk2.jpg",
}
]
}
Run Code Online (Sandbox Code Playgroud)
在“测试”选项卡中,我有以下脚本:
var template = `<img src="{{res.value[0].contentUrl}}">`;
pm.visualizer.set(template, {
res: pm.response.json() …Run Code Online (Sandbox Code Playgroud) 有人可以提供一个不使用Windows窗体绘制图形的示例吗?我有一个没有控制台窗口或Windows窗体的应用程序,但我需要绘制一些基本图形(线条和矩形等)
希望有道理.
我试图理解Windows Forms中的某个长期概念:UI编程; 以下代码来自Chris Sells的Windows窗体编程书(第2版,2006):
void ShowProgress(string pi, int totalDigits, int digitsSoFar) {
// Display progress in UI
this.resultsTextBox.Text = pi;
this.calcToolStripProgressBar.Maximum = totalDigits;
this.calcToolStripProgressBar.Value = digitsSoFar;
if( digitsSoFar == totalDigits ) {
// Reset UI
this.calcToolStripStatusLabel.Text = "Ready";
this.calcToolStripProgressBar.Visible = false;
}
// Force UI update to reflect calculation progress
this.Refresh();
}
Run Code Online (Sandbox Code Playgroud)
此方法是小样本应用程序的一部分,它具有另一个计算Pi的长期运行方法.每次计算一组数字时,都会调用ShowProgress()来更新UI.正如书中所解释的,这段代码是"错误"的处理方式,并且当应用程序最小化时会导致UI冻结,然后再次进入前台,导致系统要求应用程序重新绘制自己.
我不明白:由于this.Refresh()被重复调用,为什么它不处理任何等待注意的系统重绘事件?
还有一个后续问题:当我在this.Refresh()之后立即添加Application.DoEvents()时,冻结问题就会消失. 这是不必诉诸于Invoke/BeginInvoke等.任何评论?
我试图在左边有一个单选按钮,一个右边的按钮,两个都是固定宽度,还有一个文本框,当窗口调整大小时,它们会拉伸以填充空间.
这似乎应该工作:
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<StackPanel HorizontalAlignment="Left">
<RadioButton GroupName="FibOptions" IsChecked="True">Term Closest To N:</RadioButton>
<RadioButton GroupName="FibOptions">Nth Term:</RadioButton>
</StackPanel>
<TextBox x:Name="FibInput" Grid.Column="1" />
<Button Grid.Column="2" x:Name="FibGen" HorizontalAlignment="Right">Generate</Button>
</Grid>
Run Code Online (Sandbox Code Playgroud)
但是上面的结果是一个很小的文本框,它基本上是一个位于该区域中间的垂直线.对此有何帮助?
我在解决this flowDocument doc以下方法中的参数时遇到问题:
public static FormattedText GetFormattedText(this FlowDocument doc)
{
if (doc == null)
{
throw new ArgumentNullException("doc");
}
...
}
Run Code Online (Sandbox Code Playgroud)
调用方没有调用上述方法时指定一个参数:
myRichTextBox.TextChanged +=
new TextChangedEventHandler((o, e) => myRichTextBox.Width =
myRichTextBox.Document.GetFormattedText().WidthIncludingTrailingWhitespace + 20);
Run Code Online (Sandbox Code Playgroud)
我肯定的方法并没有创造doc本身.我之前没见过this以这种方式使用过.
c# ×5
wpf ×3
javascript ×2
richtextbox ×2
.net ×1
asp.net ×1
editor ×1
firebug ×1
firefox ×1
github ×1
graphics ×1
greasemonkey ×1
invoke ×1
linq-to-xml ×1
postman ×1
pull-request ×1
this ×1
winforms ×1
xaml ×1