Пример #1
0
 public void JumpBlock(int Index)
 {
     NowPlayingBlock.OnExit();
     PlayBlockIndex  = Index;
     NowPlayingBlock = StoryBlocks[_PlayBlockIndex];
     NowPlayingBlock.OnEnter();
 }
Пример #2
0
        public AddOrderWindow(StoryBlock ownerBlock, Vector2 windowTalePosition) : this()
        {
            this.OwnerBlock         = ownerBlock;
            this.windowTalePosition = windowTalePosition;

            CreateTypeItems();
        }
Пример #3
0
        public async Task <ActionResult <StoryBlock> > PostStoryBlock(StoryBlock storyBlock)
        {
            try
            {
                // Find the block by id
                var blockFromDb = context_.StoryBlocks.SingleOrDefault(c => c.StoryBlockId == storyBlock.StoryBlockId);
                if (blockFromDb == null)
                {
                    return(NotFound());
                }

                // Add Block
                var block = new StoryBlock
                {
                    Name         = storyBlock.Name,
                    Image        = storyBlock.Image,
                    Content      = storyBlock.Content,
                    StoryBlockId = storyBlock.StoryBlockId,
                    Path         = storyBlock.Path
                };
                context_.StoryBlocks.Add(block);
                context_.SaveChanges();
            }
            catch
            {
                return(BadRequest());
            }
            return(Ok());
            // context_.StoryBlocks.Add(storyBlock);
            // await context_.SaveChangesAsync();

            // return CreatedAtAction(nameof(GetStoryBlock), new { id = storyBlock.StoryBlockId }, storyBlock);
        }
