-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
372 additions
and
41 deletions.
There are no files selected for viewing
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using System; | ||
using System.IO; | ||
using SkiaSharp; | ||
using SkiaSharp.Views.Forms; | ||
using Xamarin.Forms; | ||
using SKSvg = SkiaSharp.Extended.Svg.SKSvg; | ||
|
||
namespace KentekenShit | ||
{ | ||
public class Icon : Frame | ||
{ | ||
#region Private Members | ||
|
||
private readonly SKCanvasView _canvasView = new SKCanvasView(); | ||
|
||
#endregion | ||
|
||
#region Bindable Properties | ||
|
||
#region ResourceId | ||
|
||
public static readonly BindableProperty ResourceIdProperty = BindableProperty.Create( | ||
nameof(ResourceId), typeof(string), typeof(Icon), default(string), propertyChanged: RedrawCanvas); | ||
|
||
public string ResourceId | ||
{ | ||
get => (string)GetValue(ResourceIdProperty); | ||
set => SetValue(ResourceIdProperty, value); | ||
} | ||
|
||
#endregion | ||
|
||
#endregion | ||
|
||
public Icon() | ||
{ | ||
Padding = new Thickness(0); | ||
BackgroundColor = Color.Transparent; | ||
HasShadow = false; | ||
Content = _canvasView; | ||
_canvasView.PaintSurface += CanvasViewOnPaintSurface; | ||
} | ||
|
||
private static void RedrawCanvas(BindableObject bindable, object oldvalue, object newvalue) | ||
{ | ||
Icon svgIcon = bindable as Icon; | ||
svgIcon?._canvasView.InvalidateSurface(); | ||
} | ||
|
||
private void CanvasViewOnPaintSurface(object sender, SKPaintSurfaceEventArgs args) | ||
{ | ||
SKCanvas canvas = args.Surface.Canvas; | ||
canvas.Clear(); | ||
|
||
if (string.IsNullOrEmpty(ResourceId)) | ||
return; | ||
|
||
using (Stream stream = GetType().Assembly.GetManifestResourceStream(ResourceId)) | ||
{ | ||
SKSvg svg = new SKSvg(); | ||
svg.Load(stream); | ||
|
||
SKImageInfo info = args.Info; | ||
canvas.Translate(info.Width / 2f, info.Height / 2f); | ||
|
||
SKRect bounds = svg.ViewBox; | ||
float xRatio = info.Width / bounds.Width; | ||
float yRatio = info.Height / bounds.Height; | ||
|
||
float ratio = Math.Min(xRatio, yRatio); | ||
|
||
canvas.Scale(ratio); | ||
canvas.Translate(-bounds.MidX, -bounds.MidY); | ||
|
||
canvas.DrawPicture(svg.Picture); | ||
} | ||
} | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,24 @@ | ||
using System; | ||
using SQLite; | ||
using System; | ||
|
||
namespace KentekenShit.Models | ||
{ | ||
public class Item | ||
{ | ||
[PrimaryKey, AutoIncrement] | ||
public string Id { get; set; } | ||
public string Text { get; set; } | ||
public string Description { get; set; } | ||
|
||
public string Plate { get; set; } | ||
public string Make { get; set; } | ||
public string Seets { get; set; } | ||
public string Cylinders { get; set; } | ||
public string Doors { get; set; } | ||
public string Wheels { get; set; } | ||
public string Price { get; set; } | ||
public string TaxiSign { get; set; } | ||
|
||
public bool InFavoirites { get; set; } | ||
} | ||
} |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System; | ||
using System.Collections.ObjectModel; | ||
using System.Diagnostics; | ||
using System.Threading.Tasks; | ||
|
||
using Xamarin.Forms; | ||
|
||
using KentekenShit.Models; | ||
using KentekenShit.Views; | ||
|
||
namespace KentekenShit.ViewModels | ||
{ | ||
public class HistoryViewModel : BaseViewModel | ||
{ | ||
public ObservableCollection<Item> Items { get; set; } | ||
public Command LoadItemsCommand { get; set; } | ||
|
||
public HistoryViewModel() | ||
{ | ||
Title = "History"; | ||
Items = new ObservableCollection<Item>(); | ||
LoadItemsCommand = new Command(async () => await ExecuteLoadItemsCommand()); | ||
|
||
MessagingCenter.Subscribe<NewItemPage, Item>(this, "AddItem", async (obj, item) => | ||
{ | ||
var newItem = item as Item; | ||
Items.Add(newItem); | ||
await DataStore.AddItemAsync(newItem); | ||
}); | ||
} | ||
|
||
async Task ExecuteLoadItemsCommand() | ||
{ | ||
if (IsBusy) | ||
return; | ||
|
||
IsBusy = true; | ||
|
||
try | ||
{ | ||
Items.Clear(); | ||
var items = await DataStore.GetItemsAsync(true); | ||
foreach (var item in items) | ||
{ | ||
Items.Add(item); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
Debug.WriteLine(ex); | ||
} | ||
finally | ||
{ | ||
IsBusy = false; | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.