Issue with EventHandler of a custom class - c#

I am workin on a project that aims to interpret some parts of the finger alphabet. I am using a Kinect v1 to this end and these two projects: Lightbuzz.Vitruvius provides the main funcionality and Lightbuzz.Vitruvius.Fingertracking the ability to detect finger-tips (at least so far is the theory).
Plugging these two together was more tedious than challenging but the real challenge comes from an EventHandler. You see there is a HandController class where the fingers are detected and displayed. In this class is an EventHandler that kicks off the detection.
Having appropately changed every thing Rider now reports this error (I am using the .NET Framework 4.0):
<LightBuzz.Vitruvius>\HandsController.cs:1706 The type 'LightBuzz.Vitruvius.HandCollection' must be convertible to 'System.EventArgs' in order to use it as parameter 'TEventArgs' in the generic delegate 'void System.EventHandler<TEventArgs>(object, TEventArgs)'
The following is the EventHandler and the Code to be executed there on:
public event EventHandler<HandCollection> HandsDetected;
private void HandsController_HandsDetected(object sender, HandCollection e)
{
// Display the results!
if (e.HandLeft != null)
{
// Draw contour.
foreach (var point in e.HandLeft.ContourDepth)
{
kinectViewer.DrawEllipse(point, Brushes.Green, 2.0);
}
// Draw fingers.
foreach (var finger in e.HandLeft.Fingers)
{
kinectViewer.DrawEllipse(finger.DepthPoint, Brushes.White, 4.0);
}
}
if (e.HandRight != null)
{
// Draw contour.
foreach (var point in e.HandRight.ContourDepth)
{
kinectViewer.DrawEllipse(point, Brushes.Blue, 2.0);
}
// Draw fingers.
foreach (var finger in e.HandRight.Fingers)
{
kinectViewer.DrawEllipse(finger.DepthPoint, Brushes.White, 4.0);
}
}
}
// The object HandCollection is a seperate class as follows:
public partial class HandCollection
{
/// <summary>
/// The tracking ID of the current body.
/// </summary>
public int TrackingId { get; set; }
/// <summary>
/// The left hand data of the current body.
/// </summary>
public Hand HandLeft { get; set; }
/// <summary>
/// The right hand data of the current body.
/// </summary>
public Hand HandRight { get; set; }
}
My question would now be what does this error mean and how do I solve it? I have relatively few clues about the how and what of C#, so please be gentle. I have also found out that switching the framework to version 4.5 solves this issue but creates a dozen more.

As the error suggests, your HandCollection class cannot be used as a parameter in the eventhandler delegate. You might have your reasons for using .Net 4.0, so try making the class inherit from System.EventArgs and see if this works. Otherwise I would suggest switching framework.

Related

C# Async Server action every second

