Esempio n. 1
0
        public async Task<string> GetFile(FileLocation fileLocation) {
            logger.debug("Getting file {0}", fileLocation);
            if(fileLocation.Constructor == Constructor.fileLocation) {
                FileLocationConstructor location = (FileLocationConstructor) fileLocation;
                string filePath = FileLocationToCachePath(location);
                using(IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication()) {
                    if(!storage.DirectoryExists("cache")) {
                        storage.CreateDirectory("cache");
                    }

                    if(storage.FileExists(filePath)) {
                        logger.debug("Getting file {0} from cache", filePath);
                        return filePath;
                    }

                    TLApi api = await session.GetFileSession(location.dc_id);
                    logger.debug("Got file session for dc {0}", location.dc_id);

                    Upload_fileConstructor file = (Upload_fileConstructor) await api.upload_getFile(TL.inputFileLocation(location.volume_id, location.local_id, location.secret), 0, int.MaxValue);

                    logger.debug("File constructor found");

                    using (Stream fileStream = new IsolatedStorageFileStream(filePath, FileMode.OpenOrCreate,
                                                                          FileAccess.Write, storage)) {
                        await fileStream.WriteAsync(file.bytes, 0, file.bytes.Length);
                    }

                    logger.debug("File saved successfully");
                    return filePath;
                }
            } else {
                throw new MTProtoFileUnavailableException();
            }
        }
Esempio n. 2
0
 public Texture CreateInstance(FileLocation rl)
 {
     Texture result;
     if (!loadedTextures.TryGetValue(rl.Name, out result))
     {
         result = TextureManager.Instance.CreateInstanceUnmanaged(rl);
         loadedTextures.Add(rl.Name, result);
     }
     return result;
 }
Esempio n. 3
0
        public QueryHeight(float longtitude, float lattiude)
        {
            //int x = 0;
            //int y = 0;
            //if (longtitude / 10 != 0)
            //    longtitude = (int)(longtitude / 10) * 10;
            //if (lattiude / 10 != 0)
            //    lattiude = (int)(lattiude / 10) * 10;
            
            //x = (int)((longtitude + 185) / 5);
            //y = (int)((95 - lattiude) / 5);

            double x = 0;
            double y = 0;
            x = (longtitude + 185) / 5;
            y = (95 - lattiude) / 5;

            int x1 = (int)(Math.Truncate(x));
            if (x1 / 2 == 0)
                x1--;
            int y1 = (int)(Math.Truncate(y));
            if (y1 / 2 == 0)
                y1--;
            string dir = "C:\\Users\\penser\\Documents\\Visual Studio 2008\\Projects\\lrvbsvnicg\\Source\\Code2015\\bin\\x86\\Debug\\terrain.lpk\\";

            file = dir + "tile_" + x1.ToString("D2") + "_" + y1.ToString("D2").ToString() + "_0.tdmp";
            FileLocation fl = new FileLocation(file);

            td = new TDMPIO();
            td.Load(new FileLocation(fl));

            int width = td.Width;
            int height = td.Height;
            data = td.Data;

            float detaX = td.XSpan / width;
            float detaY = td.YSpan / height;

            //td.Xllcorner表示经度,角度制。

            if (longtitude <= 0)
                longtitude = -longtitude;
            int posX = (int)(Math.Abs(longtitude - td.Xllcorner) / detaX);

            if (lattiude <= 0)
                lattiude = -lattiude;
            int posY = (int)(Math.Abs(lattiude - td.Yllcorner) / detaY);

            this.Height = data[posY * 513 + posX];
           
        }
 public ResourceHandle<TerrainTexture> CreateInstance(RenderSystem rs, FileLocation rl)
 {
     Resource retrived = base.Exists(rl.Name);
     if (retrived == null)
     {
         TerrainTexture mdl = new TerrainTexture(rs, rl);
         retrived = mdl;
         base.NotifyResourceNew(mdl);
     }
     
     //else
     //{
     //    retrived.Use();
     //}
     return new ResourceHandle<TerrainTexture>((TerrainTexture)retrived);
 }
Esempio n. 5
0
        public static bool SaveBinaryFile(FileLocation location, string filenamelocalpath, byte[] bytes)
        {
            if (location == FileLocation.SHARED)
            {
                return(Instance._SaveBinaryFile(location, filenamelocalpath, bytes, null));
            }
            string fullPath = GetFullPath(location, filenamelocalpath);

            try
            {
                File.WriteAllBytes(fullPath, bytes);
                Logger.LogInfo(m_instance, "Binary File successfully saved to " + fullPath);
                return(true);
            }
            catch (Exception ex)
            {
                Logger.LogFatal(m_instance, "Binary File saved Exception " + ex);
            }
            return(false);
        }
