Exemplo n.º 1
0
 private void bindHistorySettings()
 {
     try {
         var rs = new XmlReaderSettings {
             IgnoreWhitespace = false
         };
         var xml = HistorySettings.Default.HistoryList;
         using (var stream = new MemoryStream(System.Text.Encoding.Unicode.GetBytes(xml)))
             using (var reader = XmlReader.Create(stream, rs)) {
                 XmlSerializer serializer = new XmlSerializer(typeof(List <RequestViewModel>), new XmlRootAttribute("History"));
                 var           results    = (List <RequestViewModel>)serializer.Deserialize(reader);
                 results.Reverse <RequestViewModel>().Each(rvm => {
                     var snapshot = new RequestResponseSnapshot {
                         request  = rvm,
                         response = ResponseModel.Empty
                     };
                     snapshots.Add(snapshot);
                 });
                 bindSnapshots();
             }
     } catch (Exception ex) {
         log.Error(ex);
         var historySettings = Properties.HistorySettings.Default;
         historySettings.HistoryList = "<History></History>";
         historySettings.Save();
         showError("Error - " + programName, "Error loading History due to possible data corruption. Your History has been cleared in order to ensure normal application function.");
     }
 }
Exemplo n.º 2
0
 public void PreviousCommand()
 {
     Create("");
     _commandHistoryList.Add("dog");
     _vimBuffer.ProcessNotation(":<Up>");
     Assert.Equal("dog", _commandMode.Command);
 }
 public static void AddNewMessage(Message msg)
 {
     lock (Messages)
     {
         Messages.Add(msg);
     }
 }
Exemplo n.º 4
0
        public async Task <ChangeWallpaperResult> SetWallpaperAsync(ImageInfo imageInfo, IProgress <string> progress)
        {
            var wallpaperFilePath = await ImageLoader.TryLoadImageAsync(imageInfo, progress);

            if (string.IsNullOrEmpty(wallpaperFilePath))
            {
                return(ChangeWallpaperResult.Failed());
            }

            await WallpaperSetter.SetWallpaperAsync(wallpaperFilePath, progress);

            HistoryList.Add(imageInfo.ThreadId);
            Database.AddWallpaperToHistory(imageInfo.Url, imageInfo.Title, imageInfo.ThreadId);

            ThumbnailCacheBuilder.BuildThumbnailCache();

            if (Properties.Settings.Default.autoSave == true)
            {
                Savewallpaper.SaveWallpaper(Properties.Settings.Default.currentWallpaperName);
            }

            CurrentWallpaperHolder.SetCurrentWallpaper(imageInfo, wallpaperFilePath);

            return(new ChangeWallpaperResult(true, imageInfo.Title, imageInfo.ThreadId));
        }
Exemplo n.º 5
0
        private async void SongUpdateTimer_Tick(object sender, object e)
        {
            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, HistoryUrl);

            using (HttpResponseMessage response = await HistoryClient.SendAsync(request))
            {
                string content = await response.Content.ReadAsStringAsync();

                content.Trim();
                string[] songs = content.Split("\n");
                Array.Reverse(songs);

                if (songs.Length > 1)
                {
                    CurrentSong = songs[1];
                }

                HistoryList.Clear();
                foreach (string song in songs)
                {
                    if (!string.IsNullOrEmpty(song))
                    {
                        HistoryList.Add(song);
                    }
                }
            }
        }
Exemplo n.º 6
0
 public static void AddRange(this HistoryList historyList, params string[] values)
 {
     foreach (var cur in values)
     {
         historyList.Add(cur);
     }
 }
