public FractalTemplate(Fractal Fractal,FractalColorMode FractalColorMode,string Name) { _name = Name; _fractal = Fractal.GetClone(); _fcm = FractalColorMode.GetClone(); _date_of_creating = DateTime.Now; }
/*__________________________________________________________Конструкторы_класса_________________________________________________________________*/ #region Constructors public FractalDataHandler(Control Owner,Fractal Fractal,FractalPictureBox FPB,FractalColorMode FCM,Size Size,FractalAssociationParametrs FAP=null) { if (Owner==null||Fractal == null || FPB == null || FCM == null) throw new ArgumentNullException("Нельзя передавать пустые значения!"); if (Size.Width < 1 || Size.Height < 1) throw new ArgumentException("Ширина и Высота не могут быть меньше единицы!"); _fractal = Fractal; _fpb = FPB; _fcm = FCM; _width = Size.Width; _height = Size.Height; _fap = FAP; _owner=Owner; Connect(); }
/*__________________________________________________________Общедостуные_методы_________________________________________________________________*/ #region Public methods public void ConnectProgressProcessTo(Fractal._f_progress_changed_delegate ProgressChangedHandler) { _fractal.ProgressChanged += ProgressChangedHandler; }
private void FractalCreatingFinishedHandler(Fractal f,FractalAssociationParametrs fap) { ThreadPool.QueueUserWorkItem((Parallel) => { if (_fap != null) if ((ulong)_fap.Width * (ulong)_fap.Height * 4UL > int.MaxValue) { MessageBox.Show("Размер данного фрактала слишком велик, чтобы быть преобразованным в изображение!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } _fap = fap; try { if (FractalShowing != null) _owner.Invoke(FractalShowing,this); Showing = true; Bitmap bmp = _fcm.GetDrawnBitmap(fap); if(_isactive)_owner.Invoke(SetNewBitmap, bmp, _fpb); Showing = false; if (FractalShowed != null)_owner.Invoke(FractalShowed,this); } catch { Showing = false; MessageBox.Show("При преобразовании фрактала в изображение произошла ошибка!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); if (FractalRenderingFailed != null) _owner.Invoke(FractalRenderingFailed,this); //if ((ulong)_fap.Width * (ulong)_fap.Height * 4UL > int.MaxValue) MessageBox.Show("Размер данного фрактала слишком велик, чтобы быть преобразованным в изображение!","Ошибка",MessageBoxButtons.OK,MessageBoxIcon.Error); } Showing = false; GC.Collect(); }); }
private void Create_in_other_window(Fractal Fractal, int Width, int Height, int HorizontalStart, int VerticalStart, int SelectedWidth, int SelectedHeight, FractalDataHandlerControler Controler) { IsolatedFractalWindowsCreator OtherWindow = new IsolatedFractalWindowsCreator(Fractal,_fcm); OtherWindow.FractalToken += (fractal, fap) => { Disconnect(); _fractal = fractal; Connect(); _fap = fap; _width = fap.Width; _height = fap.Height; Controler.DeactivateHandlers(); Show(); }; OtherWindow.StartProcess(Width, Height,HorizontalStart,VerticalStart,SelectedWidth,SelectedHeight,UseSafeZoom); }
public void SetNewFractal(Fractal Fractal,FractalColorMode FractalColorMode) { if (Fractal == null || FractalColorMode == null) throw new ArgumentNullException(); if(!FractalColorMode.IsCompatible(Fractal.GetClone().CreateFractal(8,8)))throw new ArgumentException(); Disconnect(); _fractal = Fractal.GetClone(); Connect(); _fcm = FractalColorMode.GetClone(); if (SetNewFractalEvent != null) SetNewFractalEvent(this); }
public static void ClearProgressChangedEvents(Fractal Fractal) { Fractal.ProgressChanged = null; }
public static void CopyTo(Fractal Source,Fractal Destinator) { Destinator.f_iterations_count = Source.f_iterations_count; Destinator.f_max_count_of_saved_states = Source.f_max_count_of_saved_states; Destinator.f_max_percent = Source.f_max_percent; Destinator.f_number_of_using_threads_for_parallel = Source.f_number_of_using_threads_for_parallel; }
public static void ClearParallelFractalCreatingFinishedEvents(Fractal Fractal) { Fractal.ParallelFractalCreatingFinished = null; }
private void _finish_creating(Fractal f,FractalAssociationParametrs fap) { _fractal.f_parallel_canceled -= _end_creating; _fractal.ParallelFractalCreatingFinished -= _finish_creating; }
public void finish(Fractal fr,FractalAssociationParametrs fap) { _fractal.f_parallel_canceled -= _cancel; _fractal.ParallelFractalCreatingFinished -= finish; }
public IsolatedFractalWindowsCreator(Fractal fractal,FractalColorMode fcm) { InitializeComponent(); _fractal = fractal; _fcm = fcm; }
public IsolatedFractalWindowsCreator(Fractal fractal) { InitializeComponent(); _fractal=fractal; }