private void CustomInitializeComponent()
        {
            _fileNameBox.Text = Config.Instance.JanusStateConfig.LastFileName;
            Options           = Config.Instance.JanusStateConfig.SaveOptions;

            UpdateButtonState();
        }
Example #2
0
		private void CustomInitializeComponent()
		{
			_fileNameBox.Text = Config.Instance.JanusStateConfig.LastFileName;
			Options = Config.Instance.JanusStateConfig.SaveOptions;

			UpdateButtonState();
		}
Example #3
0
        internal static SaveStateOptions SaveStateOptions(string saveStateOptions)
        {
            var options = new SaveStateOptions()
            {
                Value = saveStateOptions
            };

            return(options);
        }
Example #4
0
        internal static SaveStateOptions SaveStateOptions(JObject saveStateOptions)
        {
            var options = new SaveStateOptions()
            {
                StateStore = GetValueOrDefault <string>(saveStateOptions, "stateStore"),
                Key        = GetValueOrDefault <string>(saveStateOptions, "key"),
                Value      = GetValueOrDefault <JToken>(saveStateOptions, "value")
            };

            return(options);
        }
Example #5
0
        /// <summary>
        /// Сохраняет избранное, прочитанное и маркеры...
        /// </summary>
        /// <param name="options">Опции сохранения.</param>
        public void SaveState(SaveStateOptions options)
        {
            if (options == SaveStateOptions.None)
            {
                return;
            }

            using (var db = _serviceProvider.CreateDBContext())
            {
                var state = new StateBag
                {
                    MaxMessageId = db.Messages().Max(msg => msg.ID)
                };

                if ((options & SaveStateOptions.ReadedMessages) != SaveStateOptions.None)
                {
                    state.UnreadMessages =
                        db
                        .Messages(m => !m.IsRead)
                        .Select(m => m.ID)
                        .ToList();
                }

                if ((options & SaveStateOptions.Markers) != SaveStateOptions.None)
                {
                    state.MarkedMessages =
                        db
                        .Messages(m => m.IsMarked)
                        .Select(m => m.ID)
                        .ToList();
                    state.MarkedTopics =
                        db
                        .TopicInfos(ti => ti.AnswersMarked > 0)
                        .Select(ti => ti.MessageID)
                        .ToList();
                }

                if ((options & SaveStateOptions.Favorites) != SaveStateOptions.None)
                {
                    state.Favorites = GetFavorites(_favManager.RootFolder);
                }

                Serialize(state);
            }
        }
Example #6
0
        internal static SaveStateOptions SaveStateOptions(byte[] saveStateOptions)
        {
            var options = new SaveStateOptions();

            try
            {
                string content = Encoding.UTF8.GetString(saveStateOptions);
                var    jObject = JObject.Parse(content);
                options = SaveStateOptions(jObject);
                if (options.Value == null)
                {
                    throw new FormatException("Invalid save state options JSON");
                }
            }
            catch (Exception)
            {
                options.Value = saveStateOptions;
            }

            return(options);
        }
Example #7
0
        /// <summary>
        /// Сохраняет избранное, прочитанное и маркеры...
        /// </summary>
        /// <param name="options">Опции сохранения.</param>
        public void SaveState(SaveStateOptions options)
        {
            if (options == SaveStateOptions.None)
                return;

            using (var db = _serviceProvider.CreateDBContext())
            {
                var state = new StateBag
                {
                    MaxMessageId = db.Messages().Max(msg => msg.ID)
                };

                if ((options & SaveStateOptions.ReadedMessages) != SaveStateOptions.None)
                    state.UnreadMessages =
                        db
                            .Messages(m => !m.IsRead)
                            .Select(m => m.ID)
                            .ToList();

                if ((options & SaveStateOptions.Markers) != SaveStateOptions.None)
                {
                    state.MarkedMessages =
                        db
                            .Messages(m => m.IsMarked)
                            .Select(m => m.ID)
                            .ToList();
                    state.MarkedTopics =
                        db
                            .TopicInfos(ti => ti.AnswersMarked > 0)
                            .Select(ti => ti.MessageID)
                            .ToList();
                }

                if ((options & SaveStateOptions.Favorites) != SaveStateOptions.None)
                    state.Favorites = GetFavorites(_favManager.RootFolder);

                Serialize(state);
            }
        }
 private static bool IsSet(SaveStateOptions options,
                           SaveStateOptions value)
 {
     return((options & value) != SaveStateOptions.None);
 }
Example #9
0
		private static bool IsSet(SaveStateOptions options,
			SaveStateOptions value)
		{
			return (options & value) != SaveStateOptions.None;
		}