예제 #1
0
 private void FolderViewList_ColumnClick(object sender, ColumnClickEventArgs e)
 {
     if (e.Column == _sorter.SortColumn)
     {
         _sorter.Order = toggleSort(_sorter.Order);
     }
     else
     {
         _sorter.SortColumn = e.Column;
     }
     FolderViewList.Sort();
 }
예제 #2
0
        private void FileTree_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (e.Node.Tag == null)
            {
                return;
            }

            if (e.Node.Tag.ToString() == "folder")
            {
                FolderViewList.Items.Clear();
                JObject jobject = GetJsonFromEndpoint(String.Format("/folders({0})/items", e.Node.Name));
                JArray  items   = jobject["value"] as JArray;
                foreach (JObject item in items)
                {
                    var type = item.Property("type").Value.ToString();

                    // only display sample results
                    if (type != "SampleResult")
                    {
                        continue;
                    }

                    var name    = item.Property("name").Value.ToString();
                    var id      = item.Property("id").Value.ToString();
                    var created = item.Property("createdAt").Value.ToString();

                    var sampleResult         = GetJsonFromEndpoint(String.Format("/sampleresults({0})", id));
                    var sample               = sampleResult.Property("sample").Value as JObject;
                    var replicate            = sample.Property("replicateNumber").Value.ToString();
                    var wellPosition         = sample.Property("wellPosition").Value.ToString();
                    var acquisitionStartTime = sample.Property("acquisitionStartTime").Value.ToString();
                    name = sample.Property("name").Value.ToString();

                    JObject analysis     = (GetJsonFromEndpoint(String.Format("/sampleresults({0})/analyses", id))["value"] as JArray).FirstOrDefault() as JObject;
                    string  analysisName = "unknown";
                    if (analysis != null)
                    {
                        analysisName = analysis.Property("name").Value.ToString();
                    }

                    FolderViewList.Items.Add(new ListViewItem(new string[] { type, analysisName, wellPosition, replicate, name, acquisitionStartTime, created }, 2)
                    {
                        Tag = String.Format("/sampleresults({0})", id)
                    });
                }
            }

            FolderViewList.Sort();
        }
예제 #3
0
        private void SelectAndPreviewNode(TreeNode mainNode)
        {
            //make sure folder is visible in tree and has corresponding neighbor entry
            if (mainNode.Nodes.Count > 0)
            {
                mainNode.Expand();
                foreach (TreeNode node in mainNode.Nodes)
                {
                    node.Collapse();
                }
            }

            var neighborList = new Dictionary <string, IEnumerable <string> >();
            var tempNode     = mainNode;

            //create neighbor list
            while (tempNode.Parent != null)
            {
                var fullName = (string)tempNode.Tag;
                var tempList = (from TreeNode item in tempNode.Parent.Nodes select(string) item.Tag);
                neighborList.Add(fullName, tempList);
                tempNode = tempNode.Parent;
            }
            {
                var tempList = (from TreeNode item in FileTree.Nodes select(string) item.Tag);
                neighborList.Add((string)tempNode.Tag, tempList);
            }


            #region Show item in folder view

            FolderViewList.Items.Clear();

            //regular folders
            _unfilteredItems = new List <ListViewItem>();
            foreach (TreeNode node in mainNode.Nodes)
            {
                var lvi = new ListViewItem {
                    Text = node.Text, ImageIndex = 8, Tag = node.Tag
                };
                lvi.SubItems.Add(string.Empty);
                lvi.SubItems.Add("File Folder");
                FolderViewList.Items.Add(lvi);
                _unfilteredItems.Add(lvi);
            }

            //Spectra Folders
            if (_spectraFolders.ContainsKey((string)mainNode.Tag))
            {
                foreach (var item in _spectraFolders[(string)mainNode.Tag])
                {
                    var lvi = new ListViewItem {
                        Text = Path.GetFileName(item[0]), ImageIndex = 9, Tag = item[0]
                    };
                    lvi.SubItems.Add(string.Empty);
                    lvi.SubItems.Add(item[1]);
                    FolderViewList.Items.Add(lvi);
                    _unfilteredItems.Add(lvi);
                }
            }

            FolderViewList.Sort();

            //Spectra Files
            if (_spectraFiles.ContainsKey((string)mainNode.Tag))
            {
                foreach (var item in _spectraFolders[(string)mainNode.Tag])
                {
                    var lvi = new ListViewItem {
                        Text = Path.GetFileName(item[0]), ImageIndex = 10, Tag = item[0]
                    };
                    lvi.SubItems.Add(string.Empty);
                    lvi.SubItems.Add(item[1]);
                    FolderViewList.Items.Add(lvi);
                    _unfilteredItems.Add(lvi);
                }
            }
            else
            {
                var fileList = new List <string[]>();
                var di       = new DirectoryInfo((string)mainNode.Tag);
                try
                {
                    foreach (var item in di.GetFiles())
                    {
                        var type = FileType(item.FullName);
                        if (!string.IsNullOrEmpty(type))
                        {
                            fileList.Add(new[] { item.FullName, type });
                            var lvi = new ListViewItem {
                                Text = item.Name, ImageIndex = 10, Tag = item.FullName
                            };
                            lvi.SubItems.Add(FileInfoLengthToString(item.Length));
                            lvi.SubItems.Add(type);
                            lvi.SubItems.Add(item.LastWriteTime.ToString());
                            FolderViewList.Items.Add(lvi);
                            _unfilteredItems.Add(lvi);
                        }
                    }
                }
                catch (IOException)
                {
                    //device cant be read at the moment if this is triggered
                }
            }

            #endregion

            BreadCrumbs.NavigateToFolder((string)mainNode.Tag, neighborList);

            //update history
            if (_historyQueue.Count >= 10)
            {
                _historyQueue.RemoveAt(0);
                _placeInQueue--;
            }

            if (!_navigatingHistory &&
                (!_historyQueue.Any() || (string)mainNode.Tag != _historyQueue.Last()))
            {
                for (var x = _historyQueue.Count - 1; x > _placeInQueue; x--)
                {
                    _historyQueue.RemoveAt(x);
                }
                _historyQueue.Add((string)mainNode.Tag);
                _placeInQueue = _historyQueue.Count - 1;
            }
            UpdateHistoryButtons();

            //apply filters
            ApplyFilters(false);
        }