Esempio n. 6
0
        public string GetGCodePathAndFileName()
        {
            if (FileLocation.Trim() != "")
            {
                if (Path.GetExtension(FileLocation).ToUpper() == ".GCODE")
                {
                    return(FileLocation);
                }

                string engineString = ((int)ActivePrinterProfile.Instance.ActiveSliceEngineType).ToString();

                string gcodeFileName        = this.FileHashCode.ToString() + "_" + engineString + "_" + ActiveSliceSettings.Instance.GetHashCode().ToString();
                string gcodePathAndFileName = Path.Combine(ApplicationDataStorage.Instance.GCodeOutputPath, gcodeFileName + ".gcode");
                return(gcodePathAndFileName);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 7
0
        private PlantDensity()
        {
            densityTable = new byte[TypeCount][];
            for (int i = 0; i < TypeCount; i++)
            {
                FileLocation fl = FileSystem.Instance.Locate(TableNames[i], GameFileLocs.Nature);

                ContentBinaryReader br = new ContentBinaryReader(fl);
                densityTable[i] = br.ReadBytes(Width * Height);

                br.Close();
            }

            //density = new byte[Width * Height];
            FileLocation        fl2 = FileSystem.Instance.Locate(DensityFile, GameFileLocs.Nature);
            ContentBinaryReader br2 = new ContentBinaryReader(fl2);

            density = br2.ReadBytes(Width * Height);
            br2.Close();
        }
Esempio n. 8
0
		public static string GetFilePath(string path, FileLocation location)
		{
			string result = string.Empty;
			if (!string.IsNullOrEmpty(path))
			{
				switch (location)
				{
					case FileLocation.AbsolutePathOrURL:
						result = path;
						break;
					case FileLocation.RelativeToDataFolder:
					case FileLocation.RelativeToPeristentDataFolder:
					case FileLocation.RelativeToProjectFolder:
					case FileLocation.RelativeToStreamingAssetsFolder:
						result = System.IO.Path.Combine(GetPath(location), path);
						break;
				}
			}
			return result;
		}
Esempio n. 9
0
        /// <inheritdoc />
        public Stream GetFileStream(string repositoryName, ObjectId objectId, FileLocation location, string suffix = null)
        {
            try
            {
                if (this.IsFileStored(repositoryName, objectId, location, false, suffix) == false)
                {
                    return(null);
                }

                string path = this.GetDirectoriesAndFileNames(repositoryName, objectId, location, suffix).Item2;
                return(new FileStream(path, FileMode.Open, FileAccess.Read));
            }
            catch (IOException ex)
            {
                throw new ErrorResponseException(new Error.ErrorResponse()
                {
                    Message = ex.Message
                }, 500);
            }
        }
Esempio n. 10
0
        static public void TranslateCompiledLocation(FileLocation location)
        {
            //Shocking!!!
            //For selection, ranges, text length, navigation
            //Scintilla operates in units, which are not characters but bytes.
            //thus if for the document content "test" you execute selection(start:0,end:3)
            //it will select the whole word [test]
            //However the same for the Cyrillic content "тест" will
            //select only two characters [те]ст because they compose
            //4 bytes.
            //
            //Basically in Scintilla language "position" is not a character offset
            //but a byte offset.
            //
            //This is a hard to believe Scintilla flaw!!!
            //The problem is discussed here: https://scintillanet.codeplex.com/discussions/218036
            //And here: https://scintillanet.codeplex.com/discussions/455082

            //Debug.WriteLine("-----------------------------");
            //Debug.WriteLine("Before: {0} ({1},{2})", location.File, location.Start, location.End);
            //return;
            if (DecorationInfo != null)
            {
                try
                {
                    if (location.File.IsSameAs(DecorationInfo.AutoGenFile, true))
                    {
                        location.File = DecorationInfo.ScriptFile;
                        if (location.Start > (DecorationInfo.IngecionStart + DecorationInfo.IngecionLength))
                        {
                            location.Start -= DecorationInfo.IngecionLength;
                            location.End   -= DecorationInfo.IngecionLength;
                            location.Line--;
                        }
                        //Debug.WriteLine("After: {0} ({1},{2})", location.File, location.Start, location.End);
                    }
                }
                catch { }
            }
            Debug.WriteLine("-----------------------------");
        }
Esempio n. 11
0
        public async Task <string> GetFile(FileLocation fileLocation)
        {
            logger.debug("Getting file {0}", fileLocation);
            if (fileLocation.Constructor == Constructor.fileLocation)
            {
                FileLocationConstructor location = (FileLocationConstructor)fileLocation;
                string filePath = FileLocationToCachePath(location);
                using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication()) {
                    if (!storage.DirectoryExists("cache"))
                    {
                        storage.CreateDirectory("cache");
                    }

                    if (storage.FileExists(filePath))
                    {
                        logger.debug("Getting file {0} from cache", filePath);
                        return(filePath);
                    }

                    TLApi api = await session.GetFileSession(location.dc_id);

                    logger.debug("Got file session for dc {0}", location.dc_id);

                    Upload_fileConstructor file = (Upload_fileConstructor)await api.upload_getFile(TL.inputFileLocation(location.volume_id, location.local_id, location.secret), 0, int.MaxValue);

                    logger.debug("File constructor found");

                    using (Stream fileStream = new IsolatedStorageFileStream(filePath, FileMode.OpenOrCreate,
                                                                             FileAccess.Write, storage)) {
                        await fileStream.WriteAsync(file.bytes, 0, file.bytes.Length);
                    }

                    logger.debug("File saved successfully");
                    return(filePath);
                }
            }
            else
            {
                throw new MTProtoFileUnavailableException();
            }
        }
        private string BuildFileName(Occupation occ, TTSEmploymentStatus empStat, FileLocation fileLocation)
        {
            var dirPath = fileLocation.GetFilePath();
            var info    = new DirectoryInfo(dirPath);

            if (!info.Exists)
            {
                info.Create();
            }
            StringBuilder buildFileName = new StringBuilder();

            switch (occ)
            {
            case Occupation.Professional:
                buildFileName.Append("P");
                break;

            case Occupation.Office:
                buildFileName.Append("G");
                break;

            case Occupation.Retail:
                buildFileName.Append("S");
                break;

            case Occupation.Manufacturing:
                buildFileName.Append("M");
                break;
            }
            switch (empStat)
            {
            case TTSEmploymentStatus.FullTime:
                buildFileName.Append("F.csv");
                break;

            case TTSEmploymentStatus.PartTime:
                buildFileName.Append("P.csv");
                break;
            }
            return(Path.Combine(dirPath, buildFileName.ToString()));
        }
Esempio n. 13
0
        public TerrainEffect(RenderSystem renderSystem, int ts)
            : base(renderSystem, TerrainEffect33Factory.Name, false)
        {
            this.terrSize     = ts;
            this.renderSystem = renderSystem;

            FileLocation fl = FileSystem.Instance.Locate("terrain.cvs", GameFileLocs.Effect);

            vtxShader = LoadVertexShader(renderSystem, fl);


            fl        = FileSystem.Instance.Locate("terrain.cps", GameFileLocs.Effect);
            pixShader = LoadPixelShader(renderSystem, fl);


            fl           = FileSystem.Instance.Locate("terrainNormalGen.cvs", GameFileLocs.Effect);
            nrmVtxShader = LoadVertexShader(renderSystem, fl);

            fl           = FileSystem.Instance.Locate("terrainNormalGen.cps", GameFileLocs.Effect);
            nrmPixShader = LoadPixelShader(renderSystem, fl);
        }
Esempio n. 14
0
        private string GetPlatformFilePath(ref string filePath, ref FileLocation fileLocation)
        {
            string result = string.Empty;

            Platform platform = GetPlatform();

            if (platform != Platform.Unknown)
            {
                // Override per-platform
                int platformIndex = (int)platform;
                if (m_platformVideoPathOverride[platformIndex])
                {
                    filePath     = m_platformVideoPath[platformIndex];
                    fileLocation = m_platformVideoLocation[platformIndex];
                }
            }

            result = GetFilePath(filePath, fileLocation);

            return(result);
        }
Esempio n. 15
0
        private void OK_Click(object sender, RoutedEventArgs e)
        {
            if (FileList.SelectedItem == null)
            {
                return;
            }

            _fileName = ((ListBoxItem)FileList.SelectedItem).Content.ToString();
            foreach (ListBoxItem item in FileList.Items)
            {
                if (item.IsSelected)
                {
                    _fileLocation = (FileLocation)item.Tag;
                }
            }

            if (OnUnloaded != null)
            {
                OnUnloaded(this, new IsoFileExplorerEventArgs(IsoFileExplorerStatus.Selected));
            }
        }
Esempio n. 16
0
        public string GetFilePath(string mode)
        {
            FileLocation locationValidator = new FileLocation();
            FileName     fileNameValidator = new FileName();

            Console.Write("\nEnter location of the file: ");
            string location = Console.ReadLine();

            //check and assign correct location
            location = locationValidator.ValidateFileLocation(location);

            Console.Write("\nEnter name of the file: ");
            string fileName = Console.ReadLine();

            //check and assign correct file name
            fileName = fileNameValidator.ValidateFileName(location, fileName, mode);

            _path = location + fileName;

            return(_path);
        }
Esempio n. 17
0
        private static void ComputeCallability(ILogger logger, Dictionary <string, List <CnvCall> > callsByContig,
                                               EvaluateCnvOptions options, IDirectoryLocation output)
        {
            var kmerFasta           = new FileLocation(options.KmerFa);
            var canvasAnnotationDir = kmerFasta.Directory;
            var filterBed           = canvasAnnotationDir.GetFileLocation("filter13.bed");

            if (!filterBed.Exists)
            {
                throw new ArgumentException($"Missing file at {filterBed}");
            }
            var annotationDir   = canvasAnnotationDir.Parent;
            var buildDir        = annotationDir.Parent;
            var genome          = new ReferenceGenome(buildDir).GenomeMetadata;
            var computer        = CallabilityMetricsComputer.Create(logger, genome, filterBed, options.PloidyInfo.SexPloidyInfo.PloidyY == 0);
            var callability     = computer.CalculateMetric(callsByContig.SelectValues(calls => calls.Where(call => call.PassFilter).ToList()));
            var callabilityFile = output.GetFileLocation($"{options.BaseFileName}_callability.txt");

            File.WriteAllLines(callabilityFile.FullName, callability.GetMetrics().Select(metric => metric.ToCsv().Replace(",", "\t")));
            logger.Info($"Callability: {callability.Callability}. Called bases: {callability.CalledBases}. Total bases: {callability.TotalBases}.");
        }
Esempio n. 18
0
        protected override void OnRegisterFile(FileLocation location)
        {
            base.OnRegisterFile(location);

            // Try to load file
            if (!File.Exists(location.FileName) ||
                fileMapping.ContainsKey(location.FileName))
            {
                return;
            }

            try
            {
                var lines = File.ReadAllLines(location.FileName);
                fileMapping.Add(location.FileName, lines);
            }
            catch
            {
                // Ignore exceptions
            }
        }
Esempio n. 19
0
    private string GetPlatformFilePath(Platform platform, ref string filePath, ref FileLocation fileLocation)
    {
        string result = string.Empty;

        //Replace file path and location if overriden by platform options
        //if (platform != Platform.Unknown)
        //{
        //    PlatformOptions options = GetCurrentPlatformOptions();
        //    if (options != null)
        //    {
        //        if (options.overridePath)
        //        {
        //            filePath = options.path;
        //            fileLocation = options.pathLocation;
        //        }
        //    }
        //}

        result = GetFilePath(filePath, fileLocation);

#if (UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN)
        // Handle very long file paths by converting to DOS 8.3 format
        if (result.Length > 200 && !result.Contains("://"))
        {
            const string pathToken = @"\\?\";
            result = pathToken + result.Replace("/", "\\");
            int length = GetShortPathName(result, null, 0);
            if (length > 0)
            {
                System.Text.StringBuilder sb = new System.Text.StringBuilder(length);
                if (0 != GetShortPathName(result, sb, length))
                {
                    result = sb.ToString().Replace(pathToken, "");
                    Debug.LogWarning("[AVProVideo] Long path detected. Changing to DOS 8.3 format");
                }
            }
        }
#endif
        return result;
    }
Esempio n. 20
0
        /// <summary>
        /// Initializes the MIB value. This will remove all levels of
        /// indirection present, such as references to other values. No
        /// value information is lost by this operation. This method may
        /// modify this object as a side-effect, and will return the basic
        /// value.
        /// </summary>
        /// <remarks>
        /// This is an internal method that should
        /// only be called by the MIB loader.
        /// </remarks>
        /// <param name="log">The MIB Loader log</param>
        /// <param name="type">The value type</param>
        /// <returns>The basic MIB value</returns>
        public override MibValue Initialize(MibLoaderLog log, MibType type)
        {
            ValueReference vref = null;

            if (this.parent == null)
            {
                return(this);
            }
            else if (this.parent is ValueReference reference)
            {
                vref = reference;
            }

            this.parent = this.parent.Initialize(log, type);

            if (vref != null)
            {
                if (this.parent is ObjectIdentifierValue oid)
                {
                    oid.AddChild(log, this.location, this);
                }
                else
                {
                    throw new MibException(
                              vref.Location,
                              "referenced value is not an object identifier");
                }
            }

            this.location = null;

            if (this.parent is ObjectIdentifierValue value1)
            {
                return(value1.GetChildByValue(this.value));
            }
            else
            {
                return(this);
            }
        }
Esempio n. 21
0
        public IActionResult Change(Guid selectedId)
        {
            var data = DataService.Instance.Get(selectedId);

            if (data == null)
            {
                return(new HtmlResult());
            }
            var model = new Models.TableEditModel()
            {
                Id   = data.Id,
                Name = data.Name,
                File = FileLocation.Create(data.Avatar.Name, data.Avatar.Type, string.Format("/File/Get/{0}", data.Id))
            };

            var form  = FormHorizontal.Create(model, Url.Location <Models.TableEditModel>(ChangeResult));
            var panel = new Panel();

            panel.ConfigLocation();
            panel.Append(form);
            return(new HtmlResult(panel));
        }
Esempio n. 22
0
        public void GetExecutablePath_test()
        {
            var logger           = Substitute.For <ILogger>();
            var workDoer         = Substitute.For <IWorkDoer>();
            var checkpointRunner = Substitute.For <ICheckpointRunner>();
            Func <string, ICommandFactory> runtimePrefix = component => Substitute.For <ICommandFactory>();
            string dotnetPath            = @"C:\path\to\dotnet.exe";
            var    runtimeExecutable     = new FileLocation(dotnetPath);
            bool   isSomatic             = true;
            var    coverageMode          = new CanvasCoverageMode();
            int    countsPerBin          = 0;
            string canvasFolder          = @"C:\path\to\Canvas\";
            var    bAlleleBedGraphWriter = Substitute.For <IBAlleleBedGraphWriter>();
            var    canvasRunner          = new CanvasRunner(logger, workDoer, checkpointRunner, runtimeExecutable, runtimePrefix, isSomatic, coverageMode, countsPerBin, bAlleleBedGraphWriter, null, canvasFolder);
            string prefix               = "something before ";
            var    commandLineBuilder   = new StringBuilder(prefix);
            string canvasExecutableStub = "CanvasBin";
            string fullName             = canvasRunner.GetExecutablePath(canvasExecutableStub, commandLineBuilder);

            Assert.Equal(@"C:\path\to\dotnet.exe", fullName);
            Assert.Equal(@"something before C:\path\to\Canvas\CanvasBin\CanvasBin.dll ", commandLineBuilder.ToString());
        }
Esempio n. 23
0
        private Task DoEditFileLocation(object o)
        {
            return(Task.Factory.StartNew(() =>
            {
                Parent.SyncContext.Post(c =>
                {
                    CustomDialog customDialog = new CustomDialog()
                    {
                        Title = "New Location"
                    };

                    var dataContext = new NewFileLocationDialogModel(obj =>
                    {
                        Parent.DialogCoordinator.HideMetroDialogAsync(Parent, customDialog);
                    },
                                                                     obj =>
                    {
                        Parent.DialogCoordinator.HideMetroDialogAsync(Parent, customDialog);
                        Parent.SyncContext.Post(d =>
                        {
                            FileLocation location = new FileLocation()
                            {
                                Name = obj.FileName,
                                Path = obj.Path
                            };
                            FileLocations.Add(location);
                            FileLocations.Remove((FileLocation)o);
                        }, null);
                    });
                    dataContext.FileName = ((FileLocation)o).Name;
                    dataContext.Path = ((FileLocation)o).Path;
                    customDialog.Content = new NewFileLocationDialog {
                        DataContext = dataContext
                    };

                    Parent.DialogCoordinator.ShowMetroDialogAsync(Parent, customDialog);
                }, null);
            }));
        }
Esempio n. 24
0
        static public void NavigateToFileLocation(string sourceLocation)
        {
            var location = FileLocation.Parse(sourceLocation);

            location.Start = npp.CharOffsetToPosition(location.Start, location.File);
            location.End   = npp.CharOffsetToPosition(location.End, location.File);

            TranslateCompiledLocation(location);

            if (File.Exists(location.File))
            {
                if (Npp.Editor.GetCurrentFilePath().IsSameAs(location.File, true))
                {
                    ShowBreakpointSourceLocation(location);
                }
                else
                {
                    OnNextFileOpenComplete = () => ShowBreakpointSourceLocation(location);
                    Npp.Editor.OpenFile(location.File, true); //needs to by asynchronous
                }
            }
        }
Esempio n. 25
0
        public override PhysicalLocation VisitPhysicalLocation(PhysicalLocation node)
        {
            // Strictly speaking, some elements that may contribute to a files table
            // key are case sensitive, e.g., everything but the schema and protocol of a
            // web URI. We don't have a proper comparer implementation that can handle
            // all cases. For now, we cover the Windows happy path, which assumes that
            // most URIs in log files are file paths (which are case-insensitive)
            //
            // Tracking item for an improved comparer:
            // https://github.com/Microsoft/sarif-sdk/issues/973
            _files = _files ?? new Dictionary <string, FileData>(StringComparer.OrdinalIgnoreCase);

            FileLocation fileLocation = node.FileLocation;

            string uriText = Uri.EscapeUriString(fileLocation.Uri.ToString());

            if (!string.IsNullOrEmpty(fileLocation.UriBaseId))
            {
                // See EXAMPLE 3 of 3.11.13.2 'Property Names' of
                // SARIF v2 'files' property specification
                uriText = "#" + fileLocation.UriBaseId + "#" + uriText;
            }

            // If the file already exists, we will not insert one as we want to
            // preserve mime-type, hash details, and other information that
            // may already be present
            if (!_files.ContainsKey(uriText))
            {
                string mimeType = Writers.MimeType.DetermineFromFileExtension(uriText);

                _files[uriText] = new FileData()
                {
                    MimeType     = mimeType,
                    FileLocation = fileLocation
                };
            }

            return(base.VisitPhysicalLocation(node));
        }
Esempio n. 26
0
        public unsafe SkinnedStandardEffect(RenderSystem rs)
            : base(rs, SkinnedStandardEffectFactory.Name, false)
        {
            FileLocation fl = FileSystem.Instance.Locate("tillingmark.tex", GameFileLocs.Texture);

            noTexture = TextureManager.Instance.CreateInstance(fl);// fac.CreateTexture(1, 1, 1, TextureUsage.Static, ImagePixelFormat.A8R8G8B8);


            this.renderSys = rs;

            fl        = FileSystem.Instance.Locate("skinnedstandard.cvs", GameFileLocs.Effect);
            vtxShader = LoadVertexShader(renderSys, fl);

            fl        = FileSystem.Instance.Locate("skinnedstandard.cps", GameFileLocs.Effect);
            pixShader = LoadPixelShader(renderSys, fl);

            fl             = FileSystem.Instance.Locate("skinnedShadowMap.cvs", GameFileLocs.Effect);
            skShdVtxShader = LoadVertexShader(renderSys, fl);

            fl = FileSystem.Instance.Locate("skinnedNormalGen.cvs", GameFileLocs.Effect);
            nrmGenVtxShader = LoadVertexShader(renderSys, fl);
        }
Esempio n. 27
0
        //public Texture Earth
        //{
        //    get { return renderTarget.GetColorBufferTexture(); }
        //}

        public Menu(Code2015 game, RenderSystem rs)
        {
            this.game     = game;
            this.mainMenu = new MainMenu(game, this);
            //this.sideSelect = new SelectScreen(game, this);
            //this.renderSys = rs;

            //CreateScene(rs);
            //this.loadScreen = new LoadingScreen(this, rs);
            this.intro       = new Intro(rs);
            this.credits     = new CreditScreen(rs, this);
            this.tutorial    = new Tutorial(this);
            this.dummyScreen = new DummyScreen();

            FileLocation fl = FileSystem.Instance.Locate("bg_black.tex", GameFileLocs.GUI);

            overlay34           = UITextureManager.Instance.CreateInstance(fl);
            this.loadingOverlay = new LoadingOverlay(game, overlay34);


            //fl = FileSystem.Instance.Locate("mm_logo.tex", GameFileLocs.GUI);
        }
Esempio n. 28
0
        private string GetPlatformFilePath(Platform platform, ref string filePath, ref FileLocation fileLocation)
        {
            string result = string.Empty;

            // Replace file path and location if overriden by platform options
            if (platform != Platform.Unknown)
            {
                PlatformOptions options = GetPlatformOptions(platform);
                if (options != null)
                {
                    if (options.overridePath)
                    {
                        filePath     = options.path;
                        fileLocation = options.pathLocation;
                    }
                }
            }

            result = GetFilePath(filePath, fileLocation);

            return(result);
        }
Esempio n. 29
0
        public override bool LoadRes()
        {
            FileLocation fl = ResourceLocation as FileLocation;

            if (fl != null)
            {
                arc = new PakArchive(fl);

                entries = arc.GetEntries();

                ListView.ListViewItemCollection col = listView1.Items;
                for (int i = 0; i < entries.Length; i++)
                {
                    ListViewItem item = col.Add(entries[i].Name);
                    item.SubItems.Add(entries[i].Size.ToString());
                    item.SubItems.Add(entries[i].Offset.ToString());
                    item.SubItems.Add(entries[i].Flag.ToString());
                }
            }

            return(true);
        }
Esempio n. 30
0
        public GameFont(string name)
        {
            FileLocation fl = FileSystem.Instance.Locate(name + ".tex", GameFileLocs.GUI);

            font = UITextureManager.Instance.CreateInstance(fl);

            charHeight = font.Height / 7;

            fl = FileSystem.Instance.Locate(name + ".xml", GameFileLocs.Config);
            Configuration config = ConfigurationManager.Instance.CreateInstance(fl);

            charWidth = new int[byte.MaxValue];

            foreach (KeyValuePair <string, ConfigurationSection> e in config)
            {
                ConfigurationSection sect = e.Value;

                char ch = (char)sect.GetInt("Char");

                charWidth[ch] = sect.GetInt("Width");
            }
        }
Esempio n. 31
0
        private void MeasureCharWidth(string fontName)
        {
            FileLocation        fl = FileSystem.Instance.Locate(fontName + ".raw", GameFileLocs.GUI);
            ContentBinaryReader br = new ContentBinaryReader(fl);

            byte[] buffur = br.ReadBytes(fl.Size);
            //rowPitch = (int)fs.Length / font.Height;

            for (int row = 0; row < charsPerHeight; row++)
            {
                for (int col = 0; col < charsPerWidth; col++)
                {
                    byte ascii = Find(row, col);
                    if (ascii != 0)
                    {
                        CharWidthHelper(buffur, col * charWidth, row * charHeight, ascii);
                    }
                }
            }

            br.Close();
        }
Esempio n. 32
0
        /// <summary>
        /// If we are changing the URIs in Results to be relative, we need to also change the URI keys in the files dictionary
        /// to be relative.
        /// </summary>
        /// <param name="node">Result location being changed to relative.</param>
        internal void RebaseFilesDictionary(PhysicalLocation node)
        {
            _files = _files ?? new Dictionary <string, FileData>(StringComparer.OrdinalIgnoreCase);

            FileLocation fileLocation = node.FileLocation;

            string uriText                 = Uri.EscapeUriString(fileLocation.Uri.ToString());
            string uriTextOriginal         = uriText;
            string uriTextOriginalWithBase = _baseUri + uriText;

            if (!string.IsNullOrEmpty(fileLocation.UriBaseId))
            {
                uriText = "#" + fileLocation.UriBaseId + "#" + uriText;
            }

            if (!_files.ContainsKey(uriText))
            {
                string mimeType = Writers.MimeType.DetermineFromFileExtension(uriText);

                if (_files.ContainsKey(uriTextOriginal))
                {
                    _files[uriText] = _files[uriTextOriginal];
                    _files.Remove(uriTextOriginal);
                }
                else if (_files.ContainsKey(uriTextOriginalWithBase))
                {
                    _files[uriText] = _files[uriTextOriginalWithBase];
                    _files.Remove(uriTextOriginalWithBase);
                }
                else
                {
                    _files[uriText] = new FileData()
                    {
                        MimeType = mimeType
                    };
                }
            }
        }
Esempio n. 33
0
        public OceanWaterTile(RenderSystem rs, OceanWaterDataManager manager, int @long, int lat)
            : base(false)
        {
            renderSystem = rs;

            PlanetEarth.TileCoord2CoordNew(@long, lat, out tileCol, out tileLat);

            material = new Material(rs);

            FileLocation             fl  = FileSystem.Instance.Locate("WaterNormal.tex", GameFileLocs.Nature);
            ResourceHandle <Texture> map = TextureManager.Instance.CreateInstance(fl);

            material.SetTexture(1, map);

            fl  = FileSystem.Instance.Locate("WaterDudv.tex", GameFileLocs.Nature);
            map = TextureManager.Instance.CreateInstance(fl);
            material.SetTexture(0, map);

            material.SetEffect(EffectManager.Instance.GetModelEffect(WaterEffectFactory.Name));
            material.IsTransparent = true;
            material.ZWriteEnabled = false;
            material.ZEnabled      = true;
            material.CullMode      = CullMode.CounterClockwise;
            material.PriorityHint  = RenderPriority.Third;

            data0 = manager.GetData(Lod0Size, tileLat);
            //data1 = manager.GetData(Lod1Size, tileLat);


            float radtc = MathEx.Degree2Radian(tileCol);
            float radtl = MathEx.Degree2Radian(tileLat);
            float rad5  = PlanetEarth.DefaultTileSpan * 0.5f;

            BoundingSphere.Center = PlanetEarth.GetPosition(radtc + rad5, radtl - rad5);
            BoundingSphere.Radius = PlanetEarth.GetTileHeight(rad5 * 2);

            Transformation = Matrix.RotationY(radtc);
        }
Esempio n. 34
0
        /// <inheritdoc />
        public string SaveFile(string repositoryName, ObjectId objectId, FileLocation location, Stream contents, string suffix = null)
        {
            var(directory, fileName) = this.GetDirectoriesAndFileNames(repositoryName, objectId, location, suffix);

            try
            {
                Directory.CreateDirectory(directory);

                using (FileStream fileStream = new FileStream(fileName, FileMode.Create, FileAccess.Write))
                {
                    contents.CopyTo(fileStream);

                    return(fileName);
                }
            }
            catch (IOException ex)
            {
                throw new ErrorResponseException(new ErrorResponse()
                {
                    Message = ex.Message
                }, 500);
            }
        }
 public void FailedToLoadFromSource(Uri uri, Exception ex, FileLocation fileLocation)
 {
 }
 public static IStatus AppendError(this IStatusAppender source, Component component, Exception exception, FileLocation location)
 {
     return AppendCore(source, new Status(component, Severity.Error, exception, location));
 }
 public void DuplicatePropertyName(IEnumerable<QualifiedName> duplicates,
                                   FileLocation loc)
 {
 }
 public static PropertyTreeException BadTargetTypeDirective(Exception ex, FileLocation loc)
 {
     return Failure.Prepare(new PropertyTreeException(SR.BadTargetTypeDirective(), ex, loc));
 }
 static string BuildMessage(string message, FileLocation location, PropertyTreeException inner)
 {
     // Don't present multiple line infos
     if (location.IsEmpty || (inner != null && inner.LineNumber > 0))
         return message;
     else
         return message + Environment.NewLine + Environment.NewLine + location.ToString("h");
 }
 public void RequiredPropertiesMissing(IEnumerable<string> requiredMissing, Carbonfrost.Commons.PropertyTrees.Schema.OperatorDefinition op, FileLocation loc)
 {
 }
Esempio n. 41
0
 public TerrainTexture(RenderSystem rs, FileLocation fl)
     : base(TerrainTextureManager.Instance, fl.Name)
 {
     texLoc = fl;
 }
 public static IStatus Append(this IStatusAppender source, Component component, string message, Exception exception, FileLocation location)
 {
     return AppendCore(source, new Status(component, message, exception, location));
 }
 public void BadAddChild(Type parentType, Exception ex, FileLocation loc)
 {
 }
		/// <summary>
		/// Loads the diagram from file.
		/// </summary>
		/// <param name="location"></param>
		public void LoadFromFile(FileLocation location = FileLocation.Disk)
		{
#if WPF
			switch (location)
			{
				case FileLocation.Disk:
					var dialog = new OpenFileDialog { Multiselect = false, Filter = "Diagram (.xml)|*.xml|All Files (*.*)|*.*" };
					if (dialog.ShowDialog() == true)
					{
						using (var fileStream = File.OpenRead(dialog.FileName))
						{
							var reader = new StreamReader(fileStream);
							var serializationString = reader.ReadToEnd();
							this.diagram.Clear();
							this.diagram.Load(serializationString);
						}
					}
					break;
				case FileLocation.IsolatedStorage:
					if (string.IsNullOrEmpty(this.CurrentFile))
					{
						RadWindow.Prompt("File name", (sender, e) =>
						{
							if (string.IsNullOrEmpty(e.PromptResult))
								throw new ArgumentNullException("e");
							this.CurrentFile = Path.GetFileNameWithoutExtension(e.PromptResult);
							if (!Path.HasExtension(this.CurrentFile))
							{
								this.CurrentFile = this.CurrentFile + ".xml";
							}
							else
							{
								if (Path.GetExtension(this.CurrentFile).ToLowerInvariant() != "xml")
								{
									this.CurrentFile = Path.ChangeExtension(this.CurrentFile, "xml");
								}
							}
							var appStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly | IsolatedStorageScope.Domain, null, null);

							using (var storageFileStream = appStore.OpenFile(this.CurrentFile, FileMode.Open))
							{
								var reader = new StreamReader(storageFileStream);
								var xml = reader.ReadToEnd();
								if (string.IsNullOrEmpty(xml))
								{
									throw new IsolatedStorageException("The serialized string was null or empty.");
								}
								this.diagram.Load(xml);
							}
						});
					}
					else
					{
						var appStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly | IsolatedStorageScope.Domain, null, null);

						using (var storageFileStream = appStore.OpenFile(this.CurrentFile, FileMode.Open))
						{
							var reader = new StreamReader(storageFileStream);
							var xml = reader.ReadToEnd();
							if (string.IsNullOrEmpty(xml))
							{
								throw new IsolatedStorageException("The serialized string was null or empty.");
							}
							this.diagram.Load(xml);
						}
					}

					break;
				default:
					throw new ArgumentOutOfRangeException("location");
			}

