我正在使用morris.js图表以及bootstrap滑块.
我想做的事:
如果移动滑块,我想在滑块值的位置插入一个事件线到图表中.没什么特别的.
问题:
设置事件后图表没有重绘.插入新数据时,将自动重绘图表.所以我尝试通过将现有数据再次传递给图表来刷新(以检查正确的语法),如下所示:
chart.setData(chart.options.data);
Run Code Online (Sandbox Code Playgroud)
这很有效!新事件将被绘制到图表中.不幸的是,由于图表正在重绘所有数据,因此效果不佳.
文件说有chart.redraw().这对我不起作用.也许有人可以找出原因.
只需运行代码段并切换单选按钮以测试这两种方法,您就会看到问题所在.
// Chart creation - not interesting
var chart = new Morris.Line({
element: 'chart',
ymin: 0,
ymax: 100,
gridIntegers: true,
parseTime:false,
// Will be set below
data: [ ],
xkey: 'position',
ykeys: ['value'],
labels: ['Value'],
hideHover: "always",
pointSize: 0,
continuousLine: false,
goalStrokeWidth: 3,
axes: true,
grid: true,
numLines: 6,
eventLineColors: [ "red" ],
smooth: true
});
// Inserting some values
var values = [101]
for(i = 1; i <= …Run Code Online (Sandbox Code Playgroud)我面临一个普遍的问题,我无法找到一个很好的例子来尝试为自己.谷歌不是一个帮助.
想象一下这样的结构:
MailMessage mail = new MailMessage(sender, receiver);
using(SmtpClient client = new SmtpClient())
{
client.Host ...
client.Port ...
mail.subject ...
mail.body ...
client.SendAsync(mail);
}
Run Code Online (Sandbox Code Playgroud)
如果服务器很慢并且需要一段时间来接受邮件,该怎么办?是否有可能SmtpClient在操作完成之前进行处理?它会以任何方式被卷入或破坏吗?
对此有一般性的答案吗?这里的服务器速度太快,不知道怎么做试用.
如果考虑取消BackgroundWorker它总是完成当前的操作.在这里可能是相同的,或者可能不是......
NumericUpDown我试图创建一个继承以显示可设置单位的自定义控件。
这是(视觉上)我到目前为止所得到的:
我的代码: 看起来有点长,但并没有做那么多
class NumericUpDownUnit : NumericUpDown
{
public event EventHandler ValueChanged;
/// <summary>
/// Constructor creates a label
/// </summary>
public NumericUpDownUnit()
{
this.TextChanged += new EventHandler(TextChanged_Base);
this.Maximum = 100000000000000000;
this.DecimalPlaces = 5;
this.Controls.Add(lblUnit);
lblUnit.BringToFront();
UpdateUnit();
}
public void TextChanged_Base(object sender, EventArgs e)
{
if(ValueChanged != null)
{
this.ValueChanged(sender, e);
}
}
/// <summary>
/// My designer property
/// </summary>
private Label lblUnit = new Label();
[Description("The text to show as the unit.")]
public string Unit
{ …Run Code Online (Sandbox Code Playgroud) 我正在尝试将c#中的trapezodial规则作为函数实现:
Int_a^b f(x) = (b-a) * [f(a) + f(b)] / 2
Run Code Online (Sandbox Code Playgroud)
c#中是否有一个功能允许我编写这样的功能?
double integrate(double b, double a, function f)
{
return (b-a) * (f(a) + f(b)) / 2;
}
Run Code Online (Sandbox Code Playgroud)
哪里f可以是在另一个函数内定义的任何多项式表达式,例如:
double f (double x)
{
return x*x + 2*x;
}
Run Code Online (Sandbox Code Playgroud) 是否有任何文件证明正则格式的边框有多厚?
目标:
我创建了一个宽度为800px的userControl。我想用一个新的实例以全分辨率(800px-可见的一切)来引发一个弹出窗口(通常是普通形式)。
我的问题:
将表单设置为Form.Size.Width = 800不可以。看起来表单的边框包含在表单的宽度属性中。我需要减去该边界。
我应该是这样的: 2px + 800px + 2px
如果您想看一些代码告诉我,但是我认为这里没有必要。
编辑:
弹出控件后:
弹出代码:
private void buttonPopup_Click(object sender, EventArgs e)
{
Form MyPopup = new Form();
customControl MyUserControl = new customControl();
MyUserControl.Dock = DockStyle.Fill;
Rectangle rc = MyUserControl.RectangleToScreen(MyUserControl.ClientRectangle);
//int thickness = SystemInformation.Border3DSize.Width;
//MyPopup.MaximumSize = new Size(MyUserControl.Size.Width + (thickness*2), 1500);
MyPopup.Controls.Add(MyUserControl);
MyPopup.MaximumSize = new Size(rc.Width, rc.Height);
MyPopup.Show();
}
Run Code Online (Sandbox Code Playgroud)
我的意思是您的代码对我来说看起来很合逻辑。但是结果仍然是一样的。该userControl显示一点点小。我知道我已经dock = fill在我的按钮没有被专业放置在布局中的地方使用过。但是,除此以外,必须有一个解决方案来设置正确的大小。
是否可以一起获得2个可选参数的要求?这是一个例子:
public void ParamChoise(string A, bool B = false, string C = "Y")
{
// Stuff here
}
Run Code Online (Sandbox Code Playgroud)
其中B是可选的,如果B为真,我希望函数需要C.从我的逻辑来看:
public void ParamChoise(string A, (bool B = false, string C = "Y"))
Run Code Online (Sandbox Code Playgroud)
无法通过谷歌搜索找到任何东西.对我来说,一种可能的方式是:
/// <summary>
/// If you want behaviour XXX to be enabled, please enter "C" for usage.
/// </summary>
/// <param name="A"></param>
/// <param name="C"></param>
public void ParamChoise(string A, string C = "Y")
{
// Stuff here
}
Run Code Online (Sandbox Code Playgroud)
当然,我可以给我的函数这样的评论,但是为一个非逻辑的给定参数写一个评论对我来说很糟糕.
这种情况可能是一个不好的例子,但我相信我将来会再遇到这种情况.
非常感谢 :).
编辑清除事项:
参数的可能组合:
我在VMware工作站中安装了CentOS 7,但是此操作系统不支持中文。所以我yum goupinstall -y chinese-support以前安装中文包。但是我得到了这个:
并且我输入了命令yum -y update; 那我该怎么办?
首先:我在不使用oop的情况下运行代码.我在同一个类中声明了所有变量,并在将查询传递给db之前和之后打开/关闭了连接.那很有效!现在有了一些新的经验,我试图将我的代码分成不同的类.现在它不再工作了.
它告诉我"连接必须有效且开放".足够的文字,这是我目前的代码:
Services.cs
public static MySqlConnection conn // Returns the connection itself
{
get
{
MySqlConnection conn = new MySqlConnection(Services.ServerConnection);
return conn;
}
}
public static string ServerConnection // Returns the connectin-string
{
get
{
return String.Format("Server={0};Port=XXXX;Database=xxx;Uid=xxx;password=xxXxxXxXxxXxxXX;", key);
}
}
public static void DB_Select(string s, params List<string>[] lists)
{
try
{
MySqlCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.Text;
string command = s;
cmd.CommandText = command;
MySqlDataReader sqlreader = cmd.ExecuteReader();
while (sqlreader.Read())
{
if (sqlreader[0].ToString().Length > 0)
{
for (int i …Run Code Online (Sandbox Code Playgroud) 我和C#一起工作多年,所以我试图在GO中找到相似之处(我对此很新).
我的目标:
我想error通过一种方法来扩展接口,因为Check()我能够error.Check()通过(在我看来)更好的可读代码来调用.
我当前的状态:
我已经学习了如何使用这种语法通过方法扩展类型:
func (foo T) MyExtension() returnType {
// return something
}
Run Code Online (Sandbox Code Playgroud)
我的问题:
看起来这只适用于类型而不适用于接口.正如我迄今所看到的error是interface,这些会用来许多包来描述自己的错误类型的基础.我不想扩展这个错误类型(从包),而是想扩展接口以涵盖所有.我找不到任何语法.因为我也不知道这个的技术术语(它不是extension-method)我在谷歌搜索时有点迷失.
那么有没有办法error通过一般方法扩展接口?
我有一个匿名类型的奇怪问题.让我们直接进入我的代码:
var anon = new[]
{
new { Var1 = 20, Var2 = 40, Var3 = 70 },
new { Var1 = 25, Var2 = 45, Var3 = 75 }
};
// found should be of type { int Var1, int Var2, int Var3 }
var found = anon.Select(x => x).Where(x => x.Var1 == 25);
var test = found.Var1 // <-- not defined error here
Run Code Online (Sandbox Code Playgroud)
很简单的问题:
为什么我Var1在使用linq选择后无法访问?
对此主题感到抱歉,想不出更好的描述.