Beispiel #1
0
        public override void OnLoad()
        {
            base.OnLoad();
            for (int i = 0; i < 10; i++)
            {
                GridColumn column = new GridColumn();
                column.Width = 64;
                AddColumn(column);
            }
            Update();
            GridRow row = null;

            for (int i = 0; i < 20; i++)
            {
                if (i == 0 || i == 10)
                {
                    row        = new GridRow();
                    row.Height = 64;
                    AddRow(row);
                }
                int col = i;
                if (i >= 10)
                {
                    col -= 10;
                }
                GridIconCell gridIconCell = new GridIconCell();
                row.AddCell(col, gridIconCell);
            }
            ResourcePath   = DataCenter.GetAppPath() + "\\config\\icons\\";
            m_macroService = DataCenter.MacroService;
            m_macroService.RegisterListener(m_macroService.GetListRequestID, new ListenerMessageCallBack(MacroDatasCallBack));
            m_macroService.RegisterListener(m_macroService.OperatorRequestID, new ListenerMessageCallBack(MacroDatasCallBack));
            RegisterEvent(new ControlInvokeEvent(Invoke), EVENTID.INVOKE);
        }
Beispiel #2
0
        /// <summary>
        /// 单元格点击方法
        /// </summary>
        /// <param name="cell">单元格</param>
        /// <param name="mp">坐标</param>
        /// <param name="button">按钮</param>
        /// <param name="clicks">点击次数</param>
        /// <param name="delta">滚轮值</param>
        public override void OnCellClick(GridCell cell, POINT mp, MouseButtonsA button, int clicks, int delta)
        {
            base.OnCellClick(cell, mp, button, clicks, delta);
            String image = cell.GetString();

            if (image != null && image.Length > 0)
            {
                GridIconCell iconCell = cell as GridIconCell;
                String       macroID  = iconCell.ID;
                Macro        macro    = new Macro();
                m_macroService.GetMacroByID(macroID, ref macro);
                m_macroService.Run(macro);
            }
        }
Beispiel #3
0
 public override void OnKeyDown(char key)
 {
     if (key >= 49 && key <= 57)
     {
         int          index    = CStrA.ConvertStrToInt(key.ToString()) - 1;
         GridIconCell iconCell = GetRow(1).GetCell(index) as GridIconCell;
         iconCell.KeyPress = true;
         String macroID = iconCell.ID;
         Macro  macro   = new Macro();
         if (m_macroService.GetMacroByID(macroID, ref macro))
         {
             m_macroService.Run(macro);
         }
         Invalidate();
         iconCell.KeyPress = false;
     }
 }
Beispiel #4
0
        /// <summary>
        /// 调用控件线程方法
        /// </summary>
        /// <param name="sender">调用者</param>
        /// <param name="args">参数</param>
        private void Invoke(object sender, object args)
        {
            CMessage     message = (CMessage)args;
            List <Macro> macros  = new List <Macro>();

            m_macroService.GetMacros(macros);
            GridRow row        = null;
            int     macrosSize = macros.Count;

            for (int i = 0; i < 20; i++)
            {
                if (i < 10)
                {
                    row = GetRow(1);
                }
                else
                {
                    row = GetRow(0);
                }
                int col = i;
                if (i >= 10)
                {
                    col -= 10;
                }
                GridIconCell iconCell = row.GetCell(col) as GridIconCell;
                if (i < macrosSize)
                {
                    Macro macro = macros[i];
                    iconCell.ID = macro.m_macroID;
                    iconCell.SetString(macro.m_icon);
                }
                else
                {
                    iconCell.ID = "";
                    iconCell.SetString("");
                }
            }
            Update();
            Invalidate();
        }
Beispiel #5
0
        /// <summary>
        /// 加载图标
        /// </summary>
        private void LoadIcons()
        {
            String dir = DataCenter.GetAppPath() + "\\config\\icons\\";

            m_gridIcons.ResourcePath = dir;
            List <String> files = new List <String>();

            CFileA.GetFiles(dir, files);
            int filesSize   = files.Count;
            int columnsSize = m_gridIcons.GetColumns().Count;

            m_gridIcons.BeginUpdate();
            GridRow row = null;

            for (int i = 0; i < filesSize; i++)
            {
                int col = i;
                if (i >= columnsSize)
                {
                    col = i % columnsSize;
                }
                if (col == 0)
                {
                    row        = new GridRow();
                    row.Height = 64;
                    m_gridIcons.AddRow(row);
                }
                String file = files[i];
                file = file.Substring(file.LastIndexOf('\\') + 1);
                GridIconCell iconCell = new GridIconCell();
                iconCell.SetString(file);
                row.AddCell(col, iconCell);
            }
            m_gridIcons.EndUpdate();
            m_gridIcons.Invalidate();
        }