-
Xamarin - change image for ImageButton
For my project I'm working on I needed a button with an image that needs to be changed according to a state variable using XAML and MVVM. In this case, the changing image for a start / stop button:
Add the ImageButton to the MainPage.xaml:
<ContentPage.BindingContext> <local:MainPageViewModel /> </ContentPage.BindingContext> <StackLayout> <ImageButton Source="{Binding StartStopImage}" Command="{Binding StartStopCommand}" WidthRequest="50" HeightRequest="50" HorizontalOptions="Center" VerticalOptions="Center" > </ImageButton>Add the implementation for MVVM:
public MainPageViewModel() { StartStopCommand = new Command(async () => await StartStop()); } public async Task StartStop() { recordEnabled = !recordEnabled; StartStopImage = recordEnabled ? "stop.png" : "start.png"; } public Command StartStopCommand { get; } private string startStopImage = "stop.png"; public string StartStopImage { get => startStopImage; set { startStopImage = value; OnPropertyChanged(nameof(StartStopImage)); } } public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged([CallerMemberName] string propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } -
Engineering Pi Day
It was in one of my first physics courses that the professor used 22/7 in an equation as an approximation. Within a few steps, he calculated the result on the board, leaving us impressed.
So simple, and yet so close:
$$\frac{22}{7} = 3.\overline{142857}$$
$$\pi = 3.14159265358\ldots$$
$$\frac{22}{7} - \pi \approx 0.00126$$
The math department would not have approved, but we engineers were perfectly fine with it!
-
Dragonfly landed safely
A dragonfly made it safely to our garden, fresh from its latest airshow performance.
Panasonic DMC-GM1 1/160s f/5,6 ISO 200/24° f=32mm/64mm
Panasonic DMC-GM1 1/160s f/6,3 ISO 200/24° f=32mm/64mm
Captains view
Panasonic DMC-GM1 1/160s f/6,3 ISO 200/24° f=32mm/64mm
Update: Anisoptera at Rest — A Moment on the Leaf
Nikon Z30 1/125s f/6,3 ISO 900 16-50mm f/3,5-6,3 VR f=50mm/75mm
Nikon Z30 1/50s f/6,3 ISO 400/27° 105mm f/2,8 VR
Nikon Z30 1/60s f/7,1 ISO 400/27° 105mm f/2,8 VR
Nikon Z30 1/60s f/7,1 ISO 400/27° 105mm f/2,8 VR
Nikon Z30 1/60s f/7,1 ISO 400/27° 105mm f/2,8 VR
Nikon Z30 1/80s f/10 ISO 1250 105mm f/2,8 VR
-
Overflow valve for CJ750 / M72 final drive
The amount of oil in final drive of the CJ750 / M72 motorcycle needs to be very precise, otherwise the oil is pushed out through the main seal. The reason for this is the small volume of the final drive gear. Even the slightest overfilling push out oil when the final drive gets warm during driving.
To solve the problem, I had installed a small cylindric chamber (1) to collect the oil. But there was still some oil splashed out of the breathing hole so I added another chamber on top of it (2).
With the recommended 0.15l oil, there was still some splashing. Especially driving uphill.
To get around this problem once and for all, I have made an even larger chamber (3) holding a fair amount of oil that allows a slight overfilling to ensure I have always enough oil.
The thread size is M14x1.5.
-
Neutral switch for CJ750 / M72
The CJ750 / M72 motorcycle does not have a neutral indicator. With a simple switch extension to the gearbox lever you can add a neutral indicator.
It starts with the switch plate that gets attached to the gearbox lever cut out from stainless steel.
Now with the parts fabricated, the switch holder gets attached to the gearbox.
You can use any ball switch for automotive purpose.
The neutral lamp is added to a simple mini dashboard, that also contains the high beam and oil lamp.
