Esempio n. 1
0
        public FileNameWindow(string fileFullName, ICCAssociationType type)
        {
            InitializeComponent();

            this.filePath             = System.IO.Path.GetDirectoryName(fileFullName) + System.IO.Path.DirectorySeparatorChar;
            this.fileExt              = System.IO.Path.GetExtension(fileFullName);
            this.TextBoxFileName.Text = System.IO.Path.GetFileNameWithoutExtension(fileFullName);

            this.type = type;
            if (type == ICCAssociationType.OutlookEmailMessage)
            {
                this.Label.Content = "Please enter the Email subject:";
            }

            this.TextBoxFileName.SelectionStart = this.TextBoxFileName.Text.Length;
            this.TextBoxFileName.Focus();
        }
Esempio n. 2
0
        public FileNameWindow(string fileFullName, ICCAssociationType type)
        {
            InitializeComponent();

            this.filePath = System.IO.Path.GetDirectoryName(fileFullName) + System.IO.Path.DirectorySeparatorChar;
            this.fileExt = System.IO.Path.GetExtension(fileFullName);
            this.TextBoxFileName.Text = System.IO.Path.GetFileNameWithoutExtension(fileFullName);

            this.type = type;
            if (type == ICCAssociationType.OutlookEmailMessage)
            {
                this.Label.Content = "Please enter the Email subject:";
            }

            this.TextBoxFileName.SelectionStart = this.TextBoxFileName.Text.Length;
            this.TextBoxFileName.Focus();
        }
Esempio n. 3
0
        public static string GenerateFileName(string fileName, ICCAssociationType type)
        {
            string newFileName = String.Empty;

            foreach (char ch in fileName)
            {
                if (!FileNameChecker.InvalidCharList.Contains(ch.ToString()))
                {
                    newFileName += ch;
                }
            }

            switch (type)
            {
            case ICCAssociationType.NotepadTextDocument:
                return(newFileName + ext_txt);

            case ICCAssociationType.WordDocument:
                return(newFileName + ext_word);

            case ICCAssociationType.ExcelSpreadsheet:
                return(newFileName + ext_excel);

            case ICCAssociationType.PowerPointPresentation:
                return(newFileName + ext_ppt);

            case ICCAssociationType.OutlookEmailMessage:
                if (newFileName == "")
                {
                    newFileName = "New Email";
                }
                return(newFileName + ext_email);

            case ICCAssociationType.OneNoteSection:
                return(newFileName + ext_onenote);

            case ICCAssociationType.TwitterUpdate:
                return(newFileName + ext_web);

            default:
                return(String.Empty);
            }
            ;
        }
Esempio n. 4
0
        public FileNameWindow(string fileFullName, string label)
        {
            InitializeComponent();

            if ((isFolder = System.IO.Directory.Exists(fileFullName)) == true)
            {
                this.filePath             = System.IO.Path.GetDirectoryName(System.IO.Path.GetDirectoryName(fileFullName)) + System.IO.Path.DirectorySeparatorChar;
                this.fileExt              = String.Empty;
                this.TextBoxFileName.Text = System.IO.Path.GetFileNameWithoutExtension(System.IO.Path.GetDirectoryName(fileFullName));
            }
            else
            {
                this.filePath             = System.IO.Path.GetDirectoryName(fileFullName) + System.IO.Path.DirectorySeparatorChar;
                this.fileExt              = System.IO.Path.GetExtension(fileFullName);
                this.TextBoxFileName.Text = System.IO.Path.GetFileNameWithoutExtension(fileFullName);
            }

            this.type = ICCAssociationType.WordDocument;

            this.Label.Content = label;
            this.TextBoxFileName.SelectionStart = this.TextBoxFileName.Text.Length;
            this.TextBoxFileName.Focus();
        }
Esempio n. 5
0
        public static string GetTemplate(ICCAssociationType at)
        {
            switch (at)
            {
            case ICCAssociationType.WordDocument:
                return(appDataFolderPath + templatePath + word);

            case ICCAssociationType.ExcelSpreadsheet:
                return(appDataFolderPath + templatePath + excel);

            case ICCAssociationType.PowerPointPresentation:
                return(appDataFolderPath + templatePath + ppt);

            case ICCAssociationType.OneNoteSection:
                return(appDataFolderPath + templatePath + onenote);

            case ICCAssociationType.NotepadTextDocument:
                return(appDataFolderPath + templatePath + notepad);

            default:
                return(null);
            }
            ;
        }
