Добавьте файлы проекта.
This commit is contained in:
208
VM/BoresVM.cs
Normal file
208
VM/BoresVM.cs
Normal file
@@ -0,0 +1,208 @@
|
||||
using Microsoft.Win32;
|
||||
using OfficeOpenXml;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TriangleNet.Geometry;
|
||||
using TriangleNet.Meshing;
|
||||
|
||||
namespace GroundOrganizer
|
||||
{
|
||||
public partial class ViewModel : INotifyPropertyChanged
|
||||
{
|
||||
private RelayCommand addBore;
|
||||
private RelayCommand renumBore;
|
||||
private RelayCommand updateBore;
|
||||
private RelayCommand createBoresMesh;
|
||||
private RelayCommand importBoresFromXLSX;
|
||||
private RelayCommand exportBoresToXLSX;
|
||||
|
||||
int numBore = 1;
|
||||
string nameBore;
|
||||
private string boresNote;
|
||||
Bore selectedBore;
|
||||
ObservableCollection<Bore> listBore = new ObservableCollection<Bore>();
|
||||
public string BoresNote { get => boresNote; set { boresNote = value; OnPropertyChanged(); } }
|
||||
|
||||
public Bore SelectedBore { get => selectedBore; set { selectedBore = value; OnPropertyChanged(); ChangeSelectedBore(); } }
|
||||
|
||||
public string NameBore { get => nameBore; set { nameBore = value; OnPropertyChanged(); } }
|
||||
|
||||
public ObservableCollection<Bore> ListBore { get => listBore; set { listBore = value; OnPropertyChanged(); } }
|
||||
public TriangleNet.Mesh MeshBores { get; private set; }
|
||||
|
||||
|
||||
public RelayCommand AddBore
|
||||
{
|
||||
get { return addBore ?? (addBore = new RelayCommand(obj => { AddBoreToList(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand UpdateBores
|
||||
{
|
||||
get { return updateBore ?? (updateBore = new RelayCommand(obj => { UpdateBoreInList(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand RenumBores
|
||||
{
|
||||
get { return renumBore ?? (renumBore = new RelayCommand(obj => { RenumberingBoreInList(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand CreateBoresMesh
|
||||
{
|
||||
get { return createBoresMesh ?? (createBoresMesh = new RelayCommand(obj => { CreateMeshBores(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand ExportBoresToXLSX
|
||||
{
|
||||
get { return exportBoresToXLSX ?? (exportBoresToXLSX = new RelayCommand(obj => { SaveBoresInXlsx(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand ImportBoresFromXLSX
|
||||
{
|
||||
get { return importBoresFromXLSX ?? (importBoresFromXLSX = new RelayCommand(obj => { ReadBoresFromXlsx(); })); }
|
||||
}
|
||||
|
||||
//Чтение таблицы набора скважин из файла *.xlsx
|
||||
internal void ReadBoresFromXlsx()
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.DefaultExt = "*.xlsx";
|
||||
ofd.Filter = "Файл Excel (*.xlsx)|*.xlsx";
|
||||
ofd.Title = "Заполнение таблицы";
|
||||
ofd.ShowDialog();
|
||||
|
||||
if (ofd.FileName == null || ofd.FileName == "") return;
|
||||
|
||||
//ListIGE.Clear();
|
||||
|
||||
using (var p = new ExcelPackage(new FileInfo(ofd.FileName)))
|
||||
{
|
||||
//A workbook must have at least on cell, so lets add one...
|
||||
var ws = p.Workbook.Worksheets["Скважины"];
|
||||
|
||||
object[,] content = ws.Cells.Value as object[,];
|
||||
List<object> source; Bore item;
|
||||
for (int i = 1; i < content.GetLength(0); i++)
|
||||
{
|
||||
source = new List<object>();
|
||||
for (int j = 0; j < content.GetLength(1); j++)
|
||||
{
|
||||
source.Add(content[i, j]);
|
||||
}
|
||||
item = new Bore(); item.ListToProps(source);
|
||||
ListBore.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Сохранение таблицы набора ИГЭ в файл *.csv
|
||||
internal void SaveBoresInXlsx()
|
||||
{
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.DefaultExt = "*.xlsx";
|
||||
sfd.Filter = "Файл Excel (*.xlsx)|*.xlsx";
|
||||
sfd.Title = "Сохранение таблицы";
|
||||
//sfd.AddExtension = true;
|
||||
sfd.OverwritePrompt = false;
|
||||
sfd.ShowDialog();
|
||||
|
||||
if (sfd.FileName == null || sfd.FileName == "") return;
|
||||
|
||||
string path = "ИГЭ.xlsx";
|
||||
FileInfo fileInf = new FileInfo(path);
|
||||
if (fileInf.Exists != true)
|
||||
{
|
||||
using (FileStream fstream = new FileStream("ИГЭ.xlsx", FileMode.OpenOrCreate))
|
||||
{
|
||||
byte[] array = Properties.Resources.IGE;
|
||||
fstream.Write(array, 0, array.Length);
|
||||
}
|
||||
}
|
||||
List<object[]> content = new List<object[]>();
|
||||
foreach (Bore item in listBore)
|
||||
{
|
||||
content.Add(item.PropsToList().ToArray());
|
||||
}
|
||||
|
||||
using (var p = new ExcelPackage(new FileInfo(sfd.FileName)))
|
||||
{
|
||||
try
|
||||
{
|
||||
var ws = p.Workbook.Worksheets["Скважины"];
|
||||
|
||||
//To set values in the spreadsheet use the Cells indexer.
|
||||
ws.Cells["A2"].LoadFromArrays(content);
|
||||
|
||||
//Save the new workbook. We haven't specified the filename so use the Save as method.
|
||||
p.SaveAs(new FileInfo(sfd.FileName));
|
||||
}
|
||||
catch
|
||||
{
|
||||
ExcelPackage p1 = new ExcelPackage(new FileInfo("ИГЭ.xlsx"));
|
||||
ExcelWorksheet ws1 = p1.Workbook.Worksheets["Скважины"];
|
||||
p.Workbook.Worksheets.Add("Скважины", ws1);
|
||||
ExcelWorksheet ws = p.Workbook.Worksheets["Скважины"];
|
||||
|
||||
//Save the new workbook. We haven't specified the filename so use the Save as method.
|
||||
ws.Cells["A2"].LoadFromArrays(content);
|
||||
ws.Select();
|
||||
p.SaveAs(new FileInfo(sfd.FileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateMeshBores()
|
||||
{
|
||||
if (listBore == null || listBore.Count == 0) return;
|
||||
|
||||
Polygon polygon = new Polygon();
|
||||
Vertex vrtx;
|
||||
int i = 1;
|
||||
foreach (Bore item in listBore)
|
||||
{
|
||||
vrtx = new Vertex(item.X, item.Y, item.Number, 2);
|
||||
polygon.Add(vrtx);
|
||||
i++;
|
||||
}
|
||||
|
||||
ConstraintOptions constraint = new ConstraintOptions() { Convex = true };
|
||||
MeshBores = (TriangleNet.Mesh)polygon.Triangulate(constraint);
|
||||
Alert("Триангуляционная сеть скважин создана");
|
||||
}
|
||||
|
||||
void AddBoreToList()
|
||||
{
|
||||
ListBore.Add(new Bore() { Number = numBore }); numBore++;
|
||||
//CreateListNumberTypeBet();
|
||||
//NameBore = listBore[0].Name;
|
||||
}
|
||||
void RenumberingBoreInList()
|
||||
{
|
||||
int j = 1;
|
||||
foreach (Bore item in ListBore)
|
||||
{
|
||||
item.Number = j;
|
||||
j++;
|
||||
}
|
||||
numBore = j;
|
||||
ListBore = new ObservableCollection<Bore>(ListBore);
|
||||
}
|
||||
void UpdateBoreInList()
|
||||
{
|
||||
ListBore = new ObservableCollection<Bore>(ListBore);
|
||||
SaveDB();
|
||||
}
|
||||
|
||||
void ChangeSelectedBore()
|
||||
{
|
||||
if (listBore.Count == 0 || selectedBore == null) return;
|
||||
NameBore = selectedBore.Name;
|
||||
ListLayer = selectedBore.Layers;
|
||||
}
|
||||
}
|
||||
}
|
||||
175
VM/CalculationsVM.cs
Normal file
175
VM/CalculationsVM.cs
Normal file
@@ -0,0 +1,175 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Microsoft.Win32;
|
||||
using netDxf;
|
||||
using netDxf.Entities;
|
||||
|
||||
namespace GroundOrganizer
|
||||
{
|
||||
public partial class ViewModel : INotifyPropertyChanged
|
||||
{
|
||||
private RelayCommand calcFoundsContours;
|
||||
private RelayCommand calcRinBore;
|
||||
private RelayCommand calcRinBores;
|
||||
private RelayCommand calcRinCoords;
|
||||
private RelayCommand calcSpInBore;
|
||||
private RelayCommand calcSpInBores;
|
||||
|
||||
private ObservableCollection<DataR> resR;
|
||||
private ObservableCollection<DataS> resS;
|
||||
private List<DataPair> resSdata;
|
||||
private List<DataPair> resRdata;
|
||||
private DataR resRselected;
|
||||
private List<TypeFound> listTypeFounds;
|
||||
|
||||
public DataR ResRselected { get => resRselected; set { resRselected = value; OnPropertyChanged(); ChangeSelectedResults(); } }
|
||||
public ObservableCollection<DataR> ResR { get => resR; set { resR = value; OnPropertyChanged(); } }
|
||||
public ObservableCollection<DataS> ResS { get => resS; set { resS = value; OnPropertyChanged(); } }
|
||||
public List<DataPair> ResRdata { get => resRdata; set { resRdata = value; OnPropertyChanged(); } }
|
||||
public List<DataPair> ResSdata { get => resSdata; set { resSdata = value; OnPropertyChanged(); } }
|
||||
|
||||
public RelayCommand CalcFoundsContours
|
||||
{
|
||||
get { return calcFoundsContours ?? (calcFoundsContours = new RelayCommand(obj => { CalculateContoursFounds(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand CalcRinBore
|
||||
{
|
||||
get { return calcRinBore ?? (calcRinBore = new RelayCommand(obj => { CalculateRinBore(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand CalcRinBores
|
||||
{
|
||||
get { return calcRinBores ?? (calcRinBores = new RelayCommand(obj => { CalculateRinBores(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand CalcRinCoords
|
||||
{
|
||||
get { return calcRinCoords ?? (calcRinCoords = new RelayCommand(obj => { CalculateRinCoords(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand CalcSpInBore
|
||||
{
|
||||
get { return calcSpInBore ?? (calcSpInBore = new RelayCommand(obj => { CalculateSpInBore(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand CalcSpInBores
|
||||
{
|
||||
get { return calcSpInBores ?? (calcSpInBores = new RelayCommand(obj => { CalculateSpInBores(); })); }
|
||||
}
|
||||
|
||||
private void CalculateContoursFounds()
|
||||
{
|
||||
if (listFoundation == null || listFoundation.Count == 0) return;
|
||||
|
||||
foreach (Foundation item in listFoundation) item.CalcContour();
|
||||
ListFoundation = new ObservableCollection<Foundation>(listFoundation);
|
||||
}
|
||||
|
||||
void ChangeSelectedResults()
|
||||
{
|
||||
if (resR == null || resR.Count == 0) return;
|
||||
ResRdata = resRselected.SmallData;
|
||||
}
|
||||
|
||||
void CalculateSpInBore()
|
||||
{
|
||||
if (selectedBore == null) { Alert("Не выбрана расчетная скважина"); return; }
|
||||
if (selectedFoundation == null) { Alert("Не выбран фундамент для расчета"); return; }
|
||||
if (selectedFoundLoad == null) { Alert("Не выбрана расчетная нагрузка"); return; }
|
||||
if (resS == null) ResS = new ObservableCollection<DataS>();
|
||||
ResS.Clear();
|
||||
DataS s = selectedFoundation.Sp(selectedBore, selectedFoundLoad);
|
||||
s.Bore = "Скв. " + nameBore;
|
||||
s.Base = nameFoundation;
|
||||
ResS.Add(s);
|
||||
ResultsPage resPage = new ResultsPage();
|
||||
MW.ResulsFrame.Content = resPage;
|
||||
resPage.ResultsDataGrid.ItemsSource = ResS;
|
||||
MW.MainTabControl.SelectedIndex = 5;
|
||||
//FoundationsPage foundPage = (FoundationsPage)MW.FoundationsFrame.Content;
|
||||
//resPage.resultExpander.IsExpanded = true;
|
||||
}
|
||||
|
||||
void CalculateSpInBores()
|
||||
{
|
||||
if (listBore == null) { Alert("Площадка не содержит ни одной скважины"); return; }
|
||||
if (selectedFoundation == null) { Alert("Не выбран фундамент для расчета"); return; }
|
||||
if (selectedFoundLoad == null) { Alert("Не выбрана расчетная нагрузка"); return; }
|
||||
if (resS == null) ResS = new ObservableCollection<DataS>();
|
||||
ResS.Clear();
|
||||
foreach (Bore item in listBore)
|
||||
{
|
||||
DataS s = selectedFoundation.Sp(item, selectedFoundLoad);
|
||||
s.Bore = "Скв. " + item.Name;
|
||||
s.Base = nameFoundation;
|
||||
ResS.Add(s);
|
||||
}
|
||||
ResultsPage resPage = new ResultsPage();
|
||||
MW.ResulsFrame.Content = resPage;
|
||||
resPage.ResultsDataGrid.ItemsSource = ResS;
|
||||
MW.MainTabControl.SelectedIndex = 5;
|
||||
//FoundationsPage foundPage = (FoundationsPage)MW.FoundationsFrame.Content;
|
||||
//foundPage.ResultsDataGrid.ItemsSource = ResS;
|
||||
//foundPage.resultExpander.IsExpanded = true;
|
||||
|
||||
}
|
||||
|
||||
void CalculateRinBore()
|
||||
{
|
||||
if (selectedBore == null) { Alert("Не выбрана расчетная скважина"); return; }
|
||||
if (selectedFoundation == null) { Alert("Не выбран фундамент для расчета"); return; }
|
||||
if (resR == null) ResR = new ObservableCollection<DataR>();
|
||||
ResR.Clear();
|
||||
DataR r = selectedFoundation.P(selectedBore, selectedStructure.flexStructure, selectedStructure.L, selectedStructure.H);
|
||||
ResR.Add(r);
|
||||
ResultsPage resPage = new ResultsPage();
|
||||
MW.ResulsFrame.Content = resPage;
|
||||
//resPage.ResultsDataGrid.ItemsSource = ResR;
|
||||
//resPage.DetailedResultsDataGrid.ItemsSource = ResRdata;
|
||||
MW.MainTabControl.SelectedIndex = 5;
|
||||
//FoundationsPage foundPage = (FoundationsPage)MW.FoundationsFrame.Content;
|
||||
//foundPage.ResultsDataGrid.ItemsSource = ResR;
|
||||
//foundPage.resultExpander.IsExpanded = true;
|
||||
}
|
||||
|
||||
private void CalculateRinBores()
|
||||
{
|
||||
if (listBore == null) { Alert("Площадка не содержит ни одной скважины"); return; }
|
||||
if (selectedFoundation == null) { Alert("Не выбран фундамент для расчета"); return; }
|
||||
ResR = selectedFoundation.P(ListBore, selectedStructure.flexStructure, selectedStructure.L, selectedStructure.H);
|
||||
ResultsPage resPage = new ResultsPage();
|
||||
MW.ResulsFrame.Content = resPage;
|
||||
//resPage.ResultsDataGrid.ItemsSource = ResR;
|
||||
//resPage.DetailedResultsDataGrid.ItemsSource = ResRdata;
|
||||
MW.MainTabControl.SelectedIndex = 5;
|
||||
//FoundationsPage foundPage = (FoundationsPage)MW.FoundationsFrame.Content;
|
||||
//foundPage.ResultsDataGrid.ItemsSource = ResR;
|
||||
//foundPage.resultExpander.IsExpanded = true;
|
||||
}
|
||||
|
||||
private void CalculateRinCoords()
|
||||
{
|
||||
if (selectedBore == null) return;
|
||||
if (resR == null) ResR = new ObservableCollection<DataR>();
|
||||
ResR.Clear();
|
||||
DataR r = SelectedFoundation.P(selectedBore, selectedStructure.flexStructure, selectedStructure.L, selectedStructure.H);
|
||||
r.Bore = "По координатам";
|
||||
r.Base = nameFoundation;
|
||||
ResR.Add(r);
|
||||
//FoundationsPage foundPage = (FoundationsPage)MW.FoundationsFrame.Content;
|
||||
//foundPage.ResultsDataGrid.ItemsSource = ResR;
|
||||
//foundPage.resultExpander.IsExpanded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
81
VM/DrawingVM.cs
Normal file
81
VM/DrawingVM.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
using netDxf;
|
||||
using netDxf.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace GroundOrganizer
|
||||
{
|
||||
public partial class ViewModel : INotifyPropertyChanged
|
||||
{
|
||||
|
||||
private RelayCommand drowFoundations;
|
||||
private RelayCommand showFoundProps;
|
||||
|
||||
CanwasWindow cw;
|
||||
|
||||
public RelayCommand DrowFoundations
|
||||
{
|
||||
get { return drowFoundations ?? (drowFoundations = new RelayCommand(obj => { DrowFounds(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand ShowFoundProps
|
||||
{
|
||||
get { return showFoundProps ?? (showFoundProps = new RelayCommand(obj => { ShowFoundPropsWindow(); })); }
|
||||
}
|
||||
|
||||
internal void ShowFoundPropsWindow()
|
||||
{
|
||||
if (listFoundation.Count == 0) return;
|
||||
if (listFoundation == null) return;
|
||||
|
||||
FoundPropWindow fpw = new FoundPropWindow();
|
||||
fpw.Owner = MW;
|
||||
fpw.DataContext = MW.DataContext;
|
||||
fpw.Top = 75;
|
||||
fpw.Left = 75;
|
||||
fpw.ShowDialog();
|
||||
}
|
||||
|
||||
internal void DrowFounds()
|
||||
{
|
||||
if (listFoundation.Count == 0) return;
|
||||
if (listFoundation == null) return;
|
||||
|
||||
CalculateContoursFounds();
|
||||
CreateSmallPropsFounds();
|
||||
int t = 75;
|
||||
int l = 75;
|
||||
double ws = SystemParameters.PrimaryScreenWidth;
|
||||
double hs = SystemParameters.PrimaryScreenHeight;
|
||||
cw = new CanwasWindow();
|
||||
cw.Top = t;
|
||||
cw.Left = l;
|
||||
cw.MaxHeight= hs - t - 37;
|
||||
cw.MaxWidth= ws - l - 5;
|
||||
cw.CanvasScrollViewer.MaxWidth = cw.MaxWidth;
|
||||
cw.CanvasScrollViewer.MaxHeight = cw.MaxHeight-60;
|
||||
cw.Owner = MW;
|
||||
CanvasDrafter.DrawFoundations(listFoundation, cw.drawArea, cw.MaxHeight - 120);
|
||||
cw.drawArea.MinHeight = cw.drawArea.Height;
|
||||
cw.drawArea.MinWidth = cw.drawArea.Width;
|
||||
cw.EventMouseEnter();
|
||||
cw.Show();
|
||||
}
|
||||
|
||||
internal void DrowFoundsNums()
|
||||
{
|
||||
if (cw == null || cw.IsActive == false) return;
|
||||
CanvasDrafter.DrawFoundationsNumbers(listFoundation, cw.drawArea);
|
||||
}
|
||||
}
|
||||
}
|
||||
188
VM/FoundLoadsVM.cs
Normal file
188
VM/FoundLoadsVM.cs
Normal file
@@ -0,0 +1,188 @@
|
||||
using Microsoft.Win32;
|
||||
using OfficeOpenXml;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GroundOrganizer
|
||||
{
|
||||
public partial class ViewModel : INotifyPropertyChanged
|
||||
{
|
||||
private RelayCommand addFoundLoad;
|
||||
private RelayCommand updateFoundLoad;
|
||||
private RelayCommand renumFoundLoad;
|
||||
private RelayCommand exportFoundLoadsToCSV;
|
||||
private RelayCommand importFoundLoadsFromCSV;
|
||||
|
||||
int numFoundLoad = 1;
|
||||
string nameFoundLoad;
|
||||
FoundLoad selectedFoundLoad;
|
||||
ObservableCollection<FoundLoad> listFoundLoad = new ObservableCollection<FoundLoad>();
|
||||
|
||||
public ObservableCollection<FoundLoad> ListFoundLoad { get => listFoundLoad; set { listFoundLoad = value; OnPropertyChanged(); } }
|
||||
|
||||
|
||||
public RelayCommand AddFoundLoad
|
||||
{
|
||||
get { return addFoundLoad ?? (addFoundLoad = new RelayCommand(obj => { AddFoundLoadToList(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand UpdateFoundLoads
|
||||
{
|
||||
get { return updateFoundLoad ?? (updateFoundLoad = new RelayCommand(obj => { UpdateFoundLoadInList(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand RenumFoundLoads
|
||||
{
|
||||
get { return renumFoundLoad ?? (renumFoundLoad = new RelayCommand(obj => { RenumberingFoundLoadInList(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand ExportFoundLoadsToCSV
|
||||
{
|
||||
get { return exportFoundLoadsToCSV ?? (exportFoundLoadsToCSV = new RelayCommand(obj => { SaveLoadsInXlsx(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand ImportFoundLoadsFromCSV
|
||||
{
|
||||
get { return importFoundLoadsFromCSV ?? (importFoundLoadsFromCSV = new RelayCommand(obj => { ReadLoadsFromXlsx(); })); }
|
||||
}
|
||||
public FoundLoad SelectedFoundLoad { get => selectedFoundLoad; set { selectedFoundLoad = value; OnPropertyChanged(); ChangeSelectedFoundLoad(); } }
|
||||
|
||||
public string NameFoundLoad { get => nameFoundLoad; set { nameFoundLoad = value; OnPropertyChanged(); } }
|
||||
|
||||
void AddFoundLoadToList()
|
||||
{
|
||||
ListFoundLoad.Add(new FoundLoad() { Number = numFoundLoad }); numFoundLoad++;
|
||||
//CreateListNumberTypeBet();
|
||||
//NameFoundLoad = listFoundLoad[0].Name;
|
||||
}
|
||||
void RenumberingFoundLoadInList()
|
||||
{
|
||||
int j = 1;
|
||||
foreach (FoundLoad item in ListFoundLoad)
|
||||
{
|
||||
item.Number = j;
|
||||
j++;
|
||||
}
|
||||
numFoundLoad = j;
|
||||
ListFoundLoad = new ObservableCollection<FoundLoad>(ListFoundLoad);
|
||||
SaveDB();
|
||||
}
|
||||
internal void UpdateFoundLoadInList()
|
||||
{
|
||||
ListFoundLoad = new ObservableCollection<FoundLoad>(ListFoundLoad);
|
||||
SaveDB();
|
||||
}
|
||||
|
||||
void ChangeSelectedFoundLoad()
|
||||
{
|
||||
if (listFoundLoad.Count == 0 || selectedFoundLoad == null) return;
|
||||
NameFoundLoad = SelectedFoundLoad.Number.ToString();
|
||||
}
|
||||
|
||||
//Сохранение таблицы нагрузок в файл *.xlsx
|
||||
internal void SaveLoadsInXlsx()
|
||||
{
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.DefaultExt = "*.xlsx";
|
||||
sfd.Filter = "Файл Excel (*.xlsx)|*.xlsx";
|
||||
sfd.Title = "Сохранение таблицы";
|
||||
//sfd.AddExtension = true;
|
||||
sfd.OverwritePrompt = true;
|
||||
sfd.ShowDialog();
|
||||
|
||||
if (sfd.FileName == null || sfd.FileName == "") return;
|
||||
|
||||
try
|
||||
{
|
||||
string path = "ИГЭ.xlsx";
|
||||
FileInfo fileInf = new FileInfo(path);
|
||||
if (fileInf.Exists != true)
|
||||
{
|
||||
using (FileStream fstream = new FileStream("ИГЭ.xlsx", FileMode.OpenOrCreate))
|
||||
{
|
||||
byte[] array = Properties.Resources.IGE;
|
||||
fstream.Write(array, 0, array.Length);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
using (var p = new ExcelPackage(new FileInfo(sfd.FileName)))
|
||||
{
|
||||
for (int i = 0; i < listFoundation.Count; i++)
|
||||
{
|
||||
List<object[]> content = new List<object[]>();
|
||||
foreach (FoundLoad fli in listFoundation[i].Loads)
|
||||
{
|
||||
content.Add(fli.PropsToList().ToArray());
|
||||
}
|
||||
ExcelPackage p1 = new ExcelPackage(new FileInfo("ИГЭ.xlsx"));
|
||||
//A workbook must have at least on cell, so lets add one...
|
||||
var ws = p1.Workbook.Worksheets["Нагрузки"];
|
||||
p.Workbook.Worksheets.Add((i + 1).ToString(), ws);
|
||||
var wsi = p.Workbook.Worksheets[i + 1];
|
||||
//To set values in the spreadsheet use the Cells indexer.
|
||||
wsi.Cells["D1"].Value = listFoundation[i].Number;
|
||||
wsi.Cells["F1"].Value = listFoundation[i].Name;
|
||||
wsi.Cells["A3"].LoadFromArrays(content);
|
||||
}
|
||||
|
||||
//Save the new workbook. We haven't specified the filename so use the Save as method.
|
||||
p.SaveAs(new FileInfo(sfd.FileName));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Alert(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
//Чтение нагрузок из файла *.xlsx
|
||||
internal void ReadLoadsFromXlsx()
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.DefaultExt = "*.xlsx";
|
||||
ofd.Filter = "Файл Excel (*.xlsx)|*.xlsx";
|
||||
ofd.Title = "Заполнение таблиц";
|
||||
ofd.ShowDialog();
|
||||
|
||||
if (ofd.FileName == null || ofd.FileName == "") return;
|
||||
|
||||
//ListFoundLoad.Clear();
|
||||
try
|
||||
{
|
||||
using (var p = new ExcelPackage(new FileInfo(ofd.FileName)))
|
||||
{
|
||||
int k = 0;
|
||||
foreach (ExcelWorksheet wsi in p.Workbook.Worksheets)
|
||||
{
|
||||
listFoundation[k].Loads = new ObservableCollection<FoundLoad>();
|
||||
|
||||
object[,] content = wsi.Cells.Value as object[,];
|
||||
List<object> source; FoundLoad item;
|
||||
for (int i = 2; i < content.GetLength(0); i++)
|
||||
{
|
||||
source = new List<object>();
|
||||
for (int j = 0; j < content.GetLength(1); j++)
|
||||
{
|
||||
source.Add(content[i, j]);
|
||||
}
|
||||
item = new FoundLoad(); item.ListToProps(source);
|
||||
listFoundation[k].Loads.Add(item);
|
||||
}
|
||||
k++;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Alert(e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
401
VM/FoundationsVM.cs
Normal file
401
VM/FoundationsVM.cs
Normal file
@@ -0,0 +1,401 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Geo;
|
||||
using Microsoft.Win32;
|
||||
using netDxf;
|
||||
using netDxf.Entities;
|
||||
using OfficeOpenXml;
|
||||
|
||||
namespace GroundOrganizer
|
||||
{
|
||||
public partial class ViewModel : INotifyPropertyChanged
|
||||
{
|
||||
private RelayCommand addFoundation;
|
||||
private RelayCommand updateFoundation;
|
||||
private RelayCommand renumFoundation;
|
||||
private RelayCommand importFoundationsFromDXF;
|
||||
private RelayCommand replaceD1Found;
|
||||
private RelayCommand replaceDLFound;
|
||||
private RelayCommand replaceFLFound;
|
||||
private RelayCommand replaceDLFoundfromNULL;
|
||||
private RelayCommand calculateDLFound;
|
||||
private RelayCommand calculateLevelsFounds;
|
||||
private RelayCommand exportFoundationsToCSV;
|
||||
private RelayCommand importFoundationsFromCSV;
|
||||
|
||||
private double d1;
|
||||
private double dL;
|
||||
private double fL;
|
||||
|
||||
int numFoundation = 1;
|
||||
string nameFoundation;
|
||||
Foundation selectedFoundation;
|
||||
ObservableCollection<Foundation> listFoundation = new ObservableCollection<Foundation>();
|
||||
List<Foundation> bufferFoundations = new List<Foundation>();
|
||||
|
||||
public double D1 { get => d1; set { d1 = value; OnPropertyChanged(); /*ChangeD1();*/ } }
|
||||
public double DL { get => dL; set { dL = value; OnPropertyChanged(); /*ChangeDL();*/ } }
|
||||
public double FL { get => fL; set { fL = value; OnPropertyChanged(); /*ChangeFL();*/ } }
|
||||
|
||||
|
||||
public ObservableCollection<Foundation> ListFoundation { get => listFoundation; set { listFoundation = value; OnPropertyChanged(); } }
|
||||
public Foundation SelectedFoundation { get => selectedFoundation; set { selectedFoundation = value; OnPropertyChanged(); ChangeSelectedFoundation(); } }
|
||||
public string NameFoundation { get => nameFoundation; set { nameFoundation = value; OnPropertyChanged(); ChangeMark(); } }
|
||||
public List<TypeFound> ListTypeFounds { get => listTypeFounds; set { listTypeFounds = value; OnPropertyChanged(); } }
|
||||
public List<Foundation> BufferFoundations { get => bufferFoundations; set => bufferFoundations = value; }
|
||||
|
||||
#region Команды
|
||||
|
||||
public RelayCommand AddFoundation
|
||||
{
|
||||
get { return addFoundation ?? (addFoundation = new RelayCommand(obj => { AddFoundationToList(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand UpdateFoundations
|
||||
{
|
||||
get { return updateFoundation ?? (updateFoundation = new RelayCommand(obj => { UpdateFoundationInList(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand RenumFoundations
|
||||
{
|
||||
get { return renumFoundation ?? (renumFoundation = new RelayCommand(obj => { RenumberingFoundationInList(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand ImportFoundationsFromDXF
|
||||
{
|
||||
get { return importFoundationsFromDXF ?? (importFoundationsFromDXF = new RelayCommand(obj => { ReadFondationsFromDXF(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand ReplaceD1Found
|
||||
{
|
||||
get { return replaceD1Found ?? (replaceD1Found = new RelayCommand(obj => { ChangeD1(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand ReplaceDLFound
|
||||
{
|
||||
get { return replaceDLFound ?? (replaceDLFound = new RelayCommand(obj => { ChangeDL(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand ReplaceFLFound
|
||||
{
|
||||
get { return replaceFLFound ?? (replaceFLFound = new RelayCommand(obj => { ChangeFL(); })); }
|
||||
}
|
||||
|
||||
|
||||
public RelayCommand ReplaceDLFoundfromNULL
|
||||
{
|
||||
get { return replaceDLFoundfromNULL ?? (replaceDLFoundfromNULL = new RelayCommand(obj => { ChangeDLfromNULL(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand CalculateDLFound
|
||||
{
|
||||
get { return calculateDLFound ?? (calculateDLFound = new RelayCommand(obj => { CalcDLFound(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand CalculateLevelsFounds
|
||||
{
|
||||
get { return calculateLevelsFounds ?? (calculateLevelsFounds = new RelayCommand(obj => { CalcDLFoundsAll(); CalcNLFoundsAll(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand ExportFoundationsToCSV
|
||||
{
|
||||
get { return exportFoundationsToCSV ?? (exportFoundationsToCSV = new RelayCommand(obj => { SaveFoundationsInCsv(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand ImportFoundationsFromCSV
|
||||
{
|
||||
get { return importFoundationsFromCSV ?? (importFoundationsFromCSV = new RelayCommand(obj => { ReadFoundationsFromCsv(); })); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
void AddFoundationToList()
|
||||
{
|
||||
ListFoundation.Add(new Foundation() { Number = numFoundation }); numFoundation++;
|
||||
//CreateListNumberTypeBet();
|
||||
//NameFoundation = listFoundation[0].Name;
|
||||
}
|
||||
void RenumberingFoundationInList()
|
||||
{
|
||||
int j = 1;
|
||||
foreach (Foundation item in ListFoundation)
|
||||
{
|
||||
item.Number = j;
|
||||
j++;
|
||||
}
|
||||
numFoundation = j;
|
||||
ListFoundation = new ObservableCollection<Foundation>(ListFoundation);
|
||||
}
|
||||
internal void UpdateFoundationInList()
|
||||
{
|
||||
ListFoundation = new ObservableCollection<Foundation>(ListFoundation);
|
||||
SaveDB();
|
||||
}
|
||||
|
||||
void ChangeSelectedFoundation()
|
||||
{
|
||||
if (listFoundation.Count == 0 || selectedFoundation == null) return;
|
||||
NameFoundation = selectedFoundation.Name;
|
||||
ListFoundLoad = selectedFoundation.Loads;
|
||||
D1 = selectedFoundation.D1;
|
||||
FL = selectedFoundation.FL;
|
||||
DL = selectedFoundation.DL;
|
||||
}
|
||||
|
||||
void CreateListTypeFoundations()
|
||||
{
|
||||
if (listFoundation == null || listPlayGround == null) return;
|
||||
ListTypeFounds = new List<TypeFound> { TypeFound.Прямоугольный, TypeFound.Круглый, TypeFound.Ленточный };
|
||||
try
|
||||
{
|
||||
FoundationsPage foundationsPage = (FoundationsPage)MW.FoundationsFrame.Content;
|
||||
foundationsPage.typeFondsListCbxCol.ItemsSource = ListTypeFounds;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
private void ReadFondationsFromDXF()
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.DefaultExt = "*.dxf";
|
||||
ofd.Filter = "Чертеж (*.dxf)|*.dxf";
|
||||
ofd.Title = "Импорт чертежа";
|
||||
ofd.ShowDialog();
|
||||
|
||||
if (ofd.FileName == null || ofd.FileName == "") return;
|
||||
|
||||
DxfDocument dxfDocument = DxfDocument.Load(ofd.FileName);
|
||||
IEnumerable<LwPolyline> dxfLwPolylines = dxfDocument.LwPolylines;
|
||||
IEnumerable<LwPolylineVertex> dxfLwPolylinesVertexes = null;
|
||||
Foundation fnd;
|
||||
Quadrangle countFound; int i = 0;
|
||||
Point2d[] ptColl = new Point2d[4];
|
||||
foreach (LwPolyline item in dxfLwPolylines)
|
||||
{
|
||||
if (item.Layer.Name == "Foundations")
|
||||
{
|
||||
dxfLwPolylinesVertexes = item.Vertexes;
|
||||
int j = 0;
|
||||
foreach (LwPolylineVertex itemVrtx in dxfLwPolylinesVertexes)
|
||||
{
|
||||
ptColl[j] = new Point2d(itemVrtx.Position.X * 0.001, itemVrtx.Position.Y * 0.001);
|
||||
j++; if (j == 4) break;
|
||||
}
|
||||
countFound = new Quadrangle(ptColl[0], ptColl[1], ptColl[2], ptColl[3]);
|
||||
countFound.Units = UnitsLin.м;
|
||||
fnd = new Foundation(countFound) { Number = i + 1 };
|
||||
ListFoundation.Add(fnd);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (dxfLwPolylinesVertexes == null) return;
|
||||
}
|
||||
|
||||
//Сохранение таблицы фундаментов в файл *.csv
|
||||
internal void SaveFoundationsInCsv()
|
||||
{
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.DefaultExt = "*.xlsx";
|
||||
sfd.Filter = "Файл Excel (*.xlsx)|*.xlsx";
|
||||
sfd.Title = "Сохранение таблицы";
|
||||
//sfd.AddExtension = true;
|
||||
sfd.OverwritePrompt = false;
|
||||
sfd.ShowDialog();
|
||||
|
||||
if (sfd.FileName == null || sfd.FileName == "") return;
|
||||
|
||||
string path = "ИГЭ.xlsx";
|
||||
FileInfo fileInf = new FileInfo(path);
|
||||
if (fileInf.Exists != true)
|
||||
{
|
||||
using (FileStream fstream = new FileStream("ИГЭ.xlsx", FileMode.OpenOrCreate))
|
||||
{
|
||||
byte[] array = Properties.Resources.IGE;
|
||||
fstream.Write(array, 0, array.Length);
|
||||
}
|
||||
}
|
||||
List<object[]> content = new List<object[]>();
|
||||
foreach (Foundation item in listFoundation)
|
||||
{
|
||||
content.Add(item.PropsToList().ToArray());
|
||||
}
|
||||
|
||||
using (var p = new ExcelPackage(new FileInfo(sfd.FileName)))
|
||||
{
|
||||
try
|
||||
{
|
||||
//A workbook must have at least on cell, so lets add one...
|
||||
var ws = p.Workbook.Worksheets["Фундаменты"];
|
||||
|
||||
//To set values in the spreadsheet use the Cells indexer.
|
||||
ws.Cells["A2"].LoadFromArrays(content);
|
||||
|
||||
//Save the new workbook. We haven't specified the filename so use the Save as method.
|
||||
p.SaveAs(new FileInfo(sfd.FileName));
|
||||
}
|
||||
catch
|
||||
{
|
||||
ExcelPackage p1 = new ExcelPackage(new FileInfo("ИГЭ.xlsx"));
|
||||
ExcelWorksheet ws1 = p1.Workbook.Worksheets["Фундаменты"];
|
||||
p.Workbook.Worksheets.Add("Фундаменты", ws1);
|
||||
|
||||
//A workbook must have at least on cell, so lets add one...
|
||||
var ws = p.Workbook.Worksheets["Фундаменты"];
|
||||
|
||||
//To set values in the spreadsheet use the Cells indexer.
|
||||
ws.Cells["A2"].LoadFromArrays(content);
|
||||
ws.Select();
|
||||
//Save the new workbook. We haven't specified the filename so use the Save as method.
|
||||
p.SaveAs(new FileInfo(sfd.FileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Чтение таблицы фундаментов из файла *.xlsx
|
||||
internal void ReadFoundationsFromCsv()
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.DefaultExt = "*.xlsx";
|
||||
ofd.Filter = "Файл Excel (*.xlsx)|*.xlsx";
|
||||
ofd.Title = "Заполнение таблицы";
|
||||
ofd.ShowDialog();
|
||||
|
||||
if (ofd.FileName == null || ofd.FileName == "") return;
|
||||
|
||||
//ListIGE.Clear();
|
||||
|
||||
try
|
||||
{
|
||||
using (var p = new ExcelPackage(new FileInfo(ofd.FileName)))
|
||||
{
|
||||
//A workbook must have at least on cell, so lets add one...
|
||||
var ws = p.Workbook.Worksheets["Фундаменты"];
|
||||
|
||||
object[,] content = ws.Cells.Value as object[,];
|
||||
List<object> source; Foundation item;
|
||||
for (int i = 1; i < content.GetLength(0); i++)
|
||||
{
|
||||
source = new List<object>();
|
||||
for (int j = 0; j < content.GetLength(1); j++)
|
||||
{
|
||||
source.Add(content[i, j]);
|
||||
}
|
||||
item = new Foundation(); item.ListToProps(source);
|
||||
ListFoundation.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Alert(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeMark()
|
||||
{
|
||||
if (selectedFoundation == null) return;
|
||||
SelectedFoundation.Name = nameFoundation;
|
||||
}
|
||||
|
||||
void ChangeD1()
|
||||
{
|
||||
if (selectedFoundation == null || selectedStructure == null) return;
|
||||
SelectedFoundation.D1 = d1;
|
||||
SelectedFoundation.D1toFL(selectedStructure.Null);
|
||||
DL = selectedFoundation.DL;
|
||||
//FL = selectedFoundation.FL;
|
||||
}
|
||||
|
||||
void ChangeDL()
|
||||
{
|
||||
if (selectedFoundation == null || selectedStructure == null) return;
|
||||
SelectedFoundation.DL = dL;
|
||||
SelectedFoundation.DLtoD1(selectedStructure.Null);
|
||||
D1 = selectedFoundation.D1;
|
||||
//FL = selectedFoundation.FL;
|
||||
}
|
||||
|
||||
void ChangeFL()
|
||||
{
|
||||
if (selectedFoundation == null || selectedStructure == null) return;
|
||||
SelectedFoundation.FL = fL;
|
||||
SelectedFoundation.FLtoD1(selectedStructure.Null);
|
||||
D1 = selectedFoundation.D1;
|
||||
//DL = selectedFoundation.DL;
|
||||
}
|
||||
|
||||
private void ChangeDLfromNULL()
|
||||
{
|
||||
if (selectedFoundation == null || selectedStructure == null) return;
|
||||
SelectedFoundation.DL = selectedStructure.Null;
|
||||
DL = SelectedFoundation.DL;
|
||||
SelectedFoundation.DLtoD1(selectedStructure.Null);
|
||||
D1 = selectedFoundation.D1;
|
||||
}
|
||||
|
||||
private void CalcDLFound()
|
||||
{
|
||||
if (selectedFoundation == null || selectedStructure == null) return;
|
||||
if (MeshRedPlanning == null) CreateRedMesh();
|
||||
selectedFoundation.CalcDL(MeshRedPlanning);
|
||||
DL = SelectedFoundation.DL;
|
||||
SelectedFoundation.DLtoD1(selectedStructure.Null);
|
||||
D1 = selectedFoundation.D1;
|
||||
}
|
||||
|
||||
internal void CalcDLFoundsAll()
|
||||
{
|
||||
if (listFoundation == null || listFoundation.Count == 0) return;
|
||||
if (MeshRedPlanning == null) CreateRedMesh();
|
||||
if (MeshRedPlanning == null)
|
||||
{
|
||||
Alert("Сооружение не содержит планировочных отметок");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (Foundation item in ListFoundation)
|
||||
{
|
||||
item.CalcDL(MeshRedPlanning);
|
||||
item.DLtoD1(selectedStructure.Null);
|
||||
}
|
||||
|
||||
Alert("Уровни планировки для всех фундаментов \nвычислены по триангуляционной сети");
|
||||
}
|
||||
|
||||
internal void CalcNLFoundsAll()
|
||||
{
|
||||
if (listFoundation == null || listFoundation.Count == 0) return;
|
||||
if (MeshBlackPlanning == null) CreateBlackMesh();
|
||||
if (MeshBlackPlanning == null)
|
||||
{
|
||||
Alert("Сооружение не содержит планировочных отметок");
|
||||
return;
|
||||
}
|
||||
foreach (Foundation item in ListFoundation)
|
||||
{
|
||||
item.CalcNL(MeshBlackPlanning);
|
||||
}
|
||||
|
||||
Alert("Отметки естественного рельефа для всех фундаментов \nвычислены по триангуляционной сети");
|
||||
}
|
||||
|
||||
internal void CreateSmallPropsFounds()
|
||||
{
|
||||
foreach (Foundation item in ListFoundation) item.CreateSmallPropsList();
|
||||
}
|
||||
}
|
||||
}
|
||||
94
VM/HelpsVM.cs
Normal file
94
VM/HelpsVM.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace GroundOrganizer
|
||||
{
|
||||
public partial class ViewModel : INotifyPropertyChanged
|
||||
{
|
||||
|
||||
private RelayCommand helpFoundation;
|
||||
private RelayCommand helpLoads;
|
||||
public RelayCommand HelpFoundation
|
||||
{
|
||||
get { return helpFoundation ?? (helpFoundation = new RelayCommand(obj => { HelpFoundAlert(); })); }
|
||||
}
|
||||
public RelayCommand HelpLoads
|
||||
{
|
||||
get { return helpLoads ?? (helpLoads = new RelayCommand(obj => { HelpLoadsAlert(); })); }
|
||||
}
|
||||
|
||||
void HelpFoundAlert()
|
||||
{
|
||||
Alert(Properties.Resources.ShemaFound, 500);
|
||||
if (MW.OwnedWindows.Count > 0)
|
||||
{
|
||||
foreach (Window item in MW.OwnedWindows) item.Close();
|
||||
Alert(Properties.Resources.ShemaFound, 500);
|
||||
}
|
||||
}
|
||||
|
||||
void HelpLoadsAlert()
|
||||
{
|
||||
Alert(@"\Images\ShemaLoads.png", 200);
|
||||
if (MW.OwnedWindows.Count > 0)
|
||||
{
|
||||
foreach (Window item in MW.OwnedWindows) item.Close();
|
||||
Alert(@"\Images\ShemaLoads.png", 200);
|
||||
}
|
||||
}
|
||||
|
||||
void Alert(string alert)
|
||||
{
|
||||
AlertWindow aw = new AlertWindow();
|
||||
aw.Owner = MW;
|
||||
aw.alertLabel.Content = alert;
|
||||
//aw.WindowStyle = WindowStyle.None;
|
||||
aw.ShowDialog();
|
||||
}
|
||||
void Alert(string alert, string title)
|
||||
{
|
||||
AlertWindow aw = new AlertWindow();
|
||||
aw.Owner = MW;
|
||||
aw.alertLabel.Content = alert;
|
||||
aw.Title = title;
|
||||
aw.ShowDialog();
|
||||
}
|
||||
void Alert(Bitmap resource, int h = 250)
|
||||
{
|
||||
ImageWindow aw = new ImageWindow();
|
||||
//BitmapImage b =new BitmapImage(new Uri("pack://application:,,,/Resources/ShemaFound.png"));
|
||||
Bitmap br = resource;
|
||||
BitmapSource b = Imaging.CreateBitmapSourceFromHBitmap(br.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
|
||||
aw.alertImage.Source = b;
|
||||
aw.alertImage.Height = h;
|
||||
aw.Owner = MW;
|
||||
aw.WindowStartupLocation = WindowStartupLocation.Manual;
|
||||
aw.Top = MW.Top;
|
||||
aw.Left = MW.Left + MW.Width;
|
||||
aw.Show();
|
||||
}
|
||||
|
||||
void Alert(string filepath, int h = 250)
|
||||
{
|
||||
Uri uri = new Uri(filepath, UriKind.RelativeOrAbsolute);
|
||||
BitmapImage b = new BitmapImage(uri);
|
||||
ImageWindow aw = new ImageWindow();
|
||||
aw.alertImage.Source = b;
|
||||
aw.alertImage.Height = h;
|
||||
aw.Owner = MW;
|
||||
aw.WindowStartupLocation = WindowStartupLocation.Manual;
|
||||
aw.Top = MW.Top;
|
||||
aw.Left = MW.Left + MW.Width;
|
||||
aw.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
278
VM/IGEsVM.cs
Normal file
278
VM/IGEsVM.cs
Normal file
@@ -0,0 +1,278 @@
|
||||
using Microsoft.Win32;
|
||||
using OfficeOpenXml;
|
||||
using OfficeOpenXml.Style;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GroundOrganizer
|
||||
{
|
||||
public partial class ViewModel : INotifyPropertyChanged
|
||||
{
|
||||
int numIGE = 1;
|
||||
ObservableCollection<IGE> listIGE = new ObservableCollection<IGE>();
|
||||
|
||||
public ObservableCollection<IGE> ListIGE { get => listIGE; set { listIGE = value; OnPropertyChanged(); } }
|
||||
|
||||
private RelayCommand addIGE;
|
||||
public RelayCommand AddIGE
|
||||
{
|
||||
get { return addIGE ?? (addIGE = new RelayCommand(obj => { AddIGEToList(); })); }
|
||||
}
|
||||
|
||||
private RelayCommand updateIGE;
|
||||
public RelayCommand UpdateIGEs
|
||||
{
|
||||
get { return updateIGE ?? (updateIGE = new RelayCommand(obj => { UpdateIGEInList(); })); }
|
||||
}
|
||||
|
||||
private RelayCommand renumIGE;
|
||||
public RelayCommand RenumIGEs
|
||||
{
|
||||
get { return renumIGE ?? (renumIGE = new RelayCommand(obj => { RenumberingIGEInList(); })); }
|
||||
}
|
||||
|
||||
private RelayCommand exportIGEtoCSV;
|
||||
public RelayCommand ExportIGEtoCSV
|
||||
{
|
||||
get { return exportIGEtoCSV ?? (exportIGEtoCSV = new RelayCommand(obj => { SaveIGEsInCsv(); })); }
|
||||
}
|
||||
|
||||
private RelayCommand importIGEfromCSV;
|
||||
public RelayCommand ImportIGEfromCSV
|
||||
{
|
||||
get { return importIGEfromCSV ?? (importIGEfromCSV = new RelayCommand(obj => { ReadIGEsFromCsv(); })); }
|
||||
}
|
||||
|
||||
private RelayCommand saveIGEsTable;
|
||||
public RelayCommand SaveIGEsTable
|
||||
{
|
||||
get { return saveIGEsTable ?? (saveIGEsTable = new RelayCommand(obj => { SaveIGEs(); })); }
|
||||
}
|
||||
|
||||
private IEnumerable<String> listNumIGEs;
|
||||
public IEnumerable<String> ListNumIGEs { get => listNumIGEs; set { listNumIGEs = value; OnPropertyChanged(); } }
|
||||
|
||||
void AddIGEToList()
|
||||
{
|
||||
ListIGE.Add(new IGE() { Number = numIGE }); numIGE++;
|
||||
CreateListNumIGEs();
|
||||
//CreateListNumberTypeBet();
|
||||
//NameIGE = listIGE[0].Name;
|
||||
}
|
||||
void RenumberingIGEInList()
|
||||
{
|
||||
int j = 1;
|
||||
foreach (IGE item in ListIGE)
|
||||
{
|
||||
item.Number = j;
|
||||
j++;
|
||||
}
|
||||
numIGE = j;
|
||||
ListIGE = new ObservableCollection<IGE>(ListIGE);
|
||||
CreateListNumIGEs();
|
||||
}
|
||||
void UpdateIGEInList()
|
||||
{
|
||||
ListIGE = new ObservableCollection<IGE>(ListIGE);
|
||||
SaveDB();
|
||||
}
|
||||
|
||||
void CreateListNumIGEs()
|
||||
{
|
||||
if (listIGE == null || listPlayGround == null) return;
|
||||
ListNumIGEs = from bet in listIGE select bet.NumIGE;
|
||||
try
|
||||
{
|
||||
BoresPage boresPage = (BoresPage)MW.BoresFrame.Content;
|
||||
boresPage.IGEsListCbxCol.ItemsSource = listNumIGEs;
|
||||
}
|
||||
catch { return; }
|
||||
}
|
||||
|
||||
//Сохранение таблицы набора ИГЭ в файл *.csv
|
||||
internal void SaveIGEsInCsv()
|
||||
{
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.DefaultExt = "*.xlsx";
|
||||
sfd.Filter = "Файл Excel (*.xlsx)|*.xlsx";
|
||||
sfd.Title = "Сохранение таблицы";
|
||||
//sfd.AddExtension = true;
|
||||
sfd.OverwritePrompt = false;
|
||||
sfd.ShowDialog();
|
||||
|
||||
if (sfd.FileName == null || sfd.FileName == "") return;
|
||||
|
||||
string path = "ИГЭ.xlsx";
|
||||
FileInfo fileInf = new FileInfo(path);
|
||||
if (fileInf.Exists != true)
|
||||
{
|
||||
using (FileStream fstream = new FileStream("ИГЭ.xlsx", FileMode.OpenOrCreate))
|
||||
{
|
||||
byte[] array = Properties.Resources.IGE;
|
||||
fstream.Write(array, 0, array.Length);
|
||||
}
|
||||
}
|
||||
List<object[]> content = new List<object[]>();
|
||||
foreach (IGE item in listIGE)
|
||||
{
|
||||
content.Add(item.PropsToList().ToArray());
|
||||
}
|
||||
|
||||
using (var p = new ExcelPackage(new FileInfo(sfd.FileName)))
|
||||
{
|
||||
try
|
||||
{
|
||||
var ws = p.Workbook.Worksheets["ИГЭ"];
|
||||
|
||||
//To set values in the spreadsheet use the Cells indexer.
|
||||
ws.Cells["A2"].LoadFromArrays(content);
|
||||
|
||||
//Save the new workbook. We haven't specified the filename so use the Save as method.
|
||||
p.SaveAs(new FileInfo(sfd.FileName));
|
||||
}
|
||||
catch
|
||||
{
|
||||
ExcelPackage p1 = new ExcelPackage(new FileInfo("ИГЭ.xlsx"));
|
||||
ExcelWorksheet ws1 = p1.Workbook.Worksheets["ИГЭ"];
|
||||
p.Workbook.Worksheets.Add("ИГЭ", ws1);
|
||||
ExcelWorksheet ws = p.Workbook.Worksheets["ИГЭ"];
|
||||
|
||||
//Save the new workbook. We haven't specified the filename so use the Save as method.
|
||||
ws.Cells["A2"].LoadFromArrays(content);
|
||||
ws.Select();
|
||||
p.SaveAs(new FileInfo(sfd.FileName));
|
||||
}
|
||||
}
|
||||
|
||||
//try
|
||||
//{
|
||||
// using (StreamWriter sw = new StreamWriter(sfd.FileName, false, System.Text.Encoding.Default))
|
||||
// {
|
||||
// foreach (IGE item in listIGE)
|
||||
// {
|
||||
// sw.WriteLine(item.PropsToString());
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//catch (Exception e)
|
||||
//{
|
||||
// Alert(e.Message);
|
||||
//}
|
||||
}
|
||||
|
||||
//Чтение таблицы набора ИГЭ из файла *.csv
|
||||
internal void ReadIGEsFromCsv()
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.DefaultExt = "*.xlsx";
|
||||
ofd.Filter = "Файл Excel (*.xlsx)|*.xlsx";
|
||||
ofd.Title = "Заполнение таблицы";
|
||||
ofd.ShowDialog();
|
||||
|
||||
if (ofd.FileName == null || ofd.FileName == "") return;
|
||||
|
||||
//ListIGE.Clear();
|
||||
|
||||
using (var p = new ExcelPackage(new FileInfo(ofd.FileName)))
|
||||
{
|
||||
//A workbook must have at least on cell, so lets add one...
|
||||
var ws = p.Workbook.Worksheets["ИГЭ"];
|
||||
|
||||
object[,] content = ws.Cells.Value as object[,];
|
||||
List<object> source; IGE item;
|
||||
for (int i = 1; i < content.GetLength(0); i++)
|
||||
{
|
||||
source = new List<object>();
|
||||
for (int j = 0; j < content.GetLength(1); j++)
|
||||
{
|
||||
source.Add(content[i, j]);
|
||||
}
|
||||
item = new IGE(); item.ListToProps(source);
|
||||
ListIGE.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
//OpenFileDialog ofd = new OpenFileDialog();
|
||||
//ofd.DefaultExt = "*.*";
|
||||
//ofd.Filter = "Текстовый файл (*.csv)|*.csv|Все файлы (*.*)|*.*";
|
||||
//ofd.Title = "Заполнение таблицы";
|
||||
//ofd.ShowDialog();
|
||||
|
||||
//if (ofd.FileName == null || ofd.FileName == "") return;
|
||||
|
||||
//ListIGE.Clear();
|
||||
//try
|
||||
//{
|
||||
// using (StreamReader sr = new StreamReader(ofd.FileName, System.Text.Encoding.Default))
|
||||
// {
|
||||
// string line;
|
||||
// IGE ige;
|
||||
// while ((line = sr.ReadLine()) != null)
|
||||
// {
|
||||
// ige = new IGE();
|
||||
// ige.StringToProps(line);
|
||||
// ListIGE.Add(ige);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//catch (Exception e)
|
||||
//{
|
||||
// Alert(e.Message);
|
||||
//}
|
||||
}
|
||||
|
||||
internal void SaveIGEs()
|
||||
{
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.DefaultExt = "*.igedb";
|
||||
sfd.Filter = "Таблица ИГЭ (*.igedb)|*.igedb";
|
||||
sfd.Title = "Сохранение таблицы";
|
||||
//sfd.AddExtension = true;
|
||||
sfd.OverwritePrompt = true;
|
||||
sfd.ShowDialog();
|
||||
|
||||
if (sfd.FileName == null || sfd.FileName == "") return;
|
||||
|
||||
BinaryFormatter formatter = new BinaryFormatter();
|
||||
// получаем поток, куда будем записывать сериализованный объект
|
||||
using (FileStream fs = new FileStream(sfd.FileName, FileMode.OpenOrCreate))
|
||||
{
|
||||
formatter.Serialize(fs, ListIGE);
|
||||
}
|
||||
//Alert("Введенные данные успешно сохранены");
|
||||
}
|
||||
|
||||
internal void ReadIGEs()
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.DefaultExt = "*.igedb";
|
||||
ofd.Filter = "Таблица ИГЭ (*.igedb)|*.igedb";
|
||||
ofd.Title = "Открытие таблицы";
|
||||
ofd.ShowDialog();
|
||||
|
||||
if (ofd.FileName == null || ofd.FileName == "") return;
|
||||
|
||||
if (File.Exists(ofd.FileName) == true)
|
||||
{
|
||||
// создаем объект BinaryFormatter
|
||||
BinaryFormatter formatter = new BinaryFormatter();
|
||||
|
||||
using (FileStream fs = new FileStream(ofd.FileName, FileMode.OpenOrCreate))
|
||||
{
|
||||
List<IGE> tmp = new List<IGE>(ListIGE);
|
||||
tmp.AddRange(formatter.Deserialize(fs) as ObservableCollection<IGE>);
|
||||
ListIGE = new ObservableCollection<IGE>(tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
244
VM/LayersVM.cs
Normal file
244
VM/LayersVM.cs
Normal file
@@ -0,0 +1,244 @@
|
||||
using Microsoft.Win32;
|
||||
using OfficeOpenXml;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GroundOrganizer
|
||||
{
|
||||
public partial class ViewModel : INotifyPropertyChanged
|
||||
{
|
||||
private RelayCommand addLayer;
|
||||
private RelayCommand updateLayer;
|
||||
private RelayCommand renumLayer;
|
||||
private RelayCommand recalcLayerH;
|
||||
private RelayCommand recalcLayerDown;
|
||||
private RelayCommand exportLayersToXLSX;
|
||||
private RelayCommand importLayersFromXLSX;
|
||||
|
||||
int numLayer = 1;
|
||||
ObservableCollection<Layer> listLayer = new ObservableCollection<Layer>();
|
||||
|
||||
public ObservableCollection<Layer> ListLayer { get => listLayer; set { listLayer = value; OnPropertyChanged(); } }
|
||||
|
||||
public RelayCommand AddLayer
|
||||
{
|
||||
get { return addLayer ?? (addLayer = new RelayCommand(obj => { AddLayerToList(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand UpdateLayers
|
||||
{
|
||||
get { return updateLayer ?? (updateLayer = new RelayCommand(obj => { UpdateLayerInList(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand RenumLayers
|
||||
{
|
||||
get { return renumLayer ?? (renumLayer = new RelayCommand(obj => { RenumberingLayerInList(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand RecalcLayerH
|
||||
{
|
||||
get { return recalcLayerH ?? (recalcLayerH = new RelayCommand(obj => { RecalcInLayersH(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand RecalcLayerDown
|
||||
{
|
||||
get { return recalcLayerDown ?? (recalcLayerDown = new RelayCommand(obj => { RecalcInLayersDown(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand ExportLayersToXLSX
|
||||
{
|
||||
get { return exportLayersToXLSX ?? (exportLayersToXLSX = new RelayCommand(obj => { SaveLayersInXlsx(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand ImportLayersFromXLSX
|
||||
{
|
||||
get { return importLayersFromXLSX ?? (importLayersFromXLSX = new RelayCommand(obj => { ReadLayersFromXlsx(); })); }
|
||||
}
|
||||
|
||||
void AddLayerToList()
|
||||
{
|
||||
ListLayer.Add(new Layer() { Number = numLayer }); numLayer++;
|
||||
//CreateListNumberTypeBet();
|
||||
//NameLayer = listLayer[0].Name;
|
||||
}
|
||||
void RenumberingLayerInList()
|
||||
{
|
||||
int j = 1;
|
||||
foreach (Layer item in listLayer)
|
||||
{
|
||||
item.Number = j;
|
||||
j++;
|
||||
}
|
||||
numLayer = j;
|
||||
ListLayer = new ObservableCollection<Layer>(listLayer);
|
||||
}
|
||||
void UpdateLayerInList()
|
||||
{
|
||||
foreach (Layer lay in listLayer)
|
||||
{
|
||||
foreach (IGE ige in listIGE)
|
||||
{
|
||||
if (lay.NumIGE==ige.NumIGE)
|
||||
{
|
||||
lay.IGE = ige.Clone();
|
||||
lay.Description = ige.Description;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
ListLayer = new ObservableCollection<Layer>(listLayer);
|
||||
selectedBore.Layers = listLayer;
|
||||
SaveDB();
|
||||
}
|
||||
|
||||
void RecalcInLayersH()
|
||||
{
|
||||
if (listLayer == null) return;
|
||||
if (listLayer.Count == 0) return;
|
||||
if (selectedBore == null) return;
|
||||
|
||||
UpdateLayerInList();
|
||||
|
||||
double down = 0;
|
||||
double up = 0;
|
||||
double z = selectedBore.Z;
|
||||
foreach (Layer item in listLayer)
|
||||
{
|
||||
z -= item.H;
|
||||
down += item.H;
|
||||
item.Down = down;
|
||||
item.Z = z;
|
||||
item.Up = up;
|
||||
up += item.H;
|
||||
}
|
||||
ListLayer = new ObservableCollection<Layer>(listLayer);
|
||||
}
|
||||
|
||||
void RecalcInLayersDown()
|
||||
{
|
||||
if (listLayer == null) return;
|
||||
if (listLayer.Count == 0) return;
|
||||
if (selectedBore == null) return;
|
||||
|
||||
UpdateLayerInList();
|
||||
|
||||
double up = 0;
|
||||
double z = selectedBore.Z;
|
||||
foreach (Layer item in listLayer)
|
||||
{
|
||||
item.Up = up;
|
||||
item.H = item.Down - item.Up;
|
||||
z -= item.H;
|
||||
item.Z = z;
|
||||
up += item.H;
|
||||
}
|
||||
ListLayer = new ObservableCollection<Layer>(listLayer);
|
||||
}
|
||||
|
||||
//Сохранение таблиц наборов слоев в файл *.xlsx
|
||||
internal void SaveLayersInXlsx()
|
||||
{
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.DefaultExt = "*.xlsx";
|
||||
sfd.Filter = "Файл Excel (*.xlsx)|*.xlsx";
|
||||
sfd.Title = "Сохранение таблицы";
|
||||
//sfd.AddExtension = true;
|
||||
sfd.OverwritePrompt = true;
|
||||
sfd.ShowDialog();
|
||||
|
||||
if (sfd.FileName == null || sfd.FileName == "") return;
|
||||
|
||||
try
|
||||
{
|
||||
string path = "ИГЭ.xlsx";
|
||||
FileInfo fileInf = new FileInfo(path);
|
||||
if (fileInf.Exists != true)
|
||||
{
|
||||
using (FileStream fstream = new FileStream("ИГЭ.xlsx", FileMode.OpenOrCreate))
|
||||
{
|
||||
byte[] array = Properties.Resources.IGE;
|
||||
fstream.Write(array, 0, array.Length);
|
||||
}
|
||||
}
|
||||
|
||||
using (var p = new ExcelPackage(new FileInfo(sfd.FileName)))
|
||||
{
|
||||
for (int i = 0; i < listBore.Count; i++)
|
||||
{
|
||||
List<object[]> content = new List<object[]>();
|
||||
foreach (Layer fli in listBore[i].Layers)
|
||||
{
|
||||
content.Add(fli.PropsToList().ToArray());
|
||||
}
|
||||
ExcelPackage p1 = new ExcelPackage(new FileInfo("ИГЭ.xlsx"));
|
||||
//A workbook must have at least on cell, so lets add one...
|
||||
var ws = p1.Workbook.Worksheets["Слои"];
|
||||
p.Workbook.Worksheets.Add((i + 1).ToString(), ws);
|
||||
var wsi = p.Workbook.Worksheets[i + 1];
|
||||
//To set values in the spreadsheet use the Cells indexer.
|
||||
wsi.Cells["D1"].Value = listBore[i].Name;
|
||||
wsi.Cells["A3"].LoadFromArrays(content);
|
||||
}
|
||||
|
||||
//Save the new workbook. We haven't specified the filename so use the Save as method.
|
||||
p.SaveAs(new FileInfo(sfd.FileName));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Alert(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
//Чтение наборов слоев из файла *.xlsx
|
||||
internal void ReadLayersFromXlsx()
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.DefaultExt = "*.xlsx";
|
||||
ofd.Filter = "Файл Excel (*.xlsx)|*.xlsx";
|
||||
ofd.Title = "Заполнение таблиц";
|
||||
ofd.ShowDialog();
|
||||
|
||||
if (ofd.FileName == null || ofd.FileName == "") return;
|
||||
|
||||
//ListFoundLoad.Clear();
|
||||
try
|
||||
{
|
||||
using (var p = new ExcelPackage(new FileInfo(ofd.FileName)))
|
||||
{
|
||||
int k = 0;
|
||||
foreach (ExcelWorksheet wsi in p.Workbook.Worksheets)
|
||||
{
|
||||
listBore[k].Layers = new ObservableCollection<Layer>();
|
||||
|
||||
object[,] content = wsi.Cells.Value as object[,];
|
||||
List<object> source; Layer item;
|
||||
for (int i = 2; i < content.GetLength(0); i++)
|
||||
{
|
||||
source = new List<object>();
|
||||
for (int j = 0; j < content.GetLength(1); j++)
|
||||
{
|
||||
source.Add(content[i, j]);
|
||||
}
|
||||
item = new Layer(); item.ListToProps(source);
|
||||
listBore[k].Layers.Add(item);
|
||||
SelectedBore = listBore[k];
|
||||
UpdateLayerInList();
|
||||
}
|
||||
k++;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Alert(e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
363
VM/PlanningVM.cs
Normal file
363
VM/PlanningVM.cs
Normal file
@@ -0,0 +1,363 @@
|
||||
using Microsoft.Win32;
|
||||
using netDxf;
|
||||
using netDxf.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TriangleNet;
|
||||
using TriangleNet.Geometry;
|
||||
using TriangleNet.Meshing;
|
||||
using TriangleNet.Tools;
|
||||
|
||||
namespace GroundOrganizer
|
||||
{
|
||||
public partial class ViewModel : INotifyPropertyChanged
|
||||
{
|
||||
private RelayCommand addRedVertex;
|
||||
private RelayCommand addBlackVertex;
|
||||
private RelayCommand updateRedPlanning;
|
||||
private RelayCommand updateBlackPlanning;
|
||||
private RelayCommand renumRedVertexes;
|
||||
private RelayCommand renumBlackVertexes;
|
||||
private RelayCommand importPlanningsFromDXF;
|
||||
private RelayCommand importRedPlanningFromCSV;
|
||||
private RelayCommand importBlackPlanningFromCSV;
|
||||
private RelayCommand exportRedPlanningToCSV;
|
||||
private RelayCommand exportBlackPlanningToCSV;
|
||||
private RelayCommand createRedPlanningMesh;
|
||||
private RelayCommand createBlackPlanningMesh;
|
||||
|
||||
int numVertex = 1;
|
||||
PlanningVertex selectedRedVertex;
|
||||
PlanningVertex selectedBlackVertex;
|
||||
ObservableCollection<PlanningVertex> redPlanning = new ObservableCollection<PlanningVertex>();
|
||||
ObservableCollection<PlanningVertex> blackPlanning = new ObservableCollection<PlanningVertex>();
|
||||
|
||||
public ObservableCollection<PlanningVertex> RedPlanning { get => redPlanning; set { redPlanning = value; OnPropertyChanged(); } }
|
||||
public ObservableCollection<PlanningVertex> BlackPlanning { get => blackPlanning; set { blackPlanning = value; OnPropertyChanged(); } }
|
||||
public PlanningVertex SelectedRedVertex { get => selectedRedVertex; set { selectedRedVertex = value; OnPropertyChanged(); } }
|
||||
public PlanningVertex SelectedBlackVertex { get => selectedBlackVertex; set { selectedBlackVertex = value; OnPropertyChanged(); } }
|
||||
public TriangleNet.Mesh MeshRedPlanning { get; private set; }
|
||||
public TriangleNet.Mesh MeshBlackPlanning { get; private set; }
|
||||
|
||||
|
||||
public RelayCommand AddRedVertex
|
||||
{
|
||||
get { return addRedVertex ?? (addRedVertex = new RelayCommand(obj => { AddRedVertexToList(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand UpdateRedPlanning
|
||||
{
|
||||
get { return updateRedPlanning ?? (updateRedPlanning = new RelayCommand(obj => { UpdateRedVertexesInList(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand RenumRedVertexes
|
||||
{
|
||||
get { return renumRedVertexes ?? (renumRedVertexes = new RelayCommand(obj => { RenumberingRedVertexesInList(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand AddBlackVertex
|
||||
{
|
||||
get { return addBlackVertex ?? (addBlackVertex = new RelayCommand(obj => { AddBlackVertexToList(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand UpdateBlackPlanning
|
||||
{
|
||||
get { return updateBlackPlanning ?? (updateBlackPlanning = new RelayCommand(obj => { UpdateBlackVertexesInList(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand RenumBlackVertexes
|
||||
{
|
||||
get { return renumBlackVertexes ?? (renumBlackVertexes = new RelayCommand(obj => { RenumberingBlackVertexesInList(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand ImportPlanningsFromDXF
|
||||
{
|
||||
get { return importPlanningsFromDXF ?? (importPlanningsFromDXF = new RelayCommand(obj => { ReadPlanningsDXF(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand ImportRedPlanningFromCSV
|
||||
{
|
||||
get { return importRedPlanningFromCSV ?? (importRedPlanningFromCSV = new RelayCommand(obj => { ReadRedPlanningCSV(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand ExportRedPlanningToCSV
|
||||
{
|
||||
get { return exportRedPlanningToCSV ?? (exportRedPlanningToCSV = new RelayCommand(obj => { SaveRedPlanningInCsv(); })); }
|
||||
}
|
||||
|
||||
|
||||
public RelayCommand ImportBlackPlanningFromCSV
|
||||
{
|
||||
get { return importBlackPlanningFromCSV ?? (importBlackPlanningFromCSV = new RelayCommand(obj => { ReadBlackPlanningCSV(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand ExportBlackPlanningToCSV
|
||||
{
|
||||
get { return exportBlackPlanningToCSV ?? (exportBlackPlanningToCSV = new RelayCommand(obj => { SaveBlackPlanningInCsv(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand CreateRedPlanningMesh
|
||||
{
|
||||
get { return createRedPlanningMesh ?? (createRedPlanningMesh = new RelayCommand(obj => { CreateRedMesh(); })); }
|
||||
}
|
||||
|
||||
public RelayCommand CreateBlackPlanningMesh
|
||||
{
|
||||
get { return createBlackPlanningMesh ?? (createBlackPlanningMesh = new RelayCommand(obj => { CreateBlackMesh(); })); }
|
||||
}
|
||||
|
||||
private void ReadRedPlanningCSV()
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.DefaultExt = "*.*";
|
||||
ofd.Filter = "Текстовый файл (*.csv)|*.csv|Все файлы (*.*)|*.*";
|
||||
ofd.Title = "Заполнение таблицы";
|
||||
ofd.ShowDialog();
|
||||
|
||||
if (ofd.FileName == null || ofd.FileName == "") return;
|
||||
|
||||
RedPlanning.Clear();
|
||||
try
|
||||
{
|
||||
using (StreamReader sr = new StreamReader(ofd.FileName, System.Text.Encoding.Default))
|
||||
{
|
||||
string line;
|
||||
PlanningVertex vert;
|
||||
while ((line = sr.ReadLine()) != null)
|
||||
{
|
||||
vert = new PlanningVertex();
|
||||
vert.StringToProps(line);
|
||||
RedPlanning.Add(vert);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Alert(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
internal void SaveRedPlanningInCsv()
|
||||
{
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.DefaultExt = "*.csv";
|
||||
sfd.Filter = "Текстовый файл (*.csv)|*.csv";
|
||||
sfd.Title = "Сохранение таблицы";
|
||||
//sfd.AddExtension = true;
|
||||
sfd.OverwritePrompt = true;
|
||||
sfd.ShowDialog();
|
||||
|
||||
if (sfd.FileName == null || sfd.FileName == "") return;
|
||||
|
||||
try
|
||||
{
|
||||
using (StreamWriter sw = new StreamWriter(sfd.FileName, false, System.Text.Encoding.Default))
|
||||
{
|
||||
foreach (PlanningVertex item in RedPlanning)
|
||||
{
|
||||
sw.WriteLine(item.PropsToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Alert(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void ReadBlackPlanningCSV()
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.DefaultExt = "*.*";
|
||||
ofd.Filter = "Текстовый файл (*.csv)|*.csv|Все файлы (*.*)|*.*";
|
||||
ofd.Title = "Заполнение таблицы";
|
||||
ofd.ShowDialog();
|
||||
|
||||
if (ofd.FileName == null || ofd.FileName == "") return;
|
||||
|
||||
BlackPlanning.Clear();
|
||||
try
|
||||
{
|
||||
using (StreamReader sr = new StreamReader(ofd.FileName, System.Text.Encoding.Default))
|
||||
{
|
||||
string line;
|
||||
PlanningVertex vert;
|
||||
while ((line = sr.ReadLine()) != null)
|
||||
{
|
||||
vert = new PlanningVertex();
|
||||
vert.StringToProps(line);
|
||||
BlackPlanning.Add(vert);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Alert(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
internal void SaveBlackPlanningInCsv()
|
||||
{
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.DefaultExt = "*.csv";
|
||||
sfd.Filter = "Текстовый файл (*.csv)|*.csv";
|
||||
sfd.Title = "Сохранение таблицы";
|
||||
//sfd.AddExtension = true;
|
||||
sfd.OverwritePrompt = true;
|
||||
sfd.ShowDialog();
|
||||
|
||||
if (sfd.FileName == null || sfd.FileName == "") return;
|
||||
|
||||
try
|
||||
{
|
||||
using (StreamWriter sw = new StreamWriter(sfd.FileName, false, System.Text.Encoding.Default))
|
||||
{
|
||||
foreach (PlanningVertex item in BlackPlanning)
|
||||
{
|
||||
sw.WriteLine(item.PropsToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Alert(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void ReadPlanningsDXF()
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.DefaultExt = "*.dxf";
|
||||
ofd.Filter = "Чертеж (*.dxf)|*.dxf";
|
||||
ofd.Title = "Импорт чертежа";
|
||||
ofd.ShowDialog();
|
||||
|
||||
if (ofd.FileName == null || ofd.FileName == "") return;
|
||||
if (selectedStructure == null) return;
|
||||
RedPlanning.Clear(); BlackPlanning.Clear();
|
||||
DxfDocument dxfDocument = DxfDocument.Load(ofd.FileName);
|
||||
IEnumerable<Text> dxfTexts = dxfDocument.Texts;
|
||||
PlanningVertex vert; int j = 1; int k = 1;
|
||||
foreach (Text item in dxfTexts)
|
||||
{
|
||||
if (item.Layer.Name == "Red")
|
||||
{
|
||||
vert = new PlanningVertex
|
||||
{
|
||||
X = Math.Round(item.Position.X * 0.001, 3),
|
||||
Y = Math.Round(item.Position.Y * 0.001, 3),
|
||||
Number = j,
|
||||
Red = double.Parse(item.Value)
|
||||
};
|
||||
RedPlanning.Add(vert);
|
||||
j++;
|
||||
}
|
||||
else if (item.Layer.Name == "Black")
|
||||
{
|
||||
vert = new PlanningVertex
|
||||
{
|
||||
X = Math.Round(item.Position.X * 0.001, 3),
|
||||
Y = Math.Round(item.Position.Y * 0.001, 3),
|
||||
Number = k,
|
||||
Black = double.Parse(item.Value)
|
||||
};
|
||||
BlackPlanning.Add(vert);
|
||||
k++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AddRedVertexToList()
|
||||
{
|
||||
RedPlanning.Add(new PlanningVertex() { Number = numVertex }); numVertex++;
|
||||
//NameStructure = listStructure[0].Name;
|
||||
}
|
||||
void RenumberingRedVertexesInList()
|
||||
{
|
||||
int j = 1;
|
||||
foreach (PlanningVertex item in RedPlanning)
|
||||
{
|
||||
item.Number = j;
|
||||
j++;
|
||||
}
|
||||
numVertex = j;
|
||||
RedPlanning = new ObservableCollection<PlanningVertex>(RedPlanning);
|
||||
}
|
||||
void UpdateRedVertexesInList()
|
||||
{
|
||||
RedPlanning = new ObservableCollection<PlanningVertex>(RedPlanning);
|
||||
SaveDB();
|
||||
}
|
||||
|
||||
void AddBlackVertexToList()
|
||||
{
|
||||
BlackPlanning.Add(new PlanningVertex() { Number = numVertex }); numVertex++;
|
||||
//NameStructure = listStructure[0].Name;
|
||||
}
|
||||
void RenumberingBlackVertexesInList()
|
||||
{
|
||||
int j = 1;
|
||||
foreach (PlanningVertex item in BlackPlanning)
|
||||
{
|
||||
item.Number = j;
|
||||
j++;
|
||||
}
|
||||
numVertex = j;
|
||||
BlackPlanning = new ObservableCollection<PlanningVertex>(BlackPlanning);
|
||||
}
|
||||
void UpdateBlackVertexesInList()
|
||||
{
|
||||
BlackPlanning = new ObservableCollection<PlanningVertex>(BlackPlanning);
|
||||
SaveDB();
|
||||
}
|
||||
|
||||
internal void CreateRedMesh()
|
||||
{
|
||||
if (selectedStructure == null || selectedStructure.RedPlanning == null || selectedStructure.RedPlanning.Count == 0) return;
|
||||
|
||||
Polygon polygon = new Polygon();
|
||||
Vertex vrtx;
|
||||
int i = 1;
|
||||
foreach (PlanningVertex item in selectedStructure.RedPlanning)
|
||||
{
|
||||
vrtx = new Vertex(item.X, item.Y, item.Number, 1);
|
||||
vrtx.Attributes[0] = item.Red;
|
||||
polygon.Add(vrtx);
|
||||
i++;
|
||||
}
|
||||
GenericMesher mesher = new GenericMesher();
|
||||
ConstraintOptions constraint = new ConstraintOptions();
|
||||
constraint.Convex = true;
|
||||
MeshRedPlanning = (TriangleNet.Mesh)mesher.Triangulate(polygon, constraint);
|
||||
Alert("\"Красная\" триангуляционная сеть создана");
|
||||
}
|
||||
|
||||
internal void CreateBlackMesh()
|
||||
{
|
||||
if (selectedStructure == null || selectedStructure.BlackPlanning == null || selectedStructure.BlackPlanning.Count == 0) return;
|
||||
|
||||
Polygon polygon = new Polygon();
|
||||
Vertex vrtx;
|
||||
int i = 1;
|
||||
foreach (PlanningVertex item in selectedStructure.BlackPlanning)
|
||||
{
|
||||
vrtx = new Vertex(item.X, item.Y, item.Number, 1);
|
||||
vrtx.Attributes[0] = item.Black;
|
||||
polygon.Add(vrtx);
|
||||
i++;
|
||||
}
|
||||
GenericMesher mesher = new GenericMesher();
|
||||
ConstraintOptions constraint = new ConstraintOptions();
|
||||
constraint.Convex = true;
|
||||
MeshBlackPlanning = (TriangleNet.Mesh)mesher.Triangulate(polygon, constraint);
|
||||
Alert("\"Черная\" триангуляционная сеть создана");
|
||||
}
|
||||
}
|
||||
}
|
||||
87
VM/PlayGroundVM.cs
Normal file
87
VM/PlayGroundVM.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GroundOrganizer
|
||||
{
|
||||
public partial class ViewModel : INotifyPropertyChanged
|
||||
{
|
||||
int numPG = 1;
|
||||
PlayGround selectedPlayGround;
|
||||
string namePlayGround;
|
||||
ObservableCollection<PlayGround> listPlayGround = new ObservableCollection<PlayGround>();
|
||||
|
||||
public ObservableCollection<PlayGround> ListPlayGround { get => listPlayGround; set { listPlayGround = value; OnPropertyChanged(); } }
|
||||
public string NamePlayGround { get => namePlayGround; set { namePlayGround = value; OnPropertyChanged(); } }
|
||||
public PlayGround SelectedPlayGround { get => selectedPlayGround; set { selectedPlayGround = value; OnPropertyChanged(); ChangeSelectedPlayGround(); } }
|
||||
|
||||
private RelayCommand addPlayGround;
|
||||
public RelayCommand AddPlayGround
|
||||
{
|
||||
get { return addPlayGround ?? (addPlayGround = new RelayCommand(obj => { AddPlayGroundToList(); })); }
|
||||
}
|
||||
|
||||
private RelayCommand updatePlayGround;
|
||||
public RelayCommand UpdatePlayGrounds
|
||||
{
|
||||
get { return updatePlayGround ?? (updatePlayGround = new RelayCommand(obj => { UpdatePlayGroundInList(); })); }
|
||||
}
|
||||
|
||||
private RelayCommand renumPlayGround;
|
||||
public RelayCommand RenumPlayGrounds
|
||||
{
|
||||
get { return renumPlayGround ?? (renumPlayGround = new RelayCommand(obj => { RenumberingPlayGroundInList(); })); }
|
||||
}
|
||||
|
||||
void AddPlayGroundToList()
|
||||
{
|
||||
ListPlayGround.Add(new PlayGround() { Number = numPG }); numPG++;
|
||||
//CreateListNumberTypeBet();
|
||||
//NamePlayGround = listPlayGround[0].Name;
|
||||
}
|
||||
void RenumberingPlayGroundInList()
|
||||
{
|
||||
int j = 1;
|
||||
foreach (PlayGround item in ListPlayGround)
|
||||
{
|
||||
item.Number = j;
|
||||
j++;
|
||||
}
|
||||
numPG = j;
|
||||
ListPlayGround = new ObservableCollection<PlayGround>(ListPlayGround);
|
||||
}
|
||||
void UpdatePlayGroundInList()
|
||||
{
|
||||
ListPlayGround = new ObservableCollection<PlayGround>(ListPlayGround);
|
||||
SaveDB();
|
||||
}
|
||||
|
||||
//void ChangeSelClassBet()
|
||||
//{
|
||||
// //if (selectedBet==null) return;
|
||||
// CreateListNumberTypeBet();
|
||||
//}
|
||||
|
||||
//void CreateListNumberTypeBet()
|
||||
//{
|
||||
// //listNumberTypeArm = new List<int>();
|
||||
// ListNumberTypeBet = from bet in listBet select bet.Id;
|
||||
//}
|
||||
|
||||
void ChangeSelectedPlayGround()
|
||||
{
|
||||
if (listPlayGround.Count == 0 || selectedPlayGround == null) return;
|
||||
NamePlayGround = SelectedPlayGround.Name;
|
||||
ListIGE = selectedPlayGround.IGEs;
|
||||
ListBore = selectedPlayGround.Bores;
|
||||
ListStructure = selectedPlayGround.Structures;
|
||||
CreateListNumIGEs();
|
||||
CreateListShemas();
|
||||
CreateListTypeFoundations();
|
||||
}
|
||||
}
|
||||
}
|
||||
38
VM/RelayCommand.cs
Normal file
38
VM/RelayCommand.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace GroundOrganizer
|
||||
{
|
||||
public class RelayCommand : ICommand
|
||||
{
|
||||
private Action<object> execute;
|
||||
private Func<object, bool> canExecute;
|
||||
|
||||
public event EventHandler CanExecuteChanged
|
||||
{
|
||||
add { CommandManager.RequerySuggested += value; }
|
||||
remove { CommandManager.RequerySuggested -= value; }
|
||||
}
|
||||
|
||||
public RelayCommand(Action<object> execute, Func<object, bool> canExecute = null)
|
||||
{
|
||||
this.execute = execute;
|
||||
this.canExecute = canExecute;
|
||||
}
|
||||
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
return this.canExecute == null || this.canExecute(parameter);
|
||||
}
|
||||
|
||||
public void Execute(object parameter)
|
||||
{
|
||||
this.execute(parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
96
VM/StructuresVM.cs
Normal file
96
VM/StructuresVM.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GroundOrganizer
|
||||
{
|
||||
public partial class ViewModel : INotifyPropertyChanged
|
||||
{
|
||||
int numStructure = 1;
|
||||
string nameStructure;
|
||||
private string structureNote;
|
||||
Structure selectedStructure;
|
||||
ObservableCollection<Structure> listStructure = new ObservableCollection<Structure>();
|
||||
|
||||
public ObservableCollection<Structure> ListStructure { get => listStructure; set { listStructure = value; OnPropertyChanged(); } }
|
||||
|
||||
private IEnumerable<TypeFlexStructure> listShemas;
|
||||
public IEnumerable<TypeFlexStructure> ListShemas { get => listShemas; set { listShemas = value; OnPropertyChanged(); } }
|
||||
public string StructureNote { get => structureNote; set { structureNote = value; OnPropertyChanged(); } }
|
||||
|
||||
private RelayCommand addStructure;
|
||||
public RelayCommand AddStructure
|
||||
{
|
||||
get { return addStructure ?? (addStructure = new RelayCommand(obj => { AddStructureToList(); })); }
|
||||
}
|
||||
|
||||
private RelayCommand updateStructure;
|
||||
public RelayCommand UpdateStructures
|
||||
{
|
||||
get { return updateStructure ?? (updateStructure = new RelayCommand(obj => { UpdateStructureInList(); })); }
|
||||
}
|
||||
|
||||
private RelayCommand renumStructure;
|
||||
|
||||
public RelayCommand RenumStructures
|
||||
{
|
||||
get { return renumStructure ?? (renumStructure = new RelayCommand(obj => { RenumberingStructureInList(); })); }
|
||||
}
|
||||
|
||||
public Structure SelectedStructure { get => selectedStructure; set { selectedStructure = value; OnPropertyChanged(); ChangeSelectedStructure(); } }
|
||||
|
||||
public string NameStructure { get => nameStructure; set { nameStructure = value; OnPropertyChanged(); } }
|
||||
|
||||
void AddStructureToList()
|
||||
{
|
||||
ListStructure.Add(new Structure() { Number = numStructure }); numStructure++;
|
||||
//NameStructure = listStructure[0].Name;
|
||||
}
|
||||
void RenumberingStructureInList()
|
||||
{
|
||||
int j = 1;
|
||||
foreach (Structure item in ListStructure)
|
||||
{
|
||||
item.Number = j;
|
||||
j++;
|
||||
}
|
||||
numStructure = j;
|
||||
ListStructure = new ObservableCollection<Structure>(ListStructure);
|
||||
}
|
||||
void UpdateStructureInList()
|
||||
{
|
||||
ListStructure = new ObservableCollection<Structure>(ListStructure);
|
||||
SaveDB();
|
||||
}
|
||||
|
||||
void ChangeSelectedStructure()
|
||||
{
|
||||
if (listStructure.Count == 0 || selectedStructure == null) return;
|
||||
NameStructure = selectedStructure.Name;
|
||||
ListFoundation = selectedStructure.Foundations;
|
||||
RedPlanning = selectedStructure.RedPlanning;
|
||||
BlackPlanning = selectedStructure.BlackPlanning;
|
||||
if (redPlanning == null) RedPlanning = new ObservableCollection<PlanningVertex>();
|
||||
if (blackPlanning == null) BlackPlanning = new ObservableCollection<PlanningVertex>();
|
||||
}
|
||||
|
||||
void CreateListShemas()
|
||||
{
|
||||
if (listStructure == null || listPlayGround == null) return;
|
||||
ListShemas = new List<TypeFlexStructure>() { TypeFlexStructure.Гибкая, TypeFlexStructure.Жесткая };
|
||||
try
|
||||
{
|
||||
StructuresPage structuresPage = (StructuresPage)MW.StructuresFrame.Content;
|
||||
structuresPage.flexListCbxCol.ItemsSource = listShemas;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
131
VM/UnitsViewModel .cs
Normal file
131
VM/UnitsViewModel .cs
Normal file
@@ -0,0 +1,131 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GroundOrganizer
|
||||
{
|
||||
public partial class ViewModel : INotifyPropertyChanged
|
||||
{
|
||||
UnitsLin[] unitsL = { UnitsLin.м, UnitsLin.см, UnitsLin.мм };
|
||||
UnitsArea[] unitsA = { UnitsArea.м, UnitsArea.см, UnitsArea.мм };
|
||||
UnitsForce[] unitsF = { UnitsForce.т, UnitsForce.кН, UnitsForce.Н };
|
||||
UnitsStress[] unitsS = { UnitsStress.т, UnitsStress.кН, UnitsStress.Н, UnitsStress.МПа, UnitsStress.кПа };
|
||||
UnitsLin unitsLId = UnitsLin.м;
|
||||
UnitsLin unitsSectId = UnitsLin.см;
|
||||
UnitsLin unitsDarmId = UnitsLin.мм;
|
||||
UnitsArea unitsAarmId = UnitsArea.см;
|
||||
UnitsArea unitsAMatId = UnitsArea._;
|
||||
UnitsLin unitsLForcId = UnitsLin.м;
|
||||
UnitsArea unitsAStressId = UnitsArea._;
|
||||
UnitsLin unitsCrackId = UnitsLin.мм;
|
||||
UnitsStress unitsSMatId = UnitsStress.МПа;
|
||||
UnitsStress unitsSStressId = UnitsStress.МПа;
|
||||
UnitsForce unitsFForceId = UnitsForce.кН;
|
||||
internal double scaleDimLength = 1;
|
||||
internal double scaleDimSect = 0.01;
|
||||
internal double scaleDimDarm = 0.001;
|
||||
internal double scaleDimAarm = 0.0001;
|
||||
internal double scaleDimLfrc = 1;
|
||||
internal double scaleDimFfrc = 1;
|
||||
internal double scaleDimStress = 0.001;
|
||||
internal double scaleDimMat = 0.001;
|
||||
internal double scaleDimCrack = 0.001;
|
||||
|
||||
public UnitsLin[] UnitsL { get => unitsL; set => unitsL = value; }
|
||||
public UnitsArea[] UnitsA { get => unitsA; set => unitsA = value; }
|
||||
public UnitsForce[] UnitsF { get => unitsF; set => unitsF = value; }
|
||||
public UnitsStress[] UnitsS { get => unitsS; set => unitsS = value; }
|
||||
|
||||
public UnitsLin UnitsLId { get => unitsLId; set { unitsLId = value; OnPropertyChanged(); ChangeUnits(); } }
|
||||
public UnitsLin UnitsSectId { get => unitsSectId; set { unitsSectId = value; OnPropertyChanged(); ChangeUnits(); } }
|
||||
public UnitsLin UnitsDarmId { get => unitsDarmId; set { unitsDarmId = value; OnPropertyChanged(); ChangeUnits(); } }
|
||||
public UnitsArea UnitsAarmId { get => unitsAarmId; set { unitsAarmId = value; OnPropertyChanged(); ChangeUnits(); } }
|
||||
public UnitsArea UnitsAMatId { get => unitsAMatId; set { unitsAMatId = value; OnPropertyChanged(); ChangeUnits(); } }
|
||||
public UnitsLin UnitsLForcId { get => unitsLForcId; set { unitsLForcId = value; OnPropertyChanged(); ChangeUnits(); } }
|
||||
public UnitsArea UnitsAStressId { get => unitsAStressId; set { unitsAStressId = value; OnPropertyChanged(); ChangeUnits(); } }
|
||||
public UnitsLin UnitsCrackId { get => unitsCrackId; set { unitsCrackId = value; OnPropertyChanged(); ChangeUnits(); } }
|
||||
public UnitsForce UnitsFForceId { get => unitsFForceId; set { unitsFForceId = value; OnPropertyChanged(); ChangeUnits(); } }
|
||||
public UnitsStress UnitsSMatId { get => unitsSMatId; set { unitsSMatId = value; OnPropertyChanged(); ChangeUnits();
|
||||
if (value == UnitsStress.МПа || value == UnitsStress.кПа) UnitsAMatId = UnitsArea._; } }
|
||||
public UnitsStress UnitsSStressId { get => unitsSStressId; set { unitsSStressId = value; OnPropertyChanged(); ChangeUnits();
|
||||
if (value == UnitsStress.МПа || value == UnitsStress.кПа) UnitsAStressId = UnitsArea._; } }
|
||||
|
||||
|
||||
void ChangeUnits()
|
||||
{
|
||||
scaleDimAarm = ScaleAUnits(unitsAarmId);
|
||||
scaleDimCrack = ScaleLUnits(unitsCrackId);
|
||||
scaleDimDarm = ScaleLUnits(unitsDarmId);
|
||||
scaleDimFfrc = ScaleFUnits(unitsFForceId);
|
||||
scaleDimLength = ScaleLUnits(unitsLId);
|
||||
scaleDimLfrc = ScaleLUnits(unitsLForcId);
|
||||
scaleDimSect = ScaleLUnits(unitsSectId);
|
||||
scaleDimMat = ScaleSUnits(unitsSMatId,unitsAMatId);
|
||||
scaleDimStress = ScaleSUnits(unitsSStressId, unitsAStressId);
|
||||
//Bfloat = B / scaleDimSect;
|
||||
//Hfloat = H / scaleDimSect;
|
||||
//Dfloat = D / scaleDimSect;
|
||||
//D1float = D1 / scaleDimSect;
|
||||
}
|
||||
|
||||
void ChangeValues()
|
||||
{
|
||||
//B = bfloat * scaleDimSect;
|
||||
//H = hfloat * scaleDimSect;
|
||||
//D = dfloat * scaleDimSect;
|
||||
//D1 = d1float * scaleDimSect;
|
||||
}
|
||||
|
||||
double ScaleLUnits(UnitsLin unit)
|
||||
{
|
||||
double res = 1;
|
||||
switch (unit)
|
||||
{
|
||||
case UnitsLin.мм: res = 1E-3; break;
|
||||
case UnitsLin.см: res = 1E-2; break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
double ScaleAUnits(UnitsArea unit)
|
||||
{
|
||||
double res = 1;
|
||||
switch (unit)
|
||||
{
|
||||
case UnitsArea.мм: res = 1E-6; break;
|
||||
case UnitsArea.см: res = 1E-4; break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
double ScaleFUnits(UnitsForce unit)
|
||||
{
|
||||
double res = 1;
|
||||
switch (unit)
|
||||
{
|
||||
case UnitsForce.Н: res = 1E+3; break;
|
||||
case UnitsForce.т: res = 0.10194; break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
double ScaleSUnits(UnitsStress unitS, UnitsArea unitA)
|
||||
{
|
||||
double res = 1;
|
||||
if (unitS == UnitsStress.кН && unitA == UnitsArea.см) res = 1E-4;
|
||||
if (unitS == UnitsStress.кН && unitA == UnitsArea.мм) res = 1E-6;
|
||||
if (unitS == UnitsStress.Н && unitA == UnitsArea.м) res = 1E+3;
|
||||
if (unitS == UnitsStress.Н && unitA == UnitsArea.см) res = 0.1;
|
||||
if (unitS == UnitsStress.Н && unitA == UnitsArea.мм) res = 1E-3;
|
||||
if (unitS == UnitsStress.т && unitA == UnitsArea.м) res = 0.10194;
|
||||
if (unitS == UnitsStress.т && unitA == UnitsArea.см) res = 1E-5;
|
||||
if (unitS == UnitsStress.т && unitA == UnitsArea.мм) res = 1.01937E-7;
|
||||
if (unitS == UnitsStress.МПа) res = 1E-3;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
101
VM/ViewModel.cs
Normal file
101
VM/ViewModel.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace GroundOrganizer
|
||||
{
|
||||
public partial class ViewModel : INotifyPropertyChanged
|
||||
{
|
||||
string title;
|
||||
ToSerializ ser = new ToSerializ();
|
||||
MainWindow MW;
|
||||
//MainPage MP;
|
||||
private string basePath;
|
||||
|
||||
public string BasePath { get => basePath; set { basePath = value; OnPropertyChanged(); } }
|
||||
|
||||
public ViewModel()
|
||||
{
|
||||
title = "GroundOrganizer";
|
||||
MW = App.Current.MainWindow as MainWindow;
|
||||
//MW.contentFrame.Content = MP;
|
||||
MW.Title = title;
|
||||
BasePath = Properties.Settings.Default.BasePath;
|
||||
StructureNote = "к числу зданий и сооружений с жесткой конструктивной схемой относятся:" +
|
||||
"\n- здания панельные, блочные и кирпичные, в которых междуэтажные" +
|
||||
"\nперекрытия опираются по всему контуру на поперечные и продольные" +
|
||||
"\nстены или только на поперечные несущие стены при малом их шаге;" +
|
||||
"\n- сооружения типа башен, силосных корпусов, дымовых труб, домен и др.";
|
||||
BoresNote = "* положительное значение отметки уровня грунтовых вод относительно устья скважины";
|
||||
|
||||
}
|
||||
|
||||
private RelayCommand openGroundBase;
|
||||
public RelayCommand OpenGroundBase
|
||||
{
|
||||
get { return openGroundBase ?? (openGroundBase = new RelayCommand(obj => { ReadDB(); })); }
|
||||
}
|
||||
|
||||
public string Title { get => title; set => title = value; }
|
||||
|
||||
string GetGroundBaseFile()
|
||||
{
|
||||
Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
|
||||
ofd.DefaultExt = "*.*";
|
||||
ofd.Filter = "База данных инженерно-геологических площадок (*.grndb)|*.grndb|Все файлы (*.*)|*.*";
|
||||
ofd.Title = "Выбор файла с базой данных инженерно-геологических площадок";
|
||||
ofd.ShowDialog();
|
||||
return ofd.FileName;
|
||||
}
|
||||
|
||||
internal void SaveDB()
|
||||
{
|
||||
//ser = new ToSerializ { PlayGroundList = ListPlayGround };
|
||||
// создаем объект BinaryFormatter
|
||||
BinaryFormatter formatter = new BinaryFormatter();
|
||||
// получаем поток, куда будем записывать сериализованный объект
|
||||
using (FileStream fs = new FileStream(Properties.Settings.Default.BasePath, FileMode.OpenOrCreate))
|
||||
{
|
||||
formatter.Serialize(fs, ListPlayGround);
|
||||
}
|
||||
//Alert("Введенные данные успешно сохранены");
|
||||
}
|
||||
|
||||
internal void ReadDB()
|
||||
{
|
||||
Properties.Settings.Default.BasePath = GetGroundBaseFile();
|
||||
Properties.Settings.Default.Save();
|
||||
BasePath = Properties.Settings.Default.BasePath;
|
||||
if (File.Exists(Properties.Settings.Default.BasePath) == true)
|
||||
{
|
||||
// создаем объект BinaryFormatter
|
||||
BinaryFormatter formatter = new BinaryFormatter();
|
||||
|
||||
using (FileStream fs = new FileStream(Properties.Settings.Default.BasePath, FileMode.OpenOrCreate))
|
||||
{
|
||||
//ToSerializ ser = (ToSerializ)formatter.Deserialize(fs);
|
||||
ListPlayGround = formatter.Deserialize(fs) as ObservableCollection<PlayGround>;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
public void OnPropertyChanged([CallerMemberName]string prop = "")
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(prop));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user