コード例 #1
0
ファイル: ResFileList.cs プロジェクト: paopaofeng/dp2
		// 菜单:修改一行
		void button_modifyFile_Click(object sender, System.EventArgs e)
		{
			if (this.SelectedItems.Count == 0) 
			{
				MessageBox.Show(this, "尚未选择要修改的行...");
				return ;
			}
			ResObjectDlg dlg = new ResObjectDlg();
            dlg.Font = GuiUtil.GetDefaultFont();
            dlg.textBox_serverName.Text = ListViewUtil.GetItemText(this.SelectedItems[0], COLUMN_ID);
			dlg.textBox_state.Text = ListViewUtil.GetItemText(this.SelectedItems[0], COLUMN_STATE);
			dlg.textBox_mime.Text = ListViewUtil.GetItemText(this.SelectedItems[0], COLUMN_MIME);
			dlg.textBox_localPath.Text = ListViewUtil.GetItemText(this.SelectedItems[0], COLUMN_LOCALPATH);
			dlg.textBox_size.Text = ListViewUtil.GetItemText(this.SelectedItems[0], COLUMN_SIZE);
			dlg.textBox_timestamp.Text = ListViewUtil.GetItemText(this.SelectedItems[0], COLUMN_TIMESTAMP);

			dlg.ShowDialog(this);

			if (dlg.DialogResult != DialogResult.OK)
				return;

			Cursor cursorSave = Cursor;
			Cursor = Cursors.WaitCursor;
			this.Enabled = false;

			DigitalPlatform.Xml.ElementItem item = GetFileItem(dlg.textBox_serverName.Text);

			if (item != null) 
			{
				item.SetAttrValue("__mime", dlg.textBox_mime.Text);
				item.SetAttrValue("__localpath", dlg.textBox_localPath.Text);
				item.SetAttrValue("__state", this.NewFileState);
				item.SetAttrValue("__size", dlg.textBox_size.Text);
				item.SetAttrValue("__timestamp", dlg.textBox_timestamp.Text);

				m_bChanged = true;
			}
			else 
			{
				Debug.Assert(false, "xmleditor中居然不存在id为["
					+ dlg.textBox_serverName.Text 
					+ "]的<dprms:file>元素");
			}

			this.Enabled = true;
			Cursor = cursorSave;


		}
コード例 #2
0
ファイル: ResFileList.cs プロジェクト: paopaofeng/dp2
		void ItemCreated(object sender,
			DigitalPlatform.Xml.ItemCreatedEventArgs e)
		{
			if (e.item is AttrItem)
			{
				ElementItem parent = e.item.parent;

				if (parent == null)
					return;

				if (this.IsFileElement(parent) == false)
					return;

				/*
				string strId = parent.GetAttrValue("id");
				if (strId == null || strId == "")
					return;
				*/

				if (e.item.Name == "id") 
				{
					ChangeFileAttr((AttrItem)e.item,
						"",
						e.item.Value);
				}
				else 
				{
					ChangeFileAttr((AttrItem)e.item,
						null,
						e.item.Value);
				}

				return;
			}


			if (!(e.item is ElementItem))
				return;

			if (IsFileElement(e.item) == false)
				return;

			ElementItem element = (ElementItem)e.item;


			// 看看创建时是否已经有id属性
			string strID = element.GetAttrValue("id");

			// 客户端
			if (strID == null || strID == "")
			{
				NewLine(element,
					true);

				ResObjectDlg dlg = new ResObjectDlg();
                dlg.Font = GuiUtil.GetDefaultFont();
                dlg.ShowDialog(this);
				if (dlg.DialogResult != DialogResult.OK) 
				{
					// e.Cancel = true;
					// 删除刚刚创建的element
					ElementItem parent = element.parent;
					parent.Remove(element);
					return;
				}

				// 直接对xmleditor进行修改
				element.SetAttrValue("__mime",dlg.textBox_mime.Text);
				element.SetAttrValue("__localpath",dlg.textBox_localPath.Text);
				element.SetAttrValue("__size",dlg.textBox_size.Text);

				strID =  NewFileId();

				// 用到了id
				if (m_tableFileId.Contains((object)strID) == false)
					m_tableFileId.Add(strID, (object)true);

				element.SetAttrValue("id", strID);

				/*
				SetItemProperty(editor, 
					(ElementItem)e.item,
					dlg.textBox_mime.Text,
					dlg.textBox_localPath.Text,
					dlg.textBox_size.Text);
				NewLine((ElementItem)e.item,
					true);
				*/

			}
			else // 来自服务器端的
			{

				string strState = element.GetAttrValue("__state");

				if (strState == null || strState == "")
				{
					NewLine(element,
						false);
					GetMetaDataParam(element);
				}
				else 
				{
					
					NewLine(element,
						IsNewFileState(strState));


					// 跟踪全部xml属性
					ChangeLine(strID, 
						null,	// newid
						element.GetAttrValue("__state"),
						element.GetAttrValue("__localpath"),
						element.GetAttrValue("__mime"),
						element.GetAttrValue("__size"),
						element.GetAttrValue("__timestamp"));
				}
			}

		}