Esempio n. 6
0
        public static string GenerateFileName(string fileName, ICCAssociationType type)
        {
            string newFileName = String.Empty;
            foreach (char ch in fileName)
            {
                if (!FileNameChecker.InvalidCharList.Contains(ch.ToString()))
                {
                    newFileName += ch;
                }
            }

            switch(type)
            {
                case ICCAssociationType.NotepadTextDocument:
                    return newFileName + ext_txt;
                case ICCAssociationType.WordDocument:
                    return newFileName + ext_word;
                case ICCAssociationType.ExcelSpreadsheet:
                    return newFileName + ext_excel;
                case ICCAssociationType.PowerPointPresentation:
                    return newFileName + ext_ppt;
                case ICCAssociationType.OutlookEmailMessage:
                    if (newFileName == "")
                    {
                        newFileName = "New Email";
                    }
                    return newFileName + ext_email;
                case ICCAssociationType.OneNoteSection:
                    return newFileName + ext_onenote;
                case ICCAssociationType.TwitterUpdate:
                    return newFileName + ext_web;
                default:
                    return String.Empty;
            };
        }
Esempio n. 7
0
 public static string GetTemplate(ICCAssociationType at)
 {
     switch (at)
     {
         case ICCAssociationType.WordDocument:
             return appDataFolderPath + templatePath + word;
         case ICCAssociationType.ExcelSpreadsheet:
             return appDataFolderPath + templatePath + excel;
         case ICCAssociationType.PowerPointPresentation:
             return appDataFolderPath + templatePath + ppt;
         case ICCAssociationType.OneNoteSection:
             return appDataFolderPath + templatePath + onenote;
         case ICCAssociationType.NotepadTextDocument:
             return appDataFolderPath + templatePath + notepad;
         default:
             return null;
     };
 }
Esempio n. 8
0
        private void HandleICC(Element element, ICCAssociationType type)
        {
            // Note: defaultName does NOT contain file extension
            string defaultName = String.Empty;

            bool insertBelow = true;
            TextBox tb = GetTextBox(element);
            if (tb.SelectionStart == 0 && tb.Text != String.Empty)
            {
                insertBelow = false;
            }

            if (tb.SelectedText != String.Empty)
            {
                defaultName = tb.SelectedText;
                insertBelow = true;
            }
            else
            {
                defaultName = element.NoteText;
            }

            if (defaultName.Length > StartProcess.MAX_EXTRACTNAME_LENGTH)
                defaultName = defaultName.Substring(0, StartProcess.MAX_EXTRACTNAME_LENGTH);
            while (defaultName.EndsWith("."))
                defaultName = defaultName.TrimEnd('.');

            switch (type)
            {
                case ICCAssociationType.TwitterUpdate:
                    TwitterWindow tw = new TwitterWindow(defaultName);
                    if (tw.ShowDialog().Value == true)
                    {
                        Tweet tweet = new Tweet{ Username = tw.Username, Password = tw.Password, Message = tw.Tweet, };
                        elementControl.ICC(element, tweet, insertBelow, type);
                    }
                    break;
                case ICCAssociationType.OutlookEmailMessage:
                    if (defaultName.Trim() == String.Empty)
                    {
                        defaultName = "New Email";
                    }
                    elementControl.ICC(element, defaultName, insertBelow, type);
                    break;
                default:
                    string fileFullName = element.Path + ICCFileNameHandler.GenerateFileName(defaultName, type);
                    FileNameWindow fnw = new FileNameWindow(fileFullName, type);
                    if (fnw.ShowDialog().Value == true)
                    {
                        elementControl.ICC(element, fnw.FileName, insertBelow, type);
                    }
                    break;
            };

            GetFocusToElementTextBox(elementControl.CurrentElement, elementControl.CurrentElement.NoteText.Length, false, false);
        }
