public override async Task <IDataSourcePlugin> GetDataSourceDataAsync(NameValueCollection locations) { var datapath = locations["raw"]; var client = new HttpClient(); string fileContents; // datapath is expected to be a valid file // Exceptions will be handled by the main program using (var reader = File.OpenText(datapath)) { fileContents = await reader.ReadToEndAsync(); } Bg bgs = null; var parsed = this.NsData = JsonConvert.DeserializeObject <GeneratedNsData>(fileContents); bgs = parsed.bgs.First(); this.Direction = bgs.direction; this.Glucose = Double.Parse(bgs.sgv, NumberStyles.Any, CultureInfo.InvariantCulture); this.Date = DateTimeOffset.FromUnixTimeMilliseconds(bgs.datetime).DateTime; this.Delta = Double.Parse(bgs.bgdelta, NumberStyles.Any, CultureInfo.InvariantCulture); return(this); }
public virtual async Task <IDataSourcePlugin> GetDataSourceDataAsync(NameValueCollection locations) { var datapath = locations["location"]; var client = new HttpClient(); Bg bgs = null; string urlContents = await client.GetStringAsync(datapath); //urlContents = "{ \"status\":[{\"now\":1471947452808}],\"bgs\":[],\"cals\":[]"; //urlContents = "{}" var parsed = this.NsData = JsonConvert.DeserializeObject <GeneratedNsData>(urlContents); try { bgs = parsed.bgs.First(); this.Direction = bgs.direction; this.Glucose = Double.Parse(bgs.sgv, NumberStyles.Any, CultureInfo.InvariantCulture); this.Date = DateTimeOffset.FromUnixTimeMilliseconds(bgs.datetime).DateTime; this.Delta = Double.Parse(bgs.bgdelta, NumberStyles.Any, CultureInfo.InvariantCulture); } catch (InvalidOperationException ex) { //this exception might be hit when the Nightscout installation is brand new or contains no recent data; throw new MissingDataException("No data"); } return(this); }
/// <summary> /// 解析XML /// </summary> private void AnalysisXml() { XmlDocument document = new XmlDocument(); //实例化一个xml文档 document.Load(Application.dataPath + "/Data/Dialog.xml"); //加载 XML 内容 XmlElement rootEle = document.LastChild as XmlElement; //根节点 foreach (XmlElement ele in rootEle.ChildNodes) //遍历根节点的所有子节点 { if (ele.Name == "bgm") //如果元素的名字是XML文档中的节点"bgm" { Bgm bgm = new Bgm(); bgm.AllType = CommandType.Bgm; bgm.Name = ele.InnerText; Commands.Add(bgm); //添加到命令数组 Commands 中 } else if (ele.Name == "bg") { Bg bg = new Bg(); bg.AllType = CommandType.Bg; bg.Name = ele.InnerText; Commands.Add(bg); } else if (ele.Name == "say") { Say say = new Say(); say.AllType = CommandType.Say; say.Name = ele.ChildNodes[0].InnerText; say.Image = ele.ChildNodes[1].InnerText; say.Sound = ele.ChildNodes[2].InnerText; say.Content = ele.ChildNodes[3].InnerText; Commands.Add(say); } } }
private void Bg_DoWork(object sender, DoWorkEventArgs e) { int i = 0; foreach (var item in listRes) { foreach (var item2 in listSchedules) { item2.Restaurant_Id_Fk = item.Restaurant; item2.Res_Cont_Contract_Id_Fk = item.Contract; db.Schedules.Add(item2); db.SaveChanges(); Bg.ReportProgress(i); i = i + 1; } lblDarsad.Invoke(new Action(() => { lblDarsad.Text = "%" + (i * 100 / countTotal).ToString(); })); } }
void BonusType(Bg bg) { for (int i = 0; i < bg.Bonuses.Length; i++) { SpriteRenderer sr = bg.Bonuses[i].GetComponentInChildren <SpriteRenderer>(); float Dice = Random.value * 10; if (Dice > 5) { sr.sprite = bulletSprite; sr.gameObject.tag = "BulletItem"; } else { if (Dice < 2) { sr.sprite = hpSprite; sr.gameObject.tag = "HealthItem"; } else { sr.sprite = rocketSprite; sr.gameObject.tag = "RocketItem"; } } } }
/// <summary> /// Parses for the default background image /// </summary> private void ParseBackground(string val) { string background = this.FindImageFile("Background", val, false); if (background != null) { Bg bg = new Bg(); bg.beat = 0f; bg.filename = background; _bgs.Add(bg); } }
public PicChannelMixerWindow(BitmapSource bs) { InitializeComponent(); this.bs = bs; Content.DataContext = picChannelMixerControl; R.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true); Rg.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true); Rb.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true); Gr.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true); G.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true); Gb.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true); Br.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true); Bg.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true); B.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true); }
public double CalculateRawGlucose(Cal cal, Bg bg, double actualGlucose) { double number; double curBG = actualGlucose; int specialValue = 0; if (this.IsMmol) { if ((actualGlucose < 2.2) || (actualGlucose > 22.2)) { specialValue = 1; } curBG = curBG * 18.01559; } else { if ((actualGlucose < 40) || (actualGlucose > 400)) { specialValue = 1; } } //this special value is only triggered when the dexcom upload is brand new //from a brand new sensor? if (specialValue == 1) { number = cal.scale * (bg.unfiltered - cal.intercept) / cal.slope; } else { number = cal.scale * (bg.filtered - cal.intercept) / cal.slope / curBG; number = cal.scale * (bg.unfiltered - cal.intercept) / cal.slope / number; } if (this.IsMmol) { number = number / 18.01559; } return(number); }
private void Bg_DoWork(object sender, DoWorkEventArgs e) { int i = 0; bool nimeshab = list.Any(p => p.schedule.Meal_Id_Fk == 3); foreach (var item in list) { db.Trays.Add(item.tray); db.SaveChanges(); item.schedule.Tray_Id_Fk = Convert.ToInt16(item.tray.Id); db.Schedules.Add(item.schedule); foreach (var itemm in item.trayItem) { itemm.Tray_Id_Fk = Convert.ToInt16(item.tray.Id); db.TrayItems.Add(itemm); } if (nimeshab) { Schedule nimeshab2 = new Schedule() { SDate = item.schedule.SDate, Restaurant_Id_Fk = 27, Tray_Id_Fk = item.schedule.Tray_Id_Fk, RegDate = item.schedule.RegDate, Meal_Id_Fk = 3, Res_Cont_Contract_Id_Fk = 2022, PorsNo = 0 }; db.Schedules.Add(nimeshab2); } db.SaveChanges(); i = i + 1; lblDarsad.Invoke(new Action(() => { lblDarsad.Text = "%" + (i * 100 / list.Count()).ToString(); })); Bg.ReportProgress(i); System.Threading.Thread.Sleep(100); } }
/// <summary> /// 执行对话命令函数 /// </summary> public void OneByOneExecuteCommand() { if (_index >= Commands.Count) //下标越界:读完 { ReloadBut.SetActive(true); //激活重载按钮 ReloadBut.GetComponent <Button>().onClick.AddListener(ReloadScene); //给按钮添加 重载场景 监听事件 _isExecute = false; //关闭执行命令 return; } Command command = Commands[_index++]; //自增:取出一条命令 switch (command.AllType) { //如果类型是:Say 说话 case CommandType.Say: Say say = (Say)command; //实例化 Say 对象 say HeadPortrait.sprite = Resources.Load <Sprite>(say.Image); //更换头像 NameText.text = say.Name; //人物 ConttentText.text = say.Content; //说话内容 if (!string.IsNullOrEmpty(say.Sound)) //如果音效名不为空 { AudioManager.Instance.PlaySe(say.Sound); //播放音效 } break; //如果类型是:Bgm 背景音乐 case CommandType.Bgm: Bgm bgm = (Bgm)command; //实例化 Bgm 对象 bgm AudioManager.Instance.PlayBgm(bgm.Name); //播放背景音乐 OneByOneExecuteCommand(); //直接执行下一条 break; //如果类型是:Bg 背景 case CommandType.Bg: Bg bg = (Bg)command; //实例化 Bg 对象 bg BgImage.sprite = Resources.Load <Sprite>(bg.Name); //更换背景图片 OneByOneExecuteCommand(); //直接执行下一条 break; } }
void BonusPlace(Bg bg) { for (int j = 0; j < 3; j++) { bg.Bonuses[j].SetActive(false); } float Dice = Random.value * 80; if (Dice < 20) { bg.Bonuses[0].SetActive(true); } if (Dice > 15 && Dice < 35) { bg.Bonuses[1].SetActive(true); } if (Dice > 30 && Dice < 50) { bg.Bonuses[2].SetActive(true); } }
private void button3_Click(object sender, EventArgs e) { if (!AllowExit) { DialogResult dialogResult = RtlMessageBox.Show("آیا اطمینان از ثبت اطلاعات در دیتا بیس را دارید؟", "تاییدیه ثبت ", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { label3.Text = "در حال ثبت در دیتابیس"; label3.ForeColor = Color.Navy; button3.Enabled = false; button4.Enabled = false; Bg.RunWorkerAsync(); } else if (dialogResult == DialogResult.No) { } } else { this.Close(); } }
/// <summary> /// Parses for subsequent background images, currently no support for videos /// </summary> private void ParseBackgrounds(string val) { string[] commaSplit = val.Split(','); foreach (string split in commaSplit) { string[] equalsSplit = split.Split('='); if (equalsSplit.Length < 2) { Warning("Improperly formatted #BGCHANGES value: " + split); continue; } float beat = this.ParseFloat("Background change beat", equalsSplit[0], false); string background = this.FindImageFile("Background change background", equalsSplit[1], false); if (beat != -1f && background != null) { Bg bg = new Bg(); bg.beat = beat; bg.filename = background; _bgs.Add(bg); } } }
public void SetTheme(string theme) { ThemesManager.LoadTheme(Sidebar.SidebarWindow.sett.path, theme); object useSystemColor = ThemesManager.GetThemeParameter(Sidebar.SidebarWindow.sett.path, sett.theme, "boolean", "UseSystemGlassColor"); if (useSystemColor != null && Convert.ToBoolean(useSystemColor)) { Bg.Fill = new SolidColorBrush(DwmManager.ColorizationColor); DwmManager.ColorizationColorChanged += new EventHandler(SideBar_DwmColorChanged); } else { Bg.SetResourceReference(Rectangle.StyleProperty, "Background"); DwmManager.ColorizationColorChanged -= new EventHandler(SideBar_DwmColorChanged); } string file = string.Format(@"{0}\{1}.theme.xaml", sett.path, theme); foreach (Tile tile in TilesGrid.Children) { tile.ChangeTheme(file); } }
public static void InfiniteLevelLoad(Game myGame) { enemyList = new List <IEnemy>(); itemList = new List <IItem>(); blockList = new List <IBlock>(); bgList = new List <IBg>(); String[] levelFile = new String[two] { "InfiniteLevel-1.txt", "InfiniteLevel-2.txt" }; int file = 0; StreamReader File = new StreamReader(Path.Combine(Directory.GetCurrentDirectory(), "Content", "Levels", levelFile[file])); String inComingLine; int posRow = zero; while (!File.EndOfStream) { inComingLine = File.ReadLine(); String[] target = inComingLine.Split(','); int posCol = zero; while (posCol < target.Length) { if (target[posCol].Equals("brick")) { IBlock block = new Brick(myGame, posCol, posRow); blockList.Add(block); } else if (target[posCol].Equals("crack")) { IBlock block = new Crack(myGame, posCol, posRow); blockList.Add(block); } else if (target[posCol].Equals("diamond")) { IBlock block = new Diamond(myGame, posCol * stdSpriteSize, posRow * stdSpriteSize); blockList.Add(block); } else if (target[posCol].Equals("question")) { IBlock block = new Question(myGame, posCol, posRow); blockList.Add(block); } else if (target[posCol].Equals("questionRedM")) { Question block = new Question(myGame, posCol, posRow); block.contain = Utility.items.redM; blockList.Add(block); } else if (target[posCol].Equals("questionFireF")) { Question block = new Question(myGame, posCol, posRow); block.contain = Utility.items.flower; blockList.Add(block); } else if (target[posCol].Equals("questionCoin")) { Question block = new Question(myGame, posCol, posRow); block.contain = Utility.items.coin; blockList.Add(block); } else if (target[posCol].Equals("questionGreenM")) { Question block = new Question(myGame, posCol, posRow); block.contain = Utility.items.greenM; blockList.Add(block); } else if (target[posCol].Equals("questionBat")) { Question block = new Question(myGame, posCol, posRow); block.contain = Utility.items.bat; blockList.Add(block); } else if (target[posCol].Equals("used")) { IBlock block = new Used(myGame, posCol, posRow); blockList.Add(block); } else if (target[posCol].Equals("invisible")) { IBlock block = new Invisible(myGame, posCol, posRow); blockList.Add(block); } else if (target[posCol].Equals("standardPipe")) { Pipe block = new Pipe(myGame, posCol, posRow); blockList.Add(block); IEnemy enemy = new PiranhaPlant(myGame, block.drawLoc.X, block.drawLoc.Y); enemyList.Add(enemy); } else if (target[posCol].Equals("pipeNeck")) { IBlock block = new PipeNeck(myGame, posCol, posRow); blockList.Add(block); } else if (target[posCol].Equals("coin")) { IItem item = new Coin(myGame, posCol * stdSpriteSize, posRow * stdSpriteSize); itemList.Add(item); } else if (target[posCol].Equals("star")) { IItem item = new Star(myGame, posCol * stdSpriteSize, posRow * stdSpriteSize); itemList.Add(item); } else if (target[posCol].Equals("flower")) { IItem item = new FireFlower(myGame, posCol * stdSpriteSize, posRow * stdSpriteSize); itemList.Add(item); } else if (target[posCol].Equals("redMushroom")) { IItem item = new RedMushroom(myGame, posCol * stdSpriteSize, posRow * stdSpriteSize); itemList.Add(item); } else if (target[posCol].Equals("greenMushroom")) { IItem item = new GreenMushroom(myGame, posCol * stdSpriteSize, posRow * stdSpriteSize); itemList.Add(item); } else if (target[posCol].Equals("goomba")) { IEnemy enemy = new Goomba(myGame, posCol, posRow); enemyList.Add(enemy); } else if (target[posCol].Equals("koopa")) { IEnemy enemy = new Koopa(myGame, posCol, posRow); enemyList.Add(enemy); } else if (target[posCol].Equals("oneCloud")) { IBg bg = new Bg(myGame, myGame.oneCloudBgElement, posCol, posRow); bgList.Add(bg); } else if (target[posCol].Equals("threeClouds")) { IBg bg = new Bg(myGame, myGame.threeCloudsBgElement, posCol, posRow); bgList.Add(bg); } else if (target[posCol].Equals("oneBush")) { IBg bg = new Bg(myGame, myGame.oneBushBgElement, posCol, posRow); bgList.Add(bg); } else if (target[posCol].Equals("threeBushes")) { IBg bg = new Bg(myGame, myGame.threeBushesBgElement, posCol, posRow); bgList.Add(bg); } else if (target[posCol].Equals("smallMountain")) { IBg bg = new Bg(myGame, myGame.smallMountainBgElement, posCol, posRow); bgList.Add(bg); } else if (target[posCol].Equals("bigMountain")) { IBg bg = new Bg(myGame, myGame.bigMountainBgElement, posCol, posRow); bgList.Add(bg); } posCol++; } posRow++; } File.Close(); if (file < two) { File = new StreamReader(Path.Combine(Directory.GetCurrentDirectory(), "Content", "Levels", levelFile[file])); file++; } else { file = zero; } IComparer <IBlock> blockComp = new BlockComparer <IBlock>(); IComparer <IItem> itemComp = new ItemComparer <IItem>(); IComparer <IEnemy> enemyComp = new EnemyComparer <IEnemy>(); blockList.Sort(blockComp); itemList.Sort(itemComp); enemyList.Sort(enemyComp); }
//偏差指数评价 private void button2_Click(object sender, EventArgs e) { double Br, Bg, Bb;//三通道偏差指数 double r, g, b; r = g = b = 0; Bitmap map2 = (Bitmap)img2; for (int i = 0; i < newBitmap.Width; i++) { for (int j = 0; j < newBitmap.Height; j++) { Color pixel1 = newBitmap.GetPixel(i, j); Color piexl2 = map2.GetPixel(i, j); r += Math.Abs(pixel1.R - piexl2.R) * 1.0 / piexl2.R; g += Math.Abs(pixel1.G - piexl2.G) * 1.0 / piexl2.G; b += Math.Abs(pixel1.B - piexl2.B) * 1.0 / piexl2.B; } } Br = r / (newBitmap.Width * newBitmap.Height); Bg = g / (newBitmap.Width * newBitmap.Height); Bb = b / (newBitmap.Width * newBitmap.Height); MessageBox.Show("融合图三通道偏差指数" + "\r\n" + "Br:" + Br.ToString() + " " + "Bg:" + Bg.ToString() + " " + "Bb:" + Bb.ToString()); }
Picture pictBottom; // самая нижеяя картинка void Awake() { platforms = new Dictionary <sbyte, Platform>(); bgs = new Dictionary <sbyte, Bg>(); chalks = new Dictionary <sbyte, Chalk>(); pictures = new Dictionary <sbyte, Picture>(); chalksCount = 25; height = 0; record = LoadOldRecord(); // Добавление начальных 10 платформ bottom = new Simple(); platforms.Add(0, bottom); for (sbyte i = 1; i < 10; i++) { Platform previous; platforms.TryGetValue((sbyte)(i - 1), out previous); platforms.Add(i, RandomPlatform(previous)); } // Добавление 3 фоновых спрайтов bgBottom = new Bg(-BGHeight()); //Первый фон находится на высоту фонового спрайта ниже игрока bgs.Add(0, bgBottom); for (sbyte i = 1; i < 3; i++) { Bg bgPrevious; bgs.TryGetValue((sbyte)(i - 1), out bgPrevious); bgs.Add(i, new Bg(bgPrevious.Obj.transform.position.y + BGHeight())); if (!bgPrevious.Obj.GetComponent <SpriteRenderer>().flipY) { Bg bgTemp; bgs.TryGetValue(i, out bgTemp); bgTemp.Obj.GetComponent <SpriteRenderer>().flipY = true; } } // Добавление мелков chalkBottom = RandomChalk(new SimpleChalk(Random.Range(-2.0f, 2.0f), Random.Range(1.0f, 3.0f))); chalks.Add(0, chalkBottom); for (sbyte i = 1; i < 5; i++) { Chalk chalkPrevious; chalks.TryGetValue((sbyte)(i - 1), out chalkPrevious); chalks.Add(i, RandomChalk(chalkPrevious)); } // Добавление картинок pictBottom = new Picture(Random.Range(-2.0f, 2.0f), Random.Range(1.0f, 3.0f)); pictures.Add(0, pictBottom); for (sbyte i = 1; i < 17; i++) { Picture pictPrevious; pictures.TryGetValue((sbyte)(i - 1), out pictPrevious); pictures.Add(i, new Picture(Random.Range(-2.0f, 2.0f), pictPrevious.Exemplar.transform.position.y + Random.Range(1.0f, 4.0f))); } }
/// <summary> /// 设置left /// </summary> /// <param name="x"></param> public PageItem SetX(double x) { Bg.SetValue(Canvas.LeftProperty, x); return(this); }
private void btnEnteshar_Click(object sender, EventArgs e) { if (!AllowExit) { btnEnteshar.Enabled = false; btnCancel.Enabled = false; listRes = new List <RestaurantContract>() { new RestaurantContract() { Restaurant = 28, Contract = 2021 }, new RestaurantContract() { Restaurant = 29, Contract = 2021 }, new RestaurantContract() { Restaurant = 32, Contract = 2021 }, new RestaurantContract() { Restaurant = 38, Contract = 2021 }, new RestaurantContract() { Restaurant = 40, Contract = 2021 }, new RestaurantContract() { Restaurant = 41, Contract = 2021 }, new RestaurantContract() { Restaurant = 42, Contract = 2021 }, new RestaurantContract() { Restaurant = 44, Contract = 2021 }, new RestaurantContract() { Restaurant = 49, Contract = 2021 }, new RestaurantContract() { Restaurant = 50, Contract = 2021 }, new RestaurantContract() { Restaurant = 51, Contract = 2021 }, new RestaurantContract() { Restaurant = 35, Contract = 2022 }, new RestaurantContract() { Restaurant = 27, Contract = 2022 }, new RestaurantContract() { Restaurant = 30, Contract = 2022 }, new RestaurantContract() { Restaurant = 31, Contract = 2022 }, new RestaurantContract() { Restaurant = 33, Contract = 2022 }, new RestaurantContract() { Restaurant = 34, Contract = 2022 }, new RestaurantContract() { Restaurant = 37, Contract = 2022 }, new RestaurantContract() { Restaurant = 36, Contract = 2022 }, new RestaurantContract() { Restaurant = 53, Contract = 2022 } }; listSchedules = db.Schedules.Where(p => p.SDate.CompareTo(date) >= 0 & p.Meal_Id_Fk != 3 & p.Restaurant_Id_Fk == 26).ToList(); countTotal = listRes.Count() * listSchedules.Count(); progressBar1.Maximum = countTotal; int x = 0; DialogResult dialogResult = RtlMessageBox.Show("آیا اطمینان از ثبت اطلاعات در دیتا بیس را دارید؟", "تاییدیه ثبت ", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { lblNotification.Text = "در حال ثبت در دیتابیس"; lblNotification.ForeColor = Color.Navy; Bg.RunWorkerAsync(); } else if (dialogResult == DialogResult.No) { } } else { this.Close(); } }