Merge pull request #5 from RedikultsevEvg/PrimitivePropsEdit

Primitive props edit
This commit is contained in:
RedikultsevEvg
2024-01-30 11:58:44 +05:00
committed by GitHub
948 changed files with 34889 additions and 1935 deletions

1
.gitignore vendored
View File

@@ -2,3 +2,4 @@
*\bin
*\packages
*\.vs
**\publish

View File

@@ -1,13 +0,0 @@
<Application x:Class="StructureHelper.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:StructureHelper"
StartupUri="Windows/MainWindow/MainView.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Infrastructure/UI/Styles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

View File

@@ -1,11 +0,0 @@
using System.Windows;
namespace StructureHelper
{
/// <summary>
/// Логика взаимодействия для App.xaml
/// </summary>
public partial class App : Application
{
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Windows.Media;
using System.Text;
namespace FieldVisualizer.Entities.ColorMaps
{
public class ColorMap : IColorMap
{
public string Name { get; set; }
public List<Color> Colors { get; set; }
}
}

View File

@@ -0,0 +1,89 @@
using FieldVisualizer.InfraStructures.Enums;
using FieldVisualizer.InfraStructures.Exceptions;
using FieldVisualizer.InfraStructures.Strings;
using System;
using System.Collections.Generic;
using System.Windows.Media;
namespace FieldVisualizer.Entities.ColorMaps.Factories
{
/// <summary>
/// Factory for creating of different color maps
/// </summary>
public static class ColorMapFactory
{
public static IColorMap GetColorMap(ColorMapsTypes mapsTypes)
{
if (mapsTypes == ColorMapsTypes.FullSpectrum) { return GetFullSpectrum(); }
if (mapsTypes == ColorMapsTypes.RedToWhite) { return GetRedToWhite(); }
if (mapsTypes == ColorMapsTypes.RedToBlue) { return GetRedToBlue(); }
if (mapsTypes == ColorMapsTypes.BlueToWhite) { return GetBlueToWhite(); }
else { throw new FieldVisulizerException(ErrorStrings.ColorMapTypeIsUnknown); }
}
private static IColorMap GetFullSpectrum()
{
ColorMap colorMap = new ColorMap();
colorMap.Name = "FullSpectrumColorMap";
List<Color> colors = new List<Color>();
byte Alpha = 0xff;
colors.AddRange(new Color[]{
Color.FromArgb(Alpha, 0xFF, 0x80, 0x80) ,//
Color.FromArgb(Alpha, 0xFF, 0, 0x80) ,//
Color.FromArgb(Alpha, 0xFF, 0, 0) ,//Red
Color.FromArgb(Alpha, 0xFF, 0x45, 0) ,//Orange Red
Color.FromArgb(Alpha, 0xFF, 0xD7, 0) ,//Gold
Color.FromArgb(Alpha, 0xFF, 0xFF, 0) ,//Yellow
Color.FromArgb(Alpha, 0x9A, 0xCD, 0x32) ,//Yellow Green
Color.FromArgb(Alpha, 0, 0x80, 0) ,//Green
Color.FromArgb(Alpha, 0, 0x64, 0) ,//Dark Green
Color.FromArgb(Alpha, 0x2F, 0x4F, 0x4F) ,//Dark Slate Gray
Color.FromArgb(Alpha, 0, 0, 0xFF) ,//Blue
});
colorMap.Colors = colors;
return colorMap;
}
private static IColorMap GetRedToWhite()
{
ColorMap colorMap = new ColorMap();
colorMap.Name = "FullSpectrumColorMap";
List<Color> colors = new List<Color>();
byte Alpha = 0xff;
colors.AddRange(new Color[]{
Color.FromArgb(Alpha, 0xFF, 0, 0) ,//Red
Color.FromArgb(Alpha, 0xFF, 0xFF, 0xFF) ,//White
});
colorMap.Colors = colors;
return colorMap;
}
private static IColorMap GetRedToBlue()
{
ColorMap colorMap = new ColorMap();
colorMap.Name = "FullSpectrumColorMap";
List<Color> colors = new List<Color>();
byte Alpha = 0xff;
colors.AddRange(new Color[]{
Color.FromArgb(Alpha, 0xFF, 0, 0) ,//Red
Color.FromArgb(Alpha, 0, 0, 0xFF) ,//Blue
});
colorMap.Colors = colors;
return colorMap;
}
private static IColorMap GetBlueToWhite()
{
ColorMap colorMap = new ColorMap();
colorMap.Name = "FullSpectrumColorMap";
List<Color> colors = new List<Color>();
byte Alpha = 0xff;
colors.AddRange(new Color[]{
Color.FromArgb(Alpha, 0, 0, 0xFF) ,//Blue
Color.FromArgb(Alpha, 0xFF, 0xFF, 0xFF) ,//White
});
colorMap.Colors = colors;
return colorMap;
}
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Windows.Media;
using System.Text;
namespace FieldVisualizer.Entities.ColorMaps
{
public interface IColorMap
{
string Name { get;}
List<Color> Colors { get; }
}
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace FieldVisualizer.Entities.ColorMaps
{
public interface IValueColorRange
{
bool IsActive { get; set; }
double BottomValue { get; set; }
double AverageValue { get; set; }
double TopValue {get;set;}
Color BottomColor { get; set; }
Color TopColor { get; set; }
}
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace FieldVisualizer.Entities.ColorMaps
{
public class ValueColorRange : IValueColorRange
{
public bool IsActive { get; set; }
public double BottomValue { get; set; }
public double AverageValue { get; set; }
public double TopValue { get; set; }
public Color BottomColor { get; set; }
public Color TopColor { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace FieldVisualizer.Entities.Values
{
public interface IValueRange
{
double TopValue { get; set; }
double BottomValue { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FieldVisualizer.Entities.Values.Primitives
{
public class CirclePrimitive : ICirclePrimitive
{
public double Diameter { get; set; }
public double Value { get; set; }
public double CenterX { get; set; }
public double CenterY { get; set; }
public double Area => Math.PI * Math.Pow(Diameter, 2) / 4;
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FieldVisualizer.Entities.Values.Primitives
{
public interface ICenter
{
double CenterX { get;}
double CenterY { get;}
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FieldVisualizer.Entities.Values.Primitives
{
/// <summary>
/// Represent circle primitive
/// </summary>
public interface ICirclePrimitive : IValuePrimitive
{
double Diameter { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FieldVisualizer.Entities.Values.Primitives
{
public interface IPrimitiveSet
{
string Name { get; }
IEnumerable<IValuePrimitive> ValuePrimitives { get; }
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FieldVisualizer.Entities.Values.Primitives
{
internal interface IRectanglePrimitive : IValuePrimitive
{
double Height { get; set; }
double Width { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FieldVisualizer.Entities.Values.Primitives
{
public interface IValuePrimitive
{
double Value { get; }
double CenterX { get; }
double CenterY { get; }
double Area { get; }
}
}

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FieldVisualizer.Entities.Values.Primitives
{
public class PrimitiveSet : IPrimitiveSet
{
public string Name { get; set; }
public IEnumerable<IValuePrimitive> ValuePrimitives { get; set;}
public PrimitiveSet()
{
Name = "New set of primitives";
ValuePrimitives = new List<IValuePrimitive>();
}
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FieldVisualizer.Entities.Values.Primitives
{
public class RectanglePrimitive : IRectanglePrimitive
{
public double Height { get; set; }
public double Width { get; set; }
public double Value { get; set; }
public double CenterX { get; set; }
public double CenterY { get; set; }
public double Area => Height * Width;
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace FieldVisualizer.Entities.Values
{
public class ValueRange : IValueRange
{
public double TopValue { get; set; }
public double BottomValue { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows7.0</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<ImplicitUsings>disable</ImplicitUsings>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

View File

@@ -0,0 +1,27 @@
using System;
using System.Windows.Input;
namespace FieldVisualizer.Infrastructure.Commands
{
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) => canExecute == null || canExecute(parameter);
public void Execute(object parameter) => execute(parameter);
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace FieldVisualizer.InfraStructures.Enums
{
public enum ColorMapsTypes
{
FullSpectrum = 0,
RedToWhite = 1,
RedToBlue = 2,
BlueToWhite = 3
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace FieldVisualizer.InfraStructures.Exceptions
{
public class FieldVisulizerException : Exception
{
public FieldVisulizerException(string errorString) : base(errorString)
{
}
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace FieldVisualizer.InfraStructures.Strings
{
public static class ErrorStrings
{
public static string ColorMapTypeIsUnknown => "#0001: ColorMap type is unknown";
public static string PrimitiveTypeIsUnknown => "#0002: Type of primitive is unknown";
}
}

View File

@@ -0,0 +1,63 @@
using FieldVisualizer.Entities.ColorMaps;
using FieldVisualizer.Entities.Values;
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Media;
namespace FieldVisualizer.Services.ColorServices
{
public static class ColorOperations
{
const byte Alpha = 0xff;
public static Color GetColorByValue(IValueRange range, IColorMap map, double val)
{
if (range.TopValue == range.BottomValue || map.Colors.Count == 0) { return map.Colors[0]; }
double minVal = range.BottomValue - 1e-15d*(Math.Abs(range.BottomValue));
double maxVal = range.TopValue + 1e-15d * (Math.Abs(range.TopValue));
if (val > maxVal || val < minVal) { return Colors.Gray; }
if (val == minVal) { return map.Colors[0]; }
if (val == maxVal) { return map.Colors[map.Colors.Count - 1]; }
double valPerc = (val - minVal) / (maxVal - minVal);// value%
if (valPerc >= 1d)
{ return map.Colors[map.Colors.Count - 1]; }
double colorPerc = 1d / (map.Colors.Count - 1d); // % of each block of color. the last is the "100% Color"
double blockOfColor = valPerc / colorPerc;// the integer part repersents how many block to skip
int blockIdx = (int)Math.Truncate(blockOfColor);// Idx of
double valPercResidual = valPerc - (blockIdx * colorPerc);//remove the part represented of block
double percOfColor = valPercResidual / colorPerc;// % of color of this block that will be filled
Color cTarget = map.Colors[blockIdx];
Color cNext = map.Colors[blockIdx + 1];
var deltaR = cNext.R - cTarget.R;
var deltaG = cNext.G - cTarget.G;
var deltaB = cNext.B - cTarget.B;
var R = cTarget.R + (deltaR * percOfColor);
var G = cTarget.G + (deltaG * percOfColor);
var B = cTarget.B + (deltaB * percOfColor);
Color c = map.Colors[0];
c = Color.FromArgb(Alpha, (byte)R, (byte)G, (byte)B);
return c;
}
public static IEnumerable<IValueColorRange> GetValueColorRanges(IValueRange fullRange, IEnumerable<IValueRange> valueRanges, IColorMap colorMap)
{
var colorRanges = new List<IValueColorRange>();
foreach (var valueRange in valueRanges)
{
IValueColorRange valueColorRange = new ValueColorRange();
valueColorRange.IsActive = true;
valueColorRange.BottomValue = valueRange.BottomValue;
valueColorRange.AverageValue = (valueRange.BottomValue + valueRange.TopValue) / 2;
valueColorRange.TopValue = valueRange.TopValue;
valueColorRange.BottomColor = GetColorByValue(fullRange, colorMap, valueColorRange.BottomValue);
valueColorRange.TopColor = GetColorByValue(fullRange, colorMap, valueColorRange.TopValue);
colorRanges.Add(valueColorRange);
}
return colorRanges;
}
}
}

View File

@@ -0,0 +1,95 @@
using FieldVisualizer.Entities.Values;
using FieldVisualizer.Entities.Values.Primitives;
using FieldVisualizer.InfraStructures.Exceptions;
using FieldVisualizer.InfraStructures.Strings;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FieldVisualizer.Services.PrimitiveServices
{
public static class PrimitiveOperations
{
public static IValueRange GetValueRange(IEnumerable<IValuePrimitive> valuePrimitives)
{
double minVal =0d, maxVal = 0d;
foreach (var primitive in valuePrimitives)
{
minVal = Math.Min(minVal, primitive.Value);
maxVal = Math.Max(maxVal, primitive.Value);
}
return new ValueRange() { BottomValue = minVal, TopValue = maxVal };
}
public static double[] GetMinMaxX(IEnumerable<IValuePrimitive> valuePrimitives)
{
List<double> coords = GetXs(valuePrimitives);
return new double[] { coords.Min(), coords.Max() };
}
public static double GetSizeX(IEnumerable<IValuePrimitive> valuePrimitives)
{
double[] coords = GetMinMaxX(valuePrimitives);
return coords[1] - coords[0];
}
public static double[] GetMinMaxY(IEnumerable<IValuePrimitive> valuePrimitives)
{
List<double> coords = GetYs(valuePrimitives);
return new double[] { coords.Min(), coords.Max() };
}
public static double GetSizeY(IEnumerable<IValuePrimitive> valuePrimitives)
{
double[] coords = GetMinMaxY(valuePrimitives);
return coords[1] - coords[0];
}
public static List<double> GetXs(IEnumerable<IValuePrimitive> valuePrimitives)
{
List<double> coords = new List<double>();
foreach (var primitive in valuePrimitives)
{
if (primitive is IRectanglePrimitive)
{
IRectanglePrimitive rectanglePrimitive = primitive as IRectanglePrimitive;
coords.Add(rectanglePrimitive.CenterX + rectanglePrimitive.Width / 2);
coords.Add(rectanglePrimitive.CenterX - rectanglePrimitive.Width / 2);
}
else if (primitive is ICirclePrimitive)
{
ICirclePrimitive circlePrimitive = primitive as ICirclePrimitive;
coords.Add(circlePrimitive.CenterX + circlePrimitive.Diameter / 2);
coords.Add(circlePrimitive.CenterX - circlePrimitive.Diameter / 2);
}
else { throw new FieldVisulizerException(ErrorStrings.PrimitiveTypeIsUnknown);}
}
return coords;
}
public static List<double> GetYs(IEnumerable<IValuePrimitive> valuePrimitives)
{
List<double> coords = new List<double>();
foreach (var primitive in valuePrimitives)
{
if (primitive is IRectanglePrimitive)
{
IRectanglePrimitive rectanglePrimitive = primitive as IRectanglePrimitive;
coords.Add(rectanglePrimitive.CenterY + rectanglePrimitive.Height / 2);
coords.Add(rectanglePrimitive.CenterY - rectanglePrimitive.Height / 2);
}
else if (primitive is ICirclePrimitive)
{
ICirclePrimitive circlePrimitive = primitive as ICirclePrimitive;
coords.Add(circlePrimitive.CenterY + circlePrimitive.Diameter / 2);
coords.Add(circlePrimitive.CenterY - circlePrimitive.Diameter / 2);
}
else { throw new FieldVisulizerException(ErrorStrings.PrimitiveTypeIsUnknown); }
}
return coords;
}
}
}

View File

@@ -0,0 +1,49 @@
using FieldVisualizer.Entities.Values.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FieldVisualizer.Services.PrimitiveServices
{
public static class TestPrimitivesOperation
{
public static List<IPrimitiveSet> AddTestPrimitives()
{
List<IPrimitiveSet> primitiveSets = new List<IPrimitiveSet>();
int imax = 100;
int jmax = 100;
PrimitiveSet primitiveSet = new PrimitiveSet();
primitiveSets.Add(primitiveSet);
List<IValuePrimitive> primitives = new List<IValuePrimitive>();
primitiveSet.ValuePrimitives = primitives;
IValuePrimitive primitive;
for (int i = 0; i < imax; i++)
{
for (int j = 0; j < jmax; j++)
{
primitive = new RectanglePrimitive() { Height = 10, Width = 20, CenterX = 20 * i, CenterY = 10 * j, Value = -(i + j) };
primitives.Add(primitive);
}
}
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 2; j++)
{
primitive = new CirclePrimitive() { Diameter = 150, CenterX = -200 * i, CenterY = -100 * j, Value = i * 100 + j * 200 };
primitives.Add(primitive);
}
}
primitiveSet = new PrimitiveSet();
primitives = new List<IValuePrimitive>();
primitive = new RectanglePrimitive() { Height = 100, Width = 200, CenterX = 0, CenterY = 0, Value = 100 };
primitives.Add(primitive);
primitive = new CirclePrimitive() { Diameter = 50, CenterX = 0, CenterY = 0, Value = -100 };
primitives.Add(primitive);
primitiveSet.ValuePrimitives = primitives;
primitiveSets.Add(primitiveSet);
return primitiveSets;
}
}
}

View File

@@ -0,0 +1,35 @@
using FieldVisualizer.Entities.Values;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FieldVisualizer.Services.ValueRanges
{
public static class ValueRangeOperations
{
public static IEnumerable<IValueRange> DivideValueRange (IValueRange valueRange, int divisionNumber)
{
List<IValueRange> valueRanges = new List<IValueRange>();
if (valueRange.BottomValue == valueRange.TopValue)
{
var newRange = new ValueRange() { BottomValue = valueRange.BottomValue, TopValue = valueRange.TopValue };
valueRanges.Add(newRange);
}
else
{
double dVal = (valueRange.TopValue - valueRange.BottomValue) / divisionNumber;
double startBottom = valueRange.BottomValue;
for (int i = 0; i < divisionNumber; i++ )
{
double currentBottom = startBottom + i * dVal;
var newRange = new ValueRange() { BottomValue = currentBottom, TopValue = currentBottom + dVal };
valueRanges.Add(newRange);
}
}
return valueRanges;
}
}
}

View File

@@ -0,0 +1,377 @@
using FieldVisualizer.Entities.ColorMaps.Factories;
using FieldVisualizer.Entities.ColorMaps;
using FieldVisualizer.Entities.Values.Primitives;
using FieldVisualizer.Entities.Values;
using FieldVisualizer.Infrastructure.Commands;
using FieldVisualizer.InfraStructures.Enums;
using FieldVisualizer.InfraStructures.Exceptions;
using FieldVisualizer.InfraStructures.Strings;
using FieldVisualizer.Services.ColorServices;
using FieldVisualizer.Services.PrimitiveServices;
using FieldVisualizer.Services.ValueRanges;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;
using FieldVisualizer.Windows.UserControls;
using System.ComponentModel;
using System.Xml.Serialization;
namespace FieldVisualizer.ViewModels.FieldViewerViewModels
{
public class FieldViewerViewModel : ViewModelBase, IDataErrorInfo
{
public ICommand RebuildCommand { get; }
public ICommand ZoomInCommand { get; }
public ICommand ZoomOutCommand { get; }
public ICommand ChangeColorMapCommand { get; }
public ICommand SetUserColorsCommand { get; }
public ICommand SetCrossLineCommand
{
get
{
if (setCrossLineCommand == null)
{
setCrossLineCommand = new RelayCommand(SetCrossLine);
}
return setCrossLineCommand;
}
}
public IPrimitiveSet PrimitiveSet
{ get
{
return primitiveSet;
}
set
{
primitiveSet = value;
OnPropertyChanged(nameof(PrimitiveSet));
AreaTotal = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Sum(x => x.Area);
OnPropertyChanged(nameof(AreaTotal));
AreaNeg = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Where(x => x.Value < 0d).Sum(x => x.Area);
OnPropertyChanged(nameof(AreaNeg));
AreaZero = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Where(x => x.Value == 0d).Sum(x => x.Area);
OnPropertyChanged(nameof(AreaZero));
AreaPos = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Where(x => x.Value > 0d).Sum(x => x.Area);
OnPropertyChanged(nameof(AreaPos));
SumTotal = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Sum(x => x.Value);
OnPropertyChanged(nameof(SumTotal));
SumNeg = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Where(x => x.Value < 0d).Sum(x => x.Value);
OnPropertyChanged(nameof(SumNeg));
SumPos = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Where(x => x.Value > 0d).Sum(x => x.Value);
OnPropertyChanged(nameof(SumPos));
}
}
public IValueRange UserValueRange { get; set; }
public bool SetMinValue
{
get
{
return setMinValue;
}
set
{
setMinValue = value;
OnPropertyChanged(nameof(SetMinValue));
//OnPropertyChanged(nameof(UserMinValue));
}
}
public bool SetMaxValue
{
get
{
return setMaxValue;
}
set
{
setMaxValue = value;
OnPropertyChanged(nameof(SetMaxValue));
//OnPropertyChanged(nameof(UserMaxValue));
}
}
public double UserMinValue
{
get
{
return UserValueRange.BottomValue;
}
set
{
UserValueRange.BottomValue = value;
OnPropertyChanged(nameof(UserMinValue));
}
}
public double UserMaxValue
{
get
{
return UserValueRange.TopValue;
}
set
{
double tmpVal = UserValueRange.TopValue;
try
{
UserValueRange.TopValue = value;
OnPropertyChanged(nameof(UserMaxValue));
}
catch (Exception ex)
{
UserValueRange.TopValue = tmpVal;
}
}
}
public double AreaTotal { get; private set; }
public double AreaNeg { get; private set; }
public double AreaZero { get; private set; }
public double AreaPos { get; private set; }
public double SumTotal { get; private set;}
public double SumNeg { get; private set; }
public double SumPos { get; private set; }
public Viewbox WorkPlaneBox { get; set; }
public VerticalLegend Legend { get; set; }
public Canvas WorkPlaneCanvas { get; set; }
public double ScrolWidth { get; set; }
public double ScrolHeight { get; set; }
public double CrossLineX { get => crossLineX; set => SetProperty(ref crossLineX, value); }
public double CrossLineY { get => crossLineY; set => SetProperty(ref crossLineY, value); }
public double SumAboveLine { get => sumAboveLine; set => SetProperty(ref sumAboveLine, value); }
public double SumUnderLine { get => sumUnderLine; set => SetProperty(ref sumUnderLine, value); }
public string Error { get; }
public string this[string columnName]
{
get
{
string error = String.Empty;
return error;
}
}
private ICommand setCrossLineCommand;
private IPrimitiveSet primitiveSet;
private double dX, dY;
private ColorMapsTypes _ColorMapType;
private IColorMap _ColorMap;
private IValueRange valueRange;
private IEnumerable<IValueRange> _ValueRanges;
private IEnumerable<IValueColorRange> _ValueColorRanges;
private bool setMinValue;
private bool setMaxValue;
private double crossLineX;
private double crossLineY;
private double sumAboveLine;
private double sumUnderLine;
private Line previosLine;
const int RangeNumber = 16;
public FieldViewerViewModel()
{
_ColorMapType = ColorMapsTypes.FullSpectrum;
RebuildCommand = new RelayCommand(o => ProcessPrimitives(), o => PrimitiveValidation());
ZoomInCommand = new RelayCommand(o => Zoom(1.2), o => PrimitiveValidation());
ZoomOutCommand = new RelayCommand(o => Zoom(0.8), o => PrimitiveValidation());
ChangeColorMapCommand = new RelayCommand(o => ChangeColorMap(), o => PrimitiveValidation());
SetUserColorsCommand = new RelayCommand(o => ColorRefresh(), o => (SetMinValue || SetMaxValue));
UserValueRange = new ValueRange() { BottomValue = 0, TopValue = 0 };
SetMinValue = false;
SetMaxValue = false;
}
public void ColorRefresh()
{
if (PrimitiveValidation() == false) { return; }
_ColorMap = ColorMapFactory.GetColorMap(_ColorMapType);
SetColor();
if ((PrimitiveSet is null) == false)
{
ProcessPrimitives();
Legend.ValueColorRanges = _ValueColorRanges;
Legend.Refresh();
}
}
public void Refresh()
{
SetMinValue = false;
SetMaxValue = false;
ColorRefresh();
}
private void ProcessPrimitives()
{
WorkPlaneCanvas.Children.Clear();
double sizeX = PrimitiveOperations.GetSizeX(PrimitiveSet.ValuePrimitives);
double sizeY = PrimitiveOperations.GetSizeY(PrimitiveSet.ValuePrimitives);
dX = PrimitiveOperations.GetMinMaxX(PrimitiveSet.ValuePrimitives)[0];
dY = PrimitiveOperations.GetMinMaxY(PrimitiveSet.ValuePrimitives)[1];
WorkPlaneCanvas.Width = Math.Abs(sizeX);
WorkPlaneCanvas.Height = Math.Abs(sizeY);
WorkPlaneBox.Width = ScrolWidth - 50;
WorkPlaneBox.Height = ScrolHeight - 50;
foreach (var primitive in PrimitiveSet.ValuePrimitives)
{
if (primitive is IRectanglePrimitive)
{
IRectanglePrimitive rectanglePrimitive = primitive as IRectanglePrimitive;
Rectangle rectangle = ProcessRectanglePrimitive(rectanglePrimitive);
WorkPlaneCanvas.Children.Add(rectangle);
}
else if (primitive is ICirclePrimitive)
{
ICirclePrimitive circlePrimitive = primitive as ICirclePrimitive;
Ellipse ellipse = ProcessCirclePrimitive(circlePrimitive);
WorkPlaneCanvas.Children.Add(ellipse);
}
else { throw new FieldVisulizerException(ErrorStrings.PrimitiveTypeIsUnknown); }
}
}
private Rectangle ProcessRectanglePrimitive(IRectanglePrimitive rectanglePrimitive)
{
Rectangle rectangle = new Rectangle
{
Height = rectanglePrimitive.Height,
Width = rectanglePrimitive.Width
};
double addX = rectanglePrimitive.Width / 2;
double addY = rectanglePrimitive.Height / 2;
ProcessShape(rectangle, rectanglePrimitive, addX, addY);
return rectangle;
}
private Ellipse ProcessCirclePrimitive(ICirclePrimitive circlePrimitive)
{
Ellipse ellipse = new Ellipse
{
Height = circlePrimitive.Diameter,
Width = circlePrimitive.Diameter
};
double addX = circlePrimitive.Diameter / 2;
double addY = circlePrimitive.Diameter / 2;
ProcessShape(ellipse, circlePrimitive, addX, addY);
return ellipse;
}
private void ProcessShape(Shape shape, IValuePrimitive valuePrimitive, double addX, double addY)
{
SolidColorBrush brush = new SolidColorBrush();
brush.Color = ColorOperations.GetColorByValue(valueRange, _ColorMap, valuePrimitive.Value);
foreach (var valueRange in _ValueColorRanges)
{
if (valuePrimitive.Value >= valueRange.BottomValue & valuePrimitive.Value <= valueRange.TopValue & (!valueRange.IsActive))
{
brush.Color = Colors.Gray;
}
}
shape.ToolTip = valuePrimitive.Value;
shape.Tag = valuePrimitive;
shape.Fill = brush;
Canvas.SetLeft(shape, valuePrimitive.CenterX - addX - dX);
Canvas.SetTop(shape, -valuePrimitive.CenterY - addY + dY);
}
private void Zoom(double coefficient)
{
WorkPlaneBox.Width *= coefficient;
WorkPlaneBox.Height *= coefficient;
}
private void ChangeColorMap()
{
//Iterate all available color maps one by one
try
{
_ColorMapType++;
IColorMap colorMap = ColorMapFactory.GetColorMap(_ColorMapType);
}
catch (Exception ex) { _ColorMapType = 0; }
ColorRefresh();
}
private bool PrimitiveValidation()
{
if (PrimitiveSet == null || PrimitiveSet.ValuePrimitives.Count() == 0) { return false; }
else return true;
}
private void SetColor()
{
valueRange = PrimitiveOperations.GetValueRange(PrimitiveSet.ValuePrimitives);
//if bottom value is greater than top value
if (SetMinValue
& SetMaxValue
& (UserValueRange.BottomValue > UserValueRange.TopValue))
{
UserValueRange.TopValue = UserValueRange.BottomValue;
}
if (SetMinValue) { valueRange.BottomValue = UserValueRange.BottomValue; } else { UserValueRange.BottomValue = valueRange.BottomValue; }
if (SetMaxValue) { valueRange.TopValue = UserValueRange.TopValue; } else { UserValueRange.TopValue = valueRange.TopValue; }
_ValueRanges = ValueRangeOperations.DivideValueRange(valueRange, RangeNumber);
_ValueColorRanges = ColorOperations.GetValueColorRanges(valueRange, _ValueRanges, _ColorMap);
}
private void SetCrossLine(object commandParameter)
{
AddCrossLine();
AddSummaryInfoCrossLine();
}
private void AddCrossLine()
{
double width = WorkPlaneCanvas.ActualWidth;
double heigth = WorkPlaneCanvas.ActualHeight;
Line line = new Line();
if (crossLineX == 0d)
{
line.X1 = - width / 2d - dX;
line.Y1 = - crossLineY + dY;
line.X2 = width / 2d - dX;
line.Y2 = - crossLineY + dY;
}
else if (crossLineY == 0d)
{
line.X1 = crossLineX - dX;
line.Y1 = heigth / 2 + dY;
line.X2 = crossLineX - dX;
line.Y2 = -heigth / 2 + dY;
}
else
{
line.X1 = - width / 2d - dX;
line.Y1 = -(crossLineY / crossLineX * width / 2 + crossLineY) - dY;
line.X2 = width / 2d - dX;
line.Y2 = -(-crossLineY / crossLineX * width / 2 + crossLineY) - dY ;
}
SolidColorBrush brush = new SolidColorBrush();
brush.Color = Colors.Red;
line.Fill = brush;
line.Stroke = brush;
line.StrokeThickness = (width + heigth) / 100;
if (previosLine != null)
{
try { WorkPlaneCanvas.Children.Remove(previosLine);}
catch (Exception) {}
}
previosLine = line;
WorkPlaneCanvas.Children.Add(line);
}
private double GetPointOfCrossLine(double x)
{
double y;
if (crossLineX == 0d)
{
y = crossLineY;
}
else
{
y = -crossLineY / crossLineX - crossLineY;
}
return y;
}
private void AddSummaryInfoCrossLine()
{
SumAboveLine = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Where(x=>x.CenterY >= GetPointOfCrossLine(x.CenterX)).Sum(x => x.Value);
SumUnderLine = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Where(x => x.CenterY <= GetPointOfCrossLine(x.CenterX)).Sum(x => x.Value);
}
}
}

View File

@@ -0,0 +1,36 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace FieldVisualizer.ViewModels
{
public class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged<T>(T value, T prop, [CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
protected virtual void OnPropertyChanged<T>(T value, ref T prop, [CallerMemberName] string propertyName = null)
{
prop = value;
OnPropertyChanged(propertyName);
}
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
protected bool SetProperty<T>(ref T field, T newValue, [CallerMemberName] string propertyName = null)
{
if (!Equals(field, newValue))
{
field = newValue;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
return true;
}
return false;
}
}
}

View File

@@ -0,0 +1,100 @@
<UserControl x:Class="FieldVisualizer.Windows.UserControls.FieldViewer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:FieldVisualizer.Windows.UserControls"
xmlns:vm="clr-namespace:FieldVisualizer.ViewModels.FieldViewerViewModels"
d:DataContext="{d:DesignInstance vm:FieldViewerViewModel}"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="220"/>
</Grid.ColumnDefinitions>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<Button x:Name="RebuildButton" Content="Rebuild" Command="{Binding RebuildCommand}"/>
<Button x:Name="ZoomInButton" Content="ZoomIn" Command="{Binding ZoomInCommand}"/>
<Button x:Name="ZoomOutButton" Content="ZoomOut" Command="{Binding ZoomOutCommand}"/>
<Button x:Name="ChangeColorMapButton" Content="ColorMap" Command="{Binding ChangeColorMapCommand}"/>
</StackPanel>
<ScrollViewer Name="WorkPlaneViewer" Grid.Row="1" HorizontalScrollBarVisibility="Visible" SizeChanged="WorkPlaneViewer_SizeChanged">
<ScrollViewer.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black"/>
<GradientStop Color="White" Offset="1"/>
<GradientStop Color="#FF00EDFF" Offset="0"/>
</LinearGradientBrush>
</ScrollViewer.Background>
<Viewbox Name="WorkPlaneBox" Margin="10">
<Canvas Name="WorkPlaneCanvas">
</Canvas>
</Viewbox>
</ScrollViewer>
</Grid>
<ScrollViewer Grid.Column="2">
<StackPanel>
<Expander Header="Color legend" IsExpanded="True">
<StackPanel>
<CheckBox x:Name="cbMinValueEnabled" Margin="3" Content="Minimum Value" IsChecked="{Binding Path=SetMinValue}"/>
<TextBox x:Name="tbMinValue" Margin="20,3,3,3" IsEnabled="{Binding IsChecked, ElementName=cbMinValueEnabled}" Text="{Binding Path=UserMinValue, ValidatesOnDataErrors=True}"/>
<CheckBox x:Name="cbMaxValueEnabled" Margin="3" Content="Maximum Value" IsChecked="{Binding Path=SetMaxValue}"/>
<TextBox x:Name="tbMaxValue" Margin="20,3,3,3" IsEnabled="{Binding IsChecked, ElementName=cbMaxValueEnabled}" Text="{Binding Path=UserMaxValue, ValidatesOnDataErrors=True}"/>
<Button Margin="3" Content="Set custom colors" Command="{Binding SetUserColorsCommand}"/>
<local:VerticalLegend x:Name="LegendViewer" Margin="3" Grid.Column="2"/>
</StackPanel>
</Expander>
<Expander Header="Summary information" IsExpanded="False">
<StackPanel>
<TextBlock Text="Total area:"/>
<TextBlock Text="{Binding AreaTotal}"/>
<TextBlock Text="Negative value area:"/>
<TextBlock Text="{Binding AreaNeg}"/>
<TextBlock Text="Zero value area:"/>
<TextBlock Text="{Binding AreaZero}"/>
<TextBlock Text="Positive value area:"/>
<TextBlock Text="{Binding AreaPos}"/>
<TextBlock Text="Total sum: "/>
<TextBlock Text="{Binding SumTotal}"/>
<TextBlock Text="Sum negative: "/>
<TextBlock Text="{Binding SumNeg}"/>
<TextBlock Text="Sum positive: "/>
<TextBlock Text="{Binding SumPos}"/>
</StackPanel>
</Expander>
<Expander Header="Summary section" IsExpanded="False">
<StackPanel>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="X-distance"/>
<TextBox Grid.Column="1" Text="{Binding CrossLineX, ValidatesOnDataErrors=True}"/>
<TextBlock Grid.Row="1" Text="Y-distance"/>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding CrossLineY, ValidatesOnDataErrors=True}"/>
</Grid>
<Button Content="Set section line" Command="{Binding SetCrossLineCommand}"/>
<TextBlock Text="Sum above line: "/>
<TextBlock Text="{Binding SumAboveLine}"/>
<TextBlock Text="Sum under line: "/>
<TextBlock Text="{Binding SumUnderLine}"/>
</StackPanel>
</Expander>
</StackPanel>
</ScrollViewer>
</Grid>
</UserControl>

View File

@@ -0,0 +1,67 @@
using FieldVisualizer.Entities.ColorMaps;
using FieldVisualizer.Entities.ColorMaps.Factories;
using FieldVisualizer.Entities.Values;
using FieldVisualizer.Entities.Values.Primitives;
using FieldVisualizer.Infrastructure.Commands;
using FieldVisualizer.InfraStructures.Enums;
using FieldVisualizer.InfraStructures.Exceptions;
using FieldVisualizer.InfraStructures.Strings;
using FieldVisualizer.Services.ColorServices;
using FieldVisualizer.Services.PrimitiveServices;
using FieldVisualizer.Services.ValueRanges;
using FieldVisualizer.ViewModels.FieldViewerViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;
namespace FieldVisualizer.Windows.UserControls
{
/// <summary>
/// Логика взаимодействия для FieldViewer.xaml
/// </summary>
public partial class FieldViewer : UserControl
{
private FieldViewerViewModel viewModel;
public FieldViewer()
{
InitializeComponent();
viewModel = new FieldViewerViewModel();
this.DataContext = viewModel;
PrimitiveSet = viewModel.PrimitiveSet;
viewModel.WorkPlaneBox = WorkPlaneBox;
viewModel.WorkPlaneCanvas = WorkPlaneCanvas;
viewModel.Legend = LegendViewer;
}
//public FieldViewer(FieldViewerViewModel vm)
//{
// InitializeComponent();
// viewModel = vm;
// this.DataContext = viewModel;
// PrimitiveSet = viewModel.PrimitiveSet;
// viewModel.WorkPlaneBox = WorkPlaneBox;
// viewModel.WorkPlaneCanvas = WorkPlaneCanvas;
// viewModel.Legend = LegendViewer;
//}
public IPrimitiveSet PrimitiveSet { get => viewModel.PrimitiveSet; set { viewModel.PrimitiveSet = value; } }
internal void Refresh()
{
viewModel.Refresh();
}
private void WorkPlaneViewer_SizeChanged(object sender, SizeChangedEventArgs e)
{
ScrollViewer viewer = (ScrollViewer)sender;
viewModel.ScrolWidth = viewer.ActualWidth;
viewModel.ScrolHeight = viewer.ActualHeight;
}
}
}

View File

@@ -0,0 +1,49 @@
<UserControl x:Class="FieldVisualizer.Windows.UserControls.VerticalLegend"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:FieldVisualizer.Windows.UserControls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid x:Name="grid">
<StackPanel>
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="#FF868686"></TextBlock>
<ListBox Name="LegendBox" ItemsSource="{Binding}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Height="30" Width="190" VerticalAlignment="Top" Background="{DynamicResource {x:Static SystemColors.MenuBarBrushKey}}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"/>
<ColumnDefinition Width="10"/>
<ColumnDefinition/>
<ColumnDefinition Width="10"/>
</Grid.ColumnDefinitions>
<CheckBox Name="ActiveCheckBox" Grid.Column="0" IsChecked="{Binding Path=IsActive}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<Rectangle Grid.Column="1" Margin="0,2,0,2" ToolTip="{Binding Path=BottomValue}">
<Rectangle.Fill>
<SolidColorBrush Color="{Binding Path=BottomColor}"/>
</Rectangle.Fill>
</Rectangle>
<Rectangle Grid.Column="2" Margin="0,2,0,2">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="1,1" StartPoint="0,0">
<GradientStop Color="{Binding Path=BottomColor}"/>
<GradientStop Color="{Binding Path=TopColor}" Offset="1"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<TextBlock Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="#FF868686" Text="{Binding AverageValue}"/>
<Rectangle Grid.Column="3" Margin="0,2,0,2" ToolTip="{Binding Path=TopValue}">
<Rectangle.Fill>
<SolidColorBrush Color="{Binding Path=TopColor}"/>
</Rectangle.Fill>
</Rectangle>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</Grid>
</UserControl>

View File

@@ -0,0 +1,36 @@
using FieldVisualizer.Entities.ColorMaps;
using FieldVisualizer.Entities.Values;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace FieldVisualizer.Windows.UserControls
{
/// <summary>
/// Логика взаимодействия для VerticalLegend.xaml
/// </summary>
public partial class VerticalLegend : UserControl
{
public IEnumerable<IValueColorRange> ValueColorRanges;
public VerticalLegend()
{
InitializeComponent();
}
public void Refresh()
{
this.DataContext = ValueColorRanges;
}
}
}

View File

@@ -0,0 +1,4 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
</ResourceDictionary>

View File

@@ -0,0 +1,30 @@
<Window x:Class="FieldVisualizer.Windows.WndFieldViewer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:FieldViewerControl="clr-namespace:FieldVisualizer.Windows.UserControls"
xmlns:local="clr-namespace:FieldVisualizer.Windows"
mc:Ignorable="d"
Title="FieldViewer" Height="800" Width="1200" WindowStartupLocation="CenterOwner">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<ListBox Name="SetsList" ItemsSource="{Binding}" SelectionChanged="SetsList_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Height="20">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Text="{Binding Path=Name}" Width="270"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<FieldViewerControl:FieldViewer x:Name="FieldViewerControl" Grid.Column="1"/>
</Grid>
</Window>

View File

@@ -0,0 +1,48 @@
using FieldVisualizer.Entities.Values.Primitives;
using FieldVisualizer.Windows.UserControls;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace FieldVisualizer.Windows
{
/// <summary>
/// Логика взаимодействия для WndFieldViewer.xaml
/// </summary>
public partial class WndFieldViewer : Window
{
public ObservableCollection<IPrimitiveSet> PrimitiveSets { get; private set; }
public WndFieldViewer(IEnumerable<IPrimitiveSet> primitiveSets)
{
InitializeComponent();
PrimitiveSets = new ObservableCollection<IPrimitiveSet>();
foreach (var primitiveSet in primitiveSets)
{
PrimitiveSets.Add(primitiveSet);
}
this.DataContext = PrimitiveSets;
}
private void SetsList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ListBox lb = sender as ListBox;
if (lb.SelectedItem != null)
{
FieldViewerControl.PrimitiveSet = lb.SelectedItem as IPrimitiveSet;
FieldViewerControl.Refresh();
}
}
}
}

View File

@@ -0,0 +1,19 @@
using FieldVisualizer.Entities.Values.Primitives;
using FieldVisualizer.Windows;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FieldVisualizer.WindowsOperation
{
public static class FieldViewerOperation
{
public static void ShowViewer(IEnumerable<IPrimitiveSet> primitiveSets)
{
WndFieldViewer Viewer = new WndFieldViewer(primitiveSets);
Viewer.ShowDialog();
}
}
}

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
</configuration>

61
FiledVisualzerDemo/DemoForm.Designer.cs generated Normal file
View File

@@ -0,0 +1,61 @@
namespace FiledVisualzerDemo
{
partial class DemoForm
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором форм Windows
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
this.RectanglesSetDemo = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// RectanglesSetDemo
//
this.RectanglesSetDemo.Location = new System.Drawing.Point(29, 22);
this.RectanglesSetDemo.Name = "RectanglesSetDemo";
this.RectanglesSetDemo.Size = new System.Drawing.Size(167, 23);
this.RectanglesSetDemo.TabIndex = 0;
this.RectanglesSetDemo.Text = "RectanglesSetDemo";
this.RectanglesSetDemo.UseVisualStyleBackColor = true;
this.RectanglesSetDemo.Click += new System.EventHandler(this.RectanglesSetDemo_Click);
//
// DemoForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.RectanglesSetDemo);
this.Name = "DemoForm";
this.Text = "FieldVisualizerDemo";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button RectanglesSetDemo;
}
}

View File

@@ -0,0 +1,29 @@
using FieldVisualizer.Entities.Values.Primitives;
using FieldVisualizer.Services.PrimitiveServices;
using FieldVisualizer.WindowsOperation;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FiledVisualzerDemo
{
public partial class DemoForm : Form
{
public DemoForm()
{
InitializeComponent();
}
private void RectanglesSetDemo_Click(object sender, EventArgs e)
{
var primitiveSets = TestPrimitivesOperation.AddTestPrimitives();
FieldViewerOperation.ShowViewer(primitiveSets);
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows10.0.18362.0</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>disable</ImplicitUsings>
<SupportedOSPlatformVersion>10.0.18362.0</SupportedOSPlatformVersion>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<ItemGroup>
<Compile Remove="StructureHelperCommon\**" />
<Compile Remove="StructureHelperLogics\**" />
<EmbeddedResource Remove="StructureHelperCommon\**" />
<EmbeddedResource Remove="StructureHelperLogics\**" />
<None Remove="StructureHelperCommon\**" />
<None Remove="StructureHelperLogics\**" />
<Page Remove="StructureHelperCommon\**" />
<Page Remove="StructureHelperLogics\**" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FieldVisualizer\FieldVisualizer.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows7.0</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>disable</ImplicitUsings>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<ItemGroup>
<Compile Remove="StructureHelperCommon\**" />
<Compile Remove="StructureHelperLogics\**" />
<EmbeddedResource Remove="StructureHelperCommon\**" />
<EmbeddedResource Remove="StructureHelperLogics\**" />
<None Remove="StructureHelperCommon\**" />
<None Remove="StructureHelperLogics\**" />
<Page Remove="StructureHelperCommon\**" />
<Page Remove="StructureHelperLogics\**" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FieldVisualizer\FieldVisualizer.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows10.0.18362.0</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<ImplicitUsings>disable</ImplicitUsings>
<SupportedOSPlatformVersion>10.0.18362.0</SupportedOSPlatformVersion>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<ItemGroup>
<Compile Remove="StructureHelperCommon\**" />
<Compile Remove="StructureHelperLogics\**" />
<EmbeddedResource Remove="StructureHelperCommon\**" />
<EmbeddedResource Remove="StructureHelperLogics\**" />
<None Remove="StructureHelperCommon\**" />
<None Remove="StructureHelperLogics\**" />
<Page Remove="StructureHelperCommon\**" />
<Page Remove="StructureHelperLogics\**" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FieldVisualizer\FieldVisualizer.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
<ItemGroup>
<Compile Update="DemoForm.cs">
<SubType>Form</SubType>
</Compile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,118 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C92A5F2E-567B-48C9-A524-5740DB03509D}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>FiledVisualzerDemo</RootNamespace>
<AssemblyName>FiledVisualzerDemo</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DemoForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="DemoForm.Designer.cs">
<DependentUpon>DemoForm.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="DemoForm.resx">
<DependentUpon>DemoForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FieldVisualizer\FieldVisualizer.csproj">
<Project>{87064b50-3b7c-4a91-af4a-941c6f95d997}</Project>
<Name>FieldVisualizer</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.8">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.8 %28x86 и x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FiledVisualzerDemo
{
internal static class Program
{
/// <summary>
/// Главная точка входа для приложения.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new DemoForm());
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Общие сведения об этой сборке предоставляются следующим набором
// набора атрибутов. Измените значения этих атрибутов для изменения сведений,
// связанных со сборкой.
[assembly: AssemblyTitle("FiledVisualzerDemo")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FiledVisualzerDemo")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
// COM, следует установить атрибут ComVisible в TRUE для этого типа.
[assembly: ComVisible(false)]
// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
[assembly: Guid("c92a5f2e-567b-48c9-a524-5740db03509d")]
// Сведения о версии сборки состоят из указанных ниже четырех значений:
//
// Основной номер версии
// Дополнительный номер версии
// Номер сборки
// Редакция
//
// Можно задать все значения или принять номера сборки и редакции по умолчанию
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace FiledVisualzerDemo.Properties {
using System;
/// <summary>
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
/// </summary>
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
// с помощью такого средства, как ResGen или Visual Studio.
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
// с параметром /str или перестройте свой проект VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FiledVisualzerDemo.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace FiledVisualzerDemo.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.3.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@@ -1,30 +0,0 @@
using System;
using System.Windows.Media;
using StructureHelper.Infrastructure.Enums;
using StructureHelper.Windows.MainWindow;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
public class Ellipse : PrimitiveBase
{
private double square;
public double Square
{
get => square;
set
{
square = value;
PrimitiveWidth = Math.Round(Math.Sqrt(4 * value / Math.PI), 2);
OnPropertyChanged(nameof(PrimitiveWidth));
OnPropertyChanged();
}
}
public Ellipse(double square, double ellipseX, double ellipseY, MainViewModel mainViewModel) : base(PrimitiveType.Ellipse, ellipseX, ellipseY, mainViewModel)
{
Square = square;
ShowedX = 0;
ShowedY = 0;
}
}
}

View File

@@ -1,258 +0,0 @@
using System;
using System.Windows.Input;
using System.Windows.Media;
using StructureHelper.Infrastructure.Enums;
using StructureHelper.Models.Materials;
using StructureHelper.Windows.MainWindow;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
public abstract class PrimitiveBase : ViewModelBase
{
#region Поля
private readonly PrimitiveType type;
private bool captured, parameterCaptured, elementLock, paramsPanelVisibilty, popupCanBeClosed = true, borderCaptured;
private Brush brush;
private MaterialDefinitionBase material;
private double opacity = 1, showedOpacity = 0, x, y, xY1, yX1, primitiveWidth, primitiveHeight, showedX, showedY, delta = 0.5;
private int showedZIndex = 1, zIndex;
#endregion
#region Свойства
public PrimitiveType Type => type;
public bool Captured
{
set => OnPropertyChanged(value, ref captured);
get => captured;
}
public bool ParameterCaptured
{
set => OnPropertyChanged(value, ref parameterCaptured);
get => parameterCaptured;
}
public bool ElementLock
{
get => elementLock;
set => OnPropertyChanged(value, ref elementLock);
}
public Brush Brush
{
get => brush;
set => OnPropertyChanged(value, ref brush);
}
public MaterialDefinitionBase Material
{
get => material;
set
{
MaterialName = material.MaterialClass;
OnPropertyChanged(value, ref material);
OnPropertyChanged(nameof(MaterialName));
}
}
private string materialName = string.Empty;
public string MaterialName
{
get => materialName;
set => OnPropertyChanged(value, ref materialName);
}
public bool ParamsPanelVisibilty
{
get => paramsPanelVisibilty;
set => OnPropertyChanged(value, ref paramsPanelVisibilty);
}
public bool PopupCanBeClosed
{
get => popupCanBeClosed;
set => OnPropertyChanged(value, ref popupCanBeClosed);
}
public double ShowedOpacity
{
get => showedOpacity;
set
{
Opacity = (100 - value) / 100;
OnPropertyChanged(nameof(Opacity));
OnPropertyChanged(value, ref showedOpacity);
}
}
public double Opacity
{
get => opacity;
set => OnPropertyChanged(value, ref opacity);
}
public int ShowedZIndex
{
get => showedZIndex;
set
{
ZIndex = value - 1;
OnPropertyChanged(nameof(ZIndex));
OnPropertyChanged(value, ref showedZIndex);
}
}
public int ZIndex
{
get => zIndex;
set => OnPropertyChanged(value, ref zIndex);
}
public double X
{
get => x;
set => OnPropertyChanged(value, ref x);
}
public double Y
{
get => y;
set => OnPropertyChanged(value, ref y);
}
public double Xy1
{
get => xY1;
set => OnPropertyChanged(value, ref xY1);
}
public double Yx1
{
get => yX1;
set => OnPropertyChanged(value, ref yX1);
}
public double PrimitiveWidth
{
get => primitiveWidth;
set => OnPropertyChanged(value, ref primitiveWidth);
}
public double PrimitiveHeight
{
get => primitiveHeight;
set => OnPropertyChanged(value, ref primitiveHeight);
}
public double ShowedX
{
get => showedX;
set
{
UpdateCoordinatesX(value);
OnPropertyChanged(value, ref showedX);
OnPropertyChanged(nameof(X));
}
}
public double ShowedY
{
get => showedY;
set
{
UpdateCoordinatesY(value);
OnPropertyChanged(value, ref showedY);
OnPropertyChanged(nameof(Y));
}
}
public bool BorderCaptured
{
get => borderCaptured;
set => OnPropertyChanged(value, ref borderCaptured);
}
#endregion
#region Команды
public ICommand PrimitiveLeftButtonDown { get; }
public ICommand PrimitiveLeftButtonUp { get; }
public ICommand RectanglePreviewMouseMove { get; }
public ICommand EllipsePreviewMouseMove { get; }
public ICommand PrimitiveDoubleClick { get; }
#endregion
protected PrimitiveBase(PrimitiveType type, double rectX, double rectY, MainViewModel mainViewModel)
{
this.type = type;
Yx1 = rectX;
Xy1 = rectY;
var randomR = new Random().Next(150, 255);
var randomG = new Random().Next(0, 255);
var randomB = new Random().Next(30, 130);
var color = Color.FromRgb((byte)randomR, (byte)randomG, (byte)randomB);
Brush = new SolidColorBrush(color);
PrimitiveLeftButtonUp = new RelayCommand(o => Captured = false);
PrimitiveLeftButtonDown = new RelayCommand(o => Captured = true);
RectanglePreviewMouseMove = new RelayCommand(o =>
{
if (!(o is Rectangle rect)) return;
if (Captured && !rect.BorderCaptured && !ElementLock)
{
var deltaX = PrimitiveWidth / 2;
var deltaY = PrimitiveHeight / 2;
if (rect.ShowedX % 10 <= delta || rect.ShowedX % 10 >= 10 - delta)
rect.ShowedX = Math.Round((mainViewModel.PanelX - deltaX - Yx1) / 10) * 10;
else
rect.ShowedX = mainViewModel.PanelX - deltaX - Yx1;
if (rect.ShowedY % 10 <= delta || rect.ShowedY % 10 >= 10 - delta)
rect.ShowedY = -(Math.Round((mainViewModel.PanelY - deltaY - Xy1 + rect.PrimitiveHeight) / 10) * 10);
else
rect.ShowedY = -(mainViewModel.PanelY - deltaY - Xy1 + rect.PrimitiveHeight);
}
if (ParameterCaptured)
{
//RectParameterX = rect.ShowedX;
//RectParameterY = rect.ShowedY;
//RectParameterWidth = rect.PrimitiveWidth;
//RectParameterHeight = rect.PrimitiveHeight;
//ParameterOpacity = rect.ShowedOpacity;
//ElementLock = rect.ElementLock;
}
});
EllipsePreviewMouseMove = new RelayCommand(o =>
{
if (!(o is Ellipse ellipse)) return;
if (ellipse.Captured && !ellipse.ElementLock)
{
var ellipseDelta = ellipse.PrimitiveWidth / 2;
if (ellipse.ShowedX % 10 <= ellipseDelta || ellipse.ShowedX % 10 >= 10 - ellipseDelta)
ellipse.ShowedX = Math.Round((mainViewModel.PanelX - Yx1) / 10) * 10;
else
ellipse.ShowedX = mainViewModel.PanelX - ellipseDelta - Yx1;
if (ellipse.ShowedY % 10 <= ellipseDelta || ellipse.ShowedY % 10 >= 10 - ellipseDelta)
ellipse.ShowedY = -(Math.Round((mainViewModel.PanelY - Xy1) / 10) * 10);
else
ellipse.ShowedY = -(mainViewModel.PanelY - ellipseDelta - Xy1);
}
if (ParameterCaptured)
{
//EllipseParameterX = ellipse.ShowedX;
//EllipseParameterY = ellipse.ShowedY;
//EllipseParameterSquare = ellipse.Square;
//ParameterOpacity = ellipse.ShowedOpacity;
//ElementLock = ellipse.ElementLock;
}
});
PrimitiveDoubleClick = new RelayCommand(o =>
{
PopupCanBeClosed = false;
Captured = false;
ParamsPanelVisibilty = true;
//if (primitive is Rectangle rect)
// rect.BorderCaptured = false;
});
}
private void UpdateCoordinatesX(double showedX)
{
if (Type == PrimitiveType.Rectangle) X = showedX + Yx1;
if (Type == PrimitiveType.Ellipse) X = showedX + Yx1 - PrimitiveWidth / 2;
}
private void UpdateCoordinatesY(double showedY)
{
if (Type == PrimitiveType.Rectangle) Y = -showedY + Xy1 - PrimitiveHeight;
if (Type == PrimitiveType.Ellipse) Y = -showedY + Xy1 - PrimitiveWidth / 2;
}
}
}

View File

@@ -1,19 +0,0 @@
using System;
using System.Windows.Input;
using System.Windows.Media;
using StructureHelper.Infrastructure.Enums;
using StructureHelper.Windows.MainWindow;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
public class Rectangle : PrimitiveBase
{
public Rectangle(double primitiveWidth, double primitiveHeight, double rectX, double rectY, MainViewModel mainViewModel) : base(PrimitiveType.Rectangle, rectX, rectY, mainViewModel)
{
PrimitiveWidth = primitiveWidth;
PrimitiveHeight = primitiveHeight;
ShowedX = 0;
ShowedY = 0;
}
}
}

View File

@@ -1,15 +0,0 @@
<UserControl x:Class="StructureHelper.Infrastructure.UI.DataTemplates.EllipseTemplate"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:StructureHelper"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:mouseEventTriggers="clr-namespace:StructureHelper.Infrastructure.UI.Triggers.MouseEventTriggers"
xmlns:dataContexts="clr-namespace:StructureHelper.Infrastructure.UI.DataContexts"
xmlns:userControls="clr-namespace:StructureHelper.Infrastructure.UI.UserControls"
mc:Ignorable="d">
<Grid>
<ContentControl Content="{StaticResource EllipsePrimitive}"/>
</Grid>
</UserControl>

View File

@@ -1,28 +0,0 @@
<UserControl x:Class="StructureHelper.Infrastructure.UI.DataTemplates.RectangleTemplate"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:StructureHelper"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:infrastructure="clr-namespace:StructureHelper.Infrastructure"
xmlns:mouseEventTriggers="clr-namespace:StructureHelper.Infrastructure.UI.Triggers.MouseEventTriggers"
xmlns:userControls="clr-namespace:StructureHelper.Infrastructure.UI.UserControls"
mc:Ignorable="d">
<Grid>
<ContentControl Content="{StaticResource RectanglePrimitive}"/>
<Rectangle Cursor="SizeNWSE" Width="20" Height="20" Fill="{Binding Brush}" VerticalAlignment="Bottom" HorizontalAlignment="Right">
<i:Interaction.Triggers>
<i:EventTrigger EventName="PreviewMouseDown">
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.LeftButtonDown}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<i:EventTrigger EventName="PreviewMouseUp">
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.LeftButtonUp}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<i:EventTrigger EventName="PreviewMouseMove">
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.PreviewMouseMove}" CommandParameter="{Binding}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Rectangle>
</Grid>
</UserControl>

View File

@@ -1,89 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:mouseEventTriggers="clr-namespace:StructureHelper.Infrastructure.UI.Triggers.MouseEventTriggers"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dataContexts="clr-namespace:StructureHelper.Infrastructure.UI.DataContexts"
mc:Ignorable="d" >
<Style TargetType="Shape" x:Key="ShapeStyle">
<Setter Property="Fill" Value="{Binding Brush, Mode=TwoWay}"/>
<Setter Property="Opacity" Value="{Binding Opacity, Mode=TwoWay}"/>
<Setter Property="ToolTip">
<Setter.Value>
<ToolTip Background="White" BorderBrush="Black" BorderThickness="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions>
<TextBox Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="Координата X:"/>
<TextBox Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="{Binding ShowedX}"/>
<TextBox Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="Координата Y:"/>
<TextBox Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="{Binding ShowedY}"/>
<TextBox Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="Ширина:"/>
<TextBox Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="{Binding PrimitiveWidth}"/>
<TextBox Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="Высота:"/>
<TextBox Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="{Binding PrimitiveHeight}"/>
<TextBox Grid.Row="4" Grid.Column="0" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="Материал:"/>
<TextBox Grid.Row="4" Grid.Column="1" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="{Binding MaterialName, Mode=TwoWay}"/>
</Grid>
</ToolTip>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="EllipseStyle" TargetType="Ellipse" BasedOn="{StaticResource ShapeStyle}">
<Style.Setters>
<Setter Property="Width" Value="{Binding PrimitiveWidth}"/>
<Setter Property="Height" Value="{Binding PrimitiveWidth}"/>
</Style.Setters>
</Style>
<Style x:Key="RectangleStyle" TargetType="Rectangle" BasedOn="{StaticResource ShapeStyle}">
<Setter Property="Width" Value="{Binding PrimitiveWidth}"/>
<Setter Property="Height" Value="{Binding PrimitiveHeight}"/>
</Style>
<Rectangle x:Key="RectanglePrimitive" Style="{StaticResource RectangleStyle}" d:DataContext="{d:DesignInstance dataContexts:PrimitiveBase}" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="PreviewMouseDown">
<i:InvokeCommandAction Command="{Binding PrimitiveLeftButtonDown}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<i:EventTrigger EventName="PreviewMouseUp">
<i:InvokeCommandAction Command="{Binding PrimitiveLeftButtonUp}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<i:EventTrigger EventName="PreviewMouseMove">
<i:InvokeCommandAction Command="{Binding RectanglePreviewMouseMove}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<mouseEventTriggers:DoubleClickEventTrigger EventName="MouseDown">
<i:InvokeCommandAction Command="{Binding PrimitiveDoubleClick}" CommandParameter="{Binding}"/>
</mouseEventTriggers:DoubleClickEventTrigger>
</i:Interaction.Triggers>
</Rectangle>
<Ellipse x:Key="EllipsePrimitive" Style="{StaticResource EllipseStyle}" d:DataContext="{d:DesignInstance dataContexts:PrimitiveBase}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="PreviewMouseDown">
<i:InvokeCommandAction Command="{Binding PrimitiveLeftButtonDown}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<i:EventTrigger EventName="PreviewMouseUp">
<i:InvokeCommandAction Command="{Binding PrimitiveLeftButtonUp}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<i:EventTrigger EventName="PreviewMouseMove">
<i:InvokeCommandAction Command="{Binding EllipsePreviewMouseMove}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<mouseEventTriggers:DoubleClickEventTrigger EventName="MouseDown">
<i:InvokeCommandAction Command="{Binding PrimitiveDoubleClick}" CommandParameter="{Binding}"/>
</mouseEventTriggers:DoubleClickEventTrigger>
</i:Interaction.Triggers>
</Ellipse>
</ResourceDictionary>

View File

@@ -1,142 +0,0 @@
<UserControl x:Class="StructureHelper.Infrastructure.UI.UserControls.PrimitivePopup"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:StructureHelper.Infrastructure.UI.UserControls"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:dataContexts="clr-namespace:StructureHelper.Infrastructure.UI.DataContexts"
mc:Ignorable="d">
<Grid>
<!--Rectangle-->
<local:PrimitivePopup IsOpen="{Binding ParamsPanelVisibilty}" d:DataContext="{d:DesignInstance dataContexts:Rectangle}" Type="Rectangle">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeave">
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.SetPopupCanBeClosedTrue}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseEnter">
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.SetPopupCanBeClosedFalse}" CommandParameter="{Binding}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<Border Background="White" BorderBrush="Black" BorderThickness="1">
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="170"/>
<ColumnDefinition Width="170"/>
</Grid.ColumnDefinitions>
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Text="Координата X" Margin="10"/>
<TextBox Grid.Column="1" VerticalAlignment="Center" Margin="10" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.RectParameterX, Mode=TwoWay}"/>
<TextBlock Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Left" Text="Координата Y" Margin="10"/>
<TextBox Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" Margin="10" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.RectParameterY, Mode=TwoWay}"/>
<TextBlock Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Left" Text="Ширина" Margin="10"/>
<TextBox Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" Margin="10" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.RectParameterWidth, Mode=TwoWay}"/>
<TextBlock Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Left" Text="Высота" Margin="10"/>
<TextBox Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" Margin="10" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.RectParameterHeight, Mode=TwoWay}"/>
<TextBlock Grid.Row="4" VerticalAlignment="Center" HorizontalAlignment="Left" Text="Материал" Margin="10"/>
<Button Grid.Row="4" Grid.Column="1" Margin="10" Background="White"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.OpenMaterialCatalogWithSelection}" CommandParameter="{Binding}"
Content="{Binding MaterialName, Mode=TwoWay}"/>
<TextBlock Grid.Row="5" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10" Text="Цвет"/>
<Button Grid.Row="5" Grid.Column="1" Margin="10" Background="{Binding Brush, Mode=TwoWay}"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.SetColor}" CommandParameter="{Binding}"/>
<TextBlock Grid.Row="6" Margin="10" VerticalAlignment="Center" HorizontalAlignment="Left" Text="Прозрачность"/>
<TextBox Grid.Row="6" Grid.Column="1" VerticalAlignment="Center" Margin="10,10,50,10" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.ParameterOpacity, Mode=TwoWay}"/>
<TextBlock Grid.Row="6" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Right" Text="%" Margin="25,10"/>
<TextBlock Grid.Row="7" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10" Text="Заблокировать объект" Grid.ColumnSpan="2"/>
<CheckBox Grid.Row="7" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10" IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.ElementLock, Mode=TwoWay}"></CheckBox>
<TextBlock Grid.Row="8" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10" Text="Z-порядок"/>
<StackPanel Grid.Row="8" Grid.Column="1" Orientation="Horizontal">
<TextBox VerticalAlignment="Center" HorizontalAlignment="Left" Width="50" Margin="10"
Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.PrimitiveIndex, Mode=TwoWay}"/>
<TextBlock VerticalAlignment="Center" Text="Max = "/>
<TextBlock VerticalAlignment="Center" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.PrimitivesCount, Mode=TwoWay}"/>
</StackPanel>
<Button Grid.Row="9" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" Content="Установить впереди всех" Margin="10"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.SetInFrontOfAll}" CommandParameter="{Binding}"/>
<Button Grid.Row="9" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" Content="Установить позади всех" Margin="10"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.SetInBackOfAll}" CommandParameter="{Binding}"/>
<Button Grid.Row="10" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="10" Content="Установить параметры"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.SetParameters}" CommandParameter="{Binding}"/>
</Grid>
</Border>
</local:PrimitivePopup>
<!--Ellipse-->
<local:PrimitivePopup IsOpen="{Binding ParamsPanelVisibilty}" d:DataContext="{d:DesignInstance dataContexts:Ellipse}" Type="Ellipse">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeave">
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.SetPopupCanBeClosedTrue}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseEnter">
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.SetPopupCanBeClosedFalse}" CommandParameter="{Binding}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<Border Background="White" BorderBrush="Black" BorderThickness="1">
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="170"/>
<ColumnDefinition Width="170"/>
</Grid.ColumnDefinitions>
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Text="Координата центра X" Margin="10"/>
<TextBox Grid.Column="1" VerticalAlignment="Center" Margin="10" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.EllipseParameterX, Mode=TwoWay}"/>
<TextBlock Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Left" Text="Координата центра Y" Margin="10"/>
<TextBox Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" Margin="10" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.EllipseParameterY, Mode=TwoWay}"/>
<TextBlock Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Left" Text="Площадь" Margin="10"/>
<TextBox Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" Margin="10" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.EllipseParameterSquare, Mode=TwoWay}"/>
<TextBlock Grid.Row="4" VerticalAlignment="Center" HorizontalAlignment="Left" Text="Материал" Margin="10"/>
<Button Grid.Row="4" Grid.Column="1" Margin="10" Background="White"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.OpenMaterialCatalogWithSelection}" CommandParameter="{Binding}"
Content="{Binding MaterialName, Mode=TwoWay}"/>
<TextBlock Grid.Row="5" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10" Text="Цвет"/>
<Button Grid.Row="5" Grid.Column="1" Margin="10" Background="{Binding Brush, Mode=TwoWay}"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.SetColor}" CommandParameter="{Binding}"/>
<TextBlock Grid.Row="6" Margin="10" VerticalAlignment="Center" HorizontalAlignment="Left" Text="Прозрачность"/>
<TextBox Grid.Row="6" Grid.Column="1" VerticalAlignment="Center" Margin="10,10,50,10" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.ParameterOpacity, Mode=TwoWay}"/>
<TextBlock Grid.Row="6" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Right" Text="%" Margin="25,10"/>
<TextBlock Grid.Row="7" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10" Text="Заблокировать объект" Grid.ColumnSpan="2"/>
<CheckBox Grid.Row="7" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10" IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.ElementLock, Mode=TwoWay}"></CheckBox>
<TextBlock Grid.Row="8" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10" Text="Z-порядок"/>
<StackPanel Grid.Row="8" Grid.Column="1" Orientation="Horizontal">
<TextBox VerticalAlignment="Center" HorizontalAlignment="Left" Width="50" Margin="10"
Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.PrimitiveIndex, Mode=TwoWay}"/>
<TextBlock VerticalAlignment="Center" Text="Max = "/>
<TextBlock VerticalAlignment="Center" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.PrimitivesCount, Mode=TwoWay}"/>
</StackPanel>
<Button Grid.Row="9" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" Content="Установить впереди всех" Margin="10"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.SetInFrontOfAll}" CommandParameter="{Binding}"/>
<Button Grid.Row="9" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" Content="Установить позади всех" Margin="10"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.SetInBackOfAll}" CommandParameter="{Binding}"/>
<Button Grid.Row="10" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="10" Content="Установить параметры"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.SetParameters}" CommandParameter="{Binding}"/>
</Grid>
</Border>
</local:PrimitivePopup>
</Grid>
</UserControl>

View File

@@ -1,59 +0,0 @@
using System.Collections.Generic;
using StructureHelper.Infrastructure;
using StructureHelper.Models.Materials;
namespace StructureHelper.MaterialCatalogWindow
{
public class MaterialCatalogModel
{
public NamedList<MaterialDefinitionBase> ConcreteDefinitions;
public NamedList<MaterialDefinitionBase> RebarDefinitions;
public List<NamedList<MaterialDefinitionBase>> Materials;
public MaterialCatalogModel()
{
InitializeMaterialCollections();
Materials = new List<NamedList<MaterialDefinitionBase>>();
Materials.Add(ConcreteDefinitions);
Materials.Add(RebarDefinitions);
}
public void InitializeMaterialCollections()
{
InitializeConcreteDefinitions();
InitializeRebarDefinitions();
}
private void InitializeRebarDefinitions()
{
RebarDefinitions = new NamedList<MaterialDefinitionBase>()
{
new RebarDefinition("S240", 2, 240, 240, 1.15, 1.15),
new RebarDefinition("S400", 2, 400, 400, 1.15, 1.15),
new RebarDefinition("S500", 2, 500, 500, 1.15, 1.15)
};
RebarDefinitions.Name = "Арматура";
}
private void InitializeConcreteDefinitions()
{
ConcreteDefinitions = new NamedList<MaterialDefinitionBase>()
{
new ConcreteDefinition("C10", 0, 10, 0, 1.3, 1.5),
new ConcreteDefinition("C15", 0, 15, 0, 1.3, 1.5),
new ConcreteDefinition("C20", 0, 20, 0, 1.3, 1.5),
new ConcreteDefinition("C25", 0, 25, 0, 1.3, 1.5),
new ConcreteDefinition("C30", 0, 30, 0, 1.3, 1.5),
new ConcreteDefinition("C35", 0, 35, 0, 1.3, 1.5),
new ConcreteDefinition("C40", 0, 40, 0, 1.3, 1.5),
new ConcreteDefinition("C45", 0, 45, 0, 1.3, 1.5),
new ConcreteDefinition("C50", 0, 50, 0, 1.3, 1.5),
new ConcreteDefinition("C60", 0, 60, 0, 1.3, 1.5),
new ConcreteDefinition("C70", 0, 70, 0, 1.3, 1.5),
new ConcreteDefinition("C80", 0, 80, 0, 1.3, 1.5)
};
ConcreteDefinitions.Name = "Бетон";
}
}
}

View File

@@ -1,80 +0,0 @@
<Window x:Class="StructureHelper.MaterialCatalogWindow.MaterialCatalogView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:StructureHelper"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance local:MaterialCatalogViewModel}"
Title="Справочник материалов" Height="900" Width="1100">
<Window.Resources>
<DataTemplate x:Key="RebarYoungModulusTemplate">
<StackPanel Orientation="Horizontal">
<TextBox VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0" Text="{Binding YoungModulus}"/>
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Text=" x 10^11"/>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="CompressiveStrengthTemplate">
<StackPanel Orientation="Horizontal">
<TextBox VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0" Text="{Binding CompressiveStrength}"/>
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Text=" x 10^6"/>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="TensileStrengthTemplate">
<StackPanel Orientation="Horizontal">
<TextBox VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0" Text="{Binding TensileStrength}"/>
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Text=" x 10^6"/>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="MaterialClassTemplate">
<TextBox VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0" Text="{Binding MaterialClass}"/>
</DataTemplate>
<DataTemplate x:Key="MaterialCoefInCompressTemplate">
<TextBox VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0" Text="{Binding MaterialCoefInCompress}"/>
</DataTemplate>
<DataTemplate x:Key="MaterialCoefInTensionTemplate">
<TextBox VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0" Text="{Binding MaterialCoefInTension}"/>
</DataTemplate>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Margin="10">
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Margin="10,20,10,10" Text="Бетон" FontSize="16"/>
<DataGrid ItemsSource="{Binding ConcreteDefinitions}" AutoGenerateColumns="False" SelectedItem="{Binding SelectedMaterial}">
<DataGrid.Columns>
<DataGridTemplateColumn Header="Класс" CellTemplate="{StaticResource MaterialClassTemplate}"/>
<DataGridTextColumn Header="Модуль упругости" Binding="{Binding YoungModulus, StringFormat={}{0} x 10^6}" IsReadOnly="True"/>
<DataGridTemplateColumn Header="Нормативная прочность на сжатие" CellTemplate="{StaticResource CompressiveStrengthTemplate}"/>
<DataGridTextColumn Header="Нормативная прочность на растяжение" Binding="{Binding TensileStrength, StringFormat={}{0} x 10^3}" IsReadOnly="True"/>
<DataGridTemplateColumn Header="Коэффициент надежности при сжатии" CellTemplate="{StaticResource MaterialCoefInCompressTemplate}"/>
<DataGridTemplateColumn Header="Коэффициент надежности при растяжении" CellTemplate="{StaticResource MaterialCoefInTensionTemplate}"/>
</DataGrid.Columns>
</DataGrid>
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Margin="10,20,10,10" Text="Арматура" FontSize="16"/>
<DataGrid ItemsSource="{Binding RebarDefinitions}" AutoGenerateColumns="False" SelectedItem="{Binding SelectedMaterial}">
<DataGrid.Columns>
<DataGridTemplateColumn Header="Класс" CellTemplate="{StaticResource MaterialClassTemplate}"/>
<DataGridTemplateColumn Header="Модуль упругости" CellTemplate="{StaticResource RebarYoungModulusTemplate}"/>
<DataGridTemplateColumn Header="Нормативная прочность на сжатие" CellTemplate="{StaticResource CompressiveStrengthTemplate}"/>
<DataGridTemplateColumn Header="Нормативная прочность на растяжение" CellTemplate="{StaticResource TensileStrengthTemplate}"/>
<DataGridTemplateColumn Header="Коэффициент надежности при сжатии" CellTemplate="{StaticResource MaterialCoefInCompressTemplate}"/>
<DataGridTemplateColumn Header="Коэффициент надежности при растяжении" CellTemplate="{StaticResource MaterialCoefInTensionTemplate}"/>
</DataGrid.Columns>
</DataGrid>
</StackPanel>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="300"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Content="Добавить материал" Margin="10" Command="{Binding AddMaterial}"/>
<Button Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Content="Выбрать материал" Margin="10" Command="{Binding SelectMaterial}" Visibility="{Binding SelectMaterialButtonVisibility}"/>
<Button Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Left" Content="Сохранить справочник" Margin="10" Command="{Binding SaveCatalog}"/>
<Button Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Right" Content="Загрузить справочник" Margin="10" Command="{Binding LoadCatalog}"/>
</Grid>
</Grid>
</Window>

View File

@@ -1,19 +0,0 @@
using System.Windows;
using StructureHelper.Infrastructure.UI.DataContexts;
namespace StructureHelper.MaterialCatalogWindow
{
/// <summary>
/// Логика взаимодействия для MaterialCatalogView.xaml
/// </summary>
public partial class MaterialCatalogView : Window
{
public MaterialCatalogView(bool isMaterialCanBeSelected = false, PrimitiveBase primitive = null)
{
var materialCatalogModel = new MaterialCatalogModel();
var materialCatalogViewModel = new MaterialCatalogViewModel(materialCatalogModel, this, isMaterialCanBeSelected, primitive);
DataContext = materialCatalogViewModel;
InitializeComponent();
}
}
}

View File

@@ -1,121 +0,0 @@
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Input;
using Newtonsoft.Json;
using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.Models.Materials;
using StructureHelper.Properties;
using StructureHelper.Windows.AddMaterialWindow;
using OpenFileDialog = System.Windows.Forms.OpenFileDialog;
using SaveFileDialog = System.Windows.Forms.SaveFileDialog;
namespace StructureHelper.MaterialCatalogWindow
{
[JsonObject(MemberSerialization.OptIn)]
public class MaterialCatalogViewModel : INotifyPropertyChanged
{
private MaterialCatalogModel materialCatalogModel;
private MaterialCatalogView materialCatalogView;
[JsonProperty]
public ObservableCollection<MaterialDefinitionBase> ConcreteDefinitions { get; set; }
[JsonProperty]
public ObservableCollection<MaterialDefinitionBase> RebarDefinitions { get; set; }
public ICommand AddMaterial { get; }
public ICommand SaveCatalog { get; }
public ICommand LoadCatalog { get; }
public ICommand SelectMaterial { get; }
private MaterialDefinitionBase selectedMaterial;
public MaterialDefinitionBase SelectedMaterial
{
get => selectedMaterial;
set
{
selectedMaterial = value;
OnPropertyChanged();
}
}
private bool isMaterialCanBeSelected;
public bool IsMaterialCanBeSelected
{
get => isMaterialCanBeSelected;
set
{
isMaterialCanBeSelected = value;
OnPropertyChanged();
OnPropertyChanged(nameof(SelectMaterialButtonVisibility));
}
}
public Visibility SelectMaterialButtonVisibility => IsMaterialCanBeSelected ? Visibility.Visible : Visibility.Hidden;
public MaterialCatalogViewModel() { }
public MaterialCatalogViewModel(MaterialCatalogModel materialCatalogModel, MaterialCatalogView materialCatalogView, bool isMaterialCanBeSelected, PrimitiveBase primitive = null)
{
this.materialCatalogModel = materialCatalogModel;
this.materialCatalogView = materialCatalogView;
IsMaterialCanBeSelected = isMaterialCanBeSelected;
ConcreteDefinitions = new ObservableCollection<MaterialDefinitionBase>(materialCatalogModel.ConcreteDefinitions);
RebarDefinitions = new ObservableCollection<MaterialDefinitionBase>(materialCatalogModel.RebarDefinitions);
AddMaterial = new RelayCommand(o =>
{
AddMaterialView addMaterialView = new AddMaterialView(this.materialCatalogModel, this);
addMaterialView.ShowDialog();
OnPropertyChanged(nameof(ConcreteDefinitions));
OnPropertyChanged(nameof(RebarDefinitions));
});
SaveCatalog = new RelayCommand(o =>
{
string json = JsonConvert.SerializeObject(this, Formatting.Indented);
SaveFileDialog saveDialog = new SaveFileDialog();
saveDialog.InitialDirectory = @"C:\";
saveDialog.Filter = "json files (*.json)|*.json|All files(*.*)|*.*";
string path = null;
if (saveDialog.ShowDialog() == DialogResult.OK)
{
path = saveDialog.FileName;
File.WriteAllText(path, json);
}
});
LoadCatalog = new RelayCommand(o =>
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.InitialDirectory = @"C:\";
openFileDialog.Filter = "json files (*.json)|*.json|All files(*.*)|*.*";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
var path = openFileDialog.FileName;
var content = File.ReadAllText(path);
var vm = JsonConvert.DeserializeObject<MaterialCatalogViewModel>(content);
ConcreteDefinitions = vm.ConcreteDefinitions;
OnPropertyChanged(nameof(ConcreteDefinitions));
RebarDefinitions = vm.RebarDefinitions;
OnPropertyChanged(nameof(RebarDefinitions));
}
});
SelectMaterial = new RelayCommand(o =>
{
if (primitive != null)
primitive.Material = SelectedMaterial;
});
}
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}

View File

@@ -1,18 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MaterialResistanceCalc
{
public class ConcreteDefinition : MaterialDefinition
{
public ConcreteDefinition(string materialClass, double youngModulus, double compressiveStrengthCoef, double tensileStrengthCoef, double materialCoefInCompress, double materialCoefInTension)
: base(materialClass, youngModulus, compressiveStrengthCoef, tensileStrengthCoef, materialCoefInCompress, materialCoefInTension)
{
CompressiveStrength = compressiveStrengthCoef * Math.Pow(10, 6);
TensileStrength = tensileStrengthCoef * Math.Sqrt(CompressiveStrength);
}
}
}

View File

@@ -1,28 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MaterialResistanceCalc
{
public class MaterialDefinition
{
public string MaterialClass { get; set; }
public double YoungModulus { get; set; }
public double CompressiveStrength { get; set; }
public double TensileStrength { get; set; }
public double MaterialCoefInCompress { get; set; }
public double MaterialCoefInTension { get; set; }
public MaterialDefinition(string materialClass, double youngModulus, double compressiveStrengthCoef, double tensileStrengthCoef, double materialCoefInCompress, double materialCoefInTension)
{
MaterialClass = materialClass;
YoungModulus = youngModulus;
CompressiveStrength = compressiveStrengthCoef;
TensileStrength = tensileStrengthCoef;
MaterialCoefInCompress = materialCoefInCompress;
MaterialCoefInTension = materialCoefInTension;
}
}
}

View File

@@ -1,18 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MaterialResistanceCalc
{
public class RebarDefinition : MaterialDefinition
{
public RebarDefinition(string materialClass, double youngModulus, double compressiveStrengthCoef, double tensileStrengthCoef, double materialCoefInCompress, double materialCoefInTension) : base(materialClass, youngModulus, compressiveStrengthCoef, tensileStrengthCoef, materialCoefInCompress, materialCoefInTension)
{
YoungModulus = youngModulus * Math.Pow(10, 11);
CompressiveStrength = compressiveStrengthCoef * Math.Pow(10, 6);
TensileStrength = tensileStrengthCoef * Math.Pow(10, 6);
}
}
}

View File

@@ -1,159 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{BAD27E27-4444-4300-ADF8-E21042C0781D}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>StructureHelper</RootNamespace>
<AssemblyName>StructureHelper</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Expression.Interactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>packages\System.Windows.Interactivity.WPF.2.0.20525\lib\net40\Microsoft.Expression.Interactions.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>packages\System.Windows.Interactivity.WPF.2.0.20525\lib\net40\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Infrastructure\Enums\PrimitiveType.cs" />
<Compile Include="Infrastructure\UI\UserControls\PrimitivePopup.xaml.cs">
<DependentUpon>PrimitivePopup.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\AddMaterialWindow\AddMaterialView.xaml.cs">
<DependentUpon>AddMaterialView.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\AddMaterialWindow\AddMaterialViewModel.cs" />
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Windows\ColorPickerWindow\ColorPickerView.xaml.cs">
<DependentUpon>ColorPickerView.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\ColorPickerWindow\ColorPickerViewModel.cs" />
<Compile Include="Infrastructure\Extensions\ObservableCollectionExtensions.cs" />
<Compile Include="Infrastructure\EventTriggerBase.cs" />
<Compile Include="Infrastructure\UI\Triggers\MouseEventTriggers\MouseWheelUpEventTrigger.cs" />
<Compile Include="Infrastructure\UI\Triggers\MouseEventTriggers\MouseWheelDownEventTrigger.cs" />
<Compile Include="Infrastructure\ViewModelBase.cs" />
<Compile Include="Models\Materials\ConcreteDefinition.cs" />
<Compile Include="Infrastructure\NamedList.cs" />
<Compile Include="Models\Materials\MaterialDefinitionBase.cs" />
<Compile Include="Infrastructure\UI\DataContexts\Ellipse.cs" />
<Compile Include="Infrastructure\UI\DataContexts\PrimitiveBase.cs" />
<Compile Include="Properties\Annotations.cs" />
<Compile Include="Models\Materials\RebarDefinition.cs" />
<Compile Include="Infrastructure\UI\DataContexts\Rectangle.cs" />
<Compile Include="Infrastructure\UI\DataTemplates\EllipseTemplate.xaml.cs">
<DependentUpon>EllipseTemplate.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\MainWindow\MainModel.cs" />
<Compile Include="Windows\MainWindow\MainView.xaml.cs" />
<Compile Include="Windows\MainWindow\MainViewModel.cs" />
<Compile Include="Infrastructure\RelayCommand.cs" />
<Compile Include="Infrastructure\UI\DataTemplates\RectangleTemplate.xaml.cs">
<DependentUpon>RectangleTemplate.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Infrastructure\UI\Triggers\MouseEventTriggers\DoubleClickEventTrigger.cs" />
<Compile Include="Infrastructure\EventArgs.cs" />
<Compile Include="MaterialCatalogWindow\MaterialCatalogModel.cs" />
<Compile Include="MaterialCatalogWindow\MaterialCatalogView.xaml.cs" />
<Compile Include="MaterialCatalogWindow\MaterialCatalogViewModel.cs" />
<Compile Include="Infrastructure\MouseBehaviour.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Page Include="Infrastructure\UI\Styles.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Infrastructure\UI\UserControls\PrimitivePopup.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\AddMaterialWindow\AddMaterialView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\ColorPickerWindow\ColorPickerView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MaterialCatalogWindow\MaterialCatalogView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Infrastructure\UI\DataTemplates\EllipseTemplate.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\MainWindow\MainView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Infrastructure\UI\DataTemplates\RectangleTemplate.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -1,11 +1,19 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.32002.261
# Visual Studio Version 17
VisualStudioVersion = 17.2.32630.192
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StructureHelper", "StructureHelper.csproj", "{BAD27E27-4444-4300-ADF8-E21042C0781D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StructureHelperTests", "StructureHelperTests\StructureHelperTests.csproj", "{7AC480BB-8A34-4913-B7AA-C6A5D7F35509}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StructureHelperTests", ".\StructureHelperTests\StructureHelperTests.csproj", "{7AC480BB-8A34-4913-B7AA-C6A5D7F35509}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FieldVisualzerDemo", "FiledVisualzerDemo\FieldVisualzerDemo.csproj", "{C92A5F2E-567B-48C9-A524-5740DB03509D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StructureHelper", "StructureHelper\StructureHelper.csproj", "{271311DE-67EE-4EE8-93EA-EA8BFD366EC6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StructureHelperCommon", "StructureHelperCommon\StructureHelperCommon.csproj", "{F1548BD2-7FE8-46C2-9BC4-9BA813A5C59A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StructureHelperLogics", "StructureHelperLogics\StructureHelperLogics.csproj", "{C9192AE7-EE6D-409C-A05C-3549D78CBB34}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FieldVisualizer", "FieldVisualizer\FieldVisualizer.csproj", "{6CAC5B83-81F3-47C2-92A1-0F94A58491C2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -13,14 +21,30 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BAD27E27-4444-4300-ADF8-E21042C0781D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BAD27E27-4444-4300-ADF8-E21042C0781D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BAD27E27-4444-4300-ADF8-E21042C0781D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BAD27E27-4444-4300-ADF8-E21042C0781D}.Release|Any CPU.Build.0 = Release|Any CPU
{7AC480BB-8A34-4913-B7AA-C6A5D7F35509}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7AC480BB-8A34-4913-B7AA-C6A5D7F35509}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7AC480BB-8A34-4913-B7AA-C6A5D7F35509}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7AC480BB-8A34-4913-B7AA-C6A5D7F35509}.Release|Any CPU.Build.0 = Release|Any CPU
{C92A5F2E-567B-48C9-A524-5740DB03509D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C92A5F2E-567B-48C9-A524-5740DB03509D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C92A5F2E-567B-48C9-A524-5740DB03509D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C92A5F2E-567B-48C9-A524-5740DB03509D}.Release|Any CPU.Build.0 = Release|Any CPU
{271311DE-67EE-4EE8-93EA-EA8BFD366EC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{271311DE-67EE-4EE8-93EA-EA8BFD366EC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{271311DE-67EE-4EE8-93EA-EA8BFD366EC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{271311DE-67EE-4EE8-93EA-EA8BFD366EC6}.Release|Any CPU.Build.0 = Release|Any CPU
{F1548BD2-7FE8-46C2-9BC4-9BA813A5C59A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F1548BD2-7FE8-46C2-9BC4-9BA813A5C59A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F1548BD2-7FE8-46C2-9BC4-9BA813A5C59A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F1548BD2-7FE8-46C2-9BC4-9BA813A5C59A}.Release|Any CPU.Build.0 = Release|Any CPU
{C9192AE7-EE6D-409C-A05C-3549D78CBB34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C9192AE7-EE6D-409C-A05C-3549D78CBB34}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C9192AE7-EE6D-409C-A05C-3549D78CBB34}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C9192AE7-EE6D-409C-A05C-3549D78CBB34}.Release|Any CPU.Build.0 = Release|Any CPU
{6CAC5B83-81F3-47C2-92A1-0F94A58491C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6CAC5B83-81F3-47C2-92A1-0F94A58491C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6CAC5B83-81F3-47C2-92A1-0F94A58491C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6CAC5B83-81F3-47C2-92A1-0F94A58491C2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

4
StructureHelper/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
*\obj
*\bin
*\packages
*\.vs

25
StructureHelper/App.xaml Normal file
View File

@@ -0,0 +1,25 @@
<Application x:Class="StructureHelper.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:StructureHelper">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Infrastructure/UI/Resources/CommonEnums.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Styles.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/DataGridStyles.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/ButtonStyles.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/Converters.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/DataGridTemplates.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/PrimitiveTemplates.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/ShapeEditTemplates.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/PrimitiveToolTips.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/ITemEditPanels.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/ForceTemplates.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/IconDictionary.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/GraphsTemplates.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/LimitCurveTemplates.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

View File

@@ -0,0 +1,43 @@
using StructureHelper.Services.Primitives;
using StructureHelper.UnitSystem;
using StructureHelper.Windows.MainWindow;
using StructureHelperLogics.Services.NdmCalculations;
using System.Windows;
using Autofac;
namespace StructureHelper
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public static IContainer Container { get; private set; }
public static ILifetimeScope Scope { get; private set; }
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
var builder = new ContainerBuilder();
builder.RegisterType<PrimitiveRepository>().As<IPrimitiveRepository>().SingleInstance();
builder.RegisterType<UnitSystemService>().AsSelf().SingleInstance();
builder.RegisterType<CalculationService>().AsSelf().SingleInstance();
builder.RegisterType<MainModel>().AsSelf().SingleInstance();
builder.RegisterType<MainViewModel>().AsSelf().SingleInstance();
builder.RegisterType<MainView>().AsSelf();
Container = builder.Build();
Scope = Container.Resolve<ILifetimeScope>();
var window = Scope.Resolve<MainView>();
window.Show();
}
protected override void OnExit(ExitEventArgs e)
{
Scope.Dispose();
base.OnExit(e);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 MiB

View File

@@ -0,0 +1,7 @@
Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,7 @@
Copyright (c) 2023 Редикульцев Евгений, Екатеринбург, Россия
Данная лицензия разрешает лицам, получившим копию данного программного обеспечения и сопутствующей документации (далее — Программное обеспечение), безвозмездно использовать Программное обеспечение без ограничений, включая неограниченное право на использование, копирование, изменение, слияние, публикацию, распространение, сублицензирование и/или продажу копий Программного обеспечения, а также лицам, которым предоставляется данное Программное обеспечение, при соблюдении следующих условий:
Указанное выше уведомление об авторском праве и данные условия должны быть включены во все копии или значимые части данного Программного обеспечения.
ДАННОЕ ПРОГРАММНОЕ ОБЕСПЕЧЕНИЕ ПРЕДОСТАВЛЯЕТСЯ «КАК ЕСТЬ», БЕЗ КАКИХ-ЛИБО ГАРАНТИЙ, ЯВНО ВЫРАЖЕННЫХ ИЛИ ПОДРАЗУМЕВАЕМЫХ, ВКЛЮЧАЯ ГАРАНТИИ ТОВАРНОЙ ПРИГОДНОСТИ, СООТВЕТСТВИЯ ПО ЕГО КОНКРЕТНОМУ НАЗНАЧЕНИЮ И ОТСУТСТВИЯ НАРУШЕНИЙ, НО НЕ ОГРАНИЧИВАЯСЬ ИМИ. НИ В КАКОМ СЛУЧАЕ АВТОРЫ ИЛИ ПРАВООБЛАДАТЕЛИ НЕ НЕСУТ ОТВЕТСТВЕННОСТИ ПО КАКИМ-ЛИБО ИСКАМ, ЗА УЩЕРБ ИЛИ ПО ИНЫМ ТРЕБОВАНИЯМ, В ТОМ ЧИСЛЕ, ПРИ ДЕЙСТВИИ КОНТРАКТА, ДЕЛИКТЕ ИЛИ ИНОЙ СИТУАЦИИ, ВОЗНИКШИМ ИЗ-ЗА ИСПОЛЬЗОВАНИЯ ПРОГРАММНОГО ОБЕСПЕЧЕНИЯ ИЛИ ИНЫХ ДЕЙСТВИЙ С ПРОГРАММНЫМ ОБЕСПЕЧЕНИЕМ.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.Enums
{
public enum ActionType
{
ForceCombination,
ForceCombinationByFactor
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.Enums
{
public enum CalculatorTypes
{
ForceCalculator,
LimitCurveCalculator,
FireCalculator
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.Enums
{
internal enum MaterialType
{
Concrete,
Reinforcement,
Elastic,
CarbonFiber,
GlassFiber
}
}

View File

@@ -2,7 +2,9 @@
{
public enum PrimitiveType
{
Ellipse,
Rectangle
Point,
Rectangle,
Circle,
Reinforcement
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace StructureHelper.Infrastructure.UI.Converters.Common
{
[ValueConversion(typeof(bool), typeof(bool))]
public class InvertBoolConverter : IValueConverter
{
public InvertBoolConverter()
{
}
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value != null && value is bool)
{
return !((bool)value);
}
return true;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return Convert(value, targetType, parameter, culture);
}
}
}

View File

@@ -0,0 +1,20 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Services.Units;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace StructureHelper.Infrastructure.UI.Converters.Units
{
internal class Area : UnitBase
{
public override UnitTypes UnitType { get => UnitTypes.Area; }
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "mm2"); }
public override string UnitName { get => "Area"; }
}
}

View File

@@ -0,0 +1,17 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Services.Units;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.UI.Converters.Units
{
internal class Curvature : UnitBase
{
public override UnitTypes UnitType { get => UnitTypes.Curvature; }
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "1/mm"); }
public override string UnitName { get => "Curvature"; }
}
}

View File

@@ -0,0 +1,19 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Services.Units;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace StructureHelper.Infrastructure.UI.Converters.Units
{
internal class Force : UnitBase
{
public override UnitTypes UnitType { get => UnitTypes.Force; }
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "kN"); }
public override string UnitName { get => "Force"; }
}
}

View File

@@ -0,0 +1,12 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Services.Units;
namespace StructureHelper.Infrastructure.UI.Converters.Units
{
internal class Length : UnitBase
{
public override UnitTypes UnitType { get => UnitTypes.Length; }
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "mm"); }
public override string UnitName { get => "Length"; }
}
}

View File

@@ -0,0 +1,17 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Services.Units;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.UI.Converters.Units
{
internal class Moment : UnitBase
{
public override UnitTypes UnitType { get => UnitTypes.Moment; }
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "kNm"); }
public override string UnitName { get => "Moment"; }
}
}

View File

@@ -0,0 +1,39 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Services.Units;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace StructureHelper.Infrastructure.UI.Converters.Units
{
internal class PlainDouble : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
try
{
return (double)value;
}
catch(Exception)
{
return new StructureHelperException(ErrorStrings.DataIsInCorrect);
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
try
{
return CommonOperation.ConvertToDoubleChangeComma((string)value);
}
catch (Exception)
{
return new StructureHelperException(ErrorStrings.DataIsInCorrect);
}
}
}
}

View File

@@ -0,0 +1,19 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Services.Units;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace StructureHelper.Infrastructure.UI.Converters.Units
{
internal class Stress : UnitBase
{
public override UnitTypes UnitType { get => UnitTypes.Stress; }
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "MPa"); }
public override string UnitName { get => "Stress"; }
}
}

View File

@@ -0,0 +1,39 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Services.Units;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
namespace StructureHelper.Infrastructure.UI.Converters.Units
{
internal abstract class UnitBase : IValueConverter
{
public abstract UnitTypes UnitType { get; }
public abstract IUnit CurrentUnit { get; }
public abstract string UnitName { get;}
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return CommonOperation.Convert(CurrentUnit, UnitName, value);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
try
{
return CommonOperation.ConvertBack(UnitType, CurrentUnit, value);
}
catch (Exception)
{
MessageBox.Show($"Value of {UnitName}={(string)value} is not correct", "Error of conversion", MessageBoxButtons.OK);
return 0;
}
}
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.UI.Converters.Units
{
internal static class UnitConstants
{
public static double Length = 1e3d;
public static double Force = 1e-3d;
public static double Stress = 1e-6d;
}
}

View File

@@ -0,0 +1,64 @@
using StructureHelper.Infrastructure.UI.Converters.Units;
using StructureHelper.Windows.ViewModels.NdmCrossSections;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
public class CircleViewPrimitive : PrimitiveBase, IHasCenter
{
ICirclePrimitive primitive;
public double Diameter
{
get
{
return primitive.Diameter;
}
set
{
primitive.Diameter = value;
RefreshPlacement();
}
}
public double PrimitiveLeft => DeltaX - Diameter / 2d;
public double PrimitiveTop => DeltaY - Diameter / 2d;
public CircleViewPrimitive(INdmPrimitive primitive) : base(primitive)
{
if (primitive is not ICirclePrimitive)
{
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $"\nExpected: {nameof(ICirclePrimitive)}, But was: {nameof(primitive)}");
}
var circle = primitive as ICirclePrimitive;
this.primitive = circle;
DivisionViewModel = new HasDivisionViewModel(circle);
}
public override INdmPrimitive GetNdmPrimitive()
{
return primitive;
}
private void RefreshPlacement()
{
OnPropertyChanged(nameof(Diameter));
OnPropertyChanged(nameof(CenterX));
OnPropertyChanged(nameof(CenterY));
OnPropertyChanged(nameof(PrimitiveLeft));
OnPropertyChanged(nameof(PrimitiveTop));
}
public override void Refresh()
{
OnPropertyChanged(nameof(Diameter));
OnPropertyChanged(nameof(PrimitiveLeft));
OnPropertyChanged(nameof(PrimitiveTop));
base.Refresh();
}
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
internal static class ViewPrimitiveFactory
{
// to do public static PrimitiveBase GetViewPrimitive() { }
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
internal interface IHasCenter
{
double PrimitiveLeft { get; }
double PrimitiveTop { get; }
}
}

Some files were not shown because too many files have changed in this diff Show More