public ArrangementPageViewModel(InteriorField[,] layout, Chair chairModel, Table tableModel)
        {
            this.Rows = layout.GetLength(0);
            this.Columns = layout.GetLength(1);
            this.Arrangement = new ObservableCollection<ArrangedFieldViewModel>();
            for (int y = 0; y < layout.GetLength(0); y++)
                for (int x = 0; x < layout.GetLength(1); x++)
                {
                    this.Arrangement.Add(new ArrangedFieldViewModel((layout[y, x])));
                }

            this.Palettes = new ObservableCollection<string>(new[] { "Light", "Dark" });
            this.ChairModel = chairModel;
            this.TableModel = tableModel;

            Pathway autoPathway = new Pathway();
            Flower autoFlower = new Flower();
            foreach (ArrangedFieldViewModel field in this.Arrangement)
            {
                if (field?.PlaceHolder?.CanHoldObject(autoFlower) ?? false) field.ArrangeObjectCommand.Execute(autoFlower);
                else if (field?.PlaceHolder?.CanHoldObject(autoPathway) ?? false) field.ArrangeObjectCommand.Execute(autoPathway);
            }

            this.ClearAllCommand = new DelegateCommand((param) => this.ClearAll());
            this.FillAllCommand = new DelegateCommand((param) => this.FillAll());
            this.RemoveObjectCommand = new DelegateCommand(this.RemoveObject, this.CanRemoveObject);
        }
        public override InteriorField[,] GetLayout()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.DefaultExt = "txt";
            DirectoryInfo currentDir = new DirectoryInfo(Environment.CurrentDirectory);
            openFileDialog.InitialDirectory = (currentDir.EnumerateDirectories().FirstOrDefault(d => d.Name == DataSubdirName) ?? currentDir).FullName;
            if (openFileDialog.ShowDialog().GetValueOrDefault())
            {
                this.LayoutIdentifier = openFileDialog.FileName;
                using (StreamReader readLines = new StreamReader(openFileDialog.OpenFile()))
                {
                    List<List<InteriorField>> layout = readLines
                        .ReadToEnd()
                        .Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
                        .Select(s => s
                            .Select(c => this.CreateField(c)).ToList()).ToList();

                    int columnsCount = layout.Max(l => l.Count);
                    InteriorField[,] result = new InteriorField[layout.Count, columnsCount];
                    for (int row = 0; row < layout.Count; row++)
                    {
                        for (int col = 0; col < layout[row].Count; col++)
                        {
                            result[row, col] = layout[row][col];
                        }
                    }
                    return result;
                }
            }
            else
            {
                return null;
            }
        }
 public void ShoudlSetBrand()
 {
     InteriorField[,] layout = new InteriorField[0, 0];
     ChooseBrandViewModel test = new ChooseBrandViewModel(layout);
     test.SelectedBrand = "test";
     ArrangementPageViewModel nextState = test.GetNextState() as ArrangementPageViewModel;
     Assert.AreEqual("test", nextState.TableModel.BrandName);
     Assert.AreEqual("test", nextState.ChairModel.BrandName);
 }
        public override InteriorField[,] GetLayout()
        {
            List<char?> symbolsPool = this.SupportedIdentifiers.Select(c => (char?)c).ToList();
            symbolsPool.Add(null);

            InteriorField[,] result = new InteriorField[rand.Next(1, MaxRows / 5), rand.Next(1, MaxColumns / 5)];
            for (int x = 0; x < result.GetLength(0); x++)
                for (int y = 0; y < result.GetLength(1); y++)
                {
                    char? currentField = symbolsPool[rand.Next(symbolsPool.Count)];
                    if (currentField != null) result[x, y] = this.CreateField(currentField.Value);
                }

            return result;
        }
 public ArrangedFieldViewModel(InteriorField placeHolder)
 {
     this.PlaceHolder = placeHolder;
     this.ArrangedItems = new ObservableCollection<InteriorObjectBase>();
     this.ArrangeObjectCommand = new DelegateCommand(this.ArrangeObject, (param) => param is DragEventArgs ? this.CanArrangeObject(param as DragEventArgs) : this.CanArrangeObject(param as InteriorObjectBase));
 }
 public ChooseBrandViewModel(InteriorField[,] layout)
 {
     this.layout = layout;
     this.Brands = new ObservableCollection<string>(new string[] { "A", "B" });
 }