コード例 #1
0
ファイル: PlayingPanel.cs プロジェクト: n28div/masterdrums
        /// <summary>
        /// Called by the notegenerator when a new note has been generated
        /// Thread safe
        /// </summary>
        /// <param name="ng">The note generator instance</param>
        public void Update(ISubject ng)
        {
            try
            {
                this._notesMutex.WaitOne();

                INote note = this._noteGenerator.CurrentNote;

                if (!(note is PauseNote))
                {
                    int timestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;

                    Point point;
                    if (note.Position == INote.notePosition.Left)
                    {
                        point = new Point(0, 0);
                    }
                    else
                    {
                        point = new Point(this.Size.Width, 0);
                    }

                    this._notes.AddLast(new Triplet <INote, Point, int>(note, point, timestamp));
                }
            }
            finally
            {
                this._notesMutex.ReleaseMutex();
            }
        }
コード例 #2
0
        public override void OnAfterUpload(INote iother)
        {
            var other = (EvernoteNote)iother;

            _updateSequenceNumber = other.UpdateSequenceNumber;
            _modificationDate     = other.ModificationDate;
        }
コード例 #3
0
 public Note(CurrencyType currency, int value, INote seniorNote)
 {
     Currency      = currency;
     Value         = value;
     JuniorNote    = seniorNote;
     TotalQuantity = 1000;
 }
コード例 #4
0
 public NoteWithPrioritySign(INote i_Note) : base(i_Note)
 {
     this.m_PriorityPicture.Image    = global::FacebookDesktopLogic.Properties.Resources.sign;
     this.m_PriorityPicture.Location = new Point(this.Location.X + this.Size.Width / 2 + 25, this.Location.Y + this.Size.Height / 2 + 15);
     this.Controls.Add(m_PriorityPicture);
     this.m_PriorityPicture.BringToFront();
 }
コード例 #5
0
        private async ValueTask <Result <INote> > InternalCreateAsync(INote note)
        {
            using var activity = ActivitySource.StartActivity($"{nameof(SqlNoteRepository)}.{nameof(InternalCreateAsync)}");

            const string createNoteSql =
                "INSERT INTO notes (title, text, CreatedOn) values (@title, @text, @createdOn);SELECT Id, Title, Text, CreatedOn, ModifiedOn FROM notes WHERE Title = @title AND createdOn = @createdOn;";
            var parameters = new DynamicParameters();

            parameters.Add("@title", note.Title);
            parameters.Add("@text", note.Text);
            parameters.Add("@createdOn", DateTime.UtcNow);

            var connection  = this.GetConnection();
            var createdNote =
                await connection.QueryFirstOrDefaultAsync <NoteRepositoryDto>(createNoteSql, parameters);

            if (createdNote == null)
            {
                activity?.SetIsSuccess(false);
                if (_logger.IsEnabled(LogLevel.Warning))
                {
                    this._logger.LogWarning("Note {name} {id} could not be created", note.Title, note.Id);
                }

                Result.Fail(new Error("Create note failed because it could not be added to the database."));
            }

            activity?.SetIsSuccess(true);
            var mappedNote = _mapper.Map <INote>(createdNote);

            return(Result.Ok(mappedNote));
        }
コード例 #6
0
        /// <summary>
        /// Determines whether the given note starts on a off-beat in the context of
        /// the given bar, or whether it starts on an on-beat.
        /// <para>
        /// The note is considered to be an off-beat if it does not start on a strong beat,
        /// i.e., it does not start in the beginning of the bar nor in the middle of the bar.
        /// </para>
        /// <para>
        /// Incase this method is intended to be called repeatedly through a bar,
        /// it is recommended  to use the more effecient analogous version of INote extension
        /// method, which carries out the same task, but saves calculations of data that is
        /// passed from the caller through additional parameters. Therefore the caller could
        /// calculate them once per bar and pass them on continuous calls on the individual
        /// notes.
        /// </para>
        /// For more information, check it out: <see cref="IsOffBeatNote(IBar, float, float?)"/>
        /// </summary>
        /// <param name="note"> The subject note in question.</param>
        /// <param name="contextBar"> The bar which contains the note in question.</param>
        /// <returns></returns>
        public static bool IsOffBeatNote(this INote note, IBar contextBar)
        {
            // init
            IDuration noteDuration;
            float     beatAccumulator = 0; // accumulates preceding notes length

            // find starting point in bar for the given note
            int noteIndex = contextBar.Notes.IndexOf(note);

            // assure the given note exists in the given context bar
            if (noteIndex < 0)
            {
                return(false);
            }

            // accumulate length of beats that precede the given note
            for (int i = 0; i < noteIndex; i++)
            {
                noteDuration     = contextBar.Notes[i].Duration;
                beatAccumulator += (float)noteDuration.Numerator / noteDuration.Denominator;
            }

            // delegate task to optimized method version
            return(contextBar.IsOffBeatNote(startingBeat: beatAccumulator));
        }
コード例 #7
0
ファイル: NoteDialog.cs プロジェクト: nolith/tasque
        void OnNoteTextChanged(object sender, EventArgs args)
        {
            NoteWidget nWidget = sender as NoteWidget;

            // if null, add a note, else, modify it
            if (nWidget.Note == null)
            {
                try {
                    INote note = task.CreateNote(nWidget.Text);
                    nWidget.Note = note;
                } catch (Exception e) {
                    Logger.Debug("Unable to create a note");
                    Logger.Debug(e.ToString());
                }
            }
            else
            {
                try {
                    task.SaveNote(nWidget.Note);
                } catch (Exception e) {
                    Logger.Debug("Unable to save note");
                    Logger.Debug(e.ToString());
                }
            }
        }
コード例 #8
0
ファイル: ScaleService.cs プロジェクト: histechup/Music
    public IScale GetScale(INote note, Scales type)
    {
        var definition = this.definitions.FirstOrDefault(d => d.Equals(type));

        if (definition == null)
        {
            throw new Exception($"Impossible to find scale of type {type}");
        }

        // get the notes.
        var notes = this.NoteService.GetNotes();

        // create the scale :)
        var scale = new Scale();

        scale.ScaleDefinition = definition.DeepClone();
        scale.Key             = note.DeepClone();
        scale.Notes           = new List <INote>()
        {
            scale.Key
        };

        // work way up.
        for (var i = 0; i < definition.DistancePatternInSemiTones.Count; i++)
        {
            var previous        = scale.Notes.Last();
            var nextNoteInScale = this.NoteIntervalService.NextNote(notes, previous, definition.DistancePatternInSemiTones[i]);
            scale.Notes.Add(nextNoteInScale);
        }

        return(scale);
    }
