小编Neo*_*Neo的帖子

FillRectangle参数无效

这是我得到的例外

System.ArgumentException was unhandled
  HResult=-2147024809
  Message=Parameter is not valid.
  Source=System.Drawing
  StackTrace:
       at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
       at System.Drawing.Graphics.FillRectangle(Brush brush, Int32 x, Int32 y, Int32 width, Int32 height)
       at System.Drawing.Graphics.FillRectangle(Brush brush, Rectangle rect)
       at frmMain.drawCboxItem(Object sender, DrawItemEventArgs e) in frmMain.cs:line 465
       at frmMain.cboxSectionCell_DrawItem(Object sender, DrawItemEventArgs e) in frmMain.cs:line 485
       at System.Windows.Forms.ComboBox.OnDrawItem(DrawItemEventArgs e)
       at System.Windows.Forms.ComboBox.WmReflectDrawItem(Message& m)
       at System.Windows.Forms.ComboBox.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at …
Run Code Online (Sandbox Code Playgroud)

c# drawing

7
推荐指数
1
解决办法
2885
查看次数

使用COUNT对子查询进行慢速MYSQL查询

对,我不知道为什么但是这个查询执行时间超过6秒,索引的设置都正确,如果我单独运行每个查询,它运行时间不到0.5秒就可以执行.

这是查询

SELECT c.supplier_id, supplier_name, address1, address2, address3, address4, suppliertype, postcode, contact_name,
(SELECT COUNT(*)
    FROM supplier_questions q1
    WHERE c.supplier_id = q1.supplier_id AND q1.incomplete = '0') AS questions, 
IF (active=1,'Yes', IF (active=2, 'NCR Only','Inactive')) AS rated, 
(SELECT COUNT(*)
    FROM supplier_questions q2
    WHERE c.supplier_id = q2.supplier_id AND q2.reviewed = '1') AS reviewed, 
questapproved, 
ss.supplier_no AS supplier_no
FROM suppliers c
INNER JOIN supplier_site ss ON c.supplier_id = ss.supplier_id
WHERE c.supplier_id != '0' AND ss.site_id = '2'
GROUP BY c.supplier_id
ORDER BY c.supplier_name ASC …
Run Code Online (Sandbox Code Playgroud)

php mysql performance

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

自定义 C# 表单设计

我有点坚持这个,我知道它可以完成,但不确定所需的步骤。

我想为我必须创建的应用程序创建一个完全自定义的用户界面设计。我可以更改表单背景等等,但这有点复杂。

下面显示了我所指的更改类型的示例图像,因为您可以看到与大多数应用程序使用的当前 UI 相比,这是一个相当大的更改。 示例 UI 图像

c# user-interface form-design winforms

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

远程检查交换凭据并检查用户是否已登录

我尝试过这个并没有太大的成功.基本上我需要远程使用EWS登录Exchange.

问题是我不知道用户是否已登录确定,或者凭据是否错误,因为我什么都没收到!如果我提供了错误的凭据,软件就会继续!

有没有我缺少的东西,我已经检查了有关EWS的MSDN内容,它向您展示了如何连接到交换,但没有关于验证凭据的内容!

下面是我目前要连接的代码.

public void connect(string Email, string Password)
    {
        try
        {            
            _useremail = Email;
            _userpass = Password;

            // Define the credentials to use.
            var credentials = new WebCredentials(_useremail, _userpass);

            _ExchangeServer = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
            _ExchangeServer.Credentials = credentials;
            _ExchangeServer.Url = new Uri(_ExchangeEWSURL);
            _ExchangeServer.Timeout = 60;
            _ExchangeServer.KeepAlive = true;
            _ExchangeConnected = true;
        }
        catch (Exception ex)
        {
            _ExchangeConnected = false;
            throw ex;
        }
    }
Run Code Online (Sandbox Code Playgroud)

