Example #1
0
 public void Refresh()
 {
     if (m_parent != null)
     {
         m_parent.Refresh();
     }
 }
Example #2
0
 public void UpdateInPlaceControlFromValue(PropertyEnumerator propEnum)
 {
     if (mInPlaceCtrl != null)
     {
         (mInPlaceCtrl as IInPlaceControl).OwnerPropertyEnumerator = propEnum;
         mInPlaceCtrl.Refresh();
     }
 }
Example #3
0
        /*
         * SendMessage( .Handle, WM_SETREDRAW, IntPtr(CInt(False)), IntPtr.Zero)
         */
        public static void enableRedraw(System.Windows.Forms.Control control, bool bEnable)
        {
            IntPtr hwnd = control.Handle;

            SendMessage(hwnd, WM_SETREDRAW, Convert.ToInt32(bEnable), 0);
            if (bEnable)
            {
                control.Refresh();
            }
        }
Example #4
0
 /// <summary>
 /// 恢复控件刷新
 /// </summary>
 /// <param name="yourCtr">your Control</param>
 public static void SetControlUnfreeze(System.Windows.Forms.Control yourCtr)
 {
     UnsafeNativeMethods.SendMessage(yourCtr.Handle, WM_SETREDRAW, 1, IntPtr.Zero);
     yourCtr.Refresh();
 }
Example #5
0
 public static void ResumeDrawing(this System.Windows.Forms.Control control)
 {
     SendMessage(control.Handle, WM_SETREDRAW, true, 0);
     control.Refresh();
 }
Example #6
0
 public static void ResumeDrawing(System.Windows.Forms.Control parent)
 {
     _ = SendMessage(parent.Handle, WM_SETREDRAW, true, 0);
     parent.Refresh();
 }
        //this is for updating the webpage and should be removed if the webpage gets an actual webhost
        //and can do this automatically
        public async void UpdateAll(System.Windows.Forms.Control log)
        {
            if (!Directory.Exists("images"))
            {
                Directory.CreateDirectory("images");
            }
            await AwaitHttpLock();

            String length = items.Values.Count.ToString();
            int    num    = 0;

            foreach (Dictionary <String, String> item in items.Values)
            {
                if (!item.TryGetValue("url_name", out String url_name))
                {
                    continue;
                }
                if (!item.TryGetValue("thumb", out String thumb_url))
                {
                    log.Text = num.ToString() + "/" + length + "  Updating " + url_name + " data";
                    log.Refresh();
                    try
                    {
                        using (HttpResponseMessage responce = await client.GetAsync(@"items/" + url_name))
                        {
                            var str = await responce.Content.ReadAsStringAsync();

                            dynamic payload = Newtonsoft.Json.JsonConvert.DeserializeObject(str);
                            Newtonsoft.Json.Linq.JArray jitems = payload.payload.item.items_in_set;
                            foreach (Newtonsoft.Json.Linq.JObject jitem in jitems)
                            {
                                String iname = jitem.Value <Newtonsoft.Json.Linq.JObject>("en").Value <String>("item_name").ToUpper();

                                if (items.TryGetValue(iname, out Dictionary <String, String> possible_data))
                                {
                                    if (jitem.TryGetValue("ducats", out Newtonsoft.Json.Linq.JToken ducats))
                                    {
                                        possible_data["ducats"] = ducats.ToString();
                                    }
                                    if (jitem.TryGetValue("thumb", out Newtonsoft.Json.Linq.JToken thumb))
                                    {
                                        possible_data["thumb"] = thumb.ToString();
                                    }
                                    if (jitem.TryGetValue("rarity", out Newtonsoft.Json.Linq.JToken rarity))
                                    {
                                        possible_data["rarity"] = rarity.ToString();
                                    }
                                }
                            }
                        }
                        item.TryGetValue("thumb", out thumb_url);
                        await Task.Delay(1000);
                    }
                    catch (Exception e) { }
                }
                try
                {
                    log.Text = num.ToString() + "/" + length + "  Updating " + url_name + " price";
                    log.Refresh();
                    using (HttpResponseMessage responce = await client.GetAsync(@"items/" + url_name + "/statistics"))
                    {
                        var str = await responce.Content.ReadAsStringAsync();

                        Newtonsoft.Json.Linq.JObject payload = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(str).payload;
                        Newtonsoft.Json.Linq.JArray  jitems  = payload.Value <Newtonsoft.Json.Linq.JObject>("statistics").Value <Newtonsoft.Json.Linq.JArray>("90days");
                        if (jitems.HasValues)
                        {
                            Dictionary <String, String> stats = jitems.Last.ToObject <Dictionary <String, String> >();
                            foreach (var i in stats)
                            {
                                item[i.Key] = i.Value;
                            }
                        }
                        item["Price Last Updated"] = DateTime.UtcNow.ToString();
                    }
                }
                catch (Exception e)
                { }
                await Task.Delay(1000);

                if ((!item.TryGetValue("local_thumb", out string file_name) || !File.Exists(file_name)) && thumb_url != "")
                {
                    try
                    {
                        log.Text = num.ToString() + "/" + length + "  Updating " + url_name + " thumbnail";
                        log.Refresh();
                        Stream s = await image_client.GetStreamAsync(thumb_url);

                        Bitmap thumb = new Bitmap(Image.FromStream(s));
                        String fname = "images/" + item["item_name"].ToUpper() + "thumb.bmp";
                        thumb.Save(fname);
                        item["local_thumb"] = fname;
                        await Task.Delay(1000);
                    }
                    catch (Exception e)
                    { }
                }
                ++num;
            }
            http_lock = false;
            Save();
            log.Text = "Done!";
        }