// // Copyright 2014 Perforce Software Inc. // using Perforce.Helper; using Perforce.P4; using System; using System.Collections.Generic; namespace Perforce.ViewModel { public class SelectWorkspaceFormViewModel : ViewModelBase { private IList _workspaceList; public void Init() { var helper = Utility.GetPerforceHelper(check: false); var workspaces = new List(); if (helper != null) { try { var clients = helper.ListClients(validLocalOnly: true); if (clients != null) { foreach (var c in clients) { // only get non-stream clients if (string.IsNullOrEmpty(c.Stream)) { workspaces.Add(new WorkspaceItem { Name = c.Name, Root = c.Root, DepotPath = "", Description = c.Description.Trim() }); } } } } catch (P4Exception p4e) { Console.WriteLine(p4e.Message); } } WorkspaceList = workspaces; } public IList WorkspaceList { get { return _workspaceList; } set { _workspaceList = value; OnPropertyChanged("WorkspaceList"); } } } public class WorkspaceItem { public string Name { get; set; } public string Root { get; set; } public string DepotPath { get; set; } public string Description { get; set; } } }