private void LoadData(List <LoginFieldS> listlp)
        {
            SourceItems.Clear();
            SourceAllItems.Clear();
            DataBase           db   = new DataBase();
            List <LoginFieldS> llp  = db.getInfoFromDB("*", "", "");
            Converts           conv = new Converts();

            if (listlp != null && listlp.Any())
            {
                foreach (LoginFieldS lf in listlp)
                {
                    DrawingImage tmpDraw = new DrawingImage();
                    if (lf.imageData == null || lf.imageData.Length == 0)
                    {
                        tmpDraw = HIOStaticValues.PutTextInImage(lf.url.Substring(0, 1));
                    }
                    else
                    {
                        tmpDraw = conv.BitmapImageToDrawingImage(conv.byteArrayToImage(lf.imageData));
                    }

                    SourceItems.Add(new TLinkItem {
                        Title = lf.title, Description = lf.userName, ImageData = tmpDraw, Id = Int32.Parse(lf.rowid), Url = url
                    });
                }
            }
            if (llp != null && llp.Any())
            {
                foreach (LoginFieldS lf in llp)
                {
                    DrawingImage tmpDraw = new DrawingImage();
                    if (lf.imageData == null || lf.imageData.Length == 0)
                    {
                        tmpDraw = HIOStaticValues.PutTextInImage(lf.url.Substring(0, 1));
                    }
                    else
                    {
                        tmpDraw = conv.BitmapImageToDrawingImage(conv.byteArrayToImage(lf.imageData));
                    }

                    SourceAllItems.Add(new TLinkItem {
                        Title = lf.title, Description = lf.userName, ImageData = tmpDraw, Id = Int32.Parse(lf.rowid), Url = lf.url
                    });
                }
            }


            OnPropertyChanged(() => Items);
        }
Ejemplo n.º 2
0
        private void LoadData(List <LoginFieldS> lf)
        {
            SourceItems.Clear();


            if (lf != null && lf.Count > 0)
            {
                Converts conv = new Converts();
                foreach (LoginFieldS fields in lf)
                {
                    DrawingImage tmpDraw = new DrawingImage();
                    if (fields.imageData == null || fields.imageData.Length == 0)
                    {
                        tmpDraw = HIOStaticValues.PutTextInImage(fields.url.Substring(0, 1));
                    }
                    else
                    {
                        tmpDraw = conv.BitmapImageToDrawingImage(conv.byteArrayToImage(fields.imageData));
                    }

                    SourceItems.Add(new TLinkItem(fields.title, fields.userName, tmpDraw, Int32.Parse(fields.rowid), fields.url));
                }
            }
            OnPropertyChanged(() => Items);
        }
