Example #1
0
        /// <summary>
        /// Default available bookmark styles
        /// </summary>
        /// <returns>List of bookmark styles</returns>
        public static List <BookmarkStyle> GetBookmarkStyles(CodeDocumentViewModel codeDocumentViewModel, string solutionFilePath)
        {
            if (string.IsNullOrEmpty(solutionFilePath))
            {
                return(GetDefaultBookmarkStyles());
            }

            var solutionStorage = SolutionStorageHelper.Load <SolutionStorageModel>(solutionFilePath);

            if (solutionStorage.Documents == null)
            {
                return(GetDefaultBookmarkStyles());
            }

            var storageItem = solutionStorage.Documents
                              .FirstOrDefault(s => s.FilePath.Equals(codeDocumentViewModel.FilePath));

            if (storageItem != null)
            {
                codeDocumentViewModel.BookmarkStyles = storageItem.BookmarkStyles;
            }

            if (codeDocumentViewModel.BookmarkStyles == null)
            {
                codeDocumentViewModel.BookmarkStyles = GetDefaultBookmarkStyles();
            }

            return(codeDocumentViewModel.BookmarkStyles);
        }
Example #2
0
        public static void SetBookmarkStyles(CodeDocumentViewModel codeDocumentViewModel, ControlCollection controls, string solutionFilePath)
        {
            var styles = new List <BookmarkStyle>();

            foreach (var item in controls)
            {
                var label = item as Label;
                styles.Add(new BookmarkStyle(ColorHelper.ToBrush(label.BackColor), ColorHelper.ToBrush(label.ForeColor)));
            }

            codeDocumentViewModel.BookmarkStyles = styles;

            SolutionStorageHelper.SaveToSolutionStorage(solutionFilePath, codeDocumentViewModel);
        }
Example #3
0
        public static void AddItemToHistory(CodeItem item)
        {
            if (item == null)
            {
                return;
            }

            var model = item.Control.CodeDocumentViewModel;

            // Clear current indicators
            model.HistoryItems.ForEach(i => i.StatusMonikerVisibility = Visibility.Collapsed);

            // Add new indicator, only keep the five latest history items
            model.HistoryItems.RemoveAll(i => i.Id.Equals(item.Id));
            model.HistoryItems.Insert(0, item);
            model.HistoryItems = model.HistoryItems.Take(MaxHistoryItems).ToList();

            SolutionStorageHelper.SaveToSolutionStorage(item.Control, model);
            ApplyHistoryIndicator(model);
        }
Example #4
0
        public static void SaveToSolutionStorage(string solutionFilePath, CodeDocumentViewModel codeDocumentViewModel)
        {
            if (string.IsNullOrEmpty(solutionFilePath))
            {
                return;
            }

            var solutionStorageModel = SolutionStorageHelper.Load <SolutionStorageModel>(solutionFilePath);

            if (solutionStorageModel.Documents == null)
            {
                solutionStorageModel.Documents = new List <CodeDocumentViewModel>();
            }

            var storageItem = solutionStorageModel.Documents
                              .FirstOrDefault(d => d.FilePath.Equals(codeDocumentViewModel.FilePath));

            solutionStorageModel.Documents.Remove(storageItem);

            solutionStorageModel.Documents.Add(codeDocumentViewModel);

            SolutionStorageHelper.Save <SolutionStorageModel>(solutionFilePath, solutionStorageModel);
        }
Example #5
0
 public static async Task ClearHistoryAsync(CodeItem item)
 {
     item.Control.CodeDocumentViewModel.HistoryItems.Clear();
     SolutionStorageHelper.SaveToSolutionStorage(item.Control, item.Control.CodeDocumentViewModel);
     await item.Control.UpdateDocumentAsync(true);
 }