コード例 #1
0
ファイル: TableWithData.cs プロジェクト: gitsharper/SharpHtml
		/////////////////////////////////////////////////////////////////////////////

		#region code
		public Tuple<string, string> Build()
		{
			// ******
			var tagList = new TagList { };

			tagList.AddChild( new QuickTag( "h4" )
				.SetValue( About )
			);
			
			// ******
			var table = new Table( caption: "Checking Account", border: 0, id: "", attrAndStyles: "" );
			tagList.AddChild( table );

			// ******
			foreach( var item in AccountSummaryData.Create() ) {
				table.AddBodyRow(
						item.Col1.ToString( "dd MMM yyyy" ),
						item.Col2.ToString(),
						item.Col3.ToString(),
						item.Col4.ToString(),
						item.Col5.ToString(),
						item.Col6.ToString(),
						item.Col7.ToString()
				);
			}

			// ******
			return new Tuple<string, string>( Render( tagList ), nameof( TableWithData ) );
		}
コード例 #2
0
ファイル: Program.cs プロジェクト: gitsharper/SharpHtml
		/////////////////////////////////////////////////////////////////////////////

		static void RunTableExamples1( IEnumerable<string> items )
		{
			// ******
			int index = 0;
			string directory = string.Empty;
			var tagList = new TagList { };

			// ******
			foreach( var example in TableExamples() ) {
				var htmlPath = example.Item1;
				var about = example.Item2;

				if( 0 == index ) {
					directory = Path.GetDirectoryName( htmlPath );
				}

				tagList.AddChild( new A( "file:///" + htmlPath ).SetValue( about ) );
			}

			//var div = new Div().AppendChildren( tagList );

			var list = new Ul().AddListItems( tagList );

			// ******
			//var page = new SimplePage<SimpleHtml> { };
			//page.AddBodyContent( tagList );
			//var html = page.Html.Render();

			var html = new BasicHtml( "Index" );
			html.BodyContainer.AddChild( list );
			var text = html.Render();

			File.WriteAllText( Path.Combine( directory,"index.html" ), text );
		}
コード例 #3
0
ファイル: ListBase.cs プロジェクト: gitsharper/SharpHtml
 /////////////////////////////////////////////////////////////////////////////
 public ListBase AddListItems( TagList tags )
 {
     foreach( var tag in tags ) {
         AddChild( new Li().AddChild( tag ) );
     }
     return this;
 }
コード例 #4
0
ファイル: FileIO.cs プロジェクト: bogdanuifalean/JuniorMind
        public void LoadTasks(TaskList taskList)
        {
            string[] lines = System.IO.File.ReadAllLines(@"List.txt");
            foreach (string line in lines)
            {
                Task task = new Task();
                var items = line.Split(';');
                task.TaskDescription = items[1];
                if (items[0] == "[X]")
                {
                    task.IsDone = true;
                }

                task.IsNewTask = false;
                task.TaskId = items[2];
                task.DueDate = Convert.ToDateTime(items[3]);
                task.DoneDate = Convert.ToDateTime(items[4]);
                int i = items.Length;
                TagList tags = new TagList();
                while (i > 5)
                {
                    Tag tag = new Tag(items[i - 1]);
                    tags.AddTag(ref tag);
                    i--;
                }

                task.TagList = tags;
                taskList.AddTask(ref task);
            }
        }
コード例 #5
0
ファイル: FileIO.cs プロジェクト: bogdanuifalean/JuniorMind
 public void LoadTags(ref TagList tags)
 {
     StreamReader tagFile = new StreamReader(@"Tags.xml");
     XmlSerializer xs = new XmlSerializer(typeof(TagList));
     tags = (TagList)xs.Deserialize(tagFile);
     tagFile.Close();
 }
コード例 #6
0
 public void Execute(ArgumentList arguments, TaskList tasklist, TagList tags, TagFolder folder)
 {
     ILister lister = new Lister();
     if (arguments.GetParameter(arguments.GetLength() - 1) == "--export")
         lister = new HtmlLister();
     lister.ListFiltered(tasklist.FilterTasks(arguments.GetParameter(1)), arguments.GetParameter(1));
 }
コード例 #7
0
ファイル: FileIO.cs プロジェクト: bogdanuifalean/JuniorMind
 public void SaveTags(TagList tags)
 {
     StreamWriter tagFile = new StreamWriter(@"Tags.xml");
     XmlSerializer xs = new XmlSerializer(typeof(TagList));
     xs.Serialize(tagFile, tags);
     tagFile.Close();
 }
コード例 #8
0
ファイル: Rules.cs プロジェクト: mctraveler/MineSharp
        public static void Load(string path)
        {
            var l = new TagList<TagString>();

            if (File.Exists(path))
            {
                var t = File.ReadAllLines(path);
                var p = "";
                foreach (string s in t)
                {
                    //New page
                    if (s == "\t----")
                    {
                        l.Add(new TagString(p));
                        p = "";
                        continue;
                    }
                    if (p == "")
                        p = s;
                    else
                        p = p + "\n" + s;
                }
                l.Add(new TagString(p));
            } else
            {
                l.Add(new TagString("Rules not found"));
            }

            var c = new TagCompound();
            c ["pages"] = l;
            c ["title"] = new TagString("Rules");
            Debug.WriteLine("Rules: " + c);
            Content = c;
        }
コード例 #9
0
		/////////////////////////////////////////////////////////////////////////////


		TagList GetSource( string src, string callerName )
		{
			const string REGION = "#region code";
			const string ENDREGION = "#endregion";

			// ******
			//var searchStr = $"{REGION} {callerName}";
			var indexStart = src.IndexOf( REGION );
			if( indexStart < 0 ) {
				return new TagList( null, new QuickTag( "div" ).SetValue( $"unable to locate method {callerName}" ) );
			}

			var indexEnd = src.IndexOf( ENDREGION, indexStart );
			var length = (indexEnd - indexStart) + ENDREGION.Length;

			var code = src.Substring( indexStart, length ).Replace( "\t", "  ");

			var codeTag = new QuickTag( "code", null, "data-language = csharp" )
						.SetValue( code );

			var preTag = new QuickTag( "pre");
			preTag.AppendChildren( codeTag );

			var tagList = new TagList( null, preTag);

			return tagList;
		}
コード例 #10
0
		string _render( TagList tags, string pathToSource, string saveFileName )
		{
			// ******
			if( null == srcPath || pathToSource != srcPath ) {
				srcPath = pathToSource;
				src = File.ReadAllText( srcPath );
			}
			var srcTags = GetSource( src, saveFileName );

			// ******
			var html = new BasicHtml( "Example" );

			// ******
			//
			// https://craig.is/making/rainbows
			// https://github.com/ccampbell/rainbow
			//
			html.AddStylesheetRef( "../Output/assets/css/code.css" );
			html.AddScriptRef( true, "../Output/assets/rainbow/rainbow.min.js" );
			html.AddScriptRef( true, "../Output/assets/rainbow/language/csharp.js" );

			// ******
			html.BodyContainer.AppendChildren( tags );
			html.BodyContainer.AppendChildren( srcTags );
			var result = html.Render();

			// ******
			var outputFilePath = $"{Path.GetDirectoryName(pathToSource)}\\{saveFileName}.html";
			File.WriteAllText( outputFilePath, result );
			return outputFilePath;
    }
コード例 #11
0
ファイル: TagListTests.cs プロジェクト: dineshkummarc/Log5
        public static void SerializeTest()
        {
            var tagList = new TagList("foo bar qux");
            var json = JsonConvert.SerializeObject(tagList);

            Assert.AreEqual("[\"foo\",\"bar\",\"qux\"]", json);
        }
コード例 #12
0
		/////////////////////////////////////////////////////////////////////////////

		#region code
		public Tuple<string, string> Build()
		{
			// ******
			var tagList = new TagList { };
			tagList.AddChild( new QuickTag( "h4" )
					.SetValue( About ) );

			// ******
			var table = new Table( caption: "Money Flow", border: 0, id: "", attrAndStyles: "background : ivory" );
			tagList.AddChild( table );

			// ******
			foreach( var item in AccountSummaryData.Create() ) {
				table.AddBodyRow(
						Content( item.Col1.ToString( "dd MMM yyyy" ), "width : 100px", "text-align : right" ),
						Content( item.Col2.ToString(), "width : 100px", "text-align : right" ),
						Content( item.Col3.ToString(), "width : 100px", "text-align : right" ),
						Content( item.Col4.ToString(), "width : 100px", "text-align : right" ),
						Content( item.Col5.ToString(), "width : 100px", "text-align : right" ),
						Content( item.Col6.ToString(), "width : 100px", "text-align : right" ),
						Content( item.Col7.ToString(), "width : 100px", "text-align : right", item.Col7 < 0 ? "color : red" : "" )
				);
			}

			// ******
			return new Tuple<string, string>( Render( tagList ), nameof( TableWithFormatting2 ) );
		}
コード例 #13
0
 public PutItemWithTagTask(TagList tags, Zone zone)
 {
     Name = "Put Item with tag: " + tags + " in zone " + zone.ID;
     Tags = tags;
     Zone = zone;
     Priority = PriorityType.Low;
 }
コード例 #14
0
 public TagFolder(string name)
 {
     FolderName = name;
     Subfolders = new List<TagFolder>();
     allTags = new List<Tag>();
     Tags = new TagList();
 }
コード例 #15
0
		/////////////////////////////////////////////////////////////////////////////

		#region code
		//
		// template is in Templates.cs
		//
		public Tuple<string, string> Build()
		{
			// ******
			var tagList = new TagList { };
			tagList.AddChild( new QuickTag( "h4" )
					.SetValue( About ) );

			// ******
			var instance = Templates.MoneyFlowTemplate.CreateTemplateInstance();
			foreach( var item in AccountSummaryData.Create() ) {
				instance.AddBodyRow(
					item.Col1.ToString( "dd MMM yyyy" ),
					item.Col2.ToString( "n" ),
					item.Col3.ToString( "n" ),
					item.Col4.ToString( "n" ),
					item.Col5.ToString( "n" ),
					item.Col6.ToString( "n" ),
					item.Col7.ToString( "n" )
				);
			}

			// ******
			tagList.AddChild( instance.CreateTable() );
			return new Tuple<string, string>( Render( tagList ), nameof( TableWithTemplate1 ) );
		}
コード例 #16
0
        /// <summary>
        /// Opens a tags.dat file from a stream.
        /// </summary>
        /// <param name="stream">The stream to open.</param>
        public TagCache(Stream stream)
        {
            Tags = new TagList(_tags);

            if (stream.Length != 0)
                Load(new BinaryReader(stream));
        }
コード例 #17
0
ファイル: Lister.cs プロジェクト: bogdanuifalean/JuniorMind
 public void ListTags(TagList tagList, TaskList tasklist)
 {
     TaskTagger tagTasks = new TaskTagger(tasklist.GetTasks());
     Console.WriteLine("Tags and the number of tasks they are assigned to:");
     foreach (Tag tg in tagList)
         Console.Write(tg.Name + ":" + tagTasks.CountTag(tg.Name) + " ");
     Console.WriteLine();
 }
コード例 #18
0
 public void Execute(ArgumentList arguments, TaskList tasklist, TagList tags, TagFolder folder)
 {
     FileIO loader = new FileIO();
     if (tasklist.MarkAsDone(arguments.GetParameter(1)))
     loader.SaveTasks(tasklist.GetTasks());
         else
             Console.WriteLine("No task with that id found to mark as done");
 }
コード例 #19
0
 public void Execute(ArgumentList arguments, TaskList tasks, TagList tags, TagFolder folder)
 {
     FileIO loader = new FileIO();
     TaskTagger tagTasks = new TaskTagger(tasks.GetTasks());
     if (tagTasks.Untag(arguments.GetParameter(1), arguments.GetParameter(2)))
         loader.SaveTasks(tagTasks.GetTasks());
     else
         Console.WriteLine("No task with that id found to untag");
 }
コード例 #20
0
ファイル: TagListTests.cs プロジェクト: dineshkummarc/Log5
        public static void DeserializeTest()
        {
            var tagList = new TagList("foo bar qux");
            var json = JsonConvert.SerializeObject(tagList);

            var reconstructed = JsonConvert.DeserializeObject<TagList>(json);

            Assert.AreEqual(tagList, reconstructed);
        }
コード例 #21
0
ファイル: TagListTests.cs プロジェクト: dineshkummarc/Log5
 public static void ClassLikeConstructorTest()
 {
     var tagList = new TagList("foo bar qux");
     Assert.IsTrue(tagList.Contains("foo"));
     Assert.IsTrue(tagList.Contains("bar"));
     Assert.IsTrue(tagList.Contains("qux"));
     Assert.IsFalse(tagList.Contains("baz"));
     Assert.IsFalse(tagList.Contains("fo"));
     Assert.IsFalse(tagList.Contains("whatever"));
 }
コード例 #22
0
		/////////////////////////////////////////////////////////////////////////////

		#region code
		public Tuple<string, string> Build()
		{
			// ******
			var tagList = new TagList { };
			tagList.AddChild( new QuickTag( "h4" )
					.SetValue( About ) );

			// ******
			var table = new Table();
			tagList.AddChild( table );

			table.AddAttributesAndStyles(
				"table-layout: fixed",
				"border-collapse: collapse",
				"border: 1px solid black",
				"margin: 0px",
				"padding : 0",
				"background : ivory"
				);

			table.AddHeaderRow( Content( "", "colspan = 4" ), Content( $"4 month moving average", "colspan = 3" ) )
				.AddHeaderRow( "Ending Date", "In", "Out", "Diff", "Moving Avg In", "Moving Avg Out", "Moving Avg Diff" );

			table.AddStyleBlock( StyleBlockAddAs.Class, "td, th", "border : 1px solid black" );

			table.AddBodyStyles();

			//
			// yet another way to set body styles; a StylesFunc allows the interception of columns as they are
			// added, parameters are the column number being added and the StylesDictionary that represents that
			// column, return an IEnumerable<string> of styles to merge, or manipulate the styles dictionary
			// itself
			//
			// breaking out the StyleFunction on it's own makes this look a lot less messy and more readable than
			// inserting the lambda directly into SetDefaultBodyStyles() - at least for the sake of an example
			//
			StylesFunc sf = ( col, sd ) => col > 3 ? Styles( "font-style : italic " ) : null;
			table.SetDefaultBodyStyles( sf, 7, "width : 100px", "text-align : right" );

			// ******
			foreach( var item in AccountSummaryData.Create() ) {
				table.AddBodyRow(
						item.Col1.ToString( "dd MMM yyyy" ),
						item.Col2.ToString(),
						item.Col3.ToString(),
						item.Col4.ToString(),
						item.Col5.ToString(),
						item.Col6.ToString(),
						Content( item.Col7.ToString(), item.Col7 < 0 ? "color : red" : null )
				);
			}

			// ******
			return new Tuple<string, string>( Render( tagList ), nameof( TableWithFormatting3 ) );
		}
コード例 #23
0
 public void Execute(ArgumentList arguments, TaskList tasklist, TagList tags, TagFolder folder)
 {
     FileIO loader = new FileIO();
     if (tasklist.RemoveTask(arguments.GetParameter(1)))
         {
         loader.SaveTasks(tasklist.GetTasks());
         Console.WriteLine("Task " + arguments.GetParameter(1) + " removed.");
         }
     else
     Console.WriteLine("No task with that id found to remove");
 }
コード例 #24
0
 public void ItShouldNotAddTagsWithSameName()
 {
     Tag tag1 = new Tag("urgent");
     Tag tag2 = new Tag("urgent");
     TagList testTaglist = new TagList();
     testTaglist.AddTag(ref tag1);
     testTaglist.AddTag(ref tag2);
     int expected = 1;
     int actual = testTaglist.GetListSize();
     Assert.AreEqual(expected, actual);
 }
コード例 #25
0
 public void ItShouldGetTagIndex()
 {
     Tag tag1 = new Tag("urgent");
     Tag tag2 = new Tag("important");
     TagList testTaglist = new TagList();
     testTaglist.AddTag(ref tag1);
     testTaglist.AddTag(ref tag2);
     int expected = 1;
     int actual = testTaglist.GetTagIndex("important");
     Assert.AreEqual(expected, actual);
 }
コード例 #26
0
ファイル: NbtMerge.cs プロジェクト: jaquadro/NNBT
 public void ApplyId(TagList tag)
 {
     foreach (var kv in Operations) {
         int index = Id.FindIndexWithId(tag, kv.Key);
         if (index == -1) {
             tag.Add(null);
             index = tag.Count - 1;
         }
         kv.Value.Apply(tag, index);
     }
 }
コード例 #27
0
 public void ItShouldGetTag()
 {
     Tag tag1 = new Tag("urgent");
     Tag tag2 = new Tag("important");
     TagList testTaglist = new TagList();
     testTaglist.AddTag(ref tag1);
     testTaglist.AddTag(ref tag2);
     string expected = "important";
     string actual = testTaglist.GetTag(1).Name;
     Assert.AreEqual(expected, actual);
 }
コード例 #28
0
 public void ItShouldCheckForTags()
 {
     Tag tag1 = new Tag("urgent");
     Tag tag2 = new Tag("important");
     TagList testTaglist = new TagList();
     testTaglist.AddTag(ref tag1);
     testTaglist.AddTag(ref tag2);
     bool expected = true;
     bool actual = testTaglist.HasTag("important");
     Assert.AreEqual(expected, actual);
 }
コード例 #29
0
 public void Execute(ArgumentList arguments, TaskList tasklist, TagList tags, TagFolder folder)
 {
     ILister lister = new Lister();
     if (arguments.GetParameter(arguments.GetLength() - 1) == "--export")
         lister = new HtmlLister();
     if (arguments.GetLength() == 1 || arguments.GetParameter(1) == "--export")
         lister.ListNotDone(tasklist.GetTasks(), string.Empty);
     else if (arguments.GetParameter(1) == "all")
         lister.ListAllTasks(tasklist.GetTasks());
     else if (arguments.GetParameter(1) == "tags")
         lister.ListTags(tags, tasklist);
 }
コード例 #30
0
		/////////////////////////////////////////////////////////////////////////////

		public Tuple<string, string> Build()
		{
			// ******
			var tagList = new TagList { };

			tagList.AddChild( new QuickTag( "h4" )
				.SetValue( About )
			);

			// ******
			var instance = Templates.MoneyFlowTemplate.CreateTemplateInstance();
			foreach( var item in AccountSummaryData.Create() ) {
				instance.AddBodyRow(
					//
					// we can modify cells as they are added
					//
					( row, column, tag ) => ModifyTags( item, row, column, tag ),

					item.Col1.ToString( "dd MMM yyyy" ),
					item.Col2.ToString( "n" ),
					item.Col3.ToString( "n" ),

					//
					// we don't have to monitor each tag as it's created, we can 
					// modify the tag "inline" by passing a CellFunc as a callback,
					// note: we do have to add the data ourself
					//
					(CellFunc) (( row, col, tag ) => {
						tag.SetValue( item.Col4.ToString( "n" ) );
						if( item.Col4 < 0 ) {
							tag.AddStyles( "color : red" );
						}
						return null;
					}),

					item.Col5.ToString( "n" ),
					item.Col6.ToString( "n" ),

					//
					// yet another way to customize the adding of data, if we pass an IEnumerable<string>
					// the first string will be used for the content of the tag and the remaining
					// items are parsed as attributes and styles ("style : value", "attribute = value")
					//
					Content( item.Col7.ToString( "n" ), item.Col7 < 0 ? "color : red" : "" )
				);
			}

			// ******
			tagList.AddChild( instance.CreateTable() );
			return new Tuple<string, string>( Render( tagList ), nameof( TableWithTemplate2 ) );
		}
コード例 #31
0
    public ObjectDesc(ushort type, XElement elem)
    {
        CultureInfo ci = (CultureInfo)CultureInfo.CurrentCulture.Clone();

        ci.NumberFormat.CurrencyDecimalSeparator = ".";
        XElement n;

        ObjectType = type;
        ObjectId   = elem.Attribute("id").Value;
        XElement xElement = elem.Element("Class");

        if (xElement != null)
        {
            Class = xElement.Value;
        }
        Group                   = (n = elem.Element("Group")) != null ? n.Value : null;
        DisplayId               = (n = elem.Element("DisplayId")) != null ? n.Value : null;
        Player                  = elem.Element("Player") != null;
        Enemy                   = elem.Element("Enemy") != null;
        OccupySquare            = elem.Element("OccupySquare") != null;
        FullOccupy              = elem.Element("FullOccupy") != null;
        EnemyOccupySquare       = elem.Element("EnemyOccupySquare") != null;
        Static                  = elem.Element("Static") != null;
        NoMiniMap               = elem.Element("NoMiniMap") != null;
        ProtectFromGroundDamage = elem.Element("ProtectFromGroundDamage") != null;
        ProtectFromSink         = elem.Element("ProtectFromSink") != null;
        Flying                  = elem.Element("Flying") != null;
        ShowName                = elem.Element("ShowName") != null;
        DontFaceAttacks         = elem.Element("DontFaceAttacks") != null;
        BlocksSight             = elem.Element("BlocksSight") != null;

        if ((n = elem.Element("Size")) != null)
        {
            MinSize  = MaxSize = Utils.FromString(n.Value);
            SizeStep = 0;
        }
        else
        {
            MinSize = (n = elem.Element("MinSize")) != null?Utils.FromString(n.Value) : 100;

            MaxSize = (n = elem.Element("MaxSize")) != null?Utils.FromString(n.Value) : 100;

            SizeStep = (n = elem.Element("SizeStep")) != null?Utils.FromString(n.Value) : 0;
        }

        Projectiles = elem.Elements("Projectile").Select(i => new ProjectileDesc(i)).ToArray();

        if ((n = elem.Element("UnlockCost")) != null)
        {
            UnlockCost = int.Parse(n.Value);
        }
        if ((n = elem.Element("MaxHitPoints")) != null)
        {
            MaxHitPoints = n.Attribute("max") != null?Utils.FromString(n.Attribute("max").Value) : -1;

            MaxHP = Utils.FromString(n.Value);
        }
        if ((n = elem.Element("MaxMagicPoints")) != null)
        {
            MaxMagicPoints = n.Attribute("max") != null?Utils.FromString(n.Attribute("max").Value) : -1;
        }

        if ((n = elem.Element("Attack")) != null)
        {
            MaxAttack = n.Attribute("max") != null?Utils.FromString(n.Attribute("max").Value) : -1;
        }
        if ((n = elem.Element("Dexterity")) != null)
        {
            MaxDexterity = n.Attribute("max") != null?Utils.FromString(n.Attribute("max").Value) : -1;
        }
        if ((n = elem.Element("Speed")) != null)
        {
            MaxSpeed = n.Attribute("max") != null?Utils.FromString(n.Attribute("max").Value) : -1;
        }
        if ((n = elem.Element("HpRegen")) != null)
        {
            MaxHpRegen = n.Attribute("max") != null?Utils.FromString(n.Attribute("max").Value) : -1;
        }
        if ((n = elem.Element("MpRegen")) != null)
        {
            MaxMpRegen = n.Attribute("max") != null?Utils.FromString(n.Attribute("max").Value) : -1;
        }

        if ((n = elem.Element("Defense")) != null)
        {
            Defense    = Utils.FromString(n.Value);
            MaxDefense = n.Attribute("max") != null?Utils.FromString(n.Attribute("max").Value) : -1;
        }
        if ((n = elem.Element("Terrain")) != null)
        {
            Terrain = n.Value;
        }
        if ((n = elem.Element("SpawnProbability")) != null)
        {
            SpawnProbability = float.Parse(n.Value, NumberStyles.Any, ci);
        }
        if ((n = elem.Element("Spawn")) != null)
        {
            Spawn = new SpawnCount(n);
        }

        God   = elem.Element("God") != null;
        Cube  = elem.Element("Cube") != null;
        Quest = elem.Element("Quest") != null;
        if ((n = elem.Element("Level")) != null)
        {
            Level = Utils.FromString(n.Value);
        }
        else
        {
            Level = null;
        }

        Tags = new TagList();
        if (elem.Elements("Tag").Any())
        {
            foreach (XElement i in elem.Elements("Tag"))
            {
                Tags.Add(new Tag(i));
            }
        }

        StasisImmune    = elem.Element("StasisImmune") != null;
        StunImmune      = elem.Element("StunImmune") != null;
        ParalyzedImmune = elem.Element("ParalyzeImmune") != null;
        DazedImmune     = elem.Element("DazedImmune") != null;
        Oryx            = elem.Element("Oryx") != null;
        Hero            = elem.Element("Hero") != null;

        if ((n = elem.Element("PerRealmMax")) != null)
        {
            PerRealmMax = Utils.FromString(n.Value);
        }
        else
        {
            PerRealmMax = null;
        }
        if ((n = elem.Element("XpMult")) != null)
        {
            ExpMultiplier = float.Parse(n.Value, NumberStyles.Any, ci);
        }
        else
        {
            ExpMultiplier = null;
        }
    }
コード例 #32
0
        public void BindSongControls()
        {
            PropertiesGroup.Hidden = false;

            BindBox(UniqueIdBox, typeof(SongEntry).GetProperty("UniqueId"));
            BindBox(TitleBox, typeof(SongEntry).GetProperty("Title"));
            BindBox(SubtitleBox, typeof(SongEntry).GetProperty("Subtitle"));

            BindBox(BackgroundBox, typeof(SongEntry).GetProperty("BackgroundImage"));

            BindBox(ComposerBox, typeof(SongEntry).GetProperty("Composer"));
            BindBox(ArrangerBox, typeof(SongEntry).GetProperty("Arranger"));
            BindBox(CopyrightBox, typeof(SongEntry).GetProperty("Copyright"));
            BindBox(LicenseBox, typeof(SongEntry).GetProperty("License"));
            BindBox(MadeFamousByBox, typeof(SongEntry).GetProperty("MadeFamousBy"));

            BindNumericBox(DifficultyBox, typeof(SongEntry).GetProperty("Difficulty"));
            BindNumericBox(RatingBox, typeof(SongEntry).GetProperty("Rating"));

            BindBox(FingerHintBox, typeof(SongEntry).GetProperty("FingerHints"));
            BindBox(HandsBox, typeof(SongEntry).GetProperty("HandParts"));
            BindBox(PartsBox, typeof(SongEntry).GetProperty("Parts"));

            int selectedCount = (int)SongList.SelectedRowCount;
            SortedDictionary <string, int> tagFrequency = new SortedDictionary <string, int>();
            Dictionary <KeyValuePair <int, string>, int> bookmarkFrequency = new Dictionary <KeyValuePair <int, string>, int>();

            RetargetButton.Enabled = selectedCount == 1;

            foreach (SongEntry e in SelectedSongs)
            {
                foreach (string tag in e.Tags)
                {
                    tagFrequency[tag] = tagFrequency.ContainsKey(tag) ? tagFrequency[tag] + 1 : 1;
                }
                foreach (var b in e.Bookmarks)
                {
                    bookmarkFrequency[b] = bookmarkFrequency.ContainsKey(b) ? bookmarkFrequency[b] + 1 : 1;
                }
            }

            Tags.Data.Clear();
            foreach (var tag in tagFrequency)
            {
                if (tag.Value == selectedCount)
                {
                    Tags.Data.Add(tag.Key);
                }
            }
            TagList.ReloadData();

            Bookmarks.Data.Clear();
            foreach (var b in bookmarkFrequency)
            {
                if (b.Value == selectedCount)
                {
                    Bookmarks.Data.Add(new Bookmark(b.Key.Key, b.Key.Value));
                }
            }
            BookmarkList.ReloadData();
        }
コード例 #33
0
        /// <summary>
        /// Extract some metadata from the streams and print it on the screen
        /// </summary>
        static void AnalyzeStreams()
        {
            // Read some properties
            _data.NVideo = (int)_data.Playbin["n-video"];
            _data.NAudio = (int)_data.Playbin["n-audio"];
            _data.NText  = (int)_data.Playbin["n-text"];

            Console.WriteLine($"{_data.NVideo} video streams, {_data.NAudio} audio streams, {_data.NText} text streams");

            string str;

            for (int i = 0; i < _data.NVideo; i++)
            {
                // Retrieve the stream's video tags
                using (TagList tags = (TagList)_data.Playbin.Emit("get-video-tags", i))
                {
                    if (tags == null)
                    {
                        continue;
                    }
                    Console.WriteLine($"video stream {i}:");
                    if (tags.GetString(Gst.Constants.TAG_VIDEO_CODEC, out str))
                    {
                        Console.WriteLine("  codec: {0}", str ?? "unknown");
                    }
                    tags.Dispose();
                }
            }

            for (int i = 0; i < _data.NAudio; i++)
            {
                // Retrieve the stream's audio tags
                using (TagList tags = (TagList)_data.Playbin.Emit("get-audio-tags", i))
                {
                    if (tags == null)
                    {
                        continue;
                    }
                    Console.WriteLine($"audio stream {i}:");
                    if (tags.GetString(Gst.Constants.TAG_AUDIO_CODEC, out str))
                    {
                        Console.WriteLine("  codec: {0}", str ?? "unknown");
                    }
                    if (tags.GetString(Gst.Constants.TAG_LANGUAGE_CODE, out str))
                    {
                        Console.WriteLine($"  language: {str}");
                    }
                    if (tags.GetUint(Gst.Constants.TAG_BITRATE, out uint rate))
                    {
                        Console.WriteLine($"  bitrage: {rate}");
                    }
                }
            }

            for (int i = 0; i < _data.NText; i++)
            {
                //Retrieve the stream's subtitle tags
                using (TagList tags = (TagList)_data.Playbin.Emit("get-text-tags", i))
                {
                    if (tags == null)
                    {
                        continue;
                    }
                    Console.WriteLine($"Subtitle stream {i}:");
                    if (tags.GetString(Gst.Constants.TAG_LANGUAGE_CODE, out str))
                    {
                        Console.WriteLine($"  language: {str}");
                    }
                }
            }

            _data.CurrentVideo = (int)_data.Playbin.GetProperty("current-video");
            _data.CurrentAudio = (int)_data.Playbin.GetProperty("current-audio");
            _data.CurrentText  = (int)_data.Playbin.GetProperty("current-text");

            Console.WriteLine($"Currently playing video stream {_data.CurrentVideo}, audio stream {_data.CurrentAudio} and text stream {_data.CurrentText}");
            Console.WriteLine("Type any number and hit ENTER to select a different audio stream");
        }
コード例 #34
0
 public void AddTag(TagData tagData)
 {
     TagList.Add(tagData);
     RaisePropertyChanged(() => TagList);
 }
コード例 #35
0
ファイル: test.cs プロジェクト: terry2012/juxta
        // Private methods ////////////////////////////////////////////

        protected override TaskStatus ExecuteStep(int s)
        {
            bool cont = true;

            // Main
            switch (currentStep)
            {
            case OpenerTaskStep.Init:
                objectsList = new List <ObjectInfo> ();
                xmlDocument = new XmlDocument();
                xmlDocument.Load(fileName);
                currentStep = OpenerTaskStep.Header;
                break;

            case OpenerTaskStep.Header:
                //ReadHeader ();
                currentStep = OpenerTaskStep.ProjectInfoRead;
                break;

            case OpenerTaskStep.ProjectInfoRead:
                foreach (XmlNode node in xmlDocument.DocumentElement.ChildNodes)
                {
                    if (node.Name == "projectinfo")
                    {
                        ResolveProjectInfoNode(node);
                    }
                }

                // FIXME: Fail if not found/not resolved
                currentStep = OpenerTaskStep.ObjectListRead;
                break;

            case OpenerTaskStep.ObjectListRead:
                foreach (XmlNode node in xmlDocument.DocumentElement.ChildNodes)
                {
                    if (node.Name == "objectlist")
                    {
                        objectListContainer = (ObjectListContainer)
                                              DataFactory.MakeDataElement(node as XmlElement);
                    }
                }

                if (objectListContainer == null)
                {
                    throw new Exception("ObjectListContainer not found!");
                }

                currentStep = OpenerTaskStep.ObjectListParse;
                break;

            case OpenerTaskStep.ObjectListParse:
                bool flush = EnumerateSomeObjects();
                if (flush)
                {
                    currentStep = OpenerTaskStep.ObjectListUnBoil;
                }
                break;

            case OpenerTaskStep.ObjectListUnBoil:
                bool done = UnBoilSomeObjects();
                if (done)
                {
                    currentStep = OpenerTaskStep.FindRoots;
                }
                break;


            case OpenerTaskStep.FindRoots:
                projectTrackList     = (TrackList)FindRoot("tracklist");
                projectTagList       = (TagList)FindRoot("taglist");
                projectStuffList     = (StuffList)FindRoot("stufflist");
                projectClipList      = (ClipList)FindRoot("cliplist");
                projectMediaItemList = (MediaItemList)FindRoot("mediaitemlist");
                projectPipeline      = (Gdv.Pipeline)FindRoot("pipeline");
                projectCommander     = (Commander)FindRoot("commander");
                projectFormat        = (Gdv.ProjectFormat)FindRoot("projectformat");

                currentStep = OpenerTaskStep.Finished;
                break;

            case OpenerTaskStep.Finished:
                cont = false;
                break;

            default:
                break;
            }

            // Post
            if (cont)
            {
                return(TaskStatus.Running);
            }
            else
            {
                return(TaskStatus.Done);
            }
        }
コード例 #36
0
        public override void Process(string fileName, int offset, string xamlElement, string linePadding, ITextSnapshot snapshot, TagList tags, List <TagSuppression> suppressions = null)
        {
            if (this.ProjectType.Matches(ProjectType.Uwp) || this.ProjectType.Matches(ProjectType.Wpf))
            {
                if (this.ProjectType.Matches(ProjectType.Uwp))
                {
                    var(uidExists, uid) = this.GetOrGenerateUid(xamlElement, Attributes.Content);

                    this.CheckForHardCodedAttribute(
                        fileName,
                        Elements.CheckBox,
                        Attributes.Content,
                        AttributeType.Any,
                        StringRes.UI_XamlAnalysisHardcodedStringCheckboxContentMessage,
                        xamlElement,
                        snapshot,
                        offset,
                        uidExists,
                        uid,
                        Guid.Empty,
                        tags,
                        suppressions,
                        this.ProjectType);
                }

                // If using one event, the recommendation is to use both
                var hasCheckedEvent   = this.TryGetAttribute(xamlElement, Attributes.CheckedEvent, AttributeType.Inline, out _, out int checkedIndex, out int checkedLength, out string checkedEventName);
                var hasuncheckedEvent = this.TryGetAttribute(xamlElement, Attributes.UncheckedEvent, AttributeType.Inline, out _, out int uncheckedIndex, out int uncheckedLength, out string uncheckedEventName);

                if (hasCheckedEvent && !hasuncheckedEvent)
                {
                    var checkedTag = new CheckBoxCheckedAndUncheckedEventsTag(new Span(offset + checkedIndex, checkedLength), snapshot, fileName, checkedEventName, hasChecked: true, this.Logger)
                    {
                        InsertPosition = offset,
                    };

                    tags.TryAdd(checkedTag, xamlElement, suppressions);
                }

                if (!hasCheckedEvent && hasuncheckedEvent)
                {
                    var uncheckedTag = new CheckBoxCheckedAndUncheckedEventsTag(new Span(offset + uncheckedIndex, uncheckedLength), snapshot, fileName, uncheckedEventName, hasChecked: false, this.Logger)
                    {
                        InsertPosition = offset,
                    };

                    tags.TryAdd(uncheckedTag, xamlElement, suppressions);
                }
            }
        }
コード例 #37
0
 public void ReadTagList(TagList pTaglist, bool bOptACP)
 {
     throw new NotImplementedException();
 }
コード例 #38
0
ファイル: TagListTests.cs プロジェクト: z77ma/runtime
        public void TestInsert()
        {
            TagList list = new TagList();

            Assert.Equal(0, list.Count);
            list.Insert(0, new KeyValuePair <string, object?>("Key0", 0));
            Assert.Equal(1, list.Count);
            Assert.Equal("Key0", list[0].Key);
            Assert.Equal(0, list[0].Value);

            // Insert at the end
            for (int i = 1; i < 20; i++)
            {
                list.Insert(i, new KeyValuePair <string, object?>("Key" + i, i));
                Assert.Equal(i + 1, list.Count);
                Assert.Equal("Key" + i, list[i].Key);
                Assert.Equal(i, list[i].Value);
            }

            // Insert at beginning
            int count = list.Count;

            for (int i = 1; i < 10; i++)
            {
                list.Insert(0, new KeyValuePair <string, object?>("Key-" + i, i + count));
                Assert.Equal(count + i, list.Count);
                Assert.Equal("Key-" + i, list[0].Key);
                Assert.Equal(i + count, list[0].Value);
            }

            // Insert in the middle
            count = list.Count;
            int pos = count / 2;

            KeyValuePair <string, object?> firstItem = list[0];
            KeyValuePair <string, object?> lastItem  = list[count - 1];

            for (int i = 1; i < 10; i++)
            {
                list.Insert(pos, new KeyValuePair <string, object?>("Key+" + i, i + count));
                Assert.Equal(count + i, list.Count);
                Assert.Equal("Key+" + i, list[pos].Key);
                Assert.Equal(i + count, list[pos].Value);

                Assert.Equal(firstItem.Key, list[0].Key);
                Assert.Equal(firstItem.Value, list[0].Value);
                Assert.Equal(lastItem.Key, list[list.Count - 1].Key);
                Assert.Equal(lastItem.Value, list[list.Count - 1].Value);
            }

            // Test insert when having less than 8 tags
            list = new TagList();
            Assert.Equal(0, list.Count);

            list.Insert(0, new KeyValuePair <string, object?>("Key!0", 0));
            Assert.Equal(1, list.Count);
            Assert.Equal("Key!0", list[0].Key);
            Assert.Equal(0, list[0].Value);

            list.Insert(1, new KeyValuePair <string, object?>("Key!1", 100));
            Assert.Equal(2, list.Count);
            Assert.Equal("Key!1", list[1].Key);
            Assert.Equal(100, list[1].Value);

            list.Insert(0, new KeyValuePair <string, object?>("Key!00", 1000));
            Assert.Equal(3, list.Count);
            Assert.Equal("Key!00", list[0].Key);
            Assert.Equal(1000, list[0].Value);

            list.Insert(3, new KeyValuePair <string, object?>("Key!300", 3000));
            Assert.Equal(4, list.Count);
            Assert.Equal("Key!300", list[3].Key);
            Assert.Equal(3000, list[3].Value);

            for (int i = 1; i < 10; i++)
            {
                list.Insert(2, new KeyValuePair <string, object?>("Key!200" + i, i * 200));
                Assert.Equal(4 + i, list.Count);
                Assert.Equal("Key!200" + i, list[2].Key);
                Assert.Equal(i * 200, list[2].Value);
            }
        }
コード例 #39
0
        public override void Process(string fileName, int offset, string xamlElement, string linePadding, ITextSnapshot snapshot, TagList tags, List <TagSuppression> suppressions = null)
        {
            if (!this.ProjectType.Matches(ProjectType.Uwp))
            {
                return;
            }

            var(uidExists, uid) = this.GetOrGenerateUid(xamlElement, Attributes.Header);

            var elementGuid = Guid.NewGuid();

            this.CheckForHardCodedAttribute(
                fileName,
                Elements.ToggleSwitch,
                Attributes.Header,
                AttributeType.InlineOrElement,
                StringRes.UI_XamlAnalysisHardcodedStringToggleSwitchHeaderMessage,
                xamlElement,
                snapshot,
                offset,
                uidExists,
                uid,
                elementGuid,
                tags,
                suppressions,
                this.ProjectType);

            this.CheckForHardCodedAttribute(
                fileName,
                Elements.ToggleSwitch,
                Attributes.OnContent,
                AttributeType.InlineOrElement,
                StringRes.UI_XamlAnalysisHardcodedStringToggleSwitchOnContentMessage,
                xamlElement,
                snapshot,
                offset,
                uidExists,
                uid,
                elementGuid,
                tags,
                suppressions,
                this.ProjectType);

            this.CheckForHardCodedAttribute(
                fileName,
                Elements.ToggleSwitch,
                Attributes.OffContent,
                AttributeType.InlineOrElement,
                StringRes.UI_XamlAnalysisHardcodedStringToggleSwitchOffContentMessage,
                xamlElement,
                snapshot,
                offset,
                uidExists,
                uid,
                elementGuid,
                tags,
                suppressions,
                this.ProjectType);
        }
コード例 #40
0
        public override void Process(string fileName, int offset, string xamlElement, string linePadding, ITextSnapshot snapshot, TagList tags, List <TagSuppression> suppressions = null, Dictionary <string, string> xlmns = null)
        {
            if (!this.ProjectType.Matches(ProjectType.Uwp))
            {
                return;
            }

            var(uidExists, uid) = this.GetOrGenerateUid(xamlElement, Attributes.Label);

            this.CheckForHardCodedAttribute(
                fileName,
                Elements.AppBarToggleButton,
                Attributes.Label,
                AttributeType.InlineOrElement,
                StringRes.UI_XamlAnalysisHardcodedStringAppBarToggleButtonLabelMessage,
                xamlElement,
                snapshot,
                offset,
                uidExists,
                uid,
                Guid.Empty,
                tags,
                suppressions,
                this.ProjectType);
        }
コード例 #41
0
 public override void Process(string fileName, int offset, string xamlElement, string linePadding, ITextSnapshot snapshot, TagList tags, List <TagSuppression> suppressions = null)
 {
     if (offset == 0)
     {
         this.SubElementFound?.Invoke(this, new SubElementEventArgs {
             SubElement = xamlElement
         });
     }
 }
コード例 #42
0
        protected void CheckForHardCodedAttribute(string fileName, string elementName, string attributeName, AttributeType types, string descriptionFormat, string xamlElement, ITextSnapshot snapshot, int offset, bool uidExists, string uidValue, Guid elementIdentifier, TagList tags, List <TagSuppression> suppressions)
        {
            if (this.TryGetAttribute(xamlElement, attributeName, types, out AttributeType foundAttributeType, out int tbIndex, out int length, out string value))
            {
                if (!string.IsNullOrWhiteSpace(value) && char.IsLetterOrDigit(value[0]))
                {
                    var tag = new HardCodedStringTag(new Span(offset + tbIndex, length), snapshot, fileName, elementName, attributeName, this.Logger)
                    {
                        AttributeType = foundAttributeType,
                        Value         = value,
                        Description   = descriptionFormat.WithParams(value),
                        UidExists     = uidExists,
                        UidValue      = uidValue,
                        ElementGuid   = elementIdentifier,
                    };

                    tags.TryAdd(tag, xamlElement, suppressions);
                }
            }
        }
コード例 #43
0
 /// <summary>
 /// Implementations of this method are used to identify any issues in the specified XAML and create Tags to highlight them.
 /// </summary>
 /// <remarks>
 /// Use of snapshot in the Process implementation should be kept to a minimum as it requires test workarounds
 /// - better to just pass through to where needed in VS initiated functionality.
 /// </remarks>
 /// <param name="fileName">The name of the file being analyzed.</param>
 /// <param name="offset">The number of characters from the start of the file to the element.</param>
 /// <param name="xamlElement">The full string representing the element to process.</param>
 /// <param name="linePadding">The amount of left padding the element has on the line where it starts.</param>
 /// <param name="snapshot">The ITextSnapshot containing the XAML being analyzed.</param>
 /// <param name="tags">Reference to the list of all tags found in the document. Add any new tags here.</param>
 /// <param name="suppressions">A list of user defined suppressions to override default behavior.</param>
 public abstract void Process(string fileName, int offset, string xamlElement, string linePadding, ITextSnapshot snapshot, TagList tags, List <TagSuppression> suppressions = null);
コード例 #44
0
        public override void Process(string fileName, int offset, string xamlElement, string linePadding, ITextSnapshot snapshot, TagList tags, List <TagSuppression> suppressions = null)
        {
            if (!this.ProjectType.Matches(ProjectType.Uwp))
            {
                return;
            }

            var(uidExists, uid) = this.GetOrGenerateUid(xamlElement, Attributes.Header);

            this.CheckForHardCodedAttribute(
                fileName,
                Elements.ComboBox,
                Attributes.Header,
                AttributeType.InlineOrElement,
                StringRes.UI_XamlAnalysisHardcodedStringComboboxHeaderMessage,
                xamlElement,
                snapshot,
                offset,
                uidExists,
                uid,
                Guid.Empty,
                tags,
                suppressions);
        }
コード例 #45
0
        public override void Process(string fileName, int offset, string xamlElement, string linePadding, ITextSnapshot snapshot, TagList tags, List <TagSuppression> suppressions = null)
        {
            this.ProcessCalled       = true;
            this.ProcessCalledCount += 1;

            this.Offset = offset;
            this.AllOffsets.Add(this.ProcessCalledCount, offset);

            this.XamlElement = xamlElement;
            this.AllXamlElements.Add(this.ProcessCalledCount, xamlElement);
        }
コード例 #46
0
        // GET: GameLists/Create
        public ActionResult Create()
        {
            string          currentUserID = User.Identity.GetUserId();
            ApplicationUser currentUser   = Database.Users.Find(currentUserID);
            string          providerKey   = currentUser.Logins.First().ProviderKey;

            providerKey = providerKey.Substring(providerKey.Length - 17);

            SteamWebAPI.SetGlobalKey(Security.apiKey);

            var identity = SteamIdentity.FromSteamID(Int64.Parse(providerKey));

            //JSON response from Steam
            var response = SteamWebAPI.General().IPlayerService().GetOwnedGames(identity).IncludeAppInfo().GetResponse();

            //Iterate through each item and add it to database
            foreach (var res in response.Data.Games)
            {
                TimeSpan timeSpan = res.PlayTimeTotal;

                int totalHours = (int)timeSpan.TotalHours;

                TagList tagList = new TagList()
                {
                    appID  = res.AppID,
                    userID = currentUserID
                };

                GameDescrip gameDesc = new GameDescrip()
                {
                    appID            = res.AppID,
                    playtime_forever = totalHours,
                    userId           = currentUserID,
                    visible          = true, //True by default for now.
                    Tags             = tagList
                };

                Game game = new Game();

                if (res.Name != null)
                {
                    game.name = res.Name;
                }
                else
                {
                    game.name = res.AppID.ToString();
                }
                game.appID          = res.AppID;
                game.img_header_url = "http://cdn.akamai.steamstatic.com/steam/apps/" + res.AppID + "/header.jpg";
                game.img_icon_url   = "http://media.steampowered.com/steamcommunity/public/images/apps/" + res.AppID + "/" + res.IconUrl + ".jpg";
                game.img_logo_url   = "http://media.steampowered.com/steamcommunity/public/images/apps/" + res.AppID + "/" + res.LogoUrl + ".jpg";

                //Ensure User entry for game doesn't exist in table
                bool doesLibraryExist = (Database.GDescriptions.Any(u => u.userId.Equals(gameDesc.userId)) &&
                                         Database.GDescriptions.Any(a => a.appID.Equals(game.appID))); //AppID
                //Ensure Game doesn't already exist in game table
                bool doesGameExist = Database.Games.Any(a => a.appID.Equals(game.appID));

                if (doesLibraryExist)
                {
                    // Do nothing
                }
                else
                {
                    if (doesGameExist)
                    {
                        //Add existing game object
                        gameDesc.Game = Database.Games.Where(a => a.appID == game.appID).SingleOrDefault();
                    }
                    else
                    {
                        //add newly created game object
                        gameDesc.Game = game;
                        Database.Games.Add(game);
                    }
                    //Add User Record for game
                    Database.GDescriptions.Add(gameDesc);
                }
            }
            currentUser.GameCount = response.Data.GameCount;
            Database.SaveChanges();

            return(RedirectToAction("Index"));
        }
コード例 #47
0
 public void ReadTagList(TagList pTaglist)
 {
     throw new NotImplementedException();
 }
コード例 #48
0
        public static ValueDefinition Draw(Rect position, GUIContent label, ValueDefinition definition, VariableInitializerType initializer, TagList tags, bool showConstraintLabel, ref bool isExpanded)
        {
            var tag        = definition.Tag;
            var constraint = definition.Constraint;

            var hasInitializer = HasInitializer(definition.Type, initializer);
            var hasConstraint  = HasConstraint(definition.Type, definition.Constraint, definition.IsConstraintLocked);
            var hasTag         = HasTags(tags);

            var typeRect = RectHelper.TakeLine(ref position);

            if (label != GUIContent.none)
            {
                var labelRect = RectHelper.TakeWidth(ref typeRect, RectHelper.CurrentLabelWidth);
                EditorGUI.LabelField(labelRect, label);
            }

            var type = DrawType(typeRect, definition.IsTypeLocked, definition.Type);

            if (hasConstraint)
            {
                var constraintHeight = GetConstraintHeight(definition.Type, definition.Constraint);
                var constraintRect   = RectHelper.TakeHeight(ref position, constraintHeight);

                DrawConstraint(constraintRect, type, definition.IsConstraintLocked, ref constraint, showConstraintLabel);
            }

            if (hasInitializer && definition.Initializer != null)
            {
                if (initializer == VariableInitializerType.Expression)
                {
                    var initializerHeight = ExpressionControl.GetFoldoutHeight(definition.Initializer, isExpanded, true, 2, 3);
                    var initializerRect   = RectHelper.TakeHeight(ref position, initializerHeight);
                    RectHelper.TakeVerticalSpace(ref position);
                    DrawInitializer(initializerRect, ref definition, ref isExpanded);
                }
                else if (initializer == VariableInitializerType.DefaultValue)
                {
                    var initializerRect = RectHelper.TakeLine(ref position);
                    DrawDefaultValue(initializerRect, ref definition);
                }
            }

            if (hasTag)
            {
                var tagRect = RectHelper.TakeLine(ref position);
                tag = DrawTag(tagRect, tag, tags);
            }

            return(ValueDefinition.Create(type, constraint, tag, definition.Initializer, definition.IsTypeLocked, definition.IsConstraintLocked));
        }
コード例 #49
0
ファイル: EntityEditForm.cs プロジェクト: renyh/dp2
        int SaveNewChip(out string strError)
        {
            strError = "";

#if OLD_CODE
            RfidChannel channel = StartRfidChannel(
                Program.MainForm.RfidCenterUrl,
                out strError);
            if (channel == null)
            {
                strError = "StartRfidChannel() error";
                return(-1);
            }
#endif


            try
            {
#if NO
                TagInfo new_tag_info = _tagExisting.TagInfo.Clone();
                new_tag_info.Bytes = this.chipEditor_editing.LogicChipItem.GetBytes(
                    (int)(new_tag_info.MaxBlockCount * new_tag_info.BlockSize),
                    (int)new_tag_info.BlockSize,
                    LogicChip.GetBytesStyle.None,
                    out string block_map);
                new_tag_info.LockStatus = block_map;
#endif
                Debug.Assert(_tagExisting != null, "");
                Debug.WriteLine("333 " + (_tagExisting.TagInfo != null ? "!=null" : "==null"));

                Debug.Assert(_tagExisting.TagInfo != null, "");

                TagInfo new_tag_info = LogicChipItem.ToTagInfo(
                    _tagExisting.TagInfo,
                    this.chipEditor_editing.LogicChipItem);
#if OLD_CODE
                NormalResult result = channel.Object.WriteTagInfo(
                    _tagExisting.ReaderName,
                    _tagExisting.TagInfo,
                    new_tag_info);
#else
                Debug.Assert(_tagExisting != null, "");

                Debug.WriteLine("111 " + (_tagExisting.TagInfo != null ? "!=null" : "==null"));

                Debug.Assert(_tagExisting.TagInfo != null, "");

                NormalResult result = RfidManager.WriteTagInfo(
                    _tagExisting.ReaderName,
                    _tagExisting.TagInfo,
                    new_tag_info);
                TagList.ClearTagTable(_tagExisting.UID);
#endif
                if (result.Value == -1)
                {
                    strError = result.ErrorInfo;
                    return(-1);
                }

                return(0);
            }
            catch (Exception ex)
            {
                strError = "SaveNewChip() 出现异常: " + ex.Message;
                return(-1);
            }
            finally
            {
#if OLD_CODE
                EndRfidChannel(channel);
#endif
            }
        }
コード例 #50
0
        public static TagList ParseList(JsonReader reader, string rootName)
        {
            TagList list         = new TagList(rootName);
            bool    foundGeneric = false;

            while (reader.Read())
            {
                if (reader.TokenType == JsonToken.Boolean)
                {
                    if (!foundGeneric)
                    {
                        foundGeneric     = true;
                        list.GenericType = ETagType.Byte;
                    }

                    bool    b   = (bool)reader.Value;
                    TagByte tag = new TagByte(null, b);
                    list.Add(tag);
                }
                else if (reader.TokenType == JsonToken.Integer)
                {
                    if (!foundGeneric)
                    {
                        foundGeneric     = true;
                        list.GenericType = ETagType.Long;
                    }

                    long    l   = (long)reader.Value;
                    TagLong tag = new TagLong(null, l);
                    list.Add(tag);
                }
                else if (reader.TokenType == JsonToken.Float)
                {
                    if (!foundGeneric)
                    {
                        foundGeneric     = true;
                        list.GenericType = ETagType.Float;
                    }
                    else if (list.GenericType == ETagType.Long)
                    {
                        List <TagDouble> buf = new List <TagDouble>();
                        foreach (TagLong tl in list)
                        {
                            buf.Add(new TagDouble(tl.Name, tl.Value));
                        }
                        list.Clear();
                        list.GenericType = ETagType.Double;
                        foreach (TagDouble td in buf)
                        {
                            list.Add(td);
                        }
                    }

                    double    d   = (double)reader.Value;
                    TagDouble tag = new TagDouble(null, d);
                    list.Add(tag);
                }
                else if (reader.TokenType == JsonToken.String)
                {
                    if (!foundGeneric)
                    {
                        foundGeneric     = true;
                        list.GenericType = ETagType.String;
                    }

                    string    s   = reader.Value as string;
                    TagString tag = new TagString(null, s);
                    list.Add(tag);
                }
                else if (reader.TokenType == JsonToken.StartObject)
                {
                    if (!foundGeneric)
                    {
                        foundGeneric     = true;
                        list.GenericType = ETagType.Compound;
                    }

                    TagCompound tag = ParseCompound(reader, null);
                    list.Add(tag);
                }
                else if (reader.TokenType == JsonToken.StartArray)
                {
                    if (!foundGeneric)
                    {
                        foundGeneric     = true;
                        list.GenericType = ETagType.List;
                    }

                    TagList inner = ParseList(reader, null);
                    list.Add(inner);
                }
                else if (reader.TokenType == JsonToken.EndArray)
                {
                    return(list);
                }
                else
                {
                    throw new NotImplementedException("Currently no handling for this type of JSON token: " + reader.TokenType.ToString());
                }
            }

            return(list);
        }
コード例 #51
0
ファイル: Descriptors.cs プロジェクト: ppmaks/LOE-V6-GAME
    public ObjectDesc(ushort type, XElement elem)
    {
        CultureInfo ci = (CultureInfo)CultureInfo.CurrentCulture.Clone();

        ci.NumberFormat.CurrencyDecimalSeparator = ".";
        XElement n;

        ObjectType = type;
        ObjectId   = elem.Attribute("id").Value;
        XElement xElement = elem.Element("Class");

        if (xElement != null)
        {
            Class = xElement.Value;
        }
        Group                   = (n = elem.Element("Group")) != null ? n.Value : null;
        DisplayId               = (n = elem.Element("DisplayId")) == null ? ObjectId : n.Value;
        Player                  = elem.Element("Player") != null;
        Enemy                   = elem.Element("Enemy") != null;
        OccupySquare            = elem.Element("OccupySquare") != null;
        FullOccupy              = elem.Element("FullOccupy") != null;
        EnemyOccupySquare       = elem.Element("EnemyOccupySquare") != null;
        Static                  = elem.Element("Static") != null;
        NoMiniMap               = elem.Element("NoMiniMap") != null;
        ProtectFromGroundDamage = elem.Element("ProtectFromGroundDamage") != null;
        ProtectFromSink         = elem.Element("ProtectFromSink") != null;
        Flying                  = elem.Element("Flying") != null;
        ShowName                = elem.Element("ShowName") != null;
        DontFaceAttacks         = elem.Element("DontFaceAttacks") != null;
        BlocksSight             = elem.Element("BlocksSight") != null;
        Skin         = elem.Element("Skin") != null;
        NoSkinSelect = elem.Element("NoSkinSelect") != null;

        if ((n = elem.Element("Size")) != null)
        {
            MinSize  = MaxSize = Utils.FromString(n.Value);
            SizeStep = 0;
        }
        else
        {
            MinSize = (n = elem.Element("MinSize")) != null?Utils.FromString(n.Value) : 100;

            MaxSize = (n = elem.Element("MaxSize")) != null?Utils.FromString(n.Value) : 100;

            SizeStep = (n = elem.Element("SizeStep")) != null?Utils.FromString(n.Value) : 0;
        }

        #region "XML Behaviors"
        if (elem.Elements("BehaviorType") != null)
        {
            BehaviorType = elem.Elements("BehaviorType").Select(i => new XMLBehaviorType(i)).ToArray();
        }
        if (elem.Elements("TransitionType") != null)
        {
            TransitionType = elem.Elements("TransitionType").Select(i => new XMLTransitionType(i)).ToArray();
        }
        if (elem.Elements("LootType") != null)
        {
            LootType = elem.Elements("LootType").Select(i => new XMLLootType(i)).ToArray();
        }

        //To select properly BehaviorType as reference is extremelly recommended to use 'i.BehaviorsType.ToString() == "NAME_OF_BEHAVIORTYPE"' after all!
        //foreach(var i in BehaviorType)
        //{
        //    if (i.BehaviorsType.ToString() == "Wander")
        //        Database.log.InfoFormat("XMLBehavior Type: {0} / Enemy: {1} / Value: {2}", i.BehaviorsType.ToString(), ObjectId, i.Wander_speed);
        //}
        #endregion "XML Behaviors"

        Projectiles = elem.Elements("Projectile").Select(i => new ProjectileDesc(i)).ToArray();

        if ((n = elem.Element("UnlockCost")) != null)
        {
            UnlockCost = int.Parse(n.Value);
        }
        if ((n = elem.Element("MaxHitPoints")) != null)
        {
            MaxHitPoints = n.Attribute("max") != null?Utils.FromString(n.Attribute("max").Value) : -1;

            MaxHP = Utils.FromString(n.Value);
        }
        if ((n = elem.Element("MaxMagicPoints")) != null)
        {
            MaxMagicPoints = n.Attribute("max") != null?Utils.FromString(n.Attribute("max").Value) : -1;
        }

        if ((n = elem.Element("Attack")) != null)
        {
            MaxAttack = n.Attribute("max") != null?Utils.FromString(n.Attribute("max").Value) : -1;
        }
        if ((n = elem.Element("Dexterity")) != null)
        {
            MaxDexterity = n.Attribute("max") != null?Utils.FromString(n.Attribute("max").Value) : -1;
        }
        if ((n = elem.Element("Speed")) != null)
        {
            MaxSpeed = n.Attribute("max") != null?Utils.FromString(n.Attribute("max").Value) : -1;
        }
        if ((n = elem.Element("HpRegen")) != null)
        {
            MaxHpRegen = n.Attribute("max") != null?Utils.FromString(n.Attribute("max").Value) : -1;
        }
        if ((n = elem.Element("MpRegen")) != null)
        {
            MaxMpRegen = n.Attribute("max") != null?Utils.FromString(n.Attribute("max").Value) : -1;
        }

        if ((n = elem.Element("Defense")) != null)
        {
            Defense    = Utils.FromString(n.Value);
            MaxDefense = n.Attribute("max") != null?Utils.FromString(n.Attribute("max").Value) : -1;
        }
        if ((n = elem.Element("Terrain")) != null)
        {
            Terrain = n.Value;
        }
        if ((n = elem.Element("SpawnProbability")) != null)
        {
            SpawnProbability = float.Parse(n.Value, NumberStyles.Any, ci);
        }
        if ((n = elem.Element("Spawn")) != null)
        {
            Spawn = new SpawnCount(n);
        }

        God   = elem.Element("God") != null;
        Cube  = elem.Element("Cube") != null;
        Quest = elem.Element("Quest") != null;
        if ((n = elem.Element("Level")) != null)
        {
            Level = Utils.FromString(n.Value);
        }
        else
        {
            Level = null;
        }

        Tags = new TagList();
        if (elem.Elements("Tag").Any())
        {
            foreach (XElement i in elem.Elements("Tag"))
            {
                Tags.Add(new Tag(i));
            }
        }

        StasisImmune    = elem.Element("StasisImmune") != null;
        StunImmune      = elem.Element("StunImmune") != null;
        ParalyzedImmune = elem.Element("ParalyzeImmune") != null;
        DazedImmune     = elem.Element("DazedImmune") != null;
        Oryx            = elem.Element("Oryx") != null;
        Hero            = elem.Element("Hero") != null;

        if ((n = elem.Element("PerRealmMax")) != null)
        {
            PerRealmMax = Utils.FromString(n.Value);
        }
        else
        {
            PerRealmMax = null;
        }
        if ((n = elem.Element("XpMult")) != null)
        {
            ExpMultiplier = float.Parse(n.Value, NumberStyles.Any, ci);
        }
        else
        {
            ExpMultiplier = null;
        }
        Connects = elem.Element("Connects") != null;
    }
コード例 #52
0
 public void WriteTagList(TagList tagList)
 {
     throw new NotImplementedException();
 }
コード例 #53
0
 /// <summary>
 /// Returns the tag index from the tag list at given index
 /// </summary>
 /// <param name="tagList">List of tag indices</param>
 /// <param name="index">Index of tag index in the list</param>
 /// <returns></returns>
 public TagIndex GetTagIndex(ref TagList tagList, int index)
 {
     return(tagIndices[tagList.tagIndicesIndex + index]);
 }
コード例 #54
0
        public bool SetTags(CheckUpdateDto data, bool overwriteExistingTags)
        {
            bool setTags = false;

            using (Stream stream = new FileStream(data.FileUrl, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
            {
                using (PresentationDocument openXmlDoc = PresentationDocument.Open(stream, true))
                {
                    var presentationPart           = openXmlDoc.PresentationPart;
                    SlideTagExCollection slideTags = GetSlideTags(presentationPart);
                    var libraryFileSlides          = _fileService.GetFileSlidesInfo(data);

                    if (overwriteExistingTags || !slideTags.Any())
                    {
                        var fileInfo = _fileService.GetFileInfo(data);

                        FileTag fileTag = new FileTag();
                        fileTag.Library.Environment = data.ServerInfo.EnvironmentName;
                        fileTag.Library.ShortName   = data.ServerInfo.ShortLibraryName;
                        fileTag.File.Id             = int.Parse(data.FileId);
                        fileTag.File.ContentType    = ContentType.File;
                        fileTag.File.LastModDate    = fileInfo.LastModDate.Value.ToLocalTime();

                        TagList tagList = new TagList();
                        tagList.Append(new Tag()
                        {
                            Name = PL_TAG,
                            Val  = XmlUtils.Serialize(fileTag)
                        });

                        if (presentationPart.UserDefinedTagsPart == null)
                        {
                            presentationPart.AddNewPart <UserDefinedTagsPart>();
                            presentationPart.UserDefinedTagsPart.TagList = tagList;
                        }

                        foreach (var slidePart in presentationPart.SlideParts)
                        {
                            var slideId = presentationPart.Presentation.SlideIdList.Where(s => ((SlideId)s).RelationshipId == presentationPart.GetIdOfPart(slidePart)).Select(s => (SlideId)s).FirstOrDefault();

                            var slideInfo = libraryFileSlides.Slides.Where(x => x.SlidePptId == slideId.Id).FirstOrDefault();

                            SlideTag slideTag = new SlideTag(fileTag);
                            slideTag.Slide.Id          = slideInfo.SlideId;
                            slideTag.Slide.LastModDate = ((DateTime)slideInfo.LastModDate).ToLocalTime();

                            Tag slideObjectTag = new Tag()
                            {
                                Name = PL_TAG, Val = XmlUtils.Serialize(slideTag)
                            };
                            UserDefinedTagsPart userDefinedTagsPart1 = slidePart.AddNewPart <UserDefinedTagsPart>();
                            if (userDefinedTagsPart1.TagList == null)
                            {
                                userDefinedTagsPart1.TagList = new TagList();
                            }

                            userDefinedTagsPart1.TagList.Append(slideObjectTag);

                            var id = slidePart.GetIdOfPart(userDefinedTagsPart1);

                            if (slidePart.Slide.CommonSlideData == null)
                            {
                                slidePart.Slide.CommonSlideData = new CommonSlideData();
                            }
                            if (slidePart.Slide.CommonSlideData.CustomerDataList == null)
                            {
                                slidePart.Slide.CommonSlideData.CustomerDataList = new CustomerDataList();
                            }
                            CustomerDataTags tags = new CustomerDataTags
                            {
                                Id = id
                            };
                            slidePart.Slide.CommonSlideData.CustomerDataList.AppendChild(tags);

                            slidePart.Slide.Save();
                        }
                    }
                    else if (presentationPart.UserDefinedTagsPart == null)
                    {
                        FileTag fileTag = new FileTag();
                        fileTag.Library.Environment = data.ServerInfo.EnvironmentName;
                        fileTag.Library.ShortName   = data.ServerInfo.ShortLibraryName;
                        fileTag.File.Id             = -1;
                        fileTag.File.ContentType    = ContentType.Undefined;
                        fileTag.File.LastModDate    = DateTime.Now;

                        TagList tagList = new TagList();
                        tagList.Append(new Tag()
                        {
                            Name = PL_TAG,
                            Val  = XmlUtils.Serialize(fileTag)
                        });

                        if (presentationPart.UserDefinedTagsPart == null)
                        {
                            presentationPart.AddNewPart <UserDefinedTagsPart>();
                            presentationPart.UserDefinedTagsPart.TagList = tagList;
                        }

                        foreach (var slidePart in presentationPart.SlideParts)
                        {
                            var slideId = presentationPart.Presentation.SlideIdList.Where(s => ((SlideId)s).RelationshipId == presentationPart.GetIdOfPart(slidePart)).Select(s => (SlideId)s).FirstOrDefault();

                            var slideInfo = libraryFileSlides.Slides.Where(x => x.SlidePptId == slideId.Id).FirstOrDefault();

                            var index = libraryFileSlides.Slides.IndexOf(slideInfo);

                            SlideTag slideTag = new SlideTag(data.ServerInfo.EnvironmentName, data.ServerInfo.ShortLibraryName, libraryFileSlides.Slides[index], -1);

                            Tag slideObjectTag = new Tag()
                            {
                                Name = PL_TAG, Val = XmlUtils.Serialize(slideTag)
                            };

                            if (slidePart.UserDefinedTagsParts.Count() > 0)
                            {
                                var customerDataPart = slidePart.UserDefinedTagsParts.FirstOrDefault().TagList;

                                customerDataPart.ReplaceChild(slideObjectTag, customerDataPart.FirstChild);

                                slidePart.Slide.Save();
                            }
                        }
                    }

                    setTags = true;
                }
            }

            return(setTags);
        }
コード例 #55
0
ファイル: BpmDetector.cs プロジェクト: thoja21/banshee-1
        private bool OnBusMessage(Bus bus, Message msg)
        {
            switch (msg.Type)
            {
            case MessageType.Tag:
                TagList tag_list = msg.ParseTag();

                foreach (var name in tag_list.Tags)
                {
                    if (name == "beats-per-minute")
                    {
                        if (tag_list.GetTagSize(name) < 1)
                        {
                            continue;
                        }
                        tag_list.Foreach(delegate(TagList list, string tagname) {
                            for (uint i = 0; i < tag_list.GetTagSize(tagname); i++)
                            {
                                GLib.Value val = tag_list.GetValueIndex(tagname, i);
                                if (val.Val is double)
                                {
                                    double bpm  = (double)val;
                                    int rounded = (int)Math.Round(bpm);
                                    if (!bpm_histogram.ContainsKey(rounded))
                                    {
                                        bpm_histogram [rounded] = 1;
                                    }
                                    else
                                    {
                                        bpm_histogram [rounded]++;
                                    }
                                }
                                val.Dispose();
                            }
                        });
                    }
                }
                break;

            case MessageType.Error:
                string          debug;
                GLib.GException error;
                msg.ParseError(out error, out debug);

                IsDetecting = false;
                Log.ErrorFormat("BPM Detection error: {0}", error.Message);
                break;

            case MessageType.Eos:
                IsDetecting = false;
                pipeline.SetState(State.Null);

                SafeUri uri = current_uri;
                int     best_bpm = -1, best_bpm_count = 0;
                foreach (int bpm in bpm_histogram.Keys)
                {
                    int count = bpm_histogram[bpm];
                    if (count > best_bpm_count)
                    {
                        best_bpm_count = count;
                        best_bpm       = bpm;
                    }
                }

                Reset();

                var handler = FileFinished;
                if (handler != null)
                {
                    handler(this, new BpmEventArgs(uri, best_bpm));
                }

                break;
            }

            return(true);
        }
コード例 #56
0
        public override void Process(string fileName, int offset, string xamlElement, string linePadding, ITextSnapshot snapshot, TagList tags, List <TagSuppression> suppressions = null, Dictionary <string, string> xlmns = null)
        {
            if (!this.ProjectType.Matches(ProjectType.Uwp))
            {
                return;
            }

            var(uidExists, uid) = this.GetOrGenerateUid(xamlElement, Attributes.Header);

            var elementGuid = Guid.NewGuid();

            this.CheckForHardCodedAttribute(
                fileName,
                Elements.CalendarDatePicker,
                Attributes.Header,
                AttributeType.InlineOrElement,
                StringRes.UI_XamlAnalysisHardcodedStringCalendarDatePickerHeaderMessage,
                xamlElement,
                snapshot,
                offset,
                uidExists,
                uid,
                elementGuid,
                tags,
                suppressions,
                this.ProjectType);

            this.CheckForHardCodedAttribute(
                fileName,
                Elements.CalendarDatePicker,
                Attributes.Description,
                AttributeType.InlineOrElement,
                StringRes.UI_XamlAnalysisHardcodedStringCalendarDatePickerDescriptionMessage,
                xamlElement,
                snapshot,
                offset,
                uidExists,
                uid,
                elementGuid,
                tags,
                suppressions,
                this.ProjectType);
        }
コード例 #57
0
    public static void Main(string [] args)
    {
        Application.Init();

        if (args.Length < 1)
        {
            Console.WriteLine("Please give filenames to read metadata from\n\n");
            return;
        }

        MakePipeline();

        int i = -1;

        while (++i < args.Length)
        {
            State   state, pending;
            TagList tags = null;

            string filename = args[i];

            if (!File.Exists(filename))
            {
                Console.WriteLine("File {0} does not exist", filename);
                continue;
            }

            source.SetProperty("location", filename);

            StateChangeReturn sret = pipeline.SetState(State.Paused);

            if (sret == StateChangeReturn.Async)
            {
                if (StateChangeReturn.Success != pipeline.GetState(out state, out pending, Clock.Second * 5))
                {
                    Console.WriteLine("State change failed for {0}. Aborting\n", filename);
                    break;
                }
            }
            else if (sret != StateChangeReturn.Success)
            {
                Console.WriteLine("{0} - Could not read file ({1})\n", filename, sret);
                continue;
            }

            if (!MessageLoop(pipeline, ref tags))
            {
                Console.Error.WriteLine("Failed in message reading for {0}", args[i]);
            }

            if (tags != null)
            {
                Console.WriteLine("Metadata for {0}:", filename);

                tags.Foreach(new TagForeachFunc(PrintTag));
                tags.Dispose();
                tags = null;
            }
            else
            {
                Console.WriteLine("No metadata found for {0}", args[0]);
            }

            sret = pipeline.SetState(State.Null);

            if (StateChangeReturn.Async == sret)
            {
                if (StateChangeReturn.Failure == pipeline.GetState(out state, out pending, Clock.TimeNone))
                {
                    Console.WriteLine("State change failed. Aborting");
                }
            }
        }

        if (pipeline != null)
        {
            pipeline.Dispose();
        }
    }
コード例 #58
0
 public override void Process(string fileName, int offset, string xamlElement, string linePadding, ITextSnapshot snapshot, TagList tags, List <TagSuppression> suppressions = null)
 {
     Assert.Fail("This is not testable");
 }
コード例 #59
0
        public override void Process(string fileName, int offset, string xamlElement, string linePadding, ITextSnapshot snapshot, TagList tags, List <TagSuppression> suppressions = null)
        {
            if (this.TryGetAttribute(xamlElement, Attributes.SelectedItem, AttributeType.Inline | AttributeType.Element, out _, out int index, out int length, out string value))
            {
                if (value.StartsWith("{") && !value.Contains("TwoWay"))
                {
                    string existingMode = null;

                    const string oneTime = "Mode=OneTime";
                    const string oneWay  = "Mode=OneWay";

                    if (value.Contains(oneTime))
                    {
                        existingMode = oneTime;
                    }
                    else if (value.Contains(oneWay))
                    {
                        existingMode = oneWay;
                    }

                    tags.TryAdd(
                        new SelectedItemBindingModeTag(new Span(offset + index, length), snapshot, fileName, this.Logger)
                    {
                        InsertPosition      = offset + index,
                        ExistingBindingMode = existingMode,
                    },
                        xamlElement,
                        suppressions);
                }
            }
        }
コード例 #60
0
ファイル: TagList.cs プロジェクト: BeljunWaffel/SpringPig3D
    public static bool ContainsTag(GameObject gameObject, string tag)
    {
        TagList tags = gameObject.GetComponent <TagList>();

        return(tags != null && tags.ContainsTag(tag));
    }