Exemple #1
0
 private bool hasChanges(PropertiesDialog dialog, DBFile item)
 {
     if (!dialog.ItemName.Equals(item.Name))  return true;
     if (item is PhotoAlbumDB.Entities.Image && item != null)
     {
         PhotoAlbumDB.Entities.Image img =
             item as PhotoAlbumDB.Entities.Image;
         if (!dialog.ItemDescription.Equals(img.Description))
         {
             return true;
         }
     }
     return false;
 }
Exemple #2
0
        private void Properties_OnClick(System.Object sender, System.EventArgs e)
        {
            TreeNode selectedNode = MainFormTreeView.GetNodeAt(treeMouseLocation);
            if (selectedNode != null && selectedNode.Tag is DBFile)
            {
                DBFile item = selectedNode.Tag as DBFile;
                PropertiesDialog dialog = new PropertiesDialog();
                try
                {
                    // fill the properties dialog first
                    dialog.ItemShared = item.Shared;
                    dialog.ItemName = item.Name;
                    dialog.ItemOwner = item.Owner;
                    dialog.ItemCreated = item.DateModified.ToString();
                    dialog.ItemSize = item.Size == 0 ?
                        "0 bytes" : item.Size.ToString("## ### ### ### ### bytes");
                    if (item is PhotoAlbumDB.Entities.Image && item != null)
                    {
                        PhotoAlbumDB.Entities.Image img =
                            item as PhotoAlbumDB.Entities.Image;
                        dialog.ItemDescription = img.Description;
                    }

                    if (dialog.ShowDialog() == DialogResult.OK &&
                        hasChanges(dialog, item))
                    {
                        item.Name = dialog.ItemName;
                        if (item is PhotoAlbumDB.Entities.Image && item != null)
                        {
                            PhotoAlbumDB.Entities.Image img =
                                item as PhotoAlbumDB.Entities.Image;
                            img.Description = dialog.ItemDescription;
                        }
                        item.update();
                        selectedNode.Text = item.Name;
                    }
                    dialog.Dispose();
                }
                catch (ServerInfoException ex)
                {
                    MessageBox.Show(dialog, ex.Message, "Info",
                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    dialog.Dispose();
                }
                catch (ObjectDBException ex)
                {
                    MessageBox.Show(this, ex.Message, "Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    dialog.Dispose();
                }
            }
        }