예제 #1
0
        public bool clearWorkspace()
        {
            tokenSource.Cancel();
            Stop();
            updateTimeRange(1);
            bool anytrackchanged = false;

            foreach (AnnoTier track in annoTiers)
            {
                if (track.AnnoList.HasChanged)
                {
                    anytrackchanged = true;
                }
            }

            if (annoTiers.Count > 0 && anytrackchanged)
            {
                MessageBoxResult mbx = MessageBox.Show("There are unsaved changes, save all annotations?", "Question", MessageBoxButton.YesNoCancel);
                if (mbx == MessageBoxResult.Cancel)
                {
                    return(false);
                }
                else if (mbx == MessageBoxResult.Yes)
                {
                    saveAllAnnos();
                }
                else if (mbx == MessageBoxResult.No)
                {
                    foreach (AnnoTier track in annoTiers)
                    {
                        track.AnnoList.HasChanged = false;
                    }
                }
            }



            while (mediaBoxes.Count > 0)
            {
                removeMediaBox(mediaBoxes[0]);
            }
            mediaList.Clear();
            while (signalTracks.Count > 0)
            {
                removeSignalTrack(signalTracks[0]);
            }
            while (annoTiers.Count > 0)
            {
                annoTiers[0].LiveAnnoMode(true);
                removeAnnoTier(annoTiers[0]);
            }


            control.annoLiveModeCheckBox.IsChecked = false;

            annoLists.Clear();
            setAnnoList(null);

            signalCursor.X           = 0;
            Time.TotalDuration       = 0;
            Time.SelectionStart      = 0;
            Time.CurrentPlayPosition = 0;

            if (DatabaseHandler.IsSession)
            {
                DatabaseHandler.ChangeSession(null);
            }

            updateControl();
            control.timeLineControl.rangeSlider.Update();
            control.timeLineControl.rangeSlider.slider.RangeStartSelected = 0;
            control.timeLineControl.rangeSlider.slider.RangeStopSelected  = 100000;
            control.geometricListControl.Visibility = Visibility.Collapsed;

            return(true);
        }
        private void Merge()
        {
            string featureName = FeatureNameTextBox.Text;

            if (featureName == "" || featureName.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0)
            {
                MessageTools.Warning("not a valid feature name");
                return;
            }

            string database = (string)DatabasesBox.SelectedItem;

            var  sessions = SessionsBox.SelectedItems;
            var  roles    = RolesBox.SelectedItems;
            var  streams  = StreamsBox.SelectedItems;
            bool force    = ForceCheckBox.IsChecked.Value;

            string sessionList = "";

            foreach (DatabaseSession session in sessions)
            {
                if (sessionList == "")
                {
                    sessionList = session.Name;
                }
                else
                {
                    sessionList += ";" + session.Name;
                }
            }

            string roleList = "";

            foreach (var role in roles)
            {
                if (roleList == "")
                {
                    roleList = ((DatabaseRole)role).Name;
                }
                else
                {
                    roleList += ";" + ((DatabaseRole)role).Name;
                }
            }

            string[] streamsNames = new string[streams.Count];
            int      i            = 0;

            foreach (DatabaseStream stream in streams)
            {
                streamsNames[i++] = stream.Name;
            }
            Array.Sort(streamsNames);

            string streamList = "";
            double sampleRate = ((DatabaseStream)streams[0]).SampleRate;

            foreach (string stream in streamsNames)
            {
                if (streamList == "")
                {
                    streamList = stream;
                }
                else
                {
                    streamList += ";" + stream;
                }
            }

            string rootDir = Properties.Settings.Default.DatabaseDirectory + "\\" + database;

            logTextBox.Text = handler.CMLMergeFeature(rootDir, sessionList, roleList, streamList, featureName, force);

            string type = Defaults.CML.StreamTypeNameFeature;
            string ext  = "stream";

            DatabaseStream streamType = new DatabaseStream()
            {
                Name = featureName, Type = type, FileExt = ext, SampleRate = sampleRate
            };

            DatabaseHandler.AddStream(streamType);

            GetStreams(streamType);
        }
        private void Extract()
        {
            if (ChainsBox.SelectedItem == null)
            {
                MessageTools.Warning("select a chain first");
                return;
            }

            string featureName = FeatureNameTextBox.Text;

            if (featureName == "" || featureName.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0)
            {
                MessageTools.Warning("not a valid feature name");
                return;
            }

            Chain chain = (Chain)ChainsBox.SelectedItem;
            bool  force = ForceCheckBox.IsChecked.Value;

            if (!File.Exists(chain.Path))
            {
                MessageTools.Warning("file does not exist '" + chain.Path + "'");
                return;
            }

            string         database = DatabaseHandler.DatabaseName;
            var            sessions = SessionsBox.SelectedItems;
            var            roles    = RolesBox.SelectedItems;
            DatabaseStream stream   = (DatabaseStream)StreamsBox.SelectedItem;

            string leftContext  = LeftContextTextBox.Text;
            string frameStep    = FrameStepTextBox.Text;
            string rightContext = RightContextTextBox.Text;

            int nParallel = 1;

            int.TryParse(NParallelTextBox.Text, out nParallel);

            logTextBox.Text = "";

            // prepare lists

            int nFiles = 0;

            using (StreamWriter fileListIn = new StreamWriter(tempInListPath))
            {
                using (StreamWriter fileListOut = new StreamWriter(tempOutListPath))
                {
                    foreach (DatabaseSession session in sessions)
                    {
                        foreach (DatabaseRole role in roles)
                        {
                            string fromPath = Properties.Settings.Default.DatabaseDirectory + "\\"
                                              + database + "\\"
                                              + session.Name + "\\"
                                              + role.Name + "." + stream.Name + "." + stream.FileExt;

                            string toPath = Path.GetDirectoryName(fromPath) + "\\"
                                            + role.Name + "." + featureName + ".stream";

                            if (force || !File.Exists(toPath))
                            {
                                nFiles++;
                                fileListIn.WriteLine(fromPath);
                                fileListOut.WriteLine(toPath);
                            }
                            else
                            {
                                logTextBox.Text += "skip " + fromPath + "\n";
                            }
                        }
                    }
                }
            }

            // start feature extraction

            Chain          selectedChain  = (Chain)ChainsBox.SelectedItem;
            DatabaseStream selectedStream = (DatabaseStream)StreamsBox.SelectedItem;

            if (nFiles > 0)
            {
                string type = Defaults.CML.StreamTypeNameFeature;
                string name = featureName;
                string ext  = "stream";

                double sr = frameStepToSampleRate(frameStep, stream.SampleRate);

                DatabaseStream streamType = new DatabaseStream()
                {
                    Name = name, Type = type, FileExt = ext, SampleRate = sr
                };
                DatabaseHandler.AddStream(streamType);
                try
                {
                    logTextBox.Text += handler.CMLExtractFeature(chain.Path, nParallel, tempInListPath, tempOutListPath, frameStep, leftContext, rightContext);
                }
                catch (Exception e) { MessageBox.Show("There was an error in the feature extaction pipeline: " + e); }
            }

            File.Delete(tempInListPath);
            File.Delete(tempOutListPath);

            GetStreams(selectedStream);
            foreach (Chain item in ChainsBox.Items)
            {
                if (item.Name == selectedChain.Name)
                {
                    ChainsBox.SelectedItem = item;
                    break;
                }
            }
        }
