我正在重新提出这个问题,因为我上次没有得到太多回应,希望一些重新措辞可能会有所帮助......
基本上我要做的是创建一个数据绑定画布,它将自动缩放其内容以"填充"可用空间.有点像缩放以适应操作.不幸的是,我的WPF技能还不是很强,我正在努力研究如何做到最后这部分.我已经按照一些数据绑定示例来获取画布,但不确定是否可能是错误并阻碍了我.
根据我尝试和解决方案的方式,我现在有两个基本问题:
我想要实现的一个例子,我有AI想要尝试获得B:
(删除过期链接到img)
我目前使用的代码非常简单,只需使用给定的坐标创建4个点,并使用另一个视图模型将其包装起来.
public class PointCollectionViewModel
{
private List<PointViewModel> viewModels;
public PointCollectionViewModel()
{
this.viewModels = new List<PointViewModel>();
this.viewModels.Add(new PointViewModel(new Point(1, 1)));
this.viewModels.Add(new PointViewModel(new Point(9, 9)));
this.viewModels.Add(new PointViewModel(new Point(1, 9)));
this.viewModels.Add(new PointViewModel(new Point(9, 1)));
}
public List<PointViewModel> Models
{
get { return this.viewModels; }
}
}
public class PointViewModel
{
private Point point;
public PointViewModel(Point point)
{
this.point = point;
}
public Double X { get { return point.X; } }
public Double Y …
Run Code Online (Sandbox Code Playgroud) 我正在努力确定DOM中元素的当前位置和大小.我已经整理了一个片段来说明屏幕右侧的基于卡片的系统.
我正在尝试构建的行为是,当您单击其中一张卡时,将添加另一张卡(最终位于下方,但现在位于顶部),它将飞到屏幕的左上角,然后再填充可用空间.
d3.selectAll("attribute-card").on("click", function (d) {
var rect = this.getBoundingClientRect();
var card = d3.select("body")
.append("div")
.attr("class", "card")
.style("background", "transparent")
.style("border", "thin solid red")
.style("left", rect.left + "px")
.style("top", rect.top + "px")
.style("width", (rect.right - rect.left) + "px")
.style("height", (rect.bottom - rect.top) + "px")
.style("position", "absolute");
});
Run Code Online (Sandbox Code Playgroud)
html {
height: 100%;
margin: 0;
font-family: Arial;
overflow: hidden;
}
body {
height: 100%;
}
svg {
background: #2c272b;
width: 100%;
height: 100%;
}
.radial-menu .segment {
fill: #3b3944;
}
.radial-menu .segment:hover { …
Run Code Online (Sandbox Code Playgroud)我试图找出调整控件大小的最佳方法,但不能完全正确.我有一个添加自定义控件的窗口:
<Grid x:Name="LayoutRoot">
<my:RateGraph Grid.Column="0" x:Name="rateGraph1" Height="88" Width="380" />
</Grid>
Run Code Online (Sandbox Code Playgroud)
然后,我希望调整XAML中定义的此控件的子组件的大小,以填充高度,宽度或两者.然而,我发现如果我取消显式宽度/高度并尝试使用像VerticalAlignment ="Stretch"之类的东西,那么我得到一个大小为0的控件......我做错了什么?
<rb:RateBase x:Class="RateBar.RateGraph"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:rb="clr-namespace:RateBar"
xmlns:sd="clr-namespace:System.Windows.Data"
mc:Ignorable="d">
<RangeBase.Resources>
<rb:JScriptConverter x:Key="JScript" TrapExceptions="False"/>
<ControlTemplate x:Key="rateGraphTemplate" TargetType="{x:Type rb:RateBase}">
<Canvas HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<rb:Axis Width="320" Height="88"/>
<Rectangle Height="88" Fill="#9690EE90" x:Name="progress">
<Rectangle.Width>
<MultiBinding Converter="{StaticResource JScript}" ConverterParameter="values[0]/values[1]*values[2]">
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Value"/>
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Maximum"/>
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Width"/>
</MultiBinding>
</Rectangle.Width>
</Rectangle>
<Polygon Fill="#FF06B025" x:Name="graph" />
<Label Canvas.Left="0" Width="380" HorizontalContentAlignment="Right" Foreground="Black" Content="{Binding Path=Caption, RelativeSource={RelativeSource TemplatedParent}}">
<Canvas.Bottom>
<MultiBinding Converter="{StaticResource JScript}" ConverterParameter="(values[2]*0.8)/values[1]*values[0]">
<Binding RelativeSource="{RelativeSource TemplatedParent}" …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 WSL2 (Ubuntu) 调试/连接用于开发的设备。我已经按照这篇文章/sf/answers/4076055791/上的步骤操作,它使用相同的 ADB 版本在 Windows 和 Linux 上设置了 ADB。
但是,一旦我这样做了,我就会在 Ubuntu 终端中得到一个空的设备列表。我试过从 Windows 命令行杀死并重新启动 ADB 服务器,这似乎没有任何区别。这在 WSL2 中是不可能的还是我遗漏了什么?
这个让我困惑了一下......试图处理一个XmlReader
XmlReader reader = XmlReader.Create(filePath);
reader.Dispose();
Run Code Online (Sandbox Code Playgroud)
提供以下错误:
由于其保护级别,'System.Xml.XmlReader.Dispose(bool)'无法访问
但是以下情况很好:
using(XmlReader reader = XmlReader.Create(filePath))
{
}
Run Code Online (Sandbox Code Playgroud)
当我在Reflector中查看定义时,我无法理解为什么我不能调用Dispose
Dispose的实现:
任何人都可以指出我错过了什么?
我有一个带有子类的自定义抽象基类,我已经使用ISerializable进行了可序列化/可序列化.当我对这个类的子类的单个实例进行序列化/反序列化时,一切正常.但是,当我做一个数组时,我总是在反序列化时得到一个空数组.使用BinaryFormatter完成序列化.
这些项目包含在:
public ObservableCollection<Trade> Trades { get; private set; }
Run Code Online (Sandbox Code Playgroud)
在序列化时,这是在SerializationInfo参数的GetObjectData中完成的:
Trade[] trades = (Trade[])Trades.ToArray<Trade>();
info.AddValue("trades", trades);
Run Code Online (Sandbox Code Playgroud)
在反序列化时,这也是在SerializationInfo参数的序列化构造函数中完成的:
Trade[] trades = (Trade[])info.GetValue("trades", typeof(Trade[]));
foreach (Trade t in trades)
{
Trades.Add(t);
}
Run Code Online (Sandbox Code Playgroud)
反序列化总是给我一个空数组,正如我前面提到的,单个项目序列化和deseriaizes与这段代码很好:
序列化(GetObjectData方法):
info.AddValue("trade", Trades.First<Trade>());
Run Code Online (Sandbox Code Playgroud)
反序列化(序列化构造函数):
Trade t = (Trade)info.GetValue("trade", typeof(Trade));
Trades.Add(t);
Run Code Online (Sandbox Code Playgroud)
这是个常见的问题吗?我似乎发现至少没有其他任何人参与其中.希望有一个解决方案:)如果我需要为您提供更多信息/代码,请告诉我.
谢谢!
我有多个与我的WPF应用程序一起使用的监视器.应用程序全屏运行,我希望能够在用户按下按钮时切换它所在的监视器.
case Key.M:
var allScreens = System.Windows.Forms.Screen.AllScreens.ToList();
if (this.CurrentScreen < allScreens.Count - 1)
{
this.CurrentScreen++;
}
else { this.CurrentScreen = 0; }
this.WindowStartupLocation = System.Windows.WindowStartupLocation.Manual;
this.Top = allScreens[this.CurrentScreen].Bounds.Top;
this.Left = allScreens[this.CurrentScreen].Bounds.Left;
break;
Run Code Online (Sandbox Code Playgroud)
我试图这样做,但是这个.Left总是有(-7)的值.我假设它不是让我设置它因为我是全屏,但我不是100%肯定.如何让它以全屏方式切换到另一台显示器?
我正在尝试对路径进行一些修改,使用D3以编程方式定义.我想做的改变很简单,修改路径的不透明度.我遇到的问题是当路径本身发生变化时,结束标记不会,而且我不太清楚如何让它这样做.
标记定义如下:
// define arrow markers for graph links
svg.append('svg:defs').append('svg:marker')
.attr('id', 'end-arrow')
.attr('viewBox', '0 -5 10 10')
.attr('refX', 6)
.attr('markerWidth', 3)
.attr('markerHeight', 3)
.attr('orient', 'auto')
.append('svg:path')
.attr('d', 'M0,-5L10,0L0,5')
.attr('fill', '#CCCCCC');
Run Code Online (Sandbox Code Playgroud)
路径:
// Create the links between the nodes
var links = svg.append("g")
.selectAll(".link")
.data(data.links)
.enter()
.append("path")
.attr("class", "link")
.attr("d", sankey.link())
.style('marker-end', "url(#end-arrow)")
.style("stroke-width", function (d) { return Math.max(1, d.dy); })
.sort(function (a, b) { return b.dy - a.dy; });
Run Code Online (Sandbox Code Playgroud)
我用来更改路径的代码,它不会更新标记:
d3.selectAll("path.link")
.filter(function (link) {
// Find all the links that …
Run Code Online (Sandbox Code Playgroud) 如何在c#中手动恢复线程之前,如何将线程置于暂停/休眠状态?
目前我正在中止线程,但这不是我想要的.线程应该睡眠/暂停,直到它触发它唤醒为止.