Beispiel #1
0
        public void OkDialog()
        {
            if (treeViewFolders.SelectedNode == null || treeViewFolders.SelectedNode.Level == 0)
            {
                // Prompt the user to select a folder if no node is selected or only the top-level node
                // (the server name) is selected.
                MessageDlg.Show(this, Resources.PublishDocumentDlg_OkDialog_Please_select_a_folder);
                return;
            }

            FolderInformation folderInfo = treeViewFolders.SelectedNode.Tag as FolderInformation;

            if (folderInfo == null)
            {
                MessageDlg.Show(this, Resources.PublishDocumentDlg_UploadSharedZipFile_Error_obtaining_server_information);
                return;
            }
            if (!folderInfo.HasWritePermission)
            {
                MessageDlg.Show(this, Resources.PublishDocumentDlg_UploadSharedZipFile_You_do_not_have_permission_to_upload_to_the_given_folder);
                return;
            }

            if (!PanoramaPublishClient.ServerSupportsSkydVersion(folderInfo, _docContainer, this))
            {
                return;
            }

            DialogResult = DialogResult.OK;
        }
        private FolderInformation ConvertFolder(SparkImageViewer.DataModel.FolderInformation source)
        {
            if (!System.IO.Directory.Exists(source.DisplayName))
            {
                return(null);
            }

            var obj = new FolderInformation(source.DisplayName)
            {
                AutoRefreshEnable = source.AutoRefreshEnable,
                //Ignored = source.Ignored,
                RefreshEnable = source.RefreshEnable,
                //RefreshTrigger = source.RefreshTrigger,
                IsTopDirectoryOnly = false,
                Mode = (source.RefreshMode == ThreeState.None) ? FolderCheckMode.None
                    : (source.RefreshMode == ThreeState.False) ? FolderCheckMode.Light
                    : FolderCheckMode.Detail,
                WatchChange = true,
            };

            if (source.Ignored)
            {
                obj.Ignore();
            }
            else
            {
                obj.CancelIgnore();
            }

            return(obj);
        }
