Exemplo n.º 1
0
        /// <summary>
        /// Gets an animation by name.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="Files">The file system.</param>
        /// <returns>The animation.</returns>
        public SingleAnimation GetAnimation(string name, FileEngine Files)
        {
            string namelow = name.ToLowerFast();

            if (Animations.TryGetValue(namelow, out SingleAnimation sa))
            {
                return(sa);
            }
            try
            {
                sa = LoadAnimation(namelow, Files);
                Animations.Add(sa.Name, sa);
                return(sa);
            }
            catch (Exception ex)
            {
                SysConsole.Output(OutputType.ERROR, "Loading an animation: " + ex.ToString());
                sa = new SingleAnimation()
                {
                    Name = namelow, Length = 1, Engine = this
                };
                Animations.Add(sa.Name, sa);
                return(sa);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets a text.
        /// </summary>
        /// <param name="Files">The file system.</param>
        /// <param name="pathAndVars">The path and its vars.</param>
        /// <returns>The text.</returns>
        public string GetText(FileEngine Files, params string[] pathAndVars)
        {
            if (pathAndVars.Length < 2)
            {
                return(GetText(Files, "core", "common.languages.badinput"));
            }
            string     category = pathAndVars[0].ToLowerFast();
            string     defPath  = pathAndVars[1].ToLowerFast();
            FDSSection lang     = GetLangDoc(category, Files);
            FDSSection langen   = GetLangDoc(category, Files, DefaultLanguage, EnglishDocuments);
            string     str      = null;

            if (lang != null)
            {
                str = lang.GetString(defPath, null);
                if (str != null)
                {
                    return(Handle(str, pathAndVars));
                }
            }
            if (langen != null)
            {
                str = langen.GetString(defPath, null);
                if (str != null)
                {
                    return(Handle(str, pathAndVars));
                }
            }
            if (defPath == BADKEY)
            {
                return("((Invalid key!))");
            }
            return(GetText(Files, "core", BADKEY));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the texture object for a specific texture name.
        /// </summary>
        /// <param name="texturename">The name of the texture.</param>
        /// <returns>A valid texture object.</returns>
        public Texture GetTexture(string texturename)
        {
            texturename = FileEngine.CleanFileName(texturename);
            if (LoadedTextures.TryGetValue(texturename, out Texture foundTexture))
            {
                return(foundTexture);
            }
            Texture Loaded = LoadTexture(texturename, 0);

            if (Loaded == null)
            {
                Loaded = new Texture()
                {
                    Engine              = this,
                    Name                = texturename,
                    Internal_Texture    = White.Original_InternalID,
                    Original_InternalID = White.Original_InternalID,
                    LoadedProperly      = false,
                    Width               = White.Width,
                    Height              = White.Height,
                };
            }
            LoadedTextures.Add(texturename, Loaded);
            OnTextureLoaded?.Invoke(this, new TextureLoadedEventArgs(Loaded));
            return(Loaded);
        }
        public override void Init()
        {
            context = new ProductContext
            {
                MasterPageFile                    = String.Concat(PathProvider.BaseVirtualPath, "Masters/BasicTemplate.Master"),
                DisabledIconFileName              = "product_disabled_logo.png",
                IconFileName                      = "product_logo.png",
                LargeIconFileName                 = "product_logolarge.svg",
                SubscriptionManager               = new ProductSubscriptionManager(),
                DefaultSortOrder                  = 20,
                SpaceUsageStatManager             = new ProjectsSpaceUsageStatManager(),
                AdminOpportunities                = () => ProjectsCommonResource.ProductAdminOpportunities.Split('|').ToList(),
                UserOpportunities                 = () => ProjectsCommonResource.ProductUserOpportunities.Split('|').ToList(),
                HasComplexHierarchyOfAccessRights = true,
            };

            FileEngine.RegisterFileSecurityProvider();
            SearchHandlerManager.Registry(new SearchHandler());
            NotifyClient.RegisterSecurityInterceptor();
            ClientScriptLocalization = new ClientLocalizationResources();
            DIHelper.Register();

            Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <Task, TasksWrapper>().ForMember(r => r.TenantId, opt => opt.MapFrom(r => GetCurrentTenant()));
                cfg.CreateMap <Message, DiscussionsWrapper>().ForMember(r => r.TenantId, opt => opt.MapFrom(r => GetCurrentTenant()));
                cfg.CreateMap <Milestone, MilestonesWrapper>().ForMember(r => r.TenantId, opt => opt.MapFrom(r => GetCurrentTenant()));
                cfg.CreateMap <Project, ProjectsWrapper>().ForMember(r => r.TenantId, opt => opt.MapFrom(r => GetCurrentTenant()));
                cfg.CreateMap <Subtask, SubtasksWrapper>().ForMember(r => r.TenantId, opt => opt.MapFrom(r => GetCurrentTenant()));
                cfg.CreateMap <Comment, CommentsWrapper>().ForMember(r => r.TenantId, opt => opt.MapFrom(r => GetCurrentTenant()));
            });
        }
Exemplo n.º 5
0
        public FileApi(
            ITokenProvider tokenProvider,
            string applicationId,
            string applicationName,
            string storagePath)
        {
            this.authDelegate = new AuthDelegateImpl(tokenProvider);

            var applicationInfo = new ApplicationInfo(
                applicationId,
                applicationName);

            var settings = new FileProfile.Settings(storagePath, false, authDelegate, applicationInfo);

            var lateFileProfile = new LateValue <FileProfile>();

            FileProfile.LoadAsync(settings, lateFileProfile);
            this.profile = lateFileProfile.AwaitValue();


            FileEngine.Settings engineSettings = new FileEngine.Settings("1234", "");

            var lateFileEngine = new LateValue <FileEngine>();

            this.profile.AddEngineAsync(engineSettings, lateFileEngine);
            this.engine = lateFileEngine.AwaitValue();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets a language document for the specified parameters.
        /// </summary>
        /// <param name="id">The document ID.</param>
        /// <param name="Files">The file system.</param>
        /// <param name="lang">The language to enforce for this read, if any.</param>
        /// <param name="confs">The custom configuration set to use, if any.</param>
        /// <returns></returns>
        public FDSSection GetLangDoc(string id, FileEngine Files, string lang = null, Dictionary <string, FDSSection> confs = null)
        {
            if (lang == null)
            {
                lang = CurrentLanguage;
            }
            if (confs == null)
            {
                confs = LanguageDocuments;
            }
            string idlow = id.ToLowerFast();

            if (LanguageDocuments.TryGetValue(idlow, out FDSSection doc))
            {
                return(doc);
            }
            string path = "info/text/" + idlow + "_" + lang + ".fds";

            if (Files.TryReadFileText(path, out string dat))
            {
                try
                {
                    doc = new FDSSection(dat);
                    LanguageDocuments[idlow] = doc;
                    return(doc);
                }
                catch (Exception ex)
                {
                    CommonUtilities.CheckException(ex);
                    SysConsole.Output("Reading language documents", ex);
                }
            }
            LanguageDocuments[idlow] = null;
            return(null);
        }
Exemplo n.º 7
0
 public override IEnumerable <Row> Execute(IEnumerable <Row> rows)
 {
     using (FileEngine file = FluentFile.For <UserAddressRecord>().From(filePath))
     {
         foreach (object obj in file)
         {
             yield return(Row.FromObject(obj));
         }
     }
 }
Exemplo n.º 8
0
        public static void ExportGridViewData(DataTable data_source, GridView grid_view, string file_name = "")
        {
            if (data_source != null && data_source.Rows.Count > 0)
            {
                SaveFileDialog sDialog = new SaveFileDialog();
                sDialog.Filter = "Microsoft Excel (*.xls)|*.xls|Microsoft Excel 2007 (*.xlsx)|*.xlsx|PDF (*.pdf)|*.pdf|Rich Text Format (*.rtf)|*.rtf|Webpage (*.html)|*.html|Rich Text File (*.rtf)|*.rtf|Text File (*.txt)|*.txt";
                sDialog.Title  = LanguageEngine.GetMessageCaption("000007", ConfigEngine.Language);
                if (!string.IsNullOrEmpty(file_name))
                {
                    sDialog.FileName = FileEngine.CreateUniqueFileName(file_name);
                }
                if (sDialog.ShowDialog() == DialogResult.OK)
                {
                    switch (sDialog.FilterIndex)
                    {
                    case 1:
                        grid_view.ExportToXls(sDialog.FileName);
                        break;

                    case 2:
                        grid_view.ExportToXlsx(sDialog.FileName);
                        break;

                    case 3:
                        grid_view.ExportToPdf(sDialog.FileName);
                        break;

                    case 4:
                        grid_view.ExportToText(sDialog.FileName);
                        break;

                    case 5:
                        grid_view.ExportToHtml(sDialog.FileName);
                        break;

                    case 6:
                        grid_view.ExportToRtf(sDialog.FileName);
                        break;

                    case 7:
                        grid_view.ExportToText(sDialog.FileName);
                        break;
                    }
                    if (XtraMessageBox.Show(LanguageEngine.GetMessageCaption("000006", ConfigEngine.Language).Replace("$FileName$", sDialog.FileName), (ConfigEngine.Language == "vi") ? "Thông Báo" : "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                    {
                        Process.Start(sDialog.FileName);
                    }
                }
            }
            else
            {
                return;
            }
        }
Exemplo n.º 9
0
        public StandardSimulation()
        {
            _random           = new Random();
            _simulationEngine = new SimulationEngine(_random);

            _bitmapEngine            = new BitmapEngine(_simulationEngine);
            _inclusionsEngine        = new InclusionsEngine(_random, _simulationEngine);
            _CAEngine                = new CAEngine(_random, _simulationEngine);
            _MCEngine                = new MCEngine(_random, _simulationEngine);
            _fileEngine              = new FileEngine(_simulationEngine);
            _recrystallizationEngine = new RecrystallizationEngine(_random, _simulationEngine);
        }
Exemplo n.º 10
0
        private void HandleErrors(FileEngine file)
        {
            if (!file.HasErrors)
            {
                return;
            }

            var errorInfo = new FileInfo(Common.GetTemporaryFolder(_entity.ProcessName).TrimEnd(new[] { '\\' }) + @"\" + _name + ".errors.txt");

            file.OutputErrors(errorInfo.FullName);
            Logger.EntityWarn(_entity.Alias, "Errors sent to {0}.", errorInfo.Name);
        }
Exemplo n.º 11
0
 /// <summary>
 /// Gets the a bitmap object for a texture by name.
 /// </summary>
 /// <param name="texturename">The name of the texture.</param>
 /// <param name="twidth">The texture width, if any.</param>
 /// <returns>A valid bitmap object, or null.</returns>
 public Bitmap GetTextureBitmapWithWidth(string texturename, int twidth)
 {
     texturename = FileEngine.CleanFileName(texturename);
     if (LoadedTextures.TryGetValue(texturename, out Texture foundTexture) && foundTexture.LoadedProperly)
     {
         if (foundTexture.Width == twidth && foundTexture.Height == twidth)
         {
             return(foundTexture.SaveToBMP());
         }
     }
     return(LoadBitmapForTexture(texturename, twidth));
 }
Exemplo n.º 12
0
 protected override async Task ExecuteYield(IAsyncEnumerable <Row> rows,
                                            AsyncEnumerator <Row> .Yield yield,
                                            CancellationToken cancellationToken = default)
 {
     using (FileEngine file = FluentFile.For <UserRecord>().From("users.txt"))
     {
         foreach (object obj in file)
         {
             await @yield.ReturnAsync(Row.FromObject(obj));
         }
     }
 }
Exemplo n.º 13
0
 /// <summary>
 /// Loads a shader from file.
 /// </summary>
 /// <param name="filename">The name of the file to use.</param>
 /// <returns>The loaded shader, or null if it does not exist.</returns>
 public Shader LoadShader(string filename)
 {
     try
     {
         string   oname = filename;
         string[] datg  = filename.SplitFast('?', 1);
         string   geom  = datg.Length > 1 ? datg[1] : null;
         string[] dat1  = datg[0].SplitFast('#', 1);
         string[] vars  = new string[0];
         if (dat1.Length == 2)
         {
             vars = dat1[1].SplitFast(',');
         }
         filename = FileEngine.CleanFileName(dat1[0]);
         if (!File.Exists("shaders/" + filename + ".vs"))
         {
             SysConsole.Output(OutputType.WARNING, "Cannot load vertex shader, file '" +
                               TextStyle.Standout + "shaders/" + filename + ".vs" + TextStyle.Base +
                               "' does not exist.");
             return(null);
         }
         if (!File.Exists("shaders/" + filename + ".fs"))
         {
             SysConsole.Output(OutputType.WARNING, "Cannot load fragment shader, file '" +
                               TextStyle.Standout + "shaders/" + filename + ".fs" + TextStyle.Base +
                               "' does not exist.");
             return(null);
         }
         string VS = GetShaderFileText(filename + ".vs");
         string FS = GetShaderFileText(filename + ".fs");
         string GS = null;
         if (geom != null)
         {
             geom = FileEngine.CleanFileName(geom);
             if (!File.Exists("shaders/" + geom + ".geom"))
             {
                 SysConsole.Output(OutputType.WARNING, "Cannot load geomry shader, file '" +
                                   TextStyle.Standout + "shaders/" + geom + ".geom" + TextStyle.Base +
                                   "' does not exist.");
                 return(null);
             }
             GS = GetShaderFileText(geom + ".geom");
         }
         return(CreateShader(VS, FS, oname, vars, GS));
     }
     catch (Exception ex)
     {
         SysConsole.Output(OutputType.ERROR, "Failed to load shader from filename '" +
                           TextStyle.Standout + "shaders/" + filename + ".fs or .vs" + TextStyle.Base + "': " + ex.ToString());
         return(null);
     }
 }
Exemplo n.º 14
0
        /// <summary>
        /// Gets the texture object for a specific texture name.
        /// </summary>
        /// <param name="textureName">The name of the texture.</param>
        /// <returns>A valid texture object.</returns>
        public Texture GetTexture(string textureName)
        {
            textureName = FileEngine.CleanFileName(textureName);
            if (LoadedTextures.TryGetValue(textureName, out Texture foundTexture))
            {
                return(foundTexture);
            }
            Texture loaded = DynamicLoadTexture(textureName);

            LoadedTextures.Add(textureName, loaded);
            OnTextureLoaded?.Invoke(this, new TextureLoadedEventArgs(loaded));
            return(loaded);
        }
Exemplo n.º 15
0
 /// <summary>
 /// Starts or restarts the texture system.
 /// </summary>
 /// <param name="files">The relevant file helper.</param>
 /// <param name="assetStreaming">The relevant asset streaming helper.</param>
 /// <param name="schedule">The relevant scheduler.</param>
 public void InitTextureSystem(FileEngine files, AssetStreamingEngine assetStreaming, Scheduler schedule)
 {
     Files          = files;
     AssetStreaming = assetStreaming;
     Schedule       = schedule;
     // Create a generic graphics object for later use
     EmptyBitmap           = new Bitmap(1, 1);
     GenericGraphicsObject = Graphics.FromImage(EmptyBitmap);
     // Reset texture list
     LoadedTextures = new Dictionary <string, Texture>(256);
     // Pregenerate a few needed textures
     AddDefaults();
 }
Exemplo n.º 16
0
        public override IEnumerable <Row> Execute(IEnumerable <Row> rows)
        {
            using (FileEngine file = FluentFile.For <FlatFile>().From(FilePath))
            {
                int i = 0;
                foreach (FlatFile fileRow in file)
                {
                    yield return(Row.FromObject(fileRow));

                    i++;
                }
            }
        }
Exemplo n.º 17
0
        public static void ChooseImage(ref PictureEdit picture_edit, ref string file_name)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter      = FileEngine.GetImageFilterOpenFile();
            ofd.Multiselect = false;
            ofd.Title       = ConfigEngine.Language.Equals("vi") ? "Chọn hình ảnh" : "Choose an image";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                picture_edit.Image = Image.FromFile(ofd.FileName);
                file_name          = ofd.FileName;
            }
        }
Exemplo n.º 18
0
 /// <summary>
 /// Loads all content for the game, and starts the systems.
 /// </summary>
 /// <param name="sender">Irrelevant.</param>
 /// <param name="e">Irrelevant.</param>
 private void Window_Load(object sender, EventArgs e)
 {
     SysConsole.Output(OutputType.INIT, "GameClient starting load sequence...");
     GL.Viewport(0, 0, Window.Width, Window.Height);
     GL.Enable(EnableCap.Texture2D);
     GL.Enable(EnableCap.Blend);
     GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
     GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
     GL.Disable(EnableCap.CullFace);
     GraphicsUtil.CheckError("GEB - Initial");
     SysConsole.Output(OutputType.INIT, "GameClient loading file helpers...");
     Files = new FileEngine();
     Files.Init(Folder_Data, Folder_Mods, Folder_Saves);
     SysConsole.Output(OutputType.INIT, "GameClient loading shader helpers...");
     Shaders = new ShaderEngine();
     Shaders.InitShaderSystem();
     SysConsole.Output(OutputType.INIT, "GameClient loading texture helpers...");
     Textures = new TextureEngine();
     Textures.InitTextureSystem(Files);
     GraphicsUtil.CheckError("GEB - Textures");
     SysConsole.Output(OutputType.INIT, "GameClient loading font helpers...");
     GLFonts = new GLFontEngine(Textures, Shaders);
     GLFonts.Init(Files);
     FontSets = new FontSetEngine(GLFonts)
     {
         FixTo = Shaders.ColorMult2DShader
     };
     // TODO: FGE/Core->Languages engine!
     FontSets.Init((subdata) => null, () => Ortho, () => GlobalTickTime);
     GraphicsUtil.CheckError("GEB - Fonts");
     SysConsole.Output(OutputType.INIT, "GameClient loading 2D/UI render helper...");
     MainUI = new ViewUI2D(this);
     SysConsole.Output(OutputType.INIT, "GameEngine loading model engine...");
     Animations = new AnimationEngine();
     Models     = new ModelEngine();
     Models.Init(Animations, this);
     SysConsole.Output(OutputType.INIT, "GameEngine loading render helper...");
     Rendering3D = new Renderer(Textures, Shaders, Models);
     Rendering3D.Init();
     Rendering2D = new Renderer2D(Textures, Shaders);
     Rendering2D.Init();
     SysConsole.Output(OutputType.INIT, "GameClient calling engine load...");
     CurrentEngine.Load();
     SysConsole.Output(OutputType.INIT, "GameClient calling external load event...");
     OnWindowLoad?.Invoke();
     SysConsole.Output(OutputType.INIT, "GameClient is ready and loaded! Starting main game loop...");
     GraphicsUtil.CheckError("GEB - Loaded");
     Loaded = true;
 }
Exemplo n.º 19
0
        public override IEnumerable <Row> Execute(IEnumerable <Row> rows)
        {
            FluentFile engine = FluentFile.For <UserFullRecord>();

            engine.HeaderText = "Id\tName\tAddress";
            using (FileEngine file = engine.To(filePath))
            {
                foreach (Row row in rows)
                {
                    file.Write(row.ToObject <UserFullRecord>());

                    //pass through rows if needed for another later operation
                    yield return(row);
                }
            }
        }
Exemplo n.º 20
0
 /// <summary>
 /// Starts or restarts the texture system.
 /// </summary>
 public void InitTextureSystem(FileEngine files)
 {
     Files = files;
     // Create a generic graphics object for later use
     EmptyBitmap           = new Bitmap(1, 1);
     GenericGraphicsObject = Graphics.FromImage(EmptyBitmap);
     // Reset texture list
     LoadedTextures = new Dictionary <string, Texture>(256);
     // Pregenerate a few needed textures
     White = GenerateForColor(Color.White, "white");
     LoadedTextures.Add("white", White);
     Black = GenerateForColor(Color.Black, "black");
     LoadedTextures.Add("black", Black);
     Clear = GenerateForColor(Color.Transparent, "clear");
     LoadedTextures.Add("clear", Clear);
     NormalDef = GenerateForColor(Color.FromArgb(255, 127, 127, 255), "normal_def");
     LoadedTextures.Add("normal_def", NormalDef);
 }
Exemplo n.º 21
0
        /// <summary>
        /// Dynamically loads a texture (returns a temporary copy of 'White', then fills it in when possible).
        /// </summary>
        /// <param name="textureName">The texture name to load.</param>
        /// <returns>The texture object.</returns>
        public Texture DynamicLoadTexture(string textureName)
        {
            textureName = FileEngine.CleanFileName(textureName);
            Texture texture = new Texture()
            {
                Engine = this,
                Name   = textureName,
                Original_InternalID = White.Original_InternalID,
                Internal_Texture    = White.Internal_Texture,
                LoadedProperly      = false,
                Width  = White.Width,
                Height = White.Height
            };

            void processLoad(byte[] data)
            {
                Bitmap bmp = BitmapForBytes(data);

                Schedule.ScheduleSyncTask(() =>
                {
                    TextureFromBitMap(texture, bmp);
                    texture.LoadedProperly = true;
                    texture.Goal.SyncFollowUp?.Invoke();
                    texture.Goal = null;
                    bmp.Dispose();
                });
            }

            void fileMissing()
            {
                SysConsole.Output(OutputType.WARNING, $"Cannot load texture, file '{TextStyle.Standout}textures/{textureName}.png{TextStyle.Base}' does not exist.");
                texture.LoadedProperly = false;
            }

            void handleError(string message)
            {
                SysConsole.Output(OutputType.ERROR, $"Failed to load texture from filename '{TextStyle.Standout}textures/{textureName}.png{TextStyle.Error}': {message}");
                texture.LoadedProperly = false;
            }

            texture.Goal = AssetStreaming.AddGoal($"textures/{textureName}.png", false, processLoad, fileMissing, handleError);
            return(texture);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Gets the text of a shader file, automatically handling the file cache.
        /// </summary>
        /// <param name="filename">The name of the shader file.</param>
        /// <returns></returns>
        public string GetShaderFileText(string filename)
        {
            filename = FileEngine.CleanFileName(filename.Trim());
            if (!File.Exists("shaders/" + filename))
            {
                throw new Exception("File " + filename + " does not exist, but was included by a shader!");
            }
            if (ShaderFilesCache.TryGetValue(filename, out string filedata))
            {
                return(filedata);
            }
            if (ShaderFilesCache.Count > 128) // TODO: Configurable?
            {
                ShaderFilesCache.Clear();
            }
            string newData = Includes(File.ReadAllText("shaders/" + filename).Replace("\r\n", "\n").Replace("\r", ""));

            ShaderFilesCache[filename] = newData;
            return(newData);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Executes this operation
        /// </summary>
        /// <param name="rows">The rows.</param>
        /// <returns></returns>
        public override IEnumerable <Row> Execute(IEnumerable <Row> rows)
        {
            FluentFile engine = FluentFile.For <UserRecord>();

            engine.HeaderText = "Id\tName\tEmail";
            using (FileEngine file = engine.To("users.txt"))
            {
                foreach (Row row in rows)
                {
                    UserRecord record = new UserRecord();

                    record.Id    = (int)row["id"];
                    record.Name  = (string)row["name"];
                    record.Email = (string)row["email"];

                    file.Write(record);
                }
            }
            yield break;
        }
Exemplo n.º 24
0
        protected override async Task ExecuteYield(IAsyncEnumerable <Row> rows, AsyncEnumerator <Row> .Yield yield,
                                                   CancellationToken cancellationToken = default)
        {
            FluentFile engine = FluentFile.For <UserRecord>();

            engine.HeaderText = "Id\tName\tEmail";
            using (FileEngine file = engine.To("users.txt"))
            {
                await rows.ForEachAsync(row =>
                {
                    UserRecord record = new UserRecord();

                    record.Id    = (int)row["id"];
                    record.Name  = (string)row["name"];
                    record.Email = (string)row["email"];

                    file.Write(record);
                }, cancellationToken);
            }
            @yield.Break();
        }
Exemplo n.º 25
0
        /// <summary>
        /// Compiles a compute shader by name to a shader.
        /// </summary>
        /// <param name="fname">The file name.</param>
        /// <param name="specialadder">Special additions (EG defines)</param>
        /// <returns>The shader program.</returns>
        public int CompileCompute(string fname, string specialadder = "")
        {
            fname = FileEngine.CleanFileName(fname.Trim());
            string ftxt  = GetShaderFileText(fname + ".comp");
            int    index = ftxt.IndexOf(FILE_START);

            if (index < 0)
            {
                index = 0;
            }
            else
            {
                index += FILE_START.Length;
            }
            ftxt = ftxt.Insert(index, specialadder);
            int shd = GL.CreateShader(ShaderType.ComputeShader);

            GL.ShaderSource(shd, ftxt);
            GL.CompileShader(shd);
            string SHD_Info = GL.GetShaderInfoLog(shd);

            GL.GetShader(shd, ShaderParameter.CompileStatus, out int SHD_Status);
            if (SHD_Status != 1)
            {
                throw new Exception("Error creating ComputeShader. Error status: " + SHD_Status + ", info: " + SHD_Info);
            }
            int program = GL.CreateProgram();

            GL.AttachShader(program, shd);
            GL.LinkProgram(program);
            string str = GL.GetProgramInfoLog(program);

            if (str.Length != 0)
            {
                SysConsole.Output(OutputType.INFO, "Linked shader with message: '" + str + "'" + " -- FOR -- " + ftxt);
            }
            GL.DeleteShader(shd);
            GraphicsUtil.CheckError("Shader - Compute - Compile");
            return(program);
        }
Exemplo n.º 26
0
 private void btnFile_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var engine = new FileEngine();
         engine.LoadFile();
         string str = new FileInfo(Repository.Path).Name;
         btnFile.Content = "Выбран файл: " + str;
     }
     catch (ArgumentException)
     {
         MessageBox.Show("Вы не выбрали файл для чтения!", "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     catch (FileFormatException)
     {
         MessageBox.Show("Неверный формат файла!", "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
        public override void Init()
        {
            context = new ProductContext
            {
                MasterPageFile                    = String.Concat(PathProvider.BaseVirtualPath, "Masters/BasicTemplate.Master"),
                DisabledIconFileName              = "product_disabled_logo.png",
                IconFileName                      = "product_logo.png",
                LargeIconFileName                 = "product_logolarge.png",
                SubscriptionManager               = new ProductSubscriptionManager(),
                DefaultSortOrder                  = 20,
                SpaceUsageStatManager             = new ProjectsSpaceUsageStatManager(),
                AdminOpportunities                = () => ProjectsCommonResource.ProductAdminOpportunities.Split('|').ToList(),
                UserOpportunities                 = () => ProjectsCommonResource.ProductUserOpportunities.Split('|').ToList(),
                HasComplexHierarchyOfAccessRights = true,
            };

            FileEngine.RegisterFileSecurityProvider();
            SearchHandlerManager.Registry(new SearchHandler());
            NotifyClient.RegisterSecurityInterceptor();
            ClientScriptLocalization = new ClientLocalizationResources();
            DIHelper.Register();
        }
Exemplo n.º 28
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                LuceneSearch.LuceneEngine le = new LuceneSearch.LuceneEngine();
                var engine = new FileEngine();

                if (txtboxName.Text != "" && cmbboxDis.SelectedIndex != -1 && btnFile.Content.ToString() != "Выбрать файл")
                {
                    var IndexMe = engine.AddFile(txtboxName.Text, cmbboxDis.SelectedIndex, txtboxAuth.Text, txtboxTags.Text, txtboxComment.Text);
                    le.BuildIndex(IndexMe);//index this file

                    this.Close();
                }
                else
                {
                    MessageBox.Show("Вы ввели не все данные!", "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 29
0
 /// <summary>
 /// Loads a texture's bitmap from file.
 /// </summary>
 /// <param name="filename">The name of the file to use.</param>
 /// <param name="twidth">The texture width, if any.</param>
 /// <returns>The loaded texture bitmap, or null if it does not exist.</returns>
 public Bitmap LoadBitmapForTexture(string filename, int twidth)
 {
     try
     {
         filename = FileEngine.CleanFileName(filename);
         if (!Files.TryReadFileData($"textures/{filename}.png", out byte[] textureFile))
Exemplo n.º 30
0
 /// <summary>
 /// Loads a model by name.
 /// </summary>
 /// <param name="filename">The name.</param>
 /// <returns>The model.</returns>
 public Model LoadModel(string filename)
 {
     try
     {
         filename = FileEngine.CleanFileName(filename);
         if (!TheClient.Files.TryReadFileData("models/" + filename + ".vmd", out byte[] bits))