예제 #4
0
        private async void FileTree_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (e.Node.Tag == null)
            {
                return;
            }

            if (cancellationTokenSource != null)
            {
                cancellationTokenSource.Cancel();
            }
            cancellationTokenSource = new CancellationTokenSource();
            var cancellationToken = cancellationTokenSource.Token;

            if (e.Node.Tag.ToString() == "folder")
            {
                FolderViewList.Items.Clear();
                JObject jobject = GetJsonFromEndpoint(String.Format("/folders({0})/items", e.Node.Name));
                JArray  items   = jobject["value"] as JArray;
                await Task.Run(() =>
                {
                    foreach (JObject item in items)
                    {
                        var type = item.Property("type").Value.ToString();

                        // only display sample results
                        if (type != "SampleResult")
                        {
                            continue;
                        }

                        if (cancellationToken.IsCancellationRequested)
                        {
                            break;
                        }

                        var name    = item.Property("name").Value.ToString();
                        var id      = item.Property("id").Value.ToString();
                        var created = item.Property("createdAt").Value.ToString();

                        var sampleResult         = GetJsonFromEndpoint(String.Format("/sampleresults({0})", id));
                        var sample               = sampleResult.Property("sample").Value as JObject;
                        var replicate            = sample.Property("replicateNumber").Value.ToString();
                        var wellPosition         = sample.Property("wellPosition").Value.ToString();
                        var acquisitionStartTime = sample.Property("acquisitionStartTime").Value.ToString();
                        name = sample.Property("name").Value.ToString();

                        JObject analysis    = (GetJsonFromEndpoint(String.Format("/sampleresults({0})/analyses", id))["value"] as JArray).FirstOrDefault() as JObject;
                        string analysisName = "unknown";
                        if (analysis != null)
                        {
                            analysisName = analysis.Property("name").Value.ToString();
                        }

                        if (cancellationToken.IsCancellationRequested)
                        {
                            break;
                        }

                        var updateView = new MethodInvoker(() => FolderViewList.Items.Add(new ListViewItem(new string[] { analysisName, wellPosition, replicate, name, acquisitionStartTime, created }, 2)
                        {
                            Tag = String.Format("/sampleresults({0})", id)
                        }));
                        FolderViewList.Invoke(updateView);
                    }

                    cancellationTokenSource = null;
                });
            }

            FolderViewList.Sort();
        }
예제 #5
0
        private async void FileTree_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (e.Node.Tag == null)
            {
                return;
            }

            if (cancellationTokenSource != null)
            {
                cancellationTokenSource.Cancel();
            }
            cancellationTokenSource = new CancellationTokenSource();
            var cancellationToken = cancellationTokenSource.Token;

            try
            {
                if (e.Node.Tag.ToString() == "folder")
                {
                    FolderViewList.Items.Clear();
                    JObject jobject = await GetJsonFromEndpoint(String.Format("/folders({0})/items", e.Node.Name), cancellationToken);

                    JArray items = jobject["value"] as JArray;

                    foreach (JObject item in items)
                    {
                        var type = item.Property("type").Value.ToString();

                        // only display sample results
                        if (type != "SampleResult")
                        {
                            continue;
                        }

                        var name         = item.Property("name").Value.ToString();
                        var id           = item.Property("id").Value.ToString();
                        var created      = item.Property("createdAt").Value.ToString();
                        var sampleResult = await GetJsonFromEndpoint(String.Format("/sampleresults({0})", id), cancellationToken);

                        var sample               = sampleResult.Property("sample").Value as JObject;
                        var replicate            = sample.Property("replicateNumber").Value.ToString();
                        var wellPosition         = sample.Property("wellPosition").Value.ToString();
                        var acquisitionStartTime = sample.Property("acquisitionStartTime").Value.ToString();
                        //name = sample.Property("name").Value.ToString();

                        var analyses = await GetJsonFromEndpoint(String.Format("/sampleresults({0})/analyses", id), cancellationToken);

                        JObject analysis     = (analyses["value"] as JArray).FirstOrDefault() as JObject;
                        string  analysisName = "unknown";
                        if (analysis != null)
                        {
                            analysisName = analysis.Property("name").Value.ToString();
                        }

                        if (name.Length == 0)
                        {
                            name = analysisName;
                        }

                        var updateView = new MethodInvoker(() => { FolderViewList.Items.Add(new ListViewItem(new string[] { analysisName, wellPosition, replicate, name, acquisitionStartTime, created }, 2)
                            {
                                Tag = new UnifiSampleResult(serverLocationTextBox.Text, id, name, replicate, wellPosition)
                            }); });
                        FolderViewList.Invoke(updateView);
                    }

                    cancellationTokenSource = null;
                }
            }
            catch (TaskCanceledException)
            {
                if (!cancellationToken.IsCancellationRequested)
                {
                    Program.HandleException(new TimeoutException("UNIFI API call timed out"));
                }
            }
            catch (Exception ex)
            {
                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                Program.HandleException(ex);
                disconnect();
            }

            FolderViewList.Sort();
        }