コード例 #9
0
        /// <summary>
        /// <para>Gets the note in the melody which preceds the note at the given indices.</para>
        /// If <paramref name="excludeRestHoldNotes"/> is set, then hold and rest notes
        /// would be bypassed, and the first preceding note which is not a rest or hold note
        /// would be returned. If no preceding note is found then null is returned.
        /// </summary>
        /// <param name="melodyBarsContext"> The bar sequence which contains the melody notes. </param>
        /// <param name="excludeRestHoldNotes">If set, rest notes and hold notes would be discarded during search for a preceding note.</param>
        /// <param name="barIndex"> Index of the bar containing the given note. </param>
        /// <param name="noteIndex"> Index of the note of whom it's predecessor is wanted. </param>
        /// <param name="precedingNoteBarIndex"> Index of the bar which contains the preceding note.</param>
        /// <param name="precedingNoteIndex">Index of the preceding note inside his containing note sequence.</param>
        /// <returns> Preceding note in the melody, or null if no predecessor note is found. </returns>
        public static INote GetPredecessorNote(this IEnumerable <IBar> melodyBarsContext, bool excludeRestHoldNotes, int barIndex, int noteIndex, out int precedingNoteBarIndex, out int precedingNoteIndex)
        {
            // initialization
            INote        note = null;
            int          startingNoteIndex = 0;
            IList <IBar> bars = melodyBarsContext.ToList();

            /* start scanning backwards from current bar & current note:
             * outer loop is for bars, inner loop for notes in the individual bars */
            for (int i = barIndex; i >= 0; i--)
            {
                /* in current bar start searching right before the given note.
                 * in the rest of the bars start from the right edge end of the bar. */
                startingNoteIndex = ((i == barIndex) ? (noteIndex - 1) : (bars[i].Notes.Count - 1));
                for (int j = startingNoteIndex; j >= 0; j--)
                {
                    note = bars[i].Notes[j];
                    if (!excludeRestHoldNotes || (note.Pitch != NotePitch.RestNote && note.Pitch != NotePitch.HoldNote))
                    {
                        // set out params with the indices values and return the preceding note
                        precedingNoteBarIndex = i;
                        precedingNoteIndex    = j;
                        return(note);
                    }
                }
            }

            // incase no preceding note is found, set the output accordingly
            precedingNoteBarIndex = -1;
            precedingNoteIndex    = -1;
            return(null);
        }
コード例 #10
0
        public override void DeleteNote(INote inote)
        {
            using (var web = CreateAuthenticatedClient())
            {
                var note = (SimpleNote)inote;

                if (note.IsConflictNote)
                {
                    return;
                }

                var remote = buckets.index.FirstOrDefault(p => p.id == note.ID);

                if (remote != null)
                {
                    if (_config.PermanentlyDeleteNotes)
                    {
                        SimpleNoteAPI.DeleteNote(web, note);
                        SimpleNoteAPI.DeleteNotePermanently(web, note);
                    }
                    else
                    {
                        SimpleNoteAPI.DeleteNote(web, note);
                    }

                    _data.AddDeletedNote(note.ID, note.LocalVersion);
                }
            }
        }
コード例 #11
0
        public override RemoteDownloadResult UpdateNoteFromRemote(INote inote)
        {
            using (var web = CreateAuthenticatedClient())
            {
                var note = (SimpleNote)inote;

                var remote = buckets.index.FirstOrDefault(p => p.id == note.ID);

                if (remote == null)
                {
                    return(RemoteDownloadResult.DeletedOnRemote);
                }

                if (remote.v == note.LocalVersion)
                {
                    return(RemoteDownloadResult.UpToDate);
                }

                var unote = SimpleNoteAPI.GetNoteData(web, note.ID, _config, this);
                if (unote.Deleted)
                {
                    return(RemoteDownloadResult.DeletedOnRemote);
                }

                inote.ApplyUpdatedData(unote);

                return(RemoteDownloadResult.Updated);
            }
        }
コード例 #12
0
        private string GetFilesystemPath(INote note)
        {
            var filename = FilenameHelper.ConvertStringForFilename(note.Title);

            if (string.IsNullOrWhiteSpace(filename))
            {
                filename = FilenameHelper.ConvertStringForFilename(note.UniqueName);
            }

            var ext = ".txt";

            if (note.HasTagCaseInsensitive(AppSettings.TAG_MARKDOWN))
            {
                ext = ".md";
            }

            if (note.Path.IsRoot())
            {
                return(Path.Combine(_path, filename + ext));
            }

            var comp = new[] { _path }
            .Concat(note.Path.Enumerate().Select(FilenameHelper.ConvertStringForFilename))
            .Concat(new[] { filename + ext });

            return(Path.Combine(comp.ToArray()));
        }
コード例 #13
0
        /// <summary>
        /// Add all the data from items in the FLExText file into their proper spots in the segment.
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="wsFactory"></param>
        /// <param name="phrase"></param>
        /// <param name="newSegment"></param>
        /// <param name="tsStrFactory"></param>
        /// <param name="textInFile">This reference boolean indicates if there was a text item in the phrase</param>
        /// <param name="phraseText">This reference string will be filled with the contents of the "txt" item in the phrase if it is there</param>
        private static void AddSegmentItemData(FdoCache cache, ILgWritingSystemFactory wsFactory, Phrase phrase, ISegment newSegment, ITsStrFactory tsStrFactory, ref bool textInFile, ref ITsString phraseText)
        {
            if (phrase.Items != null)
            {
                foreach (var item in phrase.Items)
                {
                    switch (item.type)
                    {
                    case "reference-label":
                        newSegment.Reference = tsStrFactory.MakeString(item.Value,
                                                                       GetWsEngine(wsFactory, item.lang).Handle);
                        break;

                    case "gls":
                        newSegment.FreeTranslation.set_String(GetWsEngine(wsFactory, item.lang).Handle, item.Value);
                        break;

                    case "lit":
                        newSegment.LiteralTranslation.set_String(GetWsEngine(wsFactory, item.lang).Handle, item.Value);
                        break;

                    case "note":
                        INote note = cache.ServiceLocator.GetInstance <INoteFactory>().Create();
                        newSegment.NotesOS.Add(note);
                        note.Content.set_String(GetWsEngine(wsFactory, item.lang).Handle, item.Value);
                        break;

                    case "txt":
                        phraseText = tsStrFactory.MakeString(item.Value, GetWsEngine(wsFactory, item.lang).Handle);
                        textInFile = true;
                        break;
                    }
                }
            }
        }
