我为问这么多OxyPlot问题而道歉,但我似乎真的在努力使用OxyPlot图表控件.
我的项目是WPF格式,所以我最初使用托管的WINFORMS图表,它就像一个魅力,并且做了我需要的所有内容,直到我需要在托管的winform图表上覆盖WPF元素.由于"AirSpace"问题,无论我做什么,我都无法看到我放在托管图表顶部的WPF元素.那时我决定选择OxyPlot,这给我带来了很多令人头痛的问题.
这是我的原始问题!我在CodePlex询问过.我似乎没有得到太多帮助,所以我在这里再试一次.
我的问题是:
有谁知道如何将多个LineSeries绘制到一个图上?
到目前为止我的方法:
我正在使用ac#List数组并添加一个包含要绘制的新数据的LineSeries的新副本.我的代码:
// Function to plot data
private void plotData(double numWeeks, double startingSS)
{
// Initialize new Salt Split class for acess to data variables
Salt_Split_Builder calcSS = new Salt_Split_Builder();
calcSS.compute(numWeeks, startingSS, maxDegSS);
// Create the OxyPlot graph for Salt Split
OxyPlot.Wpf.PlotView plot = new OxyPlot.Wpf.PlotView();
var model = new PlotModel();
// Add Chart Title
model.Title = "Salt Split Degradation";
// Create new Line Series
LineSeries linePoints = new LineSeries() { StrokeThickness = …Run Code Online (Sandbox Code Playgroud) 我正在创建一个将执行无限过程的C#控制台应用程序.当用户按下转义键时,如何让应用程序"暂停"?
一旦用户按下转义键,我想要选择退出应用程序或继续循环它停止的位置.我不希望在这个过程中出现任何不连续性.如果我Esc在步骤100 按下,我应该能够在步骤101正确选择.
到目前为止,这是我的方法:
// Runs the infinite loop application
public static void runLoop()
{
int count = 0;
while (Console.ReadKey().Key!= ConsoleKey.Escape)
{
WriteToConsole("Doing stuff.... Loop#" + count.ToString());
for (int step = 0; step <= int.MaxValue; step++ ) {
WriteToConsole("Performing step #" + step.ToString());
if (step == int.MaxValue)
{
step = 0; // Re-set the loop counter
}
}
count++;
}
WriteToConsole("Do you want to exit? y/n");
exitApplication(ReadFromConsole());
}
Run Code Online (Sandbox Code Playgroud)
有没有办法在单独的线程中检查用户输入密钥,然后在另一个线程看到Esc按键时暂停无限循环?
我有一个方法来解析JSON对象的结果.该方法返回一个Task对象,但是当我运行代码时,我收到以下错误:
'System.Collections.Generic.Dictionary<string,object>' does not contain a definition for 'GetAwaiter'
Run Code Online (Sandbox Code Playgroud)
从动态方法返回的对象是System.Collections.Generic.Dictionary和System.Collections.Generic.KeyValuePair类型的对象数组.这是代码:
private static async Task<dynamic> GetReslutstAsync(string url)
{
WebRequest request;
WebResponse response = null;
try
{
request = WebRequest.Create(url);
request.Credentials = new NetworkCredential("username", "password", "company");
//request.Credentials = CredentialCache.DefaultNetworkCredentials;
response = await request.GetResponseAsync();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
using (var reader = new StreamReader(response.GetResponseStream()))
{
try
{
JavaScriptSerializer js = new JavaScriptSerializer();
var objects = js.Deserialize<dynamic>(reader.ReadToEnd());
return objects;
}
catch (Exception e)
{
Console.WriteLine(e.Message);
return null;
}
}
}
Run Code Online (Sandbox Code Playgroud)
此处发生异常: …
我想创建一个方法,接受字符串数组的字符串数组类型的"参数化"输入对象.就像是:
public void MyMethod(params string[][] input)
{
//...do stuff
}
Run Code Online (Sandbox Code Playgroud)
我将此方法称为如下:
MyMethod({"arry1-elem1","arry1-elem2"}, {"arry2-elem1","arry2-elem2"}, {"arry3-elem1","arry3-elem2"});
Run Code Online (Sandbox Code Playgroud)
但是,当我这样做时,我收到以下错误:
无效的表达式术语'{'
我在这做错了什么.是否无法输入隐式类型数组作为输入?
这引用了我的最后一个问题,该问题似乎已被放弃。如果您使用 C# 和 MS VS 2015,我遇到了一个奇怪的“错误”。要重现该错误,请按照以下步骤操作:
命中Continue并抛出 NRE 异常。为什么会出现这种情况?只有我吗?对此有何技术解释?
代码:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace testapp
{
class Program
{
static void Main(string[] args)
{
FILECollection randomCollection = new FILECollection();
// Fill with junk test data:
for(int i = 0; i<10; i++)
{
FILE junkfile = new FILE() { fileName = i.ToString(), folderName = i.ToString(), fileHashDigest = new byte[1] };
randomCollection.Add(junkfile); …Run Code Online (Sandbox Code Playgroud) 谁能告诉我如何更改Y轴字符串格式?
我有Y轴百分比,我想添加百分号.
我正在使用OxyPlot在wpf中生成图表.
这是我的尝试,但它不起作用:
Func<double, string> formatFunc = (x) => string.Format("{000.00}%", x);
formatFunc = new Func<double,string>("{0}");
// Add the plot to the window
line.YAxis.LabelFormatter = formatFunc;
Run Code Online (Sandbox Code Playgroud)
这会产生空引用错误.
谢谢!
我在文档中寻找以下文字:
"substr"
"500"
"description"
Run Code Online (Sandbox Code Playgroud)
我使用以下表达式来尝试匹配:
(substr|500|description)
Run Code Online (Sandbox Code Playgroud)
这可以找到任何这些单词,但我想跳到只包含所有这些单词的行.有没有办法做到这一点?我不想要OR条件,我想对所有这些词进行AND.
例如:
test substr line one
test substr, 500 line two
test substr, 500, description line three <<--- only go to this line when I hit next!!
Run Code Online (Sandbox Code Playgroud)
这可能吗?
我正在做一个MonteCarlo模拟,我几乎完成了为我的应用程序的那部分编写代码.我有以下列表:
List<List<double>> myFullList = new List<List<double>>();
List<double> myInnerList = new List<double>();
for(int i = 1; i <= numberOfLoops; i++)
{
for(int i = 1; i <= 10; i++)
{
// Populate inner list with random numbers
myInnerList.Add(double myRandomNumber);
}
// Add the inner list to the full list
myFullList.Add(myInnerList);
}
Run Code Online (Sandbox Code Playgroud)
该列表应如下所示:
myFullList[0] = {rand#1,rand#2,rand#3,...,rand#10}
myFulllist[1] = {rand#1,rand#2,rand#3,...,rand#10}
.
.
.
.
myFulllist[1] = {rand#1,rand#2,rand#3,...,rand#10}
Run Code Online (Sandbox Code Playgroud)
我需要将这些数据平均为一个单独的列表,如下所示:
List<double> averagedData = new List<double>();
averagedData = {avg#1, avg#2........avg#10}
Run Code Online (Sandbox Code Playgroud)
此输出变量将平均内部列表中相同"行"数据的数据.
简单的例子:
innerList[0] = {1,2,3};
innerList[1] …Run Code Online (Sandbox Code Playgroud) int doEveryTwoTimes= 1; // Counter to do something every two loops
int doEveryFourTimes= 2; // Counter to do something every four loops
// add a nested infinite loop to increment counter
while(true){
if(doEveryTwoTimes%2 == 0){
// DO STUFF EVERY **TWO** LOOPS
}
if(?????){
// DO STUFF EVERY **FOUR** LOOPS
}
doEveryTwoTimes++;
doEveryFourTimes++;
}
Run Code Online (Sandbox Code Playgroud)
我可以添加一个条件来使事情每两个循环发生一次,但是如何为每个第四个循环创建一个条件?
我想写在表上插入前检查,看是否有在该表中现有条目具有相同的触发器fk_id和active flag.例如,想象下表:
| row_id | fk_id | active_flag |
| ------------------------------|
| 1 | 500 | 1 |
| 2 | 500 | 0 |
| 3 | 501 | 1 |
Run Code Online (Sandbox Code Playgroud)
假设我想用fk_id = 500和插入一个新行active_flag = 1.我想对此抛出异常,因为根据我的规则,在任何给定时间,您不能有两个具有相同的行,这些行在此表fk_id中也是活动的.
我写了一个触发器来尝试处理这个问题:
CREATE OR REPLACE TRIGGER MYSCHEMA.CHECK_DUPS_BIU
BEFORE INSERT OR UPDATE ON MYSCHEMA.MYTABLE_T FOR EACH ROW
DECLARE
l_cnt NUMBER;
e_dup EXCEPTION;
BEGIN
SELECT COUNT(*)
INTO l_cnt
FROM MYSCHEMA.MYTABLE_T
WHERE fk_id = :new.fk_id …Run Code Online (Sandbox Code Playgroud) 作为一个例子,我有一个应用程序,使水果冰沙.我可以IEnumerable列出苹果冰沙,这是有效的.
我希望能够制作一个通用的冰沙列表,IEnumerable<ISmoothie<IFruit>>以防我决定添加另一个Fruit就像橙色一样.当我尝试这样做时,代码将无法编译,我收到错误:
无法将类型'System.Collections.Generic.List>'隐式转换为'System.Collections.Generic.IEnumerable>'.存在显式转换(您是否错过了演员?)
public class Program
{
public static void Main()
{
IEnumerable<ISmoothie<Apple>> appleSmoothies = new List<ISmoothie<Apple>>(); // I Can specifically make Apple Smoothies!
IEnumerable<ISmoothie<IFruit>> genericSmoothies = new List<Smoothie<Apple>>(); // Does Not Compile - What if I want generic Smoothies?
Console.WriteLine("Hello World");
}
public class Apple : IApple
{
// Concrete Implimentation of an Apple
}
public interface IApple : IFruit
{
// Specific Interface for Apples
}
public interface IFruit
{
// Basic Fruit Interface …Run Code Online (Sandbox Code Playgroud) 我正在审查一些人编写的代码,并且很难理解为什么他们会以这种方式找到最大值的密钥.有人可以解释一下,让我知道哪一个更好"更好",更快?(如果有的话)
仅供参考,这用于模态值计算.
原始方法(我不完全理解第二个foreach循环):
// Begin Calculating the Modal Value
Dictionary<double, double> counts = new Dictionary<double, double>();
foreach (double cond_value in condDataToDouble)
{
if (counts.ContainsKey(cond_value))
{
counts[cond_value] = counts[cond_value] + 1;
}
else
{
counts[cond_value] = 1;
}
}
sourceMode = double.MinValue;
double maxVal = double.MinValue;
// Get the Max (modal) Value:
foreach (double key in counts.Keys)
{
if (counts[key] > maxVal)
{
maxVal = counts[key];
sourceMode = key;
}
}
Run Code Online (Sandbox Code Playgroud)
我的方法:
// Begin Calculating the Modal Value
Dictionary<double, double> …Run Code Online (Sandbox Code Playgroud) 在匿名块中,我有一个空/空的输入字符串,并且想要针对非空字符串进行检查。例子:
DECLARE
v_notnull varchar2(50):='this string is never null';
v_input varchar2(50):='';
BEGIN
IF trim(v_input) != trim(v_notnull) THEN
dbms_output.put_line('the strings do NOT match');
ELSE
dbms_output.put_line('the strings DO match');
END IF;
END;
Run Code Online (Sandbox Code Playgroud)
这里的问题是,当我运行这个块时,'the strings DO match'即使我输入''与 string 不同的空字符串(又名 null),输出也始终v_input是这样'this string is never null'。如何确保 oracle 覆盖空字符串大小写?当v_input为空时我希望输出为'the strings do NOT match'.
c# ×9
linq ×2
oracle ×2
oxyplot ×2
wpf ×2
arrays ×1
async-await ×1
average ×1
c ×1
charts ×1
dynamic ×1
generics ×1
ienumerable ×1
if-statement ×1
interface ×1
json ×1
lineseries ×1
list ×1
loops ×1
methods ×1
modulus ×1
montecarlo ×1
notepad++ ×1
null ×1
oracle12c ×1
parameters ×1
plsql ×1
regex ×1
search ×1
sql ×1
task ×1
triggers ×1
varchar2 ×1