Exemplo n.º 1
0
        /// <summary>
        /// 创建右键剪切选项
        /// </summary>
        /// <returns></returns>
        private ToolStripMenuItem CreateCutMenuItem()
        {
            ToolStripMenuItem tsmiCutNode = new ToolStripMenuItem();

            tsmiCutNode.Image  = UIResMang.GetImage("Cut_16x16");
            tsmiCutNode.Name   = "tsmiCutNode";
            tsmiCutNode.Size   = new System.Drawing.Size(152, 22);
            tsmiCutNode.Text   = UIResMang.GetString("Cut");
            tsmiCutNode.Click += CutNode_Click;

            return(tsmiCutNode);
        }
Exemplo n.º 2
0
        private void LargeIconMenuItem_Clicked(object sender, EventArgs e)
        {
            ToolStripMenuItem tsmi = sender as ToolStripMenuItem;

            tsmi.Image = UIResMang.GetImage("CheckMark_128");

            this.SelectedStyleItem = tsmi;
            MarkSelectedStyle(this.SelectedStyleItem);

            if (null != MyCache.Templates)
            {
                DisplayAsLargeIcon(MyCache.Templates);
            }
        }
Exemplo n.º 3
0
        public FrmCollections()
        {
            InitializeComponent();

            this.listView.ContextMenuStrip = new ContextMenuStrip();

            ToolStripMenuItem detailItem    = CreateDetailMenuItem();
            ToolStripMenuItem smallIconItem = CreateSmallIconMenuItem();
            ToolStripMenuItem largeIconItem = CreateLargeIconMenuItem();

            this.ViewStyleItems = new List <ToolStripMenuItem>();
            this.ViewStyleItems.Add(detailItem);
            this.ViewStyleItems.Add(smallIconItem);
            this.ViewStyleItems.Add(largeIconItem);

            ToolStripMenuItem groupItem = CreateGroupByMenuItem();
            ToolStripMenuItem typeItem  = CreateGroupByTypeMenuItem();
            ToolStripMenuItem noneItem  = CreateGroupByNoneMenuItem();

            this.GroupByItems = new List <ToolStripMenuItem>();
            this.GroupByItems.Add(typeItem);
            this.GroupByItems.Add(noneItem);
            groupItem.DropDownItems.Add(typeItem);
            groupItem.DropDownItems.Add(noneItem);

            this.RefreshMenuItem = CreateRefreshMenuItem();

            this.listView.ContextMenuStrip.Items.Add(detailItem);
            this.listView.ContextMenuStrip.Items.Add(smallIconItem);
            this.listView.ContextMenuStrip.Items.Add(largeIconItem);
            this.listView.ContextMenuStrip.Items.Add(new ToolStripSeparator());
            this.listView.ContextMenuStrip.Items.Add(groupItem);
            this.listView.ContextMenuStrip.Items.Add(new ToolStripSeparator());
            this.listView.ContextMenuStrip.Items.Add(this.RefreshMenuItem);

            this.SelectedGroupBy   = GroupBy.None;
            noneItem.Image         = UIResMang.GetImage("CheckMark_128");
            this.SelectedStyleItem = largeIconItem;

            if (null == MyCache.Templates)
            {
                LoadTemplates();
            }
            else
            {
                this.SelectedStyleItem.PerformClick();
            }
        }
Exemplo n.º 4
0
        private void dataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
        {
            if (e.RowIndex >= 0 && 4 == e.ColumnIndex)
            {
                bool      isSelected   = (bool)this.dataGridView.Rows[e.RowIndex].Cells["IsSelected"].Value;
                bool      isDetermined = (bool)this.dataGridView.Rows[e.RowIndex].Cells["DPTNameIsDetermined"].Value;
                string    strFileName  = this.dataGridView.Rows[e.RowIndex].Cells["DPTName"].Value.ToString();
                int       textStartPos = 2;
                Image     image        = null;
                Rectangle imgRect      = new Rectangle(e.CellBounds.X + 2, e.CellBounds.Y + 2, e.CellBounds.Height - 6,
                                                       e.CellBounds.Height - 6);
                if (isSelected && !isDetermined)
                {
                    image = UIResMang.GetImage("Help_16x16");

                    textStartPos += e.CellBounds.Height - 6;
                }

                //画单元格的边界线
                Point   p1 = new Point(e.CellBounds.Left + e.CellBounds.Width, e.CellBounds.Top);
                Point   p2 = new Point(e.CellBounds.Left + e.CellBounds.Width, e.CellBounds.Top + e.CellBounds.Height);
                Point   p3 = new Point(e.CellBounds.Left, e.CellBounds.Top + e.CellBounds.Height);
                Point[] ps = new Point[] { p1, p2, p3 };
                using (Brush gridBrush = new SolidBrush(this.dataGridView.GridColor))
                {
                    using (Pen gridLinePen = new Pen(gridBrush, 2))
                    {
                        Font newFont = new Font("宋体", 9, FontStyle.Regular);//自定义字体
                        //判断当前行是否为选中行,如果为选中行,则要修改图片的背景色和文字的字体颜色
                        if ((null != dataGridView.CurrentRow) && (dataGridView.CurrentRow.Index == e.RowIndex))
                        {
                            using (Brush backColorBrush = new SolidBrush(Color.FromArgb(051, 153, 255)))
                            {
                                //以背景色填充单元格
                                e.Graphics.FillRectangle(backColorBrush, e.CellBounds);
                                e.Graphics.DrawLines(gridLinePen, ps);

                                if (isSelected && !isDetermined)
                                {
                                    e.Graphics.DrawImage(image, imgRect);
                                }

                                SizeF sizeText = e.Graphics.MeasureString(strFileName, newFont);
                                e.Graphics.DrawString(strFileName, newFont, Brushes.White, new RectangleF(e.CellBounds.Left + textStartPos,
                                                                                                          e.CellBounds.Top + (e.CellBounds.Height - sizeText.Height) / 2, e.CellBounds.Width - textStartPos,
                                                                                                          sizeText.Height), StringFormat.GenericDefault);

                                e.Handled = true;
                            }
                        }
                        else
                        {
                            using (Brush backColorBrush = new SolidBrush(e.CellStyle.BackColor))
                            {
                                e.Graphics.FillRectangle(backColorBrush, e.CellBounds);
                                e.Graphics.DrawLines(gridLinePen, ps);

                                if (isSelected && !isDetermined)
                                {
                                    e.Graphics.DrawImage(image, imgRect);
                                }

                                SizeF sizeText = e.Graphics.MeasureString(strFileName, e.CellStyle.Font);
                                e.Graphics.DrawString(strFileName, e.CellStyle.Font, Brushes.Black, new RectangleF(e.CellBounds.Left + textStartPos,
                                                                                                                   e.CellBounds.Top + (e.CellBounds.Height - sizeText.Height) / 2, e.CellBounds.Width - textStartPos,
                                                                                                                   sizeText.Height), StringFormat.GenericDefault);

                                e.Handled = true;
                            }
                        }
                    }
                }
            }
        }