Esempio n. 1
0
        void importPicBtn_Click(object sender, EventArgs e)
        {
            TreeNode currNode = this.classTreeView.SelectedNode;

            if (currNode == null)
            {
                SVMessageBox msgBox = new SVMessageBox();
                msgBox.content(Resource.提示, Resource.请先选中分类节点);
                msgBox.Show();

                return;
            }

            if (currNode.Level != 1)
            {
                SVMessageBox msgBox = new SVMessageBox();
                msgBox.content(Resource.提示, Resource.请先选中分类节点);
                msgBox.Show();
                return;
            }

            if (this.textBoxName.Text == String.Empty)
            {
                SVMessageBox msgBox = new SVMessageBox();
                msgBox.content(Resource.提示, Resource.输入名称);
                msgBox.Show();

                return;
            }

            String timeString = DateTime.Now.ToFileTime().ToString();

            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "(JPG)|*.jpg|(BMP)|*.bmp|(PNG)|*.png";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                convertBitmap(openFileDialog.FileName, timeString);
                _pixmapManage.insertItemByClass(currNode.Text, this.textBoxName.Text, timeString);

                ListViewItem listItem = new ListViewItem();
                listItem.Text = this.textBoxName.Text;
                this.listView.Items.Add(listItem);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 确定
        /// </summary>
        /// <param Name="sender"></param>
        /// <param Name="e"></param>
        private void okBtn_Click(object sender, EventArgs e)
        {
            SVPageNode node = _svTreeView.SelectedNode as SVPageNode;

            if (node == null || node.Level != 2)
            {
                SVMessageBox msgBox = new SVMessageBox();
                msgBox.content(Resource.提示, Resource.请选择页面);
                msgBox.ShowDialog();
                return;
            }

            SVPageWidget widget = node.Addtionobj as SVPageWidget;
            ///模板文件
            String file = Path.Combine(SVProData.TemplatePath, node.Text);

            if (File.Exists(file))
            {
                SVMessageBox msgBox = new SVMessageBox();
                msgBox.content(Resource.提示, node.Text + " " + Resource.模板已经存在);
                msgBox.ShowDialog();
                return;
            }

            //保存文件
            SVXml pageXML = new SVXml();

            pageXML.createRootEle("Page");
            widget.saveXML(pageXML);
            pageXML.writeXml(file);

            //保存缩略图
            Bitmap ctlbitmap = new Bitmap(widget.Width, widget.Height);

            widget.DrawToBitmap(ctlbitmap, widget.ClientRectangle);
            ctlbitmap.Save(file + ".jpg");

            //记录日志
            SVLog.WinLog.Info(String.Format("模板{0}保存成功", node.Text));

            this.DialogResult = System.Windows.Forms.DialogResult.Yes;
        }
Esempio n. 3
0
        /// <summary>
        /// 删除模板
        /// </summary>
        /// <param Name="sender"></param>
        /// <param Name="e"></param>
        void delItem_Click(object sender, EventArgs e)
        {
            ListViewItem item = listView.SelectedItems[0];

            SVMessageBox msg = new SVMessageBox();

            msg.content("提示", String.Format("是否删除模板 {0}?", item.Text));
            if (msg.ShowDialog() == System.Windows.Forms.DialogResult.No)
            {
                return;
            }

            ///将文件句柄释放,不然会被占用。无法删除文件。
            if (this.pictureBox.Image != null)
            {
                this.pictureBox.Image.Dispose();
                this.pictureBox.Image = null;
                GC.Collect();
            }

            ///获取文件路径
            String picFile = Path.Combine(SVProData.TemplatePath, item.Text + ".jpg");
            String file    = Path.Combine(SVProData.TemplatePath, item.Text);

            try
            {
                ///把文件从磁盘移除
                File.Delete(picFile);
                File.Delete(file);
                ///列表中删除
                listView.Items.Remove(item);
            }
            catch
            {
                SVLog.WinLog.Info("文件已经打开,删除不成功");
            }
        }