Esempio n. 9
0
 private void CreateAndOpenICCFile(Element element, string fileFullName, ICCAssociationType type)
 {
     switch (type)
     {
         case ICCAssociationType.NotepadTextDocument:
             /*TextWriter tw = new StreamWriter(fileFullName);
             tw.Close();
             System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(fileFullName);
             psi.ErrorDialog = false;
             psi.UseShellExecute = true;
             System.Diagnostics.Process.Start(psi);*/
             System.IO.File.Copy(FileTypeHandler.GetTemplate(ICCAssociationType.NotepadTextDocument), fileFullName);
             System.Diagnostics.Process.Start(fileFullName);
             break;
         case ICCAssociationType.WordDocument:
             /*Word.Application wordApp = new Word.Application();
             wordApp.Visible = true;
             object oMissing = System.Reflection.Missing.Value;
             Word.Document wordDoc = wordApp.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);
             object oSavePath = fileFullName;
             wordDoc.SaveAs(ref oSavePath,
                 ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
             wordApp = null;*/
             System.IO.File.Copy(FileTypeHandler.GetTemplate(ICCAssociationType.WordDocument), fileFullName);
             System.Diagnostics.Process.Start(fileFullName);
             break;
         case ICCAssociationType.ExcelSpreadsheet:
             /*Excel.Application excelApp = new Excel.Application();
             excelApp.Visible = true;
             Excel.Workbooks workbooks = excelApp.Workbooks;
             Excel._Workbook workbook = workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet);
             Excel._Worksheet worksheet = (Excel._Worksheet)workbook.ActiveSheet;
             worksheet.SaveAs(fileFullName,
                 Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
             excelApp = null;*/
             System.IO.File.Copy(FileTypeHandler.GetTemplate(ICCAssociationType.ExcelSpreadsheet), fileFullName);
             System.Diagnostics.Process.Start(fileFullName);
             break;
         case ICCAssociationType.PowerPointPresentation:
             /*PowerPoint.Application pptApp = new PowerPoint.Application();
             pptApp.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
             PowerPoint.Presentations presentations = pptApp.Presentations;
             PowerPoint._Presentation presentation = presentations.Add(Microsoft.Office.Core.MsoTriState.msoTrue);
             presentation.SaveAs(fileFullName,
                 Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsDefault, Microsoft.Office.Core.MsoTriState.msoTrue);
             pptApp = null;*/
             System.IO.File.Copy(FileTypeHandler.GetTemplate(ICCAssociationType.PowerPointPresentation), fileFullName);
             System.Diagnostics.Process.Start(fileFullName);
             break;
         case ICCAssociationType.OutlookEmailMessage:
             Outlook.Application olApp = new Outlook.Application();
             Outlook.MailItem mail = olApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem) as Outlook.MailItem;
             mail.Subject = System.IO.Path.GetFileNameWithoutExtension(fileFullName);
             /*mail.Body += "\n\n\n----------\n" +
                 "This email was sent from Planz(TM).\n" +
                 "To find out more, see a video or download, visit: http://kftf.ischool.washington.edu/planner_index.htm";*/
             if (element.Status == ElementStatus.TempStatus_HasEmailAttachment)
             {
                 mail.Attachments.Add(element.TempData, Missing.Value, Missing.Value, Missing.Value);
                 element.Status = ElementStatus.Normal;
                 element.TempData = String.Empty;
             }
             Outlook.UserProperties props = mail.UserProperties;
             Outlook.UserProperty prop = props.Add("PlanzID", Microsoft.Office.Interop.Outlook.OlUserPropertyType.olText, false, 0);
             prop.Value = element.ID.ToString();
             mail.Display(false);
             mail.Save();
             WshShellClass wshShell = new WshShellClass();
             IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)wshShell.CreateShortcut(fileFullName);
             string targetPath = OutlookSupportFunction.GenerateShortcutTargetPath();
             shortcut.TargetPath = targetPath;
             shortcut.Arguments = "/select outlook:" + mail.EntryID;
             shortcut.Description = "PlanzICC";
             shortcut.Save();
             break;
         case ICCAssociationType.OneNoteSection:
             /*OneNote.ApplicationClass onApp = new OneNote.ApplicationClass();
             string sectionID;
             string pageID;
             //string outputXML;
             onApp.OpenHierarchy(fileFullName, String.Empty, out sectionID, Microsoft.Office.Interop.OneNote.CreateFileType.cftSection);
             //onApp.GetHierarchy(sectionID, Microsoft.Office.Interop.OneNote.HierarchyScope.hsSections, out outputXML);
             onApp.CreateNewPage(sectionID, out pageID, Microsoft.Office.Interop.OneNote.NewPageStyle.npsBlankPageWithTitle);
             onApp.NavigateTo(sectionID, pageID, true);*/
             System.IO.File.Copy(FileTypeHandler.GetTemplate(ICCAssociationType.OneNoteSection), fileFullName);
             System.Diagnostics.Process.Start(fileFullName);
             break;
         default:
             break;
     };
 }
