private void Button_Split_Click(object sender, EventArgs e) { if (DialogResult.OK == ChooseFolder.ShowDialog()) { Cursor = Cursors.WaitCursor; Microsoft.Office.Interop.PowerPoint.Application A = new Microsoft.Office.Interop.PowerPoint.Application(); foreach (string file in MyFiles) { FileInfo F = new FileInfo(file); string Name = F.Name; Presentation P = A.Presentations.Open(file, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse); for (int i = 1; i <= P.Slides.Count; i++) { P.Slides[i].Copy(); Presentation P1 = A.Presentations.Add(MsoTriState.msoFalse); P1.Slides.Paste(1); P1.Slides[1].FollowMasterBackground = MsoTriState.msoFalse; P1.SaveAs(ChooseFolder.SelectedPath + "\\" + i.ToString() + "_" + Name, PpSaveAsFileType.ppSaveAsDefault, MsoTriState.msoFalse); P1.Close(); } P.Close(); } Cursor = Cursors.Default; } }
/// <summary> /// Constructor /// </summary> /// <param name="w">The window</param> /// <param name="Client">The client</param> public IncomingTransferViewModel(ConnectionWindow w, TcpClient Client) { //------------------------------------ // Init //------------------------------------ PrivateSender = false; TheWindow = w; SelectFolder = new ChooseFolder(this); //------------------------------------ // Add the transfer but don't start it yet //------------------------------------ List <Task> Transfers = (List <Task>)Application.Current.Properties["Transfers"]; Transfers.Add(Task.Run(() => { Receive Receiver = new Receive(Client); if (!Receiver.ParseHello()) { // Not a valid request? then just close the window (NOTE: it is still hidden at this point) TheWindow.Dispatcher.InvokeAsync(() => { TheWindow.Close(); }); return; } else { // Open the window to ask user to accept or reject TheWindow.Dispatcher.InvokeAsync(() => { TheWindow.InitializeComponent(); TheWindow.DataContext = this; TheWindow.Topmost = true; TheWindow.Show(); TheWindow.Activate(); TheWindow.Topmost = false; }); } //------------------------------------ // Render data //------------------------------------ if (Receiver.SenderUser != null) { UserRequestText = Receiver.SenderUser.Name + " wants to send you"; UserProfilePicture = Receiver.SenderUser.PicBytes; } else { UserRequestText = "A private user wants to send you"; PrivateSender = true; } if (!Receiver.IsFolder) { FileName = Receiver.FileName + "." + Receiver.FileExtension; UserRequestText += " a file:"; _Size = Receiver.FileSize; Extension = Receiver.FileExtension; } else { string[] _name = Receiver.FileName.Split('/'); FileName = _name[0]; UserRequestText += " a folder:"; } //------------------------------------ // Wait for user's confirmation //------------------------------------ lock (this) { if (Status == Reply.UNANSWERED) { Monitor.Wait(this); } } //------------------------------------ // Deal with user's decision //------------------------------------ if (!SelectedPath.Equals(String.Empty)) { Receiver.FolderLocation = SelectedPath; } if (Status == Reply.ACCEPTED) { Receiver.Start(); } else { Receiver.Reject(true); } })); Accept = new AcceptTransfer(this); Reject = new RejectTransfer(this); }