コード例 #1
0
        public async Task <bool> StoreNote(NoteItem note)
        {
            if (note == null)
            {
                throw new ArgumentNullException(nameof(note));
            }

            await Task.Delay(500);

            NoteItem storedNote;

            if (!string.IsNullOrEmpty(note.Id))
            {
                storedNote = _notes.FirstOrDefault(n => n.Id == note.Id);
                if (storedNote == null)
                {
                    return(false);
                }

                storedNote.Title      = note.Title;
                storedNote.Content    = note.Content;
                storedNote.LastEdited = DateTime.Now;
                NoteEdited?.Invoke(this, new NoteEvent(storedNote.Clone()));
            }
            else
            {
                storedNote    = note;
                storedNote.Id = (_notes.Last().Id + 1); // todo: replace with Snowflake ID...
                _notes.Add(storedNote);
                NoteAdded?.Invoke(this, new NoteEvent(storedNote.Clone()));
            }

            return(true);
        }
コード例 #2
0
 public void When(NoteAdded e)
 {
     StepRecordId(e.NoteId);
     var item = new NoteItem(e.Title, e.Text, e.NoteId, e.StoryId);
     _items.Add(e.NoteId, item);
     var story = _stories[e.StoryId];
     story.AsItGoes.Add(e.NoteId);
 }
コード例 #3
0
 public async Task AddNote(string note)
 {
     if (newNotesPin == null)
     {
         await InitGpioPin();
     }
     notes.Add(note);
     NewNotesAvailable = true;
     if (NoteAdded != null)
     {
         NoteAdded.Invoke(this, new EventArgs());
     }
 }
コード例 #4
0
        private void AddNoteToDatabase(object sender, EventArgs e)
        {
            string noteDetails = NoteText.Text;

            noteDetails = noteDetails.ToUpper().Trim();

            if (noteDetails.Length > 0)
            {
                if (NoteAdded != null)
                {
                    NoteAdded.Invoke(this, new GenericNoteEventArgs(noteDetails));
                }
            }

            Dismiss();
        }
コード例 #5
0
        private void AddNoteToDatabase(object sender, EventArgs e)
        {
            string totalCost   = TotalCostText.Text.ToUpper().Trim();
            string costPerUnit = CostPerUnitText.Text.ToUpper().Trim();
            string unitsText   = UnitText.Text.ToUpper().Trim();

            if ((totalCost.Length > 0) || (costPerUnit.Length > 0) || unitsText.Length > 0)
            {
                if (NoteAdded != null)
                {
                    NoteAdded.Invoke(this, new PetrolNotesEventArgs(unitsText, costPerUnit, totalCost));
                }
            }

            Dismiss();
        }
コード例 #6
0
        async private void TextChanged(object sender, TextChangedEventArgs e)
        {
            var note = BindingContext as Notes;

            if (note.Id == 0)
            {
                await _connection.InsertAsync(note);

                NoteAdded?.Invoke(this, note);
            }
            else
            {
                await _connection.UpdateAsync(note);

                NoteUpdated?.Invoke(this, note);
            }
        }
コード例 #7
0
        private void ButtonOK_OnClick(object sender, RoutedEventArgs e)
        {
            if (contentTextbox.Text == "")
            {
                contentTextbox.ShowPopUpOnControl("记事内容不能为空", 3000);
                return;
            }

            if (allDayCheckBox.IsChecked != null && (!allDayCheckBox.IsChecked.Value && timeTextBox.Text == ""))
            {
                timeTextBox.ShowPopUpOnControl("时间不能为空", 3000);
                return;
            }

            DateTime time = DateTime.Now;

            if (allDayCheckBox.IsChecked != null && !allDayCheckBox.IsChecked.Value)
            {
                try
                {
                    time = DateTime.Parse(timeTextBox.Text);
                }
                catch (Exception)
                {
                    timeTextBox.ShowPopUpOnControl("时间格式不正确,格式为 HH:ss(例如:12:00)", 3000);
                    return;
                }
            }

            var note = new Note
            {
                Date = time,
                Type =
                    allDayCheckBox.IsChecked != null && allDayCheckBox.IsChecked.Value
                        ? Note.NoteType.Day
                        : Note.NoteType.Time,
                Circle  = Note.CircleType.Once,
                Content = contentTextbox.Text
            };

            NoteAdded?.Invoke(note);

            this.Close();
        }
コード例 #8
0
    public async Task AddNote(IPlayerSession createdBy, Guid player, string message)
    {
        _sawmill.Info($"Player {createdBy.Name} added note with message {message}");

        _systems.TryGetEntitySystem(out GameTicker? ticker);
        int?round     = ticker == null || ticker.RoundId == 0 ? null : ticker.RoundId;
        var createdAt = DateTime.UtcNow;
        var noteId    = await _db.AddAdminNote(round, player, message, createdBy.UserId, createdAt);

        var note = new SharedAdminNote(
            noteId,
            round,
            message,
            createdBy.Name,
            createdBy.Name,
            createdAt,
            createdAt
            );

        NoteAdded?.Invoke(note);
    }
コード例 #9
0
 public void AddNote(Note note)
 {
     notes.Add(note);
     NoteAdded?.Invoke(this);
 }
コード例 #10
0
ファイル: NoteManager.cs プロジェクト: umutocak/tinote
 protected virtual void OnNoteAdded(NoteAddedEventArgs e)
 {
     NoteAdded?.Invoke(this, e);
 }
コード例 #11
0
 protected void Apply(NoteAdded e)
 {
     _notes.Add(new Note(e.NoteId, e.AuthorId, e.Timestamp, e.Content));
 }
コード例 #12
0
 protected void OnNewNoteAdded(NoteAdded e)
 {
     this.text         = e.Text;
     this.creationDate = e.CreationDate;
 }
コード例 #13
0
 private void toolStripMenuItemAddNote_Click(object sender, EventArgs e)
 {
     NoteAdded?.Invoke(sender, new EventArgs());
 }
コード例 #14
0
 public void Consume(NoteAdded e)
 {
     AddRecord(e.NoteId, e.Title);
 }