public bool DeleteControl(UserControl notSelected = null)
        {
            if (notSelected != null)
            {
                _selectedControl = new LayoutControl(notSelected);
            }
            switch (_selectedControl.ControlTypeName)
            {
            case "EmptySpace":
                return(false);

            case "Row":
                foreach (UserControl childControl in ((System.Windows.Controls.Panel)_selectedControl.Control.Content).Children)
                {
                    if (_selectedControl.ControlTypeName != "EmptySpace")
                    {
                        return(false);
                    }
                }
                break;

            case "Panel":
                break;
            }
            _selectedControl.SetControlSize(1);
            AddControl(new Controls.Layout.EmptySpace(), _selectedControl.Control);
            return(true);
        }
 public List <IWebControl> ConvertToWebPage()
 {
     foreach (UserControl childControl in XamlPage.Children)
     {
         _currentControl = new LayoutControl(childControl);
         _controls.Add(GetSimpleControlFromXaml());
     }
     return(_controls);
 }
Пример #3
0
        public string GenerateCSS(LayoutControl control, WebControl newControl, string siteName)
        {
            string cssClass = "";

            siteName = "." + siteName;
            if (!string.IsNullOrEmpty(control.FontColor.ToString()) || !string.IsNullOrEmpty(control.BackgroundColor.ToString()))
            {
                cssClass = siteName + " " + newControl.Name + "Custom";
                _styles += siteName + " ." + newControl.Name + "Custom,\n";
                _styles += siteName + " ." + newControl.Name + "Custom input,\n";
                _styles += siteName + " ." + newControl.Name + "Custom select,\n";
                _styles += siteName + " ." + newControl.Name + "Custom label,\n";
                _styles += siteName + " ." + newControl.Name + "Custom a,\n";
                _styles += siteName + " ." + newControl.Name + "Custom span{\n";


                if (!string.IsNullOrEmpty(control.FontColor.ToString()))
                {
                    _styles += "color:" + "rgb(" + control.FontColor.Value.R + "," + control.FontColor.Value.G + "," + control.FontColor.Value.B + ");\n";
                }
                if (!string.IsNullOrEmpty(control.BackgroundColor.ToString()))
                {
                    _styles += "background-color:" + "rgb(" + control.BackgroundColor.Value.R + "," + control.BackgroundColor.Value.G + "," + control.BackgroundColor.Value.B + ");\n";
                }
                if (!string.IsNullOrEmpty(control.FontSize.ToString()) && control.FontSize != 0)
                {
                    _styles += "font-size:" + control.FontSize + "px;\n";
                }

                _styles += "}\n";
            }
            if (control.ControlType == WebModel.Enums.WebControlTypeEnum.button || control.ControlType == WebModel.Enums.WebControlTypeEnum.input)
            {
                if (control.ControlType == WebModel.Enums.WebControlTypeEnum.button)
                {
                    _styles += siteName + " ." + newControl.Name + "Custom a{\n";
                }
                else if (control.ControlType == WebModel.Enums.WebControlTypeEnum.input)
                {
                    _styles += siteName + " ." + newControl.Name + "Custom input{\n";
                }
                _styles += "background-color:" + "rgb(" + control.ContentColor.Value.R + "," + control.ContentColor.Value.G + "," + control.ContentColor.Value.B + ");\n";
                _styles += "border-color:" + "rgb(" + control.ContentColor.Value.R + "," + control.ContentColor.Value.G + "," + control.ContentColor.Value.B + ");\n";
                _styles += "}\n";
            }

            return(cssClass);
        }
 public bool SetControlSize(int newSize)
 {
     if (_control == null || newSize <= 0 || newSize == this.Size)
     {
         return(false);
     }
     if (this.ControlType == WebControlTypeEnum.row)
     {
         return(false);
     }
     if (newSize > this.Size)
     {
         if (this.ChildIndex + newSize > 12)
         {
             return(false);
         }
         for (int i = this.ChildIndex + 1; i < this.ChildIndex + newSize; i++)
         {
             LayoutControl child = new LayoutControl(_parentControl.Children[i] as UserControl);
             if (child.ControlType != WebControlTypeEnum.emptySpace)
             {
                 return(false);
             }
         }
         var colDefinitions = _parentControl.ColumnDefinitions.Where(x => _parentControl.ColumnDefinitions.IndexOf(x) >= this.ChildIndex && _parentControl.ColumnDefinitions.IndexOf(x) < this.ChildIndex + newSize);
         _parentControl.ColumnDefinitions[this.ChildIndex].Width = new GridLength(newSize, GridUnitType.Star);
         for (int i = this.ChildIndex + 1; i < this.ChildIndex + newSize; i++)
         {
             _parentControl.ColumnDefinitions[i].Width = new GridLength(0, GridUnitType.Star);
         }
     }
     else
     {
         _parentControl.ColumnDefinitions[this.ChildIndex].Width = new GridLength(newSize, GridUnitType.Star);
         for (int i = this.ChildIndex + newSize; i < this.ChildIndex + _size; i++)
         {
             _parentControl.ColumnDefinitions[i].Width = new GridLength(1, GridUnitType.Star);
         }
     }
     return(true);
 }
        public WebControl GetSimpleControlFromXaml()
        {
            WebControl newControl;

            switch (_currentControl.ControlTypeName)
            {
            case "button":
                newControl       = new WebSiteArchitect.WebModel.Controls.Button();
                newControl.Name  = _currentControl.ControlTypeName + ControlCounter.ButtonCount.ToString();
                newControl.Value = _currentControl.Value;
                newControl.GoTo  = _currentControl.GoTo;
                break;

            case "emptyspace":
                newControl      = new WebSiteArchitect.WebModel.Controls.EmptySpace();
                newControl.Name = _currentControl.ControlTypeName + ControlCounter.EmptySpaceCount.ToString();
                break;

            case "label":
                newControl       = new WebSiteArchitect.WebModel.Controls.Label();
                newControl.Name  = _currentControl.ControlTypeName + ControlCounter.LabelCount.ToString();
                newControl.Value = _currentControl.Value;
                break;

            case "panel":
            case "row":
                newControl = new WebSiteArchitect.WebModel.Controls.Panel();
                foreach (UserControl childControl in ((System.Windows.Controls.Panel)_currentControl.Control.Content).Children)
                {
                    var tempCurrentControl = _currentControl;
                    _currentControl = new LayoutControl(childControl);
                    newControl.ChildrenControls.Add(GetSimpleControlFromXaml());
                    _currentControl = tempCurrentControl;
                }
                break;

            case "input":
                newControl       = new WebSiteArchitect.WebModel.Controls.Input();
                newControl.Name  = _currentControl.ControlTypeName + ControlCounter.InputCount.ToString();
                newControl.Value = _currentControl.Value;

                break;

            case "select":
                newControl       = new WebSiteArchitect.WebModel.Controls.Select();
                newControl.Name  = _currentControl.ControlTypeName + ControlCounter.SelectCount.ToString();
                newControl.Value = _currentControl.Value;
                break;

            case "image":
                newControl       = new WebSiteArchitect.WebModel.Controls.Image();
                newControl.Name  = _currentControl.ControlTypeName + ControlCounter.ImageCount.ToString();
                newControl.Value = _currentControl.Value;
                break;

            default:
                return(null);
            }
            ApplyClass(newControl);
            return(newControl);
        }