Example #1
0
        protected override void LoadContent()
        {
            base.LoadContent();

            spriteBatch = new SpriteBatch(GraphicsDevice);

            EmbeddedContent  = new XNBContentManager(GraphicsDevice);
            GraphicUtilities = new GraphicUtilities();

            Content.RootDirectory = "Content";
            GameServices.AddService <ContentManager> (Content);
        }
Example #2
0
        private void Draw()
        {
            Color color = GraphicUtilities.GetColorFromHEX("#a7a7a7");

            GraphicUtilities.DrawLine(points[0], points[1], PositionOnScreen, color);
            GraphicUtilities.DrawLine(points[1], points[2], PositionOnScreen, color);
            GraphicUtilities.DrawLine(points[2], points[3], PositionOnScreen, color);
            GraphicUtilities.DrawLine(points[3], points[4], PositionOnScreen, color);
            GraphicUtilities.DrawLine(points[4], points[5], PositionOnScreen, color);
            GraphicUtilities.DrawLine(points[5], points[6], PositionOnScreen, color);
            GraphicUtilities.DrawLine(points[6], points[0], PositionOnScreen, color);

            color = GraphicUtilities.GetColorFromHEX("#00b40d");
            GraphicUtilities.DrawLine(points[7], points[8], PositionOnScreen, color, 0.2f);
            GraphicUtilities.DrawLine(points[8], points[9], PositionOnScreen, color, 0.2f);
            GraphicUtilities.DrawLine(points[9], points[10], PositionOnScreen, color, 0.2f);
            GraphicUtilities.DrawLine(points[10], points[11], PositionOnScreen, color, 0.2f);
            GraphicUtilities.DrawLine(points[11], points[12], PositionOnScreen, color, 0.2f);
            GraphicUtilities.DrawLine(points[12], points[13], PositionOnScreen, color, 0.2f);
            GraphicUtilities.DrawLine(points[13], points[0], PositionOnScreen, color, 0.2f);
        }
Example #3
0
 private void Draw()
 {
     GraphicUtilities.DrawShape(points, PositionOnScreen, 0.5f);
 }
Example #4
0
        /// <summary>
        /// ######### ########### ## ###### "##### # ######" # ############ ###### ####### ###### ## ###########
        /// # ######## HtmlEdit ## #######
        /// </summary>
        /// <param name="userConnection">UserConnection ######## ############</param>
        /// <param name="htmlEdit">######## HtmlEdit</param>
        /// <param name="entitySchema">##### #######, # ####### ######### ###########</param>
        /// <param name="entityId">UId #######, # ####### ######### ###########</param>
        public static void SaveAndInsertImage(UserConnection userConnection, HtmlEdit htmlEdit, EntitySchema entitySchema, Guid entityId)
        {
            // ######### ####### #####
            if (Page.Request.Files.Count == 0)
            {
                return;
            }

            // ######## ##### ###### "##### # ######", #### ##### ##### ### - ###### ## ######
            EntitySchemaManager esm       = userConnection.EntitySchemaManager;
            string       fileSchemaName   = entitySchema.Name + "File";
            EntitySchema fileEntitySchema = esm.FindInstanceByName(fileSchemaName);

            if (fileEntitySchema == null)
            {
                return;
            }

            string         fileFieldName = htmlEdit.ClientID + "_loadedImage-file";
            HttpPostedFile file          = Page.Request.Files[fileFieldName];
            string         fileName      = file.FileName;

            if (string.IsNullOrEmpty(fileName))
            {
                return;
            }
            // ######## ###### #### ### ###### #####
            Stream fileStream = file.InputStream;

            fileStream.Position = 0;
            long fileSize = fileStream.Length;
            var  fileData = new byte[fileStream.Length];

            fileStream.Read(fileData, 0, fileData.Length);

            var img = Image.FromStream(fileStream);

            if (GraphicUtilities.GetImageFormat(img.RawFormat) == null)
            {
                var warning       = GetLocalizableStringValue(userConnection, "Warning");
                var fileTypeError = GetLocalizableStringValue(userConnection, "FileTypeError");

                const string messageCallback = @" function() {{}} ";

                string showMessageScript = ClientScriptUtilities.GetMessageScript(warning, fileTypeError,
                                                                                  MessageBoxButtons.Ok, MessageBoxIcon.Information, messageCallback);
                ScriptManager.AddScript(showMessageScript);
                return;
            }

            // crea Entity ### ###### ##### # ######### ##
            var fileUId        = Guid.NewGuid();
            var fileRepository = ClassFactory.Get <FileRepository>(
                new ConstructorArgument("userConnection", userConnection));
            var fileEntityInfo = new FileEntityUploadInfo(fileSchemaName, fileUId, fileName);

            fileEntityInfo.ParentColumnName  = entitySchema.Name;
            fileEntityInfo.ParentColumnValue = entityId;
            fileEntityInfo.TotalFileLength   = fileData.Length;
            fileEntityInfo.Content           = new MemoryStream(fileData);
            fileRepository.UploadFile(fileEntityInfo);

            // ####### ###### ControlImage # ############## ###
            var controlImage = new ControlImage {
                // ###### ##### ###########. # ###### ###### ## Entity
                Source = ControlImageSource.EntityColumn,
                // ## ##### EntitySchema-# ##### ######## Entity
                SchemaUId = fileEntitySchema.UId,
                // ######### ####### (ID ######)
                EntityPrimaryColumnValue = fileUId,
                // ####### ## ####### ##### ######## ######. #### ###### #### UsePrimaryImageColumn, ######### ## ###########
                EntitySchemaColumnUId = fileEntitySchema.Columns.GetByName("Data").UId,
                UsePrimaryImageColumn = false
            };

            // ### ##### ######## ########## ###### ControlImage ###### ######## ##########.
            // ######### ###### ### ##### ##### ########### # ######### #######.
            // ## ###### ###### ## ###### ############## ############# ###### # ######## ### ## ######
            string controlImageValue = Json.Serialize(controlImage, new ControlImageJsonConverter());

            ScriptManager.AddScript(string.Format("{0}.insertImage({1})", htmlEdit.ClientID, controlImageValue));
        }