private void frmCyberTrack_Load(object sender, EventArgs e) { if (Directory.Exists(Path.GetTempPath() + @"\CyberApp\CyberTrack")) { string[] files = Directory.GetFiles(Path.GetTempPath() + @"\CyberApp\CyberTrack"); foreach (var file in files) { FileInfo fileInfo = new FileInfo(file); if (fileInfo.Extension.Equals(".json")) { var item = Objeto.FromJson(File.ReadAllText(file)); if (Regex.Match(item.Codigo, @"^[A-Z]{2}[\d]{9}[A-Z]{2}$").Success) { uiItem uiItem = new uiItem(); uiItem.ItemTitle = Path.GetFileNameWithoutExtension(fileInfo.FullName); uiItem.ItemCodigoRastreio = item.Codigo; uiItem.ItemImage = Properties.Resources.correios; uiItem.Click += UiItem_Click; uiItem.Tag = Path.GetFileNameWithoutExtension(fileInfo.FullName); uiItem.LabelTitle.Click += UiItem_Click; uiItem.LabelTitle.Tag = Path.GetFileNameWithoutExtension(fileInfo.FullName); uiItem.LabelCompany.Click += UiItem_Click; uiItem.LabelCompany.Tag = Path.GetFileNameWithoutExtension(fileInfo.FullName); uiItem.PictureCompany.Click += UiItem_Click; uiItem.PictureCompany.Tag = Path.GetFileNameWithoutExtension(fileInfo.FullName); uiFlowEncomendas.Controls.Add(uiItem); } } } } }
private void UiItem_Click(object sender, EventArgs e) { var eventJson = string.Empty; if (sender is Panel) { Panel panel = sender as Panel; eventJson = File.ReadAllText(Path.GetTempPath() + String.Format(@"\CyberApp\CyberTrack\{0}.json", panel.Tag)); } else if (sender is Label) { Label label = sender as Label; eventJson = File.ReadAllText(Path.GetTempPath() + String.Format(@"\CyberApp\CyberTrack\{0}.json", label.Tag)); } else if (sender is PictureBox) { PictureBox pictureBox = sender as PictureBox; eventJson = File.ReadAllText(Path.GetTempPath() + String.Format(@"\CyberApp\CyberTrack\{0}.json", pictureBox.Tag)); } else if (sender is uiItem) { uiItem item = sender as uiItem; eventJson = File.ReadAllText(Path.GetTempPath() + String.Format(@"\CyberApp\CyberTrack\{0}.json", item.Tag)); } CreateBoxEvent(Objeto.FromJson(eventJson)); }
private void btnAdd_Click(object sender, EventArgs e) { var client = new RestClient("https://api.linketrack.com/track/json?user=teste&token=1abcd00b2731640e886fb41a8a9671ad1434c599dbaa0a0de9a5aa619f29a83f&codigo=" + txtCodigoRastreio.Text); client.Timeout = -1; var request = new RestRequest(Method.GET); IRestResponse response = client.Execute(request); if (IsValidateJSON(response.Content)) { switch (response.StatusCode) { case HttpStatusCode.OK: // Se o directório "Temp\CyberApp\CyberTrack não existe crie. if (!Directory.Exists(Path.GetTempPath() + String.Format(@"\CyberApp\CyberTrack"))) { Directory.CreateDirectory(Path.GetTempPath() + @"\CyberApp\CyberTrack"); } // Cria um arquivo .JSON para o objeto no directório "Temp /CyberApp/CyberTrack" File.WriteAllText(Path.GetTempPath() + String.Format(@"\CyberApp\CyberTrack\{0}.json", txtTitulo.Text), response.Content); break; case HttpStatusCode.NotFound: break; case HttpStatusCode.InternalServerError: MessageBox.Show("arruma isso ae camarada"); break; } } else { } uiItem uiItem = new uiItem() { ItemTitle = txtTitulo.Text, ItemCodigoRastreio = txtCodigoRastreio.Text, ItemImage = Properties.Resources.correios, }; uiFlowEncomendas.Controls.Add(uiItem); }
public void MapSet(bool vert, int x, int y, uiItem val) { uint idx=(uint)(((y&0x7FFF)<<17) | ((x&0xFFFF)<<1) | (vert?1:0)); lock(_map) { if(val==null) { _map.Remove(idx); } else { _map[idx]=val; } } //RenderBackground(); //Log.Debug("MapSet({0}, {1}, {2}) = {3}", vert?"V":"H", x, y, val); }
public void MapRemove(uiItem val) { lock(_map) { foreach(var i in _map.Where(z => z.Value==val).ToArray()) { _map.Remove(i.Key); //Log.Debug("MapRemove({0}, {1}, {2}) = {3}", (i.Key&1)!=0?"V":"H", (i.Key>>1) & 0xFFFF, (i.Key>>17) & 0x7FFF, i.Value); } } }