Esempio n. 1
0
        private void deletePageToolStripButton_Click(object sender, EventArgs e)
        {
            if (localPagesListView.SelectedItems.Count <= 0)
            {
                return;
            }
            if (MessageService.Show("${res:Tree.msg.delete}", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
            {
                return;
            }

            SdsiteXmlDocument doc      = Service.Sdsite.CurrentDocument;
            MyListItem        deleItem = localPagesListView.SelectedItems[0] as MyListItem;

            doc.DeleteItem(deleItem.Element);
            localPagesListView.Items.Remove(deleItem);
        }
Esempio n. 2
0
        /// <summary>
        ///  保存/替换文件
        /// </summary>
        /// <param name="isReplace">true 替换文件 , false 只保存</param>
        /// <returns>保存/替换成功 返回TRUE 失败 FALSE</returns>
        private bool SaveOrReplaceFile(bool isReplace, string fileName)
        {
            SdsiteXmlDocument doc = Service.Sdsite.CurrentDocument;

            if (isReplace)
            {
                DialogResult result = MessageService.Show("${res:Tree.msg.coverFile}", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                if (result == DialogResult.Cancel)
                {
                    return(false);
                }

                //旧文件删除
                foreach (MyListItem item in listViewFodel.Items)
                {
                    if (item is MyListFileItem)
                    {
                        MyListFileItem fileItem = item as MyListFileItem;
                        if (fileName.Equals(fileItem.Element.FileName, StringComparison.CurrentCultureIgnoreCase))
                        {
                            MyListItem deleItem = fileItem as MyListItem;
                            doc.DeleteItem(deleItem.Element);
                            listViewFodel.Items.Remove(deleItem);
                        }
                    }
                }
            }
            //保存新文件
            if (myResourceCurrentItem != null)
            {
                string strSrcFile = Path.Combine(myResourceCurrentItem.Element.AbsoluteFilePath, fileName);
                _image.Save(strSrcFile, _imgFormat);
                FileSimpleExXmlElement fileEle = doc.CreateFileElement(myResourceCurrentItem.Element as FolderXmlElement, strSrcFile);
                InitListView(myResourceCurrentItem, listViewFodel, _resourceCurrentType);

                this.DialogResult = DialogResult.OK;
            }



            return(true);
        }