コード例 #14
0
        public override RemoteDownloadResult UpdateNoteFromRemote(INote inote)
        {
            using (var web = CreateAuthenticatedClient())
            {
                var note = (NextcloudNote)inote;

                var remote = remoteNotes.FirstOrDefault(p => p.id == note.RemoteID);

                if (remote == null)
                {
                    return(RemoteDownloadResult.DeletedOnRemote);
                }

                if (remote.modified == note.RemoteTimestamp)
                {
                    return(RemoteDownloadResult.UpToDate);
                }

                var unote = NextcloudAPI.GetNoteData(web, note.RemoteID, _config);

                inote.ApplyUpdatedData(unote);

                return(RemoteDownloadResult.Updated);
            }
        }
コード例 #15
0
        public override bool NeedsDownload(INote inote)
        {
            var note = (FilesystemNote)inote;

            if (note.IsConflictNote)
            {
                return(false);
            }
            if (string.IsNullOrWhiteSpace(note.Title))
            {
                return(false);
            }

            if (!note.IsRemoteSaved)
            {
                return(false);
            }

            if (string.IsNullOrWhiteSpace(note.PathRemote))
            {
                return(false);
            }
            if (!File.Exists(note.PathRemote))
            {
                return(true);
            }

            var remote = ReadNoteFromPath(note.PathRemote);

            return(remote.IsLocked != note.IsLocked || remote.ModificationDate > note.ModificationDate);
        }
コード例 #16
0
        public INote NextNote(IList <INote> notes, INote note, int semiTones = 1)
        {
            if (notes == null)
            {
                throw new ArgumentNullException(nameof(notes));
            }

            if (notes.Count == 0)
            {
                throw new ArgumentException("must supply a valid notes list", nameof(notes));
            }

            if (note == null)
            {
                throw new ArgumentNullException(nameof(note));
            }

            if (semiTones <= 0)
            {
                throw new ArgumentException("Must be 1 or larget", nameof(semiTones));
            }

            INote ret = note;

            for (var i = 0; i < semiTones; i++)
            {
                ret = GetNextNote(notes, ret);
            }

            return(ret);
        }
コード例 #17
0
ファイル: Mutators.cs プロジェクト: cwelt/Soloist
        /// <summary>
        /// Replaces a random concrete note pitch with a hold note.
        /// </summary>
        /// <param name="melody"> The candidate melody which contains the bar sequence to operate on. </param>
        /// <param name="barIndex"> An index of specific requested bar to operate on. </param>
        private protected virtual void ToggleToHoldNoteMutation(MelodyCandidate melody, int?barIndex)
        {
            // intialize random generator
            Random random = new Random();

            // fetch the requested bar randomly select one if no specific bar is requested
            barIndex = barIndex ?? random.Next(melody.Bars.Count);
            IBar selectedBar = melody.Bars[(int)barIndex];

            // fetch potential notes for the toggle (filter rest, hold & first notes in bar)
            IList <INote> relevantNotes = selectedBar.Notes.Where((note, noteIndex) =>
                                                                  noteIndex > 0 &&
                                                                  note.Pitch != NotePitch.RestNote &&
                                                                  note.Pitch != NotePitch.HoldNote).ToList();

            // assure at least one note as found
            if (!relevantNotes.Any())
            {
                return;
            }

            // fetch a random note from the potential notes found
            int   randomNoteIndex = random.Next(relevantNotes.Count);
            INote selectedNote    = relevantNotes[randomNoteIndex];

            // get original index of the selected note in the original sequence
            int originalNoteIndex = selectedBar.Notes.IndexOf(selectedNote);

            // replace selected note with a hold note
            INote holdNote = MusicTheoryFactory.CreateNote(NotePitch.HoldNote, selectedNote.Duration);

            selectedBar.Notes.RemoveAt(originalNoteIndex);
            selectedBar.Notes.Insert(originalNoteIndex, holdNote);
        }
コード例 #18
0
 public void SetSelectedNoteWithoutFocus(INote n)
 {
     using (PreventScintillaFocusLock.Set())
     {
         SelectedNote = n;
     }
 }
コード例 #19
0
        public override bool NeedsUpload(INote inote)
        {
            var note = (FilesystemNote)inote;

            if (note.IsConflictNote)
            {
                return(false);
            }
            //if (string.IsNullOrWhiteSpace(note.Title)) return false;

            if (!note.IsRemoteSaved)
            {
                return(true);
            }
            if (string.IsNullOrWhiteSpace(note.PathRemote))
            {
                return(true);
            }
            if (!File.Exists(note.PathRemote))
            {
                return(false);
            }

            return(false);
        }
コード例 #20
0
 public void BuildGenericData(INote note, string header, string content)
 {
     note.Content      = content;
     note.CreationDate = DateTime.Now;
     note.Header       = header;
     note.Id           = SessionData.GenerateId();
 }
コード例 #21
0
        public INote StyleTime(INote note)
        {
            double beatPerMs = 6000 / AverageBpm;

            note.realSpan = (int)Math.Round(note.givenSpan * beatPerMs);
            return(note);
        }
