This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RelayCommand : ICommand | |
{ | |
private Action<object> _execute; | |
private Func<object, bool> _canExecute; | |
public RelayCommand(Action<object> execute) | |
{ | |
_execute = execute; | |
_canExecute = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PrimeViewModel : INotifyPropertyChanged | |
{ | |
protected bool SetProperty<T>(ref T backingStore, T value, | |
[CallerMemberName] string propertyName = "", | |
Action onChanged = null) | |
{ | |
if (EqualityComparer<T>.Default.Equals(backingStore, value)) | |
return false; | |
backingStore = value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MyWpfProject.MainWindow mw = new MyWpfProject.MainWindow(); | |
ElementHost.EnableModelessKeyboardInterop(mw); | |
mw.Show(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | |
<CodeSnippet Format="1.0.0"> | |
<Header> | |
<Title>Query with handler</Title> | |
<Author>Patrik Šoma</Author> | |
<Description>SLM only!</Description> | |
<Shortcut>qryhnd</Shortcut> | |
</Header> | |
<Snippet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | |
<CodeSnippet Format="1.0.0"> | |
<Header> | |
<Title>Command with handler</Title> | |
<Author>Patrik Šoma</Author> | |
<Description>SLM Only!</Description> | |
<Shortcut>cmdhnd</Shortcut> | |
</Header> | |
<Snippet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Color x:Key="Primary">#0b5ed7</Color> | |
<Color x:Key="GridBackground">#4F000000</Color> | |
<Color x:Key="NexenColor">#9d1c9d</Color> | |
<Color x:Key="SomaDarkDark">#22272e</Color> | |
<Color x:Key="SomaDarkLight">#434c57</Color> | |
<Color x:Key="GithubDark">#24292f</Color> | |
<Color x:Key="GithubLight">#f6f8fa</Color> | |
<Color x:Key="GithubRed">#cf222e</Color> | |
<Color x:Key="GithubGreen">#2da44e</Color> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Example of conditional styling --> | |
<Label Grid.Row="2" Grid.Column="1" Text="{Binding Material.ITEM_STATE_FORMAT}" HorizontalOptions="Center" Style="{StaticResource detailText}"> | |
<Label.Triggers> | |
<DataTrigger Binding="{Binding Material.State}" TargetType="Label" Value="B"> | |
<Setter Property="Style" Value="{StaticResource detailText}" /> | |
</DataTrigger> | |
<DataTrigger Binding="{Binding Material.State}" TargetType="Label" Value="N"> | |
<Setter Property="Style" Value="{StaticResource detailTextError}" /> | |
</DataTrigger> | |
</Label.Triggers> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create tasks, must use Task.Run() not new Task() | |
Task expireTask = Task.Run(()=> { ExpireCheck(); }); | |
Task agingTask = Task.Run(() => { AgingCheck(); }); | |
Task fifoTask = Task.Run(() => { FIFOCheck(); }); | |
Task novalidTask = Task.Run(() => { NoValidCheck(); }); | |
Task nolifeTask = Task.Run(() => { NoLifeCheck(); }); | |
// Add them to list | |
List<Task> tasks = new List<Task>(); | |
tasks.Add(expireTask); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Prototype server for SNMP | |
Socket socket; | |
EndPoint ep; | |
byte[] buffer; | |
ManualResetEvent manualevent = new ManualResetEvent(false); | |
private void btnListener_Click(object sender, RoutedEventArgs e) | |
{ | |
// Construct a socket and bind it to the trap manager port 162 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Flat ComboBox --> | |
<SolidColorBrush x:Key="ComboBoxNormalBorderBrush" Color="#e3e9ef" /> | |
<SolidColorBrush x:Key="ComboBoxNormalBackgroundBrush" Color="#fff" /> | |
<SolidColorBrush x:Key="ComboBoxDisabledForegroundBrush" Color="#888" /> | |
<SolidColorBrush x:Key="ComboBoxDisabledBackgroundBrush" Color="#eee" /> | |
<SolidColorBrush x:Key="ComboBoxDisabledBorderBrush" Color="#888" /> | |
<ControlTemplate TargetType="ToggleButton" x:Key="ComboBoxToggleButtonTemplate"> | |
<Grid> | |
<Grid.ColumnDefinitions> |
NewerOlder