예제 #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
        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();
        }
예제 #3
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();
        }
예제 #4
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);
            }
        }
예제 #5
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();
        }
    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);
    }
예제 #7
0
 public void AddNote(Note note)
 {
     notes.Add(note);
     NoteAdded?.Invoke(this);
 }
예제 #8
0
 protected virtual void OnNoteAdded(NoteAddedEventArgs e)
 {
     NoteAdded?.Invoke(this, e);
 }
 private void toolStripMenuItemAddNote_Click(object sender, EventArgs e)
 {
     NoteAdded?.Invoke(sender, new EventArgs());
 }