Esempio n. 10
0
        public void ICC(Element element, Object obj, bool insertBelow, ICCAssociationType type)
        {
            Element targetElement = null;

            try
            {
                string fileName = String.Empty;
                if (obj is Tweet)
                {
                    fileName = ((Tweet)obj).Message;
                }
                else if (obj is String)
                {
                    fileName = (string)obj;
                }

                string fileFullName = element.Path + ICCFileNameHandler.GenerateFileName(fileName, type);

                switch (element.Type)
                {
                    case ElementType.Heading:
                        if (element.IsExpanded)
                        {
                            targetElement = CreateNewElement(ElementType.Note, fileName);
                            InsertElement(targetElement, element, 0);
                        }
                        else
                        {
                            fileFullName = element.ParentElement.Path + ICCFileNameHandler.GenerateFileName(fileName, type);
                            if (insertBelow)
                            {
                                targetElement = CreateNewElement(ElementType.Note, fileName);
                                InsertElement(targetElement, element.ParentElement, element.Position + 1);
                            }
                            else
                            {
                                targetElement = CreateNewElement(ElementType.Note, fileName);
                                InsertElement(targetElement, element.ParentElement, element.Position);
                            }
                        }
                        break;
                    case ElementType.Note:
                        if (element.HasAssociation == false)
                        {
                            if (insertBelow)
                            {
                                if (element.NoteText.Trim() == String.Empty)
                                {
                                    element.NoteText = fileName;
                                }
                                targetElement = element;
                            }
                            else
                            {
                                targetElement = CreateNewElement(ElementType.Note, fileName);
                                InsertElement(targetElement, element.ParentElement, element.Position);
                            }
                        }
                        else
                        {
                            if (insertBelow)
                            {
                                targetElement = CreateNewElement(ElementType.Note, fileName);
                                InsertElement(targetElement, element.ParentElement, element.Position + 1);
                            }
                            else
                            {
                                targetElement = CreateNewElement(ElementType.Note, fileName);
                                InsertElement(targetElement, element.ParentElement, element.Position);
                            }
                        }
                        break;
                };

                switch (type)
                {
                    case ICCAssociationType.OutlookEmailMessage:
                        targetElement.AssociationType = ElementAssociationType.Email;
                        if (element.AssociationType == ElementAssociationType.File)
                        {
                            targetElement.Status = ElementStatus.TempStatus_HasEmailAttachment;
                            targetElement.TempData = element.AssociationURIFullPath;
                        }

                        string folderPath = System.IO.Directory.GetParent(fileFullName).FullName + System.IO.Path.DirectorySeparatorChar;
                        string fileNameWithoutExt = System.IO.Path.GetFileNameWithoutExtension(fileFullName);
                        string ext = ShortcutNameConverter.mailLinkExt;
                        string newShortcutName = ShortcutNameConverter.RenameShortcutName(fileNameWithoutExt, ext, folderPath);
                        fileFullName = folderPath + newShortcutName;
                        if (fileNameWithoutExt + ext != newShortcutName)
                        {
                            targetElement.AssociationURI = newShortcutName;
                        }

                        break;
                    case ICCAssociationType.TwitterUpdate:
                        targetElement.AssociationType = ElementAssociationType.Tweet;
                        break;
                    default:
                        targetElement.AssociationType = ElementAssociationType.File;
                        break;
                };

                if (type == ICCAssociationType.TwitterUpdate)
                {
                    CreateTwitterUpdate(targetElement, fileFullName, obj as Tweet);
                }
                else
                {
                    CreateAndOpenICCFile(targetElement, fileFullName, type);
                }

                AssignICCInfo(targetElement, fileFullName);

                currentElement = targetElement;
            }
            catch (Exception ex)
            {
                targetElement.AssociationType = ElementAssociationType.None;
                targetElement.AssociationURI = String.Empty;
                targetElement.TailImageSource = String.Empty;

                UpdateElement(targetElement);

                string message = "ICC\n" + ex.Message;
                OnOperationError(targetElement, new OperationErrorEventArgs { Message = message });
            }
        }
Esempio n. 11
0
        public FileNameWindow(string fileFullName, string label)
        {
            InitializeComponent();

            if ((isFolder = System.IO.Directory.Exists(fileFullName)) == true)
            {
                this.filePath = System.IO.Path.GetDirectoryName(System.IO.Path.GetDirectoryName(fileFullName)) + System.IO.Path.DirectorySeparatorChar;
                this.fileExt = String.Empty;
                this.TextBoxFileName.Text = System.IO.Path.GetFileNameWithoutExtension(System.IO.Path.GetDirectoryName(fileFullName));
            }
            else
            {
                this.filePath = System.IO.Path.GetDirectoryName(fileFullName) + System.IO.Path.DirectorySeparatorChar;
                this.fileExt = System.IO.Path.GetExtension(fileFullName);
                this.TextBoxFileName.Text = System.IO.Path.GetFileNameWithoutExtension(fileFullName);
            }

            this.type = ICCAssociationType.WordDocument;

            this.Label.Content = label;
            this.TextBoxFileName.SelectionStart = this.TextBoxFileName.Text.Length;
            this.TextBoxFileName.Focus();
        }