Example #1
0
        private void ObjectReceived(object capability, ObjectReceivedEventArgs ea)
        {
            if (ea.Data is FileObject)
            {
                FileObject fileObject = ea.Data as FileObject;
                FileInfo   fileInfo   = new FileInfo(fileObject.Name);

                Type tCapability = null;
                ItemReceivedDialog dlgFileReceived = null;

                if (tCapability != null)
                {
                    Capability.NameAttribute attrName = (Capability.NameAttribute)
                                                        Attribute.GetCustomAttribute(tCapability, typeof(Capability.NameAttribute));

                    Capability.PayloadTypeAttribute attrPT = (Capability.PayloadTypeAttribute)
                                                             Attribute.GetCustomAttribute(tCapability, typeof(Capability.PayloadTypeAttribute));

                    dlgFileReceived = new ItemReceivedDialog(Strings.CapabilityReceived,
                                                             Strings.UserSentYouCapability);
                    dlgFileReceived.Button1Label = Strings.InstallHotkey;
                    dlgFileReceived.FileIconTip  = string.Format(CultureInfo.CurrentCulture,
                                                                 Strings.CapabilityNamePayloadType, attrName.Name, attrPT.PayloadType.ToString());
                }
                else
                {
                    dlgFileReceived = new ItemReceivedDialog(Strings.FileReceived, Strings.UserSentYouFile);
                }

                dlgFileReceived.Image = Image.FromStream(
                    System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MSR.LST.ConferenceXP.Images.FileReceived.gif"));
                dlgFileReceived.From         = ea.Participant.Name;
                dlgFileReceived.Avatar       = ea.Participant.Icon;
                dlgFileReceived.AvatarTip    = Strings.AvatarTipText;
                dlgFileReceived.File         = fileInfo.Name;
                dlgFileReceived.FileIcon     = fileObject.Icon;
                dlgFileReceived.FileIconTip += string.Format(CultureInfo.CurrentCulture, Strings.FileSize,
                                                             ((double)fileObject.Data.Length / 1024.0).ToString("#,#.00", CultureInfo.CurrentCulture));
                dlgFileReceived.Time = DateTime.Now.ToString("h:mm:ss tt", CultureInfo.CurrentCulture);
                if (dlgFileReceived.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                if (tCapability != null)
                {
                    RtlAwareMessageBox.Show(this, Strings.NotYetImplemented, string.Empty, MessageBoxButtons.OK,
                                            MessageBoxIcon.None, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0);
                }
                else
                {
                    SaveFileDialog saveDialog = new SaveFileDialog();
                    saveDialog.FileName = fileInfo.Name;
                    if (Directory.Exists(fileInfo.DirectoryName))
                    {
                        saveDialog.InitialDirectory = fileInfo.DirectoryName;
                    }
                    saveDialog.Filter           = "All files (*.*)|*.*";
                    saveDialog.CheckPathExists  = true;
                    saveDialog.OverwritePrompt  = true;
                    saveDialog.RestoreDirectory = true;
                    if (saveDialog.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }

                    FileStream fileStream = File.OpenWrite(saveDialog.FileName);
                    fileStream.Write(fileObject.Data, 0, fileObject.Data.Length);
                    fileStream.Close();
                }
            }
        }
        private void ObjectReceived(object capability, ObjectReceivedEventArgs ea)
        {
            if (ea.Data is FileObject)
            {
                FileObject fileObject = ea.Data as FileObject;
                FileInfo fileInfo = new FileInfo(fileObject.Name);

                Type tCapability = null;
            //              if (fileInfo.Extension.ToLower() == ".dll")
            //                  tCapability = GetCapability(fileObject.Data);

                ItemReceivedDialog dlgFileReceived = null;

                if (tCapability != null)
                {
                    Capability.NameAttribute attrName = (Capability.NameAttribute)
                        Attribute.GetCustomAttribute(tCapability, typeof(Capability.NameAttribute));

                    Capability.PayloadTypeAttribute attrPT = (Capability.PayloadTypeAttribute)
                        Attribute.GetCustomAttribute(tCapability, typeof(Capability.PayloadTypeAttribute));

                    dlgFileReceived = new ItemReceivedDialog("Capability received", "A user has just sent you a capability");
                    dlgFileReceived.Button1Label = "&Install";
                    dlgFileReceived.FileIconTip = "Capability name: " + attrName.Name + Environment.NewLine +
                        "Payload type: " + attrPT.PayloadType.ToString() + Environment.NewLine;
                }
                else
                {
                    dlgFileReceived = new ItemReceivedDialog("File received", "A user has just sent you a file");
                }

                dlgFileReceived.Image = Image.FromStream(
                    System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MSR.LST.ConferenceXP.Images.FileReceived.gif"));
                dlgFileReceived.From = ea.Participant.Name;
                dlgFileReceived.Avatar = ea.Participant.Icon;
                dlgFileReceived.AvatarTip = "IP: " + ea.Participant.RtpParticipant.IPAddress.ToString() + Environment.NewLine +
                    "Id: " + ea.Participant.Identifier + Environment.NewLine +
                    "Email: " + ea.Participant.Email + Environment.NewLine +
                    "Phone: " + ea.Participant.Phone;
                dlgFileReceived.File = fileInfo.Name;
                dlgFileReceived.FileIcon = fileObject.Icon;
                dlgFileReceived.FileIconTip += "File size: " + ((double)fileObject.Data.Length / 1024.0).ToString("#,#.00") + " KB";
                dlgFileReceived.Time = DateTime.Now.ToString("h:mm:ss tt");
                if (dlgFileReceived.ShowDialog() != DialogResult.OK)
                    return;

                if (tCapability != null)
                {
                    MessageBox.Show("Not yet implemented");
                }
                else
                {
                    SaveFileDialog saveDialog = new SaveFileDialog();
                    saveDialog.FileName = fileInfo.Name;
                    if (Directory.Exists(fileInfo.DirectoryName))
                        saveDialog.InitialDirectory = fileInfo.DirectoryName;
                    saveDialog.Filter = "All files (*.*)|*.*";
                    saveDialog.CheckPathExists = true;
                    saveDialog.OverwritePrompt = true;
                    saveDialog.RestoreDirectory = true;
                    if (saveDialog.ShowDialog() != DialogResult.OK)
                        return;

                    FileStream fileStream = File.OpenWrite(saveDialog.FileName);
                    fileStream.Write(fileObject.Data, 0, fileObject.Data.Length);
                    fileStream.Close();
                }
            }
        }
        private void ObjectReceived(object capability, ObjectReceivedEventArgs ea)
        {
            if (ea.Data is FileObject)
            {
                FileObject fileObject = ea.Data as FileObject;
                FileInfo fileInfo = new FileInfo(fileObject.Name);

                Type tCapability = null;
                ItemReceivedDialog dlgFileReceived = null;

                if (tCapability != null)
                {
                    Capability.NameAttribute attrName = (Capability.NameAttribute)
                        Attribute.GetCustomAttribute(tCapability, typeof(Capability.NameAttribute));

                    Capability.PayloadTypeAttribute attrPT = (Capability.PayloadTypeAttribute)
                        Attribute.GetCustomAttribute(tCapability, typeof(Capability.PayloadTypeAttribute));

                    dlgFileReceived = new ItemReceivedDialog(Strings.CapabilityReceived, 
                        Strings.UserSentYouCapability);
                    dlgFileReceived.Button1Label = Strings.InstallHotkey;
                    dlgFileReceived.FileIconTip = string.Format(CultureInfo.CurrentCulture, 
                        Strings.CapabilityNamePayloadType, attrName.Name, attrPT.PayloadType.ToString());
                }
                else
                {
                    dlgFileReceived = new ItemReceivedDialog(Strings.FileReceived, Strings.UserSentYouFile);
                }

                dlgFileReceived.Image = Image.FromStream(
                    System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MSR.LST.ConferenceXP.Images.FileReceived.gif"));
                dlgFileReceived.From = ea.Participant.Name;
                dlgFileReceived.Avatar = ea.Participant.Icon;
                dlgFileReceived.AvatarTip = Strings.AvatarTipText; 
                dlgFileReceived.File = fileInfo.Name;
                dlgFileReceived.FileIcon = fileObject.Icon;
                dlgFileReceived.FileIconTip += string.Format(CultureInfo.CurrentCulture, Strings.FileSize, 
                    ((double)fileObject.Data.Length / 1024.0).ToString("#,#.00", CultureInfo.CurrentCulture));
                dlgFileReceived.Time = DateTime.Now.ToString("h:mm:ss tt", CultureInfo.CurrentCulture);
                if (dlgFileReceived.ShowDialog() != DialogResult.OK)
                    return;

                if (tCapability != null)
                {
                    RtlAwareMessageBox.Show(this, Strings.NotYetImplemented, string.Empty, MessageBoxButtons.OK, 
                        MessageBoxIcon.None, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0);
                }
                else
                {
                    SaveFileDialog saveDialog = new SaveFileDialog();
                    saveDialog.FileName = fileInfo.Name;
                    if (Directory.Exists(fileInfo.DirectoryName))
                        saveDialog.InitialDirectory = fileInfo.DirectoryName;
                    saveDialog.Filter = "All files (*.*)|*.*";
                    saveDialog.CheckPathExists = true;
                    saveDialog.OverwritePrompt = true;
                    saveDialog.RestoreDirectory = true;
                    if (saveDialog.ShowDialog() != DialogResult.OK)
                        return;

                    FileStream fileStream = File.OpenWrite(saveDialog.FileName);
                    fileStream.Write(fileObject.Data, 0, fileObject.Data.Length);
                    fileStream.Close();
                }
            }
        }
Example #4
0
        private void ObjectReceived(object capability, ObjectReceivedEventArgs ea)
        {
            if (ea.Data is FileObject)
            {
                FileObject fileObject = ea.Data as FileObject;
                FileInfo   fileInfo   = new FileInfo(fileObject.Name);

                Type tCapability = null;
//              if (fileInfo.Extension.ToLower() == ".dll")
//                  tCapability = GetCapability(fileObject.Data);

                ItemReceivedDialog dlgFileReceived = null;

                if (tCapability != null)
                {
                    Capability.NameAttribute attrName = (Capability.NameAttribute)
                                                        Attribute.GetCustomAttribute(tCapability, typeof(Capability.NameAttribute));

                    Capability.PayloadTypeAttribute attrPT = (Capability.PayloadTypeAttribute)
                                                             Attribute.GetCustomAttribute(tCapability, typeof(Capability.PayloadTypeAttribute));

                    dlgFileReceived = new ItemReceivedDialog("Capability received", "A user has just sent you a capability");
                    dlgFileReceived.Button1Label = "&Install";
                    dlgFileReceived.FileIconTip  = "Capability name: " + attrName.Name + Environment.NewLine +
                                                   "Payload type: " + attrPT.PayloadType.ToString() + Environment.NewLine;
                }
                else
                {
                    dlgFileReceived = new ItemReceivedDialog("File received", "A user has just sent you a file");
                }

                dlgFileReceived.Image = Image.FromStream(
                    System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MSR.LST.ConferenceXP.Images.FileReceived.gif"));
                dlgFileReceived.From      = ea.Participant.Name;
                dlgFileReceived.Avatar    = ea.Participant.Icon;
                dlgFileReceived.AvatarTip = "IP: " + ea.Participant.RtpParticipant.IPAddress.ToString() + Environment.NewLine +
                                            "Id: " + ea.Participant.Identifier + Environment.NewLine +
                                            "Email: " + ea.Participant.Email + Environment.NewLine +
                                            "Phone: " + ea.Participant.Phone;
                dlgFileReceived.File         = fileInfo.Name;
                dlgFileReceived.FileIcon     = fileObject.Icon;
                dlgFileReceived.FileIconTip += "File size: " + ((double)fileObject.Data.Length / 1024.0).ToString("#,#.00") + " KB";
                dlgFileReceived.Time         = DateTime.Now.ToString("h:mm:ss tt");
                if (dlgFileReceived.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                if (tCapability != null)
                {
                    MessageBox.Show("Not yet implemented");
                }
                else
                {
                    SaveFileDialog saveDialog = new SaveFileDialog();
                    saveDialog.FileName = fileInfo.Name;
                    if (Directory.Exists(fileInfo.DirectoryName))
                    {
                        saveDialog.InitialDirectory = fileInfo.DirectoryName;
                    }
                    saveDialog.Filter           = "All files (*.*)|*.*";
                    saveDialog.CheckPathExists  = true;
                    saveDialog.OverwritePrompt  = true;
                    saveDialog.RestoreDirectory = true;
                    if (saveDialog.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }

                    FileStream fileStream = File.OpenWrite(saveDialog.FileName);
                    fileStream.Write(fileObject.Data, 0, fileObject.Data.Length);
                    fileStream.Close();
                }
            }
        }