#if MSCHART
using FastReport.MSChart;
#endif
using FastReport.Map;
using FastReport.Dialog;

namespace FastReport.Import
{
    /// <summary>
    /// The components factory.
    /// </summary>
    public static partial class ComponentsFactory
    {
        #region Objects

        /// <summary>
        /// Creates a RichObject instance with specified name and parent.
        /// </summary>
        /// <param name="name">The name of the RichObject instance.</param>
        /// <param name="parent">The parent of the RichObject instance.</param>
        /// <returns>The RichObject instance.</returns>
        public static RichObject CreateRichObject(string name, Base parent)
        {
            RichObject rich = new RichObject();
            rich.Name = name;
            rich.Parent = parent;
            return rich;
        }

        /// <summary>
        /// Creates a SVGObject instance with specified name and parent.
        /// </summary>
        /// <param name="name">The name of the SVGObject instance.</param>
        /// <param name="parent">The parent of the SVGObject instance.</param>
        /// <returns>The SVGObject instance.</returns>
        public static SVG.SVGObject CreateSVGObject(string name, Base parent)
        {
            SVG.SVGObject picture = new SVG.SVGObject();
            picture.Name = name;
            if ((parent as IParent).CanContain(picture))
                picture.Parent = parent;
            return picture;
        }

        /// <summary>
        /// Creates a AdvMatrixObject instance with specified name and parent.
        /// </summary>
        /// <param name="name">The name of the AdvMatrixObject instance.</param>
        /// <param name="parent">The parent of the AdvMatrixObject instance.</param>
        /// <returns>The AdvMatrixObject instance.</returns>
        public static AdvMatrix.AdvMatrixObject CreateAdvMatrixObject(string name, Base parent)
        {
            AdvMatrix.AdvMatrixObject matrix = new AdvMatrix.AdvMatrixObject();
            matrix.Name = name;
            if ((parent as IParent).CanContain(matrix))
                matrix.Parent = parent;
            return matrix;
        }

#if MSCHART
        /// <summary>
        /// Creates a MSChartObject instance with specified name and parent.
        /// </summary>
        /// <param name="name">The name of the MSChartObject instance.</param>
        /// <param name="parent">The parent of the MSChartObject instance.</param>
        /// <returns>The MSChartObject instance.</returns>
        public static MSChartObject CreateMSChartObject(string name, Base parent)
        {
            MSChartObject chart = new MSChartObject();
            chart.Name = name;
            chart.Parent = parent;
            return chart;
        }

        /// <summary>
        /// Creates a SparklineObject instance with specified name and parent.
        /// </summary>
        /// <param name="name">The name of the SparlineObject instance.</param>
        /// <param name="parent">The parent of the SparlineObject instance.</param>
        /// <returns></returns>
        public static SparklineObject CreateSparklineObject(string name, Base parent)
        {
            SparklineObject sparkline = new SparklineObject();
            sparkline.Name = name;
            sparkline.Parent = parent;
            return sparkline;
        }
#endif

        /// <summary>
        /// Creates a MapObject instance with specified name and parent.
        /// </summary>
        /// <param name="name">The name of the MapObject instance.</param>
        /// <param name="parent">The parent of the MapObject instance.</param>
        /// <returns>The MapObject instance.</returns>
        public static MapObject CreateMapObject(string name, Base parent)
        {
            MapObject map = new MapObject();
            map.Name = name;
            map.Parent = parent;
            return map;
        }

        #endregion // Objects

#if !FRCORE
        #region DialogObjects

        /// <summary>
        /// Creates a DialogPage instance in the specified Report.
        /// </summary>
        /// <param name="report">The Report instance.</param>
        /// <returns>The DialogPage instance.</returns>
        public static Dialog.DialogPage CreateDialogPage(Report report)
        {
            Dialog.DialogPage page = new Dialog.DialogPage();
            report.Pages.Add(page);
            page.CreateUniqueName();
            return page;
        }

        /// <summary>
        /// Creates a TextBoxControl instance with specified name and parent.
        /// </summary>
        /// <param name="name">The name of the TextBoxControl instance.</param>
        /// <param name="parent">The parent of the TextBoxControl instance.</param>
        /// <returns>The TextBoxControl instance.</returns>
        public static TextBoxControl CreateTextBoxControl(string name, Base parent)
        {
            TextBoxControl textBox = new TextBoxControl();
            textBox.Name = name;
            if ((parent as IParent).CanContain(textBox))
                textBox.Parent = parent;
            return textBox;
        }

        /// <summary>
        /// Creates a LabelControl instance with specified name and parent.
        /// </summary>
        /// <param name="name">The name of the LabelControl instance.</param>
        /// <param name="parent">The parent of the LabelControl instance.</param>
        /// <returns>The LabelControl instance.</returns>
        public static LabelControl CreateLabelControl(string name, Base parent)
        {
            LabelControl labelControl = new LabelControl();
            labelControl.Name = name;
            if ((parent as IParent).CanContain(labelControl))
                labelControl.Parent = parent;
            return labelControl;
        }

        /// <summary>
        /// Creates a RadioButtonControl instance with specified name and parent.
        /// </summary>
        /// <param name="name">The name of the RadioButtonControl instance.</param>
        /// <param name="parent">The parent of the RadioButtonControl instance.</param>
        /// <returns>The RadioButtonControl instance.</returns>
        public static RadioButtonControl CreateRadioButtonControl(string name, Base parent)
        {
            RadioButtonControl radioButtonControl = new RadioButtonControl();
            radioButtonControl.Name = name;
            if ((parent as IParent).CanContain(radioButtonControl))
                radioButtonControl.Parent = parent;
            return radioButtonControl;
        }

        /// <summary>
        /// Creates a DateTimePickerControl instance with specified name and parent.
        /// </summary>
        /// <param name="name">The name of the DateTimePickerControl instance.</param>
        /// <param name="parent">The parent of the DateTimePickerControl instance.</param>
        /// <returns>The DateTimePickerControl instance.</returns>
        public static DateTimePickerControl CreateDateTimePickerControl(string name, Base parent)
        {
            DateTimePickerControl dateTimePickerControl = new DateTimePickerControl();
            dateTimePickerControl.Name = name;
            if ((parent as IParent).CanContain(dateTimePickerControl))
                dateTimePickerControl.Parent = parent;
            return dateTimePickerControl;
        }

        /// <summary>
        /// Creates a GridControl instance with specified name and parent.
        /// </summary>
        /// <param name="name">The name of the GridControl instance.</param>
        /// <param name="parent">The parent of the GridControl instance.</param>
        /// <returns>The GridControl instance.</returns>
        public static GridControl CreateGridControl(string name, Base parent)
        {
            GridControl gridControl = new GridControl();
            gridControl.Name = name;
            if ((parent as IParent).CanContain(gridControl))
                gridControl.Parent = parent;
            return gridControl;
        }

        /// <summary>
        /// Creates a GroupBoxControl instance with specified name and parent.
        /// </summary>
        /// <param name="name">The name of the GroupBoxControl instance.</param>
        /// <param name="parent">The parent of the GroupBoxControl instance.</param>
        /// <returns>The GroupBoxControl instance.</returns>
        public static GroupBoxControl CreateGroupBoxControl(string name, Base parent)
        {
            GroupBoxControl gridControl = new GroupBoxControl();
            gridControl.Name = name;
            if ((parent as IParent).CanContain(gridControl))
                gridControl.Parent = parent;
            return gridControl;
        }

        /// <summary>
        /// Creates a ButtonControl instance with specified name and parent.
        /// </summary>
        /// <param name="name">The name of the ButtonControl instance.</param>
        /// <param name="parent">The parent of the ButtonControl instance.</param>
        /// <returns>The ButtonControl instance.</returns>
        public static ButtonControl CreateButtonControl(string name, Base parent)
        {
            ButtonControl buttonControl = new ButtonControl();
            buttonControl.Name = name;
            if ((parent as IParent).CanContain(buttonControl))
                buttonControl.Parent = parent;
            return buttonControl;
        }

        /// <summary>
        /// Creates a CheckBoxControl instance with specified name and parent.
        /// </summary>
        /// <param name="name">The name of the CheckBoxControl instance.</param>
        /// <param name="parent">The parent of the CheckBoxControl instance.</param>
        /// <returns>The CheckBoxControl instance.</returns>
        public static CheckBoxControl CreateCheckBoxControl(string name, Base parent)
        {
            CheckBoxControl checkBoxControl = new CheckBoxControl();
            checkBoxControl.Name = name;
            if ((parent as IParent).CanContain(checkBoxControl))
                checkBoxControl.Parent = parent;
            return checkBoxControl;
        }

        /// <summary>
        /// Creates a CheckedListBoxControl instance with specified name and parent.
        /// </summary>
        /// <param name="name">The name of the CheckedListBoxControl instance.</param>
        /// <param name="parent">The parent of the CheckedListBoxControl instance.</param>
        /// <returns>The CheckedListBoxControl instance.</returns>
        public static CheckedListBoxControl CreateCheckedListBoxControl(string name, Base parent)
        {
            CheckedListBoxControl checkedListBoxControl = new CheckedListBoxControl();
            checkedListBoxControl.Name = name;
            if ((parent as IParent).CanContain(checkedListBoxControl))
                checkedListBoxControl.Parent = parent;
            return checkedListBoxControl;
        }

        /// <summary>
        /// Creates a ListBoxControl instance with specified name and parent.
        /// </summary>
        /// <param name="name">The name of the ListBoxControl instance.</param>
        /// <param name="parent">The parent of the ListBoxControl instance.</param>
        /// <returns>The ListBoxControl instance.</returns>
        public static ListBoxControl CreateListBoxControl(string name, Base parent)
        {
            ListBoxControl listBoxControl = new ListBoxControl();
            listBoxControl.Name = name;
            if ((parent as IParent).CanContain(listBoxControl))
                listBoxControl.Parent = parent;
            return listBoxControl;
        }

        /// <summary>
        /// Creates a PanelControl instance with specified name and parent.
        /// </summary>
        /// <param name="name">The name of the PanelControl instance.</param>
        /// <param name="parent">The parent of the PanelControl instance.</param>
        /// <returns>The PanelControl instance.</returns>
        public static PanelControl CreatePanelControl(string name, Base parent)
        {
            PanelControl panelControl = new PanelControl();
            panelControl.Name = name;
            if ((parent as IParent).CanContain(panelControl))
                panelControl.Parent = parent;
            return panelControl;
        }

        /// <summary>
        /// Creates a ComboBoxControl instance with specified name and parent.
        /// </summary>
        /// <param name="name">The name of the ComboBoxControl instance.</param>
        /// <param name="parent">The parent of the ComboBoxControl instance.</param>
        /// <returns>The ComboBoxControl instance.</returns>
        public static ComboBoxControl CreateComboBoxControl(string name, Base parent)
        {
            ComboBoxControl comboBoxControl = new ComboBoxControl();
            comboBoxControl.Name = name;
            if ((parent as IParent).CanContain(comboBoxControl))
                comboBoxControl.Parent = parent;
            return comboBoxControl;
        }

        /// <summary>
        /// Creates a NumericUpDownControl instance with specified name and parent.
        /// </summary>
        /// <param name="name">The name of the NumericUpDownControl instance.</param>
        /// <param name="parent">The parent of the NumericUpDownControl instance.</param>
        /// <returns>The NumericUpDownControl instance.</returns>
        public static NumericUpDownControl CreateNumericUpDownControl(string name, Base parent)
        {
            NumericUpDownControl numericUpDownControl = new NumericUpDownControl();
            numericUpDownControl.Name = name;
            if ((parent as IParent).CanContain(numericUpDownControl))
                numericUpDownControl.Parent = parent;
            return numericUpDownControl;
        }

        /// <summary>
        /// Creates a PictureBoxControl instance with specified name and parent.
        /// </summary>
        /// <param name="name">The name of the PictureBoxControl instance.</param>
        /// <param name="parent">The parent of the PictureBoxControl instance.</param>
        /// <returns>The PictureBoxControl instance.</returns>
        public static PictureBoxControl CreatePictureBoxControl(string name, Base parent)
        {
            PictureBoxControl pictureBoxControl = new PictureBoxControl();
            pictureBoxControl.Name = name;
            if ((parent as IParent).CanContain(pictureBoxControl))
                pictureBoxControl.Parent = parent;
            return pictureBoxControl;
        }

        /// <summary>
        /// Creates a ListViewControl instance with specified name and parent.
        /// </summary>
        /// <param name="name">The name of the ListViewControl instance.</param>
        /// <param name="parent">The parent of the ListViewControl instance.</param>
        /// <returns>The ListViewControl instance.</returns>
        public static ListViewControl CreateListViewControl(string name, Base parent)
        {
            ListViewControl listViewControl = new ListViewControl();
            listViewControl.Name = name;
            if ((parent as IParent).CanContain(listViewControl))
                listViewControl.Parent = parent;
            return listViewControl;
        }

        /// <summary>
        /// Creates a RichTextBoxControl instance with specified name and parent.
        /// </summary>
        /// <param name="name">The name of the RichTextBoxControl instance.</param>
        /// <param name="parent">The parent of the RichTextBoxControl instance.</param>
        /// <returns>The RichTextBoxControl instance.</returns>
        public static RichTextBoxControl CreateRichTextBoxControl(string name, Base parent)
        {
            RichTextBoxControl richTextBoxControl = new RichTextBoxControl();
            richTextBoxControl.Name = name;
            if ((parent as IParent).CanContain(richTextBoxControl))
                richTextBoxControl.Parent = parent;
            return richTextBoxControl;
        }

        /// <summary>
        /// Creates a TreeViewControl instance with specified name and parent.
        /// </summary>
        /// <param name="name">The name of the TreeViewControl instance.</param>
        /// <param name="parent">The parent of the TreeViewControl instance.</param>
        /// <returns>The TreeViewControl instance.</returns>
        public static TreeViewControl CreateTreeViewControl(string name, Base parent)
        {
            TreeViewControl treeViewControl = new TreeViewControl();
            treeViewControl.Name = name;
            if ((parent as IParent).CanContain(treeViewControl))
                treeViewControl.Parent = parent;
            return treeViewControl;
        }
        #endregion
#endif
    }
}