コード例 #22
0
        public NoteWidget(INote note)
        {
            this.KeyPressEvent += OnNoteWidgetKeyPressed;
            this.note           = note;
            this.text           = ((note == null) || (note.Text == null)) ? string.Empty : note.Text.Trim();

            this.ShowTabs = false;

            viewPage = MakeViewPage();
            editPage = MakeEditPage();

            // The label below does not need to be translated because it's
            // for debugging purposes only.
            viewPageId = AppendPage(viewPage, new Gtk.Label("View"));

            // The label below does not need to be translated because it's
            // for debugging purposes only.
            editPageId = AppendPage(editPage, new Gtk.Label("Edit"));

            if (text == null || text == string.Empty)
            {
                // Go into edit mode (switch to the edit page)
                ShowPage(editPageId);
            }
            else
            {
                // Go to view mode (switch to the view page)
                ShowPage(viewPageId);
            }
            this.textView.Buffer.Changed += OnTextViewChanged;
        }
コード例 #23
0
        private void RenderSpecial(Graphics g, INote note, Point barStart, bool useFlats, int pixelsPerSquare, bool selected)
        {
            g.CompositingQuality = CompositingQuality.HighQuality;
            g.InterpolationMode  = InterpolationMode.HighQualityBicubic;
            g.SmoothingMode      = SmoothingMode.HighQuality;

            if (note.Pitch == Note.StartRepeat || note.Pitch == Note.EndRepeat)
            {
                int pixelsIntoBar = note.Offset * pixelsPerSquare / 4;
                using (Brush txtBrush = selected ? new SolidBrush(Color.Red) : new SolidBrush((note as ColouredNote).ForeColour))
                {
                    RectangleF blob = new RectangleF(
                        barStart.X + pixelsIntoBar + pixelsPerSquare / 8f,
                        barStart.Y + pixelsPerSquare / 4f,
                        pixelsPerSquare / 8f,
                        pixelsPerSquare / 8f);
                    if (note.Pitch == Note.EndRepeat)
                    {
                        blob.Offset(5 * pixelsPerSquare / 8f, 0f);
                    }
                    g.FillEllipse(txtBrush, blob);
                    blob.Offset(0f, 3 * pixelsPerSquare / 8f);
                    g.FillEllipse(txtBrush, blob);
                    blob.Offset(0f, pixelsPerSquare * (VerticalSquares - 1));
                    g.FillEllipse(txtBrush, blob);
                    blob.Offset(0f, -3 * pixelsPerSquare / 8f);
                    g.FillEllipse(txtBrush, blob);
                }
            }

            // TODO: First and second time bars
        }
コード例 #24
0
        public override RemoteDownloadResult UpdateNoteFromRemote(INote inote)
        {
            var note = (StandardFileNote)inote;

            if (_syncResult.deleted_notes.Any(n => n.ID == note.ID))
            {
                var bucketNote = _syncResult.deleted_notes.First(n => n.ID == note.ID);

                note.ApplyUpdatedData(bucketNote);

                return(RemoteDownloadResult.DeletedOnRemote);
            }

            if (_syncResult.retrieved_notes.Any(n => n.ID == note.ID))
            {
                var bucketNote = _syncResult.retrieved_notes.First(n => n.ID == note.ID);

                if (note.EqualsIgnoreModificationdate(bucketNote))
                {
                    note.ApplyUpdatedData(bucketNote);
                    return(RemoteDownloadResult.UpToDate);
                }
                else
                {
                    note.ApplyUpdatedData(bucketNote);
                    return(RemoteDownloadResult.Updated);
                }
            }

            return(RemoteDownloadResult.UpToDate);
        }
コード例 #25
0
        private void InsertBlank(Graphics g, INote note, Point barStart, bool useFlats, int pixelsPerSquare)
        {
            // Calculate horizontal position of note
            int   pixelsIntoBar = note.Offset * pixelsPerSquare / 4;
            Point noteCentre    = barStart;

            noteCentre.Offset(pixelsIntoBar + pixelsPerSquare / 2,
                              (note.VerticalOffset(useFlats) - Score.MinVerticalOffset) * pixelsPerSquare / 3);
            using (Font font = new Font("Arial Rounded MT", pixelsPerSquare / 3 - 2, FontStyle.Bold))
                using (Font accFont = new Font("Arial Rounded MT", pixelsPerSquare / 4, FontStyle.Bold))
                {
                    StringFormat sf = new StringFormat
                    {
                        Alignment     = StringAlignment.Center,
                        LineAlignment = StringAlignment.Center
                    };
                    string noteStr = note.ToString(useFlats);
                    SizeF  size    = g.MeasureString(noteStr.Substring(0, 1), font);
                    using (Brush fillBrush = new SolidBrush((note as ColouredNote).BackColour))
                    {
                        g.FillRectangle(fillBrush, noteCentre.X - size.Width / 2,
                                        noteCentre.Y - size.Height / 2, size.Width, size.Height);
                        if (noteStr.Length > 1)
                        {
                            SizeF accSize = g.MeasureString(noteStr.Substring(1), accFont);
                            g.FillRectangle(fillBrush,
                                            noteCentre.X + size.Width / 2 - accSize.Width / 2,
                                            noteCentre.Y - pixelsPerSquare / 10 - accSize.Height / 2,
                                            accSize.Width, accSize.Height);
                        }
                    }
                }
        }
コード例 #26
0
        private bool SpecialNoteHitTest(Point mousePt, Graphics g, INote note, Point barStart, bool useFlats, int pixelsPerSquare)
        {
            int        pixelsIntoBar = note.Offset * pixelsPerSquare / 4;
            RectangleF blob          = new RectangleF(
                barStart.X + pixelsIntoBar + pixelsPerSquare / 8f,
                barStart.Y + pixelsPerSquare / 8f,
                pixelsPerSquare / 4f,
                3 * pixelsPerSquare / 4f);
            RectangleF lowerBlob = blob;

            lowerBlob.Offset(0f, (VerticalSquares - 1) * pixelsPerSquare);
            if (note.Pitch == Note.StartRepeat && (blob.Contains(mousePt) || lowerBlob.Contains(mousePt)))
            {
                return(true);
            }

            blob.Offset(pixelsPerSquare / 2f, 0f);
            lowerBlob.Offset(pixelsPerSquare / 2f, 0f);
            if (note.Pitch == Note.EndRepeat && (blob.Contains(mousePt) || lowerBlob.Contains(mousePt)))
            {
                return(true);
            }

            // TODO: 1st and second time bars

            return(false);
        }