Exemplo n.º 7
0
        private void ImportFromExcel()
        {
            Unit _unit;
            var  rows = new List <Unit>();

            ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
            ExcelPackage excelPackage = new ExcelPackage(new FileInfo(FilePath));

            if (excelPackage.File.Exists == false)
            {
                MessageBox.Show("Invalid input. File does not exist", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            var sheet = excelPackage.Workbook.Worksheets.First();

            for (int row = 2; row <= sheet.Dimension.End.Row; row++)
            {
                _unit = createUnit((string)sheet.Cells[row, 2].Value);
                _unit.Calculate((double)sheet.Cells[row, 1].Value, "to " + (string)sheet.Cells[row, 3].Value);

                HistoryList.Add(_unit);
            }
            OldUnitValue    = HistoryList.Last().GetOldValue();
            SelectedOldUnit = HistoryList.Last().GetThisUnit();
            SelectedNewUnit = HistoryList.Last().GetNewUnit().Remove(0, 3);

            RaisePropertyChanged(nameof(OldUnitValue));
            RaisePropertyChanged(nameof(SelectedOldUnit));
            RaisePropertyChanged(nameof(SelectedNewUnit));

            AssignAnswerValues();

            RaiseButtonCanExecute();
        }
Exemplo n.º 8
0
        public static void Save(IHistory orgHistory, User user, HistoryAction action = HistoryAction.Создал)
        {
            HistoryList historyList = HistoryList.GetUniqueInstance();

            History history;

            if (action == HistoryAction.Удалил)
            {
                history        = new History(orgHistory, user);
                history.Action = action;
            }
            else
            {
                var list = historyList.GetList(orgHistory);

                if (list.Count == 2)
                {
                    history       = historyList.GetItem(orgHistory, HistoryAction.едактировал);
                    history._user = user;
                }
                else
                {
                    history        = new History(orgHistory, user);
                    history.Action = (list.Count == 0) ? HistoryAction.Создал : HistoryAction.едактировал;
                }
            }

            history._datetime = DateTime.Now;

            history.Save();

            historyList.Add(history);
        }
Exemplo n.º 9
0
        private void CalculateAnswer()
        {
            unit = createUnit(SelectedOldUnit);
            unit.Calculate(OldUnitValue, "to " + SelectedNewUnit);

            HistoryList.Add(unit);

            AssignAnswerValues();
            RaiseButtonCanExecute();
        }
Exemplo n.º 10
0
 void Refresh()
 {
     HistoryList.Clear();
     foreach (var item in _codeStorageManager.Codes)
     {
         HistoryList.Add(new HistoryItem {
             Code = item.Code, Status = item.Status
         });
     }
 }
Exemplo n.º 11
0
        private void addRequestResponseSnapshot(RequestViewModel requestVm, ResponseModel responseModel)
        {
            //update the model
            snapshots.Add(new RequestResponseSnapshot()
            {
                request = requestVm, response = responseModel
            });

            //update the view
            bindSnapshots();
        }
Exemplo n.º 12
0
        public void PushHistory(string entry)
        {
            entry.CheckArgument(nameof(entry));

            LastAccessDate = DateTime.Now;
            HistoryList.Add(entry);
            if (HistoryList.Count > MaxSize)
            {
                HistoryList.RemoveAt(0);
            }
        }
 public void DummyHistoryList()
 {
     HistoryList.Add(new HistoryModel {
         Number = "00966 56 1126458", CallType = "Missed", CallDate = "Oct 22 01:24 PM", makecall = false
     });
     HistoryList.Add(new HistoryModel {
         Number = "00966 56 1126458", CallType = "Income", CallDate = "Oct 22 01:24 PM", makecall = false
     });
     HistoryList.Add(new HistoryModel {
         Number = "00966 56 1126458", CallType = "outcome", CallDate = "Oct 22 01:24 PM", makecall = false
     });
     HistoryList.Add(new HistoryModel {
         Number = "00966 56 1126458", CallType = "Missed", CallDate = "Oct 22 01:24 PM", makecall = false
     });
     HistoryList.Add(new HistoryModel {
         Number = "00966 56 1126458", CallType = "Income", CallDate = "Oct 22 01:24 PM", makecall = false
     });
     HistoryList.Add(new HistoryModel {
         Number = "00966 56 1126458", CallType = "outcome", CallDate = "Oct 22 01:24 PM", makecall = false
     });
     HistoryList.Add(new HistoryModel {
         Number = "00966 56 1126458", CallType = "Missed", CallDate = "Oct 22 01:24 PM", makecall = false
     });
     HistoryList.Add(new HistoryModel {
         Number = "00966 56 1126458", CallType = "Income", CallDate = "Oct 22 01:24 PM", makecall = false
     });
     HistoryList.Add(new HistoryModel {
         Number = "00966 56 1126458", CallType = "outcome", CallDate = "Oct 22 01:24 PM", makecall = false
     });
     foreach (var item in HistoryList)
     {
         if (item.CallType == "Income")
         {
             item.Image = "income.png";
         }
         else if (item.CallType == "outcome")
         {
             item.Image = "outcome.png";
         }
         else
         {
             item.Image = "missed.png";
         }
     }
 }
            public void SetTab(Tabs tab)
            {
                _AktuellerTab = tab;
                try
                {
                    if (tab == Tabs.Home)
                    {
                        BaseActivity.Window.SetTitle(Functions.FormatTitle("Einstellungen"));
                    }
                    else
                    {
                        BaseActivity.Window.SetTitle(Functions.FormatTitle(tab.ToString()));
                    }
                }
                catch { }
                HistoryList.Add(tab);
                switch (tab)
                {
                case Tabs.Home:
                    MainListView.Adapter = HomeTabAdapter;
                    items = HomeTabAdapter.ItemList;
                    return;

                case Tabs.LiveWallpaper:
                    MainListView.Adapter = LiveWallpaperAdapter;
                    items = LiveWallpaperAdapter.ItemList;
                    return;

                case Tabs.Design:
                    MainListView.Adapter = DesignAdapter;
                    items = DesignAdapter.ItemList;
                    return;

                case Tabs.Upload:
                    MainListView.Adapter = UploadTabAdapter;
                    items = UploadTabAdapter.ItemList;
                    return;

                case Tabs.DeveloperMode:
                    MainListView.Adapter = DeveloperModeTabAdapter;
                    items = DeveloperModeTabAdapter.ItemList;
                    return;
                }
            }
Exemplo n.º 15
0
        async void AddHistoryFrom(string selected_path, int skip_count)
        {
            if (_gitRepository.TryGetTarget(out IGitRepository gitRepository) == false)
            {
                return;
            }
            var waiter  = gitRepository.GetGitWrapper().GetHistory(selected_path, skip_count, /*max_count=*/ 20);
            var commits = await waiter;

            foreach (var commit in commits)
            {
                HistoryStatus status = new HistoryStatus();
                status.Graph         = commit.Graph;
                status.LocalDateTime = commit.LocalTimeDate;
                if (commit.Sha != null)
                {
                    status.CommitId = commit.Sha.Substring(0, 7);
                }
                else
                {
                    status.CommitId = null;
                }
                status.Sha     = commit.Sha;
                status.Author  = commit.Author;
                status.Message = commit.Message;
                status.ListMessage_RefNames = commit.RefNames?.Trim();
                status.ListMessage          = status.Message;
                status.Comment = commit.Message;
                status.Detail  = MakeDetail(commit);
                status.historyTabViewModel_ = this;
                status.FontWeight           = FontWeights.Normal;
                if (commit.RefNames != null && commit.RefNames.Contains(string.Format("HEAD -> {0}", CurrentBranchName)))
                {
                    status.FontWeight = FontWeights.Bold;
                }
                HistoryList.Add(status);
            }

            NotifyPropertyChanged("HistoryList");
        }
Exemplo n.º 16
0
        public bool TryPushHistoryItem(Rock.Client.Family family, HistoryItem.OnHistoryItemClick onClick)
        {
            // key off the family's ID to see if it's unique or not.
            if (HistoryList.Where(h => h.Family.Id == family.Id).SingleOrDefault( ) == null)
            {
                HistoryItem newItem = new HistoryItem(family, onClick);

                // now add it to our list
                HistoryList.Add(newItem);

                // cap the list at 4 (beyond that, start dropping off the oldest one)
                if (HistoryList.Count > MaxHistory)
                {
                    HistoryList.RemoveAt(0);
                }

                UpdateItems( );

                return(true);
            }
            return(false);
        }
Exemplo n.º 17
0
        public HistoryViewModel()
        {
            using (var context = new EventDatabaseEntities())
            {
                int CurrentIndex = 0;
                // Get every date when was an event.
                var dates = context.Events.Where(x => DbFunctions.TruncateTime(x.Date) < DateTime.Today)
                            .GroupBy(r => DbFunctions.TruncateTime(r.Date)).OrderByDescending(x => x.Key).ToList();

                // Set the date indicators.
                ToDate   = dates.ElementAt(0).Key.ToString();
                FromDate = dates.ElementAt(dates.Count() - 1).Key.ToString();

                foreach (var events in dates)
                {
                    // Every event that happend at this day.
                    var Events = context.Events.Where(x => DbFunctions.TruncateTime(x.Date) == events.Key).ToList();

                    // Add the date to the list.
                    HistoryList.Add(new HistoryModel()
                    {
                        EventDate = (DateTime)events.Key
                    });

                    // Get the tasks for the events if there any.
                    foreach (var task in Events)
                    {
                        var tasks = context.Tasks.Where(x => x.EventID == task.ID).ToList();
                        HistoryList.ElementAt(CurrentIndex).EventList.Add(new HistoryListModel(task, tasks));
                    }

                    CurrentIndex++;
                }
            }

            DateFilterCommand  = new RelayCommand(DateFilterEvent);
            DeleteEventCommand = new RelayParamCommand <Event>(DeleteEvent);
            CloseEventCommand  = new RelayCommand(CloseEvent);
        }
Exemplo n.º 18
0
        public static void AddEntry(HistoryEntity newData)
        {
            if (!is_enable)
            {
                return;
            }

            if (cur_index == -1)
            {
                cur_index = 0;
            }
            else
            {
                cur_index += 1;
                if (cur_index < HistoryList.Count)
                {
                    HistoryList.RemoveRange(cur_index, HistoryList.Count - cur_index);
                }
            }

            HistoryList.Add(newData);
        }
Exemplo n.º 19
0
        private static void AddNewMessage(Message msg)
        {
            var packet = new S2C_NewMessage(msg);

            lock (Messages)
            {
                Messages.Add(msg);
                foreach (var con in Server.Connections)
                {
                    if (con.Value.Connected && con.Value.Data.Get("Connected", false))
                    {
                        try
                        {
                            con.Value.Send(packet);
                        }
                        catch
                        {
                        }
                    }
                }
            }
        }
Exemplo n.º 20
0
 private void AddToHistory(string v, string date, bool toggle)
 {
     HistoryList.Add(new HistoryVM("Button " + v, toggle, date));
 }
Exemplo n.º 21
0
        private void ExecuteLoadHistoryCommand(UDOSight claim)
        {
            HistoryList.Clear();
            //изменения за сегдня
            var updatelist = _visingCore.GetUpdateList(claim);

            foreach (var item in updatelist)
            {
                var updatelistdetail = _visingCore.GetUpdateListDetail(item);
                foreach (var itemdetail in updatelistdetail)
                {
                    var historicalAction = new RevisionHistoryUdoSight {
                        Date = item.MODIFDATE, Who = item.AUTHID
                    };
                    historicalAction.Action = new GroupNameConverter().Convert("Claim." + itemdetail.COLUMNNAME, null, null, null).ToString();
                    if (itemdetail.COLUMNNAME == "STATE")
                    {
                        if (itemdetail.NUMVALUE != null)
                        {
                            historicalAction.Value = new ValueToStateConverter().Convert(itemdetail.NUMVALUE, null, null, null).ToString();
                            if (itemdetail.UPDNUMVALUE != null)
                            {
                                historicalAction.OldValue = new ValueToStateConverter().Convert(itemdetail.UPDNUMVALUE, null, null, null).ToString();
                            }
                        }
                    }
                    else
                    if (itemdetail.STRVALUE != null)
                    {
                        historicalAction.Value    = itemdetail.STRVALUE;
                        historicalAction.OldValue = itemdetail.UPDSTRVALUE;
                    }
                    if (historicalAction.OldValue != historicalAction.Value)
                    {
                        HistoryList.Add(historicalAction);
                    }
                }
            }
            //изменениния из архива
            var updatelistarc = _visingCore.GetUpdateListArc(claim);

            foreach (var item in updatelistarc)
            {
                var updatelistdetail = _visingCore.GetUpdateListDetailArc(item);
                foreach (var itemdetail in updatelistdetail)
                {
                    var historicalAction = new RevisionHistoryUdoSight {
                        Date = item.MODIFDATE, Who = item.AUTHID
                    };

                    historicalAction.Action = new GroupNameConverter().Convert(itemdetail.COLUMNNAME, null, null, null).ToString();
                    if (itemdetail.NUMVALUE != null)
                    {
                        historicalAction.Value = new ValueToStateConverter().Convert(itemdetail.NUMVALUE, null, null, null).ToString();
                        if (itemdetail.UPDNUMVALUE != null)
                        {
                            historicalAction.OldValue = new ValueToStateConverter().Convert(itemdetail.UPDNUMVALUE, null, null, null).ToString();
                        }
                    }
                    else
                    if (itemdetail.STRVALUE != null)
                    {
                        historicalAction.Value    = itemdetail.STRVALUE;
                        historicalAction.OldValue = itemdetail.UPDSTRVALUE;
                    }
                    if (historicalAction.OldValue != historicalAction.Value)
                    {
                        HistoryList.Add(historicalAction);
                    }
                }
            }
            HistoryList = new ObservableCollection <RevisionHistoryUdoSight>(HistoryList.OrderByDescending(x => x.Date));
        }