internal static bool[,] ShowModal(RenderManagerMainField renderManager, ImageSource imageSourceForCheck, bool[,] fieldDesciption, string title = "Field redactor")
        {
            if (fieldDesciption.Length > 40000)
            {
                MessageBox.Show(LanguageHandler.GetInstance().FieldRedactorSizeWarning);
                return(fieldDesciption);
            }
            RenderManagerCheckAtField renderManagerCheckAtField = new RenderManagerCheckAtField(renderManager, imageSourceForCheck, fieldDesciption);
            var wd = new WindowCheckAtField(renderManagerCheckAtField);

            wd.Title = title;
            wd.StartRenderField();
            wd.ShowDialog();
            wd.StopRenderField();
            bool[,] res;
            if (wd.applyed)
            {
                res = renderManagerCheckAtField.GetFieldDescription();
            }
            else
            {
                res = fieldDesciption;
            }
            return(res);
        }
 public UniverseOutputManager(Universe universe, IUniverseOutputUIElement universeOutputUIElement, double pixelsWidth, double pixelsHeight)
 {
     this.universe = universe;
     this.universeOutputUIElement = universeOutputUIElement;
     renderManagerMainField       = new RenderManagerMainField(UniverseProperty.Width, UniverseProperty.Height, pixelsWidth, pixelsHeight);
     renderManagerInfoText        = new RenderManagerInfoText();
     universeOutputUIElement.ResolutionToReset      = new Size(pixelsWidth, pixelsHeight);
     universeOutputUIElement.WorkDelay              = PauseBetweenRender;
     universeOutputUIElement.CountOfCellsToGenerate = 10;
     StartWork();
     InitializeEvents();
 }
 void ResetResolution(double pixelsWidth, double pixelsHeight)
 {
     if (pixelsWidth < 100 || pixelsWidth > 2000 || pixelsHeight < 100 || pixelsHeight > 2000)
     {
         MessageBox.Show(LanguageHandler.GetInstance().ResolutionWarningMessage);
         return;
     }
     InvokeByPause(() =>
     {
         renderManagerMainField = new RenderManagerMainField(UniverseProperty.Width, UniverseProperty.Height, pixelsWidth, pixelsHeight);
     });
 }
 public void Dispose()
 {
     if (!IsDisposed())
     {
         universeOutputUIElement.ImageUniverseField.MouseDown -= mouseDownOnFieldImage;
         StopWork();
         universe = null;
         renderManagerMainField  = null;
         renderManagerInfoText   = null;
         universeOutputUIElement = null;
         disposed = true;
     }
 }
 public RenderManagerCheckAtField(RenderManagerMainField renderManager, ImageSource imageSourceForCheck, bool[,] fieldDesciption)
 {
     width  = fieldDesciption.GetLength(0);
     height = fieldDesciption.GetLength(1);
     fieldDesciptionPrev = new bool[width, height];
     for (int i = 0; i < width; i++)
     {
         for (int j = 0; j < height; j++)
         {
             fieldDesciptionPrev[i, j] = false;
         }
     }
     this.fieldDesciption     = fieldDesciption.Clone() as bool[, ];
     this.imageSourceForCheck = imageSourceForCheck;
     imageSourceForCheck.Freeze();
     this.renderManager = renderManager;
     prevRenderedField  = renderManager.RenderEmptyField();
     prevRenderedField.Freeze();
 }
        private void button_Click(object sender, RoutedEventArgs e)
        {
            int    w = 200, h = 120;
            double wPix = 1000, hPix = 1000;

            image.StretchDirection  = StretchDirection.Both;
            image1.StretchDirection = StretchDirection.Both;
            MouseButtonEventHandler mouseDownOnImage = (s, ev) =>
            {
                if (un != null)
                {
                    //double modificator =
                    Point          pos     = ev.GetPosition(s as Image);
                    PointInt       posCube = rm.GetCubePosition(pos.X, pos.Y, image.ActualWidth, image.ActualHeight);
                    UniverseObject uo      = un.GetMatrixElement(posCube.X, posCube.Y);
                    if (uo is Cell)
                    {
                        WindowImage.ShowModal(
                            ritm.DrawCellInfo(uo as Cell, 400, 20, Brushes.Black),
                            LanguageHandler.GetInstance().CellInfoWindowTitle
                            );
                    }
                }
            };

            image.MouseDown += mouseDownOnImage;
            thr              = new Thread(() =>
            {
                Thread.CurrentThread.Priority = ThreadPriority.Highest;

                un = new Universe(w, h);
                un.GenerateCells(5);
                rm   = new RenderManagerMainField(w, h, wPix, hPix);
                ritm = new RenderManagerInfoText();
                while (thr == Thread.CurrentThread)
                {
                    un.DoUniverseTick();
                    ImageSource img = rm.RenderField(un.GetAllDescriptors());
                    img.Freeze();
                    ImageSource info = ritm.DrawUniverseInfo(un, 300, 20, Brushes.Black);
                    info.Freeze();
                    try
                    {
                        image.Dispatcher.Invoke(() =>
                        {
                            image.Source = img;
                        });
                        image1.Dispatcher.Invoke(() =>
                        {
                            image1.Source = info;
                        });
                    }
                    catch
                    {
                        thr = null;
                    }
                    Thread.Sleep(30);
                }
                image.MouseDown -= mouseDownOnImage;
            });
            AppDomain.CurrentDomain.ProcessExit += delegate
            {
                thr = null;
            };
            thr.Start();
        }