// Create an empty initialized template public Template() { head = new node(); addedHead = new node(); addedTail = addedHead; firstSection = new section(); tpl = this; fields = new Object[MAX_FIELDS]; sections = new Object[MAX_FIELDS]; }
/// <summary> /// The message header includes the datalength, which allows the message to span /// more than one HID report. Useful for long UART/SPI transfers /// </summary> private void msgSend(section s, byte instruction, byte[] data) { HU320_USB_msg M = new HU320_USB_msg(); M.sect = s; M.instruction = instruction; M.flags = 0x0000; M.data = data; byte[] b = M.flatten(); usbI.write(b); }
private bool msgSendGetReply(section s, byte instruction, out byte[] replyData) { replyData = new byte[0]; //TODO - add retries for failed messages msgSend(s, instruction); //TODO - check section and instruction here bool replyOK = waitReply.WaitOne(replyTimeout); if (replyOK) replyData = RX_msg.data; return replyOK; }
// Create using template file public Template(string data) { head = new node(); addedHead = new node(); addedTail = addedHead; firstSection = new section(); tpl = this; fields = new Object[MAX_FIELDS]; sections = new Object[MAX_FIELDS]; data = SECTIONTAG_HEAD + data + SECTIONTAG_TAIL; construct(data, SECTIONTAG_HEAD_LEN, data.Length-SECTIONTAG_TAIL_LEN); }
// Create using template file public Template(string filename) { head = new node(); addedHead = new node(); addedTail = addedHead; firstSection = new section(); tpl = this; fields = new Object[MAX_FIELDS]; sections = new Object[MAX_FIELDS]; StreamReader re = new StreamReader(filename, System.Text.Encoding.Default); string data = SECTIONTAG_HEAD + re.ReadToEnd() + SECTIONTAG_TAIL; re.Close(); construct(data, SECTIONTAG_HEAD_LEN, data.Length - SECTIONTAG_TAIL_LEN); }
private section _getSection(string key) { section s = (section)sections[(uint)(key.GetHashCode()) % MAX_FIELDS]; while (s != null) { if (s.key == key) { return(s); } s = s.next; } return(null); }
private bool msgSendGetReply(section s, byte instruction, out byte[] replyData) { replyData = new byte[0]; //TODO - add retries for failed messages msgSend(s, instruction); //TODO - check section and instruction here bool replyOK = waitReply.WaitOne(replyTimeout); if (replyOK) { replyData = RX_msg.data; } return(replyOK); }
public ActionResult CreateSection([Bind(Exclude = "id")] section section) { if ((string)Session["user"] != null) { if (ModelState.IsValid) { data.section.Add(section); data.SaveChanges(); return(RedirectToAction("ListSection")); } return(View(section)); } return(RedirectToAction("Login", "User")); }
public void reset() { for (int i=0; i<MAX_FIELDS; i++) { for (field f = (field)fields[i]; f != null; f = f.next) f.val = ""; } for (section s = firstSection.nextSection; s != null; s = s.nextSection) { s.tpl.addedHead.next = null; s.tpl.addedTail = s.tpl.addedHead; s.tpl.reset(); } }
public void setSectionFromFile(string key, string filename) { section s = tpl._getSection(key); if (s == null) throw new Exception("setSection: Cannot find section "+key); node n = new node(); n.val = new cell(); StreamReader re = File.OpenText(filename); n.val.val = re.ReadToEnd(); re.Close(); n.next = s.preceding.next; s.preceding.next = n; s.preceding = n; }
public section SearchSection(int sectionNumber) { section a = null; for (int i = 0; i < sectionCount; i++) { if (sections[i].cId.Equals(sectionNumber)) { a = sections[i]; break; } } return(a); }
public IHttpActionResult Deletesection(int id) { section section = db.sections.Find(id); if (section == null) { return(NotFound()); } db.sections.Remove(section); db.SaveChanges(); return(Ok(section)); }
public void red(ref section s, int Row_start) { // for (int i = Row_start; i <= Row_start + 2; i++) { int i = Row_start; s.RM = Convert.ToDouble(dataGridView1.Rows[i].Cells[0].Value); s.GM = Convert.ToDouble(dataGridView1.Rows[i].Cells[1].Value); s.BM = Convert.ToDouble(dataGridView1.Rows[i].Cells[2].Value); s.RS = Convert.ToDouble(dataGridView1.Rows[i + 1].Cells[0].Value); s.GS = Convert.ToDouble(dataGridView1.Rows[i + 1].Cells[1].Value); s.BS = Convert.ToDouble(dataGridView1.Rows[i + 1].Cells[2].Value); } }
// GET: sections/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } section section = db.sections.Find(id); if (section == null) { return(HttpNotFound()); } return(View(section)); }
// GET: sections/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } section section = db.sections.Find(id); if (section == null) { return(HttpNotFound()); } ViewBag.ID_user = new SelectList(db.users, "ID_user", "first_name", section.ID_user); return(View(section)); }
public ActionResult Inscription(long id) { SportAssoEntities db = new SportAssoEntities(); ViewBag.seance_id = id; seance s = db.seance.Find(id); section sec = db.section.Find(s.section_id); discipline d = db.discipline.Find(sec.discipline_id); ViewBag.utilisateur_id = GetUserIdByLogin(User.Identity.GetUserName()); ViewBag.a_payer = false; ViewData["titre"] = "Inscription à la section " + sec.label + " de la discipline " + d.label; ViewData["texte"] = "Comfirmez votre inscription à la séance du " + s.jour_de_la_semaine + " de " + HourFormator("" + s.heure_debut) + " à " + HourFormator("" + s.heure_fin); return(View()); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } section section = db.section.Find(id); if (section == null) { return(HttpNotFound()); } ViewBag.discipline_id = new SelectList(db.discipline, "discipline_id", "label", section.discipline_id); return(View(section)); }
// GET: sections/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } section section = db.sections.Find(id); if (section == null) { return(HttpNotFound()); } ViewBag.id_page = new SelectList(db.pages, "id_page", "titre", section.id_page); return(View(section)); }
public ActionResult Edit([Bind(Include = "id,section_number,program_id,course_id,student_enrolled,faculty_id,is_deleted,created_by,created_on,modified_by,modified_on,class_weekday,class_start_time,room_id")] section section) { if (ModelState.IsValid) { db.Entry(section).State = EntityState.Modified; if (section.is_deleted == false) { // set related course deleted = false; var tempC = db.courses.Where(e => e.id == section.course_id); if (tempC.ToList().Count > 0) { foreach (var item in tempC) { item.is_deleted = false; } } // set related course - exam deleted = false; var tempCE = db.course_exam.Where(e => e.course_id == section.course_id); if (tempCE.ToList().Count > 0) { foreach (var item in tempCE) { item.is_deleted = false; } } } section.student_enrolled = 30; section.modified_on = DateTime.Now; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.course_id = new SelectList(db.courses.Where(c => c.is_deleted == false || c.id == section.course_id).OrderBy(o => o.code), "id", "courseDropdown", section.course_id); ViewBag.faculty_id = new SelectList(db.faculties.Where(c => c.is_deleted == false), "id", "last_name", section.faculty_id); ViewBag.program_id = new SelectList(db.programs.Where(c => c.is_deleted == false), "id", "title", section.program_id); ViewBag.room_id = new SelectList(db.rooms.Where(c => c.is_deleted == false).OrderBy(o => o.name), "id", "name", section.room_id); var weekDays = Enum.GetValues(typeof(DayOfWeek)).Cast <DayOfWeek>() .Select(dow => new { Value = (int)dow - 1, Text = dow.ToString() }) .ToList(); ViewBag.class_weekday = new SelectList(weekDays, "Value", "Text", section.class_weekday); return(View(section)); }
public void setSection(string key, string data) { section s = tpl._getSection(key); if (s == null) { fail("setSection: Cannot find section " + key); } node n = new node(); n.val = new cell(); n.val.val = data; n.next = s.preceding.next; s.preceding.next = n; s.preceding = n; }
public override bool Delete(object Obj) { try { section section = (section)Obj; dbEntities = new mpi_dbEntities(); dbEntities.sections.Remove(section); dbEntities.SaveChanges(); return(true); } catch (Exception e) { Console.WriteLine(e); return(false); } }
private section _produceSection(string key) { uint pos = (uint)(key.GetHashCode()) % MAX_FIELDS; section s = (section)sections[pos]; while (s != null) { if (s.key == key) return s; s = s.next; } s = new section(); s.key = key; s.next = (section)sections[pos]; sections[pos] = s; return s; }
public ActionResult Create([Bind(Exclude = "section_id")] section section) { if (!ModelState.IsValid) { return(View()); } try { db.section.Add(section); db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult SectionSvc() { bool Access = UserValid() && IsAdmin(); WebResponse Response = new WebResponse(); if (!Access || !StringUtil.NotNullAndNotBlank(Request.Form["Action"])) { return(Json(Response)); } string Action = Request.Form["Action"].ToString(); SectionService EntitySvc = new SectionService(); switch (Action) { case "List": Response = MVCUtil.generateResponseList(EntitySvc, Request, LoggedUser, new string[] { "id", "name", "description", "division_id", "parent_section_id" }, typeof(section)); break; case "Form": Response = MVCUtil.generateResponseWithForm(typeof(section), EntitySvc, Request); break; case "Post": section section = (section)ObjectUtil.FillObjectWithMap(new section(), BaseService.ReqToDict(Request)); if (section != null) { Response = MVCUtil.UpdateEntity(EntitySvc, section, new string[] { "id", "name", "description", "division_id", "parent_section_id" }, Response); } break; case "Delete": Response = MVCUtil.DeleteEntity(EntitySvc, Request, Response); break; default: break; } return(Json(Response)); }
static section BuildSection(XmlTextReader r, string type) { section s = DefaultS(); s.type = type; while (r.MoveToNextAttribute()) { switch (r.Name.ToLower()) { case "offset": try { s.offset = int.Parse(r.Value, NumberStyles.HexNumber); } catch { Console.WriteLine("Offset invalid HEX value or not specified."); } break; case "file": s.path = r.Value; break; case "table": s.table = r.Value; break; case "lztype": s.LZType = r.Value; break; case "bptype": //uses the same property as lztype s.LZType = r.Value; break; case "rletype": s.LZType = r.Value; break; case "type": s.LZType = r.Value; break; } } return(s); }
private void WriteSection(section section, StringBuilder sb) { if (sb.Length > 0) { sb.Append(Configuration.NewLineStr); } WriteComments(section.LeadingComments, sb); sb.Append(string.Format("{0}{1}{2}{3}", Configuration.SectionStartChar, section.SectionName, Configuration.SectionEndChar, Configuration.NewLineStr)); WriteKeyValueData(section.Keys, sb); WriteComments(section.TrailingComments, sb); }
// GET: Section/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } section section = db.sections.Find(id); if (section == null) { return(HttpNotFound()); } var weekDays = Enum.GetValues(typeof(DayOfWeek)).Cast <DayOfWeek>() .Select(dow => new { Value = (int)dow - 1, Text = dow.ToString() }) .ToList(); ViewBag.class_weekday = new SelectList(weekDays, "Value", "Text", section.class_weekday); return(View(section)); }
private void btnAdd_Click(object sender, EventArgs e) { if (txtCourse.Text.Length != 0) { MatrixLinQDataContext con = new MatrixLinQDataContext(); section s = new section(); s.sectionName = this.txtCourse.Text; con.sections.InsertOnSubmit(s); con.SubmitChanges(); MessageBox.Show("New Section Added"); txtCourse.Text = ""; } else { MessageBox.Show("Error"); } }
public ActionResult DeleteConfirmed(int id) { section section = db.sections.Find(id); //// set related section deleted = true; //var tempS = db.sections.Where(e => e.course_id == section.course_id); //if (tempS.ToList().Count > 0) //{ // foreach (var item in tempS) // { // item.is_deleted = true; // } //} //// set related course deleted = true; //var tempC = db.courses.Where(e => e.id == section.course_id); //if (tempC.ToList().Count > 0) //{ // foreach (var item in tempC) // { // item.is_deleted = true; // } //} //// set related course - exam deleted = true; //var tempCE = db.course_exam.Where(e => e.course_id == section.course_id); //if (tempCE.ToList().Count > 0) //{ // foreach (var item in tempCE) // { // item.is_deleted = true; // } //} //section.is_deleted = true; //section.modified_on = DateTime.Now; db.sections.Remove(section); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "id,section_number,program_id,course_id,student_enrolled,faculty_id,is_deleted,created_by,created_on,modified_by,modified_on,class_weekday,class_start_time,room_id")] section section) { string err = ""; var tempList = db.sections.Where(s => s.course_id == section.course_id); foreach (var item in tempList) { if (item.section_number == section.section_number) { err = "Cannot create duplicated section number for same course. This section number exists for this course."; section.section_number = null; break; } } if (section.section_number != null) { if (ModelState.IsValid) { section.created_on = DateTime.Now; section.student_enrolled = 30; db.sections.Add(section); db.SaveChanges(); return(RedirectToAction("Index")); } } ViewBag.course_id = new SelectList(db.courses.Where(p => p.is_deleted == false).OrderBy(o => o.code), "id", "courseDropdown", section.course_id); ViewBag.faculty_id = new SelectList(db.faculties.Where(c => c.is_deleted == false).OrderBy(o => o.first_name), "id", "fullName", section.faculty_id); ViewBag.program_id = new SelectList(db.programs.Where(c => c.is_deleted == false), "id", "title", section.program_id); ViewBag.room_id = new SelectList(db.rooms.Where(c => c.is_deleted == false).OrderBy(o => o.name), "id", "name", section.room_id); ViewBag.Error = err; var weekDays = Enum.GetValues(typeof(DayOfWeek)).Cast <DayOfWeek>() .Select(dow => new { Value = (int)dow - 1, Text = dow.ToString() }) .ToList(); ViewBag.class_weekday = new SelectList(weekDays, "Value", "Text", section.class_weekday); return(View(section)); }
public string getContent() { int len = 0; // Traverse this' content to get length for (node n = head.next; n != null; n = n.next) { len += n.val.val.Length; } // Traverse all sections to add length of content added to them for (section currSection = firstSection.nextSection; currSection != null; currSection = currSection.nextSection) { for (node n = currSection.tpl.addedHead.next; n != null; n = n.next) { len += n.val.val.Length; } } // Traverse to get content in the right order node currNode = head; StringBuilder sb = new StringBuilder(len); for (section currSection = firstSection.nextSection; currSection != null; currSection = currSection.nextSection) { while (currNode != currSection.preceding) { currNode = currNode.next; sb.Append(currNode.val.val); } for (node n = currSection.tpl.addedHead.next; n != null; n = n.next) { sb.Append(n.val.val); } } while ((currNode = currNode.next) != null) { sb.Append(currNode.val.val); } return(sb.ToString()); }
public async Task <IActionResult> Create_sec(section section, classroom_info classroom_info) { if (ModelState.IsValid) { section.course_id = (int)HttpContext.Session.GetInt32("course_id"); if (_context.section.Any(u => u.sec_id == section.sec_id)) { ModelState.AddModelError("sec_id", "sec_id already in use!!!"); return(View("Create_sec")); } HttpContext.Session.SetString("time_slot_id", section.time_slot_id); classroom_info.classroom_id = section.classroom_id; _context.Add(classroom_info); _context.Add(section); _context.SaveChanges(); return(RedirectToAction("Create_time")); } return(View("Create_sec")); }
public ActionResult Index(long?id) { var seance = db.seance.Include(s => s.lieu).Include(s => s.section).Include(s => s.utilisateur); ViewBag.titre_page = "Liste des Séances"; ViewBag.ajoutLier = "false"; ViewBag.section_id = 0; if (id.HasValue) { seance = from b in db.seance.Include(si => si.lieu).Include(si => si.section).Include(si => si.utilisateur) where b.section_id == id select b; section s = db.section.Find(id); discipline d = db.discipline.Find(s.discipline_id); ViewBag.titre_page = "Liste des séances de la section " + s.label + " de la discipline " + d.label; ViewBag.ajoutLier = "true"; ViewBag.section_id = id; } return(View(seance.ToList())); }
public ActionResult Edit(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } section section = db.section.Find(id); if (section == null) { return(HttpNotFound()); } ViewBag.discipline_id = new SelectList(db.discipline, "discipline_id", "label", section.discipline_id); //ViewBag.responsable_id = new SelectList(db.utilisateur, "utilisateur_id", "login", section.responsable_id); var responsables = new List <SelectListItem>(); foreach (utilisateur u in db.utilisateur) { if (u.type_user == "encadrant") { if (u.utilisateur_id == section.responsable_id) { responsables.Add(new SelectListItem() { Text = u.prenom + " " + u.nom + " " + u.login, Value = "" + u.utilisateur_id, Selected = true }); } else { responsables.Add(new SelectListItem() { Text = u.prenom + " " + u.nom + " " + u.login, Value = "" + u.utilisateur_id, Selected = false }); } } } ViewBag.responsable_id = responsables; return(View(section)); }
public void drew (int st , int w , int h , section s ) { double R1, G1, B1; Color color; for (int i = st; i < w; i++) { for (int j = 0; j < h; j++) { Random rnd = new Random(); R1 = createMemberInNormalDistribution(s.RM, s.RS, rnd); // Generate Random green color value G1 = createMemberInNormalDistribution(s.GM, s.GS, rnd); // Generate Random Blue color value B1 = createMemberInNormalDistribution(s.BM, s.BS, rnd); color = Color.FromArgb(Convert.ToInt32(R1), Convert.ToInt32(G1), Convert.ToInt32(B1)); // SolidBrush brush = new SolidBrush(color); img.SetPixel(i, j, color); } } }
private void changeDate(int newIndex, section section) { String[] sections = lastDateTemplate.Split(new char[] { '/', '-', '.' }); switch (sections[(int)section]) { case "M": case "MM": DisplayedDate = DisplayedDate.AddMonths((newIndex + 1) - DisplayedDate.Month); break; case "d": case "dd": DisplayedDate = DisplayedDate.AddDays((newIndex + 1) - DisplayedDate.Day); break; case "yyyy": case "yy": DisplayedDate = DisplayedDate.AddYears((newIndex + MinYear) - DisplayedDate.Year); break; default: break; } }
/// <summary> /// Use this method if no data packet is required /// </summary> /// <param name="s">Firmware section to access</param> /// <param name="instruction">Instruction to execute</param> private void msgSend(section s, byte instruction) { byte[] b = new byte[0]; msgSend(s, instruction, b); }
//bytewise constructor public HU320_USB_msg(byte[] msg) { //msg[0] is always 0 for an HID transfer this.sect = (section)msg[1]; this.instruction = msg[2]; this.flags = BitConverter.ToUInt16(msg, 3); data = new byte[msg[5]]; Array.Copy(msg, headerLength + 1, data, 0, data.Length); }
static void BuildSection(string outfile, string sectfile, string buildpath, section s) { byte[] sect = null; if (sectfile.Contains("|")) { string[] fis = sectfile.Split('|'); Console.Write("Evaluating files: "); for(int m = 0; m < fis.Length; m++) { Console.Write(((m==0) ? "" : " & ") + Path.GetFileName(fis[m])); } Console.Write("...\r\n"); sect = MergeFiles(sectfile.Split('|')); } else { Console.WriteLine("Evaluating file: " + Path.GetFileName(sectfile) + "..."); sect = File.ReadAllBytes(sectfile); } byte[] outbyte = null; string tablepath = Path.Combine(buildpath, s.table); string[] args = new string[] { }; string temp = ""; switch (s.type) { case "lzr"://use lunar compress and replace data LCompress.Compress(sect, out outbyte, GetLZType(s)); ReplaceSection(outfile, outbyte, s.offset); break; case "lzi"://use lunar compress and insert data LCompress.Compress(sect, out outbyte, GetLZType(s)); InsertSection(outfile, outbyte, s.offset); break; case "rep"://replace raw data ReplaceSection(outfile, sect, s.offset); break; case "ins"://insert raw data InsertSection(outfile, sect, s.offset); break; case "bpr"://bitplane convert and replace outbyte = ConvertBPP(sect, s.LZType); ReplaceSection(outfile, outbyte, s.offset); break; case "bpi"://bitplane convert and insert outbyte = ConvertBPP(sect, s.LZType); InsertSection(outfile, outbyte, s.offset); break; case "rlr"://rle compression and replace outbyte = RLECompression(sect, s.LZType); ReplaceSection(outfile, outbyte, s.offset); break; case "rli"://rle compression and insert outbyte = RLECompression(sect, s.LZType); InsertSection(outfile, outbyte, s.offset); break; case "sbi"://script build and insert temp = Script.BuildScriptThread(sectfile, "sctemp", tablepath); sect = File.ReadAllBytes(temp); File.Delete(temp); InsertSection(outfile, sect, s.offset); break; case "sbr"://script build and replace temp = Script.BuildScriptThread(sectfile, "sctemp", tablepath); sect = File.ReadAllBytes(temp); File.Delete(temp); ReplaceSection(outfile, sect, s.offset); break; } }
private void addToList(List<section> Lst, string sub) { char lf = (char)10; char cr = (char)13; string[] splitter = { cr.ToString() + lf.ToString() + cr.ToString() + lf.ToString() }; foreach (var item in sub.Split(splitter, StringSplitOptions.RemoveEmptyEntries)) { section tmp = new section(); var lines = item.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); DateTime start; DateTime end; if (DateTime.TryParse(lines[1].Split(new string[] { " --> " }, StringSplitOptions.RemoveEmptyEntries)[0].Replace(',', '.'), out start)) tmp.start = start; else continue; if (DateTime.TryParse(lines[1].Split(new string[] { " --> " }, StringSplitOptions.RemoveEmptyEntries)[1].Replace(',', '.'), out end)) tmp.end = end; else continue; string tmpcontent = ""; for (int i = 2; i < lines.Length; i++) { tmpcontent += lines[i]; } tmp.content = tmpcontent; Lst.Add(tmp); } }
static section DefaultS() { section s = new section(); s.offset = -1; s.path = ""; s.type = ""; s.LZType = ""; s.table = ""; return s; }
static uint GetLZType(section s) { return LCompress.GetLZType(s.LZType); }
/// <summary> /// loadSection loads on ComboBox with an specific DateSection ( Year , Month , Day ) /// </summary> /// <param name="time">The time to display</param> /// <param name="section">The ComboBox position</param> /// <param name="kindOfDisplay">The DateSection to display</param> /// <param name="additionalZero">Display Day and Month with addition Zero (02 / 2) and the Year long or short ( 13 / 2013 )</param> private void loadSection(DateTime time, section section, kindOfDisplay kindOfDisplay, bool additionalZero = false) { ///For the correct ComboBox or TextBlock ComboBox sectionBox = null; TextBlock sectionText = null; ///ComboBox Item for adding new Items to the list ComboBoxItem item = null; ///The Selection Changed Event Handler to delete and add again ///so the Event is not raised while adding items and set the ///selected item SelectionChangedEventHandler handler = null; ///Each section has its own ComboBox, TextBox and Selection Changed Handler ///The switch ensures getting the wright one switch (section) { case section.first: sectionBox = firstSectionComboBox; sectionText = firstSectionTextBlock; handler = firstSectionComboBox_SelectionChanged; sectionBox.SelectionChanged -= handler; break; case section.second: sectionBox = secondSectionComboBox; sectionText = secondSectionTextBlock; handler = secondSectionComboBox_SelectionChanged; sectionBox.SelectionChanged -= handler; break; case section.third: sectionBox = thirdSectionComboBox; sectionText = thirdSectionTextBlock; handler = thirdSectionComboBox_SelectionChanged; sectionBox.SelectionChanged -= handler; break; } ///Clears the sectionBox before recreating sectionBox.Items.Clear(); ///Creates different items for different Date Sections switch (kindOfDisplay) { case kindOfDisplay.day: ///Creates the Days for the Month ( 31 , 30 , 29 , 28 ) for (int i = 1; i <= DateTime.DaysInMonth(time.Year, time.Month); i++) { item = new ComboBoxItem(); ///Displayes a Day with an addition Zero or not ( 8 , 08 ) if (additionalZero && i < 10) item.Content += "0"; item.Content += i.ToString(); ///marks the correct day as selected if (i == time.Day) item.IsSelected = true; ///Adds the item sectionBox.Items.Add(item); } ///Adds the Day of the Week ( Monday ... ) sectionText.Text = time.DayOfWeek.ToString(); break; case kindOfDisplay.month: ///Creats the different Month for (int i = 1; i <= 12; i++) { item = new ComboBoxItem(); ///Displayes a Month with an addition Zero or not ( 8 , 08 ) if (additionalZero && i < 10) item.Content += "0"; item.Content += i.ToString(); ///marks the correct month as selected if (i == time.Month) item.IsSelected = true; ///Adds the item sectionBox.Items.Add(item); } ///Adds the Month as its long form ( January ) sectionText.Text = time.ToString("MMM"); break; case kindOfDisplay.year: ///Creates the Yearitems for (int i = MinYear; i <= MaxYear; i++) { item = new ComboBoxItem(); ///Displayes a Year in two different ways ( 13 , 2013 ) if (additionalZero) item.Content += i.ToString().Substring(3); else item.Content += i.ToString(); ///marks the correct year as selected if (i == time.Year) item.IsSelected = true; ///Adds the item sectionBox.Items.Add(item); } ///Clears the sectionText sectionText.Text = ""; ///Adds the DayLightSaving Flag if (DaylightSavingFlag) { if (time.IsDaylightSavingTime()) sectionText.Text += "S"; else sectionText.Text += "N"; } ///Adds the Leap Year Flag if it is a LeapYear if (LeapYearFlag && DateTime.IsLeapYear(time.Year)) sectionText.Text += " L"; break; } sectionBox.SelectionChanged += handler; }
// Copy ctor public Template(Template srctpl) { tpl = this; fields = new Object[MAX_FIELDS]; sections = new Object[MAX_FIELDS]; head = new node(); addedHead = new node(); addedTail = addedHead; firstSection = new section(); node tail = head; node currNode = srctpl.head; section lastSection = firstSection; section currSection = srctpl.firstSection.nextSection; for (; currSection != null; currSection = currSection.nextSection) { // Copy part before section while (currNode != currSection.preceding) { currNode = currNode.next; tail.next = new node(); tail = tail.next; if (currNode.val.shared) tail.val = _produceField(((field)currNode.val).key); else tail.val = new cell(); tail.val.val = currNode.val.val; } // Create section entry lastSection.nextSection = _produceSection(currSection.key); lastSection = lastSection.nextSection; lastSection.preceding = tail; lastSection.tpl = new Template(currSection.tpl); lastSection.tpl.parent = this; // Copy added content if (currSection.tpl.addedHead.next != null) { int len = 0; for (node n = currSection.tpl.addedHead.next; n != null; n = n.next) len += n.val.val.Length; lastSection.tpl.addedTail.next = new node(); lastSection.tpl.addedTail = lastSection.tpl.addedTail.next; lastSection.tpl.addedTail.val = new cell(); // Make content string StringBuilder sb = new StringBuilder(len); for (node n = currSection.tpl.addedHead.next; n != null; n = n.next) sb.Append(n.val.val); lastSection.tpl.addedTail.val.val = sb.ToString(); } } // Copy rest while ((currNode = currNode.next) != null) { tail.next = new node(); tail = tail.next; if (currNode.val.shared) tail.val = _produceField(((field)currNode.val).key); else tail.val = new cell(); tail.val.val = currNode.val.val; } }
return GetValidationAlgorithm ( #if NET_2_0 section.Validation #else section.ValidationType
private void ExtractComponents() { int countBrackets = 0; component.Clear(); section part = new section(); part.Position = element.Header; part.Start = 0; part.Name = ""; // One line at a time for (int i = 0; i < source.Count; i++) { countBrackets += CountCurlyBrackets(source[i]); // Has the section ended if ((source[i].ToLowerInvariant().Contains(GlobalSettings.fbxStartTake) && !source[i].ToLowerInvariant().Contains(GlobalSettings.fbxNotStartTake)) || countBrackets < 0 || source[i].ToLowerInvariant().Contains(GlobalSettings.fbxCurrentTake)) { // End previous section part.Count = i - part.Start; component.Add(part); // Start next section part = new section(); part.Start = i; if (source[i].ToLowerInvariant().Contains(GlobalSettings.fbxCurrentTake)) { // Is the Current take line part.Position = element.Current; part.Name = ""; } else if (countBrackets >= 0) { // Must be a take part.Position = element.Take; part.Name = GetTakeName(source[i]); } else { // If we've gone past the end of the section without finding a take // Must be the footer part.Position = element.Footer; part.Name = ""; } // Reset the counting remember there could be a bracket in this row countBrackets = Math.Max(CountCurlyBrackets(source[i]), 0); } } // Finish the final section part.Count = source.Count - part.Start; component.Add(part); }