Ejemplo n.º 3
0
 private void Fv_GetFromUrlAsyncCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
 {
     App.Current.Dispatcher.BeginInvoke(new Action(() =>
     {
         Converts conv = new Converts();
         if ((sender as Favicon).Icon != null)
         {
             IconUrl = conv.BitmapImageToDrawingImage((sender as Favicon).Icon);
         }
     }));
 }
        public async Task LoadingAsync()
        {
            try
            {
                if (HIOStaticValues.CheckSyncingData())
                {
                    SyncronizingState = SyncronizingStateEnum.Syncronizing;
                    Trace.WriteLine("SyncronizingState in dashboard:" + SyncronizingState);
                    Trace.WriteLine("percent in dashboard:" + ProgressPercent);
                    DispatcherTimer dt = new DispatcherTimer();
                    dt.Interval = TimeSpan.FromSeconds(1);
                    dt.Tick    += Dt_Tick;
                    dt.Start();
                    return;
                }
                App.Current.Dispatcher.Invoke(new Action(() =>
                {
                    SourceItems.Clear();
                }));
                Converts conv = new Converts();
                DataBase db   = new DataBase();
                //  HIOStaticValues.commandQ.Add(()=> QBatteryandSignalCheckAsync());
                Commands ic = new Commands();
                HIOStaticValues.commandQ.Add(() =>
                {
                    BatteryValue = ic.GetBatteryStatus();
                });

                HIOStaticValues.commandQ.Add(() =>
                {
                    Commands cmd = new Backend.Commands();
                    cmd.GetRssi();
                    App.Current.Dispatcher.Invoke(new Action(() =>

                    {
                        SignalValue = cmd.GetSignalStatus(HIOStaticValues.blea.rssi);
                    }));
                });
                HIOStaticValues.commandQ.Add(() =>
                {
                    App.Current.Dispatcher.Invoke(new Action(async() =>

                    {
                        SyncronizingState = ic.AmISync();
                        if (SyncronizingState == SyncronizingStateEnum.NotSynced)
                        {
                            await Syncronize();
                        }
                    }));
                });

                App.Current.Dispatcher.Invoke(new Action(async() =>
                {
                    //READ DATA
                    lp = await Task.Run(() =>
                    {
                        return(db.ReadData());
                    });
                    if (lp != null)
                    {
                        ItemCounter = (lp.Count > 1) ? lp.Count + " Items" : lp.Count + " Item";
                    }
                    //Note : lp may be null
                    if (lp != null && lp.Any())
                    {
                        #region Load Data

                        List <TAccountItem> items = new List <TAccountItem>();
                        foreach (var item in lp)
                        {
                            DrawingImage tmpDraw = new DrawingImage();
                            if (item.imageData == null || item.imageData.Length == 0)
                            {
                                tmpDraw = HIOStaticValues.PutTextInImage(item.url.Substring(0, 1));
                            }
                            else
                            {
                                tmpDraw = conv.BitmapImageToDrawingImage(conv.byteArrayToImage(item.imageData));
                            }
                            items.Add(new TAccountItem(this)
                            {
                                UserID     = item.rowid,
                                Name       = item.title,
                                Username   = item.userName,
                                Url        = item.url,
                                ImageData  = tmpDraw,
                                AppID      = item.appID,
                                SubTitle1  = item.userName,
                                SubTitle2  = conv.GetPrettyDate(item.last_used),
                                Popularity = item.popularity,
                                Date       = item.last_used
                            });
                            //  items.Add(new User() { Title = listlp[i].title, Username = listlp[i].userName, rowid = listlp[i].rowid });
                        }
                        #endregion

                        #region Sort Data

                        if (SortByField.IsNullOrEmpty() || "Name".Equals(SortByField, StringComparison.InvariantCultureIgnoreCase))
                        {
                            items = items.OrderBy(t => t.Name).ToList();
                        }
                        else if ("Date".Equals(SortByField, StringComparison.InvariantCultureIgnoreCase))
                        {
                            items = items.OrderByDescending(t => t.Date).ToList();
                        }
                        else if ("Popularity".Equals(SortByField, StringComparison.InvariantCultureIgnoreCase))
                        {
                            items = items.OrderByDescending(t => t.Popularity).ToList();
                        }
                        #endregion
                        #region Add Data
                        foreach (var item in items)
                        {
                            SourceItems.Add(item);
                        }
                        #endregion
                    }
                    OnPropertyChanged(nameof(Items));
                }));
            }
            catch (Exception ex)
            {
            }
            finally
            {
                NotifyItemsChanged();
            }
        }
        public async Task LoadData()
        {
            try
            {
                App.Current.Dispatcher.Invoke(new Action(async() =>
                {
                    SourceItems.Clear();
                    DataBase db   = new DataBase();
                    Converts conv = new Converts();
                    lp            = await Task.Run(() =>
                    {
                        return(db.ReadData());
                    });
                    if (lp != null)
                    {
                        ItemCounter = (lp.Count > 1) ? lp.Count + " Items" : lp.Count + " Item";
                    }
                    //Note : lp may be null
                    if (lp != null && lp.Any())
                    {
                        #region Load Data

                        List <TAccountItem> items = new List <TAccountItem>();
                        foreach (var item in lp)
                        {
                            DrawingImage tmpDraw = new DrawingImage();
                            if (item.imageData == null || item.imageData.Length == 0)
                            {
                                tmpDraw = HIOStaticValues.PutTextInImage(item.url.Substring(0, 1));
                            }
                            else
                            {
                                tmpDraw = conv.BitmapImageToDrawingImage(conv.byteArrayToImage(item.imageData));
                            }
                            items.Add(new TAccountItem(this)
                            {
                                UserID     = item.rowid,
                                Name       = item.title,
                                Username   = item.userName,
                                Url        = item.url,
                                ImageData  = tmpDraw,
                                AppID      = item.appID,
                                SubTitle1  = item.userName,
                                SubTitle2  = conv.GetPrettyDate(item.last_used),
                                Popularity = item.popularity,
                                Date       = item.last_used
                            });
                            //  items.Add(new User() { Title = listlp[i].title, Username = listlp[i].userName, rowid = listlp[i].rowid });
                        }
                        #endregion
                        #region Sort Data

                        if (SortByField.IsNullOrEmpty() || "Name".Equals(SortByField, StringComparison.InvariantCultureIgnoreCase))
                        {
                            items = items.OrderBy(t => t.Name).ToList();
                        }
                        else if ("Date".Equals(SortByField, StringComparison.InvariantCultureIgnoreCase))
                        {
                            items = items.OrderByDescending(t => t.Date).ToList();
                        }
                        else if ("Popularity".Equals(SortByField, StringComparison.InvariantCultureIgnoreCase))
                        {
                            items = items.OrderByDescending(t => t.Popularity).ToList();
                        }
                        #endregion
                        #region Add Data

                        foreach (var item in items)
                        {
                            SourceItems.Add(item);
                        }
                        #endregion
                    }
                    OnPropertyChanged(nameof(Items));
                }));
            }
            catch {
            }
            finally
            {
                //   NotifyItemsChanged();
                //    SyncronizingState = SyncronizingStateEnum.Completed;
            }
        }