我想要做相反的事是这里
我有一个列表,我知道如何删除重复项.但是我希望有一个选项,用户可以选择要保留的副本.一些查询问题我可以有一个只显示重复项的列表.就像是:
让我们说我的清单是:
"tom""bob""Frank""bob""Lacey""Frank"
我知道,如果我使用不同的方法,我会得到:
"汤姆""鲍勃""弗兰克""莱西"
我不知道我必须使用什么方法来获取:
"bob""bob""frank""frank"
或得到
"bob""frank"
因为那些是重复的.
我有以下属性Temp2
:(我的UserControl实现INotifyPropertyChanged)
ObservableCollection<Person> _Temp2;
public ObservableCollection<Person> Temp2
{
get
{
return _Temp2;
}
set
{
_Temp2 = value;
OnPropertyChanged("Temp2");
}
}
public event PropertyChangedEventHandler PropertyChanged = delegate { };
private void OnPropertyChanged(string propertyName)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
Run Code Online (Sandbox Code Playgroud)
我需要动态创建一个列表视图.我在XAML中有以下列表视图:
<ListView
Name="listView1"
DataContext="{Binding Temp2}"
ItemsSource="{Binding}"
IsSynchronizedWithCurrentItem="True">
<ListView.View>
.... etc
Run Code Online (Sandbox Code Playgroud)
现在我尝试用c#创建相同的listview:
ListView listView1 = new ListView();
listView1.DataContext = Temp2;
listView1.ItemsSource = Temp2; // new Binding(); // ????? how do I have to implement this line
listView1.IsSynchronizedWithCurrentItem = true;
//.. etc
Run Code Online (Sandbox Code Playgroud)
当我使用C#填充listview时,listview不会被填充.我究竟做错了什么?
我需要在我的应用程序中替换一些图像.结果我从Xcode中删除了它们,现在当我尝试再次添加它们时,我收到此错误:
我确信该文件在项目中不存在,因为我刚删除它.此外,当我尝试查找该文件时,它不存在.
我有课:
class SomeClass
{
public string Name{get;set;}
public int SomeInt{get;set;}
}
class SomeComparison: IEqualityComparer<SomeClass>
{
public bool Equals(SomeClass s, SomeClass d)
{
return s.Name == d.Name;
}
public int GetHashCode(SomeClass a)
{
return (a.Name.GetHashCode() * 251);
}
}
Run Code Online (Sandbox Code Playgroud)
我也有两个List<SomeClass>
大叫list1
和list2
在我以前之前:
var q = (from a in list1
from b in list2
where a.Name != b.Name
select a).ToList();
Run Code Online (Sandbox Code Playgroud)
这花了大约1分钟来执行.我现在有:
var q = list1.Except(list2,new SomeComparison()).ToList();
Run Code Online (Sandbox Code Playgroud)
这需要不到1秒!
我想了解Except方法的作用.该方法是否为每个列表创建哈希表,然后执行相同的比较?如果我要进行大量的比较,我应该创建一个Hashtable吗?
现在我没有列表,而是有两个HashSet<SomeClass>
叫做 hashSet1
和hashSet2
当我做:
var q …
Run Code Online (Sandbox Code Playgroud) 在visual studio中,我有一个Excel 2010加载项目.如何让该项目创建以下模块:
我知道我可以使用该模块保存该工作簿,然后将其与我的添加一起使用.如果我可以让我的插件创建该模块,这将是很好的...
使用以下方法进行转换时,我阅读的大多数文件都是合适的时间:
// works great most of the time
private static DateTime convertToDateTime(System.Runtime.InteropServices.ComTypes.FILETIME time)
{
long highBits = time.dwHighDateTime;
highBits = highBits << 32;
return DateTime.FromFileTimeUtc(highBits + time.dwLowDateTime);
}
Run Code Online (Sandbox Code Playgroud)
这里我在visual studio中有一个例子来说明这个方法有时不起作用,例如我将在我的计算机和调试中显示实际文件.所以恰好在我的调试中的文件是:
"A:\ Users\Tono\Documents\Visual Studio 2010\Projects\WpfApplication4\WpfApplication4\obj\x86\Debug\App.g.cs"
这里是我试图转换为DateTime的FILETIME"我需要LastWriteTime"
在这里你可以看到dwHighDateTime = 30136437以及该文件中的dwLowDateTime = -2138979250.
当我运行我的方法加上其他技术时,我得到以下日期:
所以到目前为止,一切似乎都很有效.但是为什么当我在Windows中浏览并查找特定文件时,我会得到一个不同的日期!这是我在查看文件属性时得到的日期:
为什么日期不匹配?我究竟做错了什么?
我的组合框在我的应用程序中就像扩展器一样.当我需要折叠一个groupbox时,我将它的高度设置为0.当我需要展开它时,我将它的高度设置为auto(double.Nan)是否可以用故事板来实现.我怎么能提前知道自动高度.表达式混合不能使我动画到自动.
我正在调用一个写入流的DLL.dll中方法的签名如下:
public bool SomeMethod(Stream stream);
Run Code Online (Sandbox Code Playgroud)
并且该方法基本上将二进制数据写入该流.所以,如果我将该方法称为:
var file = System.IO.File.Create("SomeFile.txt");
/* call dll method */ SomeMethod(file);
Run Code Online (Sandbox Code Playgroud)
然后我基本上将输出写入该文件.在这个问题中,我将输出写入networkStream.
无论如何回到这个问题.我想创建自己的流的原因是因为我想知道什么时候发生一些事件.例如,如果我在哪里创建自己的流类:
class MyStream : Stream
{
private long Position;
public override int Read(byte[] buffer, int offset, int count)
{
// implementation goes here
/* HERE I COULD CALL A CUSTOM EVENT */
}
public override long Seek(long offset, SeekOrigin origin)
{
// SAME THING I WILL LIKE TO PERFORM AN ACTION IF THIS METHOD IS CALLED!
}
// etc implement rest of …
Run Code Online (Sandbox Code Playgroud) 我有运营合同:
[System.ServiceModel.Web.WebGet( UriTemplate = "c" , BodyStyle = WebMessageBodyStyle.Bare )]
[OperationContract]
string Connect ( );
Run Code Online (Sandbox Code Playgroud)
我把它实现为:
public string Connect ( )
{
return "<a href='someLingk' >Some link</a>";
}
Run Code Online (Sandbox Code Playgroud)
当我去那个链接时,我得到:
如何将响应格式化为html?甚至是纯文本.我不想回复HTML或json ...
我知道我可以创建一个查询服务的网站,但我只想创建一个适用于任何浏览器的简单"类似于控制台"的应用程序......
我需要在几个地方使用相同的故事板,因此我将故事板放在我的Application.Resources中.当我尝试执行故事板时,唯一的问题是我需要引用我想要动画的目标.这是我的故事板:
<System:String x:Key="target">border2</System:String>
<Storyboard x:Key="stHeight">
<DoubleAnimationUsingKeyFrames
Storyboard.TargetProperty="(FrameworkElement.Height)"
Storyboard.TargetName="{DynamicResource target}">
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="90">
<EasingDoubleKeyFrame.EasingFunction>
<CircleEase EasingMode="EaseOut"/>
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
Run Code Online (Sandbox Code Playgroud)
我为不同对象的高度设置动画的方式是通过更改动态资源目标.当故事板在当前窗口中时,我能够这样做.但现在我想将它放在应用程序资源中,我不知道如何引用目标属性.
我之前发布的解决方案效果不错但有时很难用代码创建复杂的动画.所以我解决的另一个替代解决方案是使用表达式混合创建故事板.所以我将一个随机控件拖到表达式混合中的主窗口并创建一个随机动画.让我们说动画出现为:
<Storyboard x:Key="Storyboard1">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="grid">
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="90"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="grid">
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="103"/>
</DoubleAnimationUsingKeyFrames>
<PointAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransformOrigin)" Storyboard.TargetName="grid">
<EasingPointKeyFrame KeyTime="0:0:1" Value="0.75,0.5"/>
</PointAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="grid">
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="75"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
Run Code Online (Sandbox Code Playgroud)
然后我复制该代码并将其粘贴到我的工作窗口而不是APP.XAML中.
然后在我的代码中假设我有一个:
<Border Name="brdBorder" BorderBrush="Silver" BorderThickness="1" Margin="328,104,0,0" Background="#FFE52E2E" HorizontalAlignment="Left" Width="94" Height="100" VerticalAlignment="Top" >
<Border.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Border.RenderTransform>
</Border>
Run Code Online (Sandbox Code Playgroud)
由于某种原因,变换组必须在那里才能为对象设置动画.无论如何,让我们说我在工作窗口中有那个寄宿生,我想用我用表达式混合创建的相同动画来制作动画.我将在代码中做的是:
Storyboard sb1 = FindResource("Storyboard1") …
Run Code Online (Sandbox Code Playgroud) c# ×9
linq ×2
wpf ×2
xaml ×2
animation ×1
comparison ×1
datacontext ×1
datetime ×1
excel ×1
excel-addins ×1
filetime ×1
hashtable ×1
itemssource ×1
performance ×1
resources ×1
storyboard ×1
stream ×1
wcf ×1
webget ×1
xcode4 ×1