コード例 #27
0
        public override bool NeedsDownload(INote inote)
        {
            var note = (EvernoteNote)inote;

            if (note.IsConflictNote)
            {
                return(false);
            }

            if (!note.IsRemoteSaved)
            {
                return(false);
            }

            if (bucket == null)
            {
                return(false);
            }

            var remote = bucket.Notes.FirstOrDefault(p => Guid.Parse(p.Guid) == note.ID);

            if (remote == null)
            {
                return(false);
            }

            return(remote.UpdateSequenceNum > note.UpdateSequenceNumber);
        }
コード例 #28
0
ファイル: NoteWidget.cs プロジェクト: GNOME/tasque
        public NoteWidget(INote note)
        {
            this.KeyPressEvent += OnNoteWidgetKeyPressed;
            this.note = note;
            this.text = ( (note == null) || (note.Text == null) ) ? string.Empty : note.Text.Trim ();

            this.ShowTabs = false;

            viewPage = MakeViewPage ();
            editPage = MakeEditPage ();

            // The label below does not need to be translated because it's
            // for debugging purposes only.
            viewPageId = AppendPage (viewPage, new Gtk.Label ("View"));

            // The label below does not need to be translated because it's
            // for debugging purposes only.
            editPageId = AppendPage (editPage, new Gtk.Label ("Edit"));

            if (text == null || text == string.Empty) {
                // Go into edit mode (switch to the edit page)
                ShowPage (editPageId);
            } else {
                // Go to view mode (switch to the view page)
                ShowPage (viewPageId);
            }
            this.textView.Buffer.Changed += OnTextViewChanged;
        }
コード例 #29
0
        public void DisplayMainInfo(INote note)
        {
            displayFullInfoHeader(note);
            displayFullInfoContent(note);

            Console.ForegroundColor = DEFAULT_COLOR;
        }
コード例 #30
0
        /// <summary>
        /// <para>Gets the note in the melody which succeeds the note at the given indices.</para>
        /// If <paramref name="excludeRestHoldNotes"/> is set, then hold and rest notes
        /// would be bypassed, and the first succeeding note which is not a rest or hold note
        /// would be returned. If no succeeding note is found then null is returned.
        /// </summary>
        /// <param name="melodyBarsContext"> The bar sequence which contains the melody notes. </param>
        /// <param name="excludeRestHoldNotes">If set, rest notes and hold notes would be discarded during search for a preceding note. </param>
        /// <param name="barIndex"> Index of the bar containing the given note. </param>
        /// <param name="noteIndex"> Index of the note of which it's predecessor is wanted. </param>
        /// <param name="succeedingNoteBarIndex">Index of the bar which contains the successor note. </param>
        /// <param name="succeedingNoteIndex">Index of the successor note inside his containing note sequence. </param>
        /// <returns> Succeeding note in the melody, or null if no successor note is found. </returns>
        public static INote GetSuccessorNote(this IEnumerable <IBar> melodyBarsContext, bool excludeRestHoldNotes, int barIndex, int noteIndex, out int succeedingNoteBarIndex, out int succeedingNoteIndex)
        {
            // initialization
            INote        note = null;
            int          startingNoteIndex = 0;
            IList <IBar> bars = melodyBarsContext.ToList();

            // start scanning forwards from current bar & current note
            for (int i = barIndex; i < bars.Count; i++)
            {
                /* in current bar start searching right after the given note.
                 * in the rest of the bars start from the right beginning of the bar. */
                startingNoteIndex = ((i == barIndex) ? (noteIndex + 1) : 0);
                for (int j = startingNoteIndex; j < bars[i].Notes.Count; j++)
                {
                    note = bars[i].Notes[j];
                    if (!excludeRestHoldNotes || (note.Pitch != NotePitch.RestNote && note.Pitch != NotePitch.HoldNote))
                    {
                        // set out params with the indices values and return the succeeding note
                        succeedingNoteBarIndex = i;
                        succeedingNoteIndex    = j;
                        return(note);
                    }
                }
            }
            // incase no succeeding note is found, set the output accordingly
            succeedingNoteBarIndex = -1;
            succeedingNoteIndex    = -1;
            return(null);
        }
コード例 #31
0
        public override RemoteUploadResult UploadNoteToRemote(ref INote inote, out INote conflict, ConflictResolutionStrategy strategy)
        {
            var note = (StandardFileNote)inote;

            if (_syncResult.saved_notes.Any(n => n.ID == note.ID))
            {
                note.ApplyUpdatedData(_syncResult.saved_notes.First(n => n.ID == note.ID));
                conflict = null;
                return(RemoteUploadResult.Uploaded);
            }

            if (_syncResult.retrieved_notes.Any(n => n.ID == note.ID))
            {
                _logger.Warn(StandardNotePlugin.Name, "Uploaded note found in retrieved notes ... upload failed ?");
                note.ApplyUpdatedData(_syncResult.retrieved_notes.First(n => n.ID == note.ID));
                conflict = null;
                return(RemoteUploadResult.Merged);
            }

            if (_syncResult.error_notes.Any(n => n.ID == note.ID))
            {
                throw new Exception("Could not upload note - server returned note in {unsaved_notes}");
            }

            if (_syncResult.conflict_notes.Any(n => n.ID == note.ID))
            {
                conflict = _syncResult.conflict_notes.First(n => n.ID == note.ID);
                return(RemoteUploadResult.Conflict);
            }

            conflict = null;
            return(RemoteUploadResult.UpToDate);
        }
コード例 #32
0
ファイル: Note.cs プロジェクト: owq/NOTE
 public Note(INote note = null)
 {
     if (note != null) {
         Title = note.Title; //is this a copy or a reference?
         Content = note.Content;
         Tags = note.Tags;
     }
 }
コード例 #33
0
 public NoteViewModel(INote model, MainViewModel main) : base(main)
 {
     if (model == null)
         throw new ArgumentNullException("model");
     this.model = model;
     update = new UpdateLabelsCommand(this);
     newAttachment = new NewAttachmentCommand(this);
     deleteAttachment = new DeleteAttachmentCommand(this);
     main.RegisterViewModel(model, this);
     LoadViewModels();
 }