예제 #4
0
        public void GetSessions()
        {
            //if (AnnotationSelectionBox.SelectedItem == null)
            //{
            //   return;
            ////}


            if (AnnotationSelectionBox.HasItems)
            {
                AnnotationSelectionBox.ItemsSource = null;
            }



            // show sessions for which an annotation exists or is missing

            List <BsonDocument> annotations = new List <BsonDocument>();

            if (AnnotationSelectionBox.Items.Count > 0)
            {
                List <string> sessionNames = new List <string>();

                {
                    var      item       = (SchemeRoleAnnotator)AnnotationSelectionBox.Items[0];
                    string   schemeName = item.Name;
                    ObjectId schemeID   = new ObjectId();
                    DatabaseHandler.GetObjectID(ref schemeID, DatabaseDefinitionCollections.Schemes, schemeName);
                    string   roleName = item.Role;
                    ObjectId roleID   = new ObjectId();
                    DatabaseHandler.GetObjectID(ref roleID, DatabaseDefinitionCollections.Roles, roleName);

                    string   annotatorName = DatabaseHandler.Annotators.Find(a => a.FullName == item.Annotator).Name;
                    ObjectId annotatorID   = new ObjectId();
                    DatabaseHandler.GetObjectID(ref annotatorID, DatabaseDefinitionCollections.Annotators, annotatorName);

                    var builder = Builders <BsonDocument> .Filter;

                    var filter = builder.Eq("scheme_id", schemeID) & builder.Eq("annotator_id", annotatorID);

                    annotations.AddRange(DatabaseHandler.GetCollection(DatabaseDefinitionCollections.Annotations, true, filter));

                    foreach (BsonDocument annotation in annotations)
                    {
                        string sessionName = "";
                        DatabaseHandler.GetObjectName(ref sessionName, DatabaseDefinitionCollections.Sessions, annotation["session_id"].AsObjectId);
                        if (sessionName != "" && !sessionNames.Contains(sessionName))
                        {
                            sessionNames.Add(sessionName);
                        }
                    }
                }

                for (int i = 1; i < AnnotationSelectionBox.Items.Count; i++)
                {
                    List <BsonDocument> annotationstemp  = new List <BsonDocument>();
                    List <string>       sessionNamestemp = new List <string>();
                    var      item       = (SchemeRoleAnnotator)AnnotationSelectionBox.Items[i];
                    string   schemeName = item.Name;
                    ObjectId schemeID   = new ObjectId();
                    DatabaseHandler.GetObjectID(ref schemeID, DatabaseDefinitionCollections.Schemes, schemeName);
                    string   roleName = item.Role;
                    ObjectId roleID   = new ObjectId();
                    DatabaseHandler.GetObjectID(ref roleID, DatabaseDefinitionCollections.Roles, roleName);

                    string   annotatorName = DatabaseHandler.Annotators.Find(a => a.FullName == item.Annotator).Name;
                    ObjectId annotatorID   = new ObjectId();
                    DatabaseHandler.GetObjectID(ref annotatorID, DatabaseDefinitionCollections.Annotators, annotatorName);

                    var builder = Builders <BsonDocument> .Filter;

                    var filter = builder.Eq("scheme_id", schemeID) & builder.Eq("annotator_id", annotatorID);

                    annotationstemp.AddRange(DatabaseHandler.GetCollection(DatabaseDefinitionCollections.Annotations, true, filter));

                    foreach (BsonDocument annotation in annotationstemp)
                    {
                        string sessionName = "";
                        DatabaseHandler.GetObjectName(ref sessionName, DatabaseDefinitionCollections.Sessions, annotation["session_id"].AsObjectId);
                        if (sessionName != "" && !sessionNamestemp.Contains(sessionName))
                        {
                            sessionNamestemp.Add(sessionName);
                        }
                    }

                    sessionNames.RemoveAll(thing => !sessionNamestemp.Contains(thing));
                }

                List <DatabaseSession> sessions = new List <DatabaseSession>();
                foreach (string sessionName in sessionNames)
                {
                    DatabaseSession session = new DatabaseSession()
                    {
                        Name = sessionName
                    };
                    if (DatabaseHandler.GetSession(ref session))
                    {
                        sessions.Add(session);
                    }
                }

                SessionsBox.ItemsSource = sessions.OrderBy(s => s.Name).ToList();


                if (SessionsBox.HasItems)
                {
                    if (SessionsBox.SelectedItem == null)
                    {
                        SessionsBox.SelectedIndex = 0;
                    }
                }
            }
        }
