/// <summary>
 /// Create default workspace
 /// </summary>
 void CreateDefaultWorkspace()
 {
   var ws = new Workspace();
   ws.Open(AppSetting.DEFAULT_WORKSPACE_NAME);
   ws.SaveConfigData();
   Workspaces.Add(ws);
 }
    public MemoListControlSamplePage()
    {
      InitializeComponent();

      var vm = ViewModelLocator.MemoListPageVm;
      var ws = new Workspace();
      ws.Open("memoit");
      vm.OpenWorkspace(ws);

      _memolist.Build(vm.MemoList);
    }
Exemple #3
0
    public void Workspace_InitialCreation()
    {
      const string TEST_NAME = "abcdefg";
      Workspace w = new Workspace();
      w.Open(TEST_NAME);

      Assert.AreEqual("abcdefg", w.Name);
      Assert.AreEqual("/abcdefg", w.DropBoxPath);
      Assert.AreEqual(true, Workspace.Exists(TEST_NAME));
      w.Delete();
      Assert.AreEqual(false, Workspace.Exists(TEST_NAME));
    }
    /// <summary>
    /// Initialize constructor
    /// </summary>
    public WorkspaceListPageViewModel()
    {
      Workspaces = new List<Workspace>();

      StorageIo.EnsureDir(AppSetting.WORKSPACE_BASE_PATH);
      var paths =
        StorageIo.Dirs(AppSetting.WORKSPACE_BASE_PATH)
                 .ToList();
      foreach (var p in paths)
      {
        var ws = new Workspace();
        ws.Open(p);
        Workspaces.Add(ws);
      }

      if (IsEmptyWorkspace)
        CreateDefaultWorkspace();
    }
Exemple #5
0
    static void Assert_ChangeDropBoxPath(
                          string localpath,
                          string dropboxpath,
                          string newname)
    {
      var w = new Workspace();
      w.Open(PathUtil.NameOnly(localpath));

      w.ChangeDropboxPath(dropboxpath);
      Assert.AreEqual(dropboxpath, w.DropBoxPath);
      Assert.AreEqual(newname, w.Name);

      Assert.AreEqual(false, StorageIo.DirExists(localpath));
      Assert.AreEqual(true, StorageIo.DirExists(w.GetPath()));

      StorageIo.DeleteDir(localpath);
      StorageIo.DeleteDir(w.GetPath());
    }
    /// <summary>
    /// Open workspace
    /// </summary>
    /// <param name="ws">Workspace object</param>
    public void OpenWorkspace(Workspace ws)
    {
      if (ws.Thumb != null)
      {
        _img.Source = ws.Thumb;
      }
      else
      {
        ws.LoadThumb(() =>
          {
            _img.Source = ws.Thumb;
          });
      }

      _name.Text = ws.Name;
      _lastupdated.Text = string.Concat("Last updated:",
                                   ws.LastUpdated.ToString());
    }
    public void OverwritingTest()
    {
      DropboxLoginHelper.Login(
        (token, secret) =>
        {
          Workspace ws = new Workspace();
          ws.Open("memopad");
          ws.DropBoxToken = token;
          ws.DropBoxSecret = secret;

          StorageIo.WriteTextFile(Workspace.WORKSPACE_BASEPATH + "/memopad/a.txt", "THIS IS MY TEST");
          StorageIo.WriteTextFile(Workspace.WORKSPACE_BASEPATH + "/memopad/b.txt", "THIS IS MY TEST");
          StorageIo.WriteTextFile(Workspace.WORKSPACE_BASEPATH + "/memopad/c.txt", "THIS IS MY TEST");

          DropboxSync sync = new DropboxSync(ws);
          sync.Finished += (x, xe) =>
            {
              base.EnqueueTestComplete();
            };
          sync.Start();

        });
    }
Exemple #8
0
 /// <summary>
 /// Create workspace
 /// </summary>
 /// <param name="name">Workspace name</param>
 /// <returns>Workspace object</returns>
 public static Workspace Create(string name)
 {
   var ws = new Workspace();
   ws.Open(name);
   return ws;
 }
Exemple #9
0
 /// <summary>
 /// CTOR
 /// </summary>
 /// <param name="ws">Workspace</param>
 public DropboxSync(Workspace ws)
 {
   _ws = ws;
 }
Exemple #10
0
 /// <summary>
 /// Get local meta data list
 /// </summary>
 /// <returns></returns>
 List<LocalFileMeta> LocalMetaDataList(Workspace workspace)
 {
   var localfiles = workspace.GetMemoFiles(WorkspaceFileAccessMode.All);
   var localmetadatas =
     (
       from fn in localfiles
       let path = workspace.GetFullPath(fn)
       select new LocalFileMeta
       {
         Name = WorkspaceFileOp.StripShadowDeleteMark(fn),
         Path = path,
         ModifiedUtc = FileTimeDb.ReadLastModifiedTime(path),
         IsDeleted = WorkspaceFileOp.IsDeleteShadowFile(fn)
       }
       ).ToList();
   return localmetadatas;
 }
 /// <summary>
 /// Open workspace
 /// </summary>
 /// <param name="workspacepath">Workspace name</param>
 public void OpenWorkspace(Workspace ws)
 {
   Workspace = ws;
   BuildMemoList();
 }