Пример #4
0
        public bool NextBlock()
        {
            if (CurrentBlock.IsComplete)
            {
                StoryBlock prevBlock = CurrentBlock;
                prevBlock.OnEnd();

                ++CurrentBlockIndex;
                if (CurrentBlockIndex < blockList.Count)
                {
                    StoryBlock currentBlock = CurrentBlock;
                    currentBlock.OnEnter();

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                StoryBlock currentBlock = CurrentBlock;
                currentBlock.Skip();

                return(true);
            }
        }
Пример #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            StoryBlock storyBlock = db.StoryBlocks.Find(id);

            db.StoryBlocks.Remove(storyBlock);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #6
0
        public ActionResult Edit([Bind(Include = "storyBlockId,storyBlockName,storyBlockCaption,storyBlockDescription,storyBlockLocation,storyBlockOrderNumber,archivalStatus,uploadDate,collageId,temp_string1,temp_string2,temp_int1,temp_int2")] StoryBlock storyBlock, HttpPostedFileBase clientUploadedFile)
        {
            storyBlock.uploadDate = DateTime.Now;
            StoryBlock StoryBlock_Temp = TempData["StoryBlock_Temp"] as StoryBlock;

            storyBlock.archivalStatus = StoryBlock_Temp.archivalStatus;
            string acceptedFileType = "image/jpeg,image/gif,image/tiff,image/png,image/jpg";
            string imageName, image_Path, updated_Path;

            if (clientUploadedFile != null && clientUploadedFile.ContentLength > 0)               // update image
            {
                if (acceptedFileType.Split(",".ToCharArray()).Contains(clientUploadedFile.ContentType))
                {
                    if (clientUploadedFile.ContentLength < 5000000)
                    {
                        imageName = System.IO.Path.GetFileName(clientUploadedFile.FileName);
                        Collage collage1 = db.Collages.Find(storyBlock.collageId);
                        image_Path   = System.IO.Path.Combine(Server.MapPath(collage1.collageLocation), imageName);
                        updated_Path = collage1.collageLocation + "/" + imageName;
                        clientUploadedFile.SaveAs(image_Path);
                        using (MemoryStream m_stream = new MemoryStream())
                        {
                            clientUploadedFile.InputStream.CopyTo(m_stream);
                            byte[] array = m_stream.GetBuffer();
                        }
                        storyBlock.storyBlockLocation = updated_Path;
                        if (ModelState.IsValid)
                        {
                            db.Entry(storyBlock).State = EntityState.Modified;
                            db.SaveChanges();
                            return(RedirectToAction("Index"));
                        }
                    }
                    else
                    {
                        ViewBag.errorMessage = "The file to be uploaded is exceeding the size limit. Please upload a file lessthan 5MB";
                    }
                }
                else
                {
                    ViewBag.errorMessage = "Please upload the following type of files: image/jpeg,image/gif,image/tiff,image/png,image/jpg";
                }
            }
            else
            {
                storyBlock.storyBlockLocation = StoryBlock_Temp.storyBlockLocation;
                if (ModelState.IsValid)
                {
                    db.Entry(storyBlock).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            ViewBag.collageId = new SelectList(db.Collages, "collageId", "collageName", storyBlock.collageId);
            TempData.Remove("StoryBlock_Temp");
            return(View(storyBlock));
        }
        public static void Initialize(ApplicationDbContext context)
        {
            context.Database.EnsureCreated();
            if (context.Categories.Any())
            {
                return;
            }

            var category = new Categories[]
            {
                new Categories {
                    categoryName = "Projects"
                },
                new Categories {
                    categoryName = "Experiences"
                }
            };

            foreach (Categories c in category)
            {
                context.Categories.Add(c);
            }
            context.SaveChanges();

            var story = new Stories[]
            {
                new Stories {
                    storyName    = "Multi User Test Harness", storyDescription = "C++ Based Testing tool designed using WPF and C++ CLI",
                    CategoriesID = 1
                },
                new Stories {
                    storyName    = "Journey from India to USA", storyDescription = "Story about the steps and experiences of obtaining a Masters Degree",
                    CategoriesID = 2
                }
            };

            foreach (Stories s in story)
            {
                context.Stories.Add(s);
            }
            context.SaveChanges();

            var storyBlock = new StoryBlock[]
            {
                new StoryBlock {
                    FileName = "new.txt", ImageName = "desert.jpg", StoriesID = 1
                }
            };

            foreach (StoryBlock s in storyBlock)
            {
                context.StoryBlocks.Add(s);
            }
            context.SaveChanges();
        }
Пример #8
0
 public void AddBlock(StoryBlock Block)
 {
     if (StoryBlocks.Contains(Block))
     {
         return;
     }
     if (HasBlock(Block._BlockName))
     {
         return;
     }
     StoryBlocks.Add(Block);
 }
Пример #9
0
        public ActionResult Create([Bind(Include = "storyBlockId,storyBlockName,storyBlockCaption,storyBlockDescription,storyBlockLocation,storyBlockOrderNumber,archivalStatus,uploadDate,collageId,temp_string1,temp_string2,temp_int1,temp_int2")] StoryBlock storyBlock, HttpPostedFileBase clientUploadedFile)
        {
            storyBlock.uploadDate     = DateTime.Now;
            storyBlock.archivalStatus = false;
            //storyBlock.storyBlockDescription = storyBlock.temp_string1;
            string acceptedFileType = "image/jpeg,image/gif,image/tiff,image/png,image/jpg"; //Accepts the mentioned file types for upload
            string imageName, image_Path, updated_Path;

            if (clientUploadedFile != null && clientUploadedFile.ContentLength > 0)                     //checks for empty files
            {
                if (acceptedFileType.Split(",".ToCharArray()).Contains(clientUploadedFile.ContentType)) // checks for valid extensions
                {
                    if (clientUploadedFile.ContentLength < 5000000)                                     // supports up to 5MB size files
                    {
                        imageName = System.IO.Path.GetFileName(clientUploadedFile.FileName);
                        Collage collage1 = db.Collages.Find(storyBlock.collageId);
                        image_Path   = System.IO.Path.Combine(Server.MapPath(collage1.collageLocation), imageName);
                        updated_Path = collage1.collageLocation + "/" + imageName;                          // stores image path as a static path along with image name
                        clientUploadedFile.SaveAs(image_Path);
                        using (MemoryStream m_stream = new MemoryStream())                                  // Creates a stream and store to memory
                        {
                            clientUploadedFile.InputStream.CopyTo(m_stream);
                            byte[] array = m_stream.GetBuffer();
                        }
                        storyBlock.storyBlockLocation = updated_Path;
                        if (ModelState.IsValid)
                        {
                            db.StoryBlocks.Add(storyBlock);
                            db.SaveChanges();
                            return(RedirectToAction("Index"));
                        }
                    }
                    else
                    {
                        ViewBag.errorMessage = "The file to be uploaded is exceeding the size limit. Please upload a file lessthan 5MB";
                    }
                }
                else
                {
                    ViewBag.errorMessage = "Please upload the following type of files: image/jpeg,image/gif,image/tiff,image/png,image/jpg";
                }
            }
            else
            {
                ViewBag.errorMessage = "Please upload a non empty file";
            }


            ViewBag.collageId = new SelectList(db.Collages, "collageId", "collageName", storyBlock.collageId);
            return(View(storyBlock));
        }
Пример #10
0
 public void PlayNextBlock() //播放下一个故事区块
 {
     if (_PlayBlockIndex > StoryBlocks.Count)
     {
         return;
     }
     if (NowPlayingBlock)
     {
         NowPlayingBlock.OnExit();
     }
     PlayBlockIndex++;
     NowPlayingBlock = StoryBlocks[_PlayBlockIndex];
     NowPlayingBlock.OnEnter();
 }
Пример #11
0
        public void DetachBlock()
        {
            if (EditingBlock == null)
            {
                return;
            }

            //Remove events
            EditingBlock.OrderAdded   -= EditingBlock_OrderAdded;
            EditingBlock.OrderRemoved -= EditingBlock_OrderRemoved;

            this.EditingBlock = null;

            OrderEditorViewContext.Children.Clear();
        }
Пример #12
0
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StoryBlock storyBlock = db.StoryBlocks.Find(id);

            ViewBag.archival_stat = storyBlock.archivalStatus;
            if (storyBlock == null)
            {
                return(HttpNotFound());
            }
            return(View(storyBlock));
        }
Пример #13
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StoryBlock storyBlock = db.StoryBlocks.Find(id);

            if (storyBlock == null)
            {
                return(HttpNotFound());
            }
            ViewBag.archival_stat       = storyBlock.archivalStatus;
            ViewBag.collageId           = new SelectList(db.Collages, "collageId", "collageName", storyBlock.collageId);
            TempData["StoryBlock_Temp"] = storyBlock;
            return(View(storyBlock));
        }
Пример #14
0
        public void AttachBlock(StoryBlock blockItem)
        {
            DetachBlock();
            this.EditingBlock = blockItem;

            if (blockItem == null)
            {
                return;
            }

            foreach (OrderBase order in blockItem.OrderList)
            {
                EditingBlock_OrderAdded(order);
            }
            //Register events
            blockItem.OrderAdded   += EditingBlock_OrderAdded;
            blockItem.OrderRemoved += EditingBlock_OrderRemoved;
        }
Пример #15
0
        public async Task <IActionResult> Upload()
        {
            var request    = HttpContext.Request;
            var blockFile  = request.Form.Files[0];
            var blockImage = request.Form.Files[1];
            var storyImage = request.Form.Files[2];
            var date       = DateTime.Now.ToString();

            {
                if (blockFile.Length > 0)
                {
                    var path = Path.Combine(filePath, blockFile.FileName);
                    using (var fileStream = new FileStream(path, FileMode.Create))
                    {
                        await blockFile.CopyToAsync(fileStream);
                    }

                    path = Path.Combine(filePath, blockImage.FileName);
                    using (var fileStream = new FileStream(path, FileMode.Create))
                    {
                        await blockImage.CopyToAsync(fileStream);
                    }
                    path = Path.Combine(strImagePath, storyImage.FileName);
                    using (var fileStream = new FileStream(path, FileMode.Create))
                    {
                        await storyImage.CopyToAsync(fileStream);
                    }

                    /*---If a new Story is being added for the first time, saves the story into
                     *--- the database to generate its StoryID
                     *--- The IF statement checks the type of operation being performed
                     *--- A new Story or just a new block---*/

                    if (request.Form["OperationType"].Equals("Story"))
                    {
                        var story = new Stories
                        {
                            storyName        = request.Form["StoryName"],
                            storyDescription = request.Form["Descp"],
                            ImageName        = storyImage.FileName,
                            CategoriesID     = Int32.Parse(request.Form["Category"])
                        };
                        context_.Stories.Add(story);
                        context_.SaveChanges();

                        /*---Fetches the StoryID of the newly added story inorder to add the storyblock
                         *--- the story Block needs storyID to link the two tables---*/

                        var newId = context_.Stories.Where(s => s.storyName == story.storyName && s.CategoriesID == story.CategoriesID).First();

                        /*---Adding the story block for the newly added story into the StoryBlock Table---*/

                        var block = new StoryBlock
                        {
                            StoryBlockName = Path.GetFileNameWithoutExtension(blockFile.FileName),
                            FileName       = blockFile.FileName,
                            ImageName      = blockImage.FileName,
                            StoriesID      = newId.StoriesID,
                            Timeline       = Convert.ToDateTime(date)
                        };
                        context_.StoryBlocks.Add(block);
                        context_.SaveChanges();
                    }

                    /*---Adding Story block for an existing Story into the StoryBlock table---*/
                    else
                    {
                        var block = new StoryBlock
                        {
                            StoryBlockName = Path.GetFileNameWithoutExtension(blockFile.FileName),
                            FileName       = blockFile.FileName,
                            ImageName      = blockImage.FileName,
                            StoriesID      = Int32.Parse(request.Form["Story"]),
                            Timeline       = Convert.ToDateTime(date)
                        };
                        context_.StoryBlocks.Add(block);
                        context_.SaveChanges();
                    }
                }
                else
                {
                    return(BadRequest());
                }
            }
            return(Ok());
        }