예제 #5
0
        public void loadProjectFile(string filepath)
        {
            clearWorkspace();

            string workdir = Path.GetDirectoryName(filepath);

            XmlDocument doc = new XmlDocument();

            try
            {
                doc.Load(filepath);

                foreach (XmlNode node in doc.SelectNodes("//media"))
                {
                    string path = FileTools.GetAbsolutePath(node.InnerText, workdir);
                    loadFile(path);
                }

                foreach (XmlNode node in doc.SelectNodes("//signal"))
                {
                    Color background = Defaults.Colors.Background;
                    Color foreground = Defaults.Colors.Foreground;
                    if (node.Attributes["bg"] != null)
                    {
                        background = (Color)ColorConverter.ConvertFromString(node.Attributes["bg"].LastChild.Value);
                    }
                    if (node.Attributes["fg"] != null)
                    {
                        foreground = (Color)ColorConverter.ConvertFromString(node.Attributes["fg"].LastChild.Value);
                    }
                    string path = FileTools.GetAbsolutePath(node.InnerText, workdir);
                    loadFile(path, foreground, background);
                }

                if (DatabaseHandler.IsConnected)
                {
                    XmlNode node = doc.SelectSingleNode("//tiers");
                    if (node != null && node.Attributes["database"] != null)
                    {
                        DatabaseHandler.ChangeDatabase(node.Attributes["database"].LastChild.Value);
                    }
                }

                foreach (XmlNode node in (doc.SelectNodes("//tier")))
                {
                    string path = node.InnerText;
                    if (!Path.HasExtension(path))
                    {
                        AnnoList annoList = DatabaseHandler.LoadAnnoList(path);
                        if (annoList != null)
                        {
                            addAnnoTier(annoList);
                        }
                        else
                        {
                            MessageTools.Warning("Could not load annotation from database with id '" + node.InnerText + "'");
                        }
                    }
                    else
                    {
                        if (path == "")
                        {
                            path = node.Attributes["filepath"].LastChild.Value;
                        }
                        path = FileTools.GetAbsolutePath(path, workdir);
                        loadFile(path);
                    }
                }
            }
            catch (Exception e)
            {
                MessageTools.Error(e.ToString());
            }
        }
