我有一个与调用关联的 bool 值,我想将其作为字符串从 iOS 程序中传递出去。我已经尝试过以下方法:
NSString *connectedString = [self.selectedBeacon.isConnected stringValue];
Run Code Online (Sandbox Code Playgroud)
但我没有得到任何东西。
有人可以纠正我吗?
我想知道是否有一种方法可以使用Unity的RigidBody2D模拟以下代码行,而不是使用普通的RigidBody.
rigidbody.constraints = RigidbodyConstraints.FreezePositionX;
Run Code Online (Sandbox Code Playgroud)
我希望我的球员x位置在碰到某些东西时冻结.虽然我可以使用上述内容,但我需要将所有2D碰撞重新加工以处理3D碰撞.我宁愿避免的痛苦.
我之前从未使用过单元测试,但我想继续前进.现在我有我想要测试的最简单的方法:
public void GetAvailableFiles(string rootFolder)
{
string[] dirs = Directory.GetFiles(rootFolder);
}
Run Code Online (Sandbox Code Playgroud)
我的单元测试如下:
[Test]
public void CheckDirectory()
{
AvailableFile fileUpload = new AvailableFile();
fileUpload.GetAvailableFiles("C:\\Input");
}
Run Code Online (Sandbox Code Playgroud)
当我调试它时,我返回目标位置中的所有文件.但是,我正在努力想出一个有效的条件,在这个条件下,这个测试可以验证它已经通过了.
我的想法是为这个测试预留一定数量的文件.我有10个文件,所以我应该期待10个结果.但是,我不确定如何用我所拥有的东西来写这个.
我该怎么办呢?
我想要做的是当我点击我的winform时,让我的winform显示一个调试行.但是,当我这样做时,没有任何反应.我知道如何让按钮/其他点击事件发生.但我需要的是能够点击我的winform中的任何地方.
我在过去一小时用谷歌搜索了这个,但看不出我做错了什么.据我所知,这段代码在检测鼠标点击时应该是正确的.使用form1.cs类保存此方法:
private void mouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Trace.WriteLine("Mouse clicked");
}
}
Run Code Online (Sandbox Code Playgroud)
我试过设置刹车点,但这些也没有被触发.我做错了什么?
抱歉这个愚蠢的新手问题,但我对winform编程很新.
我想知道winform显示器是否可以找到并显示当前显示的当前屏幕分辨率?
例如,如果我的屏幕是1920 x 1080,它会在标签或打印行中显示.虽然后一部分是我知道如何做的事情.
有人可以告诉我,如果winform有可能找到这些数据吗?
我想逐渐而不是立即改变我的UI图像的alpha.到目前为止,我立即淡化图像alpha值的代码如下
public void Highlight()
{
foreach (Image image in imagesToHighlight)
{
Color c = image.color;
if(c.a < maxColor)
{
c.a = maxColor;
}
image.color = c;
}
foreach (Image image in imagesToFade)
{
Color c = image.color;
if(c.a > halfColor)
{
c.a = halfColor;
}
image.color = c;
}
}
Run Code Online (Sandbox Code Playgroud)
上面的代码工作正常,但我正在努力修改我的代码,以便它不是立即执行,而是在一两秒内缓慢完成.我试着改变线c.a = maxColor;对c.a--,以查看是否图像将继续淡出缓慢而阿尔法只是瞬间下降.
我究竟做错了什么?
我有一些继承的问题.
在我的基类中,我有以下构造函数:
public Camera(string n)
{
name = n;
}
Run Code Online (Sandbox Code Playgroud)
然后在我的子类中,我有以下构造函数:
public StereoCameras(string n)
{
name = n;
}
Run Code Online (Sandbox Code Playgroud)
但是,我的子类抱怨它不包含一个带0参数的构造函数.我很习惯使用这样的继承,我认为我已经正确地设置了我的childs构造函数.
有什么我想念的吗?
我创建了一个字典,它接受我的struct的值并存储它们.填写此内容如下:
_screenEntry.type = typeof(string);
_screenEntry.value = tagTextBox.Text;
_screen.nodeDictionary.Add("Tag ", _screenEntry);
Run Code Online (Sandbox Code Playgroud)
我的结构看起来像这样供参考:
public struct Entry
{
public Object value;
public Type type;
}
Run Code Online (Sandbox Code Playgroud)
但是,我现在正在尝试修改我第一次存储的值.我只是再次尝试重新调用nodeDictionary.Add,希望它会覆盖我以前的条目.但是,我收到一个错误,说我的字典已经有一个名为"Tag"的密钥,这是一个自我解释.
快速谷歌搜索让我发现,如果我想覆盖我的初始值,我只需要调用此行:
_screenTag = tagTextBox.Text;
_screen.nodeDictionary["Tag "] = _screenTag;
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误:
错误2无法将类型'string'隐式转换为'InMoTool.Entry'
我真的不知道如何转换它.有人可能会指出方向吗?
我真的很想在winforms中使用C#中的事件处理程序,目前我有以下错误:
错误1"DotFlickScreenCapture.ScreenCapture"类型不能用作泛型类型或方法"System.EventHandler"中的类型参数"TEventArgs".没有从'DotFlickScreenCapture.ScreenCapture'到'System.EventArgs'的隐式引用转换.
我试图找到一种方法来击败这个错误,但到目前为止,我的谷歌搜索没有发现任何东西.
此错误指向的行是这一行:
public EventHandler<ScreenCapture> capture;
Run Code Online (Sandbox Code Playgroud)
从我所知,这堂课:
public class ScreenCapture
{
public delegate void StatusUpdateHandler(object sender, ProgressEventArgs e);
public event StatusUpdateHandler OnUpdateStatus;
public bool saveToClipboard = true;
public void CaptureImage(bool showCursor, Size curSize, Point curPos, Point SourcePoint, Point DestinationPoint, Rectangle SelectionRectangle, string FilePath, string extension)
{
Bitmap bitmap = new Bitmap(SelectionRectangle.Width, SelectionRectangle.Height);
using (Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(SourcePoint, DestinationPoint, SelectionRectangle.Size);
if (showCursor)
{
Rectangle cursorBounds = new Rectangle(curPos, curSize);
Cursors.Default.Draw(g, cursorBounds);
}
}
if (saveToClipboard)
{
Image img …Run Code Online (Sandbox Code Playgroud) 我的程序接收一个由两部分组成的字符串:分别是距离值和id号.我把它们分开并将它们存储在程序中的局部变量中.所有id号都存储在字典中,用于检查传入的距离值.虽然我应该注意,从设备发送到我程序的每个字符串都是在一个字符串上传递的.下次我的程序收到来自设备的信号时,它会覆盖以前的数据.
如果进入我的程序的id键与我的字典中的一个匹配,那么应该更新我的字典键旁边的变量.但是,当我运行我的程序时,我没有得到6个不同的值,我只得到相同的值,它们都同时更新.
这是我写的所有代码都试图这样做:
Dictionary<string, string> myDictonary = new Dictionary<string, string>();
string Value1 = "";
string Value2 = "";
string Value3 = "";
string Value4 = "";
string Value5 = "";
string Value6 = "";
void Start()
{
myDictonary.Add("11111111", Value1);
myDictonary.Add("22222222", Value2);
myDictonary.Add("33333333", Value3);
myDictonary.Add("44444444", Value4);
myDictonary.Add("55555555", Value5);
myDictonary.Add("66666666", Value6);
}
private void AppendString(string message)
{
testMessage = message;
string[] messages = message.Split(',');
foreach(string w in messages)
{
if(!message.StartsWith(" "))
outputContent.text += w + "\n";
}
messageCount = "RSSI number …Run Code Online (Sandbox Code Playgroud) 我已经可以使用Vlcdotnet框架从winform中保存文件了.目前此代码如下:
_tempVLCWindow.TakeSnapshot("C:\\ScreenCap.jpg", 1280, 720);
Run Code Online (Sandbox Code Playgroud)
现在,我不想将"ScreenCap"作为文件(只允许我保存一个图像),而是希望它存储当前日期和时间,以便保存多个快照.这怎么可能?
我有以下几行代码:
protected void MoveFilesToInBound(string filePath, string fileName, DateTime? reportingRun)
{
var dateValue = reportingRun.Value.ToString("yyyyMMdd");
var file = fileName + "_" + dateValue + ".csv";
if (File.Exists(Path.Combine(filePath, file)))
{
File.Copy(file, InputFolder);
}
}
Run Code Online (Sandbox Code Playgroud)
单步执行我的代码,我可以看到我的目标文件位于我的目标文件位置.但是,当它将我的文件复制到我的输入文件夹(这是正确的)时,它无法告诉我:Could not find file 'myFile_20170831.csv'.
令我困惑的是,我不明白为什么会失败.如果文件不在那里,肯定它甚至不会到达File.Copy它抛出错误的行.
有人可以对此有所了解吗?我有双倍和三倍检查我的所有位置,他们确实匹配.我只是不明白为什么文件没有从我的第一个位置复制到第二个位置.
c# ×11
winforms ×3
dictionary ×2
datetime ×1
inheritance ×1
ios ×1
rigid-bodies ×1
string ×1
unit-testing ×1