正如你目前所看到的,我只是在课堂上将bool值设置为true.有任何想法吗?

c# exchangewebservices winforms exchange-server-2010

5
推荐指数
1
解决办法
4103
查看次数

获取图像中每种颜色的百分比使用情况

我有这个工作,但它在jpeg图像上非常缓慢,也需要一些改变.

我需要知道图像中的各个颜色(RGB的公差为+/- 1)和该颜色的图像的百分比.

因此,如果图像是黑白的,则会出现白色:74%黑色:26%

下面的代码就像我说的那样,但我需要添加一个容差系统,我不知道如何做到这一点.

private Dictionary<string, string> getPixelData(Bitmap image)
{
    Dictionary<string, string> pixelData = new Dictionary<string, string>();
    //int col, row;
    //int r, g, b;
    Color pixel;

    double offset = 0.000001;
    int hmm = (image.Height * image.Width);
    double current = 0;
    offset = 100 / double.Parse(hmm.ToString());// 0.01;// 100 / (image.Height * image.Width) * 10000;

    try
    {
        for (int i = 0; i < image.Height; i++)
        {
            for (int j = 0; j < image.Width; j++)
            {
                current = current + …
Run Code Online (Sandbox Code Playgroud)

c# pixel colors bitmap image-processing

4
推荐指数
2
解决办法
8872
查看次数

单一解决方案中的多个应用

我相信这是可能的,但不确定如何解决它,我需要创建一个服务器/客户端解决方案,通常我会为服务器创建一个新的解决方案,并为客户端创建一个新的解决方案,但我希望在一个单独的内容中解决方案,因为他们都将使用相同的自定义类,并不真正想要两次更改同一文件的问题.

所以问题是我可以在单个解决方案中创建多个exe,以及实现此目的的步骤是什么.

我在这里搜索过,但是没有完全理解这个程序,所以如果有人能指出我一般的正确方向,那就太好了.:)

VS2010使用C Sharp和Windows Forms

c# client multiple-projects winforms

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

带有数据源和组合框的 datagridview

我有一个 datagridview,其中附加了一个由自定义数据表组成的数据源:

数据表:0 = 字典 1 = 字符串 2 = 字符串

datagridview 是可编辑的,但是对于第 0 列,我需要显示组合框而不是文本字段。我该如何实现这一目标?

internal Dictionary<int, string> products_list = new Dictionary<int, string>();
products_list.Add(0, "Test Product 1");
products_list.Add(1, "Test Product 2");


lines.Columns.Add(new DataColumn("Product", products_list.GetType()));
lines.Columns.Add(new DataColumn("QTY", typeof(int)));
lines.Columns.Add(new DataColumn("Description", typeof(string)));

dgvQuoteLines.DataSource = lines;
dgvQuoteLines.Columns[0].Visible = false;
Run Code Online (Sandbox Code Playgroud)

* 更新 * 我现在已成功将组合框添加到 datagridview,但遗憾的是数据源无法正常工作!

DataGridViewComboBoxColumn colbox = new DataGridViewComboBoxColumn();
colbox.DataPropertyName = "0";
dgvQuoteLines.Columns.Add(colbox);
Run Code Online (Sandbox Code Playgroud)

c# combobox datagridview datacolumn

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

WPF 将网格背景设置为资源图像

这很令人困惑,在 winforms 中这是非常容易的,但在 WPF 中这似乎是不可能的。

我需要将网格的背景设置为图像,我认为应该很简单。

图像已设置为资源(右键单击项目名称 -> 属性 -> 资源选项卡 -> 导入现有文件),但是当我单击背景属性并选择平铺画笔时,它会将我指向导入到的文件Resources 文件夹,此功能一直有效,直到应用程序从 Visual Studio 外部运行(此时它不起作用)。

<Grid Width="550" Height="350">
    <Grid.Background>
        <ImageBrush ImageSource="Resources/CINTRA2016.png"/>
    </Grid.Background>
Run Code Online (Sandbox Code Playgroud)

我在 XAML 中有上述代码,如何使用资源?我也尝试过<ImageBrush ImageSource="pack://application:,,,/CINTRA 2016;CINTRA2016"/>哪个不起作用。

两个映像在解决方案资源管理器中都具有资源的构建操作

c# wpf background

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

使用JavaScript将500,000行添加到表中而不会导致页面崩溃

我有一个报告系统,用户单击该报告,执行SQL,结果显示在表中。我的问题是,单个报告为该报告带来了超过500,000行。系统需要花费一些时间通过AJAX调用来检索数据,但是当浏览器将HTML添加到页面时,它就“挂起”。

我的问题是,有没有其他方法可以将HTML添加到页面而不会导致浏览器挂起?

var HTMLPRE = '<p class="text-center"><b id="lblReportStatus">Producing report...</b><br><small>Average time: ' + parseFloat($('#hidReportID').attr('data-avg')).toFixed(2) + ' seconds</small>' +
    '<br><small>Current time: <span id="divCurrentTimeTaken">0</span></small></p>';
window.CurrentTimer = 0;
$('#reportresults').html(HTMLPRE);
// start the timer
window.ProducingReportTimer = window.setInterval(function() {
    window.CurrentTimer++;
    $('#divCurrentTimeTaken').html(window.CurrentTimer + ' seconds');
}, 1000);

$.post(window.routes['ReportWriter.ProduceReport'], FormData, function(resp, status) {
    if (status === 'success') {
        if (resp.code == '200') {
            $('#lblReportStatus').text('Generating report...<br>Please note your browser may become un-responsive.  Please wait for a few minutes if this happens.');
            ProduceReportTable(resp);
        }
    } else {
        alert("Unable to produce …
Run Code Online (Sandbox Code Playgroud)

html javascript ajax

3
推荐指数
1
解决办法
1384
查看次数

Laravel Eloquent 获取关系字段

我需要从雄辩的对象内的关系中获取一个字段。

我正在使用数据表来传递雄辩的对象以供查看。

我有一个名为“办公室”的模型和一个名为“区域”的模型

办公室 ID 名称区域 -> 所属区域

区域 ID 名称

我需要得到这样的东西:Offices.id,Offices.name,Regions.name

我已尝试以下方法,但失败了,如何在 get 方法中获取区域名称?

$ReportData = Offices::with('region')->get(['id', 'name', 'region.name']);
return datatables()->eloquent($ReportData)
Run Code Online (Sandbox Code Playgroud)

php laravel eloquent laravel-5.5

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

tcpclient接收数据不正确

不确定这是TCPClient还是别的什么,我使用网络嗅探器检查从服务器发送和接收的内容,数据是否正确,但我的软件接收数据不正确.

让我解释一下,我发送一个查询字节(05)我得到一个确认回(06)然后我发送一些以9B字节开头的数据,一旦发送,我应该接收一个06字节,然后在那个字节之后我应该得到一个C5字节,但根据我的软件我得到另一个06字节,根据嗅探器不是这种情况!

byte[] buff;
if (!this.isConnected())
    this.connect(); 

NetworkStream gs = _Socket.GetStream();

gs.Write(enq, 0, enq.Length);
gs.Flush();
outputByte(enq, "Trans"); //outputs ---> 05

buff = new byte[1];
gs.Read(buff, 0, buff.Length);
gs.Flush();
outputByte(buff, "Rec");// outputs <--- 06

if (buff[0] == 0x06)
{
    byte[] data = new byte[] {
                                            0x9B, 0x00,         0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x09,         
        0x67, 0x11, 0x01, 0x49, 0x4D, 0x41, 0x47, 0x45,         0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,         
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,         0x01, 0x53, …
Run Code Online (Sandbox Code Playgroud)

c# tcpclient

0
推荐指数
1
解决办法
868
查看次数