This file contains hidden or 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
| using MaterialDesignThemes.Wpf; | |
| using System; | |
| using System.Collections; | |
| using System.ComponentModel; | |
| using System.Globalization; | |
| using System.Linq; | |
| using System.Reflection; | |
| using System.Windows; | |
| using System.Windows.Controls; | |
| using System.Windows.Data; |
This file contains hidden or 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
| sealed class DeferredAction : IDisposable | |
| { | |
| private Timer timer; | |
| private bool disposed = false; | |
| /// <summary> | |
| /// Creates a new DeferredAction. | |
| /// </summary> | |
| /// <param name="action"> | |
| /// The action that will be deferred. It is not performed until after <see cref="Defer"/> is called. |
This file contains hidden or 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
| namespace Foo | |
| { | |
| public class RelayCommand<T> : ICommand | |
| { | |
| private readonly Action<T> _execute; | |
| private readonly Predicate<T> _canExecute; | |
| public RelayCommand(Action<T> execute) | |
| : this(execute, null) | |
| { |
This file contains hidden or 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
| private static RoutedUICommand _pressMeCommand = | |
| new RoutedUICommand("Press Me", "PressMe", typeof(MainWindow)); | |
| public static RoutedUICommand PressMeCommand | |
| { | |
| get { return _pressMeCommand; } | |
| } | |
| private void PressMe_CanExecute(object sender, CanExecuteRoutedEventArgs e) | |
| { | |
| e.CanExecute = CowboyCanTalk; |
This file contains hidden or 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 DependencyPropertyExample | |
| { | |
| // Dependency Property | |
| public static readonly DependencyProperty CurrentTimeProperty = | |
| DependencyProperty.Register( "CurrentTime", typeof(DateTime), | |
| typeof(MyClockControl), | |
| new FrameworkPropertyMetadata( DateTime.Now, | |
| OnCurrentTimePropertyChanged, // optional | |
| OnCoerceCurrentTimeProperty ), // optional | |
| OnValidateCurrentTimeProperty ); // optional |
This file contains hidden or 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
| // Register the routed event | |
| public static readonly RoutedEvent SelectedEvent = | |
| EventManager.RegisterRoutedEvent( "Selected", RoutingStrategy.Bubble, | |
| typeof(RoutedEventHandler), typeof(MyCustomControl)); | |
| // .NET wrapper | |
| public event RoutedEventHandler Selected | |
| { | |
| add { AddHandler(SelectedEvent, value); } | |
| remove { RemoveHandler(SelectedEvent, value); } |
This file contains hidden or 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 static class VisualTreeHelperExtensions | |
| { | |
| public static T FindAncestor<T>(DependencyObject dependencyObject) | |
| where T : class | |
| { | |
| DependencyObject target = dependencyObject; | |
| do | |
| { | |
| target = VisualTreeHelper.GetParent(target); | |
| } |
This file contains hidden or 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
| enum class Result | |
| { | |
| // failure codes are here and are negative numbers | |
| ERROR_UNEXPECTED = -100000, | |
| ERROR_MEMORY, // i.e: not enough memory to continue execution | |
| ERROR_MEMORY_BAD_CAST, // dynamic cast has failed | |
| ERROR_MEMORY_BAD_ALLOC, // could not allocate memory on selected heap | |
| ERROR_STACKOVERFLOW, // a stack has overflowed | |
| ERROR_ARGUMENT_INVALID, // an argument to a method was invalid | |
| ERROR_ARGUMENT_OUT_OF_RANGE, // argument value is out of range |
This file contains hidden or 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
| template<typename T> | |
| class IData : public IBase { | |
| public: | |
| using Ptr = std::unique_ptr<typename IData<T>, SDeleter>; | |
| public: | |
| virtual const T* Get(uint32_t& size) const noexcept = 0; | |
| }; | |
| using IString = IData<uchar>; |
This file contains hidden or 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
| #include "FooAPIDefs.h" | |
| #define FOOINTERFACES_VERSION 7 | |
| extern "C" FOOINTERFACES_API IFooFactory* GetFooFactoryPtr(const uchar* options = nullptr, uint32_t version = FOOINTERFACES_VERSION) noexcept; | |
| // API entry point | |
| inline IFooFactory::Ptr GetFooFactory(const uchar* options = nullptr, uint32_t version = FOOINTERFACES_VERSION) { | |
| return IFooFactory::Ptr(GetFooFactoryPtr(options, version)); | |
| } |
OlderNewer