本文整理汇总了C#中ObservableDictionary类的典型用法代码示例。如果您正苦于以下问题:C# ObservableDictionary类的具体用法?C# ObservableDictionary怎么用?C# ObservableDictionary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObservableDictionary类属于命名空间,在下文中一共展示了ObservableDictionary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GeomagicTouchViewModel
/// <summary>
/// Constructs a new GeomagicTouch View Model
/// </summary>
public GeomagicTouchViewModel()
{
DeviceNames = new ObservableCollection<string>();
SignalSources = new ObservableDictionary<string, SignalSourceViewModel>();
SignalSources.Add("X", new SignalSourceViewModel("X Position"));
SignalSources.Add("Y", new SignalSourceViewModel("Y Position"));
SignalSources.Add("Z", new SignalSourceViewModel("Z Position"));
SignalSources.Add("Theta1", new SignalSourceViewModel("Gimbal Theta 1"));
SignalSources.Add("Theta2", new SignalSourceViewModel("Gimbal Theta 2"));
SignalSources.Add("Theta3", new SignalSourceViewModel("Gimbal Theta 3"));
SignalSources.Add("Inkwell", new SignalSourceViewModel("Inkwell Switch"));
SignalSources.Add("Button1", new SignalSourceViewModel("Button 1"));
SignalSources.Add("Button2", new SignalSourceViewModel("Button 2"));
SignalSources.Add("Button3", new SignalSourceViewModel("Button 1"));
SignalSources.Add("Button4", new SignalSourceViewModel("Button 2"));
TypeName = "Geomagic Touch";
// Get a list of all GeomagicTouch device names
foreach(string device in GetGeomagicDevices())
{
DeviceNames.Add(device);
}
UpdateTimer = new System.Timers.Timer();
UpdateTimer.Elapsed += UpdateTimer_Elapsed;
UpdateTimer.Interval = 50;
}
示例2: ShouldBindBetweenIndexedObjects
public void ShouldBindBetweenIndexedObjects()
{
var binder = new Binder<ObservableDictionary<UniversalStub>>();
var dict= new ObservableDictionary<UniversalStub>();
binder.BindIf(x => x.ContainsKey("first") && x.ContainsKey("second"), x => x["first"].String).To(x => x["second"].String);
using (binder.Attach(dict))
{
var first = new UniversalStub();
var second = new UniversalStub { String = "a" };
dict.Add("second", second);
second.String.ShouldBe("a");
using (second.VerifyChangedOnce("String"))
{
dict.Add("first", first);
}
second.String.ShouldBe(null);
using (second.VerifyChangedOnce("String"))
{
first.String = "b";
}
second.String.ShouldBe("b");
}
}
示例3: BlockTypes_OnAdded
private void BlockTypes_OnAdded(object sender, ObservableDictionary<string, JSBlockType>.DictionaryEventArgs e)
{
var material = new Material(BaseBlockMaterial);
material.color = GetColor(e.Value);
blockMaterials.Add(e.Key, material);
e.Value.ColorChanged += BlockType_ColorChanged;
}
示例4: MainViewModel
/// <summary>
/// Initializes a new instance of the MainViewModel class.
/// </summary>
public MainViewModel()
{
instance = this; // this sets the static Instance property to this instance.
Plugins = new ObservableCollection<PluginBase>();
Devices = new ObservableCollection<Device>();
Motors = new ObservableCollection<MotorViewModel>();
Plugins.CollectionChanged += Plugins_CollectionChanged;
Controllers = new ObservableCollection<ControllerViewModel>();
Controllers.CollectionChanged += Controllers_CollectionChanged;
Robot = new Robot();
// This lets us know what's going on with the Robot's internal Joint collection.
Robot.Controllers.CollectionChanged += RobotControllers_CollectionChanged;
//InputSignalRegistry = new ViewModel.SignalSinkRegistryViewModel();
InputSignalRegistry = new ObservableDictionary<string, string>();
Messenger.Default.Register<Messages.RemoveController>(this,
(message) =>
{
Controllers.Remove(message.ControllerToRemove);
com = this.Robot.Com;
}
);
}
示例5: OnStartup
protected override void OnStartup( StartupEventArgs e )
{
base.OnStartup( e );
mMainWindow = new MainWindow();
var windowDescriptions = new ObservableDictionary<string, D3D11HwndDescription>
{
{
"TileManager2D",
new D3D11HwndDescription
{
Handle = mMainWindow.TileManager2DViewerContext.D3D11RenderingPaneHost.Handle,
Width = mMainWindow.TileManager2DViewerContext.D3D11RenderingPaneHost.Width,
Height = mMainWindow.TileManager2DViewerContext.D3D11RenderingPaneHost.Height
}
},
};
mEngine = new Engine( windowDescriptions );
mUpdateTimer = new DispatcherTimer( DispatcherPriority.Input ) { Interval = TimeSpan.FromMilliseconds( Settings.Default.TargetFrameTimeMilliseconds ) };
mUpdateTimer.Tick += TickHandler;
mUpdateTimer.Start();
var engineDataContext = new EngineDataContext( mEngine, new TileManagerDataContext( mEngine.TileManager ) );
mMainWindow.DataContext = engineDataContext;
mMainWindow.Closing += OnMainWindowClosing;
mMainWindow.Show();
}
示例6: SwaggerService
/// <summary>Initializes a new instance of the <see cref="SwaggerService"/> class.</summary>
public SwaggerService()
{
Swagger = "2.0";
Schemes = new List<SwaggerSchema>();
Responses = new Dictionary<string, SwaggerResponse>();
SecurityDefinitions = new Dictionary<string, SwaggerSecurityScheme>();
Info = new SwaggerInfo
{
Version = string.Empty,
Title = string.Empty
};
Definitions = new ObservableDictionary<string, JsonSchema4>();
Definitions.CollectionChanged += (sender, args) =>
{
foreach (var pair in Definitions.Where(p => string.IsNullOrEmpty(p.Value.TypeName)))
pair.Value.TypeName = pair.Key;
};
Paths = new ObservableDictionary<string, SwaggerOperations>();
Paths.CollectionChanged += (sender, args) =>
{
foreach (var path in Paths.Values)
path.Parent = this;
};
}
示例7: InitDisplayResources
/// <summary>
/// Get display resource for current project.
/// </summary>
/// <returns>Resource of project as a dictionary.</returns>
public static void InitDisplayResources()
{
var culture = GetCurrentCulture();
if (Resource != null)
{
return;
}
Resource = new ObservableDictionary<string, string>();
try
{
var resourceStringMap = ResourceManager.Current.MainResourceMap.GetSubtree("Resources");
foreach (var key in resourceStringMap.Keys)
{
// get resources base on context language
Resource[key] = resourceStringMap.GetValue(key, culture).ValueAsString;
}
}
catch (Exception exception)
{
LogManager.Instance.LogException(exception.ToString());
}
Resource["DOW_1"] = CultureInfo.CurrentCulture.DateTimeFormat.DayNames[0];
Resource["DOW_2"] = CultureInfo.CurrentCulture.DateTimeFormat.DayNames[1];
Resource["DOW_3"] = CultureInfo.CurrentCulture.DateTimeFormat.DayNames[2];
Resource["DOW_4"] = CultureInfo.CurrentCulture.DateTimeFormat.DayNames[3];
Resource["DOW_5"] = CultureInfo.CurrentCulture.DateTimeFormat.DayNames[4];
Resource["DOW_6"] = CultureInfo.CurrentCulture.DateTimeFormat.DayNames[5];
Resource["DOW_7"] = CultureInfo.CurrentCulture.DateTimeFormat.DayNames[6];
}
示例8: AddItem
public void AddItem()
{
_handle = new EventWaitHandle(false, EventResetMode.ManualReset);
var test = new ObservableDictionary<int, string>();
test.ItemAdded += Dictionary_ItemEvent;
test.Add(0, "myValue");
Assert.IsTrue(_handle.WaitOne(10));
}
示例9: ObservableDictionaryExtensions_Any_ReturnsFalseIfObservableDictionaryDoesNotContainItems
public void ObservableDictionaryExtensions_Any_ReturnsFalseIfObservableDictionaryDoesNotContainItems()
{
var dictionary = new ObservableDictionary<Int32, String>();
var result = dictionary.Any();
TheResultingValue(result).ShouldBe(false);
}
示例10: CustomNodeLoader
/// <summary>
/// Class Constructor
/// </summary>
/// <param name="searchPath">The path to search for definitions</param>
public CustomNodeLoader(string searchPath)
{
SearchPath = new ObservableCollection<string>();
SearchPath.Add(searchPath);
NodeNames = new ObservableDictionary<string, Guid>();
NodeCategories = new ObservableDictionary<Guid, string>();
}
示例11: Project
public Project()
{
LastAssignedUniqueID = 0;
_lastPageNumber = 0;
PageDictionary = new ObservableDictionary<long, ASGPage>();
ProjectName = "Untitled Project";
DefaultCanvasSettings = new CanvasSettings();
}
示例12: PlayerShip
public PlayerShip()
{
MaxHull = Hull = 30;
Scrap = 0;
Items = new ObservableDictionary<string, int>();
Items.CollectionChanged += (sender, e) =>
DoShipModified(new ShipModifiedEventArgs("Items", e));
}
示例13: ObservableDictionaryExtensions_All_ReturnsTrueIfObservableDictionaryIsEmpty
public void ObservableDictionaryExtensions_All_ReturnsTrueIfObservableDictionaryIsEmpty()
{
var dictionary = new ObservableDictionary<Int32, String>();
var result = dictionary.All(x => x.Key % 2 == 0);
TheResultingValue(result).ShouldBe(true);
}
示例14: IOSpec
/// <summary>
/// Initializes a new s_instance of the <see cref="IOSpec"/> class.
/// </summary>
internal IOSpec()
{
m_input = new ObservableDictionary<string, IOItem>();
m_output = new ObservableDictionary<string, IOItem>();
((INotifyCollectionChanged)m_input).CollectionChanged += new NotifyCollectionChangedEventHandler(IOSpec_CollectionChanged);
((INotifyCollectionChanged)m_output).CollectionChanged += new NotifyCollectionChangedEventHandler(IOSpec_CollectionChanged);
}
示例15: DisplayAllView
public DisplayAllView()
{
this.InitializeComponent();
EntryRepository = new EntryRepository();
NavigationHelper = new NavigationHelper(this);
DefaultViewModel = new ObservableDictionary();
NavigationHelper.LoadState += NavigationHelper_LoadState;
NavigationHelper.SaveState += NavigationHelper_SaveState;
}