Exemplo n.º 1
1
 public static byte[] CreateAgreementDoc(string WebPath, string AgreementNumber, string AgreementDate, string UserName, string SignerName, string TargetPosition, string TargetDepartment, string SignerShortName, string SignerPositionWithDepartment, string UserShortName)
 {
     FileInfo file = new FileInfo(Path.Combine(WebPath, @"StaffMovements\Dogovor.docx"));
     string newfilename = Path.Combine(WebPath,Guid.NewGuid().ToString()+".docx");
     var newfile = file.CopyTo(newfilename,true);
     using (var outputDocument = new TemplateProcessor(newfilename)
         .SetRemoveContentControls(true))
     {
         var documentenc = Encoding.GetEncoding(outputDocument.Document.Declaration.Encoding);
         var valuesToFill = new Content(
             new FieldContent("AgreementNumber", AgreementNumber),
             new FieldContent("AgreementDate", AgreementDate),
             new FieldContent("UserName", UserName),
             new FieldContent("Signer", SignerName),
             new FieldContent("TargetPosition", TargetPosition),
             new FieldContent("TargetDepartment", TargetDepartment),
             new FieldContent("SignerShortName", SignerShortName),
             new FieldContent("SignerPositionWithDepartment", SignerPositionWithDepartment),
             new FieldContent("UserShortName", UserShortName)
         );
         outputDocument.FillContent(valuesToFill);
         outputDocument.SaveChanges();
     }
     StreamReader reader = new StreamReader(newfilename);
     var result =  NoteCreator.ReadFull(reader.BaseStream);
     //newfile.Delete();
     return result;
 }
 /// <summary>
 /// Adds a regex url for the Create method to match against to determine if it should mock a CurrentNode
 /// </summary>
 /// <param name="url"></param>
 /// <param name="content">If the url matches, this is the content objec that will be returned for the CurrentNode mock</param>
 public void AddMatchingUrlForContent(string url, Content content)
 {
     if (!_urlsToMatch.ContainsKey(url))
     {
         _urlsToMatch.Add(url, content);
     }
 }
        public void VeneerScripts_handles_content_types_with_no_scripts()
        {
            // Arrange
            var service = new Mock<IContentService>();
            var content = new Content
            {
                RefreshDate = DateTime.Now,
                Sections = new List<ContentSection>
                {
                    new ContentSection
                    {
                        Id = "Footer", Html = "<div id='hello' />", Scripts = new List<ContentScript>()
                    }
                }
            };
            service.Setup(x => x.Get(It.IsAny<ContentTypes>())).Returns(content);
            var contentTypes = new List<ContentTypes> { ContentTypes.Footer };

            var model = new VeneerBaseViewModel(service.Object, contentTypes);

            var viewContext = new ViewContext();
            var viewDataContainer = new Mock<IViewDataContainer>();
            var htmlHelper = new HtmlHelper(viewContext, viewDataContainer.Object);

            // Act
            var result = htmlHelper.VeneerScripts(model).ToHtmlString();

            // Assert
            Assert.That(result, Is.Empty);
        }
Exemplo n.º 4
0
        protected override void VisitAndAlso(Content.Query.Expressions.AndAlsoExpression expression)
        {
            var andAlso = (AndAlsoExpression)expression;

            IMongoQuery leftClause = null;
            if (!(andAlso.Left is TrueExpression))
            {
                leftClause = VisitInner(andAlso.Left);
            }

            IMongoQuery rightClause = null;
            if (!(andAlso.Right is TrueExpression))
            {
                rightClause = VisitInner(andAlso.Right);
            }

            if (leftClause != null && rightClause != null)
            {
                var queryComplete = QueryBuilder.Query.And(leftClause, rightClause);
                SetQuery(queryComplete);
            }
            else if (leftClause != null)
            {
                SetQuery(leftClause);
            }
            else if (rightClause != null)
            {
                SetQuery(rightClause);
            }
        }
Exemplo n.º 5
0
        public override void Initialize(Content context, string backUri, Application application, object parameters)
        {
            base.Initialize(context, backUri, application, parameters);

            if (!SecurityHandler.HasPermission(NodeHead.Get("/Root/System/WebRoot/Explore.html"), PermissionType.Open))
                this.Forbidden = true;
        }
Exemplo n.º 6
0
        public HxS(string workingDir, string hxsFile,
            string title, string copyright, string locale,
            TreeNodeCollection nodes,
            Content contentDataSet,
            Dictionary<string, string> links)
        {
            this.locale = locale;
            this.title = title;
            this.copyright = copyright;
            this.nodes = nodes;
            this.contentDataSet = contentDataSet;
            this.links = links;

            this.outputFile = Path.GetFullPath(hxsFile);
            this.rawDir = Path.Combine(workingDir, "raw");

            // The source shouldn't be hidden away. If an error happens (likely) the user needs to check logs etc.
            //this.hxsDir = Path.Combine(workingDir, "hxs");
            this.hxsDir = GetUniqueDir(hxsFile);
            this.withinHxsDir = Path.Combine(hxsDir, hxsSubDir);
            this.baseFilename = Path.GetFileNameWithoutExtension(hxsFile);
            this.baseFilename = this.baseFilename.Replace(" ", "_");  //replace spaces with _ otherwise we get compile errors

            this.logFile = Path.Combine(hxsDir, this.baseFilename + ".log");
            this.projectFile = Path.Combine(hxsDir, baseFilename + ".hxc");

            if (xform == null)
            {
                xform = new XslCompiledTransform(true);
                xform.Load(transformFile);
            }
        }
Exemplo n.º 7
0
		public void UnlockAvatar(Content.Avatars avatar)
		{
			switch (avatar)
			{
			case Content.Avatars.Dragon:
				unlockedAvatar = new Dragon();
				if (!AvailableAvatars.Contains(unlockedAvatar))
					AvailableAvatars.Add(unlockedAvatar);
				break;

			case Content.Avatars.Penguin:
				unlockedAvatar = new Penguin();
				if (!AvailableAvatars.Contains(unlockedAvatar))
					AvailableAvatars.Add(unlockedAvatar);
				break;

			case Content.Avatars.PiggyBank:
				unlockedAvatar = new PiggyBank();
				if (!AvailableAvatars.Contains(unlockedAvatar))
					AvailableAvatars.Add(unlockedAvatar);
				break;
			}

			if (AvailableAvatars.Count == 1)
				ChangeAvatar(avatar);
		}
