Beispiel #1
0
		protected override void OnKeyDown(KeyEventArgs e)
		{
			try
			{
				if (e.KeyCode == Keys.Delete)
				{
					FavouriteFolder Fav = null;
					if (SelectedNode.Tag != null && SelectedNode.Tag.ToString() == "Fav Folder")
					{
						Fav = new FavouriteFolder(null, SelectedNode.Text);
						OMEInteraction.UpdateFavourite( Fav);
						Nodes.Remove(SelectedNode);
					}
					else if (SelectedNode.Parent != null && SelectedNode.Parent.Tag != null &&
					         SelectedNode.Parent.Tag.ToString() == "Fav Folder")
					{
						TreeNode tNode = SelectedNode;
						TreeNode parentNode = SelectedNode.Parent;


						if (parentNode.Nodes.Count > 0)
						{
							List<string> lststr = new List<string>();
							foreach (TreeNode tempNode in parentNode.Nodes)
							{
								lststr.Add(tempNode.Text);
							}
							Fav = new FavouriteFolder(lststr, tNode.Parent.Text);
						}
						OMEInteraction.SaveFavourite( Fav);
						SelectedNode.Remove();
					}
				}
			}
			catch (Exception oEx)
			{
				LoggingHelper.ShowMessage(oEx);
			}
		}
Beispiel #2
0
		protected override void OnAfterLabelEdit(NodeLabelEditEventArgs e)
		{
			try
			{
				base.OnAfterLabelEdit(e);
				if (!string.IsNullOrEmpty(e.Label))
				{
					bool checkSameNode = false;
					for (int i = 0; i < Nodes.Count; i++)
					{
						TreeNode tNode = Nodes[i];
						if (tNode.Text == e.Label)
						{
							checkSameNode = true;
							break;
						}
					}
					if (checkSameNode == false)
					{
						e.Node.Text = e.Label;
					}
					else
					{
						MessageBox.Show("The Foldername already exist, Please use some other name.",
						                Helper.GetResourceString(Constants.PRODUCT_CAPTION), MessageBoxButtons.OK, MessageBoxIcon.Error);
						e.CancelEdit = true;
					    return;
					}
				}
				else if (e.Label == string.Empty)
				{
					MessageBox.Show("The Foldername cannot be empty.", Helper.GetResourceString(Constants.PRODUCT_CAPTION),
					                MessageBoxButtons.OK, MessageBoxIcon.Error);
					e.CancelEdit = true;
				    return;
				}
				if (e.Node.Text != folderName)
				{
				    FavouriteFolder fav= OMEInteraction.GetFolderfromDatabaseByFoldername(folderName);
                    FavouriteFolder newFav = new FavouriteFolder(null, e.Node.Text);
                    if (fav != null)
                        OMEInteraction.RenameFolderInDatabase(fav, newFav);
                    else
                        OMEInteraction.SaveFavourite(newFav);
				}
				else
				{
					FavouriteFolder newFav = new FavouriteFolder(null, e.Node.Text);
					OMEInteraction.SaveFavourite( newFav);
				}
			}
			catch (Exception oEx)
			{
				LoggingHelper.ShowMessage(oEx);
			}
		}
Beispiel #3
0
		protected override void OnDragDrop(DragEventArgs e)
		{
			try
			{
				base.OnDragDrop(e);
				e.Effect = DragDropEffects.Move;
				Point pos = PointToClient(new Point(e.X, e.Y));
				TreeNode parentTreeNode = GetNodeAt(pos);
				if (parentTreeNode != null)
				{
					TreeNode dragNode = new TreeNode(Helper.FindRootNode(SelectedNode));
					dragNode.Tag = dragNode.Text;
					dragNode.Name = dragNode.Text;
					dragNode.ImageIndex =
						dragNode.SelectedImageIndex = 1;
					if (dragNode.Tag != null && dragNode.Tag.ToString() != "Fav Folder")
					{
						//dragNode.Tag = this.SelectedNode.Text;
						AddDummyChildNode(dragNode);

						bool checkSameNode = false;
						for (int i = 0; i < parentTreeNode.Nodes.Count; i++)
						{
							TreeNode tNode = parentTreeNode.Nodes[i];
							if (tNode.Text == dragNode.Text)
							{
								checkSameNode = true;
								break;
							}
						}
						if (checkSameNode == false && parentTreeNode.Tag != null && parentTreeNode.Tag.ToString() == "Fav Folder")
						{
							parentTreeNode.Nodes.Add(dragNode);
							FavouriteFolder Fav = new FavouriteFolder(null, parentTreeNode.Text);
							Fav.FolderName = parentTreeNode.Text;
							if (parentTreeNode.Nodes.Count > 0)
							{
								List<string> lststr = new List<string>();
								foreach (TreeNode tnode in parentTreeNode.Nodes)
								{
									lststr.Add(tnode.Text);
								}
								Fav.ListClass = lststr;
							}

							OMEInteraction.SaveFavourite( Fav);
						}
					}
				}
			}
			catch (Exception oEx)
			{
				LoggingHelper.ShowMessage(oEx);
			}
		}