我想在OnChanged方法中更改GUI属性...(实际上我试图设置图像源..但为了简单起见,这里使用了一个按钮).每次filesystemwatcher检测到文件中的更改时都会调用它.它会转到"顶部"输出..但在尝试设置按钮宽度时会捕获异常.
但如果我把相同的代码放在一个按钮..它的工作正常.我真诚地不明白为什么..能有人帮助我吗?
private void OnChanged(object source, FileSystemEventArgs e)
{
//prevents a double firing, known bug for filesystemwatcher
try
{
_jsonWatcher.EnableRaisingEvents = false;
FileInfo objFileInfo = new FileInfo(e.FullPath);
if (!objFileInfo.Exists) return; // ignore the file open, wait for complete write
//do stuff here
Console.WriteLine("top");
Test_Button.Width = 500;
Console.WriteLine("bottom");
}
catch (Exception)
{
//do nothing
}
finally
{
_jsonWatcher.EnableRaisingEvents = true;
}
}
Run Code Online (Sandbox Code Playgroud)
我真的想做什么,而不是改变按钮宽度:
BlueBan1_Image.Source = GUI.GetChampImageSource(JSONFile.Get("blue ban 1"), "avatar");
Run Code Online (Sandbox Code Playgroud) setCurrentPage 只是将对象存储到我的全局存储中的页面对象中。所以如果我在设置后尝试立即访问它..似乎有延迟并且对象是空的。但是如果我在按钮中console.log相同的对象并单击它..它就会被填充。
redux 是否存在我不知道的延迟?我该怎么做才能让它发挥作用?它弄乱了我的代码......
谢谢你的帮助
// initialState.js // my global redux store
playlist: {
currentPage: {}
}
// someComponent
let tempPage = new Page();
tempPage.controlNode = someAPItoGetControlNode(); //synchronous
this.props.actions.setCurrentPage(tempPage); //tempPage.controlNode contains object correctly
console.log(this.props.currentPage); //empty object. WHY???
// in some function in the same component i call in a button
function seeCurrentPage() {
console.log(this.props.currentPage); //works!
}
// reducer
case types.SET_CURRENT_PAGE: {
action.pageObj.selected = true;
return Object.assign({}, state, {currentPage: action.pageObj});
}
// action
export function setCurrentPage(pageObj) {
return { type: types.SET_CURRENT_PAGE, …Run Code Online (Sandbox Code Playgroud) 我在下面的“global.fetch”部分收到此错误,我不知道为什么。我觉得我正在以一种非常标准的方式做这件事......我错过了什么?我对任何东西都持开放态度,甚至是库。我只是想学习如何使用 React 测试库来测试我的组件,该库获取数据并呈现列表,但我遇到了很多麻烦...
\n感谢任何提供帮助的人
\n\n\nTS2322:类型 'Mock<Promise<{ json: () => Promise<Data[]>; }>, []>'
\n
\nis 不可分配给类型 '(input: RequestInfo | URL, init?:\nRequestInit) => Promise'。\xc2\xa0\xc2\xa0Type 'Promise<{ json: () =>\nPromise<Data[]>; }>' 不可分配给类型 'Promise'。\n\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0Type '{ json: () => Promise<Data[]>; }' 缺少类型“Response”中的以下属性:标头、确定、重定向、状态和\n其他 10 个属性。
我发现模拟 global.fetch 的通用方法如下:
\nglobal.fetch = jest.fn(() =>\n Promise.resolve({\n json: () => Promise.resolve(....data here...),\n })\n);\nRun Code Online (Sandbox Code Playgroud)\n我的组件如下所示:
\nconst SomeComponent = () => {\n const [dataList, setDataList] = useState<Data[]>([]); \n\n const fetchdataList = async () => {\n const …Run Code Online (Sandbox Code Playgroud) 我的应用程序中有 15 个边框,其中有一个图像,它调用 MouseUp 上的一个方法。所有图像都有不同的名称。因此,为什么我希望它们都调用这个方法
<GroupBox Width="75" Height="75">
<Border MouseLeftButtonUp="Image_MouseUp1" Background="Transparent">
<Image x:Name="RedPick5_Image" Height="Auto" Width="Auto"/>
</Border>
</GroupBox>
Run Code Online (Sandbox Code Playgroud)
我希望他们所有人都能够设置子项的图像源(如果我理解正确的话,图像是边框的子项..我该怎么做?
private void Image_MouseUp1(object sender, MouseButtonEventArgs e)
{
//want to set any image that calls this
//something like Sender.Child.Source = ...
}
Run Code Online (Sandbox Code Playgroud) 我真的不确定如何解释这个...我将把代码放在psuedo代码中以便于阅读
当一个类的bool变量发生变化时,我想要一个标签来改变它的文本...我不知道我需要使用什么因为我使用的是WPF而且这个类不能只改变标签我不能我想?
我需要某种活动吗?还是WPF活动?谢谢你的帮助
public MainWindow()
{
SomeClass temp = new SomeClass();
void ButtonClick(sender, EventArgs e)
{
if (temp.Authenticate)
label.Content = "AUTHENTICATED";
}
}
public SomeClass
{
bool _authenticated;
public bool Authenticate()
{
//send UDP msg
//wait for UDP msg for authentication
//return true or false accordingly
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个时钟,我想从 5:00 开始。我只想制作一个按钮,例如减去 5 秒,以便显示 4:55。我在这个和 JS DateTime 上遇到了很多困难。我不断收到错误“格式不是函数”。我错过了什么?
var dateTime = new moment(300000);
var clock = dateTime.format('m:ss'); //Displays as 5:00
//Button Click
$scope.rewindClick = function () {
clock = dateTime.diff(5000).format('m:ss');
}
Run Code Online (Sandbox Code Playgroud) 使用15个数字的列表,我需要给出一个表示最佳和最差情况的列表.它说"qs使用列表中的第一项作为枢轴项目".我不确定我是否每次都选择第一项作为枢轴,但这就是我所假设的......
为了最好的情况..我想出了(粗体用于枢轴,斜体用于大于和小于标记):
8 1 3 2 6 5 7 4 12 9 11 10 14 13 15
4 1 3 2 6 5 7--8-- 12 9 11 10 14 13 15
2 1 3 --4-- 6 5 7 ........ 8 ........ 10 9 11--12--14 13 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
希望有人可以在这里验证我的工作,如果这是错的,请指出我是如何以及为什么.
我正在努力避免数据绑定,因为我不理解它并且需要完成这个...但我正在尝试的一切似乎都不起作用.例如,我想要打印出所选项目的第二列..但是我在google上看到的所有内容都表示当我的某些原因没有一个时使用SubItems?
<ListView Name="myListView" MouseDoubleClick="myListView_MouseDoubleClick_1">
<ListView.View>
<GridView>
<GridViewColumn Header="H1" DisplayMemberBinding="{Binding Col1}"/>
<GridViewColumn Header="H2" DisplayMemberBinding="{Binding Col2}"/>
<GridViewColumn Header="H3" DisplayMemberBinding="{Binding Col3}"/>
</GridView>
</ListView.View>
</ListView>
private void Button_Click_1(object sender, RoutedEventArgs e)
{
myListView.Items.Add(new { Col1 = "test1", Col2 = "Test2", Col3 = "test3" });
}
private void myListView_MouseDoubleClick_1(object sender, MouseButtonEventArgs e)
{
//THIS DOESN'T WORK, SubItems doesn't exist?
myListView.SelectedItems[0].SubItems[0].Text.ToString();
}
Run Code Online (Sandbox Code Playgroud) 我在项目的一个文件夹中有一堆*.tif图像..我还在我的visual studio项目中添加了一个位于"Templates\Team Logos"的文件夹中
现在如果我设置一个图像源来说:
<Image Name="UL_Team1_Image" Grid.Row="1" Grid.Column="1" Margin="5" Source="Team Logos\ARI.tif"></Image>
Run Code Online (Sandbox Code Playgroud)
这样可行.但是现在如果我尝试:
UL_ImageArr[a].Source = (ImageSource)new ImageSourceConverter().ConvertFromString("Team Logos\\ARI.tif");
Run Code Online (Sandbox Code Playgroud)
这不起作用.是什么赋予了?我得到一个NullReferenceException ...但它对我没有意义?
我一整天都在搜索,但没有找到任何东西。所有的 React 库似乎都只在一个独立列表之间排序。
我发现最接近的是这篇文章:http : //rafaelquintanilha.com/sortable-targets-with-react-dnd/
用这个例子:http : //rafaelquintanilha.com/apps/sortabletargets/
问题是您必须先将项目拖到不同的列表中,然后才能对其进行排序。换句话说,您不能将项目从一个列表拖到另一个列表,也不能将该项目准确地放置在该列表中您将其拖到的位置。
有没有你们知道或知道我可以完成此任务的任何类型的库?
我迫切需要在工作项目中使用此功能。感谢您的任何帮助
c# ×5
wpf ×5
reactjs ×3
javascript ×2
algorithm ×1
delegates ×1
events ×1
html ×1
image ×1
imagesource ×1
jestjs ×1
listview ×1
momentjs ×1
react-redux ×1
redux ×1
sorting ×1
typescript ×1