Exemplo n.º 8
0
 public void OnContentRestored(Content category)
 {
     if (ContentRestored != null)
     {
         ContentRestored(new SingleItemEventArgs<Content>(category));
     }
 }
Exemplo n.º 9
0
        protected override void LoadProperties(Content.IContentManager contentManager, INode node)
        {
            base.LoadProperties(contentManager, node);

            CirclePrimitive circlePrimitive = (CirclePrimitive)node;
            circlePrimitive.Radius = Radius;
        }
Exemplo n.º 10
0
 HttpContent(Content content, string contentType, long? contentLength)
 {
     this.content = content;
     this.contentType = contentType;
     this.contentLength = contentLength;
     this.state = ContentState.Created;
 }
Exemplo n.º 11
0
 public Column(String name, String alias, Type datatype, Content datacontent )
 {
     Name = name;
     Alias = alias;
     DataType = datatype;
     DataContent = datacontent;
 }
        public static Content SetupTestContentData(Guid newGuid, Guid newGuidRedHerring, ProviderSetup providerSetup)
        {
            var baseEntity = HiveModelCreationHelper.MockTypedEntity();
            var entity = new Content(baseEntity); 
            entity.Id = new HiveId(newGuid);
            entity.EntitySchema.Alias = "schema-alias1";

            var existingDef = entity.EntitySchema.AttributeDefinitions[0];
            var newDef = HiveModelCreationHelper.CreateAttributeDefinition("aliasForQuerying", "", "", existingDef.AttributeType, existingDef.AttributeGroup, true);
            entity.EntitySchema.AttributeDefinitions.Add(newDef);
            entity.Attributes.Add(new TypedAttribute(newDef, "my-new-value"));

            entity.Attributes[1].DynamicValue = "not-on-red-herring";
            entity.Attributes[NodeNameAttributeDefinition.AliasValue].Values["UrlName"] = "my-test-route";

            var redHerringEntity = HiveModelCreationHelper.MockTypedEntity();
            redHerringEntity.Id = new HiveId(newGuidRedHerring);
            redHerringEntity.EntitySchema.Alias = "redherring-schema";

            using (var uow = providerSetup.UnitFactory.Create())
            {
                var publishedRevision = new Revision<TypedEntity>(entity)
                    { MetaData = { StatusType = FixedStatusTypes.Published } };

                uow.EntityRepository.Revisions.AddOrUpdate(publishedRevision);
                // Only add extra entity if caller wants it
                if (newGuidRedHerring != Guid.Empty) uow.EntityRepository.AddOrUpdate(redHerringEntity);
                uow.Complete();
            }

            return entity;
        }
Exemplo n.º 13
0
 /// <summary>
 /// Constructs a default GameInfo object, with 0 handicap, 5.5 komi 19x19 board and
 /// black as the starting player.
 /// </summary>
 public GameInfo()
 {
     Komi = 5.5;
     StartingPlayer = Content.Black;
     Handicap = 0;
     BoardSizeX = BoardSizeY = 19;
 }
Exemplo n.º 14
0
        public void Markup_client_retrieves_last_known_good_content_from_local_cache_if_service_throws_exception()
        {
            // Arrange
            var service = new Mock<IContentService>();

            service.Setup(x => x.Get(ContentTypes.Intranet_FatFooter)).Throws(new Exception("Unit test exception"));
            var cache = new Mock<ILocalCache<Content>>();
            cache.Setup(x => x.WriteToCache(ContentTypes.Intranet_FatFooter, It.IsAny<Content>(), It.IsAny<DateTime>()));
            var content = new Content
            {
                RefreshDate = DateTime.Now,
                Sections = new List<ContentSection>
                {
                    new ContentSection
                    {
                        Id = ContentTypes.Intranet_FatFooter.ToString()
                    }
                }
            };
            cache.Setup(x => x.ReadFromCache(ContentTypes.Intranet_FatFooter)).Returns(content);
            var client = new ContentClient(service.Object, cache.Object);

            // Act
            client.Get(ContentTypes.Intranet_FatFooter);

            // Assert
            service.Verify(x => x.Get(ContentTypes.Intranet_FatFooter), Times.Once);
            cache.Verify(x => x.ReadFromCache(ContentTypes.Intranet_FatFooter), Times.Once);
            cache.Verify(x => x.WriteToCache(ContentTypes.Intranet_FatFooter, It.IsAny<Content>(), It.IsAny<DateTime>()), Times.Never);
        }
Exemplo n.º 15
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="outFileName"></param>
 public static void addValuesPosv(string outFileName)
 {
     var ValuesToFill = new Content(
         new FieldContent("psvNomer", mvVars.psvNomer),
         new FieldContent("psvDataZv", mvVars.psvDataZv),
         new FieldContent("psvDataVik", mvVars.psvDataVik),
         new FieldContent("psvDataChn", mvVars.psvDataChn),
         new FieldContent("psvFio", mvVars.psvFio),
         new FieldContent("psvFioShort", mvVars.psvFioShort),
         new FieldContent("psvProfession", mvVars.psvProfession),
         new FieldContent("psvBirthDate", mvVars.psvBirthDate),
         new FieldContent("psvAddress", mvVars.psvAddress),
         new FieldContent("psvIpn", mvVars.psvIpn),
         new FieldContent("psvRr", mvVars.psvRr),
         new FieldContent("psvFioProfSklon", mvVars.psvFioProfSklon),
         new FieldContent("psvSumma", mvVars.psvSumma),
         new FieldContent("psvSummaStr", mvVars.psvSummaStr),
         new FieldContent("psvMonthZrp", mvVars.psvMonthZrp),
         new FieldContent("psvYearZrp", mvVars.psvYearZrp),
         new FieldContent("psvDataPosv", mvVars.psvDataPosv)//dgv[9, i].Value.ToString())
             );
     File.Copy(mvVars.dPath + "psv_templ.docx", outFileName);
     using (var outfile = new TemplateProcessor(outFileName).SetRemoveContentControls(true))
     {
         outfile.FillContent(ValuesToFill);
         outfile.SaveChanges();
     }
 }
