public attack(int dmg, elements ele, string attackName, statusconditions status) { damage = dmg; attackElement = ele; name = attackName; attackStatus = status; }
private static Element create(elements e) { switch (e) { case elements.truss22: return(new ElemTruss2d2()); case elements.truss32: return(new ElemTruss3d2()); case elements.quad4: return(new ElementLin2D()); case elements.quad8r: return(new ElementQuad2D()); case elements.hex8: return(new ElementLin3D()); case elements.hex20r: return(new ElementQuad3D()); default: return(new NonExistentElement()); } }
public pokemon(int hitpoints, string pokemonName, elements pokemonElement, int PokemonSpeed) { isAlive = true; hp = hitpoints; name = pokemonName; pmElement = pokemonElement; setAttacks(); Speed = PokemonSpeed; }
public async Task <ActionResult> DeleteConfirmed(int id) { elements elements = await db.elements.FindAsync(id); db.elements.Remove(elements); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
private static int CalcEleMulti(elements ele1, elements ele2) { if (ele1 == elements.None || ele2 == elements.None) return 1; int eleOffset = Mathf.Abs( ele1 - ele2); if (eleOffset <= 4 ) return eleOffset; else return 8 - eleOffset; }
public void collect(elements e) { if (hasCollected(e)) { return; } collected[(int)e] = true; replaceDexEntry((int)e); }
//returns true if the same element public static bool ElementCheck(elements thisElement, elements otherElement) { if (otherElement == thisElement) { return(true); } else { return(false); } }
static void TreadProc(object a) // while creating new thread pass through function and ONE object { // funtion defines thread's tasks elements b = (elements)a; // to get acces to variables i have to convert object 'a' to element decimal[] x = b.tabela; decimal y = b.zmienna_0; decimal z = b.zmienna_1; decimal min_temp = b.kmin; decimal diff_temp = b.kdiff; int id = 0; if (y == min_temp) { id = 0; } else if (y == min_temp + diff_temp / 4) { id = 1; } else if (y == min_temp + (diff_temp / 4) * 2) { id = 2; } else if (y == min_temp + (diff_temp / 4) * 3) { id = 3; } List <decimal> temp = new List <decimal>(); // creating temp list for (int i = 0; i < x.Length; i++) // x.length = lenght of array created in main function { if (x[i] >= y && x[i] < z) // checking if value from list is in set { temp.Add(x[i]); // if yes it saves to temp list } else if (id == 3 && x[i] == z) { temp.Add(x[i]); } } _sort(temp); // sorting temp list write_temp(temp, id); // saving temp list to list[id] //Console.WriteLine("End using Thread nr {0}", id); Thread.Sleep(5000); // 5 seconds break }
static void TreadProc(object a) { elements b = (elements)a; decimal[] x = b.tabela; decimal y = b.zmienna_0; decimal z = b.zmienna_1; decimal min_temp = b.kmin; decimal diff_temp = b.kdiff; int id = 0; if (y == min_temp) { id = 0; } else if (y == min_temp + diff_temp / 4) { id = 1; } else if (y == min_temp + (diff_temp / 4) * 2) { id = 2; } else if (y == min_temp + (diff_temp / 4) * 3) { id = 3; } List <decimal> temp = new List <decimal>(); for (int i = 0; i < x.Length; i++) { if (x[i] >= y && x[i] < z) { temp.Add(x[i]); } else if (id == 3 && x[i] == z) { temp.Add(x[i]); } } _sort(temp); write_temp(temp, id); Thread.Sleep(5000); // 5s przerwy }
public async Task <ActionResult> Edit([Bind(Include = "Id,path,type_name_id,item_type_id,item_layout_id")] elements elements) { if (ModelState.IsValid) { db.Entry(elements).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.type_name_id = new SelectList(db.ELEMENTS_TYPES, "Id", "TYPE_NAME", elements.type_name_id); ViewBag.item_type_id = new SelectList(db.ITEM_TYPE, "Id", "NAME", elements.item_type_id); ViewBag.item_layout_id = new SelectList(db.layout, "Id", "name", elements.item_layout_id); return(View(elements)); }
// GET: elements/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } elements elements = await db.elements.FindAsync(id); if (elements == null) { return(HttpNotFound()); } return(View(elements)); }
// Construct new element // name - element name public static Element newElement(String name) { elements el = elements.nonexistent; try { el = (elements)System.Enum.Parse(typeof(elements), name); } catch (Exception E) { UTIL.errorMsg("Incorrect element type: " + name); } return(create(el)); }
private static void ApplyColorToThemeElement(this Theme theme, elements element, Color color) { switch (element) { case elements.windowBGGradientStart: theme.BGGradientStart = color; break; case elements.windowBGGradientEnd: theme.BGGradientEnd = color; break; default: break; } }
public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } elements elements = await db.elements.FindAsync(id); if (elements == null) { return(HttpNotFound()); } ViewBag.type_name_id = new SelectList(db.ELEMENTS_TYPES, "Id", "TYPE_NAME", elements.type_name_id); ViewBag.item_type_id = new SelectList(db.ITEM_TYPE, "Id", "NAME", elements.item_type_id); ViewBag.item_layout_id = new SelectList(db.layout, "Id", "name", elements.item_layout_id); return(View(elements)); }
/// <summary> /// Adds an element to the list of combined elements /// The we check if its valid or not and update the UI /// Provides feedback and stores crafted elements /// </summary> /// <param name="Element to be added"></param> public static void addElement(elements e) { combined.Add(e); bool valid = false; foreach ((chemical c, int j) in GameStateManager.singleton.chemicals.Select((x, y) => (x, y))) { // store a mutable copy of our list List <elements> chemComp = c.elements.ToList(); // iterate through the list of combined elements and check if they are in the chemical // remove elements as we go to ensure that something with multiple of the same elements is handled for (int i = 0; i < combined.Count; i++) { if (!chemComp.Contains(combined[i])) { break; } else if (i == combined.Count - 1) { valid = true; } chemComp.Remove(combined[i]); } if (valid) { // while something may be valid, it may not have all the requirements to create a full chemical if (!chemComp.Any()) { craftChemical(c, j); } break; } } if (!valid) { // clear combined combined = new List <elements>(); // show feedback showFeedback(Resources.Load <Sprite>("X")); AudioManager.singleton.audioSource.PlayOneShot(AudioManager.singleton.wrong, 0.7F); } // update feedback t.GetChild(0).GetComponent <Text>().text = combined.Any() ? toString() : ""; }
public async Task <ActionResult> Create([Bind(Include = "ImageUpload,type_name_id, item_type_id, item_layout_id")] ImageViewModel model) { var validImageTypes = new string[] { "image/jpeg", "image/png" }; if (model.ImageUpload == null || model.ImageUpload.ContentLength == 0) { ModelState.AddModelError("ImageUpload", "This field is required"); } else if (!validImageTypes.Contains(model.ImageUpload.ContentType)) { ModelState.AddModelError("ImageUpload", "Please choose either a GIF, JPG or PNG image."); } if (ModelState.IsValid) { var elements = new elements { type_name_id = model.type_name_id }; if (model.ImageUpload != null && model.ImageUpload.ContentLength > 0) { var uploadDir = "~/Files"; var imagePath = Path.Combine(Server.MapPath(uploadDir), model.ImageUpload.FileName); var imageUrl = Path.Combine(uploadDir, model.ImageUpload.FileName); model.ImageUpload.SaveAs(imagePath); elements.path = imageUrl; elements.item_type_id = model.item_type_id; elements.type_name_id = model.type_name_id; elements.item_layout_id = model.item_layout_id; } db.elements.Add(elements); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.type_name_id = new SelectList(db.ELEMENTS_TYPES, "Id", "TYPE_NAME", model.type_name_id); return(View(model)); }
// gets row and col and returns value in table chart for multiplication public static float GetEffectiveness(elements ATK_Element, elements DEF_Element) { // return neutral multiplier if there is no element on the skill // or the defender does not have an element if (ATK_Element == elements.None || DEF_Element == elements.None) { return(1); } // get row and column int row = (int)ATK_Element - 1; int col = (int)DEF_Element - 1; // debug to check if it returns correct multiplier Debug.Log(row); Debug.Log(col); return(chart[row][col]); }
public static TileMeta.GemType elementToGem(elements element) { switch (element) { case MonsterMeta.elements.Sea: return(TileMeta.GemType.Silver); case MonsterMeta.elements.Nature: return(TileMeta.GemType.Green); case MonsterMeta.elements.Wind: return(TileMeta.GemType.Silver); case MonsterMeta.elements.Disease: return(TileMeta.GemType.Purple); case MonsterMeta.elements.Magma: return(TileMeta.GemType.Red); case MonsterMeta.elements.Lightning: return(TileMeta.GemType.Gold); case MonsterMeta.elements.Fight: return(TileMeta.GemType.Fight); default: return(TileMeta.GemType.Fight); } }
public static List <elements> GetElements() { if (connectionState == ConnectionState.Open) { List <elements> result = new List <elements>(); SqliteCommand cmd = new SqliteCommand(SQLiteQueries.GetElements, conn); SqliteDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { elements row = new elements(); row.Populate(reader); result.Add(row); } return(result); } throw new Exception("SQLite: Connection needs to be open to pull data from db."); }
public ActionResult Book(elements elementsforbooking) { var booking = new Booking { ApplicationUserId = 1, //Accomodation = elementsforbooking.Accommodation, AccommodationId = elementsforbooking.Accommodation_Id, Arrival = elementsforbooking.Arrival, Departure = elementsforbooking.Departure, Occupancy = 1, Rating = 1 }; db.Bookings.Add(booking); db.SaveChanges(); return(View(elementsforbooking)); }
public static Theme Convert(string fileName) { Theme _convertedTheme = new Theme(); string _themeFolderPath = (AppDomain.CurrentDomain.BaseDirectory + @"Resource\Themes\"); string _themePath = _themeFolderPath + fileName + ".theme"; string[] _themeRawStringLines = File.ReadAllLines(_themePath); foreach (string _line in _themeRawStringLines) { string[] _elementAndValue = _line.Split('='); int _elementPosition = _elementAndValue[0].IsPresentInEnum(typeof(elements)); elements _thisElement = new elements(); _thisElement = (elements)_elementPosition; Debug.WriteLine("elementPosition is " + _elementPosition + ". That is " + _thisElement); Color _valueColor = _elementAndValue[1].ToColor(); Debug.WriteLine(_valueColor); _convertedTheme.ApplyColorToThemeElement(_thisElement, _valueColor); } return(_convertedTheme); }
static void Main(string[] args) { string modelName = "Model 2 Test"; ModelFactory.ModelName = modelName; //model modelArchisurance = ObjectFactory.NewModel("Archisurance"); //DataSet dsArchisurance = new DataSet(); //string xmlArchiSurance = @"..\..\..\PSN.ModelMate.Schema\Samples\Archisurance\Archisurance-psn.xml"; //dsArchisurance.ReadXml(xmlArchiSurance); ////dsArchisurance.WriteXmlSchema("xmlArchiSurance.xsd"); ////dsArchisurance.WriteXml("xmlArchiSurance.xml"); //var mmpArchisurance = new ModelMateProcessor(ModelMateProcessor.ConvertAMEFFDataSet2Model); //// TODO TODO mmpArchisurance.ProcessModel(dsArchisurance, (DbContext)null, new Collection<model> { modelArchisurance }); string tenantName = "Tenant 0 " + DateTime.Now.ToString(); ModelFactory.TenantName = tenantName; var tenant0 = ModelFactory.NewTenantWithRootFolder(tenantName); tenantName = "Tenant 1 " + DateTime.Now.ToString(); ModelFactory.TenantName = tenantName; var tenant1 = ModelFactory.NewTenant(tenantName, ModelFactory.NewFolder("/", new folder[] { ModelFactory.NewFolder("Model Templates"), ModelFactory.NewFolder("Production Models") } ) ); ModelConst.PropertyDataType dtStringType = ModelConst.PropertyDataType.stringType; propertydef pdefString = ModelFactory.NewPropertyDef("String Propertydef " + DateTime.Now.ToString(), dtStringType); propertydefs pdefs = ModelFactory.NewPropertyDefs(pdefString); ModelConst.ElementType etAC = ModelConst.ElementType.ApplicationComponent; element[] elementArray = new element[10]; for (int iElement = 0; iElement < 10; iElement++) { property p = ModelFactory.NewProperty(ModelFactory.NewValue("Element Property Value " + DateTime.Now.ToString()), pdefString); elementArray[iElement] = ModelFactory.NewElement("Element " + iElement.ToString() + " " + DateTime.Now.ToString(), etAC, p); } elements elements = ModelFactory.NewElements(elementArray); tenantName = "Tenant 2 Test"; ModelFactory.TenantName = tenantName; model model2; //var tenant2 = ModelFactory.NewTenant(tenantName, // ModelFactory.NewFolder("/", // ModelFactory.NewFolder("Production Models", // ModelFactory.NewFolder("HQ Models Folder " + DateTime.Now.ToString(), // model2 = ModelFactory.NewModel(modelName, ModelConst.LANG_EN, // elements, pdefs // ) // ) // ) // ) // ); var tenant2 = ModelFactory.NewTenant(tenantName, ModelFactory.NewFolder("/", model2 = ModelFactory.NewModel(modelName, ModelConst.LANG_EN, elements, pdefs ) ) ); Console.WriteLine("Tenant.tenant_Id " + tenant2.tenant_Id.ToString()); foreach (folders fs in tenant2.folders) { Console.WriteLine("Folders.tenant_Id " + fs.tenant_Id.ToString()); Console.WriteLine("Folders.folders_Id " + fs.folders_Id.ToString()); foreach (folder f in fs.folder) { Console.WriteLine("Folder " + f.folders_Id.ToString()); Console.WriteLine("Folder " + f.folder_Id.ToString()); } } var name = ModelFactory.NewName("Model 2 Name " + DateTime.Now.ToString()); model2.name.Add(name); var documentation = ModelFactory.NewDocumentation("Model 2 Documentation " + DateTime.Now.ToString()); model2.documentation.Add(documentation); var metadata = ModelFactory.NewMetadata( ModelFactory.NewProperty(ModelFactory.NewValue("Model 2 Metadata Value " + DateTime.Now.ToString()), pdefString) ); model2.metadata.Add(metadata); var properties = ModelFactory.NewProperties( ModelFactory.NewProperty(ModelFactory.NewValue("Model 2 Property Value " + DateTime.Now.ToString()), pdefString) ); model2.properties.Add(properties); var relationship1 = ModelFactory.NewRelationship("Association Relationship " + DateTime.Now.ToString(), ModelConst.RelationshipType.AssociationRelationship, elementArray[0], elementArray[1] ); var relationships = ModelFactory.NewRelationships(relationship1); model2.relationships.Add(relationships); var organization = ModelFactory.NewOrganization( ModelFactory.NewItem(elementArray[0], ModelFactory.NewItem(null, ModelFactory.NewItem(elementArray[1] ) ) ) ); model2.organization.Add(organization); var style1 = ModelFactory.NewStyle( ModelFactory.NewFillColor(255, 0, 0), ModelFactory.NewLineColor(0, 255, 0), ModelFactory.NewFont("Times Roman", (float)10.5, "bold", ModelFactory.NewColor(0, 0, 255)), 3 ); var style2 = ModelFactory.NewStyle( ModelFactory.NewFillColor(255, 0, 0), ModelFactory.NewLineColor(0, 255, 0), ModelFactory.NewFont("Times Roman", (float)12.5, "bold", ModelFactory.NewColor(0, 0, 255)), 3 ); var node0 = ModelFactory.NewNode("Node 0 " + DateTime.Now.ToString(), 0, 0, 0, 50, 50, 50, elementArray[0], null, null, style1, new node[] { ModelFactory.NewNode("Sub Node " + DateTime.Now.ToString(), 10, 10, 10, 25, 25, 25, elementArray[3]) } ); var node1 = ModelFactory.NewNode("Node 1 " + DateTime.Now.ToString(), 100, 100, 100, 50, 50, 50, elementArray[1], null, null, style2, null ); var bendpoint1 = ModelFactory.NewBendPoint(25, 25, 25); var connection1 = ModelFactory.NewConnection("Connection 1 " + DateTime.Now.ToString(), node0, node1, relationship1 ); connection1.bendpoint.Add(bendpoint1); view view2; var views = ModelFactory.NewViews( view2 = ModelFactory.NewView("View 2 " + DateTime.Now.ToString(), ModelConst.ViewType.Layered, new node[] { node0, node1 }, new connection[] { connection1 } ) ); model2.views.Add(views); tenant2.processinghistory.Add( ModelFactory.NewProcessinghistory( ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Processinghistory " + DateTime.Now.ToString(), ModelConst.TimesnapCategory.processinghistory, "Subcategory " + DateTime.Now.ToString(), null, null, ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString ) ) ) ); tenant2.usage.Add( ModelFactory.NewUsage( ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(), ModelConst.TimesnapCategory.usage, "Subcategory " + DateTime.Now.ToString(), null, null, ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString ) ) ) ); tenant2.performance.Add( ModelFactory.NewPerformance( ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(), ModelConst.TimesnapCategory.performance, "Subcategory " + DateTime.Now.ToString(), null, null, ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString ) ) ) ); tenant2.management.Add( ModelFactory.NewManagement( ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Management " + DateTime.Now.ToString(), ModelConst.TimesnapCategory.management, "Subcategory " + DateTime.Now.ToString(), null, null, ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString ) ) ) ); model2.processinghistory.Add( ModelFactory.NewProcessinghistory( ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Processinghistory " + DateTime.Now.ToString(), ModelConst.TimesnapCategory.processinghistory, "Subcategory " + DateTime.Now.ToString(), null, null, ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString ) ) ) ); model2.usage.Add( ModelFactory.NewUsage( ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(), ModelConst.TimesnapCategory.usage, "Subcategory " + DateTime.Now.ToString(), null, null, ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString ) ) ) ); model2.performance.Add( ModelFactory.NewPerformance( ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(), ModelConst.TimesnapCategory.performance, "Subcategory " + DateTime.Now.ToString(), null, null, ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString ) ) ) ); model2.management.Add( ModelFactory.NewManagement( ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Management " + DateTime.Now.ToString(), ModelConst.TimesnapCategory.management, "Subcategory " + DateTime.Now.ToString(), null, null, ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString ) ) ) ); elementArray[0].processinghistory.Add( ModelFactory.NewProcessinghistory( ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Processinghistory " + DateTime.Now.ToString(), ModelConst.TimesnapCategory.processinghistory, "Subcategory " + DateTime.Now.ToString(), null, null, ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString ) ) ) ); elementArray[0].usage.Add( ModelFactory.NewUsage( ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(), ModelConst.TimesnapCategory.usage, "Subcategory " + DateTime.Now.ToString(), null, null, ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString ) ) ) ); elementArray[0].performance.Add( ModelFactory.NewPerformance( ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(), ModelConst.TimesnapCategory.performance, "Subcategory " + DateTime.Now.ToString(), null, null, ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString ) ) ) ); elementArray[0].management.Add( ModelFactory.NewManagement( ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Management " + DateTime.Now.ToString(), ModelConst.TimesnapCategory.management, "Subcategory " + DateTime.Now.ToString(), null, null, ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString ) ) ) ); view2.processinghistory.Add( ModelFactory.NewProcessinghistory( ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Processinghistory " + DateTime.Now.ToString(), ModelConst.TimesnapCategory.processinghistory, "Subcategory " + DateTime.Now.ToString(), null, null, ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString ) ) ) ); view2.usage.Add( ModelFactory.NewUsage( ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(), ModelConst.TimesnapCategory.usage, "Subcategory " + DateTime.Now.ToString(), null, null, ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString ) ) ) ); view2.performance.Add( ModelFactory.NewPerformance( ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(), ModelConst.TimesnapCategory.performance, "Subcategory " + DateTime.Now.ToString(), null, null, ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString ) ) ) ); view2.management.Add( ModelFactory.NewManagement( ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Management " + DateTime.Now.ToString(), ModelConst.TimesnapCategory.management, "Subcategory " + DateTime.Now.ToString(), null, null, ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString ) ) ) ); //using (XmlWriter writer = XmlWriter.Create("model2.xml")) //{ // //XmlSerializer serializer = new XmlSerializer(typeof(model)); // DataContractSerializerSettings settings = new DataContractSerializerSettings(); // DataContractSerializer serializer = new DataContractSerializer(typeof(model)); // serializer.WriteObject(writer, model2); // writer.Close(); //} string xmlSchemaFile = @"..\..\..\PSN.ModelMate.Schema\Schema\Reference ModelGood9.xsd"; // DataSet ds = new DataSet(); // ds.ReadXmlSchema(xmlSchemaFile); // BUG DataSet ds2 = new DataSet(); // BUG ds2.ReadXmlSchema(xmlSchemaFile); //DataTable dttenant = ds.Tables["tenant"]; //DataRow drtentant1 = dttenant.NewRow(); //DataRow drtentant2 = ds.Tables["tenant"].NewRow(); //DataTable dtfolders = ds.Tables["folders"]; //DataTable dtfolder = ds.Tables["folder"]; //DataTable dtmodels = ds.Tables["models"]; //DataTable dtmodel = ds.Tables["model"]; //DataTable dtprocessinghistory = ds.Tables["processinghistory"]; //DataTable dtusage = ds.Tables["usage"]; //DataTable dtperformance = ds.Tables["performance"]; //DataTable dtmanagement = ds.Tables["management"]; //DataTable dttimesnap = ds.Tables["timesnap"]; //DataTable dtproperties = ds.Tables["properties"]; //DataTable dtproperty = ds.Tables["property"]; //DataTable dtpropertydefs = ds.Tables["propertydefs"]; //DataTable dtpropertydef = ds.Tables["propertydef"]; //DataTable dtelements = ds.Tables["elements"]; //DataTable dtelement = ds.Tables["element"]; //DataTable dtrelationships = ds.Tables["relationships"]; //DataTable dtrelationship = ds.Tables["relationship"]; //DataTable dtviews = ds.Tables["views"]; //DataTable dtview = ds.Tables["view"]; //DataTable dtconnection = ds.Tables["connection"]; //DataTable dtnode = ds.Tables["node"]; //DataTable dtstyle = ds.Tables["style"]; //DataTable dtfont = ds.Tables["font"]; //DataTable dtfillColor = ds.Tables["fillColor"]; //DataTable dtlineColor = ds.Tables["lineColor"]; //DataTable dtcolor = ds.Tables["color"]; //DataTable dtbendpoint = ds.Tables["bendpoint"]; //DataTable dtmetadata = ds.Tables["metadata"]; //DataTable dtorganization = ds.Tables["organization"]; //DataTable dtitem = ds.Tables["item"]; //DataTable dtname = ds.Tables["name"]; //DataTable dtvalue = ds.Tables["value"]; //DataTable dtdocumentation = ds.Tables["documentation"]; //DataTable dtlabel = ds.Tables["label"]; using (var ctx = new ModelMateEFModel9Context()) { ctx.Database.Log = Console.Write; ctx.tenant.Add(tenant0); ModelDump.DisplayTrackedEntities("Add tenant0", ctx.ChangeTracker); ctx.SaveChanges(); ModelDump.DisplayTrackedEntities("Save tenant0", ctx.ChangeTracker); ctx.tenant.Add(tenant1); ctx.SaveChanges(); ctx.tenant.Add(tenant2); ModelDump.DisplayTrackedEntities("Add tenant2", ctx.ChangeTracker); ctx.SaveChanges(); ModelDump.DisplayTrackedEntities("Save tenant2", ctx.ChangeTracker); ModelDump.DisplayDBPropertyValues("tenant2", ctx.Entry(tenant2).CurrentValues, null); ModelDump.DisplayDBPropertyValues("model2", ctx.Entry(model2).CurrentValues, null); Console.WriteLine("Tenant.tenant_Id " + tenant2.tenant_Id.ToString()); foreach (folders fs in tenant2.folders) { Console.WriteLine("Folders.tenant_Id " + fs.tenant_Id.ToString()); Console.WriteLine("Folders.folders_Id " + fs.folders_Id.ToString()); foreach (folder f in fs.folder) { Console.WriteLine("Folder " + f.folders_Id.ToString()); Console.WriteLine("Folder " + f.folder_Id.ToString()); } } folders fs0 = tenant2.folders.ElementAt(0); ModelDump.DisplayDBPropertyValues("fs0", ctx.Entry(fs0).CurrentValues, null); folder f0 = fs0.folder.ElementAt(0); ModelDump.DisplayDBPropertyValues("f0", ctx.Entry(f0).CurrentValues, null); Console.WriteLine("RECURSION =================================================="); //DataSet dsTenant = new DataSet(); //dsTenant.ReadXmlSchema(xmlSchemaFile); ////dsTenant.Tables["tenant"].Namespace = "http://www.w3.org/XML/1998/namespace"; ////dsTenant.Tables["tenant"].Prefix = "xml"; //var tenant = ctx.tenant.Find(new object[] { tenant2.tenant_Id }); //var mmp = new ModelMateProcessor(ModelMateProcessor.ProcessObjectPopulateXMLDataSet); //mmp.ProcessTenant(dsTenant, (DbContext)ctx, new Collection<tenant> { tenant }); //dsTenant.WriteXml("tentantds.xml"); string modelSchemaFile = @"..\..\..\PSN.ModelMate.Schema\Schema\ModelMateModel9.xsd"; DataSet dsModel = new DataSet(); dsModel.ReadXmlSchema(modelSchemaFile); //DataSet ds3 = dsModel.Copy(); //var mmpModel = new ModelMateProcessor(); var mmpModel = new ModelProcessor(ModelProcessor.ConvertModel2AMEFFDataSet); mmpModel.ProcessModel(dsModel, (DbContext)ctx, new Collection <model> { model2 }); dsModel.WriteXml("modelds.xml", XmlWriteMode.IgnoreSchema); string filename = "modelds2.xml"; mmpModel.SaveAMEFFDataSetAsXML(dsModel, filename); tenant2.version = ModelConst.TENANT_TESTVERSION; var name2 = ModelFactory.NewName("Model Name FR " + DateTime.Now.ToString(), ModelConst.LANG_FR); model2.name.Add(name2); var name3 = ModelFactory.NewName("Model Name EN " + DateTime.Now.ToString()); model2.name.Add(name3); ModelDump.DisplayTrackedEntities("Change tenant2", ctx.ChangeTracker); ctx.SaveChanges(); ModelDump.DisplayTrackedEntities("Save tenant2", ctx.ChangeTracker); object[] keys = { -1702823521 }; tenant tenant9 = ctx.tenant.Find(keys); //ctx.tenant.Remove(tenantDelete); //ctx.SaveChanges(); } Console.WriteLine("Press enter to exist..."); Console.ReadLine(); }
var(elements, attributes) = GetObjects(XDocument.Load(path), xpath, namespaces);
Reverse(elements, position, length);
static void Main(string[] args) { const string tTargetName = "Tenant 2 Test"; string tTargetIdentifier = Util.MakeIdentifierRootIdentifier(typeof(tenant).Name, Util.TrimWhitespace(tTargetName)); const string mTargetName = "Model 2 Test"; string mTargetIdentifier = Util.MakeIdentifierFromParentIdentifier( Util.MakeIdentifierRootIdentifier(typeof(tenant).Name, tTargetName), typeof(model).Name, Util.TrimWhitespace(mTargetName)); tenant tTarget = null; model mTarget = null; using (var ctxTarget = new ModelMateEFModel9Context()) { ctxTarget.Database.Log = Console.Write; Console.WriteLine("LazyLoadingEnabled: " + ctxTarget.Configuration.LazyLoadingEnabled.ToString()); tTarget = ModelFinder.FindTenant(ctxTarget, tTargetIdentifier, ""); ModelDump.DisplayDBPropertyValues("tTarget", ctxTarget.Entry(tTarget).CurrentValues, null); mTarget = ModelFinder.FindModel(ctxTarget, tTarget, mTargetIdentifier, null); ModelDump.DisplayDBPropertyValues("mTarget", ctxTarget.Entry(mTarget).CurrentValues, null); element[] es0 = ModelFinder.FindElements(ctxTarget, tTarget, mTarget, ModelConst.ElementType.ApplicationComponent); Console.WriteLine("es0.Count: " + es0.Count <element>().ToString()); ModelDump.DisplayDBPropertyValues("es0", ctxTarget.Entry(es0[0]).CurrentValues, null); es0 = ModelFinder.FindElements(ctxTarget, tTarget, mTarget, ModelConst.ElementType.AllElementTypes); Console.WriteLine("es0.Count: " + es0.Count <element>().ToString()); ModelDump.DisplayDBPropertyValues("es0", ctxTarget.Entry(es0[0]).CurrentValues, null); relationship[] rs0 = ModelFinder.FindRelationships(ctxTarget, tTarget, mTarget, ModelConst.RelationshipType.AllRelationshipTypes); Console.WriteLine("es0.Count: " + es0.Count <element>().ToString()); ModelDump.DisplayDBPropertyValues("es0", ctxTarget.Entry(es0[0]).CurrentValues, null); foreach (relationship r in rs0) { element eSource = ModelFinder.FindElement(ctxTarget, tTarget, mTarget, r.source, null); element eTarget = ModelFinder.FindElement(ctxTarget, tTarget, mTarget, r.target, null); ModelDump.DisplayDBPropertyValues("eSource", ctxTarget.Entry(eSource).CurrentValues, null); ModelDump.DisplayDBPropertyValues("r", ctxTarget.Entry(r).CurrentValues, null); ModelDump.DisplayDBPropertyValues("eTarget", ctxTarget.Entry(eTarget).CurrentValues, null); } } Console.WriteLine("Press enter to exit..."); Console.ReadLine(); string tSourceName = "Tenant 2"; ModelFactory.TenantName = tSourceName; string mSourceIdentifier = mTargetIdentifier; string mSourceName = mTargetName; // "Model 2 " + DateTime.Now.ToString(); ModelFactory.ModelName = mSourceName; tenant tSource = null; model mSource = null; propertydef pdef1 = ModelFactory.NewPropertyDef("String Propertydef 1", ModelConst.PropertyDataType.stringType); propertydef pdef2 = ModelFactory.NewPropertyDef("Boolean Propertydef 2", ModelConst.PropertyDataType.booleanType); propertydef pdef3 = ModelFactory.NewPropertyDef("Number Propertydef 3", ModelConst.PropertyDataType.numberType); propertydef[] pdfArray = new propertydef[] { pdef1, pdef2, pdef3 }; propertydefs pdefs = ModelFactory.NewPropertyDefs(pdfArray); ModelConst.ElementType etAC = ModelConst.ElementType.ApplicationComponent; element[] elementArray = new element[10]; for (int iElement = 0; iElement < 10; iElement++) { property p1 = ModelFactory.NewProperty(ModelFactory.NewValue("Element Property Value " + DateTime.Now.ToString()), pdfArray[iElement % 3]); property p2 = ModelFactory.NewProperty(ModelFactory.NewValue("Element Property Value " + DateTime.Now.ToString()), pdfArray[(iElement + 1) % 3]); properties ps = ModelFactory.NewProperties(new property[] { p1, p2 }); elementArray[iElement] = ModelFactory.NewElement("Element " + iElement.ToString(), etAC, ps); } elements elements = ModelFactory.NewElements(elementArray); tSource = ModelFactory.NewTenant(tSourceName, ModelFactory.NewFolder("/", mSource = ModelFactory.NewModel(mSourceName, ModelConst.LANG_EN, elements, pdefs ) ) ); mSource.version = "9.0"; var properties = ModelFactory.NewProperties(ModelFactory.NewProperty(ModelFactory.NewValue("Model 2 Value 1"), pdef1)); mSource.properties.Add(properties); //var name = ModelFactory.NewName("Model 2 Name " + DateTime.Now.ToString()); //model3.name.Add(name); var relationship1 = ModelFactory.NewRelationship("Association Relationship 1", ModelConst.RelationshipType.AssociationRelationship, elementArray[0], elementArray[1] ); var relationship2 = ModelFactory.NewRelationship("Association Relationship 2", ModelConst.RelationshipType.AssociationRelationship, elementArray[2], elementArray[3] ); var relationships = ModelFactory.NewRelationships(new relationship[] { relationship1, relationship2 }); mSource.relationships.Add(relationships); Console.WriteLine("Press enter to exit..."); Console.ReadLine(); //var organization = ModelFactory.NewOrganization( // ModelFactory.NewItem(elementArray[0], // ModelFactory.NewItem(null, // ModelFactory.NewItem(elementArray[1] // ) // ) // ) // ); //model3.organization.Add(organization); //var documentation = ModelFactory.NewDocumentation("Model 2 Documentation " + DateTime.Now.ToString()); //model3.documentation.Add(documentation); //var metadata = ModelFactory.NewMetadata( // ModelFactory.NewProperty(ModelFactory.NewValue("Model 2 Metadata Value " + DateTime.Now.ToString()), pdefString) // ); //model3.metadata.Add(metadata); //var style1 = ModelFactory.NewStyle( // ModelFactory.NewFillColor(255, 0, 0), // ModelFactory.NewLineColor(0, 255, 0), // ModelFactory.NewFont("Times Roman", (float)10.5, "bold", ModelFactory.NewColor(0, 0, 255)), 3 // ); //var style2 = ModelFactory.NewStyle( // ModelFactory.NewFillColor(255, 0, 0), // ModelFactory.NewLineColor(0, 255, 0), // ModelFactory.NewFont("Times Roman", (float)12.5, "bold", ModelFactory.NewColor(0, 0, 255)), 3 //); //var node0 = ModelFactory.NewNode("Node 0 " + DateTime.Now.ToString(), // 0, 0, 0, 50, 50, 50, // elementArray[0], null, null, style1, // new node[] { ModelFactory.NewNode("Sub Node " + DateTime.Now.ToString(), // 10, 10, 10, 25, 25, 25, // elementArray[3]) // } // ); //var node1 = ModelFactory.NewNode("Node 1 " + DateTime.Now.ToString(), // 100, 100, 100, 50, 50, 50, // elementArray[1], null, null, style2, // null // ); //var bendpoint1 = ModelFactory.NewBendPoint(25, 25, 25); //var connection1 = ModelFactory.NewConnection("Connection 1 " + DateTime.Now.ToString(), // node0, node1, relationship1 // ); //connection1.bendpoint.Add(bendpoint1); //view view2; //var views = ModelFactory.NewViews( // view2 = ModelFactory.NewView("View 2 " + DateTime.Now.ToString(), ModelConst.ViewType.Layered, // new node[] { // node0, node1 // }, // new connection[] { connection1 } // ) // ); //model2.views.Add(views); //tenant2.processinghistory.Add( //ModelFactory.NewProcessinghistory( // ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Processinghistory " + DateTime.Now.ToString(), // ModelConst.TimesnapCategory.processinghistory, "Subcategory " + DateTime.Now.ToString(), // null, null, // ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString // ) // ) //) //); //tenant2.usage.Add( // ModelFactory.NewUsage( // ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(), // ModelConst.TimesnapCategory.usage, "Subcategory " + DateTime.Now.ToString(), // null, null, // ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString // ) // ) // ) // ); //tenant2.performance.Add( // ModelFactory.NewPerformance( // ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(), // ModelConst.TimesnapCategory.performance, "Subcategory " + DateTime.Now.ToString(), // null, null, // ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString // ) // ) // ) // ); //tenant2.management.Add( // ModelFactory.NewManagement( // ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Management " + DateTime.Now.ToString(), // ModelConst.TimesnapCategory.management, "Subcategory " + DateTime.Now.ToString(), // null, null, // ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString // ) // ) // ) // ); //model2.processinghistory.Add( // ModelFactory.NewProcessinghistory( // ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Processinghistory " + DateTime.Now.ToString(), // ModelConst.TimesnapCategory.processinghistory, "Subcategory " + DateTime.Now.ToString(), // null, null, // ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString // ) // ) // ) // ); //model2.usage.Add( // ModelFactory.NewUsage( // ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(), // ModelConst.TimesnapCategory.usage, "Subcategory " + DateTime.Now.ToString(), // null, null, // ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString // ) // ) // ) // ); //model2.performance.Add( // ModelFactory.NewPerformance( // ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(), // ModelConst.TimesnapCategory.performance, "Subcategory " + DateTime.Now.ToString(), // null, null, // ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString // ) // ) // ) // ); //model2.management.Add( // ModelFactory.NewManagement( // ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Management " + DateTime.Now.ToString(), // ModelConst.TimesnapCategory.management, "Subcategory " + DateTime.Now.ToString(), // null, null, // ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString // ) // ) // ) // ); //elementArray[0].processinghistory.Add( //ModelFactory.NewProcessinghistory( // ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Processinghistory " + DateTime.Now.ToString(), // ModelConst.TimesnapCategory.processinghistory, "Subcategory " + DateTime.Now.ToString(), // null, null, // ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString // ) // ) //) //); //elementArray[0].usage.Add( // ModelFactory.NewUsage( // ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(), // ModelConst.TimesnapCategory.usage, "Subcategory " + DateTime.Now.ToString(), // null, null, // ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString // ) // ) // ) // ); //elementArray[0].performance.Add( // ModelFactory.NewPerformance( // ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(), // ModelConst.TimesnapCategory.performance, "Subcategory " + DateTime.Now.ToString(), // null, null, // ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString // ) // ) // ) // ); //elementArray[0].management.Add( // ModelFactory.NewManagement( // ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Management " + DateTime.Now.ToString(), // ModelConst.TimesnapCategory.management, "Subcategory " + DateTime.Now.ToString(), // null, null, // ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString // ) // ) // ) // ); //view2.processinghistory.Add( // ModelFactory.NewProcessinghistory( // ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Processinghistory " + DateTime.Now.ToString(), // ModelConst.TimesnapCategory.processinghistory, "Subcategory " + DateTime.Now.ToString(), // null, null, // ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString // ) // ) // ) // ); //view2.usage.Add( // ModelFactory.NewUsage( // ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(), // ModelConst.TimesnapCategory.usage, "Subcategory " + DateTime.Now.ToString(), // null, null, // ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString // ) // ) // ) // ); //view2.performance.Add( // ModelFactory.NewPerformance( // ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(), // ModelConst.TimesnapCategory.performance, "Subcategory " + DateTime.Now.ToString(), // null, null, // ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString // ) // ) // ) // ); //view2.management.Add( // ModelFactory.NewManagement( // ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Management " + DateTime.Now.ToString(), // ModelConst.TimesnapCategory.management, "Subcategory " + DateTime.Now.ToString(), // null, null, // ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString // ) // ) // ) // ); using (var ctxTarget = new ModelMateEFModel9Context()) { ctxTarget.Database.Log = Console.Write; tTarget = ModelFinder.FindTenant(ctxTarget, tTargetIdentifier, ""); ModelDump.DisplayDBPropertyValues("tTarget", ctxTarget.Entry(tTarget).CurrentValues, null); folders fs0 = tTarget.folders.ElementAt(0); ModelDump.DisplayDBPropertyValues("fs0", ctxTarget.Entry(fs0).CurrentValues, null); folder f0 = fs0.folder.ElementAt(0); ModelDump.DisplayDBPropertyValues("f0", ctxTarget.Entry(f0).CurrentValues, null); mTarget = ModelFinder.FindModel(ctxTarget, tTarget, mTargetIdentifier, null); ModelDump.DisplayDBPropertyValues("mTarget", ctxTarget.Entry(mTarget).CurrentValues, null); ModelMigrator.MigrateModel(ctxTarget, tTarget, f0, mSource, PCOOperation.merge, PCOOperation.merge, true); } Console.WriteLine("Press enter to exist..."); Console.ReadLine(); }
protected void Page_Load(object sender, EventArgs e) { i = (int)Session["i"]; el = (elements)Session["el"]; myDB = (database)Session["myDB"]; curUser = (user)Session["curUser"]; boardName = (string)Session["boardName"]; queryItems = (List<product_image>)Session["queryItems"]; usersBoardColl = myDB.getUsersBoardCollection(curUser); p = (product_image)Session["p"]; setImage(p); }
// ReSharper disable once PossibleMultipleEnumeration BindVisibilityProperties(elements, viewModel);
private void button3_Click(object sender, EventArgs e) { decimal max = _array.Max(); decimal min = _array.Min(); decimal diff = max - min; decimal r_0 = min; decimal r_1 = min + diff / 4; List <elements> all_elem = new List <elements>(); temp_1 = new List <List <decimal> >(); for (int i = 0; i < 4; i++) { temp_1.Add(new List <decimal>()); } for (int i = 0; i < 4; i++) { decimal x = i * diff / 4; decimal a_1 = (r_0 + x); decimal a_2 = (r_1 + x); elements all = new elements(_array, a_1, a_2, min, diff); all_elem.Add(all); } Thread raz = new Thread(new ParameterizedThreadStart(TreadProc)); raz.Start(((object)all_elem[0])); Thread dwa = new Thread(new ParameterizedThreadStart(TreadProc)); dwa.Start(((object)all_elem[1])); Thread trzy = new Thread(new ParameterizedThreadStart(TreadProc)); trzy.Start(((object)all_elem[2])); Thread czt = new Thread(new ParameterizedThreadStart(TreadProc)); czt.Start(((object)all_elem[3])); raz.Join(); dwa.Join(); trzy.Join(); czt.Join(); int z = 0; for (int i = 0; i < temp_1.Count; i++) { if (i > 0) { z += temp_1[i - 1].Count; } for (int j = 0; j < temp_1[i].Count; j++) { _array[z + j] = temp_1[i][j]; } } for (int i = 0; i < 100000; i++) { dataGridView2.Rows[i].Cells[1].Value = _array[i]; } }
public static int CalculateDamage(int atkDamage, elements atkEle, int defArmour, elements defEle) { int elementalMultiplier = 1 + CalcEleMulti(atkEle,defEle); int damage = (atkDamage * elementalMultiplier) - defArmour; return damage; }
private void button_sort_Click(object sender, EventArgs e) { decimal max = _array.Max(); decimal min = _array.Min(); decimal diff = max - min; decimal r_0 = min; // lower border of searching min decimal r_1 = min + diff / 4; // upper border of searching diff/4 List <elements> all_elem = new List <elements>(); // List of elements temp_1 = new List <List <decimal> >(); // List of lists for (int i = 0; i < 4; i++) { temp_1.Add(new List <decimal>()); // filling list with list, each will be containing numbers eg for set '0' 0 - 100 } for (int i = 0; i < 4; i++) // filling elements each have different attributes { // element nr 0 stores whole array, lower border = 0 i upper border = 100 decimal x = i * diff / 4; decimal a_1 = (r_0 + x); decimal a_2 = (r_1 + x); elements all = new elements(_array, a_1, a_2, min, diff); all_elem.Add(all); } Thread raz = new Thread(new ParameterizedThreadStart(TreadProc)); // creating thread nr 1 and passing element nr 0 raz.Start(((object)all_elem[0])); Thread dwa = new Thread(new ParameterizedThreadStart(TreadProc)); dwa.Start(((object)all_elem[1])); Thread trzy = new Thread(new ParameterizedThreadStart(TreadProc)); trzy.Start(((object)all_elem[2])); Thread czt = new Thread(new ParameterizedThreadStart(TreadProc)); czt.Start(((object)all_elem[3])); raz.Join(); // main function waits as first thread finishes work dwa.Join(); trzy.Join(); czt.Join(); int z = 0; // help variable, calculates where we should insert data into main array for (int i = 0; i < temp_1.Count; i++) // temp_1.count - number of lists { if (i > 0) { z += temp_1[i - 1].Count; // increases variable by length of previous list in order to start in good place } for (int j = 0; j < temp_1[i].Count; j++) // temp[i].count - length of single list { _array[z + j] = temp_1[i][j]; // temp_1[i][j] - list number i and place on list j } } for (int i = 0; i < 100000; i++) { dataGridView2.Rows[i].Cells[1].Value = _array[i]; } }
public element(string name, uint count) { if (IsElement(name)) this.name = GetElement(name); this.count = count; }
double thelup = HUGE8; /* is initialized only once at load time */ unsafe int calc(int planet, double jd_ad, int flag, double *alng, double *arad, double *alat, double *alngspeed) { double c, s, x, knn, knv; double rp = 0.0, zp = 0.0; /* needed to call hel! */ double *azet = alat; bool calc_geo, calc_helio, calc_apparent, calc_speed, calc_nut; /* helup checks whether it was already called with same time */ helup(jd_ad); /* we could return now if we only wanted to compute ecl and nut */ calc_helio = (flag & CALC_BIT_HELIO) != 0; calc_geo = !calc_helio; calc_apparent = (flag & CALC_BIT_NOAPP) == 0; calc_nut = (flag & CALC_BIT_NONUT) == 0; calc_speed = (flag & CALC_BIT_SPEED) != 0; /* ** it is necessary to compute EARTH in the following cases: ** heliocentric MOON or EARTH ** geocentric any planet except MOON or nodes or LILITH */ if (calc_helio && (planet == MOON || planet == EARTH) || calc_geo && planet != MOON && planet != MEAN_NODE && planet != TRUE_NODE && planet != LILITH) { if (earthrem.calculation_time != jd_ad) { hel(EARTH, jd_ad, alng, arad, azet, alngspeed, &rp, &zp); /* store earthdata for geocentric calculation: */ earthrem.lng = *alng; earthrem.rad = *arad; earthrem.zet = *azet; earthrem.lngspeed = *alngspeed; earthrem.radspeed = rp; earthrem.zetspeed = zp; earthrem.calculation_time = jd_ad; } } switch (planet) { case EARTH: /* has been already computed */ *alng = earthrem.lng; *arad = earthrem.rad; *azet = earthrem.zet; *alngspeed = earthrem.lngspeed; rp = earthrem.radspeed; zp = earthrem.zetspeed; if (calc_geo) /* SUN seen from earth */ { *alng = smod8360(*alng + 180.0); *azet = -*azet; } if (calc_apparent) { *alng = *alng - 0.0057683 * (*arad) * (*alngspeed); } break; case MOON: moon(alng, arad, azet); moonrem.lng = *alng; /* moonrem will be used for TRUE_NODE */ moonrem.rad = *arad; moonrem.zet = *azet; *alngspeed = 12; moonrem.calculation_time = jd_ad; if (calc_helio || calc_speed) /* get a second moon position */ { double lng2, rad2, zet2; helup(jd_ad + MOON_SPEED_INTERVAL); moon(&lng2, &rad2, &zet2); helup(jd_ad); if (calc_helio) /* moon as seen from sun */ { togeo(earthrem.lng, -earthrem.rad, moonrem.lng, moonrem.rad, moonrem.zet, alng, arad); togeo(earthrem.lng + MOON_SPEED_INTERVAL * earthrem.lngspeed, -(earthrem.rad + MOON_SPEED_INTERVAL * earthrem.radspeed), lng2, rad2, zet2, &lng2, &rad2); } *alngspeed = diff8360(lng2, *alng) / MOON_SPEED_INTERVAL; /* rp = (rad2 - *arad) / MOON_SPEED_INTERVAL; */ /* zp = (zet2 - moonrem.zet) / MOON_SPEED_INTERVAL; */ } *alat = RADTODEG * Math.Asin(*azet / *arad); /* ** light time correction, not applied for moon or nodes; ** moon would have only term of ca. 0.02", see Expl.Sup.1961 p.109 */ break; case MERCURY: case VENUS: case MARS: case JUPITER: case SATURN: case URANUS: case NEPTUNE: case PLUTO: case CHIRON: case CERES: case PALLAS: case JUNO: case VESTA: if (hel(planet, jd_ad, alng, arad, azet, alngspeed, &rp, &zp) != 0) { return(-1); /* outer planets can fail if out of ephemeris range */ } if (calc_geo) { /* geocentric */ double lng1 = 0.0, rad1 = 0.0, lng2 = 0.0, rad2 = 0.0; togeo(earthrem.lng, earthrem.rad, *alng, *arad, *azet, &lng1, &rad1); togeo(earthrem.lng + earthrem.lngspeed, earthrem.rad + earthrem.radspeed, *alng + *alngspeed, *arad + rp, *azet + zp, &lng2, &rad2); *alng = lng1; *arad = rad1; *alngspeed = diff8360(lng2, lng1); /* rp = rad2 - rad1; */ } *alat = RADTODEG * Math.Asin(*azet / *arad); if (calc_apparent) { *alng = *alng - 0.0057683 * (*arad) * (*alngspeed); } break; case MEAN_NODE: *alng = smod8360(el[MOON].kn); /* * the distance of the node is the 'orbital parameter' p = a (1-e^2); * Our current use of the axis a is wrong, but is never used. */ *arad = pd[MOON].axis; *alat = 0.0; *alngspeed = -0.053; break; case TRUE_NODE: { /* see comment 'Note 7 May 1991' above */ double ln = 0, rn = 0, zn = 0, lv = 0, rv = 0, zv = 0, l1 = 0, r1 = 0, z1 = 0, xn, yn, xv, yv, r0, x0, y0; helup(jd_ad + NODE_INTERVAL); moon(&ln, &rn, &zn); helup(jd_ad - NODE_INTERVAL); moon(&lv, &rv, &zv); helup(jd_ad); if (moonrem.calculation_time != jd_ad) { moon(&l1, &r1, &z1); } else { /* moon is already calculated */ l1 = moonrem.lng; r1 = moonrem.rad; z1 = moonrem.zet; } rn = Math.Sqrt(rn * rn - zn * zn); rv = Math.Sqrt(rv * rv - zv * zv); r0 = Math.Sqrt(r1 * r1 - z1 * z1); xn = rn * Math.Cos(DEGTORAD * ln); yn = rn * Math.Sin(DEGTORAD * ln); xv = rv * Math.Cos(DEGTORAD * lv); yv = rv * Math.Sin(DEGTORAD * lv); x0 = r0 * Math.Cos(DEGTORAD * l1); y0 = r0 * Math.Sin(DEGTORAD * l1); x = test_near_zero(x0 * yn - xn * y0); s = (y0 * zn - z1 * yn) / x; c = test_near_zero((x0 * zn - z1 * xn) / x); knn = smod8360(RADTODEG * Math.Atan2(s, c)); /* = ATAN8(s / c) */ x = test_near_zero(y0 * xv - x0 * yv); s = (yv * z1 - zv * y0) / x; c = test_near_zero((xv * z1 - zv * x0) / x); knv = smod8360(RADTODEG * Math.Atan2(s, c)); *alng = smod8360((knv + knn) / 2); /* ** the distance of the node is the 'orbital parameter' p = a (1-e^2); ** Our current use of the axis a is wrong. */ *arad = pd[MOON].axis; *alat = 0.0; *alngspeed = diff8360(knn, knv) / NODE_INTERVAL; } break; case LILITH: { /* ** Added 22-Jun-93 ** Lilith or Dark Moon is the empty focal point of the mean lunar ellipse. ** This is 180 degrees from the perihel. ** Because the lunar orbit is not in the ecliptic, it must be ** projected onto the ecliptic in the same way as the planetary orbits ** are (see for example Montenbruck, Grundlagen der Ephemeridenrechnung). ** ** We compute the MEAN Lilith, not the TRUE one which would have to be ** derived in a similar way as the true node. ** For the radius vector of Lilith we use a simple formula; ** to get a precise value, the fact that the focal point of the ellipse ** is not at the center of the earth but at the barycenter moon-earth ** would have to be accounted for. ** For the speed we always return a constant: the T term from the ** lunar perihel. ** Joelle de Gravelaine publishes in her book "Lilith der schwarze Mond" ** (Astrodata, 1990) an ephemeris which gives noon (12.00) positions ** but does not project onto the ecliptic. ** This creates deviations */ double arg_lat, lon, cosi; elements e = el[MOON]; arg_lat = degnorm(e.pe - e.kn + 180.0); cosi = COSDEG(e.inc); if (e.inc == 0 || Math.Abs(arg_lat - 90.0) < TANERRLIMIT || Math.Abs(arg_lat - 270.0) < TANERRLIMIT) { lon = arg_lat; } else { lon = Math.Atan(TANDEG(arg_lat) * cosi); lon = RADTODEG * lon; if (arg_lat > 90.0 && arg_lat < 270.0) { lon += 180.0; } } lon = degnorm(lon + e.kn); *alng = lon; *alngspeed = 0.111404; /* 6'41.05" per day */ *arad = 2 * pd[MOON].axis * e.ex; /* ** To test Gravalaines error, return unprojected long in alat. ** the correct latitude would be: ** *alat = RADTODEG * ASIN8(SINDEG(arg_lat) * SINDEG(e->in)); */ *alat = RADTODEG * Math.Sin(SINDEG(arg_lat) * SINDEG(e.inc)); } break; default: return(-1); } /* end switch */ if (calc_nut) { *alng += nut; } *alng = smod8360(*alng); /* normalize to circle */ return(0); }
unsafe int moon(double *al, double *ar, double *az) /* return OK or ERR */ { double a1, a2, a3, a4, a5, a6, a7, a8, a9, c2, c4, arg, b, d, f, dgc, dlm, dpm, dkm, dls; double ca, cb, cd, f_2d, f_4d, g1c, lk, lk1, man, ms, nib, s, sinarg, sinp, sk; double t, tb, t2c, r2rad, i1corr, i2corr, dlid; int i; elements e = el[MOON]; t = e.tj * 36525; /* days from epoch 1900 */ /* new format table II, parameters in full rotations of 360 degrees */ r2rad = 360.0 * DEGTORAD; tb = t * 1e-12; /* units of 10^12 */ t2c = t * t * 1e-16; /* units of 10^16 */ a1 = Math.Sin(r2rad * (0.53733431 - 10104982 * tb + 191 * t2c)); a2 = Math.Sin(r2rad * (0.71995354 - 147094228 * tb + 43 * t2c)); c2 = Math.Cos(r2rad * (0.71995354 - 147094228 * tb + 43 * t2c)); a3 = Math.Sin(r2rad * (0.14222222 + 1536238 * tb)); a4 = Math.Sin(r2rad * (0.48398132 - 147269147 * tb + 43 * t2c)); c4 = Math.Cos(r2rad * (0.48398132 - 147269147 * tb + 43 * t2c)); a5 = Math.Sin(r2rad * (0.52453688 - 147162675 * tb + 43 * t2c)); a6 = Math.Sin(r2rad * (0.84536324 - 11459387 * tb)); a7 = Math.Sin(r2rad * (0.23363774 + 1232723 * tb + 191 * t2c)); a8 = Math.Sin(r2rad * (0.58750000 + 9050118 * tb)); a9 = Math.Sin(r2rad * (0.61043085 - 67718733 * tb)); dlm = 0.84 * a3 + 0.31 * a7 + 14.27 * a1 + 7.261 * a2 + 0.282 * a4 + 0.237 * a6; dpm = -2.1 * a3 - 2.076 * a2 - 0.840 * a4 - 0.593 * a6; dkm = 0.63 * a3 + 95.96 * a2 + 15.58 * a4 + 1.86 * a5; dls = -6.4 * a3 - 0.27 * a8 - 1.89 * a6 + 0.20 * a9; dgc = (-4.318 * c2 - 0.698 * c4) / 3600.0 / 360.0; /* in revolutions */ dgc = (1.000002708 + 139.978 * dgc); /* in this form used later */ man = DEGTORAD * (e.ma + (dlm - dpm) / 3600.0); /* man with periodic and secular corr. */ ms = DEGTORAD * (el[EARTH].ma + dls / 3600.0); f = DEGTORAD * (e.lg - e.kn + (dlm - dkm) / 3600.0); d = DEGTORAD * (e.lg + 180 - el[EARTH].lg + (dlm - dls) / 3600.0); lk = lk1 = sk = sinp = nib = g1c = 0; i1corr = 1.0 - 6.8320E-8 * t; i2corr = dgc * dgc; /* i2 occurs only as -2, 2 */ for (i = 0; i < m45.Count; i++) { /* arg = mp->i0 * man + mp->i1 * ms + mp->i2 * f + mp->i3 * d; */ arg = m45[i].i0 * man; arg += m45[i].i3 * d; arg += m45[i].i2 * f; arg += m45[i].i1 * ms; sinarg = Math.Sin(arg); /* ** now apply corrections due to changes in constants; ** we correct only terms in l' (i1) and F (i2), not in l (i0), because ** the latter are < 0.05" ** We don't apply corrections for cos(arg), i.e. for parallax */ if (m45[i].i1 != 0) { /* i1 can be -2, -1, 0, 1, 2 */ sinarg *= i1corr; if (m45[i].i1 == 2 || m45[i].i1 == -2) { sinarg *= i1corr; } } if (m45[i].i2 != 0) /* i2 can be -2, 0, 2 */ { sinarg *= i2corr; } lk += m45[i].lng * sinarg; sk += m45[i].lat * sinarg; sinp += m45[i].par * Math.Cos(arg); } /* ** now compute some planetary terms in longitude, list i delta; ** we take all > 0.5" and neglect secular terms in the arguments. These ** produce phase errors > 10 degrees only after 3000 years. */ dlid = 0.822 * Math.Sin(r2rad * (0.32480 - 0.0017125594 * t)); dlid += 0.307 * Math.Sin(r2rad * (0.14905 - 0.0034251187 * t)); dlid += 0.348 * Math.Sin(r2rad * (0.68266 - 0.0006873156 * t)); dlid += 0.662 * Math.Sin(r2rad * (0.65162 + 0.0365724168 * t)); dlid += 0.643 * Math.Sin(r2rad * (0.88098 - 0.0025069941 * t)); dlid += 1.137 * Math.Sin(r2rad * (0.85823 + 0.0364487270 * t)); dlid += 0.436 * Math.Sin(r2rad * (0.71892 + 0.0362179180 * t)); dlid += 0.327 * Math.Sin(r2rad * (0.97639 + 0.0001734910 * t)); /* without nutation */ *al = smod8360(e.lg + (dlm + lk + lk1 + dlid) / 3600.0); /* solar Terms in latitude Nibeta */ f_2d = f - 2.0 * d; f_4d = f - 4.0 * d; nib += -526.069 * Math.Sin(f_2d); nib += -3.352 * Math.Sin(f_4d); nib += 44.297 * Math.Sin(man + f_2d); nib += -6.000 * Math.Sin(man + f_4d); nib += 20.599 * Math.Sin(-man + f); nib += -30.598 * Math.Sin(-man + f_2d); nib += -24.649 * Math.Sin(-2 * man + f); nib += -2.000 * Math.Sin(-2 * man + f_2d); nib += -22.571 * Math.Sin(ms + f_2d); nib += 10.985 * Math.Sin(-ms + f_2d); /* new gamma1C from 29 Jul 88, all terms > 0.4 " in table III, code 2 */ g1c += -0.725 * Math.Cos(d); g1c += 0.601 * Math.Cos(2 * d); g1c += 0.394 * Math.Cos(3 * d); g1c += -0.445 * Math.Cos(man + 4 * d); g1c += 0.455 * Math.Cos(man + 1 * d); g1c += 5.679 * Math.Cos(2 * man - 2 * d); g1c += -1.300 * Math.Cos(3 * man); g1c += -1.302 * Math.Cos(ms); g1c += -0.416 * Math.Cos(ms - 4 * d); g1c += -0.740 * Math.Cos(2 * ms - 2 * d); g1c += 0.787 * Math.Cos(man + ms + 2 * d); g1c += 0.461 * Math.Cos(man + ms); g1c += 2.056 * Math.Cos(man + ms - 2 * d); g1c += -0.471 * Math.Cos(man + ms - 4 * d); g1c += -0.443 * Math.Cos(-man + ms + 2 * d); g1c += 0.679 * Math.Cos(-man + ms); g1c += -1.540 * Math.Cos(-man + ms - 2 * d); s = f + sk / 3600.0 * DEGTORAD; ca = 18519.7 + g1c; cb = -0.000336992 * ca * dgc * dgc * dgc; cd = ca / 18519.7; b = (ca * Math.Sin(s) * dgc + cb * Math.Sin(3.0 * s) + cd * nib) / 3600.0; /* we neglect the planetary terms in latitude, code 4 in table III */ sinp = (sinp + 3422.451); /* ** Improved lunar ephemeris and APAE until ca. 1970 had here ** 3422.54 as constant of moon's sine parallax. ** The difference can be applied by direct addition of 0.089" to ** our parallax results. ** ** To get the radius in A.U. from the sine parallax, ** we use 1964 IAU value 8.794" for solar parallax. ** sinp is still in seconds of arc. ** To calculate moon parallax in " it would be: ** p = sinp (1 + sinp * sinp * 3.917405E-12) ** based on the formula p = sinp + 1/6 sinp^3 ** and taking into account the conversion of " to radians. ** The semidiameter of the moon is: (Expl.Suppl. 61, p 109) ** s = 0.0796 + 0.272446 * p */ *ar = 8.794 / sinp; *az = *ar * Math.Sin(DEGTORAD * b); return(0); }
/* ** helup() ** prepares the orbital elements and the disturbation arguments for the ** inner planets and the moon. helup(t) is called by hel() and by calc(). ** helup() returns its results in global variables. ** helup() remembers the t it has been called with before and does ** not recalculate its results when it is called more than once with ** the same t. */ void helup(double jd_ad) { int i = 0; elements ee = el[EARTH]; /* pointer to el[EARTH] */ double td, ti, ti2, tj1, tj2, tj3; if (thelup == jd_ad) { return; /* if already calculated then return */ } for (i = SUN; i <= MARS; i++) { td = jd_ad - pd[i].epoch; ti = el[i].tj = td / 36525.0; /* julian centuries from epoch */ ti2 = ti * ti; tj1 = ti / 3600.0; /* used when coefficients are in seconds of arc */ tj2 = ti * tj1; tj3 = ti * tj2; el[i].lg = mod8360(pd[i].lg0 + pd[i].lg1 * td + pd[i].lg2 * tj2 + pd[i].lg3 * tj3); /* also with moon lg1 *td is exact to 10e-8 degrees within 5000 years */ el[i].pe = mod8360(pd[i].pe0 + pd[i].pe1 * tj1 + pd[i].pe2 * tj2 + pd[i].pe3 * tj3); el[i].ex = pd[i].ex0 + pd[i].ex1 * ti + pd[i].ex2 * ti2; el[i].kn = mod8360(pd[i].kn0 + pd[i].kn1 * tj1 + pd[i].kn2 * tj2 + pd[i].kn3 * tj3); el[i].inc = pd[i].in0 + pd[i].in1 * tj1 + pd[i].in2 * tj2; el[i].ma = smod8360(el[i].lg - el[i].pe); if (i == MOON) { /* calculate ekliptic according Newcomb, APAE VI, ** and nutation according Exp.Suppl. 1961, identical ** with Mark Potttenger elemnut() ** all terms >= 0.01" only . ** The 1984 IAU Theory of Nutation, as published in ** AE 1984 suppl. has not yet been implemented ** because it would mean to use other elements of ** moon and sun */ double mnode, mlong2, slong2, mg, sg, d2; mnode = DEGTORAD * el[i].kn; /* moon's mean node */ mlong2 = DEGTORAD * 2.0 * el[i].lg; /* 2 x moon's mean longitude */ mg = DEGTORAD * el[i].ma; /* moon's mean anomaly (g1) */ slong2 = DEGTORAD * 2.0 * el[i].lg; /* 2 x sun's mean longitude (L), with * the phase 180 deg earth-sun irrelevant * because 2 x 180 = 360 deg */ sg = DEGTORAD * ee.ma; /* sun's mean anomaly = earth's */ d2 = mlong2 - slong2; /* 2 x elongation of moon from sun */ meanekl = ekld[0] + ekld[1] * tj1 + ekld[2] * tj2 + ekld[3] * tj3; ekl = meanekl + (9.2100 * Math.Cos(mnode) - 0.0904 * Math.Cos(2.0 * mnode) + 0.0183 * Math.Cos(mlong2 - mnode) + 0.0884 * Math.Cos(mlong2) + 0.0113 * Math.Cos(mlong2 + mg) + 0.5522 * Math.Cos(slong2) + 0.0216 * Math.Cos(slong2 + sg)) / 3600.0; nut = ((-17.2327 - 0.01737 * ti) * Math.Sin(mnode) + 0.2088 * Math.Sin(2.0 * mnode) + 0.0675 * Math.Sin(mg) - 0.0149 * Math.Sin(mg - d2) - 0.0342 * Math.Sin(mlong2 - mnode) + 0.0114 * Math.Sin(mlong2 - mg) - 0.2037 * Math.Sin(mlong2) - 0.0261 * Math.Sin(mlong2 + mg) + 0.0124 * Math.Sin(slong2 - mnode) + 0.0214 * Math.Sin(slong2 - sg) - 1.2729 * Math.Sin(slong2) - 0.0497 * Math.Sin(slong2 + sg) + 0.1261 * Math.Sin(sg)) / 3600.0; } } /* calculate the arguments sa[] for the disturbation terms */ ti = (jd_ad - EPOCH1850) / 365.25; /* julian years from 1850 */ for (i = 0; i < _sd.Length; i++) { sa[i] = mod8360(_sd[i].sd0 + _sd[i].sd1 * ti); } /* ** sa[2] += 0.3315 * SIN8 (DEGTORAD *(133.9099 + 38.39365 * el[SUN].tj)); ** ** correction of jupiter perturbation argument for sun from Pottenger; ** creates only .03" and 1e-7 rad, not applied because origin unclear */ thelup = jd_ad; /* note the last helup time */ }