我有一个与日期功能相关的古怪问题.
码:
$numDays = 8;
$date = strtotime('2010-11-06');
for ($i=1; $i<=$numDays; $i++)
{
$thisDay = date("D, d M Y", $date);
print ($thisDay.'<br>');
$date+=86400; // add one day to timestamp
}
Run Code Online (Sandbox Code Playgroud)
我的服务器上的结果(本地主机,Windows):
2010年11月6日星期六
太阳,2010年11月7日
星期一,2010年11月8日
2010年11月9日星期二
2010年11月10日星期三
2010年11月11日星期四
2010年11月12日星期五
2010年11月13日星期六
我的网络服务器(linux)上的结果
2010年11月6日星期六
*Sun,2010年11月7日
2010年11月7日星期日*
星期一,2010年11月8日
2010年11月9日星期二
2010年11月10日星期三
2010年11月11日星期四
2010年11月12日星期五
注意Sun,2010年11月7日在远程服务器上出现两次?为什么会这样?谁能解释这种行为?
我的ViewModel中有一个布尔属性,名为boolean属性,IsNotSupported如果不支持传感器,则该属性用于显示一些警告信息。因此,我使用BooleanToVisibilityConverter,将其添加到资源中:
<phone:PhoneApplicationPage.Resources>
<local:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
</phone:PhoneApplicationPage.Resources>
Run Code Online (Sandbox Code Playgroud)
并将其绑定到包含警告的堆栈面板:
<StackPanel x:Name="NotSupportedWarning" Visibility="{Binding IsNotSupported,
Converter={StaticResource BooleanToVisibilityConverter}}">
Run Code Online (Sandbox Code Playgroud)
一切正常,但是在加载页面并支持传感器时,警告仅出现一秒钟,然后消失。我知道这种闪烁是由于绑定尚未发生而导致的,因此默认为可见。
那种闪烁令人讨厌,就像地狱一样。它应该默认为折叠,并且只有在明确显示了警告之后,才能使其可见。同样,这将避免在绑定之后进行第二次布局,因此可能会对性能产生积极影响。
我一遍又一遍地遇到了这个问题,直到我发现这个非常相关的问题,直到在互联网上一无所获,但如果搜索Windows Phone而不是Silverlight则找不到该问题。问题和解决方案都看起来很简单,但是我确实困扰了我很长时间,所以我认为写一个关于此问题的问答式的问题来帮助其他面临相同问题的人可能是一个好主意。
我是XML/HTML解析的新手.甚至不知道正确的单词来正确搜索重复项.
我有这个HTML文件,如下所示:
<body id="s1" style="s1">
<div xml:lang="uk">
<p begin="00:00:00" end="00:00:29">
<span fontFamily="SchoolHouse Cursive B" fontSize="18">I'm great!</span>
</p>
Run Code Online (Sandbox Code Playgroud)
现在我需要00:00:00,00:00:29并I'm great!从中.我可以这样读:
XmlTextReader reader = new XmlTextReader(file);
while (reader.Read())
{
if (reader.NodeType != XmlNodeType.Element)
continue;
if (reader.LocalName != "p")
continue;
var a = reader.GetAttribute(0);
var b = reader.GetAttribute(1);
if (reader.LocalName == "span")
{
XmlDocument doc = new XmlDocument();
doc.Load(reader);
XmlNode elem = doc.DocumentElement.FirstChild;
var c = elem.InnerText;
}
}
Run Code Online (Sandbox Code Playgroud)
我得到变量中的值a,b和c.但HTML格式略有变化.现在HTML看起来像这样: …
我通常习惯.net框架,最近有机会使用C++/Qt处理项目.在这个上下文中,我想实现以下功能:(为了简化事情,我可以说我有一个ListView和一个Textbox/Textedit)
基本上我看到两个解决方案(可能还有更多):
aboutToChangeSelection(proposedSelection, vetoObj) changedSelection(newSelection)第一个信号将被发送到textedit,然后最终将利用其否决权.在此之后,相同的信号将被发送到列表本身,根据否决权执行操作,并且如果它实际改变了选择则发送第二信号.
在.NET世界中,存在这样一种机制,借助于CancelEventArgs.我知道.NET事件和Qt信号有相当不同的工作原理,但有没有相同的Qt相同的效果?
非常感谢您的帮助!
我正在使用WCF(.Net 4)从.Net 4 WinForms客户端应用程序上传文件到IIS服务器,用于内部系统.
我有一个MessageContract类定义如下:
/// <summary>
/// Message contract for uploading document data together with a file stream
/// </summary>
[MessageContract]
public class DocumentDataFileUploadInfo : IDisposable
{
/// some fields omitted for brevity
/// <summary>
/// The stream containing the file
/// </summary>
[MessageBodyMember(Order = 1)]
public Stream FileByteStream;
/// <summary>
/// Dispose of the stream if necessary
/// </summary>
public void Dispose()
{
try
{
if (FileByteStream != null)
{
FileByteStream.Close();
FileByteStream.Dispose();
FileByteStream = null;
} …Run Code Online (Sandbox Code Playgroud) 这可能是一个关于LINQ的新手问题,但假设我有一组具有DateTime属性的Items,一个日期最多只有一个项目,我将如何从引用日期中选择N个最新项目,即N个项目的日期小于请求日期和最大日期?
我天真的想法是首先选择日期小于参考日期的项目,按日期排序,然后从该子集中选择N个第一项.
var recentItems = from item in dataContext.Items
where item.Date<=date
orderby item.Date descending
select item;
var mostRecentItems = recentItems.Take(5).ToList();
Run Code Online (Sandbox Code Playgroud)
这是"正确"的方式,还是有更好的方法来实现我的目标?
我创建了一个控件,派生自Canvas,应该绘制一个实时图,给定通过绑定传递给DependencyProperty的值.简化版本如下:
public class Plotter : Canvas
{
public float Value { get { return (float)GetValue(ValueProperty); } set { SetValue(ValueProperty, value); } }
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Value", typeof(float), typeof(Plotter),
new PropertyMetadata(0f, new PropertyChangedCallback(ValueChangedCallBack)));
public static void ValueChangedCallBack(DependencyObject property, DependencyPropertyChangedEventArgs args)
{
Plotter plotter = (Plotter)property;
plotter.Value = (float)args.NewValue; //<-- Removed this line to get it to work
// Actually draw the value into the canvas geometry
plotter.PlotValue(plotter.Value);
}
}
Run Code Online (Sandbox Code Playgroud)
我像这样绑定控件:
<mystuff:Plotter Value="{Binding MyViewModelProperty}" Height="50" Width="200" /> …Run Code Online (Sandbox Code Playgroud) 我的应用程序有一个对话框,通过询问用户QMessageBox是否要放弃他所做的或想要继续编辑的所有更改.我希望这个对话框是整个应用程序的模态.
我在某处读到这是a的标准行为QMessageBox,所以我不必明确地设置它:
mbox.setWindowModality(Qt::ApplicationModal);
Run Code Online (Sandbox Code Playgroud)
我想知道为什么它的行为与操作系统中的其他模态对话框不同(在我的例子中是Windows 7).一方面它的功能就像应该的那样,即应用程序中的所有其他输入方法都被阻止,直到用户回答对话框为止.但是,如果用户单击应用程序的任何其他窗口,它不会"闪烁"*.有没有办法让Qt像本机Windows对话框一样?
提前致谢!
*如果您不知道这个'闪烁'是什么意思:只需在Windows操作系统上打开记事本,输入一些文本并尝试关闭它.弹出一个对话框,要求保存,放弃或继续编辑.现在单击编辑器窗口中的某个位置 - >对话框的边框和标题栏闪烁/闪烁几次.
c# ×5
.net ×2
c++ ×2
data-binding ×2
qt ×2
datetime ×1
events ×1
file-upload ×1
html ×1
html-parsing ×1
linq ×1
messagebox ×1
modal-dialog ×1
php ×1
silverlight ×1
wcf ×1
xaml ×1