Exemplo n.º 16
0
		private void AttachButtonEvent(Content.TowerSelectionPanel buttonName, TowerType type)
		{
			var button = (InteractiveButton)GetSceneControl(buttonName.ToString());
			button.AddTag(type.ToString());
			button.Clicked += () => BuildTower(type);
			towerButtonPanel.Add(button);
		}
Exemplo n.º 17
0
 /// <summary>
 /// Called to ensure we have a valid LoadedContentItem.
 /// </summary>
 /// <param name="version"></param>
 private void EnsureLoadedContentItem(Guid version)
 {
     if (LoadedContentItem == null)
     {
         LoadedContentItem = Content.GetContentFromVersion(Version);
     }
 }
Exemplo n.º 18
0
        public void Storage_handler_writes_to_file_at_specified_location()
        {
            // Arrange
            var storageHandler = new StorageHandler<Content>();
            var content = new Content
            {
                RefreshDate = DateTime.Now,
                Sections = new List<ContentSection>
                {
                    new ContentSection
                    {
                        Id = ContentTypes.HeaderWithMegaNav.ToString(),
                        Html = "<div id='meganav' />"
                    }
                }
            };

            // Act
            storageHandler.WriteToStorage(ContentTypes.HeaderWithMegaNav, content);

            const string fileName = "C:\\dev\\Veneer\\Client\\ContentCache-HeaderWithMegaNav.cache";

            var fileContents = File.ReadAllText(fileName);

            var contentFromCache = storageHandler.ReadFromStorage(ContentTypes.HeaderWithMegaNav);

            // Assert
            Assert.That(fileContents, Is.StringContaining("meganav"));
            Assert.That(contentFromCache.Sections.FirstOrDefault(x => x.Id == ContentTypes.HeaderWithMegaNav.ToString()), Is.Not.Null);
        }
Exemplo n.º 19
0
        public override void Initialize(Content context, string backUri, Application application, object parameters)
        {
            base.Initialize(context, backUri, application, parameters);

            if (!context.Path.Contains("/(apps)/This/"))
                this.Forbidden = true;
        }
Exemplo n.º 20
0
        public override void Initialize(Content context, string backUri, Application application, object parameters)
        {
            base.Initialize(context, backUri, application, parameters);

            var clv = context.ContentHandler as SenseNet.Portal.UI.ContentListViews.Handlers.ViewBase;
            if (clv == null)
            {
                this.Forbidden = true;
                return;
            }

            var cl = ContentList.GetContentListByParentWalk(clv);
            if (cl == null)
            {
                this.Forbidden = true;
                return;
            }

            if (string.IsNullOrEmpty(cl.DefaultView))
                return;

            //if this view is the default, the action is meaningless
            if (cl.DefaultView.CompareTo(context.Name) == 0)
                this.Forbidden = true;
        }
Exemplo n.º 21
0
        public void Save(Content content)
        {
            if (content.Id == 0)
                _dataContext.Content.Add(content);

            _dataContext.SaveChanges();
        }
Exemplo n.º 22
0
        public override Content CopyDataTo(Content content)
        {
            var copy = (Widget)base.CopyDataTo(content);
            copy.Category = Category;

            return copy;
        }
Exemplo n.º 23
0
 public void Add_AddOneBookWithParamsNull()
 {
     string[] testContentParams = new string[] { null };
     IContent testContent = new Content(ContentType.Book, testContentParams);
     ICatalog currentCatalog = new Catalog();
     currentCatalog.Add(testContent);
 }
Exemplo n.º 24
0
        private static bool IsInvalidVersioningAction(Content context, string actionName)
        {
            if (string.IsNullOrEmpty(actionName) || context == null)
                return false;

            actionName = actionName.ToLower();

            var generic = context.ContentHandler as GenericContent;
            if (generic == null)
                return false;

            switch (actionName)
            {
                case "checkin":
                    return !SavingAction.HasCheckIn(generic);
                case "checkout":
                    return (generic.VersioningMode <= VersioningType.None && !(generic is IFile || generic.NodeType.IsInstaceOfOrDerivedFrom("Page"))) || !SavingAction.HasCheckOut(generic);
                case "undocheckout":
                    return !SavingAction.HasUndoCheckOut(generic);
                case "forceundocheckout":
                    return !SavingAction.HasForceUndoCheckOutRight(generic);
                case "publish":
                    return (generic.VersioningMode <= VersioningType.None || !SavingAction.HasPublish(generic));
                case "approve":
                case "reject":
                    return !generic.Approvable;
                default:
                    return false;
            }
        }
