Exemple #1
0
        /// <summary>
        /// 多页夹控件的模板
        /// </summary>
        /// <param name="tabControl">多页夹控件</param>
        /// <param name="node">节点</param>
        public static void TabControlTemplate(FCTabControl tabControl, UIXmlEx xml, XmlNode node)
        {
            XmlDocument xmlDoc = node.OwnerDocument;

            tabControl.Size = new FCSize(200, 200);
            FCTabPage tabPage = new FCTabPage();

            tabControl.addControl(tabPage);
            tabPage.Name = CreateControlName(tabPage, xml);
            tabPage.Text = tabPage.Name;
            XmlNode tabPageNode = xmlDoc.CreateNode(XmlNodeType.Element, "div", "");

            node.AppendChild(tabPageNode);
            XmlAttribute xmlAtr1 = xmlDoc.CreateAttribute("name");

            xmlAtr1.Value = tabPage.Name;
            tabPageNode.Attributes.Append(xmlAtr1);
            XmlAttribute xmlAtr2 = xmlDoc.CreateAttribute("text");

            xmlAtr2.Value = tabPage.Name;
            tabPageNode.Attributes.Append(xmlAtr2);
            XmlAttribute xmlAtr3 = xmlDoc.CreateAttribute("type");

            xmlAtr3.Value = "tabpage";
            tabPageNode.Attributes.Append(xmlAtr3);
            xml.m_controls.Add(tabPage);
            xml.Nodes[tabPage] = tabPageNode;
            tabControl.update();
        }
Exemple #2
0
        /// <summary>
        /// 保存文件
        /// </summary>
        /// <param name="fileName">文件名</param>
        public void saveFile(String fileName)
        {
            FCTabPage selectedTabPage = SelectedTabPage;

            if (selectedTabPage != null)
            {
                if (selectedTabPage == m_sourceCodeTabPage)
                {
                    if (m_sourceCodeChanged)
                    {
                        String xml   = m_scintilla.Text;
                        String error = "";
                        if (m_xml.checkXml(xml, ref error))
                        {
                            openXml(xml);
                        }
                        else
                        {
                            MessageBox.Show(error, "提示");
                            return;
                        }
                        m_sourceCodeChanged = false;
                    }
                }
                m_xml.saveFile(fileName);
                if (selectedTabPage != m_sourceCodeTabPage)
                {
                    m_scintilla.loadXml(m_xml.DocumentText.Replace("<", "<"));
                    m_ignoreNextInput = true;
                }
                Modified = false;
            }
        }