コード例 #34
0
ファイル: SongTree.cs プロジェクト: nolenfelten/ocarina
        //this function blows; how do i make it better? So much redundancy but I can't see a way to consolidate the two cases.
        public TreeNode insertNote(TreeNode currentNode, INote currentNote)
        {
            if (currentNode == null) //Then it's trying to insert a top note.
            {
                switch (currentNote.Type)
                {
                    case NoteTypes.Left:
                        if (BaseLeft == null) BaseLeft = new TreeNode(new CLeftNote());
                        return BaseLeft;

                    case NoteTypes.Right:
                        if (BaseRight == null) BaseRight = new TreeNode(new CRightNote());
                        return BaseRight;

                    case NoteTypes.Up:
                        if (BaseUp == null) BaseUp = new TreeNode(new CUpNote());
                        return BaseUp;

                    case NoteTypes.Down:
                        if (BaseDown == null) BaseDown = new TreeNode(new CDownNote());
                        return BaseDown;

                    case NoteTypes.A:
                        if (BaseA == null) BaseA = new TreeNode(new ANote());
                        return BaseA;
                }
            }
            else //it's inserting a note at a position somewhere other than the top
            {
                switch (currentNote.Type)
                {
                    case NoteTypes.Left:
                        if (currentNode.leftChild == null) currentNode.leftChild = new TreeNode(new CLeftNote());
                        return currentNode.leftChild;

                    case NoteTypes.Right:
                        if (currentNode.rightChild == null) currentNode.rightChild = new TreeNode(new CRightNote());
                        return currentNode.rightChild;

                    case NoteTypes.Up:
                        if (currentNode.upChild == null) currentNode.upChild = new TreeNode(new CUpNote());
                        return currentNode.upChild;

                    case NoteTypes.Down:
                        if (currentNode.downChild == null) currentNode.downChild = new TreeNode(new CDownNote());
                        return currentNode.downChild;

                    case NoteTypes.A:
                        if (currentNode.aChild == null) currentNode.aChild = new TreeNode(new ANote());
                        return currentNode.aChild;
                }
            }
            return null;
        }
コード例 #35
0
 //TODO: add methods to create viewmodels for models, storing the id to retrieve any existing viewmodel if already created.
 public NoteViewModel GetViewModel(INote model)
 {
     NoteViewModel vm;
     if (noteViewModels.ContainsKey(model.ID))
     {
         vm = noteViewModels[model.ID];
         vm.Model = model;
     }
     else
     {
         vm = new NoteViewModel(model, this);
     }
     return vm;
 }
コード例 #36
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            string selectedId = "";
            if (NavigationContext.QueryString.TryGetValue("selectedItem", out selectedId))
            {
                _noteId = selectedId;
            }
            _note = App.ViewModel.GetNote(_noteId);
            _category = _note.Category;

            string selectedCategoryId = "";
            if (NavigationContext.QueryString.TryGetValue("selectedCategory", out selectedCategoryId))
            {
                _categoryId = selectedCategoryId;
                _category = App.ViewModel.GetCategory(selectedCategoryId);
                _note.Category = _category;
            }

            if (_note != null)
            {
                DataContext = _note;
            }
            if (_category != null)
            {
                textCategory.Text = _category.Title;
                textCategory.IsEnabled = true;
            }

            RelatedNotesListBox.ItemsSource = App.ViewModel.AllNotes.OrderBy(t => t.Title);
            // Determine which linked notes to check
            foreach (INote note in RelatedNotesListBox.ItemsSource)
            {
                if (_selectedNotes == null)
                {
                    if (_note.LinkedNotes.Where(t => t.Id.Equals(note.Id)).Any())
                    {
                        RelatedNotesListBox.SelectedItems.Add(note);
                    }
                }
                else
                {
                    if (_selectedNotes.Contains(note))
                    {
                        RelatedNotesListBox.SelectedItems.Add(note);
                    }
                }
            }
        }
コード例 #37
0
ファイル: Invoice.cs プロジェクト: Teknyc/Merchello
        /// <summary>
        /// Initializes a new instance of the <see cref="Invoice"/> class.
        /// </summary>
        /// <param name="invoiceStatus">
        /// The invoice status.
        /// </param>
        /// <param name="billToAddress">
        /// The bill to address.
        /// </param>
        /// <param name="lineItemCollection">
        /// The line item collection.
        /// </param>
        /// <param name="orders">
        /// The orders.
        /// </param>
        /// <param name="notes">
        /// The notes collection
        /// </param>
        internal Invoice(IInvoiceStatus invoiceStatus, IAddress billToAddress, LineItemCollection lineItemCollection, OrderCollection orders, INote[] notes)
        {
            Mandate.ParameterNotNull(invoiceStatus, "invoiceStatus");
            Mandate.ParameterNotNull(billToAddress, "billToAddress");
            Mandate.ParameterNotNull(lineItemCollection, "lineItemCollection");
            Mandate.ParameterNotNull(orders, "orders");
            Mandate.ParameterNotNull(notes, "notes");

            _invoiceStatus = invoiceStatus;

            _billToName = billToAddress.Name;
            _billToAddress1 = billToAddress.Address1;
            _billToAddress2 = billToAddress.Address2;
            _billToLocality = billToAddress.Locality;
            _billToRegion = billToAddress.Region;
            _billToPostalCode = billToAddress.PostalCode;
            _billToCountryCode = billToAddress.CountryCode;
            _billToPhone = billToAddress.Phone;
            _notes = notes;
            _items = lineItemCollection;
            _orders = orders;
            _invoiceDate = DateTime.Now;

        }
コード例 #38
0
        public static PointUV GetNoteLocation(INote note, HorizontalType horizontalType, VerticalType verticalType)
        {
            double U = 0, V = 0;

            if (horizontalType == HorizontalType.Left)
                U = note.GetLocation(TextPoint.LeftSide).U;
            else if (horizontalType == HorizontalType.Right)
                Debug.Fail("Note width not implemented");
            else if (horizontalType == HorizontalType.Center)
                Debug.Fail("Note width not implemented");
            else
                Debug.Fail("Case not handled");

            if (verticalType == VerticalType.Bottom)
                V = note.GetLocation(TextPoint.BottomSide).V;
            else if (verticalType == VerticalType.Top)
                Debug.Fail("Note height not implemented");
            else if (verticalType == VerticalType.Middle)
                Debug.Fail("Note height not implemented");
            else
                Debug.Fail("Case not handled");

            return PointUV.Create(U, V);
        }