Exemplo n.º 25
0
		public void ContentDeserializationTest_DeserializeFromJson_Success()
		{
			var valuesToFill = new Content(
				// Add field.
				new FieldContent("Report date", new DateTime(2000, 01, 01).ToShortDateString()),
				// Add table.
				new TableContent("Team Members Table")
					.AddRow(
						new FieldContent("Name", "Eric"),
						new FieldContent("Role", "Program Manager"))
					.AddRow(
						new FieldContent("Name", "Bob"),
						new FieldContent("Role", "Developer")),
				// Add nested list.	
				new ListContent("Team Members Nested List")
					.AddItem(new ListItemContent("Role", "Program Manager")
						.AddNestedItem(new FieldContent("Name", "Eric"))
						.AddNestedItem(new FieldContent("Name", "Ann")))
					.AddItem(new ListItemContent("Role", "Developer")
						.AddNestedItem(new FieldContent("Name", "Bob"))
						.AddNestedItem(new FieldContent("Name", "Richard"))),
				// Add image
				new ImageContent("photo", new byte[] { 1, 2, 3 })
				);


			const string serialized = "{\"Tables\":[{\"Name\":\"Team Members Table\",\"Rows\":[{\"Tables\":[],\"Lists\":[],\"Fields\":[{\"Name\":\"Name\",\"Value\":\"Eric\"},{\"Name\":\"Role\",\"Value\":\"Program Manager\"}],\"Images\":[]},{\"Tables\":[],\"Lists\":[],\"Fields\":[{\"Name\":\"Name\",\"Value\":\"Bob\"},{\"Name\":\"Role\",\"Value\":\"Developer\"}],\"Images\":[]}],\"FieldNames\":[\"Name\",\"Role\"]}],\"Lists\":[{\"Name\":\"Team Members Nested List\",\"Items\":[{\"NestedFields\":[{\"NestedFields\":null,\"Tables\":[],\"Lists\":[],\"Fields\":[{\"Name\":\"Name\",\"Value\":\"Eric\"}],\"Images\":[]},{\"NestedFields\":null,\"Tables\":[],\"Lists\":[],\"Fields\":[{\"Name\":\"Name\",\"Value\":\"Ann\"}],\"Images\":[]}],\"Tables\":[],\"Lists\":[],\"Fields\":[{\"Name\":\"Role\",\"Value\":\"Program Manager\"}],\"Images\":[]},{\"NestedFields\":[{\"NestedFields\":null,\"Tables\":[],\"Lists\":[],\"Fields\":[{\"Name\":\"Name\",\"Value\":\"Bob\"}],\"Images\":[]},{\"NestedFields\":null,\"Tables\":[],\"Lists\":[],\"Fields\":[{\"Name\":\"Name\",\"Value\":\"Richard\"}],\"Images\":[]}],\"Tables\":[],\"Lists\":[],\"Fields\":[{\"Name\":\"Role\",\"Value\":\"Developer\"}],\"Images\":[]}],\"FieldNames\":[\"Role\",\"Name\"]}],\"Fields\":[{\"Name\":\"Report date\",\"Value\":\"01.01.2000\"}],\"Images\":[{\"Name\":\"photo\",\"Binary\":\"AQID\"}]}";

			var deserialized = JsonConvert.DeserializeObject<Content>(serialized);

			Assert.IsTrue(valuesToFill.Equals(deserialized));
		}
Exemplo n.º 26
0
 public static HtmlString IsEqual(this Content content, Content comparer, string valueIfTrue, string valueIfFalse)
 {
     if (comparer.Id == content.Id)
         return new HtmlString(valueIfTrue);
     else
         return new HtmlString(valueIfFalse);
 }
Exemplo n.º 27
0
 public  Content Create(Content content, HttpPostedFileBase picture)
 {
     try
     {
         if (picture != null && picture.ContentLength > 0)
         {
             string ext = VirtualPathUtility.GetExtension(picture.FileName);
             MemoryStream ms = new MemoryStream();
             Image bitmap = Image.FromStream(picture.InputStream);
             string filename = content.UniqueKey + ".jpg";
             bitmap.Save(Path.Combine(DBNLConfigurationManager.FileResponsity.PictureFolder, filename), ImageFormat.Jpeg);
             content.Picture = filename;
             bitmap.Dispose();
             ms.Close();
         }
     }
     catch (IOException ex)
     {
     }
     //content.CreatedDate = DateTime.Now;
     content.UpdatedDate = DateTime.Now;
     
     Contents.InsertOnSubmit(content);
     Commit();
     return content;
 }
Exemplo n.º 28
0
 public static HtmlString IsAncestorOrSelf(this Content content, Content child, string valueIfTrue, string valueIfFalse)
 {
     if (child.AllAncestorIdsOrSelf().Contains(content.Id))
         return new HtmlString(valueIfTrue);
     else
         return new HtmlString(valueIfFalse);
 }
Exemplo n.º 29
0
 public static HtmlString IsDescendantOrSelf(this Content content, Content ancestor, string valueIfTrue, string valueIfFalse)
 {
     if (ancestor.AllDescendantIdsOrSelf().Contains(content.Id))
         return new HtmlString(valueIfTrue);
     else
         return new HtmlString(valueIfFalse);
 }
Exemplo n.º 30
0
        public void Add_AddTwoIndenticalBooksAndThreeOtherItems()
        {
            string[] testBookContentParams = new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" };
            IContent testBookContent = new Content(ContentType.Book, testBookContentParams);
            ICatalog currentCatalog = new Catalog();
            currentCatalog.Add(testBookContent);
            currentCatalog.Add(testBookContent);

            string[] testMovieContentParams = new string[] { "The Secret", "Drew Heriot, Sean Byrne & others (2006)", "832763834", "http://t.co/dNV4d" };
            IContent testMovieContent = new Content(ContentType.Book, testMovieContentParams);
            currentCatalog.Add(testMovieContent);

            string[] testApplicationContentParams = new string[] { "Firefox v.11.0", "Mozilla", "16148072", "http://www.mozilla.org" };
            IContent testApplicationContent = new Content(ContentType.Book, testApplicationContentParams);
            currentCatalog.Add(testApplicationContent);

            string[] testSongContentParams = new string[] { "One", "Metallica", "8771120", "http://goo.gl/dIkth7gs" };
            IContent testSongContent = new Content(ContentType.Book, testSongContentParams);
            currentCatalog.Add(testSongContent);

            IEnumerable<IContent> currentContent = currentCatalog.GetListContent("One", 10);
            int numberOfRenurnedResults = currentContent.Count();

            Assert.AreEqual(1, numberOfRenurnedResults);
        }
Exemplo n.º 31
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            plane       = new Pesawat(spriteBatch, Content.Load <Texture2D>("png/player"), new Vector2(225f, 450f), 120, 120, Content.Load <Texture2D>("png/laserGreenShot"));

            // TODO: use this.Content to load your game content here
            keyboardState = Keyboard.GetState();
        }
        public IActionResult Index2(Content content)
        {

            return Content("Reached Action 2");
        }
Exemplo n.º 33
0
 public Application GetApplication(string applicationName, Content context)
 {
     return GetApplication(applicationName, context, null);
 }
Exemplo n.º 34
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PrtgTableRecurseCmdlet{TObject,TParam}"/> class.
 /// </summary>
 /// <param name="content">The type of content this cmdlet will retrieve.</param>
 /// <param name="progressThreshold">The numeric threshold at which this cmdlet should show a progress bar when retrieving results.</param>
 public PrtgTableRecurseCmdlet(Content content, int?progressThreshold) : base(content, progressThreshold)
 {
 }
Exemplo n.º 35
0
 public void OnUnselected()
 {
     Content.OnUnselected();
 }
Exemplo n.º 36
0
 public void OnSelected()
 {
     Content.OnSelected();
 }
Exemplo n.º 37
0
 static public Task <AES256WithoutKey> Encrypt(byte[] keyData, Content content)
 {
     return(Encrypt(keyData, content.Serialize()));
 }
    void HistoryMenu()
    {
        GUIStyle titleStyle = new GUIStyle("Button");

        titleStyle.fontSize = 35;
        float h = (int)(Screen.height / 2 / 6);//100
        float y = (currentMenu == 4) ? (float)0.8 * Screen.height:(float)0.6 * Screen.height;

        h = (currentMenu == 4) ? (float)0.2 * Screen.height / 10 : (float)0.4 * Screen.height / 10;
        GUILayout.BeginArea(new Rect(Screen.width * 0.1f, y, Screen.width * 0.8f, 1000));

        if (currentMenu == poiMenu)
        {
            if (seenPOIs == null || seenPOIs.Count == 0)
            {
                GUILayout.Button("you have not been to any POIs", titleStyle, GUILayout.Height(h));
            }
            foreach (POI poi in seenPOIs) //
            {                             //area.POIs
                if (GUILayout.Button(poi.Name, titleStyle, GUILayout.Height(h)))
                {
                    //Debug.Log("Clicked the " + poi.Name);
                    currentMenu += 1;
                    currentPOI   = poi;
                }
            }
        }

        else if (currentMenu == sceneMenu)
        {
            foreach (ContentContainer cc in currentPOI.ContentContainers)
            {
                if (GUILayout.Button(cc.Name, titleStyle, GUILayout.Height(h)))
                {
                    Debug.Log("Clicked the " + cc.Name); currentMenu += 1;
                    currentContentContainer = cc;
                }
            }
            if (GUILayout.Button("Back", titleStyle, GUILayout.Height(h)))
            {
                currentMenu -= 1;
            }
        }
        else if (currentMenu == contentMenu)
        {
            foreach (Content c in currentContentContainer.Contents)
            {
                if (GUILayout.Button(c.Description, titleStyle, GUILayout.Height(h)))
                {
                    Debug.Log("Clicked the " + c.ToString()); currentMenu += 1;
                    currentContent = c;
                }
            }
            if (GUILayout.Button("Back", titleStyle, GUILayout.Height(h)))
            {
                currentMenu -= 1;
            }
        }
        else if (currentMenu == 4)
        {
            if (GUILayout.Button("Back", titleStyle, GUILayout.Height(h)))
            {
                currentMenu       -= 1;
                currentContent     = null;
                currentContentType = 0;
            }
        }
        GUILayout.EndArea();
    }
Exemplo n.º 39
0
            private static string ParseContentPath(SiteInfo siteInfo, int channelId, IContentInfo contentInfo, string contentFilePathRule)
            {
                var filePath  = contentFilePathRule.Trim();
                var regex     = "(?<element>{@[^}]+})";
                var elements  = RegexUtils.GetContents("element", regex, filePath);
                var addDate   = DateTime.MinValue;
                var contentId = contentInfo.Id;

                foreach (var element in elements)
                {
                    var value = string.Empty;

                    if (StringUtils.EqualsIgnoreCase(element, ChannelId))
                    {
                        value = channelId.ToString();
                    }
                    else if (StringUtils.EqualsIgnoreCase(element, ContentId))
                    {
                        value = contentId.ToString();
                    }
                    else if (StringUtils.EqualsIgnoreCase(element, Sequence))
                    {
                        var tableName = ChannelManager.GetTableName(siteInfo, channelId);
                        value = Content.GetSequence(tableName, channelId, contentId).ToString();
                    }
                    else if (StringUtils.EqualsIgnoreCase(element, ParentRule))//继承父级设置 20151113 sessionliang
                    {
                        var nodeInfo   = ChannelManager.GetChannelInfo(siteInfo.Id, channelId);
                        var parentInfo = ChannelManager.GetChannelInfo(siteInfo.Id, nodeInfo.ParentId);
                        if (parentInfo != null)
                        {
                            var parentRule = GetContentFilePathRule(siteInfo, parentInfo.Id);
                            value = DirectoryUtils.GetDirectoryPath(ParseContentPath(siteInfo, parentInfo.Id, contentInfo, parentRule)).Replace("\\", "/");
                        }
                    }
                    else if (StringUtils.EqualsIgnoreCase(element, ChannelName))
                    {
                        var nodeInfo = ChannelManager.GetChannelInfo(siteInfo.Id, channelId);
                        if (nodeInfo != null)
                        {
                            value = nodeInfo.ChannelName;
                        }
                    }
                    else if (StringUtils.EqualsIgnoreCase(element, LowerChannelName))
                    {
                        var nodeInfo = ChannelManager.GetChannelInfo(siteInfo.Id, channelId);
                        if (nodeInfo != null)
                        {
                            value = nodeInfo.ChannelName.ToLower();
                        }
                    }
                    else if (StringUtils.EqualsIgnoreCase(element, ChannelIndex))
                    {
                        var nodeInfo = ChannelManager.GetChannelInfo(siteInfo.Id, channelId);
                        if (nodeInfo != null)
                        {
                            value = nodeInfo.IndexName;
                        }
                    }
                    else if (StringUtils.EqualsIgnoreCase(element, LowerChannelIndex))
                    {
                        var nodeInfo = ChannelManager.GetChannelInfo(siteInfo.Id, channelId);
                        if (nodeInfo != null)
                        {
                            value = nodeInfo.IndexName.ToLower();
                        }
                    }
                    else if (StringUtils.EqualsIgnoreCase(element, Year) || StringUtils.EqualsIgnoreCase(element, Month) || StringUtils.EqualsIgnoreCase(element, Day) || StringUtils.EqualsIgnoreCase(element, Hour) || StringUtils.EqualsIgnoreCase(element, Minute) || StringUtils.EqualsIgnoreCase(element, Second))
                    {
                        if (addDate == DateTime.MinValue)
                        {
                            var tableName = ChannelManager.GetTableName(siteInfo, channelId);
                            addDate = Content.GetAddDate(tableName, contentId);
                        }

                        if (StringUtils.EqualsIgnoreCase(element, Year))
                        {
                            value = addDate.Year.ToString();
                        }
                        else if (StringUtils.EqualsIgnoreCase(element, Month))
                        {
                            value = addDate.Month.ToString("D2");
                            //value = addDate.ToString("MM");
                        }
                        else if (StringUtils.EqualsIgnoreCase(element, Day))
                        {
                            value = addDate.Day.ToString("D2");
                            //value = addDate.ToString("dd");
                        }
                        else if (StringUtils.EqualsIgnoreCase(element, Hour))
                        {
                            value = addDate.Hour.ToString();
                        }
                        else if (StringUtils.EqualsIgnoreCase(element, Minute))
                        {
                            value = addDate.Minute.ToString();
                        }
                        else if (StringUtils.EqualsIgnoreCase(element, Second))
                        {
                            value = addDate.Second.ToString();
                        }
                    }
                    else
                    {
                        var attributeName = element.Replace("{@", string.Empty).Replace("}", string.Empty);

                        var isLower = false;
                        if (StringUtils.StartsWithIgnoreCase(attributeName, "lower"))
                        {
                            isLower       = true;
                            attributeName = attributeName.Substring(5);
                        }

                        value = contentInfo.GetString(attributeName);
                        if (isLower)
                        {
                            value = value.ToLower();
                        }
                    }

                    value = StringUtils.HtmlDecode(value);

                    filePath = filePath.Replace(element, value);
                }

                if (filePath.Contains("//"))
                {
                    filePath = Regex.Replace(filePath, @"(/)\1{2,}", "/");
                    filePath = filePath.Replace("//", "/");
                }

                if (filePath.Contains("("))
                {
                    regex    = @"(?<element>\([^\)]+\))";
                    elements = RegexUtils.GetContents("element", regex, filePath);
                    foreach (var element in elements)
                    {
                        if (!element.Contains("|"))
                        {
                            continue;
                        }

                        var value  = element.Replace("(", string.Empty).Replace(")", string.Empty);
                        var value1 = value.Split('|')[0];
                        var value2 = value.Split('|')[1];
                        value = value1 + value2;

                        if (!string.IsNullOrEmpty(value1) && !string.IsNullOrEmpty(value1))
                        {
                            value = value1;
                        }

                        filePath = filePath.Replace(element, value);
                    }
                }
                return(filePath);
            }
Exemplo n.º 40
0
        /// <summary>
        /// Asynchronously write the <see cref="MimePart"/> to the specified output stream.
        /// </summary>
        /// <remarks>
        /// Asynchronously writes the MIME part to the output stream.
        /// </remarks>
        /// <returns>An awaitable task.</returns>
        /// <param name="options">The formatting options.</param>
        /// <param name="stream">The output stream.</param>
        /// <param name="contentOnly"><c>true</c> if only the content should be written; otherwise, <c>false</c>.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <exception cref="System.ArgumentNullException">
        /// <para><paramref name="options"/> is <c>null</c>.</para>
        /// <para>-or-</para>
        /// <para><paramref name="stream"/> is <c>null</c>.</para>
        /// </exception>
        /// <exception cref="System.OperationCanceledException">
        /// The operation was canceled via the cancellation token.
        /// </exception>
        /// <exception cref="System.IO.IOException">
        /// An I/O error occurred.
        /// </exception>
        public override async Task WriteToAsync(FormatOptions options, Stream stream, bool contentOnly, CancellationToken cancellationToken = default(CancellationToken))
        {
            await base.WriteToAsync(options, stream, contentOnly, cancellationToken).ConfigureAwait(false);

            if (Content == null)
            {
                return;
            }

            var isText = ContentType.IsMimeType("text", "*") || ContentType.IsMimeType("message", "*");

            if (Content.Encoding != encoding)
            {
                if (encoding == ContentEncoding.UUEncode)
                {
                    var begin  = string.Format("begin 0644 {0}", FileName ?? "unknown");
                    var buffer = Encoding.UTF8.GetBytes(begin);

                    await stream.WriteAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false);

                    await stream.WriteAsync(options.NewLineBytes, 0, options.NewLineBytes.Length, cancellationToken).ConfigureAwait(false);
                }

                // transcode the content into the desired Content-Transfer-Encoding
                using (var filtered = new FilteredStream(stream)) {
                    filtered.Add(EncoderFilter.Create(encoding));

                    if (encoding != ContentEncoding.Binary)
                    {
                        filtered.Add(options.CreateNewLineFilter(EnsureNewLine));
                    }

                    await Content.DecodeToAsync(filtered, cancellationToken).ConfigureAwait(false);

                    await filtered.FlushAsync(cancellationToken).ConfigureAwait(false);
                }

                if (encoding == ContentEncoding.UUEncode)
                {
                    var buffer = Encoding.ASCII.GetBytes("end");

                    await stream.WriteAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false);

                    await stream.WriteAsync(options.NewLineBytes, 0, options.NewLineBytes.Length, cancellationToken).ConfigureAwait(false);
                }
            }
            else if (encoding == ContentEncoding.Binary)
            {
                // Do not alter binary content.
                await Content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false);
            }
            else if (options.VerifyingSignature && Content.NewLineFormat.HasValue && Content.NewLineFormat.Value == NewLineFormat.Mixed)
            {
                // Allow pass-through of the original parsed content without canonicalization when verifying signatures
                // if the content contains a mix of line-endings.
                //
                // See https://github.com/jstedfast/MimeKit/issues/569 for details.
                await Content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false);
            }
            else
            {
                using (var filtered = new FilteredStream(stream)) {
                    // Note: if we are writing the top-level MimePart, make sure it ends with a new-line so that
                    // MimeMessage.WriteTo() *always* ends with a new-line.
                    filtered.Add(options.CreateNewLineFilter(EnsureNewLine));
                    await Content.WriteToAsync(filtered, cancellationToken).ConfigureAwait(false);

                    await filtered.FlushAsync(cancellationToken).ConfigureAwait(false);
                }
            }
        }
Exemplo n.º 41
0
        public DrawableSwell(Swell swell)
            : base(swell)
        {
            FillMode = FillMode.Fit;

            Content.Add(bodyContainer = new Container
            {
                RelativeSizeAxes = Axes.Both,
                Depth            = 1,
                Children         = new Drawable[]
                {
                    expandingRing = new CircularContainer
                    {
                        Name             = "Expanding ring",
                        Anchor           = Anchor.Centre,
                        Origin           = Anchor.Centre,
                        Alpha            = 0,
                        RelativeSizeAxes = Axes.Both,
                        Blending         = BlendingParameters.Additive,
                        Masking          = true,
                        Children         = new[]
                        {
                            new Box
                            {
                                RelativeSizeAxes = Axes.Both,
                                Alpha            = inner_ring_alpha,
                            }
                        }
                    },
                    targetRing = new CircularContainer
                    {
                        Name             = "Target ring (thick border)",
                        Anchor           = Anchor.Centre,
                        Origin           = Anchor.Centre,
                        RelativeSizeAxes = Axes.Both,
                        Masking          = true,
                        BorderThickness  = target_ring_thick_border,
                        Blending         = BlendingParameters.Additive,
                        Children         = new Drawable[]
                        {
                            new Box
                            {
                                RelativeSizeAxes = Axes.Both,
                                Alpha            = 0,
                                AlwaysPresent    = true
                            },
                            new CircularContainer
                            {
                                Name             = "Target ring (thin border)",
                                Anchor           = Anchor.Centre,
                                Origin           = Anchor.Centre,
                                RelativeSizeAxes = Axes.Both,
                                Masking          = true,
                                BorderThickness  = target_ring_thin_border,
                                BorderColour     = Color4.White,
                                Children         = new[]
                                {
                                    new Box
                                    {
                                        RelativeSizeAxes = Axes.Both,
                                        Alpha            = 0,
                                        AlwaysPresent    = true
                                    }
                                }
                            }
                        }
                    }
                }
            });

            AddInternal(ticks = new Container <DrawableSwellTick> {
                RelativeSizeAxes = Axes.Both
            });
        }
Exemplo n.º 42
0
 public MainWindow()
 {
     InitializeComponent();
     Content.Navigate(new PageMenu());
 }
Exemplo n.º 43
0
 /// <summary>
 /// Load your graphics content.
 /// </summary>
 protected override void LoadContent()
 {
     terrain = Content.Load <Model>("terrain");
 }
Exemplo n.º 44
0
        protected override void Init()
        {
            Background     = Content.Load <Texture2D>("textures/home_back");
            banner         = Content.Load <Texture2D>("textures/banner");
            font           = Content.Load <SpriteFont>("fonts/menu_font");
            backItem       = new ImageItem(Background);
            backItem.HGrow = backItem.VGrow = 1;

            MenuItem start     = new MenuItem("Start Game", font);
            MenuItem highscore = new MenuItem("Highscores", font);
            MenuItem settings  = new MenuItem("Settings", font);
            MenuItem quit      = new MenuItem("Quit", font);

            start.FocusGain     += (s, a) => start.TextItem.Color = Color.Yellow;
            settings.FocusGain  += (s, a) => settings.TextItem.Color = Color.Yellow;
            highscore.FocusGain += (s, a) => highscore.TextItem.Color = Color.Yellow;
            quit.FocusGain      += (s, a) => quit.TextItem.Color = Color.Yellow;

            start.FocusLoss     += (s, a) => start.TextItem.Color = Color.White;
            settings.FocusLoss  += (s, a) => settings.TextItem.Color = Color.White;
            highscore.FocusLoss += (s, a) => highscore.TextItem.Color = Color.White;
            quit.FocusLoss      += (s, a) => quit.TextItem.Color = Color.White;

            // ListMenu menu = new ListMenu(start, settings, highscore, quit); // TODO fix ctor
            ListMenu menu = new ListMenu();

            menu.ItemsOrientation = Orientation.Vertical;
            menu.VAlign           = VAlignment.Top;
            menu.AddItem(start);
            menu.AddItem(highscore);
            menu.AddItem(settings);
            menu.AddItem(quit);

            HPane menuPane = new HPane(menu);

            menuPane.HAlign = HAlignment.Center;
            menuPane.VGrow  = 1;

            ImageItem bannerItem = new ImageItem(banner, 400, 200);

            bannerItem.VAlign = VAlignment.Center;
            bannerItem.HGrow  = 1;

            HPane bannerPane = new HPane(bannerItem);

            bannerPane.HGrow = bannerPane.VGrow = 1;

            VPane vPane = new VPane(bannerPane, menuPane);

            vPane.HAlign = HAlignment.Center;
            vPane.HGrow  = 0.8f;
            vPane.VGrow  = 1;

            ViewPane.Clear();
            RootPane       = new StackPane(backItem, vPane);
            RootPane.HGrow = RootPane.VGrow = 1;
            ViewPane.Add(RootPane);

            start.Action += (s, a) => {
                Manager.Add(Game.CreateMapView(this));
                Hide();
            };

            settings.Action += (s, a) => {
                Manager.Add(new SettingsView(this, Game));
                Hide();
            };

            highscore.Action += (s, a) => {
                Manager.Add(new HighscoreView(this, Game));
                Hide();
            };

            quit.Action += (s, a) => Close();
        }
Exemplo n.º 45
0
 public IEnumerable <Cell> GetSelectedCells()
 {
     return(Content.Where(c => c.IsSelected));
 }
Exemplo n.º 46
0
        public Table(string name, int columnCount, int rowCount)
        {
            Name = name;
            Size = new Size(columnCount, rowCount);
            ResetViewOptions();

            Shared.IndexArray(rowCount).ForEach(y =>
                                                Shared.IndexArray(columnCount).ForEach(x => Content.Add(new Cell("Cell x" /*, new Position(x, y), ":)"*/))));

            Shared.IndexArray(columnCount).ForEach(x =>
                                                   Header.Add(new IndexCell(x, Settings.Current.IndexCellLeftArrow, Settings.Current.IndexCellRightArrow)));

            Shared.IndexArray(rowCount).ForEach(y =>
                                                Sider.Add(new IndexCell(y, Settings.Current.IndexCellUpArrow, Settings.Current.IndexCellDownArrow)));

            //HideColumn(3);
        }
Exemplo n.º 47
0
 public Book(string title, string author, string content)
 {
     this.title   = new Title(title);
     this.author  = new Author(author);
     this.content = new Content(content);
 }
Exemplo n.º 48
0
 private void Content_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     EnterAnimation();
     Content.Focus();
 }
Exemplo n.º 49
0
 public Application GetApplication(string applicationName, Content context, string device)
 {
     bool existingApplication;
     return GetApplication(applicationName, context, out existingApplication, device);
 }
Exemplo n.º 50
0
 /// <summary>
 /// UnloadContent will be called once per game and is the place to unload
 /// game-specific content.
 /// </summary>
 protected override void UnloadContent()
 {
     // TODO: Unload any non ContentManager content here
     Content.Unload();
 }
 public override void InsertTo(Content /*!*/ str, int index, int start, int count)
 {
     str.Insert(index, _data, start, count);
 }
Exemplo n.º 52
0
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            ballTexture = Content.Load <Texture2D>("ball");
        }
Exemplo n.º 53
0
 private void contentIn()
 {
     Content.ScaleTo(1, 650, Easing.OutQuint);
     Content.FadeInFromZero(400);
 }
 /// <summary>
 /// Populate values from the base palette.
 /// </summary>
 /// <param name="state">Palette state to use when populating.</param>
 public void PopulateFromBase(PaletteState state)
 {
     Back.PopulateFromBase(state);
     Border.PopulateFromBase(state);
     Content.PopulateFromBase(state);
 }
Exemplo n.º 55
0
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            var debugSheet = Content.Load <SpriteSheet>("DebugSpriteSheet");

            // current frame test
            animatedBall = CreateSpriteEntity(Content.Load <SpriteSheet>("BallSprite1"), "sphere1");
            animatedBall.Transform.Position = new Vector3(75, 75, 0);

            // normal reference one
            var normal = CreateSpriteEntity(debugSheet, "Normal");

            normal.Transform.Position = new Vector3(150, 300, 0);

            // color
            var color = CreateSpriteEntity(debugSheet, "Color");

            color.Transform.Position            = new Vector3(0, 300, 0);
            color.Get <SpriteComponent>().Color = Color.Purple;

            // billboard
            var billboard = CreateSpriteEntity(debugSheet, "Billboard");

            billboard.Transform.Position = new Vector3(150, 150, 0);
            billboard.Get <SpriteComponent>().SpriteType = SpriteType.Billboard;

            // ratio
            var ratio = CreateSpriteEntity(debugSheet, "OtherRatio");

            ratio.Transform.Position = new Vector3(300, 150, 0);

            // Pre-multiplied Alpha
            var pAlpha = CreateSpriteEntity(debugSheet, "PAlpha");

            pAlpha.Transform.Position = new Vector3(400, 150, 0);
            pAlpha.Get <SpriteComponent>().PremultipliedAlpha = true;

            // Not Pre-multiplied alpha
            var npAlpha = CreateSpriteEntity(debugSheet, "NPAlpha");

            npAlpha.Transform.Position = new Vector3(550, 150, 0);
            npAlpha.Get <SpriteComponent>().PremultipliedAlpha = false;

            // depth test
            var onBack = CreateSpriteEntity(debugSheet, "OnBack");

            onBack.Transform.Position = new Vector3(0, 450, 0);
            var onFront = CreateSpriteEntity(debugSheet, "OnFront");

            onFront.Transform.Position = new Vector3(0, 550, 1);
            var noDepth = CreateSpriteEntity(debugSheet, "NoDepth");

            noDepth.Transform.Position = new Vector3(0, 650, 0);
            noDepth.Get <SpriteComponent>().IgnoreDepth = true;

            // create the rotating sprites
            rotatingSprites.Add(CreateSpriteEntity(debugSheet, "Center"));
            rotatingSprites.Add(CreateSpriteEntity(debugSheet, "TopLeft"));
            rotatingSprites.Add(CreateSpriteEntity(debugSheet, "OutOfImage"));

            // Invalid sprites
            CreateSpriteEntity(debugSheet, "NullWidth");
            CreateSpriteEntity(debugSheet, "NegativeHeight");

            // region out of bound
            var regionOutBound = CreateSpriteEntity(debugSheet, "ShiftedRegion");

            regionOutBound.Transform.Position = new Vector3(700, 250, 0);

            for (int i = 0; i < rotatingSprites.Count; i++)
            {
                rotatingSprites[i].Transform.Position = new Vector3(ScreenWidth, ScreenHeight, i) / 2;
            }

            // add all the entities to the scene
            foreach (var entity in entities)
            {
                SceneSystem.SceneInstance.RootScene.Entities.Add(entity);
            }

            CameraComponent.UseCustomProjectionMatrix = true;
            CameraComponent.ProjectionMatrix          = Matrix.OrthoOffCenterRH(0, ScreenWidth, 0, ScreenHeight, -10, 10);
        }
Exemplo n.º 56
0
 private void contentOut()
 {
     Content.ScaleTo(0.7f, 300, Easing.InQuint);
     Content.FadeOut(250);
 }
 // this + content[start, count]
 public override void Append(Content /*!*/ content, int start, int count)
 {
     content.AppendTo(this, start, count);
 }
Exemplo n.º 58
0
 protected override void LoadContent()
 {
     texture = Content.Load <Texture2D>(@"Textures\startMenu");
 }
 public override Content /*!*/ Concat(Content /*!*/ content)
 {
     return(content.ConcatTo(this));
 }
Exemplo n.º 60
0
 public T LoadAsset <T>(string directory)
 {
     return(Content.Load <T>(directory));
 }