可以从void*重新映射STL类对象吗?
#include <string>
void func(void *d)
{
std::string &s = reinterpret_cast<std::string&>(d);
}
int main()
{
std::string s = "Hi";
func(reinterpret_cast<void*>(&s));
}
Run Code Online (Sandbox Code Playgroud) 我正在编写一个XAML文件,该文件使用DataTrigger在ViewModel中设置属性.ViewModel类定义为:
public class ShellModel : INotifyPropertyChanged
{
public Brush ForegroundBrush
{
get; set;
}
....................
}
Run Code Online (Sandbox Code Playgroud)
我想在View.xaml中使用DataTrigger来设置属性ForegroundBrush.我写的XAML是:
<StatusBar Name="statusBar" Grid.Row="3">
<StatusBarItem>
<StatusBarItem.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding HasError}" Value="True">
<Setter Property="ForegroundBrush" Value="Red" />
</DataTrigger>
<DataTrigger Binding="{Binding HasError}" Value="False">
<Setter Property="ForegroundBrush" Value="Black" />
</DataTrigger>
</Style.Triggers>
</Style>
</StatusBarItem.Style>
<TextBlock Name="statusBarMessage" Foreground="{Binding ForegroundBrush}" Text="{Binding StatusMessage}"></TextBlock>
</StatusBarItem>
........................
Run Code Online (Sandbox Code Playgroud)
这不编译.当我改变了
<Setter Property="ForegroundBrush" Value="Black" />
Run Code Online (Sandbox Code Playgroud)
至
<Setter Property="ShellModel.ForegroundBrush" Value="Black" />
Run Code Online (Sandbox Code Playgroud)
它给了我错误:
依赖属性字段缺失....
我该怎么写这个,以便DataTrigger可以在ViewModel中设置属性ForegroundBrush?
我正在使用图像缩放器,为我的页面创建缩略图.缩放器的工作原理是包括指向图像的DIRECT链接.但我想要做的是在URL字符串中放入PHP变量,以便它指向该文件并相应地调整它的大小.
我的代码如下:
<img src="thumbnail.php?image=<?php echo $row_select_property['image_url']; ?>
Run Code Online (Sandbox Code Playgroud)
图像大小调整:
<?php
// Resize Image To A Thumbnail
// The file you are resizing
$image = '$_GET[image_url]';
//This will set our output to 45% of the original size
$size = 0.45;
// This sets it to a .jpg, but you can change this to png or gif
header('Content-type: image/jpeg');
// Setting the resize parameters
list($width, $height) = getimagesize($image);
$modwidth = $width * $size;
$modheight = $height * $size;
// Creating the Canvas
$tn= …Run Code Online (Sandbox Code Playgroud) 我是红宝石世界的新手,我正在研究它.我已经阅读了关于nil对象的谷歌,但仍然无法弄清楚它是什么?
任何人都可以更详细地解释我或分享一些链接进一步阅读?
在我的MVC3应用程序中,当用户使用IE <9时,我想删除输出的所有HTML5标签,以避免使用前端解决方法.
我看了中使用HttpModule,ActionFilter中,OnResultExecuted控制器上的内部和方法Application_Start.
到目前为止,我已经想到我需要使用以下内容将输出作为字符串 HttpApplication.Context.Response.OutputStream:
HttpApplication application = (HttpApplication)source;
HttpResponse response = application.Context.Response;
StreamReader sr = new StreamReader(stream);
string content = sr.ReadToEnd();
Run Code Online (Sandbox Code Playgroud)
但我得到的只是同样的错误Stream was not readable.我可以写回复context.Response.Write.
从阅读SO和谷歌,MVC似乎没有相同的"页面生命周期"有webforms(我只是覆盖Render,它工作正常),这使得sens.
所以我的问题是如何在MVC中将HTML作为字符串获取?有没有人试图操纵HTML输出?
我有一个类似的数据结构
public DespatchGroup(DateTime despatchDate, List<Products> products);
Run Code Online (Sandbox Code Playgroud)
而我正在努力......
var list = new List<DespatchGroup>();
foreach (var group in dc.GetDespatchedProducts().GroupBy(i => i.DespatchDate))
{
// group.Values is not correct... how do I write this?
list.Add(new DespatchGroup(group.Key, group.Values);
}
Run Code Online (Sandbox Code Playgroud)
我显然不理解,IGrouping因为我无法看到如何实际访问组内的数据记录!
我有编辑文本字段,我必须输入密码,但我必须推送此字段.如何在不触摸编辑文本的情况下自动弹出键盘?
有一个Edit text xml字段:
<EditText
android:id="@+id/editPasswd"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="phone"
android:password="true"/>
Run Code Online (Sandbox Code Playgroud) 我试图在windows ce 6.0环境中调用.net cf 3.5中的非托管c ++ dll中的函数.
结构定义为:
typedef struct TagOperatorInfo
{
DWORD dwMode;
DWORD dwFormat; //Operator name format
DWORD dwAct; //Network type(Available in 3G module£ºGSM or 3G),
TCHAR szOper[32];
}OperatorInfo,*LPOperatorInfo;
Run Code Online (Sandbox Code Playgroud)
和函数调用是:
BOOL GetCurOperatorInfo(LPOperatorInfo pinfo);
Run Code Online (Sandbox Code Playgroud)
我在.net中定义了TagOperatorInfo,如下所示:
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
public struct TagOperatorInfo
{
/// DWORD->unsigned int
public uint dwMode;
/// DWORD->unsigned int
public uint dwFormat;
/// DWORD->unsigned int
public uint dwAct;
/// TCHAR[32]
[System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst = 32)]
public string szOper;
}
Run Code Online (Sandbox Code Playgroud)
在看到一些文章和msdn文档后,我将本机函数称为:
[System.Runtime.InteropServices.DllImportAttribute(gsmaAdapterDLLName, EntryPoint = "#30", CallingConvention = CallingConvention.Winapi)] …Run Code Online (Sandbox Code Playgroud) 当我点击地图时,我希望标记能够到达最近的街道.这里有一个很好的例子:http: //econym.org.uk/gmap/example_snappath.htm(主页:http://econym.org.uk/gmap/snap.htm).但是 - 此示例适用于Google地图版本2.是否有办法在v3中执行此操作?
所以我有这个迷你画廊.这就是我想要它的工作原理:img BIG IMAGE img div description div img thumbnails img
Everyting工作得很好,除了我不知道我是否正确地将alt值提取到div中.代码公司:
HTML示例:
<p><img id="largeImg" src="zdjecia/bawialnia.jpg" alt="Large image" /></p>
<div id="opis"></div>
<p class="thumbs">
<a href="zdjecia/bawialnia.jpg" title="Bawialnia"><img src="zdjecia/bawialnia-thumb.jpg" alt="some description" /></a>
Run Code Online (Sandbox Code Playgroud)
jQuery的:
$(document).ready(function(){
$("h2").append('<em></em>')
$(".thumbs a").click(function(){
var largePath = $(this).attr("href");
var largeAlt = $(this).attr("title");
var altText = $(this).attr("alt");
$("#largeImg").attr({ src: largePath, alt: largeAlt });
$("div#opis").html(altText);
$("h2 em").html(" (" + largeAlt + ")"); return false;
});
});
Run Code Online (Sandbox Code Playgroud)
提前致谢!
c# ×2
alt ×1
android ×1
asp.net-mvc ×1
attributes ×1
c++ ×1
casting ×1
datatrigger ×1
igrouping ×1
javascript ×1
jquery ×1
keyboard ×1
linq ×1
php ×1
pinvoke ×1
razor ×1
ruby ×1
wpf ×1
xml ×1