Code clean up
This commit is contained in:
+3
-4
@@ -1,15 +1,14 @@
|
|||||||
|
using System.Linq;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
using Avalonia.Data.Core;
|
|
||||||
using Avalonia.Data.Core.Plugins;
|
using Avalonia.Data.Core.Plugins;
|
||||||
using System.Linq;
|
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
using GazpromApp.ViewModels;
|
using GazpromApp.ViewModels;
|
||||||
using GazpromApp.Views;
|
using GazpromApp.Views;
|
||||||
|
|
||||||
namespace GazpromApp;
|
namespace GazpromApp;
|
||||||
|
|
||||||
public partial class App : Application
|
public class App : Application
|
||||||
{
|
{
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -25,7 +24,7 @@ public partial class App : Application
|
|||||||
DisableAvaloniaDataAnnotationValidation();
|
DisableAvaloniaDataAnnotationValidation();
|
||||||
desktop.MainWindow = new MainWindow
|
desktop.MainWindow = new MainWindow
|
||||||
{
|
{
|
||||||
DataContext = new MainWindowViewModel(),
|
DataContext = new MainWindowViewModel()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using GazpromApp.ViewModels;
|
using CommunityToolkit.Mvvm.Messaging.Messages;
|
||||||
using CommunityToolkit.Mvvm.Messaging.Messages;
|
using GazpromApp.ViewModels;
|
||||||
|
|
||||||
namespace GazpromApp.Messages;
|
namespace GazpromApp.Messages;
|
||||||
|
|
||||||
public class NewPointMessage : AsyncRequestMessage<PointViewModel?>;
|
public class NewPointMessage : AsyncRequestMessage<PointViewModel?>;
|
||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace GazpromApp.Models;
|
namespace GazpromApp.Models;
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ public class Equipment
|
|||||||
|
|
||||||
// EF stuff
|
// EF stuff
|
||||||
public Image? Image { get; set; }
|
public Image? Image { get; set; }
|
||||||
public Models.Point? Point { get; set; }
|
public Point? Point { get; set; }
|
||||||
public List<Property> Properties { get; set; } = [];
|
public List<Property> Properties { get; set; } = [];
|
||||||
public List<Inspection> Inspections { get; set; } = [];
|
public List<Inspection> Inspections { get; set; } = [];
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using GazpromApp.Enums;
|
using GazpromApp.Enums;
|
||||||
using GazpromApp.ViewModels;
|
|
||||||
|
|
||||||
namespace GazpromApp.Models;
|
namespace GazpromApp.Models;
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,9 @@ public class Inspection
|
|||||||
public string PeriodType { get; set; } = string.Empty;
|
public string PeriodType { get; set; } = string.Empty;
|
||||||
[Required]
|
[Required]
|
||||||
public float PeriodValue { get; set; }
|
public float PeriodValue { get; set; }
|
||||||
|
|
||||||
public int EquipmentId { get; set; }
|
public int EquipmentId { get; set; }
|
||||||
|
|
||||||
// EF stuff
|
// EF stuff
|
||||||
public Equipment? Equipment { get; set; }
|
public Equipment? Equipment { get; } = new();
|
||||||
}
|
}
|
||||||
+2
-2
@@ -14,9 +14,9 @@ public class Point
|
|||||||
[Required]
|
[Required]
|
||||||
public string? Description { get; set; } = string.Empty;
|
public string? Description { get; set; } = string.Empty;
|
||||||
[Required]
|
[Required]
|
||||||
public double Latitude { get; set; } = 0;
|
public double Latitude { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public double Longitude { get; set; } = 0;
|
public double Longitude { get; set; }
|
||||||
// EF stuff
|
// EF stuff
|
||||||
public List<Image> Images { get; set; } = [];
|
public List<Image> Images { get; set; } = [];
|
||||||
public List<Equipment> Equipment { get; set; } = [];
|
public List<Equipment> Equipment { get; set; } = [];
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace GazpromApp.Models;
|
namespace GazpromApp.Models;
|
||||||
|
|
||||||
public class Property
|
public class Property
|
||||||
@@ -15,6 +16,6 @@ public class Property
|
|||||||
// EF stuff
|
// EF stuff
|
||||||
public Property? Parent { get; set; }
|
public Property? Parent { get; set; }
|
||||||
public List<Property> Properties{ get; set; } = [];
|
public List<Property> Properties{ get; set; } = [];
|
||||||
public List<Models.Point> Points { get; set; } = [];
|
public List<Point> Points { get; set; } = [];
|
||||||
public List<Equipment> Equipment { get; } = [];
|
public List<Equipment> Equipment { get; } = [];
|
||||||
}
|
}
|
||||||
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
using Avalonia;
|
using System;
|
||||||
using System;
|
using Avalonia;
|
||||||
|
|
||||||
namespace GazpromApp;
|
namespace GazpromApp;
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@ sealed class Program
|
|||||||
{
|
{
|
||||||
// Initialization code. Don't use any Avalonia, third-party APIs or any
|
// Initialization code. Don't use any Avalonia, third-party APIs or any
|
||||||
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
|
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
|
||||||
// yet and stuff might break.
|
// yet, and stuff might break.
|
||||||
[STAThread]
|
[STAThread]
|
||||||
public static void Main(string[] args) => BuildAvaloniaApp()
|
public static void Main(string[] args) => BuildAvaloniaApp()
|
||||||
.StartWithClassicDesktopLifetime(args);
|
.StartWithClassicDesktopLifetime(args);
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using GazpromApp.Models;
|
||||||
using GazpromApp.Models;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace GazpromApp.Utils;
|
namespace GazpromApp.Utils;
|
||||||
|
|
||||||
public class AppDbContext : DbContext
|
public class AppDbContext : DbContext
|
||||||
{
|
{
|
||||||
public DbSet<Models.Image> Image { get; set; }
|
public DbSet<Image> Image { get; set; }
|
||||||
public DbSet<Equipment> Equipment { get; set; }
|
public DbSet<Equipment> Equipment { get; set; }
|
||||||
public DbSet<Models.Point> Point { get; set; }
|
public DbSet<Point> Point { get; set; }
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
{
|
{
|
||||||
@@ -20,7 +20,7 @@ public class AppDbContext : DbContext
|
|||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
|
|
||||||
// Images
|
// Images
|
||||||
modelBuilder.Entity<Models.Point>()
|
modelBuilder.Entity<Point>()
|
||||||
.HasMany(e => e.Images)
|
.HasMany(e => e.Images)
|
||||||
.WithMany(e => e.Points);
|
.WithMany(e => e.Points);
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ public class AppDbContext : DbContext
|
|||||||
.HasForeignKey(e => e.ImageId);
|
.HasForeignKey(e => e.ImageId);
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
modelBuilder.Entity<Models.Point>()
|
modelBuilder.Entity<Point>()
|
||||||
.HasMany(e => e.Properties)
|
.HasMany(e => e.Properties)
|
||||||
.WithMany(e => e.Points);
|
.WithMany(e => e.Points);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using GazpromApp.Enums;
|
using GazpromApp.Enums;
|
||||||
using GazpromApp.Models;
|
|
||||||
using GazpromApp.ViewModels;
|
using GazpromApp.ViewModels;
|
||||||
|
|
||||||
namespace GazpromApp.Utils;
|
namespace GazpromApp.Utils;
|
||||||
@@ -19,11 +18,11 @@ public static class DateCalculator
|
|||||||
return [inspection.InspectionDate.DateTime, firstFutureDate];
|
return [inspection.InspectionDate.DateTime, firstFutureDate];
|
||||||
}
|
}
|
||||||
|
|
||||||
DateTime futureDate = Enumerable.Range(1, int.MaxValue)
|
var futureDate = Enumerable.Range(1, int.MaxValue)
|
||||||
.Select(i => AddPeriod(inspection.InspectionDate.DateTime, inspection.PeriodType, inspection.PeriodValue * i))
|
.Select(i => AddPeriod(inspection.InspectionDate.DateTime, inspection.PeriodType, inspection.PeriodValue * i))
|
||||||
.First(d => d > today);
|
.First(d => d > today);
|
||||||
|
|
||||||
DateTime pastDate = SubtractPeriod(futureDate, inspection.PeriodType, inspection.PeriodValue);
|
var pastDate = SubtractPeriod(futureDate, inspection.PeriodType, inspection.PeriodValue);
|
||||||
|
|
||||||
return [pastDate, futureDate];
|
return [pastDate, futureDate];
|
||||||
}
|
}
|
||||||
@@ -36,6 +35,7 @@ public static class DateCalculator
|
|||||||
PeriodType.Week => date.AddDays(value * 7),
|
PeriodType.Week => date.AddDays(value * 7),
|
||||||
PeriodType.Month => date.AddDays(value * 30.436875), // Avg days/month
|
PeriodType.Month => date.AddDays(value * 30.436875), // Avg days/month
|
||||||
PeriodType.Year => date.AddDays(value * 365.2425), // Avg days/year (incl. leap years)
|
PeriodType.Year => date.AddDays(value * 365.2425), // Avg days/year (incl. leap years)
|
||||||
|
PeriodType.Unknown => throw new ArgumentException("Invalid period type"),
|
||||||
_ => throw new ArgumentException("Invalid period type")
|
_ => throw new ArgumentException("Invalid period type")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
@@ -43,7 +42,7 @@ public partial class EquipmentViewModel : ViewModelBase
|
|||||||
Image = new ImageViewModel(equipment.Image ?? new Image());
|
Image = new ImageViewModel(equipment.Image ?? new Image());
|
||||||
Properties = new ObservableCollection<PropertyViewModel>(equipment.Properties.Select(e => new PropertyViewModel(e)));
|
Properties = new ObservableCollection<PropertyViewModel>(equipment.Properties.Select(e => new PropertyViewModel(e)));
|
||||||
|
|
||||||
List<DateTime[]> times = (equipment.Inspections.Select(e => new InspectionViewModel(e)))
|
var times = equipment.Inspections.Select(e => new InspectionViewModel(e))
|
||||||
.Select(e => e.GetNearestDates())
|
.Select(e => e.GetNearestDates())
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
@@ -62,12 +61,12 @@ public partial class EquipmentViewModel : ViewModelBase
|
|||||||
|
|
||||||
public Equipment GetEquipment()
|
public Equipment GetEquipment()
|
||||||
{
|
{
|
||||||
return new Equipment()
|
return new Equipment
|
||||||
{
|
{
|
||||||
Name = Name,
|
Name = Name,
|
||||||
Description = Description,
|
Description = Description,
|
||||||
Image = Image?.GetImage(),
|
Image = Image?.GetImage(),
|
||||||
Inspections = Inspections.Select(e => e.GetInspection()).ToList(),
|
Inspections = Inspections.Select(e => e.GetInspection()).ToList()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,7 @@ public partial class ErrorViewModel : ViewModelBase
|
|||||||
w.Close();
|
w.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ErrorSeverity severity;
|
private readonly ErrorSeverity _severity;
|
||||||
|
|
||||||
// Visual and other properties
|
// Visual and other properties
|
||||||
[ObservableProperty] private bool _isErrorVisible;
|
[ObservableProperty] private bool _isErrorVisible;
|
||||||
@@ -38,7 +38,7 @@ public partial class ErrorViewModel : ViewModelBase
|
|||||||
{
|
{
|
||||||
Title = error.Title;
|
Title = error.Title;
|
||||||
Message = error.Message;
|
Message = error.Message;
|
||||||
severity = error.Severity;
|
_severity = error.Severity;
|
||||||
switch (error.Severity)
|
switch (error.Severity)
|
||||||
{
|
{
|
||||||
case ErrorSeverity.Error:
|
case ErrorSeverity.Error:
|
||||||
@@ -48,21 +48,20 @@ public partial class ErrorViewModel : ViewModelBase
|
|||||||
IsWarnVisible = true;
|
IsWarnVisible = true;
|
||||||
break;
|
break;
|
||||||
case ErrorSeverity.Message:
|
case ErrorSeverity.Message:
|
||||||
IsInfoVisible = true;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
IsInfoVisible = true;
|
IsInfoVisible = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReSharper disable once UnusedMember.Global
|
||||||
public Error GetError()
|
public Error GetError()
|
||||||
{
|
{
|
||||||
Error error = new Error()
|
var error = new Error
|
||||||
{
|
{
|
||||||
Title = Title,
|
Title = Title,
|
||||||
Message = Message,
|
Message = Message,
|
||||||
Severity = severity,
|
Severity = _severity
|
||||||
};
|
};
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,13 +35,13 @@ public partial class ImageViewModel : ViewModelBase
|
|||||||
|
|
||||||
public Image GetImage()
|
public Image GetImage()
|
||||||
{
|
{
|
||||||
MemoryStream ms = new MemoryStream();
|
var ms = new MemoryStream();
|
||||||
FileName?.Save(ms);
|
FileName?.Save(ms);
|
||||||
return new Image()
|
return new Image
|
||||||
{
|
{
|
||||||
Bytes = ms.ToArray(),
|
Bytes = ms.ToArray(),
|
||||||
Equipment = Equipment ?? [],
|
Equipment = Equipment ?? [],
|
||||||
Points = Points ?? [],
|
Points = Points ?? []
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,7 @@ public partial class InspectionViewModel : ViewModelBase
|
|||||||
// Visual properties
|
// Visual properties
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool _isEditing = false;
|
private bool _isEditing;
|
||||||
|
|
||||||
public InspectionViewModel()
|
public InspectionViewModel()
|
||||||
{
|
{
|
||||||
@@ -39,7 +39,7 @@ public partial class InspectionViewModel : ViewModelBase
|
|||||||
|
|
||||||
public Inspection GetInspection()
|
public Inspection GetInspection()
|
||||||
{
|
{
|
||||||
return new Inspection()
|
return new Inspection
|
||||||
{
|
{
|
||||||
Name = Name,
|
Name = Name,
|
||||||
InspectionDate = InspectionDate,
|
InspectionDate = InspectionDate,
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public partial class PointViewModel : ViewModelBase
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private List<Property>? _properties;
|
private List<Property>? _properties;
|
||||||
|
|
||||||
public PointViewModel(Models.Point point)
|
public PointViewModel(Point point)
|
||||||
{
|
{
|
||||||
Name = point.Name;
|
Name = point.Name;
|
||||||
Description = point.Description;
|
Description = point.Description;
|
||||||
@@ -37,14 +37,15 @@ public partial class PointViewModel : ViewModelBase
|
|||||||
Properties = point.Properties;
|
Properties = point.Properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Models.Point GetPoint()
|
// ReSharper disable once UnusedMember.Global
|
||||||
|
public Point GetPoint()
|
||||||
{
|
{
|
||||||
return new Models.Point()
|
return new Point
|
||||||
{
|
{
|
||||||
Name = this.Name,
|
Name = Name,
|
||||||
Description = this.Description,
|
Description = Description,
|
||||||
Equipment = this.Equipment ?? [],
|
Equipment = Equipment ?? [],
|
||||||
Properties = this.Properties ?? [],
|
Properties = Properties ?? []
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
|
||||||
using GazpromApp.Models;
|
using GazpromApp.Models;
|
||||||
|
|
||||||
namespace GazpromApp.ViewModels;
|
namespace GazpromApp.ViewModels;
|
||||||
@@ -26,7 +25,7 @@ public partial class PropertyViewModel : ViewModelBase
|
|||||||
|
|
||||||
public Property GetProperty(Property? parent = null)
|
public Property GetProperty(Property? parent = null)
|
||||||
{
|
{
|
||||||
Property p = new Property
|
var p = new Property
|
||||||
{
|
{
|
||||||
Name = Name,
|
Name = Name,
|
||||||
Value = Value,
|
Value = Value,
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -13,6 +12,7 @@ using CommunityToolkit.Mvvm.Messaging;
|
|||||||
using GazpromApp.Enums;
|
using GazpromApp.Enums;
|
||||||
using GazpromApp.Messages;
|
using GazpromApp.Messages;
|
||||||
using GazpromApp.Models;
|
using GazpromApp.Models;
|
||||||
|
using Image = GazpromApp.Models.Image;
|
||||||
|
|
||||||
namespace GazpromApp.ViewModels;
|
namespace GazpromApp.ViewModels;
|
||||||
|
|
||||||
@@ -54,26 +54,26 @@ public partial class EditEquipmentDialogViewModel : ViewModelBase
|
|||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private async Task AddImage(Window w)
|
private async Task AddImage(Window w)
|
||||||
{
|
{
|
||||||
IReadOnlyList<IStorageFile> files = await w.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions()
|
var files = await w.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||||
{
|
{
|
||||||
AllowMultiple = false,
|
AllowMultiple = false,
|
||||||
Title = "Выберите картинку",
|
Title = "Выберите картинку",
|
||||||
FileTypeFilter = [FilePickerFileTypes.ImageAll],
|
FileTypeFilter = [FilePickerFileTypes.ImageAll]
|
||||||
});
|
});
|
||||||
|
|
||||||
IsImageSelected = files.Count > 0;
|
IsImageSelected = files.Count > 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Image = IsImageSelected ? new ImageViewModel(new Models.Image()) { FileName = new Bitmap(HttpUtility.UrlDecode(files[0].Path.AbsolutePath)) } : null;
|
Image = IsImageSelected ? new ImageViewModel(new Image()) { FileName = new Bitmap(HttpUtility.UrlDecode(files[0].Path.AbsolutePath)) } : null;
|
||||||
}
|
}
|
||||||
catch (ArgumentException)
|
catch (ArgumentException)
|
||||||
{
|
{
|
||||||
Error error = new Error()
|
var error = new Error
|
||||||
{
|
{
|
||||||
Title = "Ошибка обработки картинки",
|
Title = "Ошибка обработки картинки",
|
||||||
Message = "Картинка не была добавлена",
|
Message = "Картинка не была добавлена",
|
||||||
Severity = ErrorSeverity.Error,
|
Severity = ErrorSeverity.Error
|
||||||
};
|
};
|
||||||
_ = await WeakReferenceMessenger.Default.Send(new ErrorMessage(new ErrorViewModel(error)));
|
_ = await WeakReferenceMessenger.Default.Send(new ErrorMessage(new ErrorViewModel(error)));
|
||||||
|
|
||||||
@@ -142,13 +142,13 @@ public partial class EditEquipmentDialogViewModel : ViewModelBase
|
|||||||
private void CompleteEdit()
|
private void CompleteEdit()
|
||||||
{
|
{
|
||||||
IsClosed = true;
|
IsClosed = true;
|
||||||
Equipment equipment = new Equipment
|
var equipment = new Equipment
|
||||||
{
|
{
|
||||||
Name = Name,
|
Name = Name,
|
||||||
Description = Description,
|
Description = Description,
|
||||||
Image = Image?.GetImage(),
|
Image = Image?.GetImage(),
|
||||||
Inspections = Inspections.Select(e => e.GetInspection()).ToList(),
|
Inspections = Inspections.Select(e => e.GetInspection()).ToList(),
|
||||||
Properties = Properties.Select(e => e.GetProperty()).ToList(),
|
Properties = Properties.Select(e => e.GetProperty()).ToList()
|
||||||
};
|
};
|
||||||
WeakReferenceMessenger.Default.Send(new EditEquipmentDone(new EquipmentViewModel(equipment)));
|
WeakReferenceMessenger.Default.Send(new EditEquipmentDone(new EquipmentViewModel(equipment)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
@@ -14,7 +12,6 @@ using CommunityToolkit.Mvvm.Messaging;
|
|||||||
using GazpromApp.Enums;
|
using GazpromApp.Enums;
|
||||||
using GazpromApp.Messages;
|
using GazpromApp.Messages;
|
||||||
using GazpromApp.Models;
|
using GazpromApp.Models;
|
||||||
using GazpromApp.Views;
|
|
||||||
using Image = GazpromApp.Models.Image;
|
using Image = GazpromApp.Models.Image;
|
||||||
|
|
||||||
namespace GazpromApp.ViewModels;
|
namespace GazpromApp.ViewModels;
|
||||||
@@ -54,11 +51,11 @@ public partial class EditPointDialogViewModel : ViewModelBase
|
|||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private async Task AddImage(Window w)
|
private async Task AddImage(Window w)
|
||||||
{
|
{
|
||||||
IReadOnlyList<IStorageFile> files = await w.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions()
|
var files = await w.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||||
{
|
{
|
||||||
AllowMultiple = true,
|
AllowMultiple = true,
|
||||||
Title = "Выберите одну или несколько картинок",
|
Title = "Выберите одну или несколько картинок",
|
||||||
FileTypeFilter = [FilePickerFileTypes.ImageAll],
|
FileTypeFilter = [FilePickerFileTypes.ImageAll]
|
||||||
});
|
});
|
||||||
foreach (var file in files)
|
foreach (var file in files)
|
||||||
{
|
{
|
||||||
@@ -68,11 +65,11 @@ public partial class EditPointDialogViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
catch (ArgumentException)
|
catch (ArgumentException)
|
||||||
{
|
{
|
||||||
Error error = new Error()
|
var error = new Error
|
||||||
{
|
{
|
||||||
Title = "Ошибка обработки картинки",
|
Title = "Ошибка обработки картинки",
|
||||||
Message = $"Картинка не была добавлена: \"{HttpUtility.UrlDecode(file.Name)}\"",
|
Message = $"Картинка не была добавлена: \"{HttpUtility.UrlDecode(file.Name)}\"",
|
||||||
Severity = ErrorSeverity.Error,
|
Severity = ErrorSeverity.Error
|
||||||
};
|
};
|
||||||
_ = await WeakReferenceMessenger.Default.Send(new ErrorMessage(new ErrorViewModel(error)));
|
_ = await WeakReferenceMessenger.Default.Send(new ErrorMessage(new ErrorViewModel(error)));
|
||||||
}
|
}
|
||||||
@@ -96,7 +93,7 @@ public partial class EditPointDialogViewModel : ViewModelBase
|
|||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private async Task AddEquipment()
|
private async Task AddEquipment()
|
||||||
{
|
{
|
||||||
EquipmentViewModel? equipment = await WeakReferenceMessenger.Default.Send(new NewEquipmentMessage());
|
var equipment = await WeakReferenceMessenger.Default.Send(new NewEquipmentMessage());
|
||||||
|
|
||||||
if (equipment != null)
|
if (equipment != null)
|
||||||
Equipment.Add(equipment);
|
Equipment.Add(equipment);
|
||||||
@@ -107,7 +104,7 @@ public partial class EditPointDialogViewModel : ViewModelBase
|
|||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private async Task EditEquipment(EquipmentViewModel equipment)
|
private async Task EditEquipment(EquipmentViewModel equipment)
|
||||||
{
|
{
|
||||||
EquipmentViewModel e = await WeakReferenceMessenger.Default.Send(new EditEquipmentMessage(equipment)) ?? equipment;
|
var e = await WeakReferenceMessenger.Default.Send(new EditEquipmentMessage(equipment)) ?? equipment;
|
||||||
Equipment[Equipment.IndexOf(equipment)] = e;
|
Equipment[Equipment.IndexOf(equipment)] = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,13 +142,13 @@ public partial class EditPointDialogViewModel : ViewModelBase
|
|||||||
private void CompleteEdit()
|
private void CompleteEdit()
|
||||||
{
|
{
|
||||||
IsClosed = true;
|
IsClosed = true;
|
||||||
Point point = new Point()
|
var point = new Point
|
||||||
{
|
{
|
||||||
Name = Name,
|
Name = Name,
|
||||||
Description = Description,
|
Description = Description,
|
||||||
Images = Images.Select(e => e.GetImage()).ToList(),
|
Images = Images.Select(e => e.GetImage()).ToList(),
|
||||||
Equipment = Equipment.Select(e => e.GetEquipment()).ToList(),
|
Equipment = Equipment.Select(e => e.GetEquipment()).ToList(),
|
||||||
Properties = Properties.Select(e => e.GetProperty()).ToList(),
|
Properties = Properties.Select(e => e.GetProperty()).ToList()
|
||||||
};
|
};
|
||||||
WeakReferenceMessenger.Default.Send(new EditPointDone(new PointViewModel(point)));
|
WeakReferenceMessenger.Default.Send(new EditPointDone(new PointViewModel(point)));
|
||||||
}
|
}
|
||||||
@@ -234,8 +231,8 @@ public partial class EditPointDialogViewModel : ViewModelBase
|
|||||||
Value = "Property Value",
|
Value = "Property Value",
|
||||||
Properties = [],
|
Properties = [],
|
||||||
Parent = null
|
Parent = null
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
Parent = null
|
Parent = null
|
||||||
},
|
},
|
||||||
new PropertyViewModel
|
new PropertyViewModel
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using System.Collections.ObjectModel;
|
||||||
using GazpromApp.Messages;
|
|
||||||
using CommunityToolkit.Mvvm.Input;
|
|
||||||
using CommunityToolkit.Mvvm.Messaging;
|
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
using CommunityToolkit.Mvvm.Messaging;
|
||||||
|
using GazpromApp.Messages;
|
||||||
using GazpromApp.Models;
|
using GazpromApp.Models;
|
||||||
|
|
||||||
namespace GazpromApp.ViewModels;
|
namespace GazpromApp.ViewModels;
|
||||||
@@ -16,7 +16,7 @@ public partial class MainWindowViewModel : ViewModelBase
|
|||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private async Task AddPoint()
|
private async Task AddPoint()
|
||||||
{
|
{
|
||||||
PointViewModel? point = await WeakReferenceMessenger.Default.Send(new NewPointMessage());
|
var point = await WeakReferenceMessenger.Default.Send(new NewPointMessage());
|
||||||
|
|
||||||
if (point != null)
|
if (point != null)
|
||||||
Points.Add(point);
|
Points.Add(point);
|
||||||
@@ -27,7 +27,7 @@ public partial class MainWindowViewModel : ViewModelBase
|
|||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private async Task EditPoint(PointViewModel point)
|
private async Task EditPoint(PointViewModel point)
|
||||||
{
|
{
|
||||||
PointViewModel p = await WeakReferenceMessenger.Default.Send(new EditPointMessage(point)) ?? point;
|
var p = await WeakReferenceMessenger.Default.Send(new EditPointMessage(point)) ?? point;
|
||||||
Points[Points.IndexOf(point)] = p;
|
Points[Points.IndexOf(point)] = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
@@ -11,6 +10,7 @@ using CommunityToolkit.Mvvm.Messaging;
|
|||||||
using GazpromApp.Enums;
|
using GazpromApp.Enums;
|
||||||
using GazpromApp.Messages;
|
using GazpromApp.Messages;
|
||||||
using GazpromApp.Models;
|
using GazpromApp.Models;
|
||||||
|
using Image = GazpromApp.Models.Image;
|
||||||
|
|
||||||
namespace GazpromApp.ViewModels;
|
namespace GazpromApp.ViewModels;
|
||||||
|
|
||||||
@@ -30,26 +30,26 @@ public partial class NewEquipmentDialogViewModel : ViewModelBase
|
|||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private async Task AddImage(Window w)
|
private async Task AddImage(Window w)
|
||||||
{
|
{
|
||||||
IReadOnlyList<IStorageFile> files = await w.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions()
|
var files = await w.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||||
{
|
{
|
||||||
AllowMultiple = false,
|
AllowMultiple = false,
|
||||||
Title = "Выберите картинку",
|
Title = "Выберите картинку",
|
||||||
FileTypeFilter = [FilePickerFileTypes.ImageAll],
|
FileTypeFilter = [FilePickerFileTypes.ImageAll]
|
||||||
});
|
});
|
||||||
|
|
||||||
IsImageSelected = files.Count > 0;
|
IsImageSelected = files.Count > 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Image = IsImageSelected ? new ImageViewModel(new Models.Image()) { FileName = new Bitmap(HttpUtility.UrlDecode(files[0].Path.AbsolutePath)) } : null;
|
Image = IsImageSelected ? new ImageViewModel(new Image()) { FileName = new Bitmap(HttpUtility.UrlDecode(files[0].Path.AbsolutePath)) } : null;
|
||||||
}
|
}
|
||||||
catch (ArgumentException)
|
catch (ArgumentException)
|
||||||
{
|
{
|
||||||
Error error = new Error()
|
var error = new Error
|
||||||
{
|
{
|
||||||
Title = "Ошибка обработки картинки",
|
Title = "Ошибка обработки картинки",
|
||||||
Message = "Картинка не была добавлена",
|
Message = "Картинка не была добавлена",
|
||||||
Severity = ErrorSeverity.Error,
|
Severity = ErrorSeverity.Error
|
||||||
};
|
};
|
||||||
_ = await WeakReferenceMessenger.Default.Send(new ErrorMessage(new ErrorViewModel(error)));
|
_ = await WeakReferenceMessenger.Default.Send(new ErrorMessage(new ErrorViewModel(error)));
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ public partial class NewEquipmentDialogViewModel : ViewModelBase
|
|||||||
[RelayCommand (CanExecute = nameof(CanEnterEquipment))]
|
[RelayCommand (CanExecute = nameof(CanEnterEquipment))]
|
||||||
private void EnterEquipment()
|
private void EnterEquipment()
|
||||||
{
|
{
|
||||||
Equipment equipment = new Equipment()
|
var equipment = new Equipment
|
||||||
{
|
{
|
||||||
Name = Name,
|
Name = Name,
|
||||||
Description = Description ?? string.Empty,
|
Description = Description ?? string.Empty,
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
@@ -34,11 +32,11 @@ public partial class NewPointDialogViewModel : ViewModelBase
|
|||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private async Task AddImage(Window w)
|
private async Task AddImage(Window w)
|
||||||
{
|
{
|
||||||
IReadOnlyList<IStorageFile> files = await w.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions()
|
var files = await w.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||||
{
|
{
|
||||||
AllowMultiple = true,
|
AllowMultiple = true,
|
||||||
Title = "Выберите одну или несколько картинок",
|
Title = "Выберите одну или несколько картинок",
|
||||||
FileTypeFilter = [FilePickerFileTypes.ImageAll],
|
FileTypeFilter = [FilePickerFileTypes.ImageAll]
|
||||||
});
|
});
|
||||||
foreach (var file in files)
|
foreach (var file in files)
|
||||||
{
|
{
|
||||||
@@ -48,11 +46,11 @@ public partial class NewPointDialogViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
catch (ArgumentException)
|
catch (ArgumentException)
|
||||||
{
|
{
|
||||||
Error error = new Error()
|
var error = new Error
|
||||||
{
|
{
|
||||||
Title = "Ошибка обработки картинки",
|
Title = "Ошибка обработки картинки",
|
||||||
Message = $"Картинка не была добавлена: \"{HttpUtility.UrlDecode(file.Name)}\"",
|
Message = $"Картинка не была добавлена: \"{HttpUtility.UrlDecode(file.Name)}\"",
|
||||||
Severity = ErrorSeverity.Error,
|
Severity = ErrorSeverity.Error
|
||||||
};
|
};
|
||||||
_ = await WeakReferenceMessenger.Default.Send(new ErrorMessage(new ErrorViewModel(error)));
|
_ = await WeakReferenceMessenger.Default.Send(new ErrorMessage(new ErrorViewModel(error)));
|
||||||
}
|
}
|
||||||
@@ -73,7 +71,7 @@ public partial class NewPointDialogViewModel : ViewModelBase
|
|||||||
[RelayCommand (CanExecute = nameof(CanEnterPoint))]
|
[RelayCommand (CanExecute = nameof(CanEnterPoint))]
|
||||||
private void EnterPoint()
|
private void EnterPoint()
|
||||||
{
|
{
|
||||||
Point point = new Point()
|
var point = new Point
|
||||||
{
|
{
|
||||||
Name = Name,
|
Name = Name,
|
||||||
Description = Description,
|
Description = Description,
|
||||||
|
|||||||
@@ -2,6 +2,4 @@
|
|||||||
|
|
||||||
namespace GazpromApp.ViewModels;
|
namespace GazpromApp.ViewModels;
|
||||||
|
|
||||||
public class ViewModelBase : ObservableObject
|
public class ViewModelBase : ObservableObject;
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
<vm:EditEquipmentDialogViewModel/>
|
<vm:EditEquipmentDialogViewModel/>
|
||||||
</Design.DataContext>
|
</Design.DataContext>
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
<!-- ReSharper disable once Xaml.RedundantResource -->
|
<!-- ReSharper disable Xaml.RedundantResource -->
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<ResourceDictionary.ThemeDictionaries>
|
<ResourceDictionary.ThemeDictionaries>
|
||||||
<ResourceDictionary x:Key="Light">
|
<ResourceDictionary x:Key="Light">
|
||||||
@@ -31,6 +31,7 @@
|
|||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</ResourceDictionary.ThemeDictionaries>
|
</ResourceDictionary.ThemeDictionaries>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
|
<!-- ReSharper restore Xaml.RedundantResource -->
|
||||||
<enums:PeriodConverter x:Key="PeriodConverter"/>
|
<enums:PeriodConverter x:Key="PeriodConverter"/>
|
||||||
</Window.Resources>
|
</Window.Resources>
|
||||||
<Grid RowDefinitions="70,150,*,Auto" ColumnDefinitions="*,100,220" x:Name="Root">
|
<Grid RowDefinitions="70,150,*,Auto" ColumnDefinitions="*,100,220" x:Name="Root">
|
||||||
@@ -116,7 +117,7 @@
|
|||||||
<NumericUpDown Grid.Column="3" AllowSpin="True" Width="120" VerticalAlignment="Center"
|
<NumericUpDown Grid.Column="3" AllowSpin="True" Width="120" VerticalAlignment="Center"
|
||||||
Value="{Binding PeriodValue}"/>
|
Value="{Binding PeriodValue}"/>
|
||||||
<ComboBox Grid.Column="4" Width="100" VerticalAlignment="Center" Margin="4,0,0,0"
|
<ComboBox Grid.Column="4" Width="100" VerticalAlignment="Center" Margin="4,0,0,0"
|
||||||
ItemsSource="{Binding #Root.((vm:EditEquipmentDialogViewModel)DataContext).AllPeriods}"
|
ItemsSource="{Binding (vm:EditEquipmentDialogViewModel).AllPeriods}"
|
||||||
SelectedItem="{Binding PeriodType, Mode=TwoWay}"
|
SelectedItem="{Binding PeriodType, Mode=TwoWay}"
|
||||||
DisplayMemberBinding="{Binding ., Converter={StaticResource PeriodConverter}}"/>
|
DisplayMemberBinding="{Binding ., Converter={StaticResource PeriodConverter}}"/>
|
||||||
<Button Grid.Column="5" Margin="0,0,12,0" HorizontalAlignment="Right" VerticalAlignment="Center"
|
<Button Grid.Column="5" Margin="0,0,12,0" HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||||
|
|||||||
@@ -1,18 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using CommunityToolkit.Mvvm.Messaging;
|
using CommunityToolkit.Mvvm.Messaging;
|
||||||
using GazpromApp.Messages;
|
using GazpromApp.Messages;
|
||||||
using GazpromApp.Models;
|
|
||||||
using GazpromApp.ViewModels;
|
using GazpromApp.ViewModels;
|
||||||
|
|
||||||
namespace GazpromApp.Views;
|
namespace GazpromApp.Views;
|
||||||
|
|
||||||
public partial class EditEquipmentDialog : Window
|
public partial class EditEquipmentDialog : Window
|
||||||
{
|
{
|
||||||
public Equipment? Equipment;
|
|
||||||
|
|
||||||
public EditEquipmentDialog()
|
public EditEquipmentDialog()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -23,7 +18,7 @@ public partial class EditEquipmentDialog : Window
|
|||||||
// view image
|
// view image
|
||||||
WeakReferenceMessenger.Default.Register<EditEquipmentDialog, ViewImageMessage>(this, static (w, m) =>
|
WeakReferenceMessenger.Default.Register<EditEquipmentDialog, ViewImageMessage>(this, static (w, m) =>
|
||||||
{
|
{
|
||||||
ImageView dialog = new ImageView()
|
var dialog = new ImageView
|
||||||
{
|
{
|
||||||
DataContext = m.Image
|
DataContext = m.Image
|
||||||
};
|
};
|
||||||
@@ -33,7 +28,7 @@ public partial class EditEquipmentDialog : Window
|
|||||||
// error handling
|
// error handling
|
||||||
WeakReferenceMessenger.Default.Register<EditEquipmentDialog, ErrorMessage>(this, static (w, m) =>
|
WeakReferenceMessenger.Default.Register<EditEquipmentDialog, ErrorMessage>(this, static (w, m) =>
|
||||||
{
|
{
|
||||||
ErrorView dialog = new ErrorView()
|
var dialog = new ErrorView
|
||||||
{
|
{
|
||||||
DataContext = m.Error
|
DataContext = m.Error
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -24,7 +24,9 @@
|
|||||||
<SolidColorBrush x:Key="BorderBrush" Color="#d3d3d3"/>
|
<SolidColorBrush x:Key="BorderBrush" Color="#d3d3d3"/>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
<ResourceDictionary x:Key="Dark">
|
<ResourceDictionary x:Key="Dark">
|
||||||
|
<!-- ReSharper disable once Xaml.RedundantResource -->
|
||||||
<SolidColorBrush x:Key="BackgroundBrush" Color="#101010"/>
|
<SolidColorBrush x:Key="BackgroundBrush" Color="#101010"/>
|
||||||
|
<!-- ReSharper disable once Xaml.RedundantResource -->
|
||||||
<SolidColorBrush x:Key="BorderBrush" Color="#303030"/>
|
<SolidColorBrush x:Key="BorderBrush" Color="#303030"/>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</ResourceDictionary.ThemeDictionaries>
|
</ResourceDictionary.ThemeDictionaries>
|
||||||
|
|||||||
@@ -2,15 +2,12 @@
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using CommunityToolkit.Mvvm.Messaging;
|
using CommunityToolkit.Mvvm.Messaging;
|
||||||
using GazpromApp.Messages;
|
using GazpromApp.Messages;
|
||||||
using GazpromApp.Models;
|
|
||||||
using GazpromApp.ViewModels;
|
using GazpromApp.ViewModels;
|
||||||
|
|
||||||
namespace GazpromApp.Views;
|
namespace GazpromApp.Views;
|
||||||
|
|
||||||
public partial class EditPointDialog : Window
|
public partial class EditPointDialog : Window
|
||||||
{
|
{
|
||||||
public Point? Point;
|
|
||||||
|
|
||||||
public EditPointDialog()
|
public EditPointDialog()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -21,7 +18,7 @@ public partial class EditPointDialog : Window
|
|||||||
// view image
|
// view image
|
||||||
WeakReferenceMessenger.Default.Register<EditPointDialog, ViewImageMessage>(this, static (w, m) =>
|
WeakReferenceMessenger.Default.Register<EditPointDialog, ViewImageMessage>(this, static (w, m) =>
|
||||||
{
|
{
|
||||||
ImageView dialog = new ImageView()
|
var dialog = new ImageView
|
||||||
{
|
{
|
||||||
DataContext = m.Image
|
DataContext = m.Image
|
||||||
};
|
};
|
||||||
@@ -31,7 +28,7 @@ public partial class EditPointDialog : Window
|
|||||||
// error
|
// error
|
||||||
WeakReferenceMessenger.Default.Register<EditPointDialog, ErrorMessage>(this, static (w, m) =>
|
WeakReferenceMessenger.Default.Register<EditPointDialog, ErrorMessage>(this, static (w, m) =>
|
||||||
{
|
{
|
||||||
ErrorView dialog = new ErrorView()
|
var dialog = new ErrorView
|
||||||
{
|
{
|
||||||
DataContext = m.Error
|
DataContext = m.Error
|
||||||
};
|
};
|
||||||
@@ -42,7 +39,7 @@ public partial class EditPointDialog : Window
|
|||||||
WeakReferenceMessenger.Default.Register<EditPointDialog, NewEquipmentMessage>(this, (w, m) =>
|
WeakReferenceMessenger.Default.Register<EditPointDialog, NewEquipmentMessage>(this, (w, m) =>
|
||||||
{
|
{
|
||||||
WeakReferenceMessenger.Default.Unregister<ErrorMessage>(this);
|
WeakReferenceMessenger.Default.Unregister<ErrorMessage>(this);
|
||||||
NewEquipmentDialog dialog = new NewEquipmentDialog()
|
var dialog = new NewEquipmentDialog
|
||||||
{
|
{
|
||||||
DataContext = new NewEquipmentDialogViewModel()
|
DataContext = new NewEquipmentDialogViewModel()
|
||||||
};
|
};
|
||||||
@@ -54,7 +51,7 @@ public partial class EditPointDialog : Window
|
|||||||
{
|
{
|
||||||
WeakReferenceMessenger.Default.Unregister<ViewImageMessage>(this);
|
WeakReferenceMessenger.Default.Unregister<ViewImageMessage>(this);
|
||||||
WeakReferenceMessenger.Default.Unregister<ErrorMessage>(this);
|
WeakReferenceMessenger.Default.Unregister<ErrorMessage>(this);
|
||||||
EditEquipmentDialog dialog = new EditEquipmentDialog()
|
var dialog = new EditEquipmentDialog
|
||||||
{
|
{
|
||||||
DataContext = new EditEquipmentDialogViewModel(m.Equipment)
|
DataContext = new EditEquipmentDialogViewModel(m.Equipment)
|
||||||
};
|
};
|
||||||
@@ -66,7 +63,7 @@ public partial class EditPointDialog : Window
|
|||||||
{
|
{
|
||||||
WeakReferenceMessenger.Default.Register<EditPointDialog, ErrorMessage>(this, static (w, m) =>
|
WeakReferenceMessenger.Default.Register<EditPointDialog, ErrorMessage>(this, static (w, m) =>
|
||||||
{
|
{
|
||||||
ErrorView dialog = new ErrorView()
|
var dialog = new ErrorView
|
||||||
{
|
{
|
||||||
DataContext = m.Error
|
DataContext = m.Error
|
||||||
};
|
};
|
||||||
@@ -79,7 +76,7 @@ public partial class EditPointDialog : Window
|
|||||||
{
|
{
|
||||||
WeakReferenceMessenger.Default.Register<EditPointDialog, ViewImageMessage>(this, static (w, m) =>
|
WeakReferenceMessenger.Default.Register<EditPointDialog, ViewImageMessage>(this, static (w, m) =>
|
||||||
{
|
{
|
||||||
ImageView dialog = new ImageView()
|
var dialog = new ImageView
|
||||||
{
|
{
|
||||||
DataContext = m.Image
|
DataContext = m.Image
|
||||||
};
|
};
|
||||||
@@ -88,7 +85,7 @@ public partial class EditPointDialog : Window
|
|||||||
|
|
||||||
WeakReferenceMessenger.Default.Register<EditPointDialog, ErrorMessage>(this, static (w, m) =>
|
WeakReferenceMessenger.Default.Register<EditPointDialog, ErrorMessage>(this, static (w, m) =>
|
||||||
{
|
{
|
||||||
ErrorView dialog = new ErrorView()
|
var dialog = new ErrorView
|
||||||
{
|
{
|
||||||
DataContext = m.Error
|
DataContext = m.Error
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
|
|
||||||
namespace GazpromApp.Views;
|
namespace GazpromApp.Views;
|
||||||
|
|
||||||
@@ -11,8 +9,8 @@ public partial class ErrorView : Window
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
if (Design.IsDesignMode)
|
// if (Design.IsDesignMode)
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using Avalonia;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
|
|
||||||
namespace GazpromApp.Views;
|
namespace GazpromApp.Views;
|
||||||
|
|
||||||
@@ -13,6 +11,6 @@ public partial class ImageView : Window
|
|||||||
if (Design.IsDesignMode)
|
if (Design.IsDesignMode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.ExtendClientAreaToDecorationsHint = true;
|
ExtendClientAreaToDecorationsHint = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,9 @@
|
|||||||
<SolidColorBrush x:Key="BorderBrush" Color="#d3d3d3"/>
|
<SolidColorBrush x:Key="BorderBrush" Color="#d3d3d3"/>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
<ResourceDictionary x:Key="Dark">
|
<ResourceDictionary x:Key="Dark">
|
||||||
|
<!-- ReSharper disable once Xaml.RedundantResource -->
|
||||||
<SolidColorBrush x:Key="BackgroundBrush" Color="#101010"/>
|
<SolidColorBrush x:Key="BackgroundBrush" Color="#101010"/>
|
||||||
|
<!-- ReSharper disable once Xaml.RedundantResource -->
|
||||||
<SolidColorBrush x:Key="BorderBrush" Color="#303030"/>
|
<SolidColorBrush x:Key="BorderBrush" Color="#303030"/>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</ResourceDictionary.ThemeDictionaries>
|
</ResourceDictionary.ThemeDictionaries>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
using CommunityToolkit.Mvvm.Messaging;
|
||||||
using GazpromApp.Messages;
|
using GazpromApp.Messages;
|
||||||
using GazpromApp.ViewModels;
|
using GazpromApp.ViewModels;
|
||||||
using CommunityToolkit.Mvvm.Messaging;
|
|
||||||
|
|
||||||
namespace GazpromApp.Views;
|
namespace GazpromApp.Views;
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ public partial class MainWindow : Window
|
|||||||
|
|
||||||
WeakReferenceMessenger.Default.Register<MainWindow, NewPointMessage>(this, static (w, m) =>
|
WeakReferenceMessenger.Default.Register<MainWindow, NewPointMessage>(this, static (w, m) =>
|
||||||
{
|
{
|
||||||
NewPointDialog dialog = new NewPointDialog()
|
var dialog = new NewPointDialog
|
||||||
{
|
{
|
||||||
DataContext = new NewPointDialogViewModel()
|
DataContext = new NewPointDialogViewModel()
|
||||||
};
|
};
|
||||||
@@ -25,10 +25,9 @@ public partial class MainWindow : Window
|
|||||||
|
|
||||||
WeakReferenceMessenger.Default.Register<MainWindow, EditPointMessage>(this, static (w, m) =>
|
WeakReferenceMessenger.Default.Register<MainWindow, EditPointMessage>(this, static (w, m) =>
|
||||||
{
|
{
|
||||||
EditPointDialog dialog = new EditPointDialog()
|
var dialog = new EditPointDialog
|
||||||
{
|
{
|
||||||
DataContext = new EditPointDialogViewModel(m.Point),
|
DataContext = new EditPointDialogViewModel(m.Point)
|
||||||
Point = m.Point.GetPoint()
|
|
||||||
};
|
};
|
||||||
m.Reply(dialog.ShowDialog<PointViewModel?>(w));
|
m.Reply(dialog.ShowDialog<PointViewModel?>(w));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public partial class NewEquipmentDialog : Window
|
|||||||
// register to work with errors
|
// register to work with errors
|
||||||
WeakReferenceMessenger.Default.Register<NewEquipmentDialog, ErrorMessage>(this, static (w, m) =>
|
WeakReferenceMessenger.Default.Register<NewEquipmentDialog, ErrorMessage>(this, static (w, m) =>
|
||||||
{
|
{
|
||||||
ErrorView dialog = new ErrorView()
|
var dialog = new ErrorView
|
||||||
{
|
{
|
||||||
DataContext = m.Error
|
DataContext = m.Error
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public partial class NewPointDialog : Window
|
|||||||
// register to work with errors
|
// register to work with errors
|
||||||
WeakReferenceMessenger.Default.Register<NewPointDialog, ErrorMessage>(this, static (w, m) =>
|
WeakReferenceMessenger.Default.Register<NewPointDialog, ErrorMessage>(this, static (w, m) =>
|
||||||
{
|
{
|
||||||
ErrorView dialog = new ErrorView()
|
var dialog = new ErrorView
|
||||||
{
|
{
|
||||||
DataContext = m.Error
|
DataContext = m.Error
|
||||||
};
|
};
|
||||||
|
|||||||
Binary file not shown.
@@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("GazpromApp")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("GazpromApp")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+72dc9b68743bc32f202a106f6161f2a4c5401a0c")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+2a8f8d2714fbf16f8b576c0df1cc1439e63924d0")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("GazpromApp")]
|
[assembly: System.Reflection.AssemblyProductAttribute("GazpromApp")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("GazpromApp")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("GazpromApp")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
15ad954b97553ac87ab7a0c39a3000dca500a7ad2febeb4c503529c5bb6ac55b
|
e3eb625a6811d3ba189fee7ab939040462cf2260b099c0651fd6ad4eaff5612d
|
||||||
|
|||||||
Reference in New Issue
Block a user