Exemplo n.º 1
0
        public Source GetActiveSource(string typeName, int id)
        {
            var q = from s in GetActiveSources(SourceTypes.Get(typeName))
                    where s.Id == id
                    select s;

            return(q.FirstOrDefault());
        }
Exemplo n.º 2
0
        void RestoreUIState()
        {
            try {
                var repo     = Repo.Foreground;
                var newState = LoadUIState(repo);

                if (newState)
                {
                    InitialData.Load(repo);
                }

                if (_uiState.ActiveScreen == "Message")
                {
                    var id = int.Parse(_uiState.ActiveScreenValue);
                    var mq = from m in repo.Table <Message> ()
                             where m.Id == id
                             select m;
                    var msg = mq.First();
                    var s   = msg.GetSource(repo.GetActiveSources());
                    ShowSourceMessages(s);
                    ShowMessage(msg.Reference, ((SourceTypeMessages)MVC.MainView).TheMessages);
                }
                else if (_uiState.ActiveScreen == "Source")
                {
                    var parts          = _uiState.ActiveScreenValue.Split('-');
                    var sourceTypeName = parts[0];
                    var id             = int.Parse(parts[1]);
                    var s = repo.GetActiveSource(sourceTypeName, id);
                    ShowSourceMessages(s);
                }
                else if (_uiState.ActiveScreen == "SourceType")
                {
                    string sourceTypeName = _uiState.ActiveScreenValue;
                    var    sourceType     = SourceTypes.Get(sourceTypeName);
                    if (sourceType != null)
                    {
                        ShowSourceTypeMessages(sourceType, false);
                    }
                }
                else if (_uiState.ActiveScreen == "Home")
                {
                    ShowHome();
                }
                else
                {
                    ShowHome();
                }
            } catch (Exception) {
                _uiState.ActiveScreen      = "";
                _uiState.ActiveScreenValue = "";
                ShowHome();
            }
        }