diff --git a/.editorconfig b/.editorconfig
deleted file mode 100644
index cbb77773d..000000000
--- a/.editorconfig
+++ /dev/null
@@ -1,4 +0,0 @@
-; 4-column space indentation
-[*.{cs,tt}]
-indent_style = space
-indent_size = 4
\ No newline at end of file
diff --git a/CSharpCodeStyle.SpaceIndent.DotSettings b/CSharpCodeStyle.SpaceIndent.DotSettings
deleted file mode 100644
index 9174a55bd..000000000
--- a/CSharpCodeStyle.SpaceIndent.DotSettings
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- False
- USE_SPACES_ONLY
-
- True
-
\ No newline at end of file
diff --git a/FractalPainter/App/Actions/DragonFractalAction.cs b/FractalPainter/App/Actions/DragonFractalAction.cs
deleted file mode 100644
index a9a37d562..000000000
--- a/FractalPainter/App/Actions/DragonFractalAction.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System;
-using FractalPainting.App.Fractals;
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Infrastructure.Injection;
-using FractalPainting.Infrastructure.UiActions;
-using Ninject;
-
-namespace FractalPainting.App.Actions
-{
- public class DragonFractalAction : IUiAction, INeed
- {
- private IImageHolder imageHolder;
-
- public void SetDependency(IImageHolder dependency)
- {
- imageHolder = dependency;
- }
-
- public string Category => "Фракталы";
- public string Name => "Дракон";
- public string Description => "Дракон Хартера-Хейтуэя";
-
- public void Perform()
- {
- var dragonSettings = CreateRandomSettings();
- // редактируем настройки:
- SettingsForm.For(dragonSettings).ShowDialog();
- // создаём painter с такими настройками
- var container = new StandardKernel();
- container.Bind().ToConstant(imageHolder);
- container.Bind().ToConstant(dragonSettings);
- container.Get().Paint();
- }
-
- private static DragonSettings CreateRandomSettings()
- {
- return new DragonSettingsGenerator(new Random()).Generate();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/App/Actions/ImageSettingsAction.cs b/FractalPainter/App/Actions/ImageSettingsAction.cs
deleted file mode 100644
index eb0ea0421..000000000
--- a/FractalPainter/App/Actions/ImageSettingsAction.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Infrastructure.Injection;
-using FractalPainting.Infrastructure.UiActions;
-
-namespace FractalPainting.App.Actions
-{
- public class ImageSettingsAction : IUiAction, INeed, INeed
- {
- private IImageHolder imageHolder;
- private IImageSettingsProvider imageSettingsProvider;
-
- public void SetDependency(IImageHolder dependency)
- {
- imageHolder = dependency;
- }
-
- public void SetDependency(IImageSettingsProvider dependency)
- {
- imageSettingsProvider = dependency;
- }
-
- public string Category => "Настройки";
- public string Name => "Изображение...";
- public string Description => "Размеры изображения";
-
- public void Perform()
- {
- var imageSettings = imageSettingsProvider.ImageSettings;
- SettingsForm.For(imageSettings).ShowDialog();
- imageHolder.RecreateImage(imageSettings);
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/App/Actions/KochFractalAction.cs b/FractalPainter/App/Actions/KochFractalAction.cs
deleted file mode 100644
index bec694807..000000000
--- a/FractalPainter/App/Actions/KochFractalAction.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using FractalPainting.App.Fractals;
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Infrastructure.Injection;
-using FractalPainting.Infrastructure.UiActions;
-using Ninject;
-
-namespace FractalPainting.App.Actions
-{
- public class KochFractalAction : IUiAction, INeed, INeed
- {
- private IImageHolder imageHolder;
- private Palette palette;
-
- public void SetDependency(IImageHolder dependency)
- {
- imageHolder = dependency;
- }
-
- public void SetDependency(Palette dependency)
- {
- palette = dependency;
- }
-
- public string Category => "Фракталы";
- public string Name => "Кривая Коха";
- public string Description => "Кривая Коха";
-
- public void Perform()
- {
- var container = new StandardKernel();
- container.Bind().ToConstant(imageHolder);
- container.Bind().ToConstant(palette);
-
- container.Get().Paint();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/App/Actions/PaletteSettingsAction.cs b/FractalPainter/App/Actions/PaletteSettingsAction.cs
deleted file mode 100644
index e73d195fb..000000000
--- a/FractalPainter/App/Actions/PaletteSettingsAction.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Infrastructure.Injection;
-using FractalPainting.Infrastructure.UiActions;
-
-namespace FractalPainting.App.Actions
-{
- public class PaletteSettingsAction : IUiAction, INeed
- {
- private Palette palette;
-
- public void SetDependency(Palette dependency)
- {
- palette = dependency;
- }
-
- public string Category => "Настройки";
- public string Name => "Палитра...";
- public string Description => "Цвета для рисования фракталов";
-
- public void Perform()
- {
- SettingsForm.For(palette).ShowDialog();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/App/Actions/SaveImageAction.cs b/FractalPainter/App/Actions/SaveImageAction.cs
deleted file mode 100644
index 1c1ef2fab..000000000
--- a/FractalPainter/App/Actions/SaveImageAction.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using System.IO;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Infrastructure.Injection;
-using FractalPainting.Infrastructure.UiActions;
-
-namespace FractalPainting.App.Actions
-{
- public class SaveImageAction : IUiAction, INeed, INeed
- {
- private IImageDirectoryProvider imageDirectoryProvider;
- private IImageHolder imageHolder;
-
- public void SetDependency(IImageDirectoryProvider dependency)
- {
- imageDirectoryProvider = dependency;
- }
-
- public void SetDependency(IImageHolder dependency)
- {
- imageHolder = dependency;
- }
-
- public string Category => "Файл";
- public string Name => "Сохранить...";
- public string Description => "Сохранить изображение в файл";
-
- public void Perform()
- {
- var dialog = new SaveFileDialog
- {
- CheckFileExists = false,
- InitialDirectory = Path.GetFullPath(imageDirectoryProvider.ImagesDirectory),
- DefaultExt = "bmp",
- FileName = "image.bmp",
- Filter = "Изображения (*.bmp)|*.bmp"
- };
- var res = dialog.ShowDialog();
- if (res == DialogResult.OK)
- imageHolder.SaveImage(dialog.FileName);
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/App/AppSettings.cs b/FractalPainter/App/AppSettings.cs
deleted file mode 100644
index b4db60ea4..000000000
--- a/FractalPainter/App/AppSettings.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.App
-{
- public class AppSettings : IImageDirectoryProvider, IImageSettingsProvider
- {
- public string ImagesDirectory { get; set; }
- public ImageSettings ImageSettings { get; set; }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/App/Fractals/DragonPainter.cs b/FractalPainter/App/Fractals/DragonPainter.cs
deleted file mode 100644
index 1f83d61c1..000000000
--- a/FractalPainter/App/Fractals/DragonPainter.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System;
-using System.Drawing;
-using System.Linq;
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.App.Fractals
-{
- public class DragonPainter
- {
- private readonly IImageHolder imageHolder;
- private readonly DragonSettings settings;
- private readonly float size;
- private Size imageSize;
-
- public DragonPainter(IImageHolder imageHolder, DragonSettings settings)
- {
- this.imageHolder = imageHolder;
- this.settings = settings;
- imageSize = imageHolder.GetImageSize();
- size = Math.Min(imageSize.Width, imageSize.Height)/2.1f;
- }
-
- public void Paint()
- {
- using (var graphics = imageHolder.StartDrawing())
- {
- graphics.FillRectangle(Brushes.Black, 0, 0, imageSize.Width, imageSize.Height);
- var r = new Random();
- var cosa = (float) Math.Cos(settings.Angle1);
- var sina = (float) Math.Sin(settings.Angle1);
- var cosb = (float) Math.Cos(settings.Angle2);
- var sinb = (float) Math.Sin(settings.Angle2);
- var shiftX = settings.ShiftX*size*0.8f;
- var shiftY = settings.ShiftY*size*0.8f;
- var scale = settings.Scale;
- var p = new PointF(0, 0);
- foreach (var i in Enumerable.Range(0, settings.IterationsCount))
- {
- graphics.FillRectangle(Brushes.Yellow, imageSize.Width/3f + p.X, imageSize.Height/2f + p.Y, 1, 1);
- if (r.Next(0, 2) == 0)
- p = new PointF(scale*(p.X*cosa - p.Y*sina), scale*(p.X*sina + p.Y*cosa));
- else
- p = new PointF(scale*(p.X*cosb - p.Y*sinb) + shiftX, scale*(p.X*sinb + p.Y*cosb) + shiftY);
- if (i%100 == 0) imageHolder.UpdateUi();
- }
- }
- imageHolder.UpdateUi();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/App/Fractals/DragonSettings.cs b/FractalPainter/App/Fractals/DragonSettings.cs
deleted file mode 100644
index 084e55d38..000000000
--- a/FractalPainter/App/Fractals/DragonSettings.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-
-namespace FractalPainting.App.Fractals
-{
- public class DragonSettings
- {
- public double Angle1 { get; set; } = Math.PI / 4;
- public double Angle2 { get; set; } = 3 * Math.PI / 4;
- public float ShiftX { get; set; } = 1;
- public float ShiftY { get; set; } = 0;
- public float Scale { get; set; } = (float)(1 / Math.Sqrt(2));
- public int IterationsCount { get; set; } = 20000;
-
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/App/Fractals/DragonSettingsGenerator.cs b/FractalPainter/App/Fractals/DragonSettingsGenerator.cs
deleted file mode 100644
index baec5b400..000000000
--- a/FractalPainter/App/Fractals/DragonSettingsGenerator.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System;
-
-namespace FractalPainting.App.Fractals
-{
- public class DragonSettingsGenerator
- {
- private readonly Random random;
-
- public DragonSettingsGenerator(Random random)
- {
- this.random = random;
- }
-
- public DragonSettings Generate()
- {
- return new DragonSettings
- {
- Angle1 = random.NextDouble() / 2 + 0.5,
- Angle2 = 3 * (random.NextDouble() / 2 + 0.5),
- ShiftX = 1,
- ShiftY = 0,
- Scale = (float)(1/Math.Sqrt(2) + (random.NextDouble() - 0.5)/10)
- };
- }
-
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/App/Fractals/KochPainter.cs b/FractalPainter/App/Fractals/KochPainter.cs
deleted file mode 100644
index db0dff4ea..000000000
--- a/FractalPainter/App/Fractals/KochPainter.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-using System;
-using System.Drawing;
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.App.Fractals
-{
- public class KochPainter
- {
- private readonly IImageHolder imageHolder;
- private readonly Palette palette;
- private Size imageSize;
-
- public KochPainter(IImageHolder imageHolder, Palette palette)
- {
- this.imageHolder = imageHolder;
- this.palette = palette;
- imageSize = imageHolder.GetImageSize();
- }
-
- public void Paint()
- {
- using (var graphics = imageHolder.StartDrawing())
- using (var backgroundBrush = new SolidBrush(palette.BackgroundColor))
- {
- graphics.FillRectangle(backgroundBrush, 0, 0, imageSize.Width, imageSize.Height);
- DrawSegment(graphics, 0, imageSize.Height*0.9f, imageSize.Width, imageSize.Height*0.9f, true);
- }
- imageHolder.UpdateUi();
- }
-
- private void DrawSegment(Graphics graphics, float x0, float y0, float x1, float y1, bool primaryColor)
- {
- var len2 = (x0 - x1)*(x0 - x1) + (y0 - y1)*(y0 - y1);
- if (len2 < 4)
- {
- if (y0 < 0 || y1 < 0) return;
- using (var penBrush = new SolidBrush(primaryColor ? palette.PrimaryColor : palette.SecondaryColor))
- {
- var pen = new Pen(penBrush, 3);
- graphics.DrawLine(pen, x0, y0, x1, y1);
- }
- }
- else
- {
- var vx = (x1 - x0)/3;
- var vy = (y1 - y0)/3;
- DrawSegment(graphics, x0, y0, x0 + vx, y0 + vy, primaryColor);
- var k = (float) Math.Sqrt(3)/2f;
- var px = (x0 + x1)/2 + vy*k;
- var py = (y0 + y1)/2 - vx*k;
- DrawSegment(graphics, x0 + vx, y0 + vy, px, py, !primaryColor);
- DrawSegment(graphics, px, py, x0 + 2*vx, y0 + 2*vy, !primaryColor);
- DrawSegment(graphics, x0 + 2*vx, y0 + 2*vy, x1, y1, primaryColor);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/App/MainForm.cs b/FractalPainter/App/MainForm.cs
deleted file mode 100644
index aa484e046..000000000
--- a/FractalPainter/App/MainForm.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-using System;
-using System.Drawing;
-using System.Windows.Forms;
-using FractalPainting.App.Actions;
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Infrastructure.Injection;
-using FractalPainting.Infrastructure.UiActions;
-using Ninject;
-
-namespace FractalPainting.App
-{
- public class MainForm : Form
- {
- public MainForm()
- : this(
- new IUiAction[]
- {
- new SaveImageAction(),
- new DragonFractalAction(),
- new KochFractalAction(),
- new ImageSettingsAction(),
- new PaletteSettingsAction()
- })
- {
- }
-
- public MainForm(IUiAction[] actions)
- {
- var imageSettings = CreateSettingsManager().Load().ImageSettings;
- ClientSize = new Size(imageSettings.Width, imageSettings.Height);
-
- var mainMenu = new MenuStrip();
- mainMenu.Items.AddRange(actions.ToMenuItems());
- Controls.Add(mainMenu);
-
- var pictureBox = new PictureBoxImageHolder();
- pictureBox.RecreateImage(imageSettings);
- pictureBox.Dock = DockStyle.Fill;
- Controls.Add(pictureBox);
-
- DependencyInjector.Inject(actions, pictureBox);
- DependencyInjector.Inject(actions, CreateSettingsManager().Load());
- DependencyInjector.Inject(actions, CreateSettingsManager().Load());
- DependencyInjector.Inject(actions, new Palette());
- }
-
- private static SettingsManager CreateSettingsManager()
- {
- var container = new StandardKernel();
- container.Bind().To();
- container.Bind().To();
- return container.Get();
- }
-
- protected override void OnShown(EventArgs e)
- {
- base.OnShown(e);
- Text = "Fractal Painter";
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/App/MainForm.resx b/FractalPainter/App/MainForm.resx
deleted file mode 100644
index 9d845151a..000000000
--- a/FractalPainter/App/MainForm.resx
+++ /dev/null
@@ -1,123 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- 17, 17
-
-
\ No newline at end of file
diff --git a/FractalPainter/App/PictureBoxImageHolder.cs b/FractalPainter/App/PictureBoxImageHolder.cs
deleted file mode 100644
index 9fe74e328..000000000
--- a/FractalPainter/App/PictureBoxImageHolder.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-using System;
-using System.Drawing;
-using System.Drawing.Imaging;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.App
-{
- public class PictureBoxImageHolder : PictureBox, IImageHolder
- {
- public Size GetImageSize()
- {
- FailIfNotInitialized();
- return Image.Size;
- }
-
- public Graphics StartDrawing()
- {
- FailIfNotInitialized();
- return Graphics.FromImage(Image);
- }
-
- private void FailIfNotInitialized()
- {
- if (Image == null)
- throw new InvalidOperationException("Call PictureBoxImageHolder.RecreateImage before other method call!");
- }
-
- public void UpdateUi()
- {
- Refresh();
- Application.DoEvents();
- }
-
- public void RecreateImage(ImageSettings imageSettings)
- {
- Image = new Bitmap(imageSettings.Width, imageSettings.Height, PixelFormat.Format24bppRgb);
- }
-
- public void SaveImage(string fileName)
- {
- FailIfNotInitialized();
- Image.Save(fileName);
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/App/Program.cs b/FractalPainter/App/Program.cs
deleted file mode 100644
index 48d4fb27f..000000000
--- a/FractalPainter/App/Program.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using System;
-using System.Windows.Forms;
-using Ninject;
-
-namespace FractalPainting.App
-{
- internal static class Program
- {
- ///
- /// The main entry point for the application.
- ///
- [STAThread]
- private static void Main()
- {
- try
- {
- var container = new StandardKernel();
-
- // start here
- // container.Bind().To();
-
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new MainForm());
- }
- catch (Exception e)
- {
- MessageBox.Show(e.Message);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/App/SettingsManager.cs b/FractalPainter/App/SettingsManager.cs
deleted file mode 100644
index 580c1c422..000000000
--- a/FractalPainter/App/SettingsManager.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.App
-{
- public class SettingsManager
- {
- private readonly IObjectSerializer serializer;
- private readonly IBlobStorage storage;
- private string settingsFilename;
-
- public SettingsManager(IObjectSerializer serializer, IBlobStorage storage)
- {
- this.serializer = serializer;
- this.storage = storage;
- }
-
- public AppSettings Load()
- {
- try
- {
- settingsFilename = "app.settings";
- var data = storage.Get(settingsFilename);
- if (data == null)
- {
- var defaultSettings = CreateDefaultSettings();
- Save(defaultSettings);
- return defaultSettings;
- }
- return serializer.Deserialize(data);
- }
- catch (Exception e)
- {
- MessageBox.Show(e.Message, "не удалось загрузить настройки");
- return CreateDefaultSettings();
- }
- }
-
- private static AppSettings CreateDefaultSettings()
- {
- return new AppSettings
- {
- ImagesDirectory = ".",
- ImageSettings = new ImageSettings()
- };
- }
-
- public void Save(AppSettings settings)
- {
- storage.Set(settingsFilename, serializer.Serialize(settings));
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Infrastructure/Common/FileBlobStorage.cs b/FractalPainter/Infrastructure/Common/FileBlobStorage.cs
deleted file mode 100644
index a5feff667..000000000
--- a/FractalPainter/Infrastructure/Common/FileBlobStorage.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System.IO;
-
-namespace FractalPainting.Infrastructure.Common
-{
- public class FileBlobStorage : IBlobStorage
- {
- public byte[] Get(string name)
- {
- return File.Exists(name) ? File.ReadAllBytes(name) : null;
- }
-
- public void Set(string name, byte[] content)
- {
- File.WriteAllBytes(name, content);
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Infrastructure/Common/IBlobStorage.cs b/FractalPainter/Infrastructure/Common/IBlobStorage.cs
deleted file mode 100644
index 288c37530..000000000
--- a/FractalPainter/Infrastructure/Common/IBlobStorage.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace FractalPainting.Infrastructure.Common
-{
- public interface IBlobStorage
- {
- byte[] Get(string name);
- void Set(string name, byte[] content);
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Infrastructure/Common/IImageDirectoryProvider.cs b/FractalPainter/Infrastructure/Common/IImageDirectoryProvider.cs
deleted file mode 100644
index 29ae0dbde..000000000
--- a/FractalPainter/Infrastructure/Common/IImageDirectoryProvider.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace FractalPainting.Infrastructure.Common
-{
- public interface IImageDirectoryProvider
- {
- string ImagesDirectory { get; }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Infrastructure/Common/IImageHolder.cs b/FractalPainter/Infrastructure/Common/IImageHolder.cs
deleted file mode 100644
index 58e4f2d2d..000000000
--- a/FractalPainter/Infrastructure/Common/IImageHolder.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using System.Drawing;
-
-namespace FractalPainting.Infrastructure.Common
-{
- public interface IImageHolder
- {
- Size GetImageSize();
- Graphics StartDrawing();
- void UpdateUi();
- void RecreateImage(ImageSettings settings);
- void SaveImage(string fileName);
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Infrastructure/Common/IImageSettingsProvider.cs b/FractalPainter/Infrastructure/Common/IImageSettingsProvider.cs
deleted file mode 100644
index b9184171b..000000000
--- a/FractalPainter/Infrastructure/Common/IImageSettingsProvider.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace FractalPainting.Infrastructure.Common
-{
- public interface IImageSettingsProvider
- {
- ImageSettings ImageSettings { get; }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Infrastructure/Common/IObjectSerializer.cs b/FractalPainter/Infrastructure/Common/IObjectSerializer.cs
deleted file mode 100644
index c8f56e81a..000000000
--- a/FractalPainter/Infrastructure/Common/IObjectSerializer.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace FractalPainting.Infrastructure.Common
-{
- public interface IObjectSerializer
- {
- T Deserialize(byte[] bytes);
- byte[] Serialize(T obj);
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Infrastructure/Common/ImageSettings.cs b/FractalPainter/Infrastructure/Common/ImageSettings.cs
deleted file mode 100644
index 56f860ce0..000000000
--- a/FractalPainter/Infrastructure/Common/ImageSettings.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace FractalPainting.Infrastructure.Common
-{
- public class ImageSettings
- {
- public int Width { get; set; } = 100;
- public int Height { get; set; } = 100;
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Infrastructure/Common/Palette.cs b/FractalPainter/Infrastructure/Common/Palette.cs
deleted file mode 100644
index db70c1472..000000000
--- a/FractalPainter/Infrastructure/Common/Palette.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System.Drawing;
-
-namespace FractalPainting.Infrastructure.Common
-{
- public class Palette
- {
- public Color PrimaryColor { get; set; } = Color.Yellow;
- public Color SecondaryColor { get; set; } = Color.Red;
- public Color BackgroundColor { get; set; } = Color.DarkBlue;
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Infrastructure/Common/SettingsForm.cs b/FractalPainter/Infrastructure/Common/SettingsForm.cs
deleted file mode 100644
index e5ac2aa98..000000000
--- a/FractalPainter/Infrastructure/Common/SettingsForm.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System;
-using System.Windows.Forms;
-
-namespace FractalPainting.Infrastructure.Common
-{
- public static class SettingsForm
- {
- public static SettingsForm For(TSettings settings)
- {
- return new SettingsForm(settings);
- }
- }
-
- public class SettingsForm : Form
- {
- public SettingsForm(TSettings settings)
- {
- var okButton = new Button
- {
- Text = "OK",
- DialogResult = DialogResult.OK,
- Dock = DockStyle.Bottom,
- };
- Controls.Add(okButton);
- Controls.Add(new PropertyGrid
- {
- SelectedObject = settings,
- Dock = DockStyle.Fill
- });
- AcceptButton = okButton;
- }
-
- protected override void OnLoad(EventArgs e)
- {
- base.OnLoad(e);
- Text = "";
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Infrastructure/Common/XmlObjectSerializer.cs b/FractalPainter/Infrastructure/Common/XmlObjectSerializer.cs
deleted file mode 100644
index 3b2046fa2..000000000
--- a/FractalPainter/Infrastructure/Common/XmlObjectSerializer.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System.IO;
-using System.Xml.Serialization;
-
-namespace FractalPainting.Infrastructure.Common
-{
- public class XmlObjectSerializer : IObjectSerializer
- {
- public T Deserialize(byte[] bytes)
- {
- using (var ms = new MemoryStream(bytes))
- return (T) new XmlSerializer(typeof(T)).Deserialize(ms);
- }
-
- public byte[] Serialize(T obj)
- {
- using (var ms = new MemoryStream())
- {
- new XmlSerializer(typeof(T)).Serialize(ms, obj);
- return ms.ToArray();
- }
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Infrastructure/Injection/DependencyInjector.cs b/FractalPainter/Infrastructure/Injection/DependencyInjector.cs
deleted file mode 100644
index 60bbbd3fc..000000000
--- a/FractalPainter/Infrastructure/Injection/DependencyInjector.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System.Collections;
-
-namespace FractalPainting.Infrastructure.Injection
-{
- public class DependencyInjector
- {
- public static void Inject(object service, TDependency dependency)
- {
- var need = service as INeed;
- need?.SetDependency(dependency);
- }
-
- public static void Inject(IEnumerable services, TDependency dependency)
- {
- foreach (var service in services)
- Inject(service, dependency);
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Infrastructure/Injection/INeed.cs b/FractalPainter/Infrastructure/Injection/INeed.cs
deleted file mode 100644
index daed4b561..000000000
--- a/FractalPainter/Infrastructure/Injection/INeed.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace FractalPainting.Infrastructure.Injection
-{
- public interface INeed
- {
- void SetDependency(T dependency);
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Infrastructure/UiActions/IUiAction.cs b/FractalPainter/Infrastructure/UiActions/IUiAction.cs
deleted file mode 100644
index 1ea934ce0..000000000
--- a/FractalPainter/Infrastructure/UiActions/IUiAction.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace FractalPainting.Infrastructure.UiActions
-{
- public interface IUiAction
- {
- string Category { get; }
- string Name { get; }
- string Description { get; }
- void Perform();
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Infrastructure/UiActions/UiActionExtensions.cs b/FractalPainter/Infrastructure/UiActions/UiActionExtensions.cs
deleted file mode 100644
index b7de09172..000000000
--- a/FractalPainter/Infrastructure/UiActions/UiActionExtensions.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using System.Windows.Forms;
-
-namespace FractalPainting.Infrastructure.UiActions
-{
- public static class UiActionExtensions
- {
- public static ToolStripItem[] ToMenuItems(this IUiAction[] actions)
- {
- var items = actions.GroupBy(a => a.Category)
- .Select(g => CreateTopLevelMenuItem(g.Key, g.ToList()))
- .Cast()
- .ToArray();
- return items;
- }
-
- private static ToolStripMenuItem CreateTopLevelMenuItem(string name, IList items)
- {
- var menuItems = items.Select(a => a.ToMenuItem()).ToArray();
- return new ToolStripMenuItem(name, null, menuItems);
- }
-
- public static ToolStripItem ToMenuItem(this IUiAction action)
- {
- return
- new ToolStripMenuItem(action.Name, null, (sender, args) => action.Perform())
- {
- ToolTipText = action.Description,
- Tag = action
- };
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Readme.md b/FractalPainter/Readme.md
deleted file mode 100644
index e9674ef7b..000000000
--- a/FractalPainter/Readme.md
+++ /dev/null
@@ -1,67 +0,0 @@
-# Задание FractalPainter
-
-1. Разминка. В классе Program переделайте Main так, чтобы MainForm
-создавался контейнером. Удалите у MainForm конструктор без параметров
-и сделайте так, чтобы контейнер инжектировал в MainForm список IUiAction.
-
-2. INeed. Изучите код KochFractalAction.
-Изучите механику работы INeed и DependencyInjector.
-Оцените такой подход к управлению зависимостями.
-
-3. Рефакторинг. Измените класс KochFractalAction так,
-чтобы его зависимости IImageHolder и Pallette инжектировались
-явно через конструктор, без использования интерфейса INeed.
-
- Подсказка. Сложность в том, чтобы в MainForm и KochFractalAction
- оказались ссылки на один и тот же объект PictureBoxImageHolder.
-
- Убедитесь, что настройка палитры для рисования кривой Коха всё ещё работает.
-
-4. Еще рефакторинг. Изучите KochFractalAction и поймите, что
-на самом деле IImageHolder и Pallette ему не нужны. Измените его так,
-чтобы он принимал только KochPainter.
-
-5. Фабрика. Аналогично удалите INeed,
-и явное использование контейнера из класса DragonFractalAction.
-Дополнительное ограничение — нельзя менять публичный интерфейс DragonPainter.
-Особенность в том, что одна из зависимостей DragonPainter —
-DragonSettings оказывается известной только в процессе работы экшена.
-Из-за этого вы не можете просить инжектировать в конструктор уже готовый Painter.
-Вместо этого инжектируйте фабрику DragonPainter-ов.
-https://github.com/ninject/Ninject.Extensions.Factory/wiki/Factory-interface
-Подсказка 1: достаточно описать интерфейс фабрики,
-а класс фабрики, реализующий этот интерфейс Ninject сгенерирует самостоятельно.
-Подсказка 2: проверьте, что изменение настроек работает. В фабриках есть явная
-договоренность - имена параметров метода в фабрике должны совпадать с именами
-параметров конструктора создаваемой сущности.
-
-6. Фабрика 2. Используйте для создания DragonSettingsGenerator Func-фабрику
-и инжектируйте эту зависимость в DragonFractalAction.
-https://github.com/ninject/Ninject.Extensions.Factory/wiki/Func
-
-7. Новая зависимость. Переведите DragonPainter на использование цветов палитры,
-как это сделано в KochPainter.
-
- Убедитесь, что экшен настройки палитры работает как надо.
- Если вы всё сделали правильно, то для добавления зависимости вам не пришлось
- править код работы с контейнером вообще. Магия!
-
-8. Источник зависимости. Аналогично отрефакторите ImageSettingsAction.
-Попробуйте придумать, как избавиться от класса IImageSettingsProvider.
-Вам поможет ToMethod.
-https://github.com/ninject/Ninject/wiki/Providers,-Factory-Methods-and-the-Activation-Context#factory-methods
-Обратите внимание, что ToMethod позволяет доставать нужные зависимости из контейнера:
-ToMethod(context => context.Kernel.Get() ... )
-
- Убедитесь, что окно настройки размера изображения запоминает установленный размер.
-
-9. Избавьтесь от остальных использований INeed и удалите этот интерфейс
-и класс DependencyInjector из проекта.
-
-10. Обратите внимание на многочисленные привязки к IUiAction. В реальных
-проектах количество классов может исчисляться десятками и сотнями. Воспользуйтесь
-документацией https://github.com/ninject/Ninject.Extensions.Conventions/wiki/Overview
-и найдите, как все эти привязки сделать в одну строчку.
-
-11. Кажется после последнего рефакторинга пункты меню перемешались.
-Что делать?
diff --git a/FractalPainter/Solved/Infrastructure/Infrastructure.csproj b/FractalPainter/Solved/Infrastructure/Infrastructure.csproj
deleted file mode 100644
index b80772fa4..000000000
--- a/FractalPainter/Solved/Infrastructure/Infrastructure.csproj
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
- netcoreapp3.1
- 8
- false
- true
- FractalPainting.Infrastructure
- FractalPainting.Infrastructure
-
-
-
- Common\FileBlobStorage.cs
-
-
- Common\IBlobStorage.cs
-
-
- Common\IImageDirectoryProvider.cs
-
-
- Common\IImageHolder.cs
-
-
- Common\IImageSettingsProvider.cs
-
-
- Common\ImageSettings.cs
-
-
- Common\IObjectSerializer.cs
-
-
- Common\Palette.cs
-
-
- Common\SettingsForm.cs
-
-
- Common\XmlObjectSerializer.cs
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/FractalPainter/Solved/Solved.sln b/FractalPainter/Solved/Solved.sln
deleted file mode 100644
index e15469c42..000000000
--- a/FractalPainter/Solved/Solved.sln
+++ /dev/null
@@ -1,76 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Infrastructure", "Infrastructure\Infrastructure.csproj", "{DBF231B5-CAB6-49AD-AB64-7BC21ECC296F}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step01", "Step01\Step01.csproj", "{F2CCBD42-F636-4C39-B0D1-006331BE6925}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step03", "Step03\Step03.csproj", "{CF9051FC-B9B6-44E3-A50E-5292107A23CE}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step04", "Step04\Step04.csproj", "{8742DC1F-985A-425A-8C47-985EFFEEB2F4}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step05", "Step05\Step05.csproj", "{32FB9056-C1D2-443A-83DE-AA94561A0074}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step06", "Step06\Step06.csproj", "{3F871EDC-92FC-44B0-9C2F-CA89E8D3D0B9}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step07", "Step07\Step07.csproj", "{A34B95BC-86ED-4378-B42C-C02D2877959E}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step08", "Step08\Step08.csproj", "{D89A621B-BE8D-44FA-8C9D-3681380E57AA}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step09", "Step09\Step09.csproj", "{BAA8D352-44BD-4A51-9EF5-1027F5185A76}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step10", "Step10\Step10.csproj", "{6013A58C-CDDF-49E9-8BE1-26A6C4A7E210}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Step11", "Step11\Step11.csproj", "{3DBAA817-5853-47DE-8FDC-C18E7809B324}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {DBF231B5-CAB6-49AD-AB64-7BC21ECC296F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {DBF231B5-CAB6-49AD-AB64-7BC21ECC296F}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {DBF231B5-CAB6-49AD-AB64-7BC21ECC296F}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {DBF231B5-CAB6-49AD-AB64-7BC21ECC296F}.Release|Any CPU.Build.0 = Release|Any CPU
- {F2CCBD42-F636-4C39-B0D1-006331BE6925}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {F2CCBD42-F636-4C39-B0D1-006331BE6925}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {F2CCBD42-F636-4C39-B0D1-006331BE6925}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {F2CCBD42-F636-4C39-B0D1-006331BE6925}.Release|Any CPU.Build.0 = Release|Any CPU
- {CF9051FC-B9B6-44E3-A50E-5292107A23CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {CF9051FC-B9B6-44E3-A50E-5292107A23CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {CF9051FC-B9B6-44E3-A50E-5292107A23CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {CF9051FC-B9B6-44E3-A50E-5292107A23CE}.Release|Any CPU.Build.0 = Release|Any CPU
- {8742DC1F-985A-425A-8C47-985EFFEEB2F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {8742DC1F-985A-425A-8C47-985EFFEEB2F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {8742DC1F-985A-425A-8C47-985EFFEEB2F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {8742DC1F-985A-425A-8C47-985EFFEEB2F4}.Release|Any CPU.Build.0 = Release|Any CPU
- {32FB9056-C1D2-443A-83DE-AA94561A0074}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {32FB9056-C1D2-443A-83DE-AA94561A0074}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {32FB9056-C1D2-443A-83DE-AA94561A0074}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {32FB9056-C1D2-443A-83DE-AA94561A0074}.Release|Any CPU.Build.0 = Release|Any CPU
- {3F871EDC-92FC-44B0-9C2F-CA89E8D3D0B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {3F871EDC-92FC-44B0-9C2F-CA89E8D3D0B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {3F871EDC-92FC-44B0-9C2F-CA89E8D3D0B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {3F871EDC-92FC-44B0-9C2F-CA89E8D3D0B9}.Release|Any CPU.Build.0 = Release|Any CPU
- {A34B95BC-86ED-4378-B42C-C02D2877959E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {A34B95BC-86ED-4378-B42C-C02D2877959E}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {A34B95BC-86ED-4378-B42C-C02D2877959E}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {A34B95BC-86ED-4378-B42C-C02D2877959E}.Release|Any CPU.Build.0 = Release|Any CPU
- {D89A621B-BE8D-44FA-8C9D-3681380E57AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {D89A621B-BE8D-44FA-8C9D-3681380E57AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {D89A621B-BE8D-44FA-8C9D-3681380E57AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {D89A621B-BE8D-44FA-8C9D-3681380E57AA}.Release|Any CPU.Build.0 = Release|Any CPU
- {BAA8D352-44BD-4A51-9EF5-1027F5185A76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {BAA8D352-44BD-4A51-9EF5-1027F5185A76}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {BAA8D352-44BD-4A51-9EF5-1027F5185A76}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {BAA8D352-44BD-4A51-9EF5-1027F5185A76}.Release|Any CPU.Build.0 = Release|Any CPU
- {6013A58C-CDDF-49E9-8BE1-26A6C4A7E210}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {6013A58C-CDDF-49E9-8BE1-26A6C4A7E210}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {6013A58C-CDDF-49E9-8BE1-26A6C4A7E210}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {6013A58C-CDDF-49E9-8BE1-26A6C4A7E210}.Release|Any CPU.Build.0 = Release|Any CPU
- {3DBAA817-5853-47DE-8FDC-C18E7809B324}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {3DBAA817-5853-47DE-8FDC-C18E7809B324}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {3DBAA817-5853-47DE-8FDC-C18E7809B324}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {3DBAA817-5853-47DE-8FDC-C18E7809B324}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
-EndGlobal
diff --git a/FractalPainter/Solved/Step01/App/Actions/DragonFractalAction.cs b/FractalPainter/Solved/Step01/App/Actions/DragonFractalAction.cs
deleted file mode 100644
index 1fdc46169..000000000
--- a/FractalPainter/Solved/Step01/App/Actions/DragonFractalAction.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System;
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step01.App.Fractals;
-using FractalPainting.Solved.Step01.Infrastructure.Injection;
-using FractalPainting.Solved.Step01.Infrastructure.UiActions;
-using Ninject;
-
-namespace FractalPainting.Solved.Step01.App.Actions
-{
- public class DragonFractalAction : IUiAction, INeed
- {
- private IImageHolder imageHolder;
-
- public void SetDependency(IImageHolder dependency)
- {
- imageHolder = dependency;
- }
-
- public string Category => "Фракталы";
- public string Name => "Дракон";
- public string Description => "Дракон Хартера-Хейтуэя";
-
- public void Perform()
- {
- var dragonSettings = CreateRandomSettings();
- // редактируем настройки:
- SettingsForm.For(dragonSettings).ShowDialog();
- // создаём painter с такими настройками
- var container = new StandardKernel();
- container.Bind().ToConstant(imageHolder);
- container.Bind().ToConstant(dragonSettings);
- container.Get().Paint();
- }
-
- private static DragonSettings CreateRandomSettings()
- {
- return new DragonSettingsGenerator(new Random()).Generate();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step01/App/Actions/ImageSettingsAction.cs b/FractalPainter/Solved/Step01/App/Actions/ImageSettingsAction.cs
deleted file mode 100644
index bc6690657..000000000
--- a/FractalPainter/Solved/Step01/App/Actions/ImageSettingsAction.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step01.Infrastructure.Injection;
-using FractalPainting.Solved.Step01.Infrastructure.UiActions;
-
-namespace FractalPainting.Solved.Step01.App.Actions
-{
- public class ImageSettingsAction : IUiAction, INeed, INeed
- {
- private IImageHolder imageHolder;
- private IImageSettingsProvider imageSettingsProvider;
-
- public void SetDependency(IImageHolder dependency)
- {
- imageHolder = dependency;
- }
-
- public void SetDependency(IImageSettingsProvider dependency)
- {
- imageSettingsProvider = dependency;
- }
-
- public string Category => "Настройки";
- public string Name => "Изображение...";
- public string Description => "Размеры изображения";
-
- public void Perform()
- {
- var imageSettings = imageSettingsProvider.ImageSettings;
- SettingsForm.For(imageSettings).ShowDialog();
- imageHolder.RecreateImage(imageSettings);
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step01/App/Actions/KochFractalAction.cs b/FractalPainter/Solved/Step01/App/Actions/KochFractalAction.cs
deleted file mode 100644
index 897557894..000000000
--- a/FractalPainter/Solved/Step01/App/Actions/KochFractalAction.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step01.App.Fractals;
-using FractalPainting.Solved.Step01.Infrastructure.Injection;
-using FractalPainting.Solved.Step01.Infrastructure.UiActions;
-using Ninject;
-
-namespace FractalPainting.Solved.Step01.App.Actions
-{
- public class KochFractalAction : IUiAction, INeed, INeed
- {
- private IImageHolder imageHolder;
- private Palette palette;
-
- public void SetDependency(IImageHolder dependency)
- {
- imageHolder = dependency;
- }
-
- public void SetDependency(Palette dependency)
- {
- palette = dependency;
- }
-
- public string Category => "Фракталы";
- public string Name => "Кривая Коха";
- public string Description => "Кривая Коха";
-
- public void Perform()
- {
- var container = new StandardKernel();
- container.Bind().ToConstant(imageHolder);
- container.Bind().ToConstant(palette);
-
- container.Get().Paint();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step01/App/Actions/PaletteSettingsAction.cs b/FractalPainter/Solved/Step01/App/Actions/PaletteSettingsAction.cs
deleted file mode 100644
index ed7f54255..000000000
--- a/FractalPainter/Solved/Step01/App/Actions/PaletteSettingsAction.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step01.Infrastructure.Injection;
-using FractalPainting.Solved.Step01.Infrastructure.UiActions;
-
-namespace FractalPainting.Solved.Step01.App.Actions
-{
- public class PaletteSettingsAction : IUiAction, INeed
- {
- private Palette palette;
-
- public void SetDependency(Palette dependency)
- {
- palette = dependency;
- }
-
- public string Category => "Настройки";
- public string Name => "Палитра...";
- public string Description => "Цвета для рисования фракталов";
-
- public void Perform()
- {
- SettingsForm.For(palette).ShowDialog();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step01/App/Actions/SaveImageAction.cs b/FractalPainter/Solved/Step01/App/Actions/SaveImageAction.cs
deleted file mode 100644
index 0462ec96f..000000000
--- a/FractalPainter/Solved/Step01/App/Actions/SaveImageAction.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using System.IO;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step01.Infrastructure.Injection;
-using FractalPainting.Solved.Step01.Infrastructure.UiActions;
-
-namespace FractalPainting.Solved.Step01.App.Actions
-{
- public class SaveImageAction : IUiAction, INeed, INeed
- {
- private IImageDirectoryProvider imageDirectoryProvider;
- private IImageHolder imageHolder;
-
- public void SetDependency(IImageDirectoryProvider dependency)
- {
- imageDirectoryProvider = dependency;
- }
-
- public void SetDependency(IImageHolder dependency)
- {
- imageHolder = dependency;
- }
-
- public string Category => "Файл";
- public string Name => "Сохранить...";
- public string Description => "Сохранить изображение в файл";
-
- public void Perform()
- {
- var dialog = new SaveFileDialog
- {
- CheckFileExists = false,
- InitialDirectory = Path.GetFullPath(imageDirectoryProvider.ImagesDirectory),
- DefaultExt = "bmp",
- FileName = "image.bmp",
- Filter = "Изображения (*.bmp)|*.bmp"
- };
- var res = dialog.ShowDialog();
- if (res == DialogResult.OK)
- imageHolder.SaveImage(dialog.FileName);
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step01/App/AppSettings.cs b/FractalPainter/Solved/Step01/App/AppSettings.cs
deleted file mode 100644
index eb9aa0b3a..000000000
--- a/FractalPainter/Solved/Step01/App/AppSettings.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step01.App
-{
- public class AppSettings : IImageDirectoryProvider, IImageSettingsProvider
- {
- public string ImagesDirectory { get; set; }
- public ImageSettings ImageSettings { get; set; }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step01/App/Fractals/DragonPainter.cs b/FractalPainter/Solved/Step01/App/Fractals/DragonPainter.cs
deleted file mode 100644
index 3e826bce8..000000000
--- a/FractalPainter/Solved/Step01/App/Fractals/DragonPainter.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System;
-using System.Drawing;
-using System.Linq;
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step01.App.Fractals
-{
- public class DragonPainter
- {
- private readonly IImageHolder imageHolder;
- private readonly DragonSettings settings;
- private readonly float size;
- private Size imageSize;
-
- public DragonPainter(IImageHolder imageHolder, DragonSettings settings)
- {
- this.imageHolder = imageHolder;
- this.settings = settings;
- imageSize = imageHolder.GetImageSize();
- size = Math.Min(imageSize.Width, imageSize.Height)/2.1f;
- }
-
- public void Paint()
- {
- using (var graphics = imageHolder.StartDrawing())
- {
- graphics.FillRectangle(Brushes.Black, 0, 0, imageSize.Width, imageSize.Height);
- var r = new Random();
- var cosa = (float) Math.Cos(settings.Angle1);
- var sina = (float) Math.Sin(settings.Angle1);
- var cosb = (float) Math.Cos(settings.Angle2);
- var sinb = (float) Math.Sin(settings.Angle2);
- var shiftX = settings.ShiftX*size*0.8f;
- var shiftY = settings.ShiftY*size*0.8f;
- var scale = settings.Scale;
- var p = new PointF(0, 0);
- foreach (var i in Enumerable.Range(0, settings.IterationsCount))
- {
- graphics.FillRectangle(Brushes.Yellow, imageSize.Width/3f + p.X, imageSize.Height/2f + p.Y, 1, 1);
- if (r.Next(0, 2) == 0)
- p = new PointF(scale*(p.X*cosa - p.Y*sina), scale*(p.X*sina + p.Y*cosa));
- else
- p = new PointF(scale*(p.X*cosb - p.Y*sinb) + shiftX, scale*(p.X*sinb + p.Y*cosb) + shiftY);
- if (i%100 == 0) imageHolder.UpdateUi();
- }
- }
- imageHolder.UpdateUi();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step01/App/Fractals/DragonSettings.cs b/FractalPainter/Solved/Step01/App/Fractals/DragonSettings.cs
deleted file mode 100644
index 67a538ed0..000000000
--- a/FractalPainter/Solved/Step01/App/Fractals/DragonSettings.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-
-namespace FractalPainting.Solved.Step01.App.Fractals
-{
- public class DragonSettings
- {
- public double Angle1 { get; set; } = Math.PI / 4;
- public double Angle2 { get; set; } = 3 * Math.PI / 4;
- public float ShiftX { get; set; } = 1;
- public float ShiftY { get; set; } = 0;
- public float Scale { get; set; } = (float)(1 / Math.Sqrt(2));
- public int IterationsCount { get; set; } = 20000;
-
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step01/App/Fractals/DragonSettingsGenerator.cs b/FractalPainter/Solved/Step01/App/Fractals/DragonSettingsGenerator.cs
deleted file mode 100644
index c0ff2437f..000000000
--- a/FractalPainter/Solved/Step01/App/Fractals/DragonSettingsGenerator.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System;
-
-namespace FractalPainting.Solved.Step01.App.Fractals
-{
- public class DragonSettingsGenerator
- {
- private readonly Random random;
-
- public DragonSettingsGenerator(Random random)
- {
- this.random = random;
- }
-
- public DragonSettings Generate()
- {
- return new DragonSettings
- {
- Angle1 = random.NextDouble() / 2 + 0.5,
- Angle2 = 3 * (random.NextDouble() / 2 + 0.5),
- ShiftX = 1,
- ShiftY = 0,
- Scale = (float)(1/Math.Sqrt(2) + (random.NextDouble() - 0.5)/10)
- };
- }
-
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step01/App/Fractals/KochPainter.cs b/FractalPainter/Solved/Step01/App/Fractals/KochPainter.cs
deleted file mode 100644
index 3da908d99..000000000
--- a/FractalPainter/Solved/Step01/App/Fractals/KochPainter.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-using System;
-using System.Drawing;
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step01.App.Fractals
-{
- public class KochPainter
- {
- private readonly IImageHolder imageHolder;
- private readonly Palette palette;
- private Size imageSize;
-
- public KochPainter(IImageHolder imageHolder, Palette palette)
- {
- this.imageHolder = imageHolder;
- this.palette = palette;
- imageSize = imageHolder.GetImageSize();
- }
-
- public void Paint()
- {
- using (var graphics = imageHolder.StartDrawing())
- using (var backgroundBrush = new SolidBrush(palette.BackgroundColor))
- {
- graphics.FillRectangle(backgroundBrush, 0, 0, imageSize.Width, imageSize.Height);
- DrawSegment(graphics, 0, imageSize.Height*0.9f, imageSize.Width, imageSize.Height*0.9f, true);
- }
- imageHolder.UpdateUi();
- }
-
- private void DrawSegment(Graphics graphics, float x0, float y0, float x1, float y1, bool primaryColor)
- {
- var len2 = (x0 - x1)*(x0 - x1) + (y0 - y1)*(y0 - y1);
- if (len2 < 4)
- {
- if (y0 < 0 || y1 < 0) return;
- using (var penBrush = new SolidBrush(primaryColor ? palette.PrimaryColor : palette.SecondaryColor))
- {
- var pen = new Pen(penBrush, 3);
- graphics.DrawLine(pen, x0, y0, x1, y1);
- }
- }
- else
- {
- var vx = (x1 - x0)/3;
- var vy = (y1 - y0)/3;
- DrawSegment(graphics, x0, y0, x0 + vx, y0 + vy, primaryColor);
- var k = (float) Math.Sqrt(3)/2f;
- var px = (x0 + x1)/2 + vy*k;
- var py = (y0 + y1)/2 - vx*k;
- DrawSegment(graphics, x0 + vx, y0 + vy, px, py, !primaryColor);
- DrawSegment(graphics, px, py, x0 + 2*vx, y0 + 2*vy, !primaryColor);
- DrawSegment(graphics, x0 + 2*vx, y0 + 2*vy, x1, y1, primaryColor);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step01/App/MainForm.cs b/FractalPainter/Solved/Step01/App/MainForm.cs
deleted file mode 100644
index a30fd0de8..000000000
--- a/FractalPainter/Solved/Step01/App/MainForm.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using System;
-using System.Drawing;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step01.Infrastructure.Injection;
-using FractalPainting.Solved.Step01.Infrastructure.UiActions;
-using Ninject;
-
-namespace FractalPainting.Solved.Step01.App
-{
- public class MainForm : Form
- {
- public MainForm(IUiAction[] actions)
- {
- var imageSettings = CreateSettingsManager().Load().ImageSettings;
- ClientSize = new Size(imageSettings.Width, imageSettings.Height);
-
- var mainMenu = new MenuStrip();
- mainMenu.Items.AddRange(actions.ToMenuItems());
- Controls.Add(mainMenu);
-
- var pictureBox = new PictureBoxImageHolder();
- pictureBox.RecreateImage(imageSettings);
- pictureBox.Dock = DockStyle.Fill;
- Controls.Add(pictureBox);
-
- DependencyInjector.Inject(actions, pictureBox);
- DependencyInjector.Inject(actions, CreateSettingsManager().Load());
- DependencyInjector.Inject(actions, CreateSettingsManager().Load());
- DependencyInjector.Inject(actions, new Palette());
- }
-
- private static SettingsManager CreateSettingsManager()
- {
- var container = new StandardKernel();
- container.Bind().To();
- container.Bind().To();
- return container.Get();
- }
-
- protected override void OnShown(EventArgs e)
- {
- base.OnShown(e);
- Text = "Fractal Painter";
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step01/App/MainForm.resx b/FractalPainter/Solved/Step01/App/MainForm.resx
deleted file mode 100644
index 9d845151a..000000000
--- a/FractalPainter/Solved/Step01/App/MainForm.resx
+++ /dev/null
@@ -1,123 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- 17, 17
-
-
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step01/App/PictureBoxImageHolder.cs b/FractalPainter/Solved/Step01/App/PictureBoxImageHolder.cs
deleted file mode 100644
index 2053ac5eb..000000000
--- a/FractalPainter/Solved/Step01/App/PictureBoxImageHolder.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-using System;
-using System.Drawing;
-using System.Drawing.Imaging;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step01.App
-{
- public class PictureBoxImageHolder : PictureBox, IImageHolder
- {
- public Size GetImageSize()
- {
- FailIfNotInitialized();
- return Image.Size;
- }
-
- public Graphics StartDrawing()
- {
- FailIfNotInitialized();
- return Graphics.FromImage(Image);
- }
-
- private void FailIfNotInitialized()
- {
- if (Image == null)
- throw new InvalidOperationException("Call PictureBoxImageHolder.RecreateImage before other method call!");
- }
-
- public void UpdateUi()
- {
- Refresh();
- Application.DoEvents();
- }
-
- public void RecreateImage(ImageSettings imageSettings)
- {
- Image = new Bitmap(imageSettings.Width, imageSettings.Height, PixelFormat.Format24bppRgb);
- }
-
- public void SaveImage(string fileName)
- {
- FailIfNotInitialized();
- Image.Save(fileName);
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step01/App/Program.cs b/FractalPainter/Solved/Step01/App/Program.cs
deleted file mode 100644
index 6cbccda1d..000000000
--- a/FractalPainter/Solved/Step01/App/Program.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System;
-using System.Windows.Forms;
-using FractalPainting.Solved.Step01.App.Actions;
-using FractalPainting.Solved.Step01.Infrastructure.UiActions;
-using Ninject;
-
-namespace FractalPainting.Solved.Step01.App
-{
- internal static class Program
- {
- ///
- /// The main entry point for the application.
- ///
- [STAThread]
- private static void Main()
- {
- try
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
-
- var container = new StandardKernel();
-
- container.Bind().To();
- container.Bind().To();
- container.Bind().To();
- container.Bind().To();
- container.Bind().To();
-
- var mainForm = container.Get();
- Application.Run(mainForm);
- }
- catch (Exception e)
- {
- MessageBox.Show(e.Message);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step01/App/SettingsManager.cs b/FractalPainter/Solved/Step01/App/SettingsManager.cs
deleted file mode 100644
index 05d4b101a..000000000
--- a/FractalPainter/Solved/Step01/App/SettingsManager.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step01.App
-{
- public class SettingsManager
- {
- private readonly IObjectSerializer serializer;
- private readonly IBlobStorage storage;
- private string settingsFilename;
-
- public SettingsManager(IObjectSerializer serializer, IBlobStorage storage)
- {
- this.serializer = serializer;
- this.storage = storage;
- }
-
- public AppSettings Load()
- {
- try
- {
- settingsFilename = "app.settings";
- var data = storage.Get(settingsFilename);
- if (data == null)
- {
- var defaultSettings = CreateDefaultSettings();
- Save(defaultSettings);
- return defaultSettings;
- }
- return serializer.Deserialize(data);
- }
- catch (Exception e)
- {
- MessageBox.Show(e.Message, "Не удалось загрузить настройки");
- return CreateDefaultSettings();
- }
- }
-
- private static AppSettings CreateDefaultSettings()
- {
- return new AppSettings
- {
- ImagesDirectory = ".",
- ImageSettings = new ImageSettings()
- };
- }
-
- public void Save(AppSettings settings)
- {
- storage.Set(settingsFilename, serializer.Serialize(settings));
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step01/Infrastructure/Injection/DependencyInjector.cs b/FractalPainter/Solved/Step01/Infrastructure/Injection/DependencyInjector.cs
deleted file mode 100644
index 8c8e67f7f..000000000
--- a/FractalPainter/Solved/Step01/Infrastructure/Injection/DependencyInjector.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System.Collections;
-
-namespace FractalPainting.Solved.Step01.Infrastructure.Injection
-{
- public class DependencyInjector
- {
- public static void Inject(object service, TDependency dependency)
- {
- var need = service as INeed;
- need?.SetDependency(dependency);
- }
-
- public static void Inject(IEnumerable services, TDependency dependency)
- {
- foreach (var service in services)
- Inject(service, dependency);
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step01/Infrastructure/Injection/INeed.cs b/FractalPainter/Solved/Step01/Infrastructure/Injection/INeed.cs
deleted file mode 100644
index 49b128ad4..000000000
--- a/FractalPainter/Solved/Step01/Infrastructure/Injection/INeed.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace FractalPainting.Solved.Step01.Infrastructure.Injection
-{
- public interface INeed
- {
- void SetDependency(T dependency);
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step01/Infrastructure/UiActions/IUiAction.cs b/FractalPainter/Solved/Step01/Infrastructure/UiActions/IUiAction.cs
deleted file mode 100644
index 75f7d3b49..000000000
--- a/FractalPainter/Solved/Step01/Infrastructure/UiActions/IUiAction.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace FractalPainting.Solved.Step01.Infrastructure.UiActions
-{
- public interface IUiAction
- {
- string Category { get; }
- string Name { get; }
- string Description { get; }
- void Perform();
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step01/Infrastructure/UiActions/UiActionExtensions.cs b/FractalPainter/Solved/Step01/Infrastructure/UiActions/UiActionExtensions.cs
deleted file mode 100644
index c3e42bf45..000000000
--- a/FractalPainter/Solved/Step01/Infrastructure/UiActions/UiActionExtensions.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using System.Windows.Forms;
-
-namespace FractalPainting.Solved.Step01.Infrastructure.UiActions
-{
- public static class UiActionExtensions
- {
- public static ToolStripItem[] ToMenuItems(this IUiAction[] actions)
- {
- var items = actions.GroupBy(a => a.Category)
- .Select(g => CreateTopLevelMenuItem(g.Key, g.ToList()))
- .Cast()
- .ToArray();
- return items;
- }
-
- private static ToolStripMenuItem CreateTopLevelMenuItem(string name, IList items)
- {
- var menuItems = items.Select(a => a.ToMenuItem()).ToArray();
- return new ToolStripMenuItem(name, null, menuItems);
- }
-
- public static ToolStripItem ToMenuItem(this IUiAction action)
- {
- return
- new ToolStripMenuItem(action.Name, null, (sender, args) => action.Perform())
- {
- ToolTipText = action.Description,
- Tag = action
- };
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step01/Step01.csproj b/FractalPainter/Solved/Step01/Step01.csproj
deleted file mode 100644
index 4866cf797..000000000
--- a/FractalPainter/Solved/Step01/Step01.csproj
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
- WinExe
- netcoreapp3.1
- 8
- true
- false
- FractalPainting.Solved.Step01
- FractalPainter
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step03/App/Actions/DragonFractalAction.cs b/FractalPainter/Solved/Step03/App/Actions/DragonFractalAction.cs
deleted file mode 100644
index c2fa2db10..000000000
--- a/FractalPainter/Solved/Step03/App/Actions/DragonFractalAction.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System;
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step03.App.Fractals;
-using FractalPainting.Solved.Step03.Infrastructure.Injection;
-using FractalPainting.Solved.Step03.Infrastructure.UiActions;
-using Ninject;
-
-namespace FractalPainting.Solved.Step03.App.Actions
-{
- public class DragonFractalAction : IUiAction, INeed
- {
- private IImageHolder imageHolder;
-
- public void SetDependency(IImageHolder dependency)
- {
- imageHolder = dependency;
- }
-
- public string Category => "Фракталы";
- public string Name => "Дракон";
- public string Description => "Дракон Хартера-Хейтуэя";
-
- public void Perform()
- {
- var dragonSettings = CreateRandomSettings();
- // редактируем настройки:
- SettingsForm.For(dragonSettings).ShowDialog();
- // создаём painter с такими настройками
- var container = new StandardKernel();
- container.Bind().ToConstant(imageHolder);
- container.Bind().ToConstant(dragonSettings);
- container.Get().Paint();
- }
-
- private static DragonSettings CreateRandomSettings()
- {
- return new DragonSettingsGenerator(new Random()).Generate();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step03/App/Actions/ImageSettingsAction.cs b/FractalPainter/Solved/Step03/App/Actions/ImageSettingsAction.cs
deleted file mode 100644
index a4a095269..000000000
--- a/FractalPainter/Solved/Step03/App/Actions/ImageSettingsAction.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step03.Infrastructure.Injection;
-using FractalPainting.Solved.Step03.Infrastructure.UiActions;
-
-namespace FractalPainting.Solved.Step03.App.Actions
-{
- public class ImageSettingsAction : IUiAction, INeed, INeed
- {
- private IImageHolder imageHolder;
- private IImageSettingsProvider imageSettingsProvider;
-
- public void SetDependency(IImageHolder dependency)
- {
- imageHolder = dependency;
- }
-
- public void SetDependency(IImageSettingsProvider dependency)
- {
- imageSettingsProvider = dependency;
- }
-
- public string Category => "Настройки";
- public string Name => "Изображение...";
- public string Description => "Размеры изображения";
-
- public void Perform()
- {
- var imageSettings = imageSettingsProvider.ImageSettings;
- SettingsForm.For(imageSettings).ShowDialog();
- imageHolder.RecreateImage(imageSettings);
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step03/App/Actions/KochFractalAction.cs b/FractalPainter/Solved/Step03/App/Actions/KochFractalAction.cs
deleted file mode 100644
index 8c16376d1..000000000
--- a/FractalPainter/Solved/Step03/App/Actions/KochFractalAction.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step03.App.Fractals;
-using FractalPainting.Solved.Step03.Infrastructure.UiActions;
-using Ninject;
-
-namespace FractalPainting.Solved.Step03.App.Actions
-{
- public class KochFractalAction : IUiAction
- {
- private readonly IImageHolder imageHolder;
- private readonly Palette palette;
-
- public KochFractalAction(IImageHolder imageHolder, Palette palette)
- {
- this.imageHolder = imageHolder;
- this.palette = palette;
- }
-
- public string Category => "Фракталы";
- public string Name => "Кривая Коха";
- public string Description => "Кривая Коха";
-
- public void Perform()
- {
- var container = new StandardKernel();
- container.Bind().ToConstant(imageHolder);
- container.Bind().ToConstant(palette);
-
- container.Get().Paint();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step03/App/Actions/PaletteSettingsAction.cs b/FractalPainter/Solved/Step03/App/Actions/PaletteSettingsAction.cs
deleted file mode 100644
index 452cfbc80..000000000
--- a/FractalPainter/Solved/Step03/App/Actions/PaletteSettingsAction.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step03.Infrastructure.Injection;
-using FractalPainting.Solved.Step03.Infrastructure.UiActions;
-
-namespace FractalPainting.Solved.Step03.App.Actions
-{
- public class PaletteSettingsAction : IUiAction, INeed
- {
- private Palette palette;
-
- public void SetDependency(Palette dependency)
- {
- palette = dependency;
- }
-
- public string Category => "Настройки";
- public string Name => "Палитра...";
- public string Description => "Цвета для рисования фракталов";
-
- public void Perform()
- {
- SettingsForm.For(palette).ShowDialog();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step03/App/Actions/SaveImageAction.cs b/FractalPainter/Solved/Step03/App/Actions/SaveImageAction.cs
deleted file mode 100644
index 908cc494d..000000000
--- a/FractalPainter/Solved/Step03/App/Actions/SaveImageAction.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using System.IO;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step03.Infrastructure.Injection;
-using FractalPainting.Solved.Step03.Infrastructure.UiActions;
-
-namespace FractalPainting.Solved.Step03.App.Actions
-{
- public class SaveImageAction : IUiAction, INeed, INeed
- {
- private IImageDirectoryProvider imageDirectoryProvider;
- private IImageHolder imageHolder;
-
- public void SetDependency(IImageDirectoryProvider dependency)
- {
- imageDirectoryProvider = dependency;
- }
-
- public void SetDependency(IImageHolder dependency)
- {
- imageHolder = dependency;
- }
-
- public string Category => "Файл";
- public string Name => "Сохранить...";
- public string Description => "Сохранить изображение в файл";
-
- public void Perform()
- {
- var dialog = new SaveFileDialog
- {
- CheckFileExists = false,
- InitialDirectory = Path.GetFullPath(imageDirectoryProvider.ImagesDirectory),
- DefaultExt = "bmp",
- FileName = "image.bmp",
- Filter = "Изображения (*.bmp)|*.bmp"
- };
- var res = dialog.ShowDialog();
- if (res == DialogResult.OK)
- imageHolder.SaveImage(dialog.FileName);
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step03/App/AppSettings.cs b/FractalPainter/Solved/Step03/App/AppSettings.cs
deleted file mode 100644
index 0d19d68ee..000000000
--- a/FractalPainter/Solved/Step03/App/AppSettings.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step03.App
-{
- public class AppSettings : IImageDirectoryProvider, IImageSettingsProvider
- {
- public string ImagesDirectory { get; set; }
- public ImageSettings ImageSettings { get; set; }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step03/App/Fractals/DragonPainter.cs b/FractalPainter/Solved/Step03/App/Fractals/DragonPainter.cs
deleted file mode 100644
index 69c51e3a3..000000000
--- a/FractalPainter/Solved/Step03/App/Fractals/DragonPainter.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System;
-using System.Drawing;
-using System.Linq;
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step03.App.Fractals
-{
- public class DragonPainter
- {
- private readonly IImageHolder imageHolder;
- private readonly DragonSettings settings;
- private readonly float size;
- private Size imageSize;
-
- public DragonPainter(IImageHolder imageHolder, DragonSettings settings)
- {
- this.imageHolder = imageHolder;
- this.settings = settings;
- imageSize = imageHolder.GetImageSize();
- size = Math.Min(imageSize.Width, imageSize.Height)/2.1f;
- }
-
- public void Paint()
- {
- using (var graphics = imageHolder.StartDrawing())
- {
- graphics.FillRectangle(Brushes.Black, 0, 0, imageSize.Width, imageSize.Height);
- var r = new Random();
- var cosa = (float) Math.Cos(settings.Angle1);
- var sina = (float) Math.Sin(settings.Angle1);
- var cosb = (float) Math.Cos(settings.Angle2);
- var sinb = (float) Math.Sin(settings.Angle2);
- var shiftX = settings.ShiftX*size*0.8f;
- var shiftY = settings.ShiftY*size*0.8f;
- var scale = settings.Scale;
- var p = new PointF(0, 0);
- foreach (var i in Enumerable.Range(0, settings.IterationsCount))
- {
- graphics.FillRectangle(Brushes.Yellow, imageSize.Width/3f + p.X, imageSize.Height/2f + p.Y, 1, 1);
- if (r.Next(0, 2) == 0)
- p = new PointF(scale*(p.X*cosa - p.Y*sina), scale*(p.X*sina + p.Y*cosa));
- else
- p = new PointF(scale*(p.X*cosb - p.Y*sinb) + shiftX, scale*(p.X*sinb + p.Y*cosb) + shiftY);
- if (i%100 == 0) imageHolder.UpdateUi();
- }
- }
- imageHolder.UpdateUi();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step03/App/Fractals/DragonSettings.cs b/FractalPainter/Solved/Step03/App/Fractals/DragonSettings.cs
deleted file mode 100644
index 86e6231bc..000000000
--- a/FractalPainter/Solved/Step03/App/Fractals/DragonSettings.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-
-namespace FractalPainting.Solved.Step03.App.Fractals
-{
- public class DragonSettings
- {
- public double Angle1 { get; set; } = Math.PI / 4;
- public double Angle2 { get; set; } = 3 * Math.PI / 4;
- public float ShiftX { get; set; } = 1;
- public float ShiftY { get; set; } = 0;
- public float Scale { get; set; } = (float)(1 / Math.Sqrt(2));
- public int IterationsCount { get; set; } = 20000;
-
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step03/App/Fractals/DragonSettingsGenerator.cs b/FractalPainter/Solved/Step03/App/Fractals/DragonSettingsGenerator.cs
deleted file mode 100644
index ddaec1fc5..000000000
--- a/FractalPainter/Solved/Step03/App/Fractals/DragonSettingsGenerator.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System;
-
-namespace FractalPainting.Solved.Step03.App.Fractals
-{
- public class DragonSettingsGenerator
- {
- private readonly Random random;
-
- public DragonSettingsGenerator(Random random)
- {
- this.random = random;
- }
-
- public DragonSettings Generate()
- {
- return new DragonSettings
- {
- Angle1 = random.NextDouble() / 2 + 0.5,
- Angle2 = 3 * (random.NextDouble() / 2 + 0.5),
- ShiftX = 1,
- ShiftY = 0,
- Scale = (float)(1/Math.Sqrt(2) + (random.NextDouble() - 0.5)/10)
- };
- }
-
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step03/App/Fractals/KochPainter.cs b/FractalPainter/Solved/Step03/App/Fractals/KochPainter.cs
deleted file mode 100644
index 96b07c108..000000000
--- a/FractalPainter/Solved/Step03/App/Fractals/KochPainter.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-using System;
-using System.Drawing;
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step03.App.Fractals
-{
- public class KochPainter
- {
- private readonly IImageHolder imageHolder;
- private readonly Palette palette;
- private Size imageSize;
-
- public KochPainter(IImageHolder imageHolder, Palette palette)
- {
- this.imageHolder = imageHolder;
- this.palette = palette;
- imageSize = imageHolder.GetImageSize();
- }
-
- public void Paint()
- {
- using (var graphics = imageHolder.StartDrawing())
- using (var backgroundBrush = new SolidBrush(palette.BackgroundColor))
- {
- graphics.FillRectangle(backgroundBrush, 0, 0, imageSize.Width, imageSize.Height);
- DrawSegment(graphics, 0, imageSize.Height*0.9f, imageSize.Width, imageSize.Height*0.9f, true);
- }
- imageHolder.UpdateUi();
- }
-
- private void DrawSegment(Graphics graphics, float x0, float y0, float x1, float y1, bool primaryColor)
- {
- var len2 = (x0 - x1)*(x0 - x1) + (y0 - y1)*(y0 - y1);
- if (len2 < 4)
- {
- if (y0 < 0 || y1 < 0) return;
- using (var penBrush = new SolidBrush(primaryColor ? palette.PrimaryColor : palette.SecondaryColor))
- {
- var pen = new Pen(penBrush, 3);
- graphics.DrawLine(pen, x0, y0, x1, y1);
- }
- }
- else
- {
- var vx = (x1 - x0)/3;
- var vy = (y1 - y0)/3;
- DrawSegment(graphics, x0, y0, x0 + vx, y0 + vy, primaryColor);
- var k = (float) Math.Sqrt(3)/2f;
- var px = (x0 + x1)/2 + vy*k;
- var py = (y0 + y1)/2 - vx*k;
- DrawSegment(graphics, x0 + vx, y0 + vy, px, py, !primaryColor);
- DrawSegment(graphics, px, py, x0 + 2*vx, y0 + 2*vy, !primaryColor);
- DrawSegment(graphics, x0 + 2*vx, y0 + 2*vy, x1, y1, primaryColor);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step03/App/MainForm.cs b/FractalPainter/Solved/Step03/App/MainForm.cs
deleted file mode 100644
index 717318415..000000000
--- a/FractalPainter/Solved/Step03/App/MainForm.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using System;
-using System.Drawing;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step03.Infrastructure.Injection;
-using FractalPainting.Solved.Step03.Infrastructure.UiActions;
-using Ninject;
-
-namespace FractalPainting.Solved.Step03.App
-{
- public class MainForm : Form
- {
- public MainForm(IUiAction[] actions,
- PictureBoxImageHolder pictureBox,
- Palette palette)
- {
- var imageSettings = CreateSettingsManager().Load().ImageSettings;
- ClientSize = new Size(imageSettings.Width, imageSettings.Height);
-
- var mainMenu = new MenuStrip();
- mainMenu.Items.AddRange(actions.ToMenuItems());
- Controls.Add(mainMenu);
-
- pictureBox.RecreateImage(imageSettings);
- pictureBox.Dock = DockStyle.Fill;
- Controls.Add(pictureBox);
-
- DependencyInjector.Inject(actions, pictureBox);
- DependencyInjector.Inject(actions, CreateSettingsManager().Load());
- DependencyInjector.Inject(actions, CreateSettingsManager().Load());
- DependencyInjector.Inject(actions, palette);
- }
-
- private static SettingsManager CreateSettingsManager()
- {
- var container = new StandardKernel();
- container.Bind().To();
- container.Bind().To();
- return container.Get();
- }
-
- protected override void OnShown(EventArgs e)
- {
- base.OnShown(e);
- Text = "Fractal Painter";
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step03/App/MainForm.resx b/FractalPainter/Solved/Step03/App/MainForm.resx
deleted file mode 100644
index 9d845151a..000000000
--- a/FractalPainter/Solved/Step03/App/MainForm.resx
+++ /dev/null
@@ -1,123 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- 17, 17
-
-
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step03/App/PictureBoxImageHolder.cs b/FractalPainter/Solved/Step03/App/PictureBoxImageHolder.cs
deleted file mode 100644
index a2cb38e22..000000000
--- a/FractalPainter/Solved/Step03/App/PictureBoxImageHolder.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-using System;
-using System.Drawing;
-using System.Drawing.Imaging;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step03.App
-{
- public class PictureBoxImageHolder : PictureBox, IImageHolder
- {
- public Size GetImageSize()
- {
- FailIfNotInitialized();
- return Image.Size;
- }
-
- public Graphics StartDrawing()
- {
- FailIfNotInitialized();
- return Graphics.FromImage(Image);
- }
-
- private void FailIfNotInitialized()
- {
- if (Image == null)
- throw new InvalidOperationException("Call PictureBoxImageHolder.RecreateImage before other method call!");
- }
-
- public void UpdateUi()
- {
- Refresh();
- Application.DoEvents();
- }
-
- public void RecreateImage(ImageSettings imageSettings)
- {
- Image = new Bitmap(imageSettings.Width, imageSettings.Height, PixelFormat.Format24bppRgb);
- }
-
- public void SaveImage(string fileName)
- {
- FailIfNotInitialized();
- Image.Save(fileName);
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step03/App/Program.cs b/FractalPainter/Solved/Step03/App/Program.cs
deleted file mode 100644
index 42ef06d9b..000000000
--- a/FractalPainter/Solved/Step03/App/Program.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-using System;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step03.App.Actions;
-using FractalPainting.Solved.Step03.Infrastructure.UiActions;
-using Ninject;
-
-namespace FractalPainting.Solved.Step03.App
-{
- internal static class Program
- {
- ///
- /// The main entry point for the application.
- ///
- [STAThread]
- private static void Main()
- {
- try
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
-
- var container = new StandardKernel();
-
- container.Bind().To();
- container.Bind().To();
- container.Bind().To();
- container.Bind().To();
- container.Bind().To();
-
- container.Bind().ToSelf()
- .InSingletonScope();
- container.Bind()
- .To()
- .InSingletonScope();
-
- var mainForm = container.Get();
- Application.Run(mainForm);
- }
- catch (Exception e)
- {
- MessageBox.Show(e.Message);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step03/App/SettingsManager.cs b/FractalPainter/Solved/Step03/App/SettingsManager.cs
deleted file mode 100644
index 05c230c5a..000000000
--- a/FractalPainter/Solved/Step03/App/SettingsManager.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step03.App
-{
- public class SettingsManager
- {
- private readonly IObjectSerializer serializer;
- private readonly IBlobStorage storage;
- private string settingsFilename;
-
- public SettingsManager(IObjectSerializer serializer, IBlobStorage storage)
- {
- this.serializer = serializer;
- this.storage = storage;
- }
-
- public AppSettings Load()
- {
- try
- {
- settingsFilename = "app.settings";
- var data = storage.Get(settingsFilename);
- if (data == null)
- {
- var defaultSettings = CreateDefaultSettings();
- Save(defaultSettings);
- return defaultSettings;
- }
- return serializer.Deserialize(data);
- }
- catch (Exception e)
- {
- MessageBox.Show(e.Message, "Не удалось загрузить настройки");
- return CreateDefaultSettings();
- }
- }
-
- private static AppSettings CreateDefaultSettings()
- {
- return new AppSettings
- {
- ImagesDirectory = ".",
- ImageSettings = new ImageSettings()
- };
- }
-
- public void Save(AppSettings settings)
- {
- storage.Set(settingsFilename, serializer.Serialize(settings));
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step03/Infrastructure/Injection/DependencyInjector.cs b/FractalPainter/Solved/Step03/Infrastructure/Injection/DependencyInjector.cs
deleted file mode 100644
index 4b1a9312f..000000000
--- a/FractalPainter/Solved/Step03/Infrastructure/Injection/DependencyInjector.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System.Collections;
-
-namespace FractalPainting.Solved.Step03.Infrastructure.Injection
-{
- public class DependencyInjector
- {
- public static void Inject(object service, TDependency dependency)
- {
- var need = service as INeed;
- need?.SetDependency(dependency);
- }
-
- public static void Inject(IEnumerable services, TDependency dependency)
- {
- foreach (var service in services)
- Inject(service, dependency);
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step03/Infrastructure/Injection/INeed.cs b/FractalPainter/Solved/Step03/Infrastructure/Injection/INeed.cs
deleted file mode 100644
index eedfda5c3..000000000
--- a/FractalPainter/Solved/Step03/Infrastructure/Injection/INeed.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace FractalPainting.Solved.Step03.Infrastructure.Injection
-{
- public interface INeed
- {
- void SetDependency(T dependency);
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step03/Infrastructure/UiActions/IUiAction.cs b/FractalPainter/Solved/Step03/Infrastructure/UiActions/IUiAction.cs
deleted file mode 100644
index 2e6a805bf..000000000
--- a/FractalPainter/Solved/Step03/Infrastructure/UiActions/IUiAction.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace FractalPainting.Solved.Step03.Infrastructure.UiActions
-{
- public interface IUiAction
- {
- string Category { get; }
- string Name { get; }
- string Description { get; }
- void Perform();
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step03/Infrastructure/UiActions/UiActionExtensions.cs b/FractalPainter/Solved/Step03/Infrastructure/UiActions/UiActionExtensions.cs
deleted file mode 100644
index c1226c864..000000000
--- a/FractalPainter/Solved/Step03/Infrastructure/UiActions/UiActionExtensions.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using System.Windows.Forms;
-
-namespace FractalPainting.Solved.Step03.Infrastructure.UiActions
-{
- public static class UiActionExtensions
- {
- public static ToolStripItem[] ToMenuItems(this IUiAction[] actions)
- {
- var items = actions.GroupBy(a => a.Category)
- .Select(g => CreateTopLevelMenuItem(g.Key, g.ToList()))
- .Cast()
- .ToArray();
- return items;
- }
-
- private static ToolStripMenuItem CreateTopLevelMenuItem(string name, IList items)
- {
- var menuItems = items.Select(a => a.ToMenuItem()).ToArray();
- return new ToolStripMenuItem(name, null, menuItems);
- }
-
- public static ToolStripItem ToMenuItem(this IUiAction action)
- {
- return
- new ToolStripMenuItem(action.Name, null, (sender, args) => action.Perform())
- {
- ToolTipText = action.Description,
- Tag = action
- };
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step03/Step03.csproj b/FractalPainter/Solved/Step03/Step03.csproj
deleted file mode 100644
index 2ecb6cdfe..000000000
--- a/FractalPainter/Solved/Step03/Step03.csproj
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
- WinExe
- netcoreapp3.1
- true
- false
- FractalPainting.Solved.Step03
- FractalPainter
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step04/App/Actions/DragonFractalAction.cs b/FractalPainter/Solved/Step04/App/Actions/DragonFractalAction.cs
deleted file mode 100644
index 9500587c8..000000000
--- a/FractalPainter/Solved/Step04/App/Actions/DragonFractalAction.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System;
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step04.App.Fractals;
-using FractalPainting.Solved.Step04.Infrastructure.Injection;
-using FractalPainting.Solved.Step04.Infrastructure.UiActions;
-using Ninject;
-
-namespace FractalPainting.Solved.Step04.App.Actions
-{
- public class DragonFractalAction : IUiAction, INeed
- {
- private IImageHolder imageHolder;
-
- public void SetDependency(IImageHolder dependency)
- {
- imageHolder = dependency;
- }
-
- public string Category => "Фракталы";
- public string Name => "Дракон";
- public string Description => "Дракон Хартера-Хейтуэя";
-
- public void Perform()
- {
- var dragonSettings = CreateRandomSettings();
- // редактируем настройки:
- SettingsForm.For(dragonSettings).ShowDialog();
- // создаём painter с такими настройками
- var container = new StandardKernel();
- container.Bind().ToConstant(imageHolder);
- container.Bind().ToConstant(dragonSettings);
- container.Get().Paint();
- }
-
- private static DragonSettings CreateRandomSettings()
- {
- return new DragonSettingsGenerator(new Random()).Generate();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step04/App/Actions/ImageSettingsAction.cs b/FractalPainter/Solved/Step04/App/Actions/ImageSettingsAction.cs
deleted file mode 100644
index b65106a04..000000000
--- a/FractalPainter/Solved/Step04/App/Actions/ImageSettingsAction.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step04.Infrastructure.Injection;
-using FractalPainting.Solved.Step04.Infrastructure.UiActions;
-
-namespace FractalPainting.Solved.Step04.App.Actions
-{
- public class ImageSettingsAction : IUiAction, INeed, INeed
- {
- private IImageHolder imageHolder;
- private IImageSettingsProvider imageSettingsProvider;
-
- public void SetDependency(IImageHolder dependency)
- {
- imageHolder = dependency;
- }
-
- public void SetDependency(IImageSettingsProvider dependency)
- {
- imageSettingsProvider = dependency;
- }
-
- public string Category => "Настройки";
- public string Name => "Изображение...";
- public string Description => "Размеры изображения";
-
- public void Perform()
- {
- var imageSettings = imageSettingsProvider.ImageSettings;
- SettingsForm.For(imageSettings).ShowDialog();
- imageHolder.RecreateImage(imageSettings);
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step04/App/Actions/KochFractalAction.cs b/FractalPainter/Solved/Step04/App/Actions/KochFractalAction.cs
deleted file mode 100644
index 3ff168a70..000000000
--- a/FractalPainter/Solved/Step04/App/Actions/KochFractalAction.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using FractalPainting.Solved.Step04.App.Fractals;
-using FractalPainting.Solved.Step04.Infrastructure.UiActions;
-
-namespace FractalPainting.Solved.Step04.App.Actions
-{
- public class KochFractalAction : IUiAction
- {
- private readonly KochPainter kochPainter;
-
- public KochFractalAction(KochPainter kochPainter)
- {
- this.kochPainter = kochPainter;
- }
-
- public string Category => "Фракталы";
- public string Name => "Кривая Коха";
- public string Description => "Кривая Коха";
-
- public void Perform()
- {
- kochPainter.Paint();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step04/App/Actions/PaletteSettingsAction.cs b/FractalPainter/Solved/Step04/App/Actions/PaletteSettingsAction.cs
deleted file mode 100644
index 85bb762ab..000000000
--- a/FractalPainter/Solved/Step04/App/Actions/PaletteSettingsAction.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step04.Infrastructure.Injection;
-using FractalPainting.Solved.Step04.Infrastructure.UiActions;
-
-namespace FractalPainting.Solved.Step04.App.Actions
-{
- public class PaletteSettingsAction : IUiAction, INeed
- {
- private Palette palette;
-
- public void SetDependency(Palette dependency)
- {
- palette = dependency;
- }
-
- public string Category => "Настройки";
- public string Name => "Палитра...";
- public string Description => "Цвета для рисования фракталов";
-
- public void Perform()
- {
- SettingsForm.For(palette).ShowDialog();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step04/App/Actions/SaveImageAction.cs b/FractalPainter/Solved/Step04/App/Actions/SaveImageAction.cs
deleted file mode 100644
index a45f1e0ee..000000000
--- a/FractalPainter/Solved/Step04/App/Actions/SaveImageAction.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using System.IO;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step04.Infrastructure.Injection;
-using FractalPainting.Solved.Step04.Infrastructure.UiActions;
-
-namespace FractalPainting.Solved.Step04.App.Actions
-{
- public class SaveImageAction : IUiAction, INeed, INeed
- {
- private IImageDirectoryProvider imageDirectoryProvider;
- private IImageHolder imageHolder;
-
- public void SetDependency(IImageDirectoryProvider dependency)
- {
- imageDirectoryProvider = dependency;
- }
-
- public void SetDependency(IImageHolder dependency)
- {
- imageHolder = dependency;
- }
-
- public string Category => "Файл";
- public string Name => "Сохранить...";
- public string Description => "Сохранить изображение в файл";
-
- public void Perform()
- {
- var dialog = new SaveFileDialog
- {
- CheckFileExists = false,
- InitialDirectory = Path.GetFullPath(imageDirectoryProvider.ImagesDirectory),
- DefaultExt = "bmp",
- FileName = "image.bmp",
- Filter = "Изображения (*.bmp)|*.bmp"
- };
- var res = dialog.ShowDialog();
- if (res == DialogResult.OK)
- imageHolder.SaveImage(dialog.FileName);
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step04/App/AppSettings.cs b/FractalPainter/Solved/Step04/App/AppSettings.cs
deleted file mode 100644
index cc0371a46..000000000
--- a/FractalPainter/Solved/Step04/App/AppSettings.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step04.App
-{
- public class AppSettings : IImageDirectoryProvider, IImageSettingsProvider
- {
- public string ImagesDirectory { get; set; }
- public ImageSettings ImageSettings { get; set; }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step04/App/Fractals/DragonPainter.cs b/FractalPainter/Solved/Step04/App/Fractals/DragonPainter.cs
deleted file mode 100644
index f5dd59704..000000000
--- a/FractalPainter/Solved/Step04/App/Fractals/DragonPainter.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System;
-using System.Drawing;
-using System.Linq;
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step04.App.Fractals
-{
- public class DragonPainter
- {
- private readonly IImageHolder imageHolder;
- private readonly DragonSettings settings;
- private readonly float size;
- private Size imageSize;
-
- public DragonPainter(IImageHolder imageHolder, DragonSettings settings)
- {
- this.imageHolder = imageHolder;
- this.settings = settings;
- imageSize = imageHolder.GetImageSize();
- size = Math.Min(imageSize.Width, imageSize.Height)/2.1f;
- }
-
- public void Paint()
- {
- using (var graphics = imageHolder.StartDrawing())
- {
- graphics.FillRectangle(Brushes.Black, 0, 0, imageSize.Width, imageSize.Height);
- var r = new Random();
- var cosa = (float) Math.Cos(settings.Angle1);
- var sina = (float) Math.Sin(settings.Angle1);
- var cosb = (float) Math.Cos(settings.Angle2);
- var sinb = (float) Math.Sin(settings.Angle2);
- var shiftX = settings.ShiftX*size*0.8f;
- var shiftY = settings.ShiftY*size*0.8f;
- var scale = settings.Scale;
- var p = new PointF(0, 0);
- foreach (var i in Enumerable.Range(0, settings.IterationsCount))
- {
- graphics.FillRectangle(Brushes.Yellow, imageSize.Width/3f + p.X, imageSize.Height/2f + p.Y, 1, 1);
- if (r.Next(0, 2) == 0)
- p = new PointF(scale*(p.X*cosa - p.Y*sina), scale*(p.X*sina + p.Y*cosa));
- else
- p = new PointF(scale*(p.X*cosb - p.Y*sinb) + shiftX, scale*(p.X*sinb + p.Y*cosb) + shiftY);
- if (i%100 == 0) imageHolder.UpdateUi();
- }
- }
- imageHolder.UpdateUi();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step04/App/Fractals/DragonSettings.cs b/FractalPainter/Solved/Step04/App/Fractals/DragonSettings.cs
deleted file mode 100644
index 9bd2043e2..000000000
--- a/FractalPainter/Solved/Step04/App/Fractals/DragonSettings.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-
-namespace FractalPainting.Solved.Step04.App.Fractals
-{
- public class DragonSettings
- {
- public double Angle1 { get; set; } = Math.PI / 4;
- public double Angle2 { get; set; } = 3 * Math.PI / 4;
- public float ShiftX { get; set; } = 1;
- public float ShiftY { get; set; } = 0;
- public float Scale { get; set; } = (float)(1 / Math.Sqrt(2));
- public int IterationsCount { get; set; } = 20000;
-
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step04/App/Fractals/DragonSettingsGenerator.cs b/FractalPainter/Solved/Step04/App/Fractals/DragonSettingsGenerator.cs
deleted file mode 100644
index 2a985a961..000000000
--- a/FractalPainter/Solved/Step04/App/Fractals/DragonSettingsGenerator.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System;
-
-namespace FractalPainting.Solved.Step04.App.Fractals
-{
- public class DragonSettingsGenerator
- {
- private readonly Random random;
-
- public DragonSettingsGenerator(Random random)
- {
- this.random = random;
- }
-
- public DragonSettings Generate()
- {
- return new DragonSettings
- {
- Angle1 = random.NextDouble() / 2 + 0.5,
- Angle2 = 3 * (random.NextDouble() / 2 + 0.5),
- ShiftX = 1,
- ShiftY = 0,
- Scale = (float)(1/Math.Sqrt(2) + (random.NextDouble() - 0.5)/10)
- };
- }
-
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step04/App/Fractals/KochPainter.cs b/FractalPainter/Solved/Step04/App/Fractals/KochPainter.cs
deleted file mode 100644
index 468de7158..000000000
--- a/FractalPainter/Solved/Step04/App/Fractals/KochPainter.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-using System;
-using System.Drawing;
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step04.App.Fractals
-{
- public class KochPainter
- {
- private readonly IImageHolder imageHolder;
- private readonly Palette palette;
-
- public KochPainter(IImageHolder imageHolder, Palette palette)
- {
- this.imageHolder = imageHolder;
- this.palette = palette;
- }
-
- public void Paint()
- {
- var imageSize = imageHolder.GetImageSize();
- using (var graphics = imageHolder.StartDrawing())
- using (var backgroundBrush = new SolidBrush(palette.BackgroundColor))
- {
- graphics.FillRectangle(backgroundBrush, 0, 0, imageSize.Width, imageSize.Height);
- DrawSegment(graphics, 0, imageSize.Height*0.9f, imageSize.Width, imageSize.Height*0.9f, true);
- }
- imageHolder.UpdateUi();
- }
-
- private void DrawSegment(Graphics graphics, float x0, float y0, float x1, float y1, bool primaryColor)
- {
- var len2 = (x0 - x1)*(x0 - x1) + (y0 - y1)*(y0 - y1);
- if (len2 < 4)
- {
- if (y0 < 0 || y1 < 0) return;
- using (var penBrush = new SolidBrush(primaryColor ? palette.PrimaryColor : palette.SecondaryColor))
- {
- var pen = new Pen(penBrush, 3);
- graphics.DrawLine(pen, x0, y0, x1, y1);
- }
- }
- else
- {
- var vx = (x1 - x0)/3;
- var vy = (y1 - y0)/3;
- DrawSegment(graphics, x0, y0, x0 + vx, y0 + vy, primaryColor);
- var k = (float) Math.Sqrt(3)/2f;
- var px = (x0 + x1)/2 + vy*k;
- var py = (y0 + y1)/2 - vx*k;
- DrawSegment(graphics, x0 + vx, y0 + vy, px, py, !primaryColor);
- DrawSegment(graphics, px, py, x0 + 2*vx, y0 + 2*vy, !primaryColor);
- DrawSegment(graphics, x0 + 2*vx, y0 + 2*vy, x1, y1, primaryColor);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step04/App/MainForm.cs b/FractalPainter/Solved/Step04/App/MainForm.cs
deleted file mode 100644
index ce6a51f2b..000000000
--- a/FractalPainter/Solved/Step04/App/MainForm.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using System;
-using System.Drawing;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step04.Infrastructure.Injection;
-using FractalPainting.Solved.Step04.Infrastructure.UiActions;
-using Ninject;
-
-namespace FractalPainting.Solved.Step04.App
-{
- public class MainForm : Form
- {
- public MainForm(IUiAction[] actions,
- PictureBoxImageHolder pictureBox,
- Palette palette)
- {
- var imageSettings = CreateSettingsManager().Load().ImageSettings;
- ClientSize = new Size(imageSettings.Width, imageSettings.Height);
-
- var mainMenu = new MenuStrip();
- mainMenu.Items.AddRange(actions.ToMenuItems());
- Controls.Add(mainMenu);
-
- pictureBox.RecreateImage(imageSettings);
- pictureBox.Dock = DockStyle.Fill;
- Controls.Add(pictureBox);
-
- DependencyInjector.Inject(actions, pictureBox);
- DependencyInjector.Inject(actions, CreateSettingsManager().Load());
- DependencyInjector.Inject(actions, CreateSettingsManager().Load());
- DependencyInjector.Inject(actions, palette);
- }
-
- private static SettingsManager CreateSettingsManager()
- {
- var container = new StandardKernel();
- container.Bind().To();
- container.Bind().To();
- return container.Get();
- }
-
- protected override void OnShown(EventArgs e)
- {
- base.OnShown(e);
- Text = "Fractal Painter";
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step04/App/MainForm.resx b/FractalPainter/Solved/Step04/App/MainForm.resx
deleted file mode 100644
index 9d845151a..000000000
--- a/FractalPainter/Solved/Step04/App/MainForm.resx
+++ /dev/null
@@ -1,123 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- 17, 17
-
-
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step04/App/PictureBoxImageHolder.cs b/FractalPainter/Solved/Step04/App/PictureBoxImageHolder.cs
deleted file mode 100644
index 296696f21..000000000
--- a/FractalPainter/Solved/Step04/App/PictureBoxImageHolder.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-using System;
-using System.Drawing;
-using System.Drawing.Imaging;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step04.App
-{
- public class PictureBoxImageHolder : PictureBox, IImageHolder
- {
- public Size GetImageSize()
- {
- FailIfNotInitialized();
- return Image.Size;
- }
-
- public Graphics StartDrawing()
- {
- FailIfNotInitialized();
- return Graphics.FromImage(Image);
- }
-
- private void FailIfNotInitialized()
- {
- if (Image == null)
- throw new InvalidOperationException("Call PictureBoxImageHolder.RecreateImage before other method call!");
- }
-
- public void UpdateUi()
- {
- Refresh();
- Application.DoEvents();
- }
-
- public void RecreateImage(ImageSettings imageSettings)
- {
- Image = new Bitmap(imageSettings.Width, imageSettings.Height, PixelFormat.Format24bppRgb);
- }
-
- public void SaveImage(string fileName)
- {
- FailIfNotInitialized();
- Image.Save(fileName);
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step04/App/Program.cs b/FractalPainter/Solved/Step04/App/Program.cs
deleted file mode 100644
index b06132e3e..000000000
--- a/FractalPainter/Solved/Step04/App/Program.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-using System;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step04.App.Actions;
-using FractalPainting.Solved.Step04.Infrastructure.UiActions;
-using Ninject;
-
-namespace FractalPainting.Solved.Step04.App
-{
- internal static class Program
- {
- ///
- /// The main entry point for the application.
- ///
- [STAThread]
- private static void Main()
- {
- try
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
-
- var container = new StandardKernel();
-
- container.Bind().To();
- container.Bind().To();
- container.Bind().To();
- container.Bind().To();
- container.Bind().To();
-
- container.Bind().ToSelf()
- .InSingletonScope();
- container.Bind()
- .To()
- .InSingletonScope();
-
- var mainForm = container.Get();
- Application.Run(mainForm);
- }
- catch (Exception e)
- {
- MessageBox.Show(e.Message);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step04/App/SettingsManager.cs b/FractalPainter/Solved/Step04/App/SettingsManager.cs
deleted file mode 100644
index d2a8466b5..000000000
--- a/FractalPainter/Solved/Step04/App/SettingsManager.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step04.App
-{
- public class SettingsManager
- {
- private readonly IObjectSerializer serializer;
- private readonly IBlobStorage storage;
- private string settingsFilename;
-
- public SettingsManager(IObjectSerializer serializer, IBlobStorage storage)
- {
- this.serializer = serializer;
- this.storage = storage;
- }
-
- public AppSettings Load()
- {
- try
- {
- settingsFilename = "app.settings";
- var data = storage.Get(settingsFilename);
- if (data == null)
- {
- var defaultSettings = CreateDefaultSettings();
- Save(defaultSettings);
- return defaultSettings;
- }
- return serializer.Deserialize(data);
- }
- catch (Exception e)
- {
- MessageBox.Show(e.Message, "Не удалось загрузить настройки");
- return CreateDefaultSettings();
- }
- }
-
- private static AppSettings CreateDefaultSettings()
- {
- return new AppSettings
- {
- ImagesDirectory = ".",
- ImageSettings = new ImageSettings()
- };
- }
-
- public void Save(AppSettings settings)
- {
- storage.Set(settingsFilename, serializer.Serialize(settings));
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step04/Infrastructure/Injection/DependencyInjector.cs b/FractalPainter/Solved/Step04/Infrastructure/Injection/DependencyInjector.cs
deleted file mode 100644
index 648a02758..000000000
--- a/FractalPainter/Solved/Step04/Infrastructure/Injection/DependencyInjector.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System.Collections;
-
-namespace FractalPainting.Solved.Step04.Infrastructure.Injection
-{
- public class DependencyInjector
- {
- public static void Inject(object service, TDependency dependency)
- {
- var need = service as INeed;
- need?.SetDependency(dependency);
- }
-
- public static void Inject(IEnumerable services, TDependency dependency)
- {
- foreach (var service in services)
- Inject(service, dependency);
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step04/Infrastructure/Injection/INeed.cs b/FractalPainter/Solved/Step04/Infrastructure/Injection/INeed.cs
deleted file mode 100644
index 08198ad0d..000000000
--- a/FractalPainter/Solved/Step04/Infrastructure/Injection/INeed.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace FractalPainting.Solved.Step04.Infrastructure.Injection
-{
- public interface INeed
- {
- void SetDependency(T dependency);
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step04/Infrastructure/UiActions/IUiAction.cs b/FractalPainter/Solved/Step04/Infrastructure/UiActions/IUiAction.cs
deleted file mode 100644
index 717fc02ef..000000000
--- a/FractalPainter/Solved/Step04/Infrastructure/UiActions/IUiAction.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace FractalPainting.Solved.Step04.Infrastructure.UiActions
-{
- public interface IUiAction
- {
- string Category { get; }
- string Name { get; }
- string Description { get; }
- void Perform();
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step04/Infrastructure/UiActions/UiActionExtensions.cs b/FractalPainter/Solved/Step04/Infrastructure/UiActions/UiActionExtensions.cs
deleted file mode 100644
index 5b9517d83..000000000
--- a/FractalPainter/Solved/Step04/Infrastructure/UiActions/UiActionExtensions.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using System.Windows.Forms;
-
-namespace FractalPainting.Solved.Step04.Infrastructure.UiActions
-{
- public static class UiActionExtensions
- {
- public static ToolStripItem[] ToMenuItems(this IUiAction[] actions)
- {
- var items = actions.GroupBy(a => a.Category)
- .Select(g => CreateTopLevelMenuItem(g.Key, g.ToList()))
- .Cast()
- .ToArray();
- return items;
- }
-
- private static ToolStripMenuItem CreateTopLevelMenuItem(string name, IList items)
- {
- var menuItems = items.Select(a => a.ToMenuItem()).ToArray();
- return new ToolStripMenuItem(name, null, menuItems);
- }
-
- public static ToolStripItem ToMenuItem(this IUiAction action)
- {
- return
- new ToolStripMenuItem(action.Name, null, (sender, args) => action.Perform())
- {
- ToolTipText = action.Description,
- Tag = action
- };
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step04/Step04.csproj b/FractalPainter/Solved/Step04/Step04.csproj
deleted file mode 100644
index ae813ceef..000000000
--- a/FractalPainter/Solved/Step04/Step04.csproj
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
- WinExe
- netcoreapp3.1
- true
- false
- FractalPainting.Solved.Step04
- FractalPainter
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step05/App/Actions/DragonFractalAction.cs b/FractalPainter/Solved/Step05/App/Actions/DragonFractalAction.cs
deleted file mode 100644
index 32e083b34..000000000
--- a/FractalPainter/Solved/Step05/App/Actions/DragonFractalAction.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using System;
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step05.App.Fractals;
-using FractalPainting.Solved.Step05.Infrastructure.UiActions;
-
-namespace FractalPainting.Solved.Step05.App.Actions
-{
- public class DragonFractalAction : IUiAction
- {
- private readonly IDragonPainterFactory dragonPainterFactory;
-
- public DragonFractalAction(IDragonPainterFactory dragonPainterFactory)
- {
- this.dragonPainterFactory = dragonPainterFactory;
- }
-
- public string Category => "Фракталы";
- public string Name => "Дракон";
- public string Description => "Дракон Хартера-Хейтуэя";
-
- public void Perform()
- {
- var dragonSettings = CreateRandomSettings();
- // редактируем настройки:
- SettingsForm.For(dragonSettings).ShowDialog();
- // создаём painter с такими настройками
- dragonPainterFactory.Create(dragonSettings).Paint();
- }
-
- private static DragonSettings CreateRandomSettings()
- {
- return new DragonSettingsGenerator(new Random()).Generate();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step05/App/Actions/ImageSettingsAction.cs b/FractalPainter/Solved/Step05/App/Actions/ImageSettingsAction.cs
deleted file mode 100644
index 439aad5ac..000000000
--- a/FractalPainter/Solved/Step05/App/Actions/ImageSettingsAction.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step05.Infrastructure.Injection;
-using FractalPainting.Solved.Step05.Infrastructure.UiActions;
-
-namespace FractalPainting.Solved.Step05.App.Actions
-{
- public class ImageSettingsAction : IUiAction, INeed, INeed
- {
- private IImageHolder imageHolder;
- private IImageSettingsProvider imageSettingsProvider;
-
- public void SetDependency(IImageHolder dependency)
- {
- imageHolder = dependency;
- }
-
- public void SetDependency(IImageSettingsProvider dependency)
- {
- imageSettingsProvider = dependency;
- }
-
- public string Category => "Настройки";
- public string Name => "Изображение...";
- public string Description => "Размеры изображения";
-
- public void Perform()
- {
- var imageSettings = imageSettingsProvider.ImageSettings;
- SettingsForm.For(imageSettings).ShowDialog();
- imageHolder.RecreateImage(imageSettings);
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step05/App/Actions/KochFractalAction.cs b/FractalPainter/Solved/Step05/App/Actions/KochFractalAction.cs
deleted file mode 100644
index 18d59e5f3..000000000
--- a/FractalPainter/Solved/Step05/App/Actions/KochFractalAction.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using FractalPainting.Solved.Step05.App.Fractals;
-using FractalPainting.Solved.Step05.Infrastructure.UiActions;
-
-namespace FractalPainting.Solved.Step05.App.Actions
-{
- public class KochFractalAction : IUiAction
- {
- private readonly KochPainter kochPainter;
-
- public KochFractalAction(KochPainter kochPainter)
- {
- this.kochPainter = kochPainter;
- }
-
- public string Category => "Фракталы";
- public string Name => "Кривая Коха";
- public string Description => "Кривая Коха";
-
- public void Perform()
- {
- kochPainter.Paint();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step05/App/Actions/PaletteSettingsAction.cs b/FractalPainter/Solved/Step05/App/Actions/PaletteSettingsAction.cs
deleted file mode 100644
index ccd89b290..000000000
--- a/FractalPainter/Solved/Step05/App/Actions/PaletteSettingsAction.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step05.Infrastructure.Injection;
-using FractalPainting.Solved.Step05.Infrastructure.UiActions;
-
-namespace FractalPainting.Solved.Step05.App.Actions
-{
- public class PaletteSettingsAction : IUiAction, INeed
- {
- private Palette palette;
-
- public void SetDependency(Palette dependency)
- {
- palette = dependency;
- }
-
- public string Category => "Настройки";
- public string Name => "Палитра...";
- public string Description => "Цвета для рисования фракталов";
-
- public void Perform()
- {
- SettingsForm.For(palette).ShowDialog();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step05/App/Actions/SaveImageAction.cs b/FractalPainter/Solved/Step05/App/Actions/SaveImageAction.cs
deleted file mode 100644
index d06f8fb33..000000000
--- a/FractalPainter/Solved/Step05/App/Actions/SaveImageAction.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using System.IO;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step05.Infrastructure.Injection;
-using FractalPainting.Solved.Step05.Infrastructure.UiActions;
-
-namespace FractalPainting.Solved.Step05.App.Actions
-{
- public class SaveImageAction : IUiAction, INeed, INeed
- {
- private IImageDirectoryProvider imageDirectoryProvider;
- private IImageHolder imageHolder;
-
- public void SetDependency(IImageDirectoryProvider dependency)
- {
- imageDirectoryProvider = dependency;
- }
-
- public void SetDependency(IImageHolder dependency)
- {
- imageHolder = dependency;
- }
-
- public string Category => "Файл";
- public string Name => "Сохранить...";
- public string Description => "Сохранить изображение в файл";
-
- public void Perform()
- {
- var dialog = new SaveFileDialog
- {
- CheckFileExists = false,
- InitialDirectory = Path.GetFullPath(imageDirectoryProvider.ImagesDirectory),
- DefaultExt = "bmp",
- FileName = "image.bmp",
- Filter = "Изображения (*.bmp)|*.bmp"
- };
- var res = dialog.ShowDialog();
- if (res == DialogResult.OK)
- imageHolder.SaveImage(dialog.FileName);
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step05/App/AppSettings.cs b/FractalPainter/Solved/Step05/App/AppSettings.cs
deleted file mode 100644
index 1c005975a..000000000
--- a/FractalPainter/Solved/Step05/App/AppSettings.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step05.App
-{
- public class AppSettings : IImageDirectoryProvider, IImageSettingsProvider
- {
- public string ImagesDirectory { get; set; }
- public ImageSettings ImageSettings { get; set; }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step05/App/Fractals/DragonPainter.cs b/FractalPainter/Solved/Step05/App/Fractals/DragonPainter.cs
deleted file mode 100644
index f164ca050..000000000
--- a/FractalPainter/Solved/Step05/App/Fractals/DragonPainter.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System;
-using System.Drawing;
-using System.Linq;
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step05.App.Fractals
-{
- public class DragonPainter
- {
- private readonly IImageHolder imageHolder;
- private readonly DragonSettings settings;
- private readonly float size;
- private Size imageSize;
-
- public DragonPainter(IImageHolder imageHolder, DragonSettings settings)
- {
- this.imageHolder = imageHolder;
- this.settings = settings;
- imageSize = imageHolder.GetImageSize();
- size = Math.Min(imageSize.Width, imageSize.Height)/2.1f;
- }
-
- public void Paint()
- {
- using (var graphics = imageHolder.StartDrawing())
- {
- graphics.FillRectangle(Brushes.Black, 0, 0, imageSize.Width, imageSize.Height);
- var r = new Random();
- var cosa = (float) Math.Cos(settings.Angle1);
- var sina = (float) Math.Sin(settings.Angle1);
- var cosb = (float) Math.Cos(settings.Angle2);
- var sinb = (float) Math.Sin(settings.Angle2);
- var shiftX = settings.ShiftX*size*0.8f;
- var shiftY = settings.ShiftY*size*0.8f;
- var scale = settings.Scale;
- var p = new PointF(0, 0);
- foreach (var i in Enumerable.Range(0, settings.IterationsCount))
- {
- graphics.FillRectangle(Brushes.Yellow, imageSize.Width/3f + p.X, imageSize.Height/2f + p.Y, 1, 1);
- if (r.Next(0, 2) == 0)
- p = new PointF(scale*(p.X*cosa - p.Y*sina), scale*(p.X*sina + p.Y*cosa));
- else
- p = new PointF(scale*(p.X*cosb - p.Y*sinb) + shiftX, scale*(p.X*sinb + p.Y*cosb) + shiftY);
- if (i%100 == 0) imageHolder.UpdateUi();
- }
- }
- imageHolder.UpdateUi();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step05/App/Fractals/DragonSettings.cs b/FractalPainter/Solved/Step05/App/Fractals/DragonSettings.cs
deleted file mode 100644
index 2cbc7d752..000000000
--- a/FractalPainter/Solved/Step05/App/Fractals/DragonSettings.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-
-namespace FractalPainting.Solved.Step05.App.Fractals
-{
- public class DragonSettings
- {
- public double Angle1 { get; set; } = Math.PI / 4;
- public double Angle2 { get; set; } = 3 * Math.PI / 4;
- public float ShiftX { get; set; } = 1;
- public float ShiftY { get; set; } = 0;
- public float Scale { get; set; } = (float)(1 / Math.Sqrt(2));
- public int IterationsCount { get; set; } = 20000;
-
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step05/App/Fractals/DragonSettingsGenerator.cs b/FractalPainter/Solved/Step05/App/Fractals/DragonSettingsGenerator.cs
deleted file mode 100644
index bd8526584..000000000
--- a/FractalPainter/Solved/Step05/App/Fractals/DragonSettingsGenerator.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System;
-
-namespace FractalPainting.Solved.Step05.App.Fractals
-{
- public class DragonSettingsGenerator
- {
- private readonly Random random;
-
- public DragonSettingsGenerator(Random random)
- {
- this.random = random;
- }
-
- public DragonSettings Generate()
- {
- return new DragonSettings
- {
- Angle1 = random.NextDouble() / 2 + 0.5,
- Angle2 = 3 * (random.NextDouble() / 2 + 0.5),
- ShiftX = 1,
- ShiftY = 0,
- Scale = (float)(1/Math.Sqrt(2) + (random.NextDouble() - 0.5)/10)
- };
- }
-
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step05/App/Fractals/IDragonPainterFactory.cs b/FractalPainter/Solved/Step05/App/Fractals/IDragonPainterFactory.cs
deleted file mode 100644
index 6b1f6a01d..000000000
--- a/FractalPainter/Solved/Step05/App/Fractals/IDragonPainterFactory.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace FractalPainting.Solved.Step05.App.Fractals
-{
- public interface IDragonPainterFactory
- {
- DragonPainter Create(DragonSettings settings);
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step05/App/Fractals/KochPainter.cs b/FractalPainter/Solved/Step05/App/Fractals/KochPainter.cs
deleted file mode 100644
index 69b65e003..000000000
--- a/FractalPainter/Solved/Step05/App/Fractals/KochPainter.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-using System;
-using System.Drawing;
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step05.App.Fractals
-{
- public class KochPainter
- {
- private readonly IImageHolder imageHolder;
- private readonly Palette palette;
-
- public KochPainter(IImageHolder imageHolder, Palette palette)
- {
- this.imageHolder = imageHolder;
- this.palette = palette;
- }
-
- public void Paint()
- {
- var imageSize = imageHolder.GetImageSize();
- using (var graphics = imageHolder.StartDrawing())
- using (var backgroundBrush = new SolidBrush(palette.BackgroundColor))
- {
- graphics.FillRectangle(backgroundBrush, 0, 0, imageSize.Width, imageSize.Height);
- DrawSegment(graphics, 0, imageSize.Height * 0.9f, imageSize.Width, imageSize.Height * 0.9f, true);
- }
- imageHolder.UpdateUi();
- }
-
- private void DrawSegment(Graphics graphics, float x0, float y0, float x1, float y1, bool primaryColor)
- {
- var len2 = (x0 - x1)*(x0 - x1) + (y0 - y1)*(y0 - y1);
- if (len2 < 4)
- {
- if (y0 < 0 || y1 < 0) return;
- using (var penBrush = new SolidBrush(primaryColor ? palette.PrimaryColor : palette.SecondaryColor))
- {
- var pen = new Pen(penBrush, 3);
- graphics.DrawLine(pen, x0, y0, x1, y1);
- }
- }
- else
- {
- var vx = (x1 - x0)/3;
- var vy = (y1 - y0)/3;
- DrawSegment(graphics, x0, y0, x0 + vx, y0 + vy, primaryColor);
- var k = (float) Math.Sqrt(3)/2f;
- var px = (x0 + x1)/2 + vy*k;
- var py = (y0 + y1)/2 - vx*k;
- DrawSegment(graphics, x0 + vx, y0 + vy, px, py, !primaryColor);
- DrawSegment(graphics, px, py, x0 + 2*vx, y0 + 2*vy, !primaryColor);
- DrawSegment(graphics, x0 + 2*vx, y0 + 2*vy, x1, y1, primaryColor);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step05/App/MainForm.cs b/FractalPainter/Solved/Step05/App/MainForm.cs
deleted file mode 100644
index 877c005ae..000000000
--- a/FractalPainter/Solved/Step05/App/MainForm.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using System;
-using System.Drawing;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step05.Infrastructure.Injection;
-using FractalPainting.Solved.Step05.Infrastructure.UiActions;
-using Ninject;
-
-namespace FractalPainting.Solved.Step05.App
-{
- public class MainForm : Form
- {
- public MainForm(IUiAction[] actions,
- PictureBoxImageHolder pictureBox,
- Palette palette)
- {
- var imageSettings = CreateSettingsManager().Load().ImageSettings;
- ClientSize = new Size(imageSettings.Width, imageSettings.Height);
-
- var mainMenu = new MenuStrip();
- mainMenu.Items.AddRange(actions.ToMenuItems());
- Controls.Add(mainMenu);
-
- pictureBox.RecreateImage(imageSettings);
- pictureBox.Dock = DockStyle.Fill;
- Controls.Add(pictureBox);
-
- DependencyInjector.Inject(actions, pictureBox);
- DependencyInjector.Inject(actions, CreateSettingsManager().Load());
- DependencyInjector.Inject(actions, CreateSettingsManager().Load());
- DependencyInjector.Inject(actions, palette);
- }
-
- private static SettingsManager CreateSettingsManager()
- {
- var container = new StandardKernel();
- container.Bind().To();
- container.Bind().To();
- return container.Get();
- }
-
- protected override void OnShown(EventArgs e)
- {
- base.OnShown(e);
- Text = "Fractal Painter";
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step05/App/MainForm.resx b/FractalPainter/Solved/Step05/App/MainForm.resx
deleted file mode 100644
index 9d845151a..000000000
--- a/FractalPainter/Solved/Step05/App/MainForm.resx
+++ /dev/null
@@ -1,123 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- 17, 17
-
-
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step05/App/PictureBoxImageHolder.cs b/FractalPainter/Solved/Step05/App/PictureBoxImageHolder.cs
deleted file mode 100644
index ad016afba..000000000
--- a/FractalPainter/Solved/Step05/App/PictureBoxImageHolder.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-using System;
-using System.Drawing;
-using System.Drawing.Imaging;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step05.App
-{
- public class PictureBoxImageHolder : PictureBox, IImageHolder
- {
- public Size GetImageSize()
- {
- FailIfNotInitialized();
- return Image.Size;
- }
-
- public Graphics StartDrawing()
- {
- FailIfNotInitialized();
- return Graphics.FromImage(Image);
- }
-
- private void FailIfNotInitialized()
- {
- if (Image == null)
- throw new InvalidOperationException("Call PictureBoxImageHolder.RecreateImage before other method call!");
- }
-
- public void UpdateUi()
- {
- Refresh();
- Application.DoEvents();
- }
-
- public void RecreateImage(ImageSettings imageSettings)
- {
- Image = new Bitmap(imageSettings.Width, imageSettings.Height, PixelFormat.Format24bppRgb);
- }
-
- public void SaveImage(string fileName)
- {
- FailIfNotInitialized();
- Image.Save(fileName);
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step05/App/Program.cs b/FractalPainter/Solved/Step05/App/Program.cs
deleted file mode 100644
index 25e582559..000000000
--- a/FractalPainter/Solved/Step05/App/Program.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step05.App.Actions;
-using FractalPainting.Solved.Step05.App.Fractals;
-using FractalPainting.Solved.Step05.Infrastructure.UiActions;
-using Ninject;
-using Ninject.Extensions.Factory;
-
-namespace FractalPainting.Solved.Step05.App
-{
- internal static class Program
- {
- ///
- /// The main entry point for the application.
- ///
- [STAThread]
- private static void Main()
- {
- try
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
-
- var container = new StandardKernel();
-
- container.Bind().To();
- container.Bind().To();
- container.Bind().To();
- container.Bind().To();
- container.Bind().To();
-
- container.Bind().ToSelf()
- .InSingletonScope();
- container.Bind()
- .To()
- .InSingletonScope();
-
- container.Bind().ToFactory();
-
- var mainForm = container.Get();
- Application.Run(mainForm);
- }
- catch (Exception e)
- {
- MessageBox.Show(e.Message);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step05/App/SettingsManager.cs b/FractalPainter/Solved/Step05/App/SettingsManager.cs
deleted file mode 100644
index 954131f26..000000000
--- a/FractalPainter/Solved/Step05/App/SettingsManager.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step05.App
-{
- public class SettingsManager
- {
- private readonly IObjectSerializer serializer;
- private readonly IBlobStorage storage;
- private string settingsFilename;
-
- public SettingsManager(IObjectSerializer serializer, IBlobStorage storage)
- {
- this.serializer = serializer;
- this.storage = storage;
- }
-
- public AppSettings Load()
- {
- try
- {
- settingsFilename = "app.settings";
- var data = storage.Get(settingsFilename);
- if (data == null)
- {
- var defaultSettings = CreateDefaultSettings();
- Save(defaultSettings);
- return defaultSettings;
- }
- return serializer.Deserialize(data);
- }
- catch (Exception e)
- {
- MessageBox.Show(e.Message, "Не удалось загрузить настройки");
- return CreateDefaultSettings();
- }
- }
-
- private static AppSettings CreateDefaultSettings()
- {
- return new AppSettings
- {
- ImagesDirectory = ".",
- ImageSettings = new ImageSettings()
- };
- }
-
- public void Save(AppSettings settings)
- {
- storage.Set(settingsFilename, serializer.Serialize(settings));
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step05/Infrastructure/Injection/DependencyInjector.cs b/FractalPainter/Solved/Step05/Infrastructure/Injection/DependencyInjector.cs
deleted file mode 100644
index 148effd25..000000000
--- a/FractalPainter/Solved/Step05/Infrastructure/Injection/DependencyInjector.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System.Collections;
-
-namespace FractalPainting.Solved.Step05.Infrastructure.Injection
-{
- public class DependencyInjector
- {
- public static void Inject(object service, TDependency dependency)
- {
- var need = service as INeed;
- need?.SetDependency(dependency);
- }
-
- public static void Inject(IEnumerable services, TDependency dependency)
- {
- foreach (var service in services)
- Inject(service, dependency);
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step05/Infrastructure/Injection/INeed.cs b/FractalPainter/Solved/Step05/Infrastructure/Injection/INeed.cs
deleted file mode 100644
index 43aa14b8f..000000000
--- a/FractalPainter/Solved/Step05/Infrastructure/Injection/INeed.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace FractalPainting.Solved.Step05.Infrastructure.Injection
-{
- public interface INeed
- {
- void SetDependency(T dependency);
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step05/Infrastructure/UiActions/IUiAction.cs b/FractalPainter/Solved/Step05/Infrastructure/UiActions/IUiAction.cs
deleted file mode 100644
index dd7f27909..000000000
--- a/FractalPainter/Solved/Step05/Infrastructure/UiActions/IUiAction.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace FractalPainting.Solved.Step05.Infrastructure.UiActions
-{
- public interface IUiAction
- {
- string Category { get; }
- string Name { get; }
- string Description { get; }
- void Perform();
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step05/Infrastructure/UiActions/UiActionExtensions.cs b/FractalPainter/Solved/Step05/Infrastructure/UiActions/UiActionExtensions.cs
deleted file mode 100644
index 0624cad3e..000000000
--- a/FractalPainter/Solved/Step05/Infrastructure/UiActions/UiActionExtensions.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using System.Windows.Forms;
-
-namespace FractalPainting.Solved.Step05.Infrastructure.UiActions
-{
- public static class UiActionExtensions
- {
- public static ToolStripItem[] ToMenuItems(this IUiAction[] actions)
- {
- var items = actions.GroupBy(a => a.Category)
- .Select(g => CreateTopLevelMenuItem(g.Key, g.ToList()))
- .Cast()
- .ToArray();
- return items;
- }
-
- private static ToolStripMenuItem CreateTopLevelMenuItem(string name, IList items)
- {
- var menuItems = items.Select(a => a.ToMenuItem()).ToArray();
- return new ToolStripMenuItem(name, null, menuItems);
- }
-
- public static ToolStripItem ToMenuItem(this IUiAction action)
- {
- return
- new ToolStripMenuItem(action.Name, null, (sender, args) => action.Perform())
- {
- ToolTipText = action.Description,
- Tag = action
- };
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step05/Step05.csproj b/FractalPainter/Solved/Step05/Step05.csproj
deleted file mode 100644
index 5fc8b4a65..000000000
--- a/FractalPainter/Solved/Step05/Step05.csproj
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
- WinExe
- netcoreapp3.1
- true
- false
- FractalPainting.Solved.Step05
- FractalPainter
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step06/App/Actions/DragonFractalAction.cs b/FractalPainter/Solved/Step06/App/Actions/DragonFractalAction.cs
deleted file mode 100644
index 889438c69..000000000
--- a/FractalPainter/Solved/Step06/App/Actions/DragonFractalAction.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using System;
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step06.App.Fractals;
-using FractalPainting.Solved.Step06.Infrastructure.UiActions;
-
-namespace FractalPainting.Solved.Step06.App.Actions
-{
- public class DragonFractalAction : IUiAction
- {
- private readonly IDragonPainterFactory dragonPainterFactory;
- private readonly Func createDragonSettingsGenerator;
-
- public DragonFractalAction(IDragonPainterFactory dragonPainterFactory,
- Func createDragonSettingsGenerator)
- {
- this.dragonPainterFactory = dragonPainterFactory;
- this.createDragonSettingsGenerator = createDragonSettingsGenerator;
- }
-
- public string Category => "Фракталы";
- public string Name => "Дракон";
- public string Description => "Дракон Хартера-Хейтуэя";
-
- public void Perform()
- {
- var dragonSettings = CreateRandomSettings();
- // редактируем настройки:
- SettingsForm.For(dragonSettings).ShowDialog();
- // создаём painter с такими настройками
- dragonPainterFactory.Create(dragonSettings).Paint();
- }
-
- private DragonSettings CreateRandomSettings()
- {
- return createDragonSettingsGenerator(new Random()).Generate();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step06/App/Actions/ImageSettingsAction.cs b/FractalPainter/Solved/Step06/App/Actions/ImageSettingsAction.cs
deleted file mode 100644
index 6e28c9e3e..000000000
--- a/FractalPainter/Solved/Step06/App/Actions/ImageSettingsAction.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step06.Infrastructure.Injection;
-using FractalPainting.Solved.Step06.Infrastructure.UiActions;
-
-namespace FractalPainting.Solved.Step06.App.Actions
-{
- public class ImageSettingsAction : IUiAction, INeed, INeed
- {
- private IImageHolder imageHolder;
- private IImageSettingsProvider imageSettingsProvider;
-
- public void SetDependency(IImageHolder dependency)
- {
- imageHolder = dependency;
- }
-
- public void SetDependency(IImageSettingsProvider dependency)
- {
- imageSettingsProvider = dependency;
- }
-
- public string Category => "Настройки";
- public string Name => "Изображение...";
- public string Description => "Размеры изображения";
-
- public void Perform()
- {
- var imageSettings = imageSettingsProvider.ImageSettings;
- SettingsForm.For(imageSettings).ShowDialog();
- imageHolder.RecreateImage(imageSettings);
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step06/App/Actions/KochFractalAction.cs b/FractalPainter/Solved/Step06/App/Actions/KochFractalAction.cs
deleted file mode 100644
index 03bfc0f0d..000000000
--- a/FractalPainter/Solved/Step06/App/Actions/KochFractalAction.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using FractalPainting.Solved.Step06.App.Fractals;
-using FractalPainting.Solved.Step06.Infrastructure.UiActions;
-
-namespace FractalPainting.Solved.Step06.App.Actions
-{
- public class KochFractalAction : IUiAction
- {
- private readonly KochPainter kochPainter;
-
- public KochFractalAction(KochPainter kochPainter)
- {
- this.kochPainter = kochPainter;
- }
-
- public string Category => "Фракталы";
- public string Name => "Кривая Коха";
- public string Description => "Кривая Коха";
-
- public void Perform()
- {
- kochPainter.Paint();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step06/App/Actions/PaletteSettingsAction.cs b/FractalPainter/Solved/Step06/App/Actions/PaletteSettingsAction.cs
deleted file mode 100644
index dd25aa093..000000000
--- a/FractalPainter/Solved/Step06/App/Actions/PaletteSettingsAction.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step06.Infrastructure.Injection;
-using FractalPainting.Solved.Step06.Infrastructure.UiActions;
-
-namespace FractalPainting.Solved.Step06.App.Actions
-{
- public class PaletteSettingsAction : IUiAction, INeed
- {
- private Palette palette;
-
- public void SetDependency(Palette dependency)
- {
- palette = dependency;
- }
-
- public string Category => "Настройки";
- public string Name => "Палитра...";
- public string Description => "Цвета для рисования фракталов";
-
- public void Perform()
- {
- SettingsForm.For(palette).ShowDialog();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step06/App/Actions/SaveImageAction.cs b/FractalPainter/Solved/Step06/App/Actions/SaveImageAction.cs
deleted file mode 100644
index 730d9bd7c..000000000
--- a/FractalPainter/Solved/Step06/App/Actions/SaveImageAction.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using System.IO;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step06.Infrastructure.Injection;
-using FractalPainting.Solved.Step06.Infrastructure.UiActions;
-
-namespace FractalPainting.Solved.Step06.App.Actions
-{
- public class SaveImageAction : IUiAction, INeed, INeed
- {
- private IImageDirectoryProvider imageDirectoryProvider;
- private IImageHolder imageHolder;
-
- public void SetDependency(IImageDirectoryProvider dependency)
- {
- imageDirectoryProvider = dependency;
- }
-
- public void SetDependency(IImageHolder dependency)
- {
- imageHolder = dependency;
- }
-
- public string Category => "Файл";
- public string Name => "Сохранить...";
- public string Description => "Сохранить изображение в файл";
-
- public void Perform()
- {
- var dialog = new SaveFileDialog
- {
- CheckFileExists = false,
- InitialDirectory = Path.GetFullPath(imageDirectoryProvider.ImagesDirectory),
- DefaultExt = "bmp",
- FileName = "image.bmp",
- Filter = "Изображения (*.bmp)|*.bmp"
- };
- var res = dialog.ShowDialog();
- if (res == DialogResult.OK)
- imageHolder.SaveImage(dialog.FileName);
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step06/App/AppSettings.cs b/FractalPainter/Solved/Step06/App/AppSettings.cs
deleted file mode 100644
index 0e21cc558..000000000
--- a/FractalPainter/Solved/Step06/App/AppSettings.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step06.App
-{
- public class AppSettings : IImageDirectoryProvider, IImageSettingsProvider
- {
- public string ImagesDirectory { get; set; }
- public ImageSettings ImageSettings { get; set; }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step06/App/Fractals/DragonPainter.cs b/FractalPainter/Solved/Step06/App/Fractals/DragonPainter.cs
deleted file mode 100644
index 09dee4ca5..000000000
--- a/FractalPainter/Solved/Step06/App/Fractals/DragonPainter.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System;
-using System.Drawing;
-using System.Linq;
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step06.App.Fractals
-{
- public class DragonPainter
- {
- private readonly IImageHolder imageHolder;
- private readonly DragonSettings settings;
- private readonly float size;
- private Size imageSize;
-
- public DragonPainter(IImageHolder imageHolder, DragonSettings settings)
- {
- this.imageHolder = imageHolder;
- this.settings = settings;
- imageSize = imageHolder.GetImageSize();
- size = Math.Min(imageSize.Width, imageSize.Height)/2.1f;
- }
-
- public void Paint()
- {
- using (var graphics = imageHolder.StartDrawing())
- {
- graphics.FillRectangle(Brushes.Black, 0, 0, imageSize.Width, imageSize.Height);
- var r = new Random();
- var cosa = (float) Math.Cos(settings.Angle1);
- var sina = (float) Math.Sin(settings.Angle1);
- var cosb = (float) Math.Cos(settings.Angle2);
- var sinb = (float) Math.Sin(settings.Angle2);
- var shiftX = settings.ShiftX*size*0.8f;
- var shiftY = settings.ShiftY*size*0.8f;
- var scale = settings.Scale;
- var p = new PointF(0, 0);
- foreach (var i in Enumerable.Range(0, settings.IterationsCount))
- {
- graphics.FillRectangle(Brushes.Yellow, imageSize.Width/3f + p.X, imageSize.Height/2f + p.Y, 1, 1);
- if (r.Next(0, 2) == 0)
- p = new PointF(scale*(p.X*cosa - p.Y*sina), scale*(p.X*sina + p.Y*cosa));
- else
- p = new PointF(scale*(p.X*cosb - p.Y*sinb) + shiftX, scale*(p.X*sinb + p.Y*cosb) + shiftY);
- if (i%100 == 0) imageHolder.UpdateUi();
- }
- }
- imageHolder.UpdateUi();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step06/App/Fractals/DragonSettings.cs b/FractalPainter/Solved/Step06/App/Fractals/DragonSettings.cs
deleted file mode 100644
index 2157b7728..000000000
--- a/FractalPainter/Solved/Step06/App/Fractals/DragonSettings.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-
-namespace FractalPainting.Solved.Step06.App.Fractals
-{
- public class DragonSettings
- {
- public double Angle1 { get; set; } = Math.PI / 4;
- public double Angle2 { get; set; } = 3 * Math.PI / 4;
- public float ShiftX { get; set; } = 1;
- public float ShiftY { get; set; } = 0;
- public float Scale { get; set; } = (float)(1 / Math.Sqrt(2));
- public int IterationsCount { get; set; } = 20000;
-
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step06/App/Fractals/DragonSettingsGenerator.cs b/FractalPainter/Solved/Step06/App/Fractals/DragonSettingsGenerator.cs
deleted file mode 100644
index 29d5dcb73..000000000
--- a/FractalPainter/Solved/Step06/App/Fractals/DragonSettingsGenerator.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System;
-
-namespace FractalPainting.Solved.Step06.App.Fractals
-{
- public class DragonSettingsGenerator
- {
- private readonly Random random;
-
- public DragonSettingsGenerator(Random random)
- {
- this.random = random;
- }
-
- public DragonSettings Generate()
- {
- return new DragonSettings
- {
- Angle1 = random.NextDouble() / 2 + 0.5,
- Angle2 = 3 * (random.NextDouble() / 2 + 0.5),
- ShiftX = 1,
- ShiftY = 0,
- Scale = (float)(1/Math.Sqrt(2) + (random.NextDouble() - 0.5)/10)
- };
- }
-
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step06/App/Fractals/IDragonPainterFactory.cs b/FractalPainter/Solved/Step06/App/Fractals/IDragonPainterFactory.cs
deleted file mode 100644
index f7cf84451..000000000
--- a/FractalPainter/Solved/Step06/App/Fractals/IDragonPainterFactory.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace FractalPainting.Solved.Step06.App.Fractals
-{
- public interface IDragonPainterFactory
- {
- DragonPainter Create(DragonSettings settings);
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step06/App/Fractals/KochPainter.cs b/FractalPainter/Solved/Step06/App/Fractals/KochPainter.cs
deleted file mode 100644
index a84c57b24..000000000
--- a/FractalPainter/Solved/Step06/App/Fractals/KochPainter.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-using System;
-using System.Drawing;
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step06.App.Fractals
-{
- public class KochPainter
- {
- private readonly IImageHolder imageHolder;
- private readonly Palette palette;
-
- public KochPainter(IImageHolder imageHolder, Palette palette)
- {
- this.imageHolder = imageHolder;
- this.palette = palette;
- }
-
- public void Paint()
- {
- var imageSize = imageHolder.GetImageSize();
- using (var graphics = imageHolder.StartDrawing())
- using (var backgroundBrush = new SolidBrush(palette.BackgroundColor))
- {
- graphics.FillRectangle(backgroundBrush, 0, 0, imageSize.Width, imageSize.Height);
- DrawSegment(graphics, 0, imageSize.Height * 0.9f, imageSize.Width, imageSize.Height * 0.9f, true);
- }
- imageHolder.UpdateUi();
- }
-
- private void DrawSegment(Graphics graphics, float x0, float y0, float x1, float y1, bool primaryColor)
- {
- var len2 = (x0 - x1)*(x0 - x1) + (y0 - y1)*(y0 - y1);
- if (len2 < 4)
- {
- if (y0 < 0 || y1 < 0) return;
- using (var penBrush = new SolidBrush(primaryColor ? palette.PrimaryColor : palette.SecondaryColor))
- {
- var pen = new Pen(penBrush, 3);
- graphics.DrawLine(pen, x0, y0, x1, y1);
- }
- }
- else
- {
- var vx = (x1 - x0)/3;
- var vy = (y1 - y0)/3;
- DrawSegment(graphics, x0, y0, x0 + vx, y0 + vy, primaryColor);
- var k = (float) Math.Sqrt(3)/2f;
- var px = (x0 + x1)/2 + vy*k;
- var py = (y0 + y1)/2 - vx*k;
- DrawSegment(graphics, x0 + vx, y0 + vy, px, py, !primaryColor);
- DrawSegment(graphics, px, py, x0 + 2*vx, y0 + 2*vy, !primaryColor);
- DrawSegment(graphics, x0 + 2*vx, y0 + 2*vy, x1, y1, primaryColor);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step06/App/MainForm.cs b/FractalPainter/Solved/Step06/App/MainForm.cs
deleted file mode 100644
index bfe737ad1..000000000
--- a/FractalPainter/Solved/Step06/App/MainForm.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using System;
-using System.Drawing;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step06.Infrastructure.Injection;
-using FractalPainting.Solved.Step06.Infrastructure.UiActions;
-using Ninject;
-
-namespace FractalPainting.Solved.Step06.App
-{
- public class MainForm : Form
- {
- public MainForm(IUiAction[] actions,
- PictureBoxImageHolder pictureBox,
- Palette palette)
- {
- var imageSettings = CreateSettingsManager().Load().ImageSettings;
- ClientSize = new Size(imageSettings.Width, imageSettings.Height);
-
- var mainMenu = new MenuStrip();
- mainMenu.Items.AddRange(actions.ToMenuItems());
- Controls.Add(mainMenu);
-
- pictureBox.RecreateImage(imageSettings);
- pictureBox.Dock = DockStyle.Fill;
- Controls.Add(pictureBox);
-
- DependencyInjector.Inject(actions, pictureBox);
- DependencyInjector.Inject(actions, CreateSettingsManager().Load());
- DependencyInjector.Inject(actions, CreateSettingsManager().Load());
- DependencyInjector.Inject(actions, palette);
- }
-
- private static SettingsManager CreateSettingsManager()
- {
- var container = new StandardKernel();
- container.Bind().To();
- container.Bind().To();
- return container.Get();
- }
-
- protected override void OnShown(EventArgs e)
- {
- base.OnShown(e);
- Text = "Fractal Painter";
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step06/App/MainForm.resx b/FractalPainter/Solved/Step06/App/MainForm.resx
deleted file mode 100644
index 9d845151a..000000000
--- a/FractalPainter/Solved/Step06/App/MainForm.resx
+++ /dev/null
@@ -1,123 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- 17, 17
-
-
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step06/App/PictureBoxImageHolder.cs b/FractalPainter/Solved/Step06/App/PictureBoxImageHolder.cs
deleted file mode 100644
index e7aebdf66..000000000
--- a/FractalPainter/Solved/Step06/App/PictureBoxImageHolder.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-using System;
-using System.Drawing;
-using System.Drawing.Imaging;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step06.App
-{
- public class PictureBoxImageHolder : PictureBox, IImageHolder
- {
- public Size GetImageSize()
- {
- FailIfNotInitialized();
- return Image.Size;
- }
-
- public Graphics StartDrawing()
- {
- FailIfNotInitialized();
- return Graphics.FromImage(Image);
- }
-
- private void FailIfNotInitialized()
- {
- if (Image == null)
- throw new InvalidOperationException("Call PictureBoxImageHolder.RecreateImage before other method call!");
- }
-
- public void UpdateUi()
- {
- Refresh();
- Application.DoEvents();
- }
-
- public void RecreateImage(ImageSettings imageSettings)
- {
- Image = new Bitmap(imageSettings.Width, imageSettings.Height, PixelFormat.Format24bppRgb);
- }
-
- public void SaveImage(string fileName)
- {
- FailIfNotInitialized();
- Image.Save(fileName);
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step06/App/Program.cs b/FractalPainter/Solved/Step06/App/Program.cs
deleted file mode 100644
index 8a1a7b362..000000000
--- a/FractalPainter/Solved/Step06/App/Program.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step06.App.Actions;
-using FractalPainting.Solved.Step06.App.Fractals;
-using FractalPainting.Solved.Step06.Infrastructure.UiActions;
-using Ninject;
-using Ninject.Extensions.Factory;
-
-namespace FractalPainting.Solved.Step06.App
-{
- internal static class Program
- {
- ///
- /// The main entry point for the application.
- ///
- [STAThread]
- private static void Main()
- {
- try
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
-
- var container = new StandardKernel();
-
- container.Bind().To();
- container.Bind().To();
- container.Bind().To();
- container.Bind().To();
- container.Bind().To();
-
- container.Bind().ToSelf()
- .InSingletonScope();
- container.Bind()
- .To()
- .InSingletonScope();
-
- container.Bind().ToFactory();
-
- var mainForm = container.Get();
- Application.Run(mainForm);
- }
- catch (Exception e)
- {
- MessageBox.Show(e.Message);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step06/App/SettingsManager.cs b/FractalPainter/Solved/Step06/App/SettingsManager.cs
deleted file mode 100644
index 874e29fae..000000000
--- a/FractalPainter/Solved/Step06/App/SettingsManager.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step06.App
-{
- public class SettingsManager
- {
- private readonly IObjectSerializer serializer;
- private readonly IBlobStorage storage;
- private string settingsFilename;
-
- public SettingsManager(IObjectSerializer serializer, IBlobStorage storage)
- {
- this.serializer = serializer;
- this.storage = storage;
- }
-
- public AppSettings Load()
- {
- try
- {
- settingsFilename = "app.settings";
- var data = storage.Get(settingsFilename);
- if (data == null)
- {
- var defaultSettings = CreateDefaultSettings();
- Save(defaultSettings);
- return defaultSettings;
- }
- return serializer.Deserialize(data);
- }
- catch (Exception e)
- {
- MessageBox.Show(e.Message, "Не удалось загрузить настройки");
- return CreateDefaultSettings();
- }
- }
-
- private static AppSettings CreateDefaultSettings()
- {
- return new AppSettings
- {
- ImagesDirectory = ".",
- ImageSettings = new ImageSettings()
- };
- }
-
- public void Save(AppSettings settings)
- {
- storage.Set(settingsFilename, serializer.Serialize(settings));
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step06/Infrastructure/Injection/DependencyInjector.cs b/FractalPainter/Solved/Step06/Infrastructure/Injection/DependencyInjector.cs
deleted file mode 100644
index c8ddb2147..000000000
--- a/FractalPainter/Solved/Step06/Infrastructure/Injection/DependencyInjector.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System.Collections;
-
-namespace FractalPainting.Solved.Step06.Infrastructure.Injection
-{
- public class DependencyInjector
- {
- public static void Inject(object service, TDependency dependency)
- {
- var need = service as INeed;
- need?.SetDependency(dependency);
- }
-
- public static void Inject(IEnumerable services, TDependency dependency)
- {
- foreach (var service in services)
- Inject(service, dependency);
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step06/Infrastructure/Injection/INeed.cs b/FractalPainter/Solved/Step06/Infrastructure/Injection/INeed.cs
deleted file mode 100644
index 86fd6ca5f..000000000
--- a/FractalPainter/Solved/Step06/Infrastructure/Injection/INeed.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace FractalPainting.Solved.Step06.Infrastructure.Injection
-{
- public interface INeed
- {
- void SetDependency(T dependency);
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step06/Infrastructure/UiActions/IUiAction.cs b/FractalPainter/Solved/Step06/Infrastructure/UiActions/IUiAction.cs
deleted file mode 100644
index 623186a89..000000000
--- a/FractalPainter/Solved/Step06/Infrastructure/UiActions/IUiAction.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace FractalPainting.Solved.Step06.Infrastructure.UiActions
-{
- public interface IUiAction
- {
- string Category { get; }
- string Name { get; }
- string Description { get; }
- void Perform();
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step06/Infrastructure/UiActions/UiActionExtensions.cs b/FractalPainter/Solved/Step06/Infrastructure/UiActions/UiActionExtensions.cs
deleted file mode 100644
index 4b281fb10..000000000
--- a/FractalPainter/Solved/Step06/Infrastructure/UiActions/UiActionExtensions.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using System.Windows.Forms;
-
-namespace FractalPainting.Solved.Step06.Infrastructure.UiActions
-{
- public static class UiActionExtensions
- {
- public static ToolStripItem[] ToMenuItems(this IUiAction[] actions)
- {
- var items = actions.GroupBy(a => a.Category)
- .Select(g => CreateTopLevelMenuItem(g.Key, g.ToList()))
- .Cast()
- .ToArray();
- return items;
- }
-
- private static ToolStripMenuItem CreateTopLevelMenuItem(string name, IList items)
- {
- var menuItems = items.Select(a => a.ToMenuItem()).ToArray();
- return new ToolStripMenuItem(name, null, menuItems);
- }
-
- public static ToolStripItem ToMenuItem(this IUiAction action)
- {
- return
- new ToolStripMenuItem(action.Name, null, (sender, args) => action.Perform())
- {
- ToolTipText = action.Description,
- Tag = action
- };
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step06/Step06.csproj b/FractalPainter/Solved/Step06/Step06.csproj
deleted file mode 100644
index 719caddb0..000000000
--- a/FractalPainter/Solved/Step06/Step06.csproj
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
- WinExe
- netcoreapp3.1
- true
- false
- FractalPainting.Solved.Step06
- FractalPainter
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step07/App/Actions/DragonFractalAction.cs b/FractalPainter/Solved/Step07/App/Actions/DragonFractalAction.cs
deleted file mode 100644
index ad4b07249..000000000
--- a/FractalPainter/Solved/Step07/App/Actions/DragonFractalAction.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using System;
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step07.App.Fractals;
-using FractalPainting.Solved.Step07.Infrastructure.UiActions;
-
-namespace FractalPainting.Solved.Step07.App.Actions
-{
- public class DragonFractalAction : IUiAction
- {
- private readonly IDragonPainterFactory dragonPainterFactory;
- private readonly Func createDragonSettingsGenerator;
-
- public DragonFractalAction(IDragonPainterFactory dragonPainterFactory,
- Func createDragonSettingsGenerator)
- {
- this.dragonPainterFactory = dragonPainterFactory;
- this.createDragonSettingsGenerator = createDragonSettingsGenerator;
- }
-
- public string Category => "Фракталы";
- public string Name => "Дракон";
- public string Description => "Дракон Хартера-Хейтуэя";
-
- public void Perform()
- {
- var dragonSettings = CreateRandomSettings();
- // редактируем настройки:
- SettingsForm.For(dragonSettings).ShowDialog();
- // создаём painter с такими настройками
- dragonPainterFactory.Create(dragonSettings).Paint();
- }
-
- private DragonSettings CreateRandomSettings()
- {
- return createDragonSettingsGenerator(new Random()).Generate();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step07/App/Actions/ImageSettingsAction.cs b/FractalPainter/Solved/Step07/App/Actions/ImageSettingsAction.cs
deleted file mode 100644
index e249a2e7c..000000000
--- a/FractalPainter/Solved/Step07/App/Actions/ImageSettingsAction.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step07.Infrastructure.Injection;
-using FractalPainting.Solved.Step07.Infrastructure.UiActions;
-
-namespace FractalPainting.Solved.Step07.App.Actions
-{
- public class ImageSettingsAction : IUiAction, INeed, INeed
- {
- private IImageHolder imageHolder;
- private IImageSettingsProvider imageSettingsProvider;
-
- public void SetDependency(IImageHolder dependency)
- {
- imageHolder = dependency;
- }
-
- public void SetDependency(IImageSettingsProvider dependency)
- {
- imageSettingsProvider = dependency;
- }
-
- public string Category => "Настройки";
- public string Name => "Изображение...";
- public string Description => "Размеры изображения";
-
- public void Perform()
- {
- var imageSettings = imageSettingsProvider.ImageSettings;
- SettingsForm.For(imageSettings).ShowDialog();
- imageHolder.RecreateImage(imageSettings);
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step07/App/Actions/KochFractalAction.cs b/FractalPainter/Solved/Step07/App/Actions/KochFractalAction.cs
deleted file mode 100644
index d9f114af4..000000000
--- a/FractalPainter/Solved/Step07/App/Actions/KochFractalAction.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using FractalPainting.Solved.Step07.App.Fractals;
-using FractalPainting.Solved.Step07.Infrastructure.UiActions;
-
-namespace FractalPainting.Solved.Step07.App.Actions
-{
- public class KochFractalAction : IUiAction
- {
- private readonly KochPainter kochPainter;
-
- public KochFractalAction(KochPainter kochPainter)
- {
- this.kochPainter = kochPainter;
- }
-
- public string Category => "Фракталы";
- public string Name => "Кривая Коха";
- public string Description => "Кривая Коха";
-
- public void Perform()
- {
- kochPainter.Paint();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step07/App/Actions/PaletteSettingsAction.cs b/FractalPainter/Solved/Step07/App/Actions/PaletteSettingsAction.cs
deleted file mode 100644
index b56a51b71..000000000
--- a/FractalPainter/Solved/Step07/App/Actions/PaletteSettingsAction.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step07.Infrastructure.Injection;
-using FractalPainting.Solved.Step07.Infrastructure.UiActions;
-
-namespace FractalPainting.Solved.Step07.App.Actions
-{
- public class PaletteSettingsAction : IUiAction, INeed
- {
- private Palette palette;
-
- public void SetDependency(Palette dependency)
- {
- palette = dependency;
- }
-
- public string Category => "Настройки";
- public string Name => "Палитра...";
- public string Description => "Цвета для рисования фракталов";
-
- public void Perform()
- {
- SettingsForm.For(palette).ShowDialog();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step07/App/Actions/SaveImageAction.cs b/FractalPainter/Solved/Step07/App/Actions/SaveImageAction.cs
deleted file mode 100644
index b0ea5ee3c..000000000
--- a/FractalPainter/Solved/Step07/App/Actions/SaveImageAction.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using System.IO;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step07.Infrastructure.Injection;
-using FractalPainting.Solved.Step07.Infrastructure.UiActions;
-
-namespace FractalPainting.Solved.Step07.App.Actions
-{
- public class SaveImageAction : IUiAction, INeed, INeed
- {
- private IImageDirectoryProvider imageDirectoryProvider;
- private IImageHolder imageHolder;
-
- public void SetDependency(IImageDirectoryProvider dependency)
- {
- imageDirectoryProvider = dependency;
- }
-
- public void SetDependency(IImageHolder dependency)
- {
- imageHolder = dependency;
- }
-
- public string Category => "Файл";
- public string Name => "Сохранить...";
- public string Description => "Сохранить изображение в файл";
-
- public void Perform()
- {
- var dialog = new SaveFileDialog
- {
- CheckFileExists = false,
- InitialDirectory = Path.GetFullPath(imageDirectoryProvider.ImagesDirectory),
- DefaultExt = "bmp",
- FileName = "image.bmp",
- Filter = "Изображения (*.bmp)|*.bmp"
- };
- var res = dialog.ShowDialog();
- if (res == DialogResult.OK)
- imageHolder.SaveImage(dialog.FileName);
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step07/App/AppSettings.cs b/FractalPainter/Solved/Step07/App/AppSettings.cs
deleted file mode 100644
index 26761818e..000000000
--- a/FractalPainter/Solved/Step07/App/AppSettings.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step07.App
-{
- public class AppSettings : IImageDirectoryProvider, IImageSettingsProvider
- {
- public string ImagesDirectory { get; set; }
- public ImageSettings ImageSettings { get; set; }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step07/App/Fractals/DragonPainter.cs b/FractalPainter/Solved/Step07/App/Fractals/DragonPainter.cs
deleted file mode 100644
index ff5dd293d..000000000
--- a/FractalPainter/Solved/Step07/App/Fractals/DragonPainter.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System;
-using System.Drawing;
-using System.Linq;
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step07.App.Fractals
-{
- public class DragonPainter
- {
- private readonly IImageHolder imageHolder;
- private readonly DragonSettings settings;
- private readonly Palette palette;
- private readonly float size;
- private Size imageSize;
-
- public DragonPainter(IImageHolder imageHolder,
- DragonSettings settings, Palette palette)
- {
- this.imageHolder = imageHolder;
- this.settings = settings;
- this.palette = palette;
- imageSize = imageHolder.GetImageSize();
- size = Math.Min(imageSize.Width, imageSize.Height)/2.1f;
- }
-
- public void Paint()
- {
- using (var graphics = imageHolder.StartDrawing())
- {
- graphics.FillRectangle(new SolidBrush(palette.BackgroundColor), 0, 0, imageSize.Width, imageSize.Height);
- var r = new Random();
- var cosa = (float) Math.Cos(settings.Angle1);
- var sina = (float) Math.Sin(settings.Angle1);
- var cosb = (float) Math.Cos(settings.Angle2);
- var sinb = (float) Math.Sin(settings.Angle2);
- var shiftX = settings.ShiftX*size*0.8f;
- var shiftY = settings.ShiftY*size*0.8f;
- var scale = settings.Scale;
- var p = new PointF(0, 0);
- var pointBrush = new SolidBrush(palette.PrimaryColor);
- foreach (var i in Enumerable.Range(0, settings.IterationsCount))
- {
- graphics.FillRectangle(pointBrush, imageSize.Width/3f + p.X, imageSize.Height/2f + p.Y, 1, 1);
- if (r.Next(0, 2) == 0)
- p = new PointF(scale*(p.X*cosa - p.Y*sina), scale*(p.X*sina + p.Y*cosa));
- else
- p = new PointF(scale*(p.X*cosb - p.Y*sinb) + shiftX, scale*(p.X*sinb + p.Y*cosb) + shiftY);
- if (i%100 == 0) imageHolder.UpdateUi();
- }
- }
- imageHolder.UpdateUi();
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step07/App/Fractals/DragonSettings.cs b/FractalPainter/Solved/Step07/App/Fractals/DragonSettings.cs
deleted file mode 100644
index 9a3f21fc4..000000000
--- a/FractalPainter/Solved/Step07/App/Fractals/DragonSettings.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-
-namespace FractalPainting.Solved.Step07.App.Fractals
-{
- public class DragonSettings
- {
- public double Angle1 { get; set; } = Math.PI / 4;
- public double Angle2 { get; set; } = 3 * Math.PI / 4;
- public float ShiftX { get; set; } = 1;
- public float ShiftY { get; set; } = 0;
- public float Scale { get; set; } = (float)(1 / Math.Sqrt(2));
- public int IterationsCount { get; set; } = 20000;
-
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step07/App/Fractals/DragonSettingsGenerator.cs b/FractalPainter/Solved/Step07/App/Fractals/DragonSettingsGenerator.cs
deleted file mode 100644
index bb30c5e5f..000000000
--- a/FractalPainter/Solved/Step07/App/Fractals/DragonSettingsGenerator.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System;
-
-namespace FractalPainting.Solved.Step07.App.Fractals
-{
- public class DragonSettingsGenerator
- {
- private readonly Random random;
-
- public DragonSettingsGenerator(Random random)
- {
- this.random = random;
- }
-
- public DragonSettings Generate()
- {
- return new DragonSettings
- {
- Angle1 = random.NextDouble() / 2 + 0.5,
- Angle2 = 3 * (random.NextDouble() / 2 + 0.5),
- ShiftX = 1,
- ShiftY = 0,
- Scale = (float)(1/Math.Sqrt(2) + (random.NextDouble() - 0.5)/10)
- };
- }
-
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step07/App/Fractals/IDragonPainterFactory.cs b/FractalPainter/Solved/Step07/App/Fractals/IDragonPainterFactory.cs
deleted file mode 100644
index 8f8702c9a..000000000
--- a/FractalPainter/Solved/Step07/App/Fractals/IDragonPainterFactory.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace FractalPainting.Solved.Step07.App.Fractals
-{
- public interface IDragonPainterFactory
- {
- DragonPainter Create(DragonSettings settings);
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step07/App/Fractals/KochPainter.cs b/FractalPainter/Solved/Step07/App/Fractals/KochPainter.cs
deleted file mode 100644
index ab9247fe7..000000000
--- a/FractalPainter/Solved/Step07/App/Fractals/KochPainter.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-using System;
-using System.Drawing;
-using FractalPainting.Infrastructure.Common;
-
-namespace FractalPainting.Solved.Step07.App.Fractals
-{
- public class KochPainter
- {
- private readonly IImageHolder imageHolder;
- private readonly Palette palette;
-
- public KochPainter(IImageHolder imageHolder, Palette palette)
- {
- this.imageHolder = imageHolder;
- this.palette = palette;
- }
-
- public void Paint()
- {
- var imageSize = imageHolder.GetImageSize();
- using (var graphics = imageHolder.StartDrawing())
- using (var backgroundBrush = new SolidBrush(palette.BackgroundColor))
- {
- graphics.FillRectangle(backgroundBrush, 0, 0, imageSize.Width, imageSize.Height);
- DrawSegment(graphics, 0, imageSize.Height * 0.9f, imageSize.Width, imageSize.Height * 0.9f, true);
- }
- imageHolder.UpdateUi();
- }
-
- private void DrawSegment(Graphics graphics, float x0, float y0, float x1, float y1, bool primaryColor)
- {
- var len2 = (x0 - x1)*(x0 - x1) + (y0 - y1)*(y0 - y1);
- if (len2 < 4)
- {
- if (y0 < 0 || y1 < 0) return;
- using (var penBrush = new SolidBrush(primaryColor ? palette.PrimaryColor : palette.SecondaryColor))
- {
- var pen = new Pen(penBrush, 3);
- graphics.DrawLine(pen, x0, y0, x1, y1);
- }
- }
- else
- {
- var vx = (x1 - x0)/3;
- var vy = (y1 - y0)/3;
- DrawSegment(graphics, x0, y0, x0 + vx, y0 + vy, primaryColor);
- var k = (float) Math.Sqrt(3)/2f;
- var px = (x0 + x1)/2 + vy*k;
- var py = (y0 + y1)/2 - vx*k;
- DrawSegment(graphics, x0 + vx, y0 + vy, px, py, !primaryColor);
- DrawSegment(graphics, px, py, x0 + 2*vx, y0 + 2*vy, !primaryColor);
- DrawSegment(graphics, x0 + 2*vx, y0 + 2*vy, x1, y1, primaryColor);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step07/App/MainForm.cs b/FractalPainter/Solved/Step07/App/MainForm.cs
deleted file mode 100644
index a00b981d1..000000000
--- a/FractalPainter/Solved/Step07/App/MainForm.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using System;
-using System.Drawing;
-using System.Windows.Forms;
-using FractalPainting.Infrastructure.Common;
-using FractalPainting.Solved.Step07.Infrastructure.Injection;
-using FractalPainting.Solved.Step07.Infrastructure.UiActions;
-using Ninject;
-
-namespace FractalPainting.Solved.Step07.App
-{
- public class MainForm : Form
- {
- public MainForm(IUiAction[] actions,
- PictureBoxImageHolder pictureBox,
- Palette palette)
- {
- var imageSettings = CreateSettingsManager().Load().ImageSettings;
- ClientSize = new Size(imageSettings.Width, imageSettings.Height);
-
- var mainMenu = new MenuStrip();
- mainMenu.Items.AddRange(actions.ToMenuItems());
- Controls.Add(mainMenu);
-
- pictureBox.RecreateImage(imageSettings);
- pictureBox.Dock = DockStyle.Fill;
- Controls.Add(pictureBox);
-
- DependencyInjector.Inject(actions, pictureBox);
- DependencyInjector.Inject(actions, CreateSettingsManager().Load());
- DependencyInjector.Inject(actions, CreateSettingsManager().Load());
- DependencyInjector.Inject(actions, palette);
- }
-
- private static SettingsManager CreateSettingsManager()
- {
- var container = new StandardKernel();
- container.Bind().To();
- container.Bind().To();
- return container.Get();
- }
-
- protected override void OnShown(EventArgs e)
- {
- base.OnShown(e);
- Text = "Fractal Painter";
- }
- }
-}
\ No newline at end of file
diff --git a/FractalPainter/Solved/Step07/App/MainForm.resx b/FractalPainter/Solved/Step07/App/MainForm.resx
deleted file mode 100644
index 9d845151a..000000000
--- a/FractalPainter/Solved/Step07/App/MainForm.resx
+++ /dev/null
@@ -1,123 +0,0 @@
-
-
-
-
-
-
-
-
-
-