private bool isBST2(Node root, counter count) // in order traversal { bool ret; if (root != null) { ret = isBST2(root.lChild, count); if (!ret) { return(false); } if (count.value > root.value) { return(false); } count.value = root.value; ret = isBST2(root.rChild, count); if (!ret) { return(false); } } return(true); }
public void Menu(Product[] one) { ConsoleKeyInfo key = new ConsoleKeyInfo(); counter expCount = null; Console.WriteLine("Собираем отчет:"); Console.WriteLine("Стоимость всех товаров \t Добавить - ПРОБЕЛ"); key = Console.ReadKey(); if (key.Key == ConsoleKey.Spacebar) { expCount += TotalSum; } Console.WriteLine("Стоимость всех просроченных товаров \t Добавить - ПРОБЕЛ"); key = Console.ReadKey(); if (key.Key == ConsoleKey.Spacebar) { expCount += SumExp; } Console.WriteLine("Средняя цена одного товара \t Добавить - ПРОБЕЛ"); key = Console.ReadKey(); if (key.Key == ConsoleKey.Spacebar) { expCount += avgPrice; } Console.WriteLine("Общий вес всех товаров \t Добавить - ПРОБЕЛ"); key = Console.ReadKey(); if (key.Key == ConsoleKey.Spacebar) { expCount += TotalWeight; } expCount(one); }
private void RefCnt(Term t) { counter cnt; if (!refcnt.TryGetValue(t, out cnt)) { cnt = new counter(); refcnt.Add(t, cnt); } cnt.cnt++; if (cnt.cnt == 1) { var kind = t.GetKind(); if (kind == TermKind.App) { var args = t.GetAppArgs(); foreach (var arg in args) { RefCnt(arg); } } else if (t is VCExprQuantifier) { RefCnt((t as VCExprQuantifier).Body); } } }
public FloatTrashState(trash pTrash, float pSpinsPerSeconds, float pSpinRadius) : base(pTrash) { _spinsPerSecond = pSpinsPerSeconds; _spinRadius = pSpinRadius; _outlineCounter = new counter(0); _spinDirection = UnityEngine.Random.Range(0, 2) == 0 ? 1 : -1; }
public ActionResult Create() { counter newWord = new counter(Request.Form["word"], Request.Form["sentence"]); //newWord.Save(); List <counter> allWords = counter.GetAll(); //counter.ClearAll(); return(View("Index", allWords)); }
private void btnStart_Click(object sender, EventArgs e) { counter work1 = new counter(lblResult1); counter work2 = new counter(lblResult2); thread1 = new Thread(work1.loops); thread2 = new Thread(work2.loops); CheckForIllegalCrossThreadCalls = false; thread1.Start(); thread2.Start(); }
static void Main(string[] args) { jerpBot.checkCreateBotStorage(); jerpBot.checkCreateBotDatabase(); logger logGeneral = new logger("log_general.txt"); botConfig tempConfig = new botConfig(); botConnection connConfig; if (tempConfig.loaded && tempConfig.configData.connections.Count > 0) { connConfig = tempConfig.configData.connections[0]; } else { return; } jerpBot botGeneral = new jerpBot(logGeneral, tempConfig); raffle raffleModule = new raffle(botGeneral); quotes quoteModule = new quotes(botGeneral); customCommand customCommandModule = new customCommand(botGeneral); gameCommand gameCommandModule = new gameCommand(botGeneral); counter counterModule = new counter(botGeneral); queueSystem queueModule = new queueSystem(botGeneral); autoShoutout shoutoutModule = new autoShoutout(botGeneral); lurkShoutout lurkShoutModule = new lurkShoutout(botGeneral); messageRoll rollModule = new messageRoll(botGeneral); pollManager pollModule = new pollManager(botGeneral); soundCommands soundManager = new soundCommands(botGeneral); commandAlias aliasManager = new commandAlias(botGeneral); trivia triviaManager = new trivia(botGeneral); hydrateReminder hydrateManager = new hydrateReminder(botGeneral); delaySender delaySendManager = new delaySender(botGeneral); hostMessages hostMessageModule = new hostMessages(botGeneral); streamProfiles streamProfileManager = new streamProfiles(botGeneral); predictionManager streamPredictionManager = new predictionManager(botGeneral); customCommandModule.initTable(); gameCommandModule.initTable(); aliasManager.initTable(); botGeneral.customCommandModule = customCommandModule; botGeneral.gameCommandModule = gameCommandModule; botGeneral.soundCommandModule = soundManager; botGeneral.aliasModule = aliasManager; while (!botGeneral.isReadyToClose) { botGeneral.frame(); } }
public void CheckingGetW() { //Arrange string testWord = "Tu"; string testString = "Hola"; counter newTest = new counter(testWord, testString); //Act string totalWord = newTest.GetWord(); string totalString = newTest.GetString(); //Assert Assert.AreEqual(testWord, totalWord); Assert.AreEqual(testString, totalString); }
public void TestTwo() { //Arrange string testingOne = "Good"; string testingTwo = "Bye"; counter newTest = new counter(testingOne, testingTwo); //Act string totalWord = newTest.GetWord(); string totalString = newTest.GetString(); int total = newTest.WordTotal(); //Assert Assert.AreEqual(testingOne, totalWord); Assert.AreEqual(testingTwo, totalString); Assert.AreEqual(0, total); }
public static counter getClosestCounter(Player player) { var enteredBank = business.businessList.Find(a => a.bizId == player.GetData <int>("enteredBank")); var counterResult = new counter(); float distance = 2.5f; foreach (var counter in enteredBank.external.counters) { float dist = player.Position.DistanceTo(counter.textLabel); if (dist < distance) { counterResult = counter; distance = dist; } } return(counterResult); }
void OnTriggerStay(Collider other) { GameObject target = other.gameObject; Explode playerScript = target.GetComponent <Explode>(); walls = GameObject.Find("Plane"); counter wallScript = walls.GetComponent <counter>(); if (playerScript != null) { if (charaType == playerScript.charaType) {//found another thing //increment score if (charaType == 1) { wallScript.red--; } else if (charaType == 2) { wallScript.blue--; } else if (charaType == 3) { wallScript.yellow--; } else if (charaType == 4) { wallScript.green--; } /* * else if (charaType == 5) * { * GameObject grayExplosion = Instantiate(prefabe) as GameObject; * grayExplosion.transform.position = target.transform.position; * }*/ Destroy(gameObject); } } }
public void onPlayerAddCounter(Player player) { if (!player.HasData("inBankCreator")) { player.SendChatMessage("Nu esti in creearea unei banci."); return; } var biz = player.GetData <business.model>("inBankCreator"); if (biz == null) { player.SendChatMessage("That bank doesn't exist."); return; } var counter = new counter( ); counter.textLabel = player.Position; player.SetData("counterCreator", counter); player.SendChatMessage("a fost create counteru si sa pus textlabelu acm pune setcounterped acolo unde vrei sa fie pedu"); }
public byte[] Serialize(object obj) { if ((obj is Game) == false) throw new InvalidOperationException("obj must be typeof Game"); var game = obj as Game; var rootPath = new DirectoryInfo(game.InstallPath).FullName; var save = new game(); save.id = game.Id.ToString(); save.name = game.Name; save.card = new gameCard(); save.card.back = game.CardSize.Back; save.card.front = game.CardSize.Front; save.card.height = game.CardSize.Height.ToString(); save.card.width = game.CardSize.Width.ToString(); save.card.cornerRadius = game.CardSize.CornerRadius.ToString(); save.version = game.Version.ToString(); save.authors = string.Join(",", game.Authors); save.description = game.Description; save.gameurl = game.GameUrl; save.iconurl = game.IconUrl; save.tags = string.Join(" ", game.Tags); save.octgnVersion = game.OctgnVersion.ToString(); save.markersize = game.MarkerSize; save.usetwosidedtable = game.UseTwoSidedTable ? boolean.True : boolean.False; save.noteBackgroundColor = game.NoteBackgroundColor; save.noteForegroundColor = game.NoteForegroundColor; save.scriptVersion = game.ScriptVersion == null ? null : game.ScriptVersion.ToString(); #region Variables save.variables = (game.Variables ?? new List<Variable>()).Select(x => new gameVariable() { @default = x.Default.ToString(), global = x.Global ? boolean.True : boolean.False, name = x.Name, reset = x.Reset ? boolean.True : boolean.False, }).ToArray(); #endregion #region table save.table = SerializeGroup(game.Table, rootPath); #endregion table #region gameBoards if (game.GameBoards != null) { var boardList = new List<gameBoardDef>(); foreach (var b in game.GameBoards) { var board = new gameBoardDef(); board.name = b.Value.Name; board.x = b.Value.XPos.ToString(); board.y = b.Value.YPos.ToString(); board.width = b.Value.Width.ToString(); board.height = b.Value.Height.ToString(); board.src = (b.Value.Source ?? "").Replace(rootPath, ""); boardList.Add(board); } save.gameboards.gameboard = boardList.ToArray(); } #endregion gameBoards #region shared if (game.GlobalPlayer != null) { var gs = new gameShared(); var clist = new List<counter>(); foreach (var counter in game.GlobalPlayer.Counters) { var c = new counter(); c.name = counter.Name; c.icon = (counter.Icon ?? "").Replace(rootPath, ""); c.reset = counter.Reset ? boolean.True : boolean.False; c.@default = counter.Start.ToString(); clist.Add(c); } var glist = new List<group>(); foreach (var group in game.GlobalPlayer.Groups) { glist.Add(SerializeGroup(group, rootPath)); } gs.group = glist.ToArray(); gs.counter = clist.ToArray(); save.shared = gs; } #endregion shared #region player if (game.Player != null) { var player = new gamePlayer(); var ilist = new List<object>(); foreach (var counter in game.Player.Counters) { var c = new counter(); c.name = counter.Name; c.icon = (counter.Icon ?? "").Replace(rootPath, ""); c.reset = counter.Reset ? boolean.True : boolean.False; c.@default = counter.Start.ToString(); ilist.Add(c); } foreach (var v in game.Player.GlobalVariables) { var gv = new gamePlayerGlobalvariable(); gv.name = v.Name; gv.value = v.Value; ilist.Add(gv); } ilist.Add(SerializeGroup(game.Player.Hand, rootPath)); foreach (var g in game.Player.Groups) { ilist.Add(SerializeGroup(g, rootPath)); } player.Items = ilist.ToArray(); player.summary = game.Player.IndicatorsFormat; save.player = player; } #endregion player #region documents if (game.Documents != null) { var docList = new List<gameDocument>(); foreach (var d in game.Documents) { var doc = new gameDocument(); doc.icon = (d.Icon ?? "").Replace(rootPath, ""); doc.name = d.Name; doc.src = (d.Source ?? "").Replace(rootPath, ""); docList.Add(doc); } save.documents = docList.ToArray(); } #endregion documents #region sounds if (game.Sounds != null) { var soundList = new List<gameSound>(); foreach (var d in game.Sounds) { var doc = new gameSound(); doc.name = d.Value.Name; doc.src = (d.Value.Src ?? "").Replace(rootPath, ""); soundList.Add(doc); } save.sounds = soundList.ToArray(); } #endregion sounds #region deck if (game.DeckSections != null) { var dl = new List<deckSection>(); foreach (var s in game.DeckSections) { var sec = new deckSection(); sec.name = s.Value.Name; sec.group = s.Value.Group; dl.Add(sec); } save.deck = dl.ToArray(); } if (game.SharedDeckSections != null) { var dl = new List<deckSection>(); foreach (var s in game.SharedDeckSections) { var sec = new deckSection(); sec.name = s.Value.Name; sec.group = s.Value.Group; dl.Add(sec); } save.sharedDeck = dl.ToArray(); } #endregion deck #region card if (game.CustomProperties != null) { var pl = new List<propertyDef>(); foreach (var prop in game.CustomProperties) { if (prop.Name == "Name") continue; var pd = new propertyDef(); pd.name = prop.Name; pd.type = (propertyDefType)Enum.Parse(typeof(propertyDefType), prop.Type.ToString()); pd.hidden = prop.Hidden.ToString(); pd.ignoreText = prop.IgnoreText ? boolean.True : boolean.False; switch (prop.TextKind) { case PropertyTextKind.FreeText: pd.textKind = propertyDefTextKind.Free; break; case PropertyTextKind.Enumeration: pd.textKind = propertyDefTextKind.Enum; break; case PropertyTextKind.Tokens: pd.textKind = propertyDefTextKind.Tokens; break; } pl.Add(pd); } save.card.property = pl.ToArray(); } #endregion card #region fonts var flist = new List<gameFont>(); if (game.ChatFont.IsSet()) { var f = new gameFont(); f.src = (game.ChatFont.Src ?? "").Replace(rootPath, ""); f.size = (uint)game.ChatFont.Size; f.target = fonttarget.chat; flist.Add(f); } if (game.ContextFont.IsSet()) { var f = new gameFont(); f.src = (game.ContextFont.Src ?? "").Replace(rootPath, ""); f.size = (uint)game.ContextFont.Size; f.target = fonttarget.context; flist.Add(f); } if (game.NoteFont.IsSet()) { var f = new gameFont(); f.src = (game.NoteFont.Src ?? "").Replace(rootPath, ""); f.size = (uint)game.NoteFont.Size; f.target = fonttarget.notes; flist.Add(f); } if (game.DeckEditorFont.IsSet()) { var f = new gameFont(); f.src = (game.DeckEditorFont.Src ?? "").Replace(rootPath, ""); f.size = (uint)game.DeckEditorFont.Size; f.target = fonttarget.deckeditor; flist.Add(f); } save.fonts = flist.ToArray(); #endregion fonts #region scripts if (game.Scripts != null) { var scriptList = new List<gameScript>(); foreach (var script in game.Scripts) { var f = new gameScript(); f.src = script; scriptList.Add(f); } save.scripts = scriptList.ToArray(); } #endregion scripts #region events if (game.Events != null) { var eventList = new List<gameEvent>(); foreach (var e in game.Events.SelectMany(x => x.Value)) { var eve = new gameEvent(); eve.name = e.Name; eve.action = e.PythonFunction; eventList.Add(eve); } save.events = eventList.ToArray(); } #endregion events #region proxygen save.proxygen = new gameProxygen(); save.proxygen.definitionsrc = game.ProxyGenSource; #endregion proxygen #region globalvariables if (game.GlobalVariables != null) { var gllist = new List<gameGlobalvariable>(); foreach (var gv in game.GlobalVariables) { var v = new gameGlobalvariable(); v.name = gv.Name; v.value = gv.Value; gllist.Add(v); } save.globalvariables = gllist.ToArray(); } #endregion globalvariables #region GameModes if (game.Modes != null) { var list = new List<gameGameMode>(); foreach (var m in game.Modes) { var nm = new gameGameMode(); nm.name = m.Name; nm.image = m.Image = (m.Image ?? "").Replace(rootPath, ""); nm.playerCount = m.PlayerCount; nm.shortDescription = nm.shortDescription; list.Add(nm); } save.gameModes = list.ToArray(); } #endregion GameModes var serializer = new XmlSerializer(typeof(game)); directory = new FileInfo(game.InstallPath).Directory.FullName; using (var fs = File.Open(game.Filename, FileMode.Create, FileAccess.Write, FileShare.None)) { serializer.Serialize(fs, save); } return File.ReadAllBytes(game.Filename); }
public byte[] Serialize(object obj) { if ((obj is Game) == false) { throw new InvalidOperationException("obj must be typeof Game"); } var game = obj as Game; var rootPath = new DirectoryInfo(game.InstallPath).FullName; var save = new game(); save.id = game.Id.ToString(); save.name = game.Name; save.card = new gameCard(); save.card.back = game.CardBack; save.card.front = game.CardFront; save.card.height = game.CardHeight.ToString(); save.card.width = game.CardWidth.ToString(); save.card.cornerRadius = game.CardCornerRadius.ToString(); save.version = game.Version.ToString(); save.authors = string.Join(",", game.Authors); save.description = game.Description; save.gameurl = game.GameUrl; save.iconurl = game.IconUrl; save.tags = string.Join(" ", game.Tags); save.octgnVersion = game.OctgnVersion.ToString(); save.markersize = game.MarkerSize; save.usetwosidedtable = game.UseTwoSidedTable ? boolean.True : boolean.False; save.noteBackgroundColor = game.NoteBackgroundColor; save.noteForegroundColor = game.NoteForegroundColor; save.scriptVersion = game.ScriptVersion == null ? null : game.ScriptVersion.ToString(); #region Variables save.variables = (game.Variables ?? new List <Variable>()).Select(x => new gameVariable() { @default = x.Default.ToString(), global = x.Global ? boolean.True : boolean.False, name = x.Name, reset = x.Reset ? boolean.True : boolean.False, }).ToArray(); #endregion #region table save.table = SerializeGroup(game.Table, rootPath); #endregion table #region shared if (game.GlobalPlayer != null) { var gs = new gameShared(); var clist = new List <counter>(); foreach (var counter in game.GlobalPlayer.Counters) { var c = new counter(); c.name = counter.Name; c.icon = (counter.Icon ?? "").Replace(rootPath, ""); c.reset = counter.Reset ? boolean.True : boolean.False; c.@default = counter.Start.ToString(); clist.Add(c); } var glist = new List <group>(); foreach (var group in game.GlobalPlayer.Groups) { glist.Add(SerializeGroup(group, rootPath)); } gs.group = glist.ToArray(); gs.counter = clist.ToArray(); save.shared = gs; } #endregion shared #region player if (game.Player != null) { var player = new gamePlayer(); var ilist = new List <object>(); foreach (var counter in game.Player.Counters) { var c = new counter(); c.name = counter.Name; c.icon = (counter.Icon ?? "").Replace(rootPath, ""); c.reset = counter.Reset ? boolean.True : boolean.False; c.@default = counter.Start.ToString(); ilist.Add(c); } foreach (var v in game.Player.GlobalVariables) { var gv = new gamePlayerGlobalvariable(); gv.name = v.Name; gv.value = v.Value; ilist.Add(gv); } ilist.Add(SerializeGroup(game.Player.Hand, rootPath)); foreach (var g in game.Player.Groups) { ilist.Add(SerializeGroup(g, rootPath)); } player.Items = ilist.ToArray(); player.summary = game.Player.IndicatorsFormat; save.player = player; } #endregion player #region documents if (game.Documents != null) { var docList = new List <gameDocument>(); foreach (var d in game.Documents) { var doc = new gameDocument(); doc.icon = (d.Icon ?? "").Replace(rootPath, ""); doc.name = d.Name; doc.src = (d.Source ?? "").Replace(rootPath, ""); docList.Add(doc); } save.documents = docList.ToArray(); } #endregion documents #region sounds if (game.Sounds != null) { var soundList = new List <gameSound>(); foreach (var d in game.Sounds) { var doc = new gameSound(); doc.name = d.Value.Name; doc.src = (d.Value.Src ?? "").Replace(rootPath, ""); soundList.Add(doc); } save.sounds = soundList.ToArray(); } #endregion sounds #region deck if (game.DeckSections != null) { var dl = new List <deckSection>(); foreach (var s in game.DeckSections) { var sec = new deckSection(); sec.name = s.Value.Name; sec.group = s.Value.Group; dl.Add(sec); } save.deck = dl.ToArray(); } if (game.SharedDeckSections != null) { var dl = new List <deckSection>(); foreach (var s in game.SharedDeckSections) { var sec = new deckSection(); sec.name = s.Value.Name; sec.group = s.Value.Group; dl.Add(sec); } save.sharedDeck = dl.ToArray(); } #endregion deck #region card if (game.CustomProperties != null) { var pl = new List <propertyDef>(); foreach (var prop in game.CustomProperties) { if (prop.Name == "Name") { continue; } var pd = new propertyDef(); pd.name = prop.Name; pd.type = (propertyDefType)Enum.Parse(typeof(propertyDefType), prop.Type.ToString()); pd.hidden = prop.Hidden.ToString(); pd.ignoreText = prop.IgnoreText ? boolean.True : boolean.False; switch (prop.TextKind) { case PropertyTextKind.FreeText: pd.textKind = propertyDefTextKind.Free; break; case PropertyTextKind.Enumeration: pd.textKind = propertyDefTextKind.Enum; break; case PropertyTextKind.Tokens: pd.textKind = propertyDefTextKind.Tokens; break; } pl.Add(pd); } save.card.property = pl.ToArray(); } #endregion card #region fonts if (game.Fonts != null) { var flist = new List <gameFont>(); foreach (var font in game.Fonts) { var f = new gameFont(); f.src = (font.Src ?? "").Replace(rootPath, ""); f.size = (uint)font.Size; f.target = (fonttarget)Enum.Parse(typeof(fonttarget), font.Target); flist.Add(f); } save.fonts = flist.ToArray(); } #endregion fonts #region scripts if (game.Scripts != null) { var scriptList = new List <gameScript>(); foreach (var script in game.Scripts) { var f = new gameScript(); f.src = script; scriptList.Add(f); } save.scripts = scriptList.ToArray(); } #endregion scripts #region events if (game.Events != null) { var eventList = new List <gameEvent>(); foreach (var e in game.Events.SelectMany(x => x.Value)) { var eve = new gameEvent(); eve.name = e.Name; eve.action = e.PythonFunction; eventList.Add(eve); } save.events = eventList.ToArray(); } #endregion events #region proxygen save.proxygen = new gameProxygen(); save.proxygen.definitionsrc = game.ProxyGenSource; #endregion proxygen #region globalvariables if (game.GlobalVariables != null) { var gllist = new List <gameGlobalvariable>(); foreach (var gv in game.GlobalVariables) { var v = new gameGlobalvariable(); v.name = gv.Name; v.value = gv.Value; gllist.Add(v); } save.globalvariables = gllist.ToArray(); } #endregion globalvariables #region GameModes if (game.Modes != null) { var list = new List <gameGameMode>(); foreach (var m in game.Modes) { var nm = new gameGameMode(); nm.name = m.Name; nm.image = m.Image = (m.Image ?? "").Replace(rootPath, ""); nm.playerCount = m.PlayerCount; nm.shortDescription = nm.shortDescription; list.Add(nm); } save.gameModes = list.ToArray(); } #endregion GameModes var serializer = new XmlSerializer(typeof(game)); directory = new FileInfo(game.InstallPath).Directory.FullName; using (var fs = File.Open(game.Filename, FileMode.Create, FileAccess.Write, FileShare.None)) { serializer.Serialize(fs, save); } return(File.ReadAllBytes(game.Filename)); }
public void Start() { countScript = linkedCounter.GetComponent<counter>(); }
public SwimFishState(fish pFish, float pSpeed) : base(pFish) { _speed = pSpeed; _outlineCounter = new counter(0); }
public SwimJellyfishState(Jellyfish pJellyfish, float pSpeed, float pLerpSpeed, float pRevealDuration) : base(pJellyfish) { _speed = pSpeed; _lerpSpeed = pLerpSpeed; _outlineCounter = new counter(pRevealDuration); }
foreach (var(counter, value) in countersAndValues)
private counter() { instance = this; }
internal bool isBST2() { counter c = new counter(); return(isBST2(root, c)); }
static int MinValue(ref Node p, ref counter c, int depth) { c.nodes++; depth++; if (c.nodes % 10000 == 0) Console.WriteLine("Nodes: " + c.nodes + "\n" + "Min Prune: " + c.minprune + "\n" + "Max Prune: " + c.maxprune); //if(count%10== 0) Console.WriteLine(count); if (Terminal(p, true)) { return 20; } if (depth == MAX_DEPTH) { return Node.UtilityFunc(p.CBoard); } int v = int.MaxValue; List<Move> moves = Move.GenerateAllMoves(p.CBoard, true); if (moves.Count() > 0) if (moves[0].Jump) { foreach (Piece[,] b in GenerateJumps(moves, p.CBoard, false)) { Node tNode = new Node(b); tNode.Alpha = p.Alpha; tNode.Beta = p.Beta; tNode.Parent = p; v = Math.Min(v, MaxValue(ref tNode, ref c, depth)); if (v <= p.Alpha) { c.minprune++; return v; } p.Beta = Math.Min(p.Beta, v); } } else { foreach (Move m in moves) { Node tNode = new Node(p, m, p.Alpha, p.Beta); v = Math.Min(v, MaxValue(ref tNode, ref c, depth)); if (v <= p.Alpha) { c.minprune++; return v; } p.Beta = Math.Min(p.Beta, v); } } return v; }
protected void loadQuest(string i, string attributeMulti, string img, int count, List<questions> t, bool pb) { int[] arr = new int[4]; if (pb == true) { foreach (var x in listq) { int id = x.getId(); if (id.ToString() == i) { arr = x.getArr(); } } } else if (pb == false) { foreach (var x in t) { int id = x.getId(); if (id.ToString() == i) { arr = x.getArr(); } } } //Skapar nya rader row1 = new TableRow(); row2 = new TableRow(); row3 = new TableRow(); row4 = new TableRow(); row5 = new TableRow(); row6 = new TableRow(); //Skapar nya celler i raderna ovan cell1 = new TableCell(); cell2 = new TableCell(); cell3 = new TableCell(); cell4 = new TableCell(); cell5 = new TableCell(); cell6 = new TableCell(); imgcell = new TableCell(); //Skapar ny label Label lblQuestion = new Label(); //Om frågan bara har ett svarsalternativ som är rätt if (attributeMulti == "false") { //Skapar nya radiobuttons radiob1 = new RadioButton(); radiob2 = new RadioButton(); radiob3 = new RadioButton(); radiob4 = new RadioButton(); //Ger ett gruppnamn till radiobuttons radiob1.GroupName = "gr" + i.ToString(); radiob2.GroupName = "gr" + i.ToString(); radiob3.GroupName = "gr" + i.ToString(); radiob4.GroupName = "gr" + i.ToString(); //Sätter ett unikt namn till varje radiobutton radiob1.ID = i.ToString() + "r1"; radiob2.ID = i.ToString() + "r2"; radiob3.ID = i.ToString() + "r3"; radiob4.ID = i.ToString() + "r4"; lblQuestion.Text = count + ": " + (xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']").FirstChild.InnerText); XmlNode n1 = xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']"); string cat1 = n1.Attributes["multi"].Value; lblQuestion.Attributes.Add("multi", cat1); string cat2 = n1.Attributes["id"].Value; lblQuestion.Attributes.Add("id", cat2); radiob1.Text = xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']/answer/answer[@id = '" + arr[0] + "']").InnerText; XmlNode n = xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']/answer/answer[@id ='" + arr[0] + "']"); string at = n.Attributes["correct"].Value; n = xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']"); string cat = n.Attributes["category"].Value; lblQuestion.Text += " (" + cat + ")"; radiob1.Attributes.Add("correct", at); radiob1.Attributes.Add("category", cat); string qid = n.Attributes["id"].Value; radiob1.Attributes.Add("qid", arr[0].ToString()); radiob2.Text = xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']/answer/answer[@id = '" + arr[1] + "']").InnerText; n = xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']/answer/answer[@id='" + arr[1] + "']"); at = n.Attributes["correct"].Value; n = xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']"); cat = n.Attributes["category"].Value; radiob2.Attributes.Add("category", cat); radiob2.Attributes.Add("correct", at); qid = n.Attributes["id"].Value; radiob2.Attributes.Add("qid", arr[1].ToString()); radiob3.Text = xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']/answer/answer[@id = '" + arr[2] + "']").InnerText; n = xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']/answer/answer[@id='" + arr[2] + "']"); at = n.Attributes["correct"].Value; n = xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']"); cat = n.Attributes["category"].Value; radiob3.Attributes.Add("category", cat); radiob3.Attributes.Add("correct", at); qid = n.Attributes["id"].Value; radiob3.Attributes.Add("qid", arr[2].ToString()); radiob4.Text = xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']/answer/answer[@id = '" + arr[3] + "']").InnerText; n = xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']/answer/answer[@id='" + arr[3] + "']"); at = n.Attributes["correct"].Value; n = xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']"); cat = n.Attributes["category"].Value; radiob4.Attributes.Add("category", cat); radiob4.Attributes.Add("correct", at); qid = n.Attributes["id"].Value; radiob4.Attributes.Add("qid", arr[3].ToString()); //Lägger in radiobuttons i cellerna cell1.Controls.Add(lblQuestion); cell1.ColumnSpan = 2; cell2.Controls.Add(radiob1); cell3.Controls.Add(radiob2); cell4.Controls.Add(radiob3); cell5.Controls.Add(radiob4); } //Om det är en fråga med många svarsalternativ if (attributeMulti == "true") { //Skapar nya checkboxes checkbox1 = new CheckBox(); checkbox2 = new CheckBox(); checkbox3 = new CheckBox(); checkbox4 = new CheckBox(); answ ch = new answ(); counter cnt = new counter(); //checkbox1.Attributes.Add("runat", "server"); //checkbox2.Attributes.Add("runat", "server"); //checkbox3.Attributes.Add("runat", "server"); //checkbox4.Attributes.Add("runat", "server"); //checkbox1.Attributes.Add("onClick", "Check(this)"); //checkbox2.Attributes.Add("onClick", "Check(this)"); //checkbox3.Attributes.Add("onClick", "Check(this)"); //checkbox4.Attributes.Add("onClick", "Check(this)"); //checkbox1.A //checkbox1.ID = i.ToString() + "c1"; //checkbox2.ID = i.ToString() + "c2"; //checkbox3.ID = i.ToString() + "c3"; //checkbox4.ID = i.ToString() + "c4"; checkbox1.InputAttributes.Add("name", "check" + count); checkbox1.InputAttributes.Add("value", "1"); checkbox2.InputAttributes.Add("name", "check" + count); checkbox2.InputAttributes.Add("value", "2"); checkbox3.InputAttributes.Add("name", "check" + count); checkbox3.InputAttributes.Add("value", "3"); checkbox4.InputAttributes.Add("name", "check" + count); checkbox4.InputAttributes.Add("value", "4"); cnt.setGroup("check" + count.ToString()); ch.setId(Convert.ToInt16(i)); lblQuestion.Text = count + ": " + (xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']").FirstChild.InnerText); XmlNode n1 = xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']"); string cat1 = n1.Attributes["multi"].Value; lblQuestion.Attributes.Add("multi", cat1); string cat2 = n1.Attributes["id"].Value; lblQuestion.Attributes.Add("id", cat2); checkbox1.Text = xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']/answer/answer[@id = '" + arr[0] + "']").InnerText; XmlNode usernode = xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']/answer/answer[@id='" + arr[0] + "']"); string at = usernode.Attributes["correct"].Value; usernode = xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']"); string cat = usernode.Attributes["category"].Value; lblQuestion.Text += " (" + cat + ")"; checkbox1.Attributes.Add("category", cat); checkbox1.Attributes.Add("correct", at); checkbox1.Attributes.Add("group", i); string qid = n1.Attributes["id"].Value; checkbox1.Attributes.Add("qid", arr[0].ToString()); if (at == "true") { ch.setCount(); cnt.setCount(); } checkbox2.Text = xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']/answer/answer[@id = '" + arr[1] + "']").InnerText; usernode = xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']/answer/answer[@id='" + arr[1] + "']"); at = usernode.Attributes["correct"].Value; usernode = xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']"); cat = usernode.Attributes["category"].Value; qid = n1.Attributes["id"].Value; checkbox2.Attributes.Add("qid", arr[1].ToString()); if (at == "true") { ch.setCount(); cnt.setCount(); } checkbox2.Attributes.Add("category", cat); checkbox2.Attributes.Add("correct", at); checkbox2.Attributes.Add("group", i); checkbox3.Text = xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']/answer/answer[@id = '" + arr[2] + "']").InnerText; usernode = xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']/answer/answer[@id='" + arr[2] + "']"); at = usernode.Attributes["correct"].Value; usernode = xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']"); cat = usernode.Attributes["category"].Value; qid = n1.Attributes["id"].Value; checkbox3.Attributes.Add("qid", arr[2].ToString()); if (at == "true") { ch.setCount(); cnt.setCount(); } checkbox3.Attributes.Add("category", cat); checkbox3.Attributes.Add("correct", at); checkbox3.Attributes.Add("group", i); checkbox4.Text = xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']/answer/answer[@id = '" + arr[3] + "']").InnerText; usernode = xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']/answer/answer[@id='" + arr[3] + "']"); at = usernode.Attributes["correct"].Value; usernode = xmldoc2.SelectSingleNode("/categories/question[@id='" + i + "']"); cat = usernode.Attributes["category"].Value; if (at == "true") { ch.setCount(); cnt.setCount(); } checkbox4.Attributes.Add("category", cat); checkbox4.Attributes.Add("correct", at); checkbox4.Attributes.Add("group", i); qid = n1.Attributes["id"].Value; checkbox4.Attributes.Add("qid", arr[3].ToString()); //Lägger in checkboxar i cellerna cell1.Controls.Add(lblQuestion); cell1.ColumnSpan = 2; cell2.Controls.Add(checkbox1); cell3.Controls.Add(checkbox2); cell4.Controls.Add(checkbox3); cell5.Controls.Add(checkbox4); ch.setCat(cat); list.Add(ch); checklist.Add(cnt); } //Lägger in label i cellen cell1.Attributes.Add("class", "questionCell"); //Lägger in cellen på raden row1.Controls.Add(cell1); row2.Controls.Add(cell2); row3.Controls.Add(cell3); row4.Controls.Add(cell4); row5.Controls.Add(cell5); row6.Controls.Add(cell6); //Lägger till attribut till de olika radobjekten row1.Attributes.Add("class", "question"); table1.Controls.Add(row1); //row2.Attributes.Add("class", "answers answer1"); row2.Attributes.Add("class", "answers"); table1.Controls.Add(row2); row3.Attributes.Add("class", "answers"); table1.Controls.Add(row3); row4.Attributes.Add("class", "answers"); table1.Controls.Add(row4); row5.Attributes.Add("class", "answers"); table1.Controls.Add(row5); row6.Attributes.Add("class", "empty"); table1.Controls.Add(row6); count++; //Om attributet image är satt till true if (img == "true") { Image bild = new Image(); string imagelink = xmldoc2.SelectSingleNode("categories/question[@id='" + i + "']/image").InnerText; bild.ImageUrl = imagelink; imgcell.RowSpan = 4; row2.Controls.Add(imgcell); imgcell.Controls.Add(bild); } }