コード例 #39
0
ファイル: DummyTask.cs プロジェクト: nolith/tasque
 public override void SaveNote(INote note)
 {
 }
コード例 #40
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            var noteToSave = (INote)DataContext;

            noteToSave.Title = textTitle.Text;
            noteToSave.Body = textNote.Text;
            noteToSave.Modified = DateTime.Now;
            noteToSave.Category = _category;
            noteToSave.LinkedNotes.Clear();
            if (RelatedNotesListBox.SelectedItems.Count > 0)
            {
                foreach (INote selected in RelatedNotesListBox.SelectedItems)
                {
                    noteToSave.LinkedNotes.Add(selected);
                }
            }
            App.ViewModel.Context.SaveChanges();

            NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
            _note = null;
            _selectedNotes = null;
        }
コード例 #41
0
 public async void Load()
 {
     Model = await App.Bll.LoadNote(model);
 }
コード例 #42
0
ファイル: RtmTask.cs プロジェクト: nolith/tasque
 /// <summary>
 /// Deletes a note from a task
 /// </summary>
 /// <param name="note">
 /// A <see cref="INote"/>
 /// </param>
 public override void SaveNote(INote note)
 {
     rtmBackend.SaveNote(this, (note as RtmNote));
 }
コード例 #43
0
ファイル: AbstractTask.cs プロジェクト: nolith/tasque
 public abstract void DeleteNote(INote note);
コード例 #44
0
ファイル: Bus.cs プロジェクト: Roustalski/LiteMvc
        private void doNotify( INote note )
        {
            if ( _noteInterestsInDelivery == null )
            {
                Trace.writeNullError( "The delivery ", typeof( IDictionary ) );
                return;
            }

            string interest = note.name;

            List<IObserver> list = getObservers( interest );
            if ( list == null )
            {
                Trace.writeNullError( typeof( List<IObserver> ), System.Diagnostics.TraceLevel.Warning );
                return;
            }

            if ( _noteInterestsInDelivery.Contains( interest ) )
            {
                Trace.writeLine( "Notifying observers again for interest: " + interest, System.Diagnostics.TraceLevel.Warning );
                _noteInterestsInDelivery[interest] = (int)_noteInterestsInDelivery[interest] + 1;
            }
            else
            {
                _noteInterestsInDelivery[interest] = 1;
            }

            List<IObserver> executeList = new List<IObserver>( list );
            while ( executeList.Count > 0 )
            {
                IObserver observer = executeList[0];
                observer.onNoteReceived( note );
                executeList.RemoveAt( 0 );
            }

            _noteInterestsInDelivery[interest] = (int)_noteInterestsInDelivery[interest] - 1;
            if ( (int)_noteInterestsInDelivery[interest] == 0 )
                _noteInterestsInDelivery.Remove( interest );
        }
コード例 #45
0
 public NoteViewModel(MainViewModel main) : base(main)
 {
     this.model = new NoteMock();
 }
コード例 #46
0
 internal void RegisterViewModel(INote model, NoteViewModel vm)
 {
     if (noteViewModels.ContainsKey(model.ID) == false)
         noteViewModels.Add(model.ID, vm);
 }
コード例 #47
0
 internal void UnregisterViewModel(INote model)
 {
     if (noteViewModels.ContainsKey(model.ID))
         noteViewModels.Remove(model.ID);
 }
コード例 #48
0
ファイル: AddPage.xaml.cs プロジェクト: GTuritto/BrightstarDB
 /// <summary>
 /// Clears _note and _selectedNotes cache
 /// </summary> 
 private void ClearNotesCache()
 {
     _note = null;
     _selectedNotes = null;
 }
コード例 #49
0
ファイル: AddPage.xaml.cs プロジェクト: GTuritto/BrightstarDB
 /// <summary>
 /// Navigates to the Category Selection page.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void CategoryButton_Click(object sender, RoutedEventArgs e)
 {
     _note = new Note() { Title = textTitle.Text, Body = textNote.Text };
     _selectedNotes = RelatedNotesListBox.SelectedItems;
     NavigationService.Navigate(new Uri("/AddCategoryPage.xaml", UriKind.Relative));
 }
コード例 #50
0
		/// <summary>
		/// Assumes the selection data belongs to a translation or note!
		/// Gets the InterlinLineChoices flid (id) and a meaningful interpretation of
		/// where the IP is in the translation or note text.
		/// If an empty translation note was selected, its tag is kTagUserPrompt.
		/// </summary>
		/// <param name="curSeg">The selected segment to get the translation or note text from.</param>
		/// <param name="curNote">null or the selected note</param>
		/// <param name="tag">The SegmentTags or NoteTags or kTagUserPrompt selected.</param>
		/// <param name="ichAnchor">The start index of the text selection.</param>
		/// <param name="ichEnd">The end index of the text selection.</param>
		/// <param name="wid">Index of the writing system of the selection.</param>
		/// <param name="id">The returned InterlinLineChoices flid.</param>
		/// <param name="lineNum">Configured line number of the translation or note.</param>
		/// <param name="where">The returned meaningful interpretation of where the IP is in the translation or note text.</param>
		/// <param name="isRightToLeft">is set to <c>true</c> if the Configured line is right to left, false otherwise.</param>
		/// <param name="hasPrompt">is set to <c>true</c> if the line is an empty translation.</param>
		/// <returns>
		/// true if the information was found, false otherwise.
		/// </returns>
		private bool GetLineInfo(ISegment curSeg, INote curNote, int tag, int ichAnchor, int ichEnd, int wid,
						out int id, out int lineNum, out WhichEnd where, out bool isRightToLeft, out bool hasPrompt)
		{
			isRightToLeft = false;
			hasPrompt = false;
			var wsf = Cache.WritingSystemFactory;
			var ws = wsf.get_EngineOrNull(wid);
			if (ws != null)
				isRightToLeft = ws.RightToLeftScript;

			id = 0;
			lineNum = -1;
			where = WhichEnd.Neither;
			switch (tag)
			{
				case SegmentTags.kflidFreeTranslation:
					id = InterlinLineChoices.kflidFreeTrans;
					where = ExtremePositionInString(ichAnchor, ichEnd, curSeg.FreeTranslation.get_String(wid).Length, isRightToLeft);
					break;
				case SegmentTags.kflidLiteralTranslation:
					id = InterlinLineChoices.kflidLitTrans;
					where = ExtremePositionInString(ichAnchor, ichEnd, curSeg.LiteralTranslation.get_String(wid).Length, isRightToLeft);
					break;
				case NoteTags.kflidContent:
					Debug.Assert(curNote != null, "Moving from a non-exisiting note in interlinear Doc.");
					id = InterlinLineChoices.kflidNote;
					where = ExtremePositionInString(ichAnchor, ichEnd, curNote.Content.get_String(wid).Length, isRightToLeft);
					break;
				case kTagUserPrompt: // user prompt property for empty translation annotations
					// Is this free or literal?
					hasPrompt = true;
					id = m_vc.ActiveFreeformFlid;
					id = (id == SegmentTags.kflidLiteralTranslation) ?
						InterlinLineChoices.kflidLitTrans : InterlinLineChoices.kflidFreeTrans;
					if (wid == 0)
						wid = m_vc.ActiveFreeformWs;
					where = WhichEnd.Both;
					break;
				default: // not expected
					return false;
			}
			if (wid > 0)
				lineNum = LineChoices.IndexOf(id, wid);
			if (lineNum == -1)
				lineNum = LineChoices.IndexOf(id);
			return true;
		}