예제 #6
0
        private void Apply_Click(object sender, RoutedEventArgs e)
        {
            Properties.Settings.Default.SettingCMLDefaultBN = NetworkSelectionBox.SelectedItem.ToString();
            Properties.Settings.Default.CMLDefaultAnnotator = AnnotatorsBox.SelectedItem.ToString();
            Properties.Settings.Default.CMLDefaultRole      = RolesBox.SelectedItem.ToString();
            Properties.Settings.Default.CMLDefaultScheme    = SchemesBox.SelectedItem.ToString();
            Properties.Settings.Default.CMLDefaultTrainer   = NetworkSelectionBox.SelectedItem.ToString();
            Properties.Settings.Default.Save();

            bool force = ForceCheckBox.IsChecked.Value;

            string database = DatabaseHandler.DatabaseName;

            var sessions = SessionsBox.SelectedItems;

            logTextBox.Text = "";

            string networkrDir = Properties.Settings.Default.CMLDirectory + "\\" +
                                 Defaults.CML.FusionFolderName + "\\" +
                                 Defaults.CML.FusionBayesianNetworkFolderName + "\\" + NetworkSelectionBox.SelectedItem + ".xdsl";

            string datasetDir = Properties.Settings.Default.CMLDirectory + "\\" +
                                Defaults.CML.FusionFolderName + "\\" +
                                Defaults.CML.FusionBayesianNetworkFolderName + "\\" + namebox.Text;

            double chunksizeinMS;

            double.TryParse(chunksizebox.Text, out chunksizeinMS);

            int tempsteps;

            int.TryParse(timestepsbox.Text, out tempsteps);

            bool isdynamic = tempsteps > 0 ? true : false;

            if (File.Exists(datasetDir) && ForceCheckBox.IsChecked == false)
            {
                // logTextBox.Text = "dataset exists, skip.\n";
                logTextBox.Text += "\nData sheet exits, check force to overwrite";
                //  logTextBox.Text += handler.CMLTrainBayesianNetwork(networkrDir, datasetDir, isdynamic);
                return;
            }

            File.Delete(datasetDir);

            bool ishead = true;

            foreach (DatabaseSession session in SessionsBox.SelectedItems)
            {
                List <AnnoList> annoLists = new List <AnnoList>();
                foreach (SchemeRoleAnnotator item in AnnotationSelectionBox.Items)
                {
                    DatabaseRole   role        = DatabaseHandler.Roles.Find(r => r.Name == item.Role);
                    DatabaseScheme scheme      = DatabaseHandler.Schemes.Find(m => m.Name == item.Name);
                    ObjectId       annotatorID = DatabaseHandler.Annotators.Find(a => a.FullName == item.Annotator).Id;

                    var builder = Builders <BsonDocument> .Filter;
                    var filter  = builder.Eq("scheme_id", scheme.Id) & builder.Eq("annotator_id", annotatorID) & builder.Eq("role_id", role.Id) & builder.Eq("session_id", session.Id);
                    List <DatabaseAnnotation> list = DatabaseHandler.GetAnnotations(filter);
                    foreach (DatabaseAnnotation anno in list)
                    {
                        AnnoList annolist = DatabaseHandler.LoadAnnoList(anno.Id);
                        if (annolist.Scheme.Type == AnnoScheme.TYPE.CONTINUOUS)
                        {
                            for (int i = 0; i < item.Classes; i++)
                            {
                                annolist.Scheme.Labels.Add(new AnnoScheme.Label("s" + (i + 1).ToString(), System.Windows.Media.Colors.Black))
                                ;
                            }
                        }

                        annoLists.Add(annolist);
                        logTextBox.Text = logTextBox.Text + "Session: " + session.Name + " Role: " + annolist.Meta.Role + " Scheme: " + annolist.Scheme.Name + "\n";

                        logTextBox.Focus();
                        logTextBox.CaretIndex = logTextBox.Text.Length;
                        logTextBox.ScrollToEnd();
                    }
                }
                logTextBox.Text = logTextBox.Text + "----------------------------------\n";

                if (rolecheckbox.IsChecked == true)
                {
                    ExportFrameWiseAnnotations(chunksizeinMS, ';', "REST", datasetDir, annoLists, ishead, session.Name, tempsteps);
                }
                else

                {
                    ExportFrameWiseAnnotationsRolesSeperated(chunksizeinMS, ';', "REST", datasetDir, annoLists, ishead, session.Name, tempsteps);
                }

                if (ishead)
                {
                    ishead = false;
                }
            }

            string[] pairs = new string[AnnotationSelectionBox.Items.Count];
            int      s     = 0;

            foreach (SchemeRoleAnnotator item in AnnotationSelectionBox.Items)
            {
                pairs[s] = item.Name + ":" + item.Annotator + ":" + item.Role + ":" + item.Classes;
                s++;
            }

            string cmlfolderpath = Properties.Settings.Default.CMLDirectory + "\\" +
                                   Defaults.CML.FusionFolderName + "\\" +
                                   Defaults.CML.FusionBayesianNetworkFolderName + "\\";

            string trainingsetpath = cmlfolderpath + "training.set";


            System.IO.File.WriteAllLines(trainingsetpath, pairs);


            logTextBox.Text += "\nCreating Data sheet successful\nHit train to train the network or use it in GenIE";
        }
