Esempio n. 1
0
        private void MainFormDragDrop(object sender, DragEventArgs e)
        {
            var paths = e.Data.GetData(DataFormats.FileDrop) as string[];

            if (paths == null)
            {
                return;
            }

            // Filter paths
            var pathsToOpen =
                from path in paths
                where
                ((File.GetAttributes(path) & FileAttributes.Directory) == 0) &&
                !SledUtil.FileEndsWithExtension(path, SledProjectService.ProjectExtensions)
                select path;

            // Open files
            foreach (var path in pathsToOpen)
            {
                ISledDocument sd;
                Open(new Uri(path), out sd);
            }
        }
Esempio n. 2
0
        public SledDocumentService(
            MainForm mainForm,
            ICommandService commandService,
            IContextRegistry contextRegistry,
            IDocumentRegistry documentRegistry,
            IFileDialogService fileDialogService,
            IControlHostService controlHostService)
            : base(commandService, documentRegistry, fileDialogService)
        {
            m_mainForm           = mainForm;
            m_commandService     = commandService;
            m_contextRegistry    = contextRegistry;
            m_documentRegistry   = documentRegistry;
            m_fileDialogService  = fileDialogService;
            m_controlHostService = controlHostService;

            m_mainForm.Shown    += MainFormShown;
            m_mainForm.DragOver += MainFormDragOver;
            m_mainForm.DragDrop += MainFormDragDrop;

            // Relay this event
            m_documentRegistry.ActiveDocumentChanged += DocumentRegistryActiveDocumentChanged;

            // Everything but the copious new & open
            RegisterCommands =
                CommandRegister.FileClose |
                CommandRegister.FileSave |
                CommandRegister.FileSaveAll |
                CommandRegister.FileSaveAs;

            //
            // Register default document types
            //

            m_txtDocumentClient =
                new SledDocumentClient(
                    "Text",
                    ".txt",
                    Atf.Resources.DocumentImage,
                    true,
                    new SledDocumentLanguageSyntaxHighlighter(Languages.Text));

            m_xmlDocumentClient =
                new SledDocumentClient(
                    "Xml",
                    ".xml",
                    Atf.Resources.DocumentImage,
                    new SledDocumentLanguageSyntaxHighlighter(Languages.Xml));

            m_csDocumentClient =
                new SledDocumentClient(
                    "C#",
                    ".cs",
                    Atf.Resources.DocumentImage,
                    new SledDocumentLanguageSyntaxHighlighter(Languages.Csharp));

            m_pyDocumentClient =
                new SledDocumentClient(
                    "Python",
                    ".py",
                    Atf.Resources.DocumentImage,
                    new SledDocumentLanguageSyntaxHighlighter(Languages.Python));

            // One time setup
            SledDocument.ControlHostClient = this;

            // Do not use the system clipboard until further
            // safety measures can be added. Ron Little, 5/26/2011
            StandardEditCommands.UseSystemClipboard = false;

            // Check if any command line args
            var bFirst = true;

            foreach (var arg in Environment.GetCommandLineArgs())
            {
                // First one is application .exe
                if (bFirst)
                {
                    bFirst = false;
                    continue;
                }

                // Skip non-files
                if (!File.Exists(arg))
                {
                    continue;
                }

                // Skip project files
                if (SledUtil.FileEndsWithExtension(arg, SledProjectService.ProjectExtensions))
                {
                    continue;
                }

                m_lstStartupFiles.Add(arg);
            }
        }