#else
			switch (location)
			{
				case FileLocation.Disk:
					var dialog = new OpenFileDialog { Multiselect = false, Filter = "Diagram (.xml)|*.xml|All Files (*.*)|*.*" };
					if (dialog.ShowDialog() == true)
					{
						this.CurrentFile = System.Windows.Application.Current.HasElevatedPermissions ? dialog.File.FullName : dialog.File.Name;
						using (var fileStream = dialog.File.OpenRead())
						{
							var reader = new StreamReader(fileStream);
							var serializationString = reader.ReadToEnd();
							this.diagram.Clear();
							this.diagram.Load(serializationString);
						}
					}
					break;
				case FileLocation.IsolatedStorage:
					if (string.IsNullOrEmpty(this.CurrentFile))
					{
						RadWindow.Prompt("File name", (sender, e) =>
						{
							if (string.IsNullOrEmpty(e.PromptResult))
								throw new ArgumentNullException("e");
							this.CurrentFile = Path.GetFileNameWithoutExtension(e.PromptResult);
							if (!Path.HasExtension(this.CurrentFile))
							{
								this.CurrentFile = this.CurrentFile + ".xml";
							}
							else
							{
								if (Path.GetExtension(this.CurrentFile).ToLowerInvariant() != "xml")
								{
									this.CurrentFile = Path.ChangeExtension(this.CurrentFile, "xml");
								}
							}
							var appStore = IsolatedStorageFile.GetUserStoreForApplication();
							using (var storageFileStream = appStore.OpenFile(this.CurrentFile, FileMode.Open))
							{
								var reader = new StreamReader(storageFileStream);
								var xml = reader.ReadToEnd();
								if (string.IsNullOrEmpty(xml))
									throw new IsolatedStorageException("The serialed string was null or empty.");
								this.diagram.Load(xml);
							}
						});
					}
					else
					{
						var appStore = IsolatedStorageFile.GetUserStoreForApplication();
						using (var storageFileStream = appStore.OpenFile(this.CurrentFile, FileMode.Open))
						{
							var reader = new StreamReader(storageFileStream);
							var xml = reader.ReadToEnd();
							if (string.IsNullOrEmpty(xml))
								throw new IsolatedStorageException("The serialed string was null or empty.");
							this.diagram.Load(xml);
						}
					}

					break;
				default:
					throw new ArgumentOutOfRangeException("location");
			}

