Exemplo n.º 1
0
        /// <summary>
        /// override for item ordering, used when moving an item up or down
        /// </summary>
        /// <param name="direction">the movement direction of the selected item</param>
        /// <param name="selectedRow">the corresponding row in the data to move</param>
        private void ReorderItems(MovementDirection direction, PdfFileList.FileListRow selectedRow)
        {
            var currentPosition = selectedRow.order;

            PdfFileList.FileListRow currentRow = this.fileList.FileList.FindByid(selectedRow.id);
            switch (direction)
            {
            case MovementDirection.Down:
            {
                PdfFileList.FileListRow nextRow = this.fileList.FileList.Where(r => r.order == currentPosition + 1).First();
                nextRow.order    = currentPosition;
                currentRow.order = currentPosition + 1;
                break;
            }

            case MovementDirection.Up:
            {
                PdfFileList.FileListRow prevRow = this.fileList.FileList.Where(r => r.order == currentPosition - 1).First();
                prevRow.order    = currentPosition;
                currentRow.order = currentPosition - 1;
                break;
            }
            }
            this.fileList.AcceptChanges();
            AssignListContent();
        }
Exemplo n.º 2
0
        /// <summary>
        /// handles events when the user clicks "Add" button
        /// opens the "File Open Dialog"
        /// allows the user to add file(s) to the list
        /// </summary>
        /// <param name="sender">the button</param>
        /// <param name="e">event arguments</param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            ofDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var result = ofDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                foreach (var file in ofDialog.FileNames)
                {
                    var fileInfo = new FileInfo(file);
                    PdfFileList.FileListRow row = fileList.FileList.NewFileListRow();
                    row.filePath = fileInfo.DirectoryName;
                    row.filename = fileInfo.Name;
                    row.order    = fileList.FileList.Rows.Count;
                    fileList.FileList.AddFileListRow(row);
                }
                fileList.AcceptChanges();
                AssignListContent();
            }
        }