I've successfully created a simple server and client application in C# that communicate asynchronously between the server and multiple clients, i used the following Microsoft Docs to create it:
https://learn.microsoft.com/en-us/dotnet/framework/network-programming/asynchronous-server-socket-example
https://learn.microsoft.com/en-us/dotnet/framework/network-programming/asynchronous-client-socket-example
They are both working fine, but my question is, i want to execute an action every second on the server and i don't know the best way to go about it. Should i use something like the Timer class to do it? Is using a Timer interfere in any way with the calls that the server is receiving from the clients?
I would suggest using some form of Thread.Sleep or calling await on a method with a Task.Delay. See an example here.
Yes a timer is a good way to it.
I have something similar for a Blazor component called a Sprite, where I perform a movement of an image everytime the timer event goes off.
In my case my subscriber is an interface, ISpriteSubscriber:
namespace DataJuggler.Blazor.Components.Interfaces
{
#region interface ISpriteSubscriber
/// <summary>
/// This interface is used by the AnimationManager to notifiy callers that a refresh occurred.
/// </summary>
public interface ISpriteSubscriber
{
#region Methods
#region Refresh()
/// <summary>
/// This method will call StateHasChanged to refresh the UI
/// </summary>
void Refresh();
#endregion
#region Register(Sprite sprite)
/// <summary>
/// This method is called by the Sprite to a subscriber so it can register with the subscriber, and
/// receiver events after that.
/// </summary>
void Register(Sprite sprite);
#endregion
#endregion
#region Properties
#region ProgressBar
/// <summary>
/// This is used so the ProgressBar is stored and available to the Subscriber after Registering
/// </summary>
ProgressBar ProgressBar { get; set; }
#endregion
#endregion
}
#endregion
}
public ISpriteSubscriber Subscriber { get; set; }
In my Start event, I create the Timer:
public void Start()
{
this.Timer = new Timer();
this.Timer.Interval = this.interval;
this.Timer.Elapsed += Timer_Elapsed;
this.Timer.Start();
}
private void Timer_Elapsed(object sender, ElapsedEventArgs e)
{
// if a subscriber (returns true if Subscriber != null)
if (HasSubscriber)
{
// Notify Subscriber
Subscriber.Refresh();
}
}
public void Refresh()
{
// do your actions here
}
public void Register(Sprite sprite)
{
// If the sprite object exists
if (NullHelper.Exists(sprite))
{
// if this is the RedCar
if (sprite.Name == "RedCar")
{
// Set the RedCar
RedCar = sprite;
}
else
{
// Set the WhiteCar
WhiteCar = sprite;
}
}
}
The Refresh event is where I move an image (by random numbers in my example).
One tip When using a timer that goes off as often as you have it, I usually put something like a NotificationInProgress flag or something in case one operation takes longer than a second.
Maybe in your use case it is ok to have multiple messages, but sometimes you need to wait on one to finish before completing the next.
public bool NotificationInProgress { get; set; }
Then before you notify a Subscriber I test
if (!NotificationInProgress)
{
// send your message.
}
If you want to see an open source Blazor sample project where I demonstrate simple animations that this code came from, it is here:
https://github.com/DataJuggler/DataJuggler.Blazor.Components
Maybe it will give you some ideas on how to arrange your project.

Using interface to pass through a method

I've got 2+ objects that come from different inheritance trees, but I'd like them to share a common set of code IMoveable.
The IMoveable interface is looking good, and I'm happy with where I've got with it:
public interface IMoveable
{
/// <summary>
/// The speed the object travells between start and end
/// </summary>
int Speed { get; set; }
/// <summary>
/// The current velocity of the object
/// </summary>
Vector2 Velocity { get; set; }
/// <summary>
/// How far the object has travelled
/// </summary>
int DistanceTravelled { get; set; }
/// <summary>
/// The map the object is traversing
/// </summary>
Map Map { get; set; }
/// <summary>
/// Where the object was when they started moving
/// </summary>
Rectangle StartRectangle { get; set; }
/// <summary>
/// Where the object is right now
/// </summary>
Rectangle CurrentRectangle { get; }
/// <summary>
/// Where the object will be after moving
/// </summary>
Rectangle EndRectangle { get; set; }
/// <summary>
/// What will happen if the object walks to the "EndRectangle"
/// </summary>
Map.CollisionResults CollisionResult { get; set; }
/// <summary>
/// What happens if the object triggers a battle
/// </summary>
Action OnBattle { get; set; }
/// <summary>
/// How the object determines their movement
/// </summary>
Action SetMovement { get; set; }
}
With that interface I have a method:
private static void Move(IMoveable moveableOjb)
{
moveableOjb.Speed = 4;
if (moveableOjb.DistanceTravelled > 0)
{
moveableOjb.DistanceTravelled += moveableOjb.Speed;
if (moveableOjb.DistanceTravelled > Map.TileWidth)
{
moveableOjb.DistanceTravelled = 0;
moveableOjb.Velocity = new Vector2();
}
else
{
return;
}
}
moveableOjb.SetMovement();
if (moveableOjb.Velocity != Vector2.Zero)
{
moveableOjb.StartRectangle = moveableOjb.CurrentRectangle;
moveableOjb.EndRectangle = new Rectangle(
moveableOjb.CurrentRectangle.X + ((int)moveableOjb.Velocity.X * 10),
moveableOjb.CurrentRectangle.Y + ((int)moveableOjb.Velocity.Y * 10),
moveableOjb.CurrentRectangle.Width,
moveableOjb.CurrentRectangle.Height);
moveableOjb.CollisionResult = moveableOjb.Map.GetValue(moveableOjb.EndRectangle);
switch (moveableOjb.CollisionResult)
{
case Map.CollisionResults.None:
break;
case Map.CollisionResults.Colliding:
moveableOjb.Velocity = new Vector2();
break;
case Map.CollisionResults.Battle:
moveableOjb.OnBattle();
moveableOjb.Velocity = new Vector2();
break;
case Map.CollisionResults.OffRight:
case Map.CollisionResults.OffLeft:
case Map.CollisionResults.OffTop:
case Map.CollisionResults.OffBottom:
moveableOjb.Speed = 0;
break;
default:
break;
}
}
if (moveableOjb.Velocity != Vector2.Zero)
moveableOjb.DistanceTravelled += moveableOjb.Speed;
}
The problem I'm facing is this code is just weird. I've gotten a static Move method and I don't know where to put it, and I feel like I've gone about this the completely wrong way.
An alternative I have to this is rewrite my classes so instead of them coming from different inheritance, they are in the same tree. I could do that, but it will take some time to restructure.
I guess my main question is - am I going about this the wrong way, or am I close to following a coding practice that I can't quite figure out?
Example of implementation:
public class ClassA : Sprite, IMoveable
{
// interface implementation
public override Update(GameTime gameTime)
{
// Stuff
Move(this);
// More stuff
}
}
EDIT:
I've been informed that is C# 8 you can have default interface methods. I think that may be exactly what I need!
You are confusing what static means. When a method affects a specific instance, like in this case, it should be non static. This is where the "weirdness" comes from.
Static methods are for general operations or, though with pros and cons, as a surrogate for singletons.
Instead of a static method, define it as a member of the class that implements IMoveable or as a default interface method. With no instance as parameter. That way the instance, this, will be moving. You will be able to move by calling it from that instance, which makes more sense semantically:
IMoveable moveableObj = //constructor here...
moveableObj.Move();
If every class implementing the interface moves in the same way, you can still avoid putting the reference to the instance as a parameter and use this. Perhaps the parameters are best used for information about the movement, if needed.