예제 #7
0
        private void ResampleScheme_Click(object sender, RoutedEventArgs e)
        {
            if (SchemesBox.SelectedItem != null)
            {
                string     name      = (string)SchemesBox.SelectedItem;
                AnnoScheme oldScheme = DatabaseHandler.GetAnnotationScheme(name);
                AnnoScheme newScheme = DatabaseHandler.GetAnnotationScheme(name);
                if (newScheme.Type != AnnoScheme.TYPE.CONTINUOUS)
                {
                    MessageBox.Show("Only continuous annotations can be resampled");
                    return;
                }



                newScheme.Name = newScheme.Name + "_resampled";
                AnnoTierNewContinuousSchemeWindow window = new AnnoTierNewContinuousSchemeWindow(ref newScheme);
                window.ShowDialog();

                if (window.DialogResult == true)
                {
                    if (DatabaseHandler.AddScheme(newScheme))
                    {
                        List <DatabaseAnnotation> existingAnnos = DatabaseHandler.GetAnnotations(oldScheme);

                        if (existingAnnos.Count > 0)
                        {
                            AnnoList al_t   = DatabaseHandler.LoadAnnoList(existingAnnos[0].Id);
                            double   old_sr = al_t.Scheme.SampleRate;
                            double   factor = 0;

                            if (old_sr > newScheme.SampleRate)
                            {
                                factor = old_sr / newScheme.SampleRate;
                            }
                            else if (old_sr < newScheme.SampleRate)
                            {
                                factor = newScheme.SampleRate / old_sr;
                            }

                            else
                            {
                                factor = 1;
                            }


                            if (factor % 1 != 0)
                            {
                                MessageBox.Show("New samplerate must be a number divisible by old samplerate.");
                                return;
                            }


                            foreach (DatabaseAnnotation anno in existingAnnos)
                            {
                                AnnoList al = DatabaseHandler.LoadAnnoList(anno.Id);
                                DatabaseHandler.resampleAnnotationtoNewScheme(al, newScheme, al_t.Scheme);
                            }

                            GetSchemes();
                        }
                        else
                        {
                            MessageBox.Show("Scheme created, but no existing Annotations found, nothing was converted.");
                        }
                    }
                }
            }
        }
        private void downloadSelectedFiles()
        {
            labelDownloaded.Visibility = Visibility.Visible;
            labelPerc.Visibility       = Visibility.Visible;
            labelSpeed.Visibility      = Visibility.Visible;
            progressBar.Visibility     = Visibility.Visible;
            string localPath = Properties.Settings.Default.DatabaseDirectory + "\\" + DatabaseBox.SelectedItem.ToString() + "\\" + ((DatabaseSession)SessionsBox.SelectedItem).Name + "\\";

            Directory.CreateDirectory(Path.GetDirectoryName(localPath));
            List <string> streamstoDownload = new List <string>();

            foreach (StreamItem stream in SelectedStreams())
            {
                string localfile = localPath + stream.Name;

                if (!File.Exists(localfile))
                {
                    streamstoDownload.Add(stream.Name);
                }
            }

            if (streamstoDownload.Count == 0 && closeAfterDownload)
            {
                DialogResult = true;
                Close();
                return;
            }

            string url          = "";
            bool   requiresAuth = false;

            DatabaseDBMeta meta = new DatabaseDBMeta()
            {
                Name = DatabaseHandler.DatabaseName
            };

            if (!DatabaseHandler.GetDBMeta(ref meta))
            {
                return;
            }

            if (meta.Server == "" || meta.Server == null)
            {
                return;
            }


            if (meta.UrlFormat == UrlFormat.NEXTCLOUD)
            {
                url = meta.Server + "/download?path=%2F" + DatabaseBox.SelectedItem.ToString() + "%2F" + ((DatabaseSession)SessionsBox.SelectedItem).Name + "&files=";
            }
            else
            {
                url          = meta.Server + '/' + DatabaseHandler.SessionName + '/';
                requiresAuth = meta.ServerAuth;
            }



            List <string> urls = new List <string>();

            foreach (string file in streamstoDownload)
            {
                urls.Add(url + file);
                if (file.EndsWith(".stream"))
                {
                    urls.Add(url + file + "~");
                }
            }


            remainingfiles = urls.Count;
            downloadFile(urls);
        }
        //not used anymore
        public void addAnnoToList(BsonDocument annotation, DatabaseSession session, bool onlyMe, bool onlyUnfinished)
        {
            ObjectId id = annotation["_id"].AsObjectId;

            string roleName = "";

            DatabaseHandler.GetObjectName(ref roleName, DatabaseDefinitionCollections.Roles, annotation["role_id"].AsObjectId);
            string schemeName = "";

            DatabaseHandler.GetObjectName(ref schemeName, DatabaseDefinitionCollections.Schemes, annotation["scheme_id"].AsObjectId);
            string annotatorName = "";

            DatabaseHandler.GetObjectName(ref annotatorName, DatabaseDefinitionCollections.Annotators, annotation["annotator_id"].AsObjectId);
            string annotatorFullName = DatabaseHandler.GetUserInfo(annotatorName).Fullname;

            //DatabaseHandler.GetObjectField(ref annotatorFullName, DatabaseDefinitionCollections.Annotators, annotation["annotator_id"].AsObjectId, "fullname");

            bool isFinished = false;

            try
            {
                isFinished = annotation["isFinished"].AsBoolean;
            }
            catch  { }

            bool islocked = false;

            try
            {
                islocked = annotation["isLocked"].AsBoolean;
            }
            catch  { }

            DateTime date = DateTime.Today;

            try
            {
                date = annotation["date"].ToUniversalTime();
            }
            catch  { }

            bool isOwner = Properties.Settings.Default.MongoDBUser == annotatorName || DatabaseHandler.CheckAuthentication() > DatabaseAuthentication.DBADMIN;


            if (!onlyMe && !onlyUnfinished ||
                onlyMe && !onlyUnfinished && Properties.Settings.Default.MongoDBUser == annotatorName ||
                !onlyMe && onlyUnfinished && !isFinished ||
                onlyMe && onlyUnfinished && !isFinished && Properties.Settings.Default.MongoDBUser == annotatorName)
            {
                annotations.Add(new DatabaseAnnotation()
                {
                    Id = id, Role = roleName, Scheme = schemeName, Annotator = annotatorName, AnnotatorFullName = annotatorFullName, Session = session.Name, IsFinished = isFinished, IsLocked = islocked, Date = date, IsOwner = isOwner
                });
            }
        }
        public DatabaseCMLTransferWindow(MainHandler handler)
        {
            InitializeComponent();

            this.handler = handler;
            //TODO Hard coded mfccs for now, this should be more dynamic in the future.
            StreamListBox.Items.Add("close.mfccdd[-f 0.04 -d 0]");

            try
            {
                mongo = new MongoClient(connectionstring);
                int count = 0;
                while (mongo.Cluster.Description.State.ToString() == "Disconnected")
                {
                    Thread.Sleep(100);
                    if (count++ >= 25)
                    {
                        throw new MongoException("Unable to connect to the database. Please make sure that " + mongo.Settings.Server.Host + ":" + mongo.Settings.Server.Port + " is online and you entered your credentials correctly!");
                    }
                }

                authlevel = DatabaseHandler.CheckAuthentication(Properties.Settings.Default.MongoDBUser, "admin");
                database  = mongo.GetDatabase(Properties.Settings.Default.DatabaseName);
                if (authlevel > 0)
                {
                    GetAnnotationSchemes();
                    GetRoles();
                    GetAnnotators();
                    GetSessionsTraining();
                    GetSessionsForward();

                    ContextTextBox.Text           = Properties.Settings.Default.CMLContext.ToString();
                    AnnotatorListBox.SelectedItem = Properties.Settings.Default.CMLDefaultAnnotator;
                    TierListBox.SelectedItem      = Properties.Settings.Default.CMLDefaultScheme;

                    ConfidenceCheckBox.IsChecked  = Properties.Settings.Default.CMLSetConf;
                    FillGapCheckBox.IsChecked     = Properties.Settings.Default.CMLFill;
                    RemoveLabelCheckBox.IsChecked = Properties.Settings.Default.CMLRemove;

                    ConfidenceTextBox.Text  = Properties.Settings.Default.CMLDefaultConf.ToString();
                    FillGapTextBox.Text     = Properties.Settings.Default.CMLDefaultGap.ToString();
                    RemoveLabelTextBox.Text = Properties.Settings.Default.CMLDefaultMinDur.ToString();



                    string[] roles = Properties.Settings.Default.CMLDefaultRole.Split(';');
                    for (int i = 0; i < roles.Length; i++)
                    {
                        RoleListBox.SelectedItems.Add(roles[i]);
                    }

                    StreamListBox.SelectedIndex = 0;
                }
                else
                {
                    MessageBox.Show("You have no rights to access the database list");
                    authlevel = DatabaseHandler.CheckAuthentication(Properties.Settings.Default.MongoDBUser, Properties.Settings.Default.DatabaseName);
                }
            }
            catch { };
        }