コード例 #51
0
ファイル: DummyTask.cs プロジェクト: nolith/tasque
 public override void DeleteNote(INote note)
 {
 }
コード例 #52
0
ファイル: INoteCapture.cs プロジェクト: sagamors/Tuner
 public NoteDetectedEvent(INote nearestNote, double frequency)
 {
     NearestNote = nearestNote;
     Frequency = frequency;
 }
コード例 #53
0
ファイル: RtmTask.cs プロジェクト: nolith/tasque
        /// <summary>
        /// Deletes a note from a task
        /// </summary>
        /// <param name="note">
        /// A <see cref="INote"/>
        /// </param>
        public override void DeleteNote(INote note)
        {
            RtmNote rtmNote = (note as RtmNote);

            foreach(RtmNote lRtmNote in notes) {
                if(lRtmNote.ID == rtmNote.ID) {
                    notes.Remove(lRtmNote);
                    break;
                }
            }
            rtmBackend.DeleteNote(this, rtmNote);
        }
コード例 #54
0
 internal async void AddNewAttachment(System.IO.Stream stream, string fileName)
 {
     this.Model = await App.Bll.AddAttachment(model, stream, fileName);
 }
コード例 #55
0
ファイル: AbstractTask.cs プロジェクト: nolith/tasque
 public abstract void SaveNote(INote note);
コード例 #56
0
 internal async void UpdateLabels(string[] labels)
 {
     INote updated = await App.Bll.UpdateLabels(model, labels);
     Disconnect();
     Model = updated;
     Connect();
 }
コード例 #57
0
 private void CategoryButton_Click(object sender, RoutedEventArgs e)
 {
     _note = (INote)DataContext;
     _note.Title = textTitle.Text;
     _note.Body = textNote.Text;
     _note.LinkedNotes.Clear();
     if (RelatedNotesListBox.SelectedItems.Count > 0)
     {
         foreach (INote selected in RelatedNotesListBox.SelectedItems)
         {
             _note.LinkedNotes.Add(selected);
         }
     }
     _selectedNotes = RelatedNotesListBox.SelectedItems;
     NavigationService.Navigate(new Uri("/AddCategoryPage.xaml?editPage=true", UriKind.Relative));
 }
コード例 #58
0
 private void CancelButton_Click(object sender, EventArgs e)
 {
     NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
     _note = null;
     _selectedNotes = null;
 }
コード例 #59
0
		/// <summary>
		/// Retrieves the selected objects and data from the selection range.
		/// </summary>
		/// <param name="clev">The number of levels of selection range results.</param>
		/// <param name="rgvsli">The selection range with clev levels of structure.</param>
		/// <param name="tag">The property of the bottom-level [0] object that is of interest.</param>
		/// <param name="curParaIndex">The index of the paragraph containing the selected text.</param>
		/// <param name="curSegIndex">The index of the segment containing the selected text.</param>
		/// <param name="curNoteIndex">if tag indicates a note, the note index in its segment sequence otherwise -1.</param>
		/// <param name="curSeg">The selected segment object</param>
		/// <param name="curNote">The selected note object or null if curNoteIndex is -1.</param>
		private void GetCurrentTextObjects(int clev, SelLevInfo[] rgvsli, int tag, out int curParaIndex, out int curSegIndex, out int curNoteIndex, out ISegment curSeg, out INote curNote)
		{
			curParaIndex = rgvsli[clev - 2].ihvo;
			var curPara = (IStTxtPara)RootStText.ParagraphsOS[curParaIndex];
			Debug.Assert(curPara != null, "Moving from a non-exisiting paragraph in interlinear Doc.");
			curSegIndex = rgvsli[clev - 3].ihvo;
			curSeg = curPara.SegmentsOS[curSegIndex];
			Debug.Assert(curSeg != null, "Moving from a non-exisiting segment in interlinear Doc.");
			curNote = null;
			curNoteIndex = -1;
			if (tag == NoteTags.kflidContent)
			{
				//if clev == 5 then we have both a Free Translation and some number of Notes
				//otherwise I assume we have only a Free Translation if clev == 4
				if (clev == 5)
				{
					curNoteIndex = rgvsli[0].ihvo; //if there are multiple Notes the index could be more than 0
					curNote = curSeg.NotesOS[curNoteIndex];
				}
			}
		}
コード例 #60
0
ファイル: SqliteTask.cs プロジェクト: nolith/tasque
        public override void SaveNote(INote note)
        {
            SqliteNote sqNote = (note as SqliteNote);

            string text = backend.SanitizeText (sqNote.Text);
            string command = String.Format("UPDATE Notes SET Text='{0}' WHERE ID='{1}'", text, sqNote.ID);
            backend.Database.ExecuteScalar(command);
        }