示例#1
0
        private void AnnoList_Drop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] filenames = e.Data.GetData(DataFormats.FileDrop, true) as string[];
                if (filenames != null && filenames[0].EndsWith(".annotation"))
                {
                    try
                    {
                        AnnoList list = AnnoList.LoadfromFile(filenames[0]);

                        if (list.Scheme.Type == AnnoScheme.TYPE.DISCRETE)
                        {
                            foreach (var item in list.Scheme.Labels)
                            {
                                AnnotationSchemeSegment ass = new AnnotationSchemeSegment();
                                ass.Label = item.Name;
                                ass.Color = item.Color;
                                if (!items.Contains(ass) && ass.Label != "GARBAGE" && ass.Label != "")
                                {
                                    items.Add(ass);
                                }
                            }
                        }
                        else if (list.Scheme.Type == AnnoScheme.TYPE.FREE)
                        {
                            HashSet <string> labelNames = new HashSet <string>();
                            foreach (AnnoListItem item in list)
                            {
                                labelNames.Add(item.Label);
                            }
                            foreach (string name in labelNames)
                            {
                                AnnotationSchemeSegment ass = new AnnotationSchemeSegment();
                                ass.Label = name;
                                ass.Color = list.Scheme.MaxOrForeColor;
                                if (!items.Contains(ass) && ass.Label != "GARBAGE" && ass.Label != "")
                                {
                                    items.Add(ass);
                                }
                            }
                        }
                        else
                        {
                            return;
                        }

                        schemeNameTextField.Text           = list.Scheme.Name;
                        backroundColorPicket.SelectedColor = list.Scheme.MinOrBackColor;
                    }
                    catch (Exception ex)
                    {
                        MessageTools.Warning("This is not a valid annotation file");
                    }
                }
            }
        }
示例#2
0
        private void AddLabel_Click(object sender, RoutedEventArgs e)
        {
            AnnotationSchemeSegment item = new AnnotationSchemeSegment()
            {
                Label = "", Color = Colors.Black
            };

            items.Add(item);
            LabelsListBox.SelectedItem = item;
            LabelsListBox.ScrollIntoView(item);
        }