RichTextBox我的WPF应用程序中的组件使用a FlowDocument和RichTextBoxs Document属性填充.
rtb.ScrollToEnd();似乎没有做任何事情,我甚至试图调用BringIntoView()添加到构造我的表的最后一行"行" FlowDocument.
有什么建议?谢谢!
我有一个简单的C#控制台应用程序,它读入指定用户的XML文件,对其运行XSLT转换,并输出结果.
当我将我的应用程序分发给用户时,我想分发一个.EXE文件.我的源代码由3个文件组成:.csproj文件,.cs代码文件和.xslt样式表.
如何设置csproj以使.xslt在输出中"嵌入"并且最终用户无法查看或修改?
看起来很简单,但我无法弄清楚,谷歌并没有太大的用处.
我的应用程序设置为在打开扩展名为.myappdata的文件后激活.它通过这个intent-filter完成了这个:
<activity
android:name="com.myapp.ExamineFileActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="file" android:pathPattern=".*\\.myappdata" android:mimeType="*/*"/>
<data android:scheme="content" android:pathPattern=".*\\.myappdata" android:mimeType="*/*"/>
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
我打开Chrome网络浏览器(在运行Android 6.0.1的Nexus 7上),然后转到下载名为"file123.myappdata"的文件的网站,然后点击Chrome中的"打开"链接.
该操作会触发我的应用程序打开并运行此代码,这将获取下载的文件名:
Uri uri = this.getIntent().getData();
if (uri.getScheme().equals("content")) {
Cursor cursor = getContentResolver().query(uri, null, null, null, null);
try {
if (cursor != null && cursor.moveToFirst()) {
return cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
}
} finally {
cursor.close();
}
}
Run Code Online (Sandbox Code Playgroud)
当这段代码运行时(在我从Chrome打开文件后),uri就是内容:// downloads/my_downloads/1602,cursor.moveToFirst()返回false
然后我退出我的应用程序并转到下载应用程序并打开完全相同的文件.这会触发我的应用程序打开,运行相同的代码除了使用uri 内容:// downloads/all_downloads/1602(uri中的其他内容完全相同),cursor.moveToFirst()调用返回true并返回cursor.getString ()方法返回"file123.myappdata"(这正是我想要的).
当我从Chrome打开下载的文件(在uri中给我"my_downloads")而不是从下载中打开相同的下载文件(在uri中给我"all_downloads")时,为什么cursor.moveToFirst()方法找不到任何数据?
我定义了一个CSS类,调用它:
<style type="text/css">
.Foo { position: fixed; left: 50px; top: 50px; }
</style>
Run Code Online (Sandbox Code Playgroud)
我绝对在屏幕上放置一个元素的地方.在我的网页执行过程中,我创建并删除了许多元素并给它们上课Foo.当我调整浏览器的大小时,我想更改类上的left和top值,Foo以便在计算结果时更改所有 Foo元素的位置.
我不想简单地更改样式表,我想计算一个值,并使所有当前和未来的Foo元素都具有新的计算值left和top值.
这个网站有一个例子,但代码相当复杂. http://www.shawnolson.net/a/503/altering-css-class-attributes-with-javascript.html
是否有一种良好,干净的方式来基本上以编程方式改变Foo定义的内容?
谢谢!
我正在运行一个使用Entity Framework 4.0进行数据库交互的C#4.0网站.我想找到导致实体框架对数据库进行最多调用的页面(因为调用越多,页面可能越慢).
我将为实体框架添加某种工具,让实际用户操作网站一段时间,然后分析某种日志以找出生成对数据库的调用最多的页面.
是否有某种性能计数器或其他事件可以检查以确定实体框架何时进行数据库调用?
我正在使用SQL Server 2008数据库进行C#项目.数据库中有50多个表,仅凭名称,这些表的目的及其中的列并不是很明显.我想创建一些形式的文档,以便未来的团队成员知道列和表的作用.
我正在寻找SQL Server相当于C#"代码注释"或"关于方法的XML文档" - 新人可以浏览一下以了解数据库表或列.
有哪些选择?
给定这样的XML结构:
<garage>
<car>Firebird</car>
<car>Altima</car>
<car>Prius</car>
</garage>
Run Code Online (Sandbox Code Playgroud)
我希望将"Prius"节点"移动""一级",使其显示在Altima节点上方.这是我想要的最终结构:
<garage>
<car>Firebird</car>
<car>Prius</car>
<car>Altima</car>
</garage>
Run Code Online (Sandbox Code Playgroud)
所以考虑到C#代码:
XmlNode priusNode = GetReferenceToPriusNode()
Run Code Online (Sandbox Code Playgroud)
什么是让priusNode在车库的子列表中"向上移动"一个位置的最佳方法是什么?
我对C#了解很多,但是这个让我感到困惑,谷歌没有帮助.
我有一个IEnumerable范围的对象.我想在第一个上设置一个属性.我这样做,但是当我在修改后枚举对象范围时,我看不到我的变化.
这是问题的一个很好的例子:
public static void GenericCollectionModifier()
{
// 1, 2, 3, 4... 10
var range = Enumerable.Range(1, 10);
// Convert range into SubItem classes
var items = range.Select(i => new SubItem() {Name = "foo", MagicNumber = i});
Write(items); // Expect to output 1,2,3,4,5,6,7,8,9,10
// Make a change
items.First().MagicNumber = 42;
Write(items); // Expect to output 42,2,3,4,5,6,7,8,9,10
// Actual output: 1,2,3,4,5,6,7,8,9,10
}
public static void Write(IEnumerable<SubItem> items)
{
Console.WriteLine(string.Join(", ", items.Select(item => item.MagicNumber.ToString()).ToArray()));
}
public class SubItem
{
public string …Run Code Online (Sandbox Code Playgroud) 我需要在我的代码中进行一些日志记录.我需要使用公司内部开发的库来记录一些信息.这是它的工作原理.
Recorder recorder = Recorder.StartTiming();
DoSomeWork();
recorder.Stop(); // Writes some diagnostic information.
Run Code Online (Sandbox Code Playgroud)
为了确保始终调用Stop(),我创建了一个包装类,允许使用干净的"使用"块.
using (RecorderWrapper recorderWrapper = new RecorderWrapper) // Automatically calls Recorder.StartTiming() under the covers
{
DoSomeWork();
} // When the recorderWrapper goes out of scope, the 'using' statement calls recorderWrapper.Dispose() automatically - which calls recorder.Stop() under the covers
Run Code Online (Sandbox Code Playgroud)
它到目前为止运作良好.但是,我的公司需要改变,在原始代码上看起来像这样:
Recorder recorder = Recorder.StartTiming();
try
{
DoSomeWork();
}
catch (Exception ex)
{
recorder.ReportFailure(ex); // Write out some exception details associated with this "transaction"
}
recorder.Stop(); // Writes some diagnostic …Run Code Online (Sandbox Code Playgroud) c# ×6
.net ×1
android ×1
csproj ×1
css ×1
exception ×1
flowdocument ×1
ienumerable ×1
javascript ×1
project ×1
richtextbox ×1
scroll ×1
sql-server ×1
using ×1
wpf ×1
xml ×1