Ejemplo n.º 1
0
        private void SetGroupBox(GroupBox gb)
        {
            try
            {
                if (group.Controls.Count > 0)
                {
                    gb.Location = new Point(m_OffsetXGroupBox,
                                            group.Controls[group.Controls.Count - 1].Location.Y +
                                            group.Controls[group.Controls.Count - 1].Height + m_IntervalHeightBetweenGroupBoxes);
                }
                else
                {
                    gb.Location = new Point(m_OffsetXGroupBox, m_IntervalHeightBetweenGroupBoxes);
                }

                //计算一行中可以包含多少个UCMould
                int mouldCountInLine = (m_ActualWidth - m_OffsetXGroupBox * 2 - m_OffsetXUCMould * 2 - m_IntervalWidthBetweenMoulds) / (m_WidthMould + m_IntervalWidthBetweenMoulds);

                if (mouldCountInLine == 0)
                {
                    return;
                }

                //Groupbox中的行数
                int lineCount = Convert.ToInt32(Math.Ceiling(gb.Controls.Count / (mouldCountInLine * 1.0)));
                gb.Height = m_OffsetYUCMould * 2 + (m_HeightMould + m_IntervalHeightBetweenMoulds) * lineCount - m_IntervalHeightBetweenMoulds;
                gb.Width  = m_ActualWidth - m_OffsetXGroupBox * 2;
                gb.Tag    = mouldCountInLine + " " + gb.Controls.Count;//在Tag中记录此GroupBox中一行可以容纳多少UCMould 和 此GroupBox中包含的所有的UCMould

                for (int rowIndex = 0; rowIndex < lineCount; rowIndex++)
                {
                    for (int columnIndex = 0; columnIndex < mouldCountInLine; columnIndex++)
                    {
                        if (rowIndex * mouldCountInLine + columnIndex < gb.Controls.Count)
                        {
                            UCMould mould = gb.Controls[rowIndex * mouldCountInLine + columnIndex] as UCMould;
                            if (mould != null)
                            {
                                int startPosition = m_OffsetXUCMould + m_IntervalWidthBetweenMoulds / 2;
                                int positionX     = startPosition + columnIndex * (m_WidthMould + m_IntervalWidthBetweenMoulds);
                                int positionY     = m_OffsetYUCMould + (m_HeightMould + m_IntervalHeightBetweenMoulds) * rowIndex;
                                mould.Location = new Point(positionX, positionY);
                            }
                        }
                    }
                }

                group.Controls.Add(gb);
                group.Width  = m_ActualWidth;
                group.Height = gb.Location.Y + gb.Height + m_IntervalHeightBetweenGroupBoxes;
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 点击某个小模块
        /// </summary>
        /// <param name="sendr"></param>
        /// <param name="e"></param>
        private void moule_MouldFunClick(object sendr, MouldEventArgs e)
        {
            UCMould mould = sendr as UCMould;

            if ((mould == null) || (mould.Tag == null))
            {
                return;
            }
            DrectSoft.FrameWork.IPlugIn plg = m_App.Manager.Runner.LoadPlugIn(e.PlugInfo.AssemblyName, e.PlugInfo.AssemblyStartupClass, true);
            if (plg == null)
            {
                m_App.CustomMessageBox.MessageShow("加载" + ((PlugInConfiguration)mould.Tag).MenuCaption + "失败!");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 加载界面图片
        /// </summary>
        private void InitGroup()
        {
            try
            {
                if (m_ListCaption == null)
                {
                    m_ListCaption = new List <string>();
                }
                if (m_ListCaption.Count == 0)
                {
                    m_ListCaption.Add("");
                    m_ListCaption.Add("");
                    m_ListCaption.Add("");
                }
                if (m_ListCaption.Count == 1)
                {
                    m_ListCaption.Add("");
                    m_ListCaption.Add("");
                }
                if (m_ListCaption.Count == 2)
                {
                    m_ListCaption.Add("");
                }
                var listModuleTemp0 = from info in m_App.PrivilegeMenu
                                      where info.MenuParentCaption.Equals(m_ListCaption[0])
                                      select info;
                var listModuleTemp1 = from info in m_App.PrivilegeMenu
                                      where info.MenuParentCaption.Equals(m_ListCaption[1])
                                      select info;
                var listModuleTemp2 = from info in m_App.PrivilegeMenu
                                      where info.MenuParentCaption.Equals(m_ListCaption[2])
                                      select info;

                List <PlugInConfiguration> list0 = listModuleTemp0.ToList();
                List <PlugInConfiguration> list1 = listModuleTemp1.ToList();
                List <PlugInConfiguration> list2 = listModuleTemp2.ToList();

                GroupBox GroupBox0 = new GroupBox();
                GroupBox GroupBox1 = new GroupBox();
                GroupBox GroupBox2 = new GroupBox();

                GroupBox0.BackColor = Color.Transparent;
                GroupBox1.BackColor = Color.Transparent;
                GroupBox2.BackColor = Color.Transparent;

                //group.AutoScroll = true;
                if (list0 != null && list0.Count > 0)
                {
                    #region 设置GroupBox0
                    GroupBox0.Text = m_ListCaption[0];
                    GroupBox0.Font = myFont;
                    for (int i = 0; i < list0.Count; i++)
                    {
                        PlugInConfiguration plugInfo = list0[i];
                        if (!String.IsNullOrEmpty(plugInfo.IconName))
                        {
                            plugInfo.Icon = DrectSoft.Resources.ResourceManager.GetMiddleIcon(plugInfo.IconName, IconType.Normal);
                        }

                        UCMould moule = new UCMould(plugInfo);
                        moule.EnterSingleOrDoubleClick = m_EnterSingleOrDoubleClick;
                        moule.MouldFunClick           += new UCMould.MouldFunClickEventHandler(moule_MouldFunClick);
                        GroupBox0.Controls.Add(moule);
                    }
                    SetGroupBox(GroupBox0);
                    #endregion
                }
                if (list1 != null && list1.Count > 0)
                {
                    #region 设置GroupBox1
                    GroupBox1.Text = m_ListCaption[1];
                    GroupBox1.Font = myFont;
                    for (int i = 0; i < list1.Count; i++)
                    {
                        PlugInConfiguration plugInfo = list1[i];
                        if (!String.IsNullOrEmpty(plugInfo.IconName))
                        {
                            plugInfo.Icon = DrectSoft.Resources.ResourceManager.GetMiddleIcon(plugInfo.IconName, IconType.Normal);
                        }

                        UCMould moule = new UCMould(plugInfo);
                        moule.EnterSingleOrDoubleClick = m_EnterSingleOrDoubleClick;
                        moule.MouldFunClick           += new UCMould.MouldFunClickEventHandler(moule_MouldFunClick);
                        GroupBox1.Controls.Add(moule);
                    }

                    SetGroupBox(GroupBox1);
                    #endregion
                }
                if (list2 != null && list2.Count > 0)
                {
                    #region 设置GroupBox2
                    GroupBox2.Text = m_ListCaption[2];
                    GroupBox2.Font = myFont;
                    for (int i = 0; i < list2.Count; i++)
                    {
                        PlugInConfiguration plugInfo = list2[i];
                        if (!String.IsNullOrEmpty(plugInfo.IconName))
                        {
                            plugInfo.Icon = DrectSoft.Resources.ResourceManager.GetMiddleIcon(plugInfo.IconName, IconType.Normal);
                        }

                        UCMould moule = new UCMould(plugInfo);
                        moule.EnterSingleOrDoubleClick = m_EnterSingleOrDoubleClick;
                        moule.MouldFunClick           += new UCMould.MouldFunClickEventHandler(moule_MouldFunClick);
                        GroupBox2.Controls.Add(moule);
                    }

                    SetGroupBox(GroupBox2);
                    #endregion
                }
                ProcessGroupBox();
            }
            catch (Exception)
            {
                throw;
            }
        }