public FolderListItemViewModel(FolderReactionManagePageViewModel pageVM, FolderModel folderModel)
		{
			PageVM = pageVM;
			FolderModel = folderModel;

			FolderName = folderModel.Folder.Name;

			
		}
Esempio n. 2
0
		FolderModel(DirectoryInfo folder, FolderModel parentFolder = null)
		{
			ParentFolder = parentFolder;
			Folder = folder;

			_Reactions = new ObservableCollection<FolderReactionModel>();
			Reactions = new ReadOnlyObservableCollection<FolderReactionModel>(_Reactions);
			_Children = new ObservableCollection<FolderModel>();
			Children = new ReadOnlyObservableCollection<FolderModel>(_Children);
		}
Esempio n. 3
0
		public static FolderModel LoadFolder(DirectoryInfo dir, FolderModel parentFolder = null)
		{
			var folderModel = new FolderModel(dir, parentFolder);

			folderModel.UpdateReactionModels();

			folderModel.UpdateChildren();

			return folderModel;
			
		}
Esempio n. 4
0
		/// <summary>
		/// フォルダーを削除します。
		/// 引数で渡されたfolderのフォルダツリー全てを対象に探査します。
		/// </summary>
		/// <param name="folder"></param>
		/// <returns></returns>
		public bool RemoveFolder(FolderModel folder)
		{
			if (_Children.Contains(folder))
			{
				_Children.Remove(folder);

				folder.Folder.Delete(true);

				return true;
			}

			foreach(var child in _Children)
			{
				if (child.RemoveFolder(child))
				{
					return true;
				}
			}

			return false;
		}
Esempio n. 5
0
		public FolderReactionModel ReactionCopyTo(FolderReactionModel target, FolderModel destFolder)
		{
			throw new NotImplementedException("ReactionCopyTo is still implement.");
		}
		public ReactionManageFolderViewModel(FolderReactionManagePageViewModel pageVM, FolderModel folder)
		{
			PageVM = pageVM;
			Folder = folder;
			FolderName = Folder.Name;

			ReactionItems = Folder.Reactions
				.ToReadOnlyReactiveCollection(x => new ReactionListItemViewModel(PageVM, x));

			FolderItems = Folder.Children
				.ToReadOnlyReactiveCollection(x => new FolderListItemViewModel(PageVM, x));
			
			SelectedReaction = new ReactiveProperty<ReactionListItemViewModel>();

			SelectedReaction.Subscribe(x =>
			{
				if (x != null)
				{
					PageVM.ShowReaction(x.Reaction);
					x.IsSelected = true;
				}

				foreach (var item in ReactionItems.Where(y => y != x))
				{
					item.IsSelected = false;
				}

			});
			
		}
		internal FolderReactionModel ImportReactionFile(FolderModel folder, string path)
		{
			var importedReaction = FileSerializeHelper.LoadAsync<FolderReactionModel>(path);

			if (null != Monitor.FindReaction(importedReaction.Guid))
			{
				// alread exist reaction
				// Guidを張り替える?
			}
			else
			{
				folder.AddReaction(importedReaction);
			}

			return importedReaction;
		}
		internal void SelectFolder(FolderModel folder)
		{
			if (CurrentFolder?.Value.Folder == folder)
			{
				return;
			}

			// 一個上のフォルダを積むとき
			if (CurrentFolder.Value.Folder.Children.Any(x => x == folder))
			{
				var folderVM = new ReactionManageFolderViewModel(this, folder);
				FolderStack.Add(folderVM);

				return;
			}


			
			var existFolder = FolderStack.SingleOrDefault(x => x.Folder == folder);


			// 前のフォルダに戻る時
			if (existFolder != null)
			{
				var position = FolderStack.IndexOf(existFolder);

				position += 1;

				var removeFolders = FolderStack.Where((x, index) => position <= index).ToArray();
				foreach (var removeFolder in removeFolders)
				{
					FolderStack.Remove(removeFolder);
				}
			}

			// それ以外の時は一旦全削除して再度フォルダを積み直す
			else
			{
				FolderStack.Clear();

				var folderStackModels = folder.GetAllParent();

				folderStackModels.Add(folder);

				foreach (var parentFolder in folderStackModels)
				{
					FolderStack.Add(new ReactionManageFolderViewModel(this, parentFolder));
				}
			}
		}
		private void RecursiveFolder(FolderModel folder, Action<FolderReactionModel> act)
		{
			foreach (var reaction in folder.Reactions)
			{
				act(reaction);
			}

			// check child folder
			foreach (var childFolder in folder.Children)
			{
				RecursiveFolder(childFolder, act);
			}
		}