C# Check if controls are a value that I can take in a physical board

I've been working on this for a bit, and I've been stuck at this one spot, I can't figure out a way to count the points in the board...
So, first of all, this is a part of the code that makes the cases, in which my tokens are in:
class Case:Control
{
public Point Position { get; set; }
/// <summary>
/// Creates the dimensions for the cases
/// </summary>
public Case()
{
MaximumSize = new Size(50, 50);
MinimumSize = new Size(50, 50);
}
/// <summary>
/// Creates the background for the cases
/// </summary>
public enum DifferentCase
{
Dark,
Pale,
Brown
}
/// <summary>
/// Creates the tokens
/// </summary>
public enum Token
{
Nothing,
White,
Black
}
public DifferentCase ColorCase { get; set; }
public Token ColorToken { get; set; }
public bool IsBlack { get; set; }
And those being my tokens, I have a method that I'm trying to make that counts how many tokens are black and how many are white:
private void CheckPoints(Case cases)
{
foreach (Case case_ in cases.Controls)
{
if (case_.ColorToken == Case.Token.Black)
{
_player1Points++;
lbl_player1Points.Text = _player1Points.ToString();
}
else if (case_.ColorToken == Case.Token.White)
{
_player2Points++;
lbl_player2Points.Text = _player2Points.ToString();
}
}
}
But when I try to call that method in like this: CheckPoints() for example, if I'm clicking on of those cases, it tells me that "There is no argument that corresponds to the required formal parameter "cases" of 'frm_othello.CheckPoints(Case)'"
I don't know if the code that I put in that method is good, neither I don't know why I cant call that method in.
Currently you can't call CheckPoints(); with no arguments. You have defined it with a parameter Case
so you need to do CheckPoints(cases) or whatever is the name of the variable / property / field that has cases

Caliburn.Micro nested ViewModels best practice

This is a pretty long question, so please bear with me.
Currently I am developing a small tool intended to help me keep track of the myriad of characters in my Stories.
The tool does the following:
Load the characters which are currently stored as json on the disk and stores them in a list, which is presented in the Shell via a ListBox.
If the user then opens a character the Shell, which is a Conductor<Screen>.Collection.OneActive, opens a new CharacterViewModel, that derives from Screen.
The Character gets the Character that is going to be opened via the IEventAggregator message system.
The CharacterViewModel furthermore has various properties which are sub ViewModels which bind to various sub Views.
And here is my Problem:
Currently I initialize the sub ViewModels manually when the ChracterViewModel is initialized. But this sounds fishy to me and I am pretty sure there is a better way to do this, but I cannot see how I should do it.
Here is the code of the CharacterViewModel:
/// <summary>ViewModel for the character view.</summary>
public class CharacterViewModel : Screen, IHandle<DataMessage<ICharacterTagsService>>
{
// --------------------------------------------------------------------------------------------------------------------
// Fields
// -------------------------------------------------------------------------------------------------------------------
/// <summary>The event aggregator.</summary>
private readonly IEventAggregator eventAggregator;
/// <summary>The character tags service.</summary>
private ICharacterTagsService characterTagsService;
// --------------------------------------------------------------------------------------------------------------------
// Constructors & Destructors
// -------------------------------------------------------------------------------------------------------------------
/// <summary>Initializes a new instance of the <see cref="CharacterViewModel"/> class.</summary>
public CharacterViewModel()
{
if (Execute.InDesignMode)
{
this.CharacterGeneralViewModel = new CharacterGeneralViewModel();
this.CharacterMetadataViewModel = new CharacterMetadataViewModel();
}
}
/// <summary>Initializes a new instance of the <see cref="CharacterViewModel"/> class.</summary>
/// <param name="eventAggregator">The event aggregator.</param>
[ImportingConstructor]
public CharacterViewModel(IEventAggregator eventAggregator)
: this()
{
this.eventAggregator = eventAggregator;
this.eventAggregator.Subscribe(this);
}
// --------------------------------------------------------------------------------------------------------------------
// Properties
// -------------------------------------------------------------------------------------------------------------------
/// <summary>Gets or sets the character.</summary>
public Character Character { get; set; }
/// <summary>Gets or sets the character general view model.</summary>
public CharacterGeneralViewModel CharacterGeneralViewModel { get; set; }
/// <summary>Gets or sets the character metadata view model.</summary>
public CharacterMetadataViewModel CharacterMetadataViewModel { get; set; }
/// <summary>Gets or sets the character characteristics view model.</summary>
public CharacterApperanceViewModel CharacterCharacteristicsViewModel { get; set; }
/// <summary>Gets or sets the character family view model.</summary>
public CharacterFamilyViewModel CharacterFamilyViewModel { get; set; }
// --------------------------------------------------------------------------------------------------------------------
// Methods
// -------------------------------------------------------------------------------------------------------------------
/// <summary>Saves a character to the file system as a json file.</summary>
public void SaveCharacter()
{
ICharacterSaveService saveService = new JsonCharacterSaveService(Constants.CharacterSavePathMyDocuments);
saveService.SaveCharacter(this.Character);
this.characterTagsService.AddTags(this.Character.Metadata.Tags);
this.characterTagsService.SaveTags();
}
/// <summary>Called when initializing.</summary>
protected override void OnInitialize()
{
this.CharacterGeneralViewModel = new CharacterGeneralViewModel(this.eventAggregator);
this.CharacterMetadataViewModel = new CharacterMetadataViewModel(this.eventAggregator, this.Character);
this.CharacterCharacteristicsViewModel = new CharacterApperanceViewModel(this.eventAggregator, this.Character);
this.CharacterFamilyViewModel = new CharacterFamilyViewModel(this.eventAggregator);
this.eventAggregator.PublishOnUIThread(new CharacterMessage
{
Data = this.Character
});
base.OnInitialize();
}
/// <summary>
/// Handles the message.
/// </summary>
/// <param name="message">The message.</param>
public void Handle(DataMessage<ICharacterTagsService> message)
{
this.characterTagsService = message.Data;
}
}
For Completion Sake I also give you one of the sub ViewModels. The others a of no importance because they are structured the same way, just perform different tasks.
/// <summary>The character metadata view model.</summary>
public class CharacterMetadataViewModel : Screen
{
/// <summary>The event aggregator.</summary>
private readonly IEventAggregator eventAggregator;
/// <summary>Initializes a new instance of the <see cref="CharacterMetadataViewModel"/> class.</summary>
public CharacterMetadataViewModel()
{
if (Execute.InDesignMode)
{
this.Character = DesignData.LoadSampleCharacter();
}
}
/// <summary>Initializes a new instance of the <see cref="CharacterMetadataViewModel"/> class.</summary>
/// <param name="eventAggregator">The event aggregator.</param>
/// <param name="character">The character.</param>
public CharacterMetadataViewModel(IEventAggregator eventAggregator, Character character)
{
this.Character = character;
this.eventAggregator = eventAggregator;
this.eventAggregator.Subscribe(this);
}
/// <summary>Gets or sets the character.</summary>
public Character Character { get; set; }
/// <summary>
/// Gets or sets the characters tags.
/// </summary>
public string Tags
{
get
{
return string.Join("; ", this.Character.Metadata.Tags);
}
set
{
char[] delimiters = { ',', ';', ' ' };
List<string> tags = value.Split(delimiters, StringSplitOptions.RemoveEmptyEntries).ToList();
this.Character.Metadata.Tags = tags;
this.NotifyOfPropertyChange(() => this.Tags);
}
}
}
I already read in on Screens, Conductors and Composition, IResult and Coroutines and skimmed the rest of the Documentation, but somehow I cannot find what I am looking for.
//edit: I should mention the code I have works just fine. I'm just not satisfied with it, since I think I am not understanding the concept of MVVM quite right and therefore make faulty code.
There is nothing wrong with having one ViewModel instantiate several child ViewModels. If you're building a larger or more complex application, it's pretty much unavoidable if you want to keep your code readable and maintainable.
In your example, you are instantiating all four child ViewModels whenever you create an instance of CharacterViewModel. Each of the child ViewModels takes IEventAggregator as a dependency. I would suggest that you treat those four child ViewModels as dependencies of the primary CharacterViewModel and import them through the constructor:
[ImportingConstructor]
public CharacterViewModel(IEventAggregator eventAggregator,
CharacterGeneralViewModel generalViewModel,
CharacterMetadataViewModel metadataViewModel,
CharacterAppearanceViewModel appearanceViewModel,
CharacterFamilyViewModel familyViewModel)
{
this.eventAggregator = eventAggregator;
this.CharacterGeneralViewModel generalViewModel;
this.CharacterMetadataViewModel = metadataViewModel;
this.CharacterCharacteristicsViewModel = apperanceViewModel;
this.CharacterFamilyViewModel = familyViewModel;
this.eventAggregator.Subscribe(this);
}
You can thus make the setters on the child ViewModel properties private.
Change your child ViewModels to import IEventAggregator through constructor injection:
[ImportingConstructor]
public CharacterGeneralViewModel(IEventAggregator eventAggregator)
{
this.eventAggregator = eventAggregator;
}
In your example, two of those child ViewModels are passed an instance of the Character data in their constructors, implying a dependency. In these cases, I would give each child ViewModel a public Initialize() method where you set the Character data and activate the event aggregator subscription there:
public Initialize(Character character)
{
this.Character = character;
this.eventAggregator.Subscribe(this);
}
Then call this method in your CharacterViewModel OnInitialize() method:
protected override void OnInitialize()
{
this.CharacterMetadataViewModel.Initialize(this.Character);
this.CharacterCharacteristicsViewModel.Initialize(this.Character);
this.eventAggregator.PublishOnUIThread(new CharacterMessage
{
Data = this.Character
});
base.OnInitialize();
}
For the child ViewModels where you're only updating the Character data through the EventAggregator, leave the this.eventAggregator.Subscribe(this) call in the constructor.
If any of your child ViewModels are not actually required for the page to function, you could initialize those VM properties via property import:
[Import]
public CharacterGeneralViewModel CharacterGeneralViewModel { get; set; }
Property imports don't occur until after the constructor has completed running.
I would also suggest handling the instantiation of ICharacterSaveService through constructor injection as well, rather than explicitly creating a new instance every time you save data.
The primary purpose of MVVM was to allow front-end designers to work on the layout of the UI in a visual tool (Expression Blend) and coders to implement the behavior and business without interfering with one another. The ViewModel exposes data to be bound to the view, describes the view's behavior at an abstract level, and frequently acts as a mediator to the back-end services.
There is no one "correct" way to do it, and there are situations where it isn't the best solution. There are times when the best solution is to toss the extra layer of abstraction of using a ViewModel and just write some code-behind. So while it's a great structure for your application as a whole, don't fall into the trap of forcing everything to fit into the MVVM pattern. If you have a few more graphically complex user controls where it simply works better to have some code-behind, then that's what you should do.

Form does not work unless .Show() is called

I have a form that represents a USB device Terminal that has been giving me some errors. After half a day of debugging strange errors with no known source I somehow found out that the Terminal does not function when it is instantiated but not shown. When I change the code and add usbTerminal.Show();, then it works properly.
USBTerminal usbTouchTerminal;
public MainForm()
{
InitializeComponent();
USBSettings usbTouchSettings = new USBSettings();
usbTouchTerminal = new USBTerminal(usbTouchSettings); //Create Terminal with settings
usbTouchTerminal.StartUSB();
usbTouchTerminal.Show(); //works ONLY when show is here
}
How is this possible and why? I've done a massive search and none of my code depends on the .Visible property on either my Terminal or main form?
I'm completely baffled on why some form would not work if it isn't shown. MSDN or google wasn't really a help either. I was certain it would function properly when instantiated but not shown.
PS. I added
usbTerminal.Show();
usbTerminal.Hide();
and the Terminal functioned correctly.
Thank you for any help!
EDIT:
I should also note that this usbTerminal uses the WndProc override. I'm not an expert on that, but I feel that it may have something to do with it.
I should note that this is LibUSBdotnet
public class USBSettings
{
/// <summary>
/// This is the Vender ID Number. (0x0B6A)
/// </summary>
public ushort VID { get; set; }
/// <summary>
/// This is the Product ID Number. (0x5346)
/// </summary>
public ushort PID { get; set; }
/// <summary>
/// This is the optional Serial Name. ("")
/// </summary>
public string SerialName { get; set; }
/// <summary>
/// This is the Reader USB Endpoint. (ReadEndpointID.Ep02)
/// </summary>
public ReadEndpointID ReaderEndpoint { get; set; }
/// <summary>
/// This is the Writer USB Endpoint. (WriteEndpointID.Ep01)
/// </summary>
public WriteEndpointID WriterEndpoint { get; set; }
/// <summary>
/// This is the Registry Key for USB settings. ("SOFTWARE\\DEFAULT\\USBPROPERTIES")
/// </summary>
public string SubKey { get; set; }
/// <summary>
/// This is the default read buffer size for the USB Device.
/// </summary>
public int ReadBufferSize { get; set; }
/// <summary>
/// This constructor houses default values for all properties.
/// </summary>
public USBSettings()
{
VID = 0x0B6A;
PID = 0x5346;
SerialName = "";
ReaderEndpoint = ReadEndpointID.Ep02;
WriterEndpoint = WriteEndpointID.Ep01;
SubKey = "SOFTWARE\\DEFAULT\\USBPROPERTIES";
ReadBufferSize = 100;
}
}
The question is poorly documented but this is fairly normal for code that works with devices. They tend to need to know about Plug & Play events and that requires a top-level window to be created that receives the WM_DEVICECHANGE notification message. Creating a .NET Form object isn't enough, you also have to create the native window for it. Which, in typical .NET lazy fashion, happens at the last possible moment, when you force the window to be visible. Either by calling the Show() method or setting the Visible property to true. The window doesn't actually have to be visible to get the Plug & Play notifications.
You can get the window created without also making it visible. That requires modifying the USBTerminal class. Paste this code:
protected override void SetVisibleCore(bool value) {
if (!this.IsHandleCreated) {
this.CreateHandle();
value = false;
}
base.SetVisibleCore(value);
}
And call the Show() method as normal. Beware that the Load event won't fire until the window actually becomes visible so if necessary move any code in the event handler to this method. If this is not the primary window for the app, in other words not the one that's passed to Application.Run() in your Main() method, then you can make do with simply calling this.CreateHandle() as the last statement in the form constructor. In which case calling Show() is no longer necessary.
I suspect this is because the underlying window is not created before you call Show(). Since the window isn't created, your custom WndProc isn't called.
To verify, you can create the window without showing it - by looking at the Handle property. As the documentation says - if the handle has not been created by the time you call, it will be created. Try it, I bet it'll work just as if you called Show and then Hide.
It is very hard to tell from the information you have but I think you are using a form where a class should be used. You should rethink your program structure and re-write this as a class to hold and transmit the data as you need. As some of the other have pointed out the listbox and/or other function are not running until the form is shown and the methods is executed.
Because some required functions will be called when Form onShow event called.

Categories

Resources