public Translator(StackPanel xamlPage, string siteName, bool lastpage)
        {
            this.XamlPage  = xamlPage;
            this._siteName = siteName;
            var mainPanel = xamlPage.Children[0];

            _controls     = new List <IWebControl>();
            _content      = new WebContent();
            _styleBuilder = new StyleBuilder("C:\\Users\\Michał\\Desktop\\Praca Inzynierska\\WebSiteArchitect\\WebSiteArchitectDev\\WebSiteArchitect.ClientWeb\\Content\\Style");

            _content.Controls = ConvertToWebPage();

            if (lastpage)
            {
                _styleBuilder.SaveFile(siteName);
            }
            else
            {
                _styleBuilder.SaveFile();
            }
        }
        public async void OnEditModeChangeAsync()
        {
            if (_mainWindowVM.ControlsWindow == null)
            {
                _mainWindowVM.ControlsWindow = new Views.Controls();
            }
            if (_mainWindowVM.PropertWindow == null)
            {
                _mainWindowVM.PropertWindow = new Views.Property();
            }

            switch (_editMode)
            {
            case -1:
                if (_mainWindowVM.ControlsWindow != null)
                {
                    _mainWindowVM.ControlsWindow.Hide();
                }
                if (_mainWindowVM.PropertWindow != null)
                {
                    _mainWindowVM.PropertWindow.Hide();
                }
                break;

            case 0:
                _mainWindowVM.ControlsWindow.Show();
                _mainWindowVM.PropertWindow.Hide();
                break;

            case 1:
                _mainWindowVM.ControlsWindow.Hide();
                _mainWindowVM.PropertWindow.Hide();
                break;

            case 2:
                _mainWindowVM.ControlsWindow.Hide();
                _mainWindowVM.PropertWindow.Hide();
                break;

            case 3:
                _mainWindowVM.ControlsWindow.Hide();
                _mainWindowVM.PropertWindow.Hide();
                break;

            case 4:
                _mainWindowVM.ControlsWindow.Hide();
                _mainWindowVM.PropertWindow.Hide();
                break;

            case 5:
                _mainWindowVM.ControlsWindow.Hide();
                _mainWindowVM.PropertWindow.Show();
                break;

            case 6:
                _mainWindowVM.ControlsWindow.Hide();
                _mainWindowVM.PropertWindow.Hide();

                StyleBuilder _styleBuilder = new StyleBuilder("C:\\Users\\Michał\\Desktop\\Praca Inzynierska\\WebSiteArchitect\\WebSiteArchitectDev\\WebSiteArchitect.ClientWeb\\Content\\Style");
                _styleBuilder.ClearFile(_mainWindowVM.SelectedSite.Name);

                if (_mainWindowVM.SelectedPage != null)
                {
                    _mainWindowVM.SelectedPage.XamlPageString = Settings.XamlToSring(this.XamlPage);
                    UpdatePageRequest req = new UpdatePageRequest()
                    {
                        Id         = _mainWindowVM.SelectedPage.PageId,
                        XamlSchema = _mainWindowVM.SelectedPage.XamlPageString,
                        Controls   = null
                    };
                    _mainWindowVM.Consumer.UpdateAsync("api/page", req);
                }
                else if (_mainWindowVM.SelectedMenu != null)
                {
                    _mainWindowVM.SelectedMenu.XamlPageString = Settings.XamlToSring(this.XamlPage);

                    UpdatePageRequest req = new UpdatePageRequest()
                    {
                        Id         = _mainWindowVM.SelectedMenu.MenuId,
                        XamlSchema = _mainWindowVM.SelectedMenu.XamlPageString,
                        Controls   = null
                    };
                    _mainWindowVM.Consumer.UpdateAsync("api/menu", req);
                }

                Thread.Sleep(1000);
                if (_mainWindowVM.SelectedSite != null)
                {
                    var pages = _mainWindowVM.Consumer.GetPageForSite(_mainWindowVM.SelectedSite.SiteId).ToList();
                    var menus = _mainWindowVM.Consumer.GetMenusForSite(_mainWindowVM.SelectedSite.SiteId).ToList();
                    ControlCounter.Clear();
                    foreach (Base.Menu menu in menus)
                    {
                        Translator        translator = new Translator(Settings.StringToXaml(menu.XamlPageString), _mainWindowVM.SelectedSite.Name, false);
                        UpdatePageRequest req        = new UpdatePageRequest()
                        {
                            Id         = menu.MenuId,
                            XamlSchema = menu.XamlPageString,
                            Controls   = Settings.ConvertToJson(translator.Content)
                        };
                        _mainWindowVM.Consumer.UpdateAsync("api/menu", req);
                    }

                    foreach (Base.Page page in pages)
                    {
                        var               islast     = pages.IndexOf(page) == pages.Count() - 1 ? true : false;
                        Translator        translator = new Translator(Settings.StringToXaml(page.XamlPageString), _mainWindowVM.SelectedSite.Name, islast);
                        UpdatePageRequest req        = new UpdatePageRequest()
                        {
                            Id         = page.PageId,
                            XamlSchema = page.XamlPageString,
                            Controls   = Settings.ConvertToJson(translator.Content)
                        };
                        _mainWindowVM.Consumer.UpdateAsync("api/page", req);
                    }



                    ControlCounter.Clear();
                }

                break;
            }
        }