本文介绍了WPF简单的二维条码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我开始在接下来的日子一个比较大的项目,我想什么是创建项目的最佳方式。现在我有一个控制我真的不知道怎样做实现它的最好办法的一个重要问题。

I am starting a quite big Project in the next days and I thought about what's the best way to create the project. And now I have an important question on a control I don't really know what's the BEST way to do implement it.

我有LED灯的矩阵。 (32x16发光二极管)。这些都显示在一个网格,现在棘手的问题。我必须要能够做不少事情他们。为例我必须能够访问数据绑定的LED很容易做一些操作,例如转移所有的人的2倍左右或反转他们等等。

I have a matrix of led lights. (32x16 leds). These have to be displayed in a grid and now that the tricky part. I have to be able to do quite a lot of things with them. As example I have to be able to access the databound leds quite easy do some operations like shift all of them 2 times right or left or invert them and so on.

我想过这样在itemcontrol显示它们:

I thought about displaying them in an itemcontrol like this:

<ItemsControl ItemsSource="{Binding Path=Leds}">
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <UniformGrid Rows="16" Columns="32"/>
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
        <ItemsControl.ItemTemplate>
            <DataTemplate DataType="{x:Type local:Led}">
                <Ellipse Name="ellipse" Fill="Green"/>
                <DataTemplate.Triggers>
                    <DataTrigger Binding="{Binding Path=State}" Value="Off">
                        <Setter TargetName="ellipse" Property="Fill" Value="Red"/>
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>



不过,我应该如何处理在带领鼠标点击打开它或。 (我用MVVM)
和你将如何抽象整个网格的指示灯内?

But how should I handle the mouseclicks on the led to turn it or of. (I am using MVVM)And how would you abstract the whole grid within the leds?

有很多解决方案,但我不知道拿哪一个?

There are many solutions but I don t know which one to take?

您可能有一个有趣的想法如何创建一个简单而干净的解决方案。

May you have an interesting idea how to create a simple and CLEAN solution.

推荐答案

而不是使用 UniformGrid ,我宁愿建议你使用优秀的 DataGrid2D 控制在这个计算器线程 >

Instead of using an UniformGrid, I'd rather advice you to use the excellent DataGrid2D control introduced in this stackoverflow thread

这将会让你绑定你的 DataGrid2D 的ItemsSource 到2D物体,在你的情况下, LED [,] ,然后会显示任何的二维数组中的更改。
假设你想切换两个LED,就像从位置[1,2]到[2,5],你就必须做你 LED [,] 阵列和视图将自动更新相应

It'd allow you to bind your DataGrid2D's ItemsSource to a 2D object, in your case, a Led[,] , and then will display any of your changes in the 2D array.Assume you want to switch two leds, like from position [1,2] to [2,5], you'd just have to do it on your Led[,] array and the view will update itself accordingly

这篇关于WPF简单的二维条码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 21:28