Exemple #1
0
        public static string GetProjectItemType(XFileType type)
        {
            switch (type)
            {
            case XFileType.SourceCode:
                return(ProjectFileConstants.Compile);

            case XFileType.NativeResource:
                return(ProjectFileConstants.NativeResource);

            case XFileType.VOForm:
            case XFileType.VODBServer:
            case XFileType.VOFieldSpec:
            case XFileType.VOMenu:
            case XFileType.VOIndex:
            case XFileType.VOOrder:
                return(ProjectFileConstants.VOBinary);

            case XFileType.ManagedResource:
                return(ProjectFileConstants.Resource);

            case XFileType.XAML:
                return(ProjectFileConstants.Page);

            default:
                return(ProjectFileConstants.None);
            }
        }
Exemple #2
0
        /// <summary>
        /// Open a file in a document window
        /// </summary>
        /// <param name="newFile">Open the file as a new file</param>
        /// <param name="openWith">Use a dialog box to determine which editor to use</param>
        /// <param name="logicalView">In MultiView case determines view to be activated by IVsMultiViewDocumentView. For a list of logical view GUIDS, see constants starting with LOGVIEWID_ defined in NativeMethods class</param>
        /// <param name="docDataExisting">IntPtr to the IUnknown interface of the existing document data object</param>
        /// <param name="windowFrame">A reference to the window frame that is mapped to the file</param>
        /// <param name="windowFrameAction">Determine the UI action on the document window</param>
        /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code.</returns>
        public override int Open(bool newFile, bool openWith, ref Guid logicalView, IntPtr docDataExisting, out IVsWindowFrame windowFrame, WindowFrameShowAction windowFrameAction)
        {
            windowFrame = null;
            Guid      editorType = VSConstants.LOGVIEWID_Primary;
            string    fullPath   = this.GetFullPathForDocument();
            XFileType type       = XFileTypeHelpers.GetFileType(fullPath);

            switch (type)
            {
            case XFileType.SourceCode:
            case XFileType.Header:
            case XFileType.PreprocessorOutput:
            case XFileType.NativeResource:
            case XFileType.License:
            case XFileType.Template:
                editorType = GuidStrings.guidSourcecodeEditorFactory;
                break;

            case XFileType.VOForm:
            case XFileType.VOMenu:
            case XFileType.VODBServer:
            case XFileType.VOFieldSpec:
                // the primary view is the normal editor which is defined with an attribute on the package
                // we only have to tell it what to do when we want to see the code.
                if (logicalView == VSConstants.LOGVIEWID.Code_guid)
                {
                    editorType = GuidStrings.guidVSXmlEditor;
                }
                break;
            }
            return(base.Open(newFile, openWith, 0, ref editorType, null, ref logicalView, docDataExisting, out windowFrame, windowFrameAction));
        }
Exemple #3
0
        public static string GenerateOutPutPath(this string str, XFileType destinationType, string extraText = null)
        {
            var name      = Path.GetFileNameWithoutExtension(str);
            var extension = Path.GetExtension(str);

            str = str.Replace(extension, destinationType.GetExtensionType());
            return(str.Replace(name, $"{name}[{extraText ?? string.Empty}]_out"));
        }
Exemple #4
0
 public static bool OpenInSourceCodeEditor(this XFileType type)
 {
     switch (type)
     {
     case XFileType.SourceCode:
     case XFileType.Header:
     case XFileType.NativeResource:
     case XFileType.Unknown:
         return(true);
     }
     return(false);
 }
Exemple #5
0
        public static string GenerateGuidPath(this string path, XFileType dst, string extraText = null)
        {
            //Guid g = Guid.NewGuid();
            //string GuidString = System.Convert.ToBase64String(g.ToByteArray());
            //GuidString = GuidString.Replace("=", "");
            //GuidString = GuidString.Replace("+", "");

            string GuidString = (new Random()).Next(1000000).ToString();
            var    dir        = Path.GetDirectoryName(path);
            var    file       = $"{GuidString} [{extraText ?? string.Empty}]{dst.GetExtensionType()}";

            return(Path.Combine(dir, file));
        }
Exemple #6
0
        public static string GetExtensionType(this XFileType f)
        {
            if (f == XFileType.Mp3)
            {
                return(Mp3Extension);
            }
            else if (f == XFileType.Wma)
            {
                return(WmaExtension);
            }

            return(WavExtension);
        }
Exemple #7
0
 public static bool IsVOBinary(this XFileType type)
 {
     switch (type)
     {
     case XFileType.VOMenu:
     case XFileType.VODBServer:
     case XFileType.VOFieldSpec:
     case XFileType.VOForm:
     case XFileType.VOIndex:
     case XFileType.VOOrder:
         return(true);
     }
     return(false);
 }
Exemple #8
0
 public XFile(string fullPath)
 {
     // TODO: Change to support Case Sensitive types
     _usings       = new List <string>();
     _usingStatics = new List <string>();
     this.filePath = fullPath;
     _type         = XFileTypeHelpers.GetFileType(fullPath);
     //
     InitTypeList();
     //
     _parsed      = !HasCode;
     _lock        = new object();
     _lastWritten = DateTime.MinValue;
     //_hashCode = 0;
 }
Exemple #9
0
        protected override bool RenameDocument(string oldName, string newName, out HierarchyNode newNodeOut)
        {
            var result = base.RenameDocument(oldName, newName, out newNodeOut);

            if (result)
            {
                XSharpProjectNode project = ProjectMgr as XSharpProjectNode;
                if (project != null)
                {
                    project.ProjectModel.RemoveFile(oldName);
                    project.ProjectModel.AddFile(newName);
                    project.ProjectModel.Walk();
                }
                _fileType = XFileTypeHelpers.GetFileType(newName);
            }
            return(result);
        }
        public XJobResult Convert(string srcPath, XFileType dst)
        {
            var         res = new XJobResult();
            XConvertJob p   = new XConvertJob();

            p.ISourceFileType       = srcPath.RetrieveExtension();
            p.AlternativeOutputPath = srcPath.GenerateGuidPath(dst);
            p.DestinationFileType   = dst;
            p.SourceFileName        = srcPath;
            res.EndTime             = DateTime.Now;
            Convert(p);
            XMusicLogger.AddLog($"{DateTime.Now} : Converting {srcPath} to {p.AlternativeOutputPath}");
            res.OutputData = File.ReadAllBytes(p.AlternativeOutputPath);
            File.Delete(p.AlternativeOutputPath);
            res.TempFileName = p.AlternativeOutputPath;
            return(res);
        }
Exemple #11
0
        public static string ReplaceExtension(this string str, XFileType destinatinFileType)
        {
            var ext = Path.GetExtension(str);

            return(str.Replace(Path.GetExtension(str), destinatinFileType.GetExtensionType()));
        }