Beispiel #3
0
        public void Upload(Control parent)
        {
            string            folderPath  = GetFolderPath(treeViewFolders.SelectedNode);
            var               zipFilePath = tbFilePath.Text;
            FolderInformation folderInfo  = treeViewFolders.SelectedNode.Tag as FolderInformation;

            if (folderInfo != null)
            {
                PanoramaPublishClient.UploadSharedZipFile(parent, folderInfo.Server, zipFilePath, folderPath);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 与えられたフォルダ内のファイルを列挙してライブラリに登録
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public async Task ActivateFolderAsync(string directory)
        {
            //var directory = System.IO.Path.GetDirectoryName(path);
            var info = new FolderInformation(directory)
            {
                IsTopDirectoryOnly = true,
                AutoRefreshEnable  = false,
            };

            await this.ActivateNeighborFilesAsync(new[] { info });
        }
 /// <summary>
 /// Returns a list of files under a given node in the FileTreeView.
 /// </summary>
 /// <param name="node">A node contained in the current FileTreeView</param>
 /// <returns>A string array containing a list of files under a node.</returns>
 public string[] GetFilesUnderNode(TreeNode node)
 {
     string[] results = new string[0];
     foreach (TreeNode n in node.Nodes)
     {
         string[] files = GetFilesUnderNode(n);
         results = Utility.MergeArrays(results, files);
     }
     if (node.Tag != null)
     {
         FolderInformation fi    = (FolderInformation)node.Tag;
         ArrayList         items = (ArrayList)fi.Items;
         if (items != null)
         {
             string[] files = (string[])items.ToArray(typeof(String));
             results = Utility.MergeArrays(results, files);
         }
     }
     return(results);
 }
 private void FileTreeView_AfterSelect(object sender, TreeViewEventArgs e)
 {
     // If neccessary, update the child control.
     if (m_showFiles == ShowFilesBehavior.ChildControl)
     {
         if (e.Node.Tag != null)
         {
             FolderInformation fi   = (FolderInformation)e.Node.Tag;
             object[]          list = ((ArrayList)fi.Items).ToArray();
             if (list.Length > 0)
             {
                 string[] files = new string[list.Length];
                 for (int x = 0; x < list.Length; x++)
                 {
                     //FileNode fn = (FileNode)list[x];
                     files[x] = (string)list[x];
                 }
                 ChildControl.UpdateList(files);
             }
         }
     }
 }
Beispiel #7
0
        /// <summary>
        /// データベースとの接続を初期化
        /// </summary>
        public async Task LoadAsync()
        {
            TagInformation[]     tags;
            FolderInformation[]  folders;
            ExifVisibilityItem[] exifItems;

            using (var connection = await this.Database.ConnectAsync().ConfigureAwait(false))
            {
                await this.Database.InitializeAsync(connection).ConfigureAwait(false);

                tags = await this.TagDatabase.GetAllAsTrackingAsync(connection)
                       .ConfigureAwait(false);

                folders = await this.FolderDatabase.GetAllAsTrackingAsync(connection)
                          .ConfigureAwait(false);

                exifItems = await this.ExifVisibilityDatabase.GetAllAsTrackingAsync(connection)
                            .ConfigureAwait(false);

                //loading test
                await this.Records.AsQueryable(connection).FirstOrDefaultAsync().ConfigureAwait(false);
            }

            this.Tags.SetSource(tags.ToDictionary(x => x.Id, x => x));
            this.Folders.SetSource(folders);
            this.ExifManager.SetSource(exifItems);

            if (folders.Length <= 0 && this.config.IsKnownFolderEnabled)
            {
                this.Folders.TryAddItems(FolderInformation.GetSpecialFolders());
            }


            this.MakeDirectoryTree();

            this.IsLoaded = true;
        }
Beispiel #8
0
        public void OkDialog()
        {
            if (treeViewFolders.SelectedNode == null || treeViewFolders.SelectedNode.Level == 0)
            {
                // Prompt the user to select a folder if no node is selected or only the top-level node
                // (the server name) is selected.
                MessageDlg.Show(this, Resources.PublishDocumentDlg_OkDialog_Please_select_a_folder);
                return;
            }

            FolderInformation folderInfo = treeViewFolders.SelectedNode.Tag as FolderInformation;

            if (folderInfo == null)
            {
                MessageDlg.Show(this, Resources.PublishDocumentDlg_UploadSharedZipFile_Error_obtaining_server_information);
                return;
            }
            if (!folderInfo.HasWritePermission)
            {
                MessageDlg.Show(this, Resources.PublishDocumentDlg_UploadSharedZipFile_You_do_not_have_permission_to_upload_to_the_given_folder);
                return;
            }

            try
            {
                ShareType = PanoramaPublishClient.DecideShareType(folderInfo, _docContainer.DocumentUI);
            }
            catch (PanoramaServerException panoramaServerException)
            {
                MessageDlg.ShowWithException(this, panoramaServerException.Message, panoramaServerException);
                return;
            }

            Assume.IsNotNull(ShareType);
            DialogResult = DialogResult.OK;
        }
//    public void LoadFiles(AbstractFolder[] folderList, AbstractFile[] fileList)
//    {
//      foreach(AbstractFolder folder in folderList)
//        AddTreeNode(folder.FullName);
//
//      foreach(AbstractFile file in fileList)
//        AddTreeNode(file.FullName);
//    }
        /// <summary>
        /// Reads a string array of file names, and populates the control with
        /// nodes and child nodes as appropriate.
        /// </summary>
        /// <param name="nodeName">A string array containing the filenames to
        /// be added to the control.</param>
        public void AddTreeNode(string nodeName)
        {
            string[] parts = nodeName.Split('\\');
            TreeNode n     = this.Nodes[0];

            for (int y = 0; y < parts.Length; y++)
            {
                bool addNodes = true;
                bool isFolder = true;
                if (y == parts.Length - 1)
                {
                    if (parts[y].IndexOfAny(".".ToCharArray()) > 0)
                    {
                        // We can assume that is there is no '.' then this is
                        // not a folder.  This wouldn't work in a non-Halo setting.
                        isFolder = false;
                    }
                }

                if ((!isFolder) && (m_showFiles == ShowFilesBehavior.ChildControl))
                {
                    addNodes = false;
                }

                if (!addNodes)
                {
                    // Add files to the node's Tag for persistance and forwarding
                    // to the child IShowFiles control.
                    string text = parts[parts.Length - 1];
                    if (n.Tag == null)
                    {
                        n.Tag = new FolderInformation();
                    }
                    FolderInformation fi   = (FolderInformation)n.Tag;
                    ArrayList         list = (ArrayList)fi.Items;
                    if (!list.Contains(text))
                    {
                        list.Add(nodeName);
                    }
                }
                else
                {
                    bool nodeFound = false;
                    foreach (TreeNode node in n.Nodes)
                    {
                        if (node.Text == parts[y])
                        {
                            nodeFound = true;
                            n         = node;
                            break;
                        }
                    }
                    if (!nodeFound)
                    {
                        if (!isFolder) // It's a file
                        {
                            BetterTreeNode newNode = new BetterTreeNode(parts[y]);
                            newNode.CollapsedImageIndex = this.FileImageIndex;
                            newNode.ExpandedImageIndex  = this.FileImageIndex;
                            newNode.ImageIndex          = newNode.CollapsedImageIndex;

                            if (n.Nodes.Count == 1)
                            {
                                if (n.Nodes[0] is DummyTreeNode)
                                {
                                    n.Nodes.Clear();
                                }
                            }
                            n.Nodes.Add(newNode);
                            n = newNode;
                        }
                        else // This is another folder.
                        {
                            if (parts[y] != "")
                            {
                                BetterTreeNode newNode = new BetterTreeNode(parts[y]);
                                newNode.CollapsedImageIndex = 2;
                                newNode.ExpandedImageIndex  = 1;
                                newNode.ImageIndex          = newNode.CollapsedImageIndex;
                                newNode.SelectedImageIndex  = newNode.ImageIndex;
                                newNode.Nodes.Add(new DummyTreeNode("Loading Data..."));

                                FolderInformation fi       = new FolderInformation();
                                string            fullPath = "";
                                for (int z = 0; z < y + 1; z++)
                                {
                                    fullPath += parts[z] + "\\";
                                }
                                fullPath    = fullPath.TrimEnd("\\".ToCharArray());
                                fi.FullPath = fullPath;
                                newNode.Tag = fi;

                                if (n.Nodes.Count == 1)
                                {
                                    if (n.Nodes[0] is DummyTreeNode)
                                    {
                                        n.Nodes.Clear();
                                    }
                                }
                                n.Nodes.Add(newNode);
                                n = newNode;
                            }
                        }
                    }
                }
            }
        }
Beispiel #10
0
        private bool PublishToSavedUri(IPanoramaPublishClient publishClient, Uri panoramaSavedUri, string fileName,
            ServerList servers)
        {
            var message = TextUtil.LineSeparate(Resources.SkylineWindow_ShowPublishDlg_This_file_was_last_published_to___0_,
                Resources.SkylineWindow_ShowPublishDlg_Publish_to_the_same_location_);
            if (MultiButtonMsgDlg.Show(this, string.Format(message, panoramaSavedUri),
                    MultiButtonMsgDlg.BUTTON_YES, MultiButtonMsgDlg.BUTTON_NO, false) != DialogResult.Yes)
                return false;

            var server = servers.FirstOrDefault(s => s.URI.Host.Equals(panoramaSavedUri.Host));
            if (server == null)
                return false;

            JToken folders;
            var folderPath = panoramaSavedUri.AbsolutePath;
            try
            {
                folders = publishClient.GetInfoForFolders(server, folderPath.TrimEnd('/').TrimStart('/'));
            }
            catch (WebException)
            {
                return false;
            }

            // must escape uri string as panorama api does not and strings are escaped in schema
            if (folders == null || !folderPath.Contains(Uri.EscapeUriString(folders["path"].ToString()))) // Not L10N
                return false;

            if (!PanoramaUtil.CheckFolderPermissions(folders) || !PanoramaUtil.CheckFolderType(folders))
                return false;

            var fileInfo = new FolderInformation(server, true);
            if (!publishClient.ServerSupportsSkydVersion(fileInfo, this, this))
                return false;

            var zipFilePath = FileEx.GetTimeStampedFileName(fileName);
            if (!ShareDocument(zipFilePath, false))
                return false;

            var serverRelativePath = folders["path"].ToString() + '/'; // Not L10N
            serverRelativePath = serverRelativePath.TrimStart('/');
            publishClient.UploadSharedZipFile(this, server, zipFilePath, serverRelativePath);
            return true; // success!
        }
Beispiel #11
0
#pragma warning restore 1998

        public async Task <bool> IsFolderExistsAsync(FolderInformation folder)
        {
            return(await this.IsFolderExistsAsync(folder.Path));
        }