Exemple #3
0
        /// <summary>
        /// 表格选中行改变方法
        /// </summary>
        public void onGridSelectedRowsChanged()
        {
            List <FCGridRow> selectedRows = m_tvCollection.SelectedRows;
            int selectedRowsSize          = selectedRows.Count;

            if (selectedRowsSize > 0)
            {
                if (selectedRows[0].Tag != null)
                {
                    List <FCView> targets = new List <FCView>();
                    if (m_collectionName == "TabPages")
                    {
                        FCTabPage tabPage = selectedRows[0].Tag as FCTabPage;
                        targets.Add(tabPage);
                    }
                    else if (m_collectionName == "Columns")
                    {
                        FCGridColumn column = selectedRows[0].Tag as FCGridColumn;
                        targets.Add(column);
                    }
                    m_gridProperty.clearTargets();
                    m_gridProperty.addTargets(targets);
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// 删除类
        /// </summary>
        public void deleteClass()
        {
            List <FCGridRow> selectedRows = m_tvCollection.SelectedRows;
            int selectedRowsSize          = selectedRows.Count;

            if (selectedRowsSize > 0)
            {
                if (m_collectionName == "TabPages")
                {
                    FCTabControl tabControl = m_target as FCTabControl;
                    FCTabPage    tabPage    = selectedRows[0].Tag as FCTabPage;
                    m_xml.removeControl(tabPage);
                    m_tvCollection.removeRow(selectedRows[0]);
                    m_tvCollection.update();
                    tabControl.update();
                }
                else if (m_collectionName == "Columns")
                {
                    FCGrid       grid   = m_target as FCGrid;
                    FCGridColumn column = selectedRows[0].Tag as FCGridColumn;
                    grid.removeColumn(column);
                    m_xml.m_controls.Remove(column);
                    m_xml.Nodes[column].ParentNode.RemoveChild(m_xml.Nodes[column]);
                    m_xml.Nodes.Remove(column);
                    m_tvCollection.removeRow(selectedRows[0]);
                    m_tvCollection.update();
                    grid.update();
                }
                Native.invalidate();
                m_designerDiv.saveUndo();
            }
        }
Exemple #5
0
 /// <summary>
 /// 结束拖动页头
 /// </summary>
 /// <param name="tabPage">页</param>
 public virtual void onDragTabHeaderEnd(FCTabPage tabPage)
 {
     if (m_animationState == 1)
     {
         m_animationState = 2;
         drawMoving();
     }
 }
Exemple #6
0
        /// <summary>
        /// 插入控件
        /// </summary>
        /// <param name="index">索引</param>
        /// <param name="control">控件</param>
        public override void insertControl(int index, FCView control)
        {
            FCTabPage tabPage = control as FCTabPage;

            if (tabPage != null)
            {
                tabPage.TabControl = this;
            }
            base.addControl(control);
            m_tabPages.Insert(index, tabPage);
            SelectedTabPage = tabPage;
        }
Exemple #7
0
        /// <summary>
        /// 获取偏移坐标
        /// </summary>
        /// <returns>偏移坐标</returns>
        public FCPoint getOffsetPoint()
        {
            FCPoint offset = new FCPoint();
            FCView  parent = Parent;

            if (parent != null)
            {
                FCTabPage designerDiv = parent as FCTabPage;
                offset.x += (designerDiv.HScrollBar != null ? designerDiv.HScrollBar.Pos : 0);
                offset.y += (designerDiv.VScrollBar != null ? designerDiv.VScrollBar.Pos : 0);
            }
            return(offset);
        }
Exemple #8
0
 /// <summary>
 /// 页选中改变方法
 /// </summary>
 public override void onSelectedTabPageChanged()
 {
     base.onSelectedTabPageChanged();
     if (m_xml != null)
     {
         FCNative  native          = Native;
         FCTabPage selectedTabPage = SelectedTabPage;
         if (selectedTabPage != null)
         {
             bool modified = Modified;
             m_canModifyCaption = false;
             //设计视图
             if (selectedTabPage == m_designerTabPage)
             {
                 if (m_sourceCodeChanged)
                 {
                     if (m_scintilla != null)
                     {
                         String xml   = m_scintilla.Text;
                         String error = "";
                         if (m_xml.checkXml(xml, ref error))
                         {
                             saveUndo();
                             openXml(xml);
                             m_sourceCodeChanged = false;
                         }
                     }
                 }
             }
             //源代码
             else if (selectedTabPage == m_sourceCodeTabPage)
             {
                 if (m_scintilla != null)
                 {
                     String xml = m_scintilla.Text;
                     if (xml.Length == 0 || modified)
                     {
                         String error = "";
                         if (xml.Length == 0 || m_xml.checkXml(xml, ref error))
                         {
                             m_scintilla.loadXml(m_xml.DocumentText.Replace("<", "<"));
                             m_ignoreNextInput = true;
                         }
                     }
                     m_designer.viewSource();
                 }
             }
             m_canModifyCaption = true;
         }
     }
 }
Exemple #9
0
        /// <summary>
        /// 添加控件方法
        /// </summary>
        /// <param name="control">控件</param>
        public override void addControl(FCView control)
        {
            FCTabPage tabPage = control as FCTabPage;

            if (tabPage != null)
            {
                tabPage.TabControl = this;
            }
            base.addControl(control);
            if (tabPage != null)
            {
                m_tabPages.add(tabPage);
                SelectedTabPage = tabPage;
            }
        }
Exemple #10
0
        /// <summary>
        /// 创建多页夹的页
        /// </summary>
        /// <param name="node">节点</param>
        /// <param name="control">控件</param>
        protected virtual void createTabPage(XmlNode node, FCView control)
        {
            FCTabControl tabControl = control as FCTabControl;

            if (tabControl != null)
            {
                FCTabPage tabPage = new FCTabPage();
                tabPage.Native = m_native;
                tabControl.addControl(tabPage);
                setAttributesBefore(node, tabPage);
                readChildNodes(node, tabPage);
                setAttributesAfter(node, tabPage);
                onAddControl(tabPage, node);
            }
        }
Exemple #11
0
        /// <summary>
        /// 移除控件
        /// </summary>
        /// <param name="control">控件</param>
        public override void removeControl(FCView control)
        {
            FCTabPage tabPage = control as FCTabPage;

            if (tabPage != null)
            {
                int tabPageSize = m_tabPages.size();
                if (tabPageSize > 0)
                {
                    FCTabPage selectedPage = SelectedTabPage;
                    if (selectedPage == tabPage)
                    {
                        if (m_selectedIndex > 0)
                        {
                            if (m_selectedIndex < tabPageSize - 1)
                            {
                                selectedPage = m_tabPages.get(m_selectedIndex + 1);
                            }
                            else
                            {
                                selectedPage = m_tabPages.get(m_selectedIndex - 1);
                            }
                        }
                        else
                        {
                            if (tabPageSize > 1)
                            {
                                selectedPage = m_tabPages.get(m_selectedIndex + 1);
                            }
                        }
                    }
                    m_tabPages.remove(tabPage);
                    base.removeControl(tabPage.HeaderButton);
                    base.removeControl(tabPage);
                    tabPage.TabControl = null;
                    SelectedTabPage    = selectedPage;
                }
            }
            else
            {
                base.removeControl(control);
            }
        }
Exemple #12
0
 /// <summary>
 /// 显示
 /// </summary>
 public override void showDialog()
 {
     if (m_collectionName == "TabPages")
     {
         FCTabControl     tabControlA = m_target as FCTabControl;
         List <FCTabPage> tabPages    = tabControlA.getTabPages();
         int tabPagesSize             = tabPages.Count;
         for (int i = 0; i < tabPagesSize; i++)
         {
             FCTabPage  tabPage = tabPages[i];
             FCTreeNode node    = new FCTreeNode();
             node.setString(tabPage.Text);
             m_tvCollection.appendNode(node);
             node.Row.Tag = tabPage;
         }
     }
     else if (m_collectionName == "Columns")
     {
         FCGrid grid = m_target as FCGrid;
         List <FCGridColumn> columns = grid.getColumns();
         int columnsSize             = columns.Count;
         for (int i = 0; i < columnsSize; i++)
         {
             FCGridColumn column = columns[i];
             FCTreeNode   node   = new FCTreeNode();
             node.setString(column.Text);
             m_tvCollection.appendNode(node);
             node.Row.Tag = column;
         }
     }
     m_tvCollection.update();
     m_gridSelectedRowsChangedEvent = new FCEvent(gridSelectedRowsChanged);
     m_gridProperty.Xml             = m_xml;
     m_gridProperty.DesignerDiv     = m_designerDiv;
     m_tvCollection.addEvent(m_gridSelectedRowsChangedEvent, FCEventID.GRIDSELECTEDROWSCHANGED);
     if (m_tvCollection.getRows().Count > 0)
     {
         ArrayList <FCGridRow> selectedRows = new ArrayList <FCGridRow>();
         selectedRows.Add(m_tvCollection.getRow(0));
         m_tvCollection.SelectedRows = selectedRows;
     }
     base.showDialog();
 }
Exemple #13
0
 /// <summary>
 /// 添加控件方法
 /// </summary>
 public override void onLoad()
 {
     base.onLoad();
     if (m_designerTabPage == null)
     {
         m_designerTabPage = new FCTabPage();
         addControl(m_designerTabPage);
         m_designerTabPage.BorderColor         = FCColor.None;
         m_designerTabPage.HeaderButton.Size   = new FCSize(60, 20);
         m_designerTabPage.HeaderButton.Margin = new FCPadding(1, -1, 0, 2);
         m_designerTabPage.ShowHScrollBar      = true;
         m_designerTabPage.ShowVScrollBar      = true;
         m_designerTabPage.Text      = "设计";
         m_designerTabPage.BackColor = FCColor.argb(75, 51, 153, 255);
         m_resizeDiv        = new ResizeDiv();
         m_resizeDiv.Native = Native;
         m_designerTabPage.addControl(m_resizeDiv);
     }
     if (m_sourceCodeTabPage == null)
     {
         m_sourceCodeTabPage             = new FCTabPage();
         m_sourceCodeTabPage.BorderColor = FCColor.None;
         //创建编辑器
         m_scintilla         = new ScintillaX();
         m_scintilla.Visible = false;
         FCNative  native    = Native;
         WinHostEx host      = native.Host as WinHostEx;
         Control   container = Control.FromHandle(host.HWnd);
         container.Controls.Add(m_scintilla);
         m_scintilla.ParentDiv    = m_sourceCodeTabPage;
         m_scintilla.TextChanged += new EventHandler <EventArgs>(scintilla_TextChanged);
         addControl(m_sourceCodeTabPage);
         m_sourceCodeTabPage.Text = "源";
         m_sourceCodeTabPage.HeaderButton.Size   = new FCSize(60, 20);
         m_sourceCodeTabPage.HeaderButton.Margin = new FCPadding(1, -1, 0, 2);
     }
     if (Parent != null)
     {
         Parent.addEvent(m_parentVisibleChangedEvent, FCEventID.VISIBLECHANGED);
     }
     SelectedIndex = 0;
 }
Exemple #14
0
 /// <summary>
 /// 开始拖动页头
 /// </summary>
 /// <param name="tabPage">页</param>
 public virtual void onDragTabHeaderBegin(FCTabPage tabPage)
 {
     m_animationState = 1;
     tabPage.HeaderButton.bringToFront();
 }
Exemple #15
0
        /// <summary>
        /// 创建内部控件
        /// </summary>
        /// <param name="parent">父控件</param>
        /// <param name="clsid">控件标识</param>
        /// <returns>内部控件</returns>
        public override FCView createInternalControl(FCView parent, String clsid)
        {
            //日历控件
            FCCalendar calendar = parent as FCCalendar;

            if (calendar != null)
            {
                if (clsid == "datetitle")
                {
                    return(new DateTitle(calendar));
                }
                else if (clsid == "headdiv")
                {
                    HeadDiv headDiv = new HeadDiv(calendar);
                    headDiv.Width = parent.Width;
                    headDiv.Dock  = FCDockStyle.Top;
                    return(headDiv);
                }
                else if (clsid == "lastbutton")
                {
                    return(new ArrowButton(calendar));
                }
                else if (clsid == "nextbutton")
                {
                    ArrowButton nextBtn = new ArrowButton(calendar);
                    nextBtn.ToLast = false;
                    return(nextBtn);
                }
            }
            //分割层
            FCSplitLayoutDiv splitLayoutDiv = parent as FCSplitLayoutDiv;

            if (splitLayoutDiv != null)
            {
                if (clsid == "splitter")
                {
                    FCButton splitter = new FCButton();
                    splitter.BackColor   = FCColor.Border;
                    splitter.BorderColor = FCColor.Border;
                    splitter.Size        = new FCSize(5, 5);
                    return(splitter);
                }
            }
            //滚动条
            FCScrollBar scrollBar = parent as FCScrollBar;

            if (scrollBar != null)
            {
                scrollBar.BorderColor = FCColor.None;
                scrollBar.BackColor   = FCColor.None;
                if (clsid == "addbutton")
                {
                    RibbonButton addButton = new RibbonButton();
                    addButton.Size = new FCSize(10, 10);
                    if (scrollBar is FCHScrollBar)
                    {
                        addButton.ArrowType = 2;
                    }
                    else if (scrollBar is FCVScrollBar)
                    {
                        addButton.ArrowType = 4;
                    }
                    return(addButton);
                }
                else if (clsid == "backbutton")
                {
                    FCButton backButton = new FCButton();
                    backButton.BorderColor = FCColor.None;
                    backButton.BackColor   = FCColor.None;
                    return(backButton);
                }
                else if (clsid == "scrollbutton")
                {
                    RibbonButton scrollButton = new RibbonButton();
                    scrollButton.AllowDrag = true;
                    if (scrollBar is FCVScrollBar)
                    {
                        scrollButton.Angle = 0;
                    }
                    return(scrollButton);
                }
                else if (clsid == "reducebutton")
                {
                    RibbonButton reduceButton = new RibbonButton();
                    reduceButton.Size = new FCSize(10, 10);
                    if (scrollBar is FCHScrollBar)
                    {
                        reduceButton.ArrowType = 1;
                    }
                    else if (scrollBar is FCVScrollBar)
                    {
                        reduceButton.ArrowType = 3;
                    }
                    return(reduceButton);
                }
            }
            //页夹
            FCTabPage tabPage = parent as FCTabPage;

            if (tabPage != null)
            {
                if (clsid == "headerbutton")
                {
                    RibbonButton button = new RibbonButton();
                    button.AllowDrag = true;
                    FCSize size = new FCSize(100, 20);
                    button.Size = size;
                    return(button);
                }
            }
            //下拉列表
            FCComboBox comboBox = parent as FCComboBox;

            if (comboBox != null)
            {
                if (clsid == "dropdownbutton")
                {
                    RibbonButton dropDownButton = new RibbonButton();
                    dropDownButton.ArrowType     = 4;
                    dropDownButton.DisplayOffset = false;
                    int     width    = comboBox.Width;
                    int     height   = comboBox.Height;
                    FCPoint location = new FCPoint(width - 20, 0);
                    dropDownButton.Location = location;
                    FCSize size = new FCSize(20, height);
                    dropDownButton.Size = size;
                    return(dropDownButton);
                }
                else if (clsid == "dropdownmenu")
                {
                    FCComboBoxMenu comboBoxMenu = new FCComboBoxMenu();
                    comboBoxMenu.ComboBox = comboBox;
                    comboBoxMenu.Popup    = true;
                    FCSize size = new FCSize(100, 200);
                    comboBoxMenu.Size = size;
                    return(comboBoxMenu);
                }
            }
            //日期选择
            FCDateTimePicker datePicker = parent as FCDateTimePicker;

            if (datePicker != null)
            {
                if (clsid == "dropdownbutton")
                {
                    RibbonButton dropDownButton = new RibbonButton();
                    dropDownButton.ArrowType     = 4;
                    dropDownButton.DisplayOffset = false;
                    int     width    = datePicker.Width;
                    int     height   = datePicker.Height;
                    FCPoint location = new FCPoint(width - 16, 0);
                    dropDownButton.Location = location;
                    FCSize size = new FCSize(16, height);
                    dropDownButton.Size = size;
                    return(dropDownButton);
                }
                else if (clsid == "dropdownmenu")
                {
                    FCMenu dropDownMenu = new FCMenu();
                    dropDownMenu.Padding = new FCPadding(1);
                    dropDownMenu.Popup   = true;
                    FCSize size = new FCSize(200, 200);
                    dropDownMenu.Size = size;
                    return(dropDownMenu);
                }
            }
            //数字选择
            FCSpin spin = parent as FCSpin;

            if (spin != null)
            {
                if (clsid == "downbutton")
                {
                    RibbonButton downButton = new RibbonButton();
                    downButton.DisplayOffset = false;
                    downButton.ArrowType     = 4;
                    FCSize size = new FCSize(16, 16);
                    downButton.Size = size;
                    return(downButton);
                }
                else if (clsid == "upbutton")
                {
                    RibbonButton upButton = new RibbonButton();
                    upButton.DisplayOffset = false;
                    upButton.ArrowType     = 3;
                    FCSize size = new FCSize(16, 16);
                    upButton.Size = size;
                    return(upButton);
                }
            }
            //容器层
            FCDiv div = parent as FCDiv;

            if (div != null)
            {
                if (clsid == "hscrollbar")
                {
                    FCHScrollBar hScrollBar = new FCHScrollBar();
                    hScrollBar.Visible = false;
                    hScrollBar.Size    = new FCSize(10, 10);
                    return(hScrollBar);
                }
                else if (clsid == "vscrollbar")
                {
                    FCVScrollBar vScrollBar = new FCVScrollBar();
                    vScrollBar.Visible = false;
                    vScrollBar.Size    = new FCSize(10, 10);
                    return(vScrollBar);
                }
            }
            //表格
            FCGrid grid = parent as FCGrid;

            if (grid != null)
            {
                if (clsid == "edittextbox")
                {
                    return(new FCTextBox());
                }
            }
            return(base.createInternalControl(parent, clsid));
        }
Exemple #16
0
        /// <summary>
        /// 添加类
        /// </summary>
        public void addClass()
        {
            XmlDocument xmlDoc = m_xml.XmlDoc;

            if (m_collectionName == "TabPages")
            {
                FCTabControl tabControl = m_target as FCTabControl;
                FCTabPage    tabPage    = new FCTabPage();
                tabControl.addControl(tabPage);
                String newControlName = UITemplate.CreateControlName(tabPage, m_xml);
                tabPage.Name = newControlName;
                tabPage.Text = newControlName;
                XmlNode tabControlNode = m_xml.Nodes[tabControl];
                XmlNode tabpageNode    = m_xml.XmlDoc.CreateNode(XmlNodeType.Element, "div", "");
                tabControlNode.AppendChild(tabpageNode);
                XmlAttribute xmlAtr1 = xmlDoc.CreateAttribute("name");
                xmlAtr1.Value = tabPage.Text;
                tabpageNode.Attributes.Append(xmlAtr1);
                XmlAttribute xmlAtr2 = xmlDoc.CreateAttribute("text");
                xmlAtr2.Value = tabPage.Text;
                tabpageNode.Attributes.Append(xmlAtr2);
                XmlAttribute xmlAtr3 = xmlDoc.CreateAttribute("type");
                xmlAtr3.Value = "tabpage";
                tabpageNode.Attributes.Append(xmlAtr3);
                m_xml.m_controls.Add(tabPage);
                m_xml.Nodes[tabPage] = tabpageNode;
                FCTreeNode node = new FCTreeNode();
                node.setString(tabPage.Name);
                m_tvCollection.appendNode(node);
                node.Row.Tag = tabPage;
                m_tvCollection.update();
                m_tvCollection.selectNextRow();
                tabControl.update();
            }
            else if (m_collectionName == "Columns")
            {
                FCGrid       grid   = m_target as FCGrid;
                FCGridColumn column = new FCGridColumn();
                grid.addColumn(column);
                String newControlName = UITemplate.CreateControlName(column, m_xml);
                column.Name = newControlName;
                column.Text = newControlName;
                XmlNode gridNode    = m_xml.Nodes[grid];
                XmlNode columnsNode = null;
                foreach (XmlNode subNode in gridNode.ChildNodes)
                {
                    if (subNode.Name.ToLower() == "columns" || subNode.Name.ToLower() == "tr")
                    {
                        columnsNode = subNode;
                        break;
                    }
                }
                if (columnsNode == null)
                {
                    columnsNode = xmlDoc.CreateNode(XmlNodeType.Element, "tr", "");
                    gridNode.AppendChild(columnsNode);
                }
                XmlNode columnNode = m_xml.XmlDoc.CreateNode(XmlNodeType.Element, "th", "");
                columnNode.InnerText = column.Text;
                columnsNode.AppendChild(columnNode);
                XmlAttribute xmlAtr1 = xmlDoc.CreateAttribute("name");
                xmlAtr1.Value = column.Text;
                columnNode.Attributes.Append(xmlAtr1);
                m_xml.m_controls.Add(column);
                m_xml.Nodes[column] = columnNode;
                FCTreeNode node = new FCTreeNode();
                node.setString(column.Name);
                m_tvCollection.appendNode(node);
                node.Row.Tag = column;
                grid.update();
            }
            m_tvCollection.update();
            m_tvCollection.selectNextRow();
            Native.invalidate();
            m_designerDiv.saveUndo();
        }
Exemple #17
0
        /// <summary>
        /// 重新布局
        /// </summary>
        public override void update()
        {
            if (Native == null)
            {
                return;
            }
            base.update();
            FCPadding padding = Padding;
            int       left = padding.left, top = padding.top;
            int       width       = Width - padding.left - padding.right;
            int       height      = Height - padding.top - padding.bottom;
            int       tabPageSize = m_tabPages.size();

            for (int i = 0; i < tabPageSize; i++)
            {
                FCTabPage tabPage      = m_tabPages.get(i);
                FCButton  headerButton = tabPage.HeaderButton;
                if (headerButton.Visible)
                {
                    FCPadding margin         = headerButton.Margin;
                    int       tw             = headerButton.Width + margin.left + margin.right;
                    int       th             = headerButton.Height + margin.top + margin.bottom;
                    FCRect    bounds         = new FCRect();
                    FCPoint   headerLocation = new FCPoint();
                    int       layout         = 0;
                    switch (m_layout)
                    {
                    case FCTabPageLayout.Bottom:
                        layout = 0;
                        break;

                    case FCTabPageLayout.Left:
                        layout = 1;
                        break;

                    case FCTabPageLayout.Right:
                        layout = 2;
                        break;

                    case FCTabPageLayout.Top:
                        layout = 3;
                        break;
                    }
                    tabStyle(layout, ref bounds, ref padding,
                             ref margin, left, top, width, height,
                             tw, th, ref headerLocation);
                    tabPage.Bounds         = bounds;
                    tabPage.HeaderLocation = headerLocation;
                    if (!m_useAnimation)
                    {
                        tabPage.HeaderButton.Location = headerLocation;
                    }
                    if (m_animationState > 0)
                    {
                        if (m_layout == FCTabPageLayout.Left || m_layout == FCTabPageLayout.Right)
                        {
                            headerLocation.y = headerButton.Top;
                        }
                        else if (m_layout == FCTabPageLayout.Bottom || m_layout == FCTabPageLayout.Top)
                        {
                            headerLocation.x = headerButton.Left;
                        }
                    }
                    headerButton.Location = headerLocation;
                    left += tw;
                    top  += th;
                }
                else
                {
                    tabPage.Visible = false;
                }
            }
        }
Exemple #18
0
        /// <summary>
        /// 页头拖动中
        /// </summary>
        /// <param name="tabPage">页</param>
        public virtual void onDraggingTabHeader(FCTabPage tabPage)
        {
            FCButton headerButton = tabPage.HeaderButton;
            int      moving       = headerButton.Left;

            if (m_layout == FCTabPageLayout.Left || m_layout == FCTabPageLayout.Right)
            {
                moving = headerButton.Top;
            }
            int tabPageSize = m_tabPages.size();

            for (int i = 0; i < tabPageSize; i++)
            {
                FCTabPage page = m_tabPages.get(i);
                if (page != tabPage)
                {
                    FCButton tpHeader = page.HeaderButton;
                    if (tpHeader.Visible)
                    {
                        int pos   = page.HeaderLocation.x;
                        int size  = tpHeader.Width;
                        int sSize = headerButton.Width;
                        if (m_layout == FCTabPageLayout.Left || m_layout == FCTabPageLayout.Right)
                        {
                            pos   = page.HeaderLocation.y;
                            size  = tpHeader.Height;
                            sSize = headerButton.Height;
                        }
                        bool instead = false;
                        //向左交换
                        if (moving > pos)
                        {
                            if (moving > pos &&
                                moving < pos + size / 2)
                            {
                                instead = true;
                            }
                        }
                        if (moving < pos)
                        {
                            if (moving + sSize > pos + size / 2 &&
                                moving + sSize < pos + size)
                            {
                                instead = true;
                            }
                        }
                        //向右交换
                        if (instead)
                        {
                            FCPoint sLocation = tabPage.HeaderLocation;
                            if (m_layout == FCTabPageLayout.Left || m_layout == FCTabPageLayout.Right)
                            {
                                tabPage.HeaderLocation = new FCPoint(tabPage.HeaderLocation.x, pos);
                                page.HeaderLocation    = new FCPoint(page.HeaderLocation.x, sLocation.y);
                            }
                            else
                            {
                                tabPage.HeaderLocation = new FCPoint(pos, tabPage.HeaderLocation.y);
                                page.HeaderLocation    = new FCPoint(sLocation.x, page.HeaderLocation.y);
                            }
                            int oIndex = m_tabPages.IndexOf(tabPage);
                            int nIndex = m_tabPages.IndexOf(page);
                            m_tabPages.set(oIndex, page);
                            m_tabPages.set(nIndex, tabPage);
                            m_selectedIndex = nIndex;
                            break;
                        }
                    }
                }
            }
            drawMoving();
        }
Exemple #19
0
 /// <summary>
 /// 绘制移动
 /// </summary>
 protected void drawMoving()
 {
     if (m_animationState > 0)
     {
         bool      drawing         = false;
         int       tabPageSize     = m_tabPages.size();
         FCTabPage selectedTabPage = SelectedTabPage;
         for (int i = 0; i < tabPageSize; i++)
         {
             FCTabPage tabPage = m_tabPages.get(i);
             if (tabPage == selectedTabPage && m_animationState == 1)
             {
                 continue;
             }
             FCButton headerButton = tabPage.HeaderButton;
             if (headerButton.Visible)
             {
                 int moving = headerButton.Left;
                 int pos    = tabPage.HeaderLocation.x;
                 if (m_layout == FCTabPageLayout.Left || m_layout == FCTabPageLayout.Right)
                 {
                     pos    = tabPage.HeaderLocation.y;
                     moving = headerButton.Top;
                 }
                 if (pos != moving)
                 {
                     int relative = moving;
                     int sub      = Math.Abs(pos - relative);
                     int step     = 20;
                     if (m_useAnimation)
                     {
                         if (tabPage == selectedTabPage)
                         {
                             if (sub > 200)
                             {
                                 step = sub / 200 * 100;
                             }
                         }
                         else
                         {
                             step = sub;
                         }
                     }
                     else
                     {
                         step = sub;
                     }
                     if (relative != pos)
                     {
                         if (pos > relative + step)
                         {
                             relative += step;
                         }
                         else if (pos < relative - step)
                         {
                             relative -= step;
                         }
                         else
                         {
                             relative = pos;
                         }
                         if (m_layout == FCTabPageLayout.Left || m_layout == FCTabPageLayout.Right)
                         {
                             headerButton.Top = relative;
                         }
                         else
                         {
                             headerButton.Left = relative;
                         }
                         drawing = true;
                     }
                 }
             }
         }
         //绘制
         if (!drawing)
         {
             if (m_animationState == 2)
             {
                 m_animationState = 0;
             }
         }
         update();
         invalidate();
     }
 }