Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("HookupId,HostId,GuestId,Location,DateTime")] Hookup hookup)
        {
            if (id != hookup.HookupId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(hookup);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HookupExists(hookup.HookupId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(hookup));
        }
        internal void InsertLineBreak()
        {
            IStyle style = null;

            if (RootBox != null && RootBox.Style != null && RootBox.Style.Stylesheet != null)
            {
                style = RootBox.Style.Stylesheet.Style(Hookup.GetStyleNameAt(this));
            }
            var paragraphOps = ParagraphOperations;

            if (paragraphOps == null)
            {
                return;
            }
            Action makeSelection;

            if (IsAtEndOfPara)
            {
                paragraphOps.InsertFollowingParagraph(this, out makeSelection);
            }
            else if (IsAtStartOfPara)
            {
                paragraphOps.InsertPrecedingParagraph(this, out makeSelection);
            }
            else
            {
                paragraphOps.SplitParagraph(this, out makeSelection);
            }
            RootBox.Site.PerformAfterNotifications(makeSelection);
            StyleToBeApplied = style;
        }
        /// <summary>
        /// Return true if Delete() will delete something. Default is that it will not.
        /// </summary>
        public override bool CanDelete()
        {
            var sel = new InsertionPoint(Hookup, StringPosition, AssociatePrevious);

            sel = sel.MoveByKey(new KeyEventArgs(Keys.Right)) as InsertionPoint;
            return(Hookup.CanDelete(this, sel));
        }
        /// <summary>
        /// Delete the selected material, or whatever else is appropriate when the Delete key is pressed.
        /// (Insertion Point deletes the following character.)
        /// </summary>
        public override void Delete()
        {
            Invalidate();             // while we still know the old position.
            if (Hookup == null)
            {
                return;
            }
            if (StringPosition == Hookup.Text.Length)
            {
                if (Hookup.ClientRunIndex == Para.Source.ClientRuns.Count - 1)
                {
                    DeleteLineBreak();
                    return;
                }
                if (Para.Source.ClientRuns[Hookup.ClientRunIndex + 1] is TextClientRun)
                {
                    // Delete at end of previous run.
                    var nextClientRun = Para.Source.NonEmptyStringClientRunBeginningAfter(Hookup.ClientRunIndex);
                    if (nextClientRun == null)
                    {
                        return;
                    }
                    // Enhance JohnT: maybe some kind of hookup can merge with previous para or delete an embedded object?
                    CopyFrom(nextClientRun.SelectAtStart(Para));
                    //Debug.Assert(StringPosition != Hookup.Text.Length - 1, "should have selected at the START of a non-empty run");
                }
            }
            var insertionPointEnd = new InsertionPoint(Hookup, StringPosition + 1, AssociatePrevious);

            if (!Hookup.CanDelete(this, insertionPointEnd))
            {
                return;
            }
            Hookup.Delete(this, insertionPointEnd);
        }
Example #5
0
 /// <summary>
 /// An entry point for making a selection, setting the current position to the specified hookup.
 /// </summary>
 public static SelectionBuilder In(Hookup startHookup)
 {
     return(new SelectionBuilder()
     {
         AnchorHookup = startHookup
     });
 }
Example #6
0
        public async Task <IActionResult> Create([Bind("HookupId,HostId,GuestId,Location,DateTime")] Hookup hookup)
        {
            if (ModelState.IsValid)
            {
                _context.Add(hookup);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(hookup));
        }
Example #7
0
 public void Save(Hookup h)
 {
     if (h.HookupId == 0)
     {
         _context.Hookups.Add(h);
     }
     else
     {
         _context.Hookups.Update(h);
     }
     _context.SaveChanges();
 }
 /// <summary>
 /// Insert the specified text at the insertion point.
 /// Enhance JohnT: normalize the string after the edit, maintaining the posititon of the IP correctly.
 /// </summary>
 public override bool InsertText(string input)
 {
     if (!CanInsertText)
     {
         return(false);        // cannot modify; should we report this somehow?
     }
     Invalidate();             // Hide the old selection while we still know where it is.
     if (input.Contains("\r") || input.Contains("\n"))
     {
         MultiLineInsertData inputInsertData = new MultiLineInsertData(this, input, null);
         Action makeSelection;
         ParagraphOperations.InsertLines(inputInsertData, out makeSelection);
         RootBox.Site.PerformAfterNotifications(makeSelection);
         return(true);
     }
     Hookup.InsertText(this, input);
     StringPosition += input.Length;
     return(true);
 }
        /// <summary>
        /// Implement the backspace key function (delete one character, or merge two paragraphs).
        /// </summary>
        public void Backspace()
        {
            Invalidate();             // while we still know the old position.
            if (Hookup == null)
            {
                return;
            }
            if (StringPosition == 0)
            {
                if (Hookup.ClientRunIndex == 0)
                {
                    BackspaceDeleteLineBreak();
                    return;
                }
                if (Para.Source.ClientRuns[Hookup.ClientRunIndex - 1] is TextClientRun)
                {
                    // Delete at end of previous run.
                    var prevClientRun = Para.Source.NonEmptyStringClientRunEndingBefore(Hookup.ClientRunIndex);
                    if (prevClientRun == null)
                    {
                        return;
                    }
                    // Enhance JohnT: maybe some kind of hookup can merge with previous para or delete an embedded object?
                    CopyFrom(prevClientRun.SelectAtEnd(Para));
                    Debug.Assert(StringPosition != 0, "should have selected at the END of a non-empty run");
                }
            }
            string oldValue = Hookup.Text;
            int    newPos   = Surrogates.PrevChar(oldValue, StringPosition);        // Enhance JohnT: should we delete back to a base?
            var    start    = new InsertionPoint(Hookup, newPos, false);

            if (!Hookup.CanDelete(start, this))
            {
                return;
            }
            Hookup.Delete(start, this);
            StringPosition = newPos;
        }
 /// <summary>
 /// Checks whether the Selection's style can be changed
 /// </summary>
 public override bool CanApplyStyle(string style)
 {
     return(Hookup.CanApplyStyle(this, this, style));
 }