Exemple #1
0
        private async void ButtonNewFolder_Click(object sender, RoutedEventArgs e)
        {
            TreeSmartItem sItem = TreeViewFolders.SelectedItem as TreeSmartItem;

            if ((sItem == null) || sItem.HasError)
            {
                return;
            }

            NewFolderWindow NFW = new NewFolderWindow(this, false);

            if (!(bool)NFW.ShowDialog() || NFW.newFolder.NullEmpty())
            {
                return;
            }

            //item.Expanded = true;
            TreeSmartItem item;

            if (sItem.Parent != null)
            {
                item = sItem.Parent;
            }
            else
            {
                item = sItem;
            }

            if (item.HasDummy)
            {
                item.Items.Clear();
                item.HasDummy = false;
            }

            string path = item.FullName;

            PathHelper.AddEndningSlash(ref path);
            TreeSmartItem folder = new TreeSmartItem(NFW.newFolder, path);

            item.Items.Add(folder);

            folder.OptColor  = SolidColors.DarkGreen;
            folder.Operation = AppLanguage.Get("LangOperationCreating");

            if (await ClientHelper.NewFolder(NFW.newFolder, path))
            {
                folder.Selected  = true;
                folder.OptColor  = SolidColors.SolidBlue;
                folder.Operation = AppLanguage.Get("LangOperationCreated");
            }
            else
            {
                folder.Items.Clear();
                folder.HasError  = true;
                folder.OptColor  = SolidColors.DarkRed;
                folder.Operation = AppLanguage.Get("LangOperationCreateError");
                folder.Items.Add(new TreeSmartItem(AppLanguage.Get("LangTextNoFoldersInside"), dummyIcon));
            }
        }
        internal static async Task<string> New(Window owner, bool isLocal)
        {
            NewFolderWindow NF = new NewFolderWindow(owner, isLocal);

            if ((bool)NF.ShowDialog())
            {
                if (isLocal)
                {
                    if (DirectoryHelper.Create(LocalHelper.CurrentPath + @"\" + NF.newFolder))
                        return NF.newFolder;
                }
                else if (await ClientHelper.NewFolder(NF.newFolder, ClientHelper.CurrentPath))
                    return NF.newFolder;
            }

            return null;
        }