小编Mel*_*een的帖子

获取ProgressBar以填充StatusBarItem

我有一个StatusBar我想把一个TextBlock停靠在左边并ProgressBar填充剩余的宽度.在我使用WPF的所有其他经验中ProgressBar,它将填充其给定的容器,但是在这种情况下它根本不会自动调整大小,它只是显示为一个小圆圈.手动设置它的高度和宽度工作正常,但我希望它可以缩放到剩余的宽度StatusBar.

这是我的XAML StatusBar:

<StatusBar DockPanel.Dock="Bottom" Height="25">
    <StatusBarItem DockPanel.Dock="Left">
        <TextBlock x:Name="lblStatus"  Margin="5,0,0,0"/>
    </StatusBarItem>
    <StatusBarItem>
        <ProgressBar x:Name="pgbStatus" />
    </StatusBarItem>
</StatusBar>
Run Code Online (Sandbox Code Playgroud)

wpf xaml statusbar progress-bar

16
推荐指数
1
解决办法
7838
查看次数

Silverlight页面加载来自Microsoft的不安全内容

我有一个主要由单个Silverlight应用程序组成的网站.该网站配置为通过HTTPS运行,效果很好.但是,当网站加载到Chrome时,会发出警告

" https://testing.efilecabinet.com/上的页面显示了来自http://download.microsoft.com/download/5/1/6/5165823D-1D79-4871-8AC2-42DDDB94A5C2/PNGs/SLMedallion_ENU的不安全内容. png."

似乎SL框架正在通过HTTP从microsoft加载此图像.有谁知道通过HTTPS实现这一点的方法?

silverlight https google-chrome silverlight-4.0

12
推荐指数
1
解决办法
6153
查看次数

使用SSL创建TCP客户端连接

我正在尝试创建TCP连接并发送/读取使用SSL的数据,但我无法成功完成此操作.

我想做的是这样的事情:

    TcpClient _tcpClient = new TcpClient("host", 110);

    BinaryReader reader = 
       new BinaryReader(new System.Net.Security.SslStream(_tcpClient.GetStream(), true));

    Console.WriteLine(reader.ReadString());
Run Code Online (Sandbox Code Playgroud)

我虽然没有运气.创建BinaryReader时抛出异常.

有谁知道这样做的一个简单例子?我不想写这个服务器端,只是客户端.

.net c# ssl tcp

11
推荐指数
1
解决办法
2万
查看次数

WCF:Net.TCP多个绑定,相同的端口,不同的IP地址

我遇到了一个问题.我在WCF有点新,所以任何帮助都会有很大的帮助.

这是我的代码:

public static void StartHosts()
    {
        try
        {
            // Create a new host
            ServiceHost host = new ServiceHost(typeof(ServerTasks));

            List<IPAddress> ips = new List<IPAddress>(Dns.GetHostAddresses(Dns.GetHostName()));
            if (IPAddress.Loopback != null)
                ips.Add(IPAddress.Loopback);

            ips.RemoveAll(i => i.AddressFamily != AddressFamily.InterNetwork);

            foreach (var ip in ips)
            {
                string uri = string.Empty;

                // Formulate the uri for this host
                uri = string.Format(
                    "net.tcp://{0}:{1}/ServerTasks",
                    ip.ToString(),
                    ServerSettings.Instance.TCPListeningPort
                );


                // Add the endpoint binding
                host.AddServiceEndpoint(
                    typeof(ServerTasks),
                    new NetTcpBinding(SecurityMode.Transport) { TransferMode = TransferMode.Streamed },
                    uri
                );

            }



            // Add the meta data …
Run Code Online (Sandbox Code Playgroud)

wcf wcf-binding net.tcp

9
推荐指数
1
解决办法
2万
查看次数

ASP.Net Web API不读取StreamContent中的所有字节

我在我的网站上设置了ASP.Net Web API,用于与WPF桌面应用程序通信.我在API上有一个动作设置来从客户端应用程序接收二进制文件.但是在某些(看似随机的)情况下,当我从请求中获取所有字节时,不会读取所有字节.希望你可以让我知道如何以一种始终有效的方式做到这一点.这是代码:

客户端:

public static SubmitTurnResult SubmitTurn(int turnId, Stream fileStream)
{
    HttpClient client = CreateHttpClient();

    HttpContent content = new StreamContent(fileStream);
    content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
    content.Headers.ContentDisposition.FileName = "new-turn.Civ5Save";
    content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
    content.Headers.ContentLength = fileStream.Length;

    HttpResponseMessage response = client.PostAsync(
        string.Format("SubmitTurn?authKey={0}&turnId={1}",
                        LocalSettings.Instance.AuthenticationKey,
                        turnId
                        ),
        content
    ).Result;

    response.EnsureSuccessStatusCode();

    return response.Content.ReadAsAsync<SubmitTurnResult>().Result;
}
Run Code Online (Sandbox Code Playgroud)

SubmitTurnResult是一个枚举,用于定义服务器上的结果,turnId是此文件附加到的实体的ID,fileStream是读取磁盘字节的实际FileStream.

服务器端:

[HttpGet, HttpPost]
public SubmitTurnResult SubmitTurn(string authKey, int turnId)
{

    try
    {
        bool worked = false;
        int gameId = 0;

        using (GmrEntities gmrDb = new …
Run Code Online (Sandbox Code Playgroud)

c# file-upload asp.net-mvc-4 asp.net-web-api

6
推荐指数
1
解决办法
9978
查看次数

C#接口可以要求或指定特定的类吗?

我是否可以声明一个接口(即IMySpecialControl),它需要实现它的类也从一些基类继承(即System.Windows.Controls.UserControl)?

我的想法是,不,这是不可能的.但是以这样的方式编写客户端代码非常好,它只需要一个'IMySpecialControl'来定义它关心的几个成员,它可以指望该对象也是一个UserControl,然后它可以添加到GUI或操作.

我知道我总是可以检查定义为'IMySpecialControl'的对象实例是否也是UserControl,但我希望在.Net中可能有一些光滑的技巧我不知道.:-)

c# interface constraints

4
推荐指数
1
解决办法
1485
查看次数