public void ExitShow() { mode = md.editshow; sceneobj.canvas.SetActive(false); Screen.SetResolution(1280, 720, false); for (int i = sceneobj.ostr.childCount - 1; i >= 0; i--) { Destroy(sceneobj.ostr.GetChild(i).gameObject); } for (int i = sceneobj.functr.childCount - 1; i >= 0; i--) { Destroy(sceneobj.functr.GetChild(i).gameObject); } sceneobj.oss = new List <RectTransform>(); sceneobj.funcs = new List <RectTransform>(); if (sceneobj.cursel != null) { Destroy(sceneobj.cursel); } showui.SetActive(false); projprev.SetActive(true); }
public void CloseProject() { mode = md.select; projprev.SetActive(false); selectproj.SetActive(true); for (int i = prevopt.osscroll.childCount - 1; i >= 0; i--) { Destroy(prevopt.osscroll.GetChild(i).gameObject); } for (int i = prevopt.funcscroll.childCount - 1; i >= 0; i--) { Destroy(prevopt.funcscroll.GetChild(i).gameObject); } scene.bg.sprite = prew.defbg; config.bigicon.text = "0"; config.smallicon.text = "0"; curProj = new ProjectFiles(); prevopt.functog = new List <Toggle>(); prevopt.ostog = new List <Toggle>(); GetProjects(); }
public void Start() { SaveSystemAlt.StartWork(); GetProjects(); mode = md.select; sceneobj.canvas.SetActive(false); selectproj.SetActive(true); showui.SetActive(false); projprev.SetActive(false); }
static MarketOverview getMarketData(string e2) { md[] bfxOrders = new md[10]; md[] e2Orders = new md[10]; HttpWebRequest bfxDepthReq = (HttpWebRequest)WebRequest.Create("https://api.bitfinex.com/v1/book/LTCUSD?limit_bids=10&limit_asks=10"); bitfinex_json.Depth e1Depth = JsonConvert.DeserializeObject <bitfinex_json.Depth>(Query.read(bfxDepthReq)); if (e2 == "btcchina") { HttpWebRequest btcchinaDepthReq = (HttpWebRequest)WebRequest.Create("https://data.btcchina.com/data/orderbook?market=LTCCNY&limit=10"); btcchina_json.Depth e2Depth = JsonConvert.DeserializeObject <btcchina_json.Depth>(Query.read(btcchinaDepthReq)); for (int i = 0; i < 10; i++) { bfxOrders[i] = new md(); bfxOrders[i].asks = new md.Asks(); bfxOrders[i].bids = new md.Bids(); bfxOrders[i].asks.price = e1Depth.asks[i].price; bfxOrders[i].asks.volume = e1Depth.asks[i].amount; bfxOrders[i].bids.price = e1Depth.bids[i].price; bfxOrders[i].bids.volume = e1Depth.bids[i].amount; e2Orders[i] = new md(); e2Orders[i].asks = new md.Asks(); e2Orders[i].bids = new md.Bids(); e2Orders[i].asks.price = e2Depth.asks[i][0]; e2Orders[i].asks.volume = e2Depth.asks[i][1]; e2Orders[i].bids.price = e2Depth.bids[i][0]; e2Orders[i].bids.volume = e2Depth.bids[i][1]; } } else if (e2 == "btc-e") { HttpWebRequest btceDepthReq = (HttpWebRequest)WebRequest.Create("https://btc-e.com/api/3/depth/ltc_usd?limit=10"); btce_json.Depth e2Depth = JsonConvert.DeserializeObject <btce_json.Depth>(Query.read(btceDepthReq)); for (int i = 0; i < 10; i++) { bfxOrders[i] = new md(); bfxOrders[i].asks = new md.Asks(); bfxOrders[i].bids = new md.Bids(); bfxOrders[i].asks.price = e1Depth.asks[i].price; bfxOrders[i].asks.volume = e1Depth.asks[i].amount; bfxOrders[i].bids.price = e1Depth.bids[i].price; bfxOrders[i].bids.volume = e1Depth.bids[i].amount; e2Orders[i] = new md(); e2Orders[i].asks = new md.Asks(); e2Orders[i].bids = new md.Bids(); e2Orders[i].asks.price = e2Depth.ltc_usd.asks[i][0]; e2Orders[i].asks.volume = e2Depth.ltc_usd.asks[i][1]; e2Orders[i].bids.price = e2Depth.ltc_usd.bids[i][0]; e2Orders[i].bids.volume = e2Depth.ltc_usd.bids[i][1]; } } double bfx_ask = bfxOrders[0].asks.price; double bfx_bid = bfxOrders[0].bids.price; double btce_ask = e2Orders[0].asks.price; double btce_bid = e2Orders[0].bids.price; #region profit calculation //bfx limit entry double bfxLimitEntryVolume = 0; //volume of best bid at other exchange double adjustedBtceAsk = btce_ask; for (int i = 0; i < 5; i++) { double profitAtNextDepth = calculateProfit(bfx_ask, btce_ask).Item1;//((1 - e2MarketFee) * (bfx_ask / exitRatio) - (1 + e2MarketFee) * btceDepth.ltc_usd.asks[i][0]) + bfx_ask - (1 + bfxLimitFee) * bfx_ask; if (profitAtNextDepth > 0) { adjustedBtceAsk = e2Orders[i].asks.price; bfxLimitEntryVolume += e2Orders[i].asks.volume; //we can buy up to this volume, add this volume to our max and go for this price } else { break; } } //btce limit entry double btceLimitEntryVolume = 0; //volume of best bid at other exchange double adjustedBfxBid = bfx_bid; for (int i = 0; i < 5; i++) { double profitAtNextDepth = calculateProfit(bfx_ask, btce_ask, bfx_bid, btce_bid).Item3;//((1 - e2MarketFee) * (bfx_ask / exitRatio) - (1 + e2MarketFee) * btceDepth.ltc_usd.asks[i][0]) + bfx_ask - (1 + bfxLimitFee) * bfx_ask; if (profitAtNextDepth > 0) { adjustedBfxBid = bfxOrders[i].bids.price; btceLimitEntryVolume += bfxOrders[i].bids.volume; //we can buy up to this volume, add this volume to our max and go for this price } else { break; } } //market entry volume double marketEntryVolume = 0; //volume of best bid at other exchange if (bfxLimitEntryVolume > 0 && btceLimitEntryVolume > 0) { double nextBfxBidVol = bfxOrders[0].bids.volume; double nextBtceAskVol = e2Orders[0].asks.volume; double nextBfxBidPrice = bfxOrders[0].bids.price; double nextBtceAskPrice = e2Orders[0].asks.price; int bfxLastIndex = 0; int btceLastIndex = 0; while (bfxLastIndex < 4 && btceLastIndex < 4) { double profitAtNextDepth = calculateProfit(bfx_ask, nextBtceAskPrice, nextBfxBidPrice).Item2;//((1 - e2MarketFee) * (bfx_ask / exitRatio) - (1 + e2MarketFee) * btceDepth.ltc_usd.asks[i][0]) + bfx_ask - (1 + bfxLimitFee) * bfx_ask; if (profitAtNextDepth > 0) { adjustedBtceAsk = nextBtceAskPrice; adjustedBfxBid = nextBfxBidPrice; double minVol = Math.Min(nextBfxBidVol, nextBtceAskVol); marketEntryVolume += minVol; nextBfxBidVol -= minVol; nextBtceAskVol -= minVol; if (nextBfxBidVol == 0) { adjustedBfxBid = nextBfxBidPrice; bfxLastIndex++; nextBfxBidVol = bfxOrders[bfxLastIndex].bids.volume; nextBfxBidPrice = bfxOrders[bfxLastIndex].bids.price; } else { //nextbtceask<0 adjustedBtceAsk = nextBtceAskPrice; btceLastIndex++; nextBtceAskVol = e2Orders[btceLastIndex].asks.volume; nextBtceAskPrice = e2Orders[btceLastIndex].asks.price; } //we can buy up to this volume, add this volume to our max and go for this price } else { break; } } } //bfx limit exit volume double bfxLimitExitVolume = 0; //volume of best bid at other exchange double adjustedBtceBid = btce_bid; for (int i = 0; i < 5; i++) { double exitRatioAtNextDepth = bfx_bid / e2Orders[i].bids.price; if (exitRatioAtNextDepth < exitRatio) { adjustedBtceBid = e2Orders[i].bids.price; bfxLimitExitVolume += e2Orders[i].bids.volume; //we can buy up to this volume, add this volume to our max and go for this price } else { break; } } //btce limit exit volume double btceLimitExitVolume = 0; //volume of best bid at other exchange double adjustedBfxAsk = bfx_ask; for (int i = 0; i < 5; i++) { double exitRatioAtNextDepth = bfx_ask / e2Orders[i].bids.price; if (exitRatioAtNextDepth < exitRatio) { //adjustedBfxAsk = btceDepth.ltc_usd.asks[i][ //btce_bid = btceDepth.ltc_usd.asks[i][0]; btceLimitExitVolume += bfxOrders[i].asks.volume; //we can buy up to this volume, add this volume to our max and go for this price } else { break; } } //market exit volume double marketExitVolume = 0; //volume of best bid at other exchange if (bfxLimitExitVolume > 0 && btceLimitExitVolume > 0) { double nextBfxAskVol = bfxOrders[0].asks.volume; double nextBtceBidVol = e2Orders[0].bids.volume; double nextBfxAskPrice = bfxOrders[0].asks.price; double nextBtceBidPrice = e2Orders[0].bids.price; int bfxLastIndex = 0; int btceLastIndex = 0; while (bfxLastIndex < 4 && btceLastIndex < 4) { double ratioAtNextDepth = nextBfxAskPrice / nextBtceBidPrice; if (ratioAtNextDepth < exitRatio) { //btce_ask = btceDepth.ltc_usd.asks[i][0]; double minVol = Math.Min(nextBfxAskVol, nextBtceBidVol); marketExitVolume += minVol; nextBfxAskVol -= minVol; nextBtceBidVol -= minVol; if (nextBfxAskVol == 0) { adjustedBfxAsk = nextBfxAskPrice; bfxLastIndex++; nextBfxAskVol = bfxOrders[bfxLastIndex].asks.volume; nextBfxAskPrice = bfxOrders[bfxLastIndex].asks.price; } else { //nextBtceBidVol==0 adjustedBtceBid = nextBtceBidPrice; btceLastIndex++; nextBtceBidVol = e2Orders[btceLastIndex].bids.volume; nextBfxAskPrice = e2Orders[btceLastIndex].bids.price; } //we can buy up to this volume, add this volume to our max and go for this price } else { break; } } } #endregion MarketOverview mkt = new MarketOverview(); mkt.prices = new MarketOverview.Prices(); mkt.entry = new MarketOverview.Entry(); mkt.exit = new MarketOverview.Exit(); mkt.prices.bfx_bid = bfxOrders[0].bids.price; mkt.prices.bfx_ask = bfxOrders[0].asks.price; mkt.prices.btce_bid = e2Orders[0].bids.price; mkt.prices.btce_ask = e2Orders[0].asks.price; mkt.entry.bfxLimitEntryVolume = bfxLimitEntryVolume; mkt.exit.bfxLimitExitVolume = bfxLimitExitVolume; mkt.entry.marketEntryVolume = marketEntryVolume; mkt.entry.btceLimitEntryVolume = btceLimitEntryVolume; mkt.exit.marketExitVolume = marketExitVolume; mkt.prices.bfx_ask_adjusted = adjustedBfxAsk; mkt.prices.bfx_bid_adjusted = adjustedBfxBid; mkt.prices.btce_ask_adjusted = adjustedBtceAsk; mkt.prices.btce_bid_adjusted = adjustedBtceBid; return(mkt); }
void startDownLoad(md m) { var dir = path + tb_lfpre.Text + m.lv; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } var x1 = (int)Math.Min(m.ps.X, m.pe.X); var x2 = (int)Math.Max(m.ps.X, m.pe.X); var y1 = (int)Math.Min(m.ps.Y, m.pe.Y); var y2 = (int)Math.Max(m.ps.Y, m.pe.Y); var pc = (x2 - x1 + 1) * (y2 - y1 + 1); long c = 0; var img = new Bitmap(256, 256); var g = Graphics.FromImage(img); for (var x = x1; x <= x2; x++) { for (var y = y1; y <= y2; y++) { if (stop) { break; } var url = mtype == 0 ? "http://webgis.591map.net/tiler/tdt-vec_w-{sw}-" + x + "-" + y + "-" + m.lv + ".html" : "http://webgis.591map.net/tiler/tdt-img_w-{sw}-" + x + "-" + y + "-" + m.lv + ".html"; var data = downData(url); using (var ms = new MemoryStream()) { ms.Write(data, 0, data.Length); var bmp = System.Drawing.Image.FromStream(ms); g.DrawImage(bmp, new Rectangle(0, 0, 256, 256), new Rectangle(0, 0, 256, 256), GraphicsUnit.Pixel); bmp.Dispose(); } img.Save(dir + "\\" + x + "," + y + ".jpg", ImageFormat.Jpeg); lock (this) c++; Invoke((Action)(() => { tsl_tip.Text = "已下载瓦片:" + m.lv + "级," + x + "," + y + " " + c + "/" + pc + "(" + ((float)c / pc * 100).ToString("F2") + "%)"; })); } if (stop) { break; } } Invoke((Action)(() => { if (stop) { tsl_tip.Text = "下载中断"; } else if (m.lv == int.Parse(cb_maxlev.SelectedItem + "")) { tsl_tip.Text = "下载完成"; } bt_start.Enabled = true; bt_stop.Enabled = false; })); g.Dispose(); img.Dispose(); }
public void Run() { mode = md.show; sceneobj.canvas.SetActive(true); sceneobj.bg.sprite = curProj.bg; Screen.SetResolution(int.Parse(prevopt.screenX.text), int.Parse(prevopt.screenY.text), true); showui.SetActive(true); projprev.SetActive(false); sceneobj.osbg.sizeDelta = new Vector2(sceneobj.osbg.sizeDelta.x, curProj.bigicon); sceneobj.funcbg.sizeDelta = new Vector2(sceneobj.funcbg.sizeDelta.x, curProj.smallicon); for (int i = 0; i < prevopt.ostog.Count; i++) { if (prevopt.ostog[i].isOn) { RectTransform obj = Instantiate(sceneobj.img, sceneobj.ostr).GetComponent <RectTransform>(); obj.gameObject.SetActive(true); obj.sizeDelta = new Vector2(curProj.bigicon, curProj.bigicon); obj.GetComponent <Image>().sprite = curProj.oss[prevopt.ostog[i].GetComponent <ProjPrevToggle>().i]; sceneobj.oss.Add(obj); } } for (int i = 0; i < prevopt.functog.Count; i++) { if (prevopt.functog[i].isOn) { RectTransform obj = Instantiate(sceneobj.img, sceneobj.functr).GetComponent <RectTransform>(); obj.gameObject.SetActive(true); obj.sizeDelta = new Vector2(curProj.smallicon, curProj.smallicon); obj.GetComponent <Image>().sprite = curProj.funcs[prevopt.functog[i].GetComponent <ProjPrevToggle>().i]; sceneobj.funcs.Add(obj); } } sceneobj.possel = 0; if (sceneobj.oss.Count == 0) { sceneobj.func = true; } else { sceneobj.func = false; } if (!(sceneobj.oss.Count == 0 && sceneobj.funcs.Count == 0)) { sceneobj.cursel = Instantiate(sceneobj.img, sceneobj.selzone); sceneobj.cursel.SetActive(true); sceneobj.imgsel = sceneobj.cursel.GetComponent <Image>(); sceneobj.rcsel = sceneobj.cursel.GetComponent <RectTransform>(); sceneobj.bigsel = new Vector2(curProj.bigicon, curProj.bigicon); sceneobj.smsel = new Vector2(curProj.smallicon, curProj.smallicon); if (sceneobj.oss.Count > 0) { sceneobj.imgsel.sprite = curProj.b_select; sceneobj.rcsel.sizeDelta = new Vector2(curProj.bigicon, curProj.bigicon); sceneobj.rcsel.position = sceneobj.oss[sceneobj.possel].position; } else { sceneobj.imgsel.sprite = curProj.l_select; sceneobj.rcsel.sizeDelta = new Vector2(curProj.smallicon, curProj.smallicon); sceneobj.rcsel.position = sceneobj.funcs[sceneobj.possel].position; } } }
public void GetProject(int i) { mode = md.editshow; //Debug.Log(i); projprev.SetActive(true); selectproj.SetActive(false); curProj.dir = FastFind.GetDefaultPath() + "/SLywnow/rEFInd theme editor/projects/" + dirs[i]; //load structure //load bg if (FilesSet.CheckFile(curProj.dir + "/background.png", false)) { FileStream streamimg = File.Open(curProj.dir + "/background.png", FileMode.Open); byte[] imgbt = new byte[streamimg.Length]; streamimg.Read(imgbt, 0, imgbt.Length); streamimg.Close(); Texture2D imgtex = new Texture2D(0, 0); imgtex.LoadImage(imgbt); curProj.bg = Sprite.Create(imgtex, new Rect(0.0f, 0.0f, imgtex.width, imgtex.height), new Vector2(0.5f, 0.5f)); } else { curProj.bg = prew.defbg; } //load sel if (FilesSet.CheckFile(curProj.dir + "/selection_big.png", false)) { FileStream streamimg = File.Open(curProj.dir + "/selection_big.png", FileMode.Open); byte[] imgbt = new byte[streamimg.Length]; streamimg.Read(imgbt, 0, imgbt.Length); streamimg.Close(); Texture2D imgtex = new Texture2D(0, 0); imgtex.LoadImage(imgbt); curProj.b_select = Sprite.Create(imgtex, new Rect(0.0f, 0.0f, imgtex.width, imgtex.height), new Vector2(0.5f, 0.5f)); } else { curProj.b_select = prew.defsel; } if (FilesSet.CheckFile(curProj.dir + "/selection_small.png", false)) { FileStream streamimg = File.Open(curProj.dir + "/selection_small.png", FileMode.Open); byte[] imgbt = new byte[streamimg.Length]; streamimg.Read(imgbt, 0, imgbt.Length); streamimg.Close(); Texture2D imgtex = new Texture2D(0, 0); imgtex.LoadImage(imgbt); curProj.l_select = Sprite.Create(imgtex, new Rect(0.0f, 0.0f, imgtex.width, imgtex.height), new Vector2(0.5f, 0.5f)); } else { curProj.l_select = prew.defsel; } //load ico string[] icons = null; if (FilesSet.CheckDirectory(curProj.dir + "/icons")) { icons = FilesSet.GetFilesFromdirectories(curProj.dir + "/icons", "png", false, FilesSet.TypeOfGet.NamesOfFiles); for (int a = 0; a < icons.Length; a++) { if (icons[a].IndexOf("os_") >= 0) { FileStream streamimg = File.Open(curProj.dir + "/icons/" + icons[a] + ".png", FileMode.Open); byte[] imgbt = new byte[streamimg.Length]; streamimg.Read(imgbt, 0, imgbt.Length); streamimg.Close(); Texture2D imgtex = new Texture2D(0, 0); imgtex.LoadImage(imgbt); curProj.oss.Add(Sprite.Create(imgtex, new Rect(0.0f, 0.0f, imgtex.width, imgtex.height), new Vector2(0.5f, 0.5f))); curProj.ossp.Add(icons[a].Replace("os_", "")); } if (icons[a].IndexOf("func_") >= 0) { FileStream streamimg = File.Open(curProj.dir + "/icons/" + icons[a] + ".png", FileMode.Open); byte[] imgbt = new byte[streamimg.Length]; streamimg.Read(imgbt, 0, imgbt.Length); streamimg.Close(); Texture2D imgtex = new Texture2D(0, 0); imgtex.LoadImage(imgbt); curProj.funcs.Add(Sprite.Create(imgtex, new Rect(0.0f, 0.0f, imgtex.width, imgtex.height), new Vector2(0.5f, 0.5f))); curProj.funcsp.Add(icons[a].Replace("func_", "")); } } } //get theme.conf if (FilesSet.CheckFile(curProj.dir + "/theme.conf", false)) { List <string> conf = FilesSet.LoadStream(curProj.dir + "/theme.conf", false).ToList(); for (int c = 0; c < conf.Count; c++) { if (!((conf[c].IndexOf("#")) >= 0) && (conf[c].IndexOf("big_icon_size ") >= 0)) { curProj.bigicon = int.Parse(conf[c].Replace("big_icon_size ", "")); } if (!((conf[c].IndexOf("#")) >= 0) && (conf[c].IndexOf("small_icon_size ") >= 0)) { curProj.smallicon = int.Parse(conf[c].Replace("small_icon_size ", "")); } } if (curProj.bigicon == 0) { curProj.bigicon = 256; } if (curProj.smallicon == 0) { curProj.smallicon = 96; } } else { curProj.bigicon = 256; curProj.smallicon = 96; } //setup workspace scene.bg.sprite = curProj.bg; config.bigicon.text = curProj.bigicon + ""; config.smallicon.text = curProj.smallicon + ""; prevopt.screenX.text = Screen.width + ""; prevopt.screenY.text = Screen.height + ""; prevopt.selbig.sprite = curProj.b_select; prevopt.selsmall.sprite = curProj.l_select; prevopt.bgimg.sprite = curProj.bg; for (int o = 0; o < curProj.oss.Count; o++) { GameObject obj = Instantiate(prevopt.togpresset, prevopt.osscroll); obj.SetActive(true); FastFind.FindChild(obj.transform, "Icon").GetComponent <Image>().sprite = curProj.oss[o]; FastFind.FindChild(obj.transform, "Name").GetComponent <Text>().text = curProj.ossp[o]; obj.GetComponent <ProjPrevToggle>().i = o; obj.GetComponent <ProjPrevToggle>().tpe = ProjPrevToggle.tp.os; prevopt.ostog.Add(obj.GetComponent <Toggle>()); } for (int f = 0; f < curProj.funcs.Count; f++) { GameObject obj = Instantiate(prevopt.togpresset, prevopt.funcscroll); obj.SetActive(true); FastFind.FindChild(obj.transform, "Icon").GetComponent <Image>().sprite = curProj.funcs[f]; FastFind.FindChild(obj.transform, "Name").GetComponent <Text>().text = curProj.funcsp[f]; obj.GetComponent <ProjPrevToggle>().i = f; obj.GetComponent <ProjPrevToggle>().tpe = ProjPrevToggle.tp.func; prevopt.functog.Add(obj.GetComponent <Toggle>()); } }