#endif

		}
		/// <summary>
		/// Saves the diagram to file.
		/// </summary>
		/// <param name="location">The location.</param>
		public void SaveToFile(FileLocation location = FileLocation.Disk)
		{
#if WPF
			switch (location)
			{
				case FileLocation.Disk:
					var dialog = new SaveFileDialog
						{
							DefaultExt = "xml",
							Filter = "Diagram files|*.xml|All Files (*.*)|*.*",
							CheckPathExists = true,
							AddExtension = true,
							Title = "Select a location to save the diagram"
						};
					if (dialog.ShowDialog() == true)
					{
						this.CurrentFile = dialog.FileName;
					}

					if (!string.IsNullOrWhiteSpace(this.CurrentFile))
					{
						var serializationString = this.diagram.Save();
						using (var writer = new StreamWriter(this.CurrentFile))
						{
							writer.Write(serializationString);
							writer.Flush();
						}
					}
					break;
				case FileLocation.IsolatedStorage:
					try
					{
						if (string.IsNullOrEmpty(this.CurrentFile))
						{
							RadWindow.Prompt("File name", (sender, e) =>
							{
								if (string.IsNullOrEmpty(e.PromptResult))
									throw new ArgumentNullException("e");

								this.CurrentFile = Path.GetFileNameWithoutExtension(e.PromptResult);

								if (!Path.HasExtension(this.CurrentFile))
								{
									this.CurrentFile = this.CurrentFile + ".xml";
								}
								else
								{
									if (Path.GetExtension(this.CurrentFile).ToLowerInvariant() != "xml")
									{
										this.CurrentFile = Path.ChangeExtension(this.CurrentFile, "xml");
									}
								}
								var appStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly | IsolatedStorageScope.Domain, null, null);
								using (var storageFileStream = appStore.CreateFile(this.CurrentFile))
								{
									var serializationString = this.diagram.Save();
									var writer = new StreamWriter(storageFileStream);
									writer.Write(serializationString);
									writer.Flush();
								}
							});
						}
						else
						{
							var appStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly | IsolatedStorageScope.Domain, null, null);

							using (var storageFileStream = appStore.CreateFile(this.CurrentFile))
							{
								var serializationString = this.diagram.Save();
								var writer = new StreamWriter(storageFileStream);
								writer.Write(serializationString);
								writer.Flush();
							}
						}
					}
					catch (IsolatedStorageException exc)
					{
						RadWindow.Alert(exc.Message);
					}
					break;
				default:
					throw new ArgumentOutOfRangeException("location");
			}
#else
			switch (location)
			{
				case FileLocation.Disk:
					Stream fileStream = null;
					try
					{
						var dialog = new SaveFileDialog { DefaultExt = "xml", Filter = "Diagram files|*.xml|All Files (*.*)|*.*", DefaultFileName = "Diagram.xml" };
						if (dialog.ShowDialog() == true)
						{
							fileStream = dialog.OpenFile();
							this.CurrentFile = dialog.DefaultFileName;
						}
						if (fileStream == null) return; // likely canceled the dialog
						using (fileStream)
						{
							var serializationString = this.diagram.Save();
							var writer = new StreamWriter(fileStream);
							writer.Write(serializationString);
							writer.Flush();
						}
					}
					finally
					{
						if (fileStream != null)
							fileStream.Close();
					}

					break;
				case FileLocation.IsolatedStorage:
					try
					{
						if (string.IsNullOrEmpty(this.CurrentFile))
						{
							RadWindow.Prompt("File name", (sender, e) =>
								{
									if (string.IsNullOrEmpty(e.PromptResult))
										throw new ArgumentNullException("e");
									this.CurrentFile = Path.GetFileNameWithoutExtension(e.PromptResult);
									if (!Path.HasExtension(this.CurrentFile))
									{
										this.CurrentFile = this.CurrentFile + ".xml";
									}
									else
									{
										if (Path.GetExtension(this.CurrentFile).ToLowerInvariant() != "xml")
										{
											this.CurrentFile = Path.ChangeExtension(this.CurrentFile, "xml");
										}
									}
									var appStore = IsolatedStorageFile.GetUserStoreForApplication();
									using (var storageFileStream = appStore.CreateFile(this.CurrentFile))
									{
										var serializationString = this.diagram.Save();
										var writer = new StreamWriter(storageFileStream);
										writer.Write(serializationString);
										writer.Flush();
									}
								});
						}
						else
						{
							var appStore = IsolatedStorageFile.GetUserStoreForApplication();
							using (var storageFileStream = appStore.CreateFile(this.CurrentFile))
							{
								var serializationString = this.diagram.Save();
								var writer = new StreamWriter(storageFileStream);
								writer.Write(serializationString);
								writer.Flush();
							}
						}
					}
					catch (IsolatedStorageException exc)
					{
						RadWindow.Alert(exc.Message);
					}
					catch (Exception)
					{
					}
					break;
				default:
					throw new ArgumentOutOfRangeException("location");
			}
#endif
		}
 public static PropertyTreeException CouldNotBindGenericParameters(Type type, Exception ex, FileLocation loc)
 {
     return Failure.Prepare(new PropertyTreeException(SR.CouldNotBindGenericParameters(type), ex, loc));
 }
 public static IStatus Append(this IStatusAppender source, Component component, string message, Exception exception, Severity level, FileLocation location, int errorCode)
 {
     return AppendCore(source, new Status(component, level, message, exception, location, errorCode));
 }
Esempio n. 48
0
 public SimplifiedDiagnostic WithLocation(FileLocation fileLocation)
 {
     return new SimplifiedDiagnostic(descriptor.Id, fileLocation, message);
 }
 public void NoAddMethodSupported(Type type, FileLocation loc)
 {
 }
 public void BadSourceDirective(Exception ex, FileLocation loc)
 {
 }
 public void NoTargetProviderMatches(Type componentType, FileLocation loc)
 {
 }
 public void BadTargetProviderDirective(Exception ex, FileLocation loc)
 {
 }
Esempio n. 53
0
 bool EqualsCheckOutParams(FileStateInfo fsi, FileLocation fl, out bool differentHost)
 {
     return EqualsCheckOutParams(fsi, fl.LocalPath, out differentHost);
 }
 public void BadTargetTypeDirective(Exception ex, FileLocation loc)
 {
 }
Esempio n. 55
0
        private static string CallFile(string name, string args, FileLocation location)
        {
            string folder = "";
            switch (location)
            {
                case FileLocation.SameLocation: folder = CurrentFolder; break;
                case FileLocation.Default: folder = Program.FilesFolder; break;
            }
            if (!IO.Directory.Exists(folder))
                IO.Directory.CreateDirectory(folder);
            string[] files = IO.Directory.GetFiles(folder, name + ".*");
            string file = files[0];
            Process p = new Process();
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.FileName = file;
            p.StartInfo.Arguments = args;
            p.Start();
            string output = p.StandardOutput.ReadToEnd();

            p.WaitForExit();
            p.Dispose();
            return output;
        }
 public void CouldNotBindGenericParameters(Type componentType, Exception ex, FileLocation loc)
 {
 }
 public PropertyTreeException(string message, Exception innerException, FileLocation fileLocation)
     : base(BuildMessage(message, fileLocation, innerException as PropertyTreeException), innerException)
 {
     this.FileLocation = fileLocation;
 }
 public void CouldNotBindStreamingSource(Type componentType, FileLocation loc)
 {
 }
 public static PropertyTreeException BinderConversionError(string text, string propertyName, Type type, Exception exception, FileLocation loc)
 {
     return Failure.Prepare(new PropertyTreeException(SR.BinderConversionError(propertyName, type), exception, loc));
 }
 public static IStatus AppendError(this IStatusAppender source, Component component, string message, FileLocation location)
 {
     return AppendCore(source, new Status(component, Severity.Error, message, location));
 }