public override bool HandleCommand(CommandCenter.Item command) { if (command == Globals.Commands.OPEN) { if (LastFocusedBoxId < 0) { return(false); } var ebox = Globals.UI.LoadBoxForEditing(LastFocusedBoxId); if (ebox == null) { UIGlobals.Do.ShowTimedMessge("Cannot find task"); return(true); } UIGlobals.Do.AddBoxToEditStack(ebox); return(true); } if (command == Globals.Commands.NEWLINKEDBOX) { UIGlobals.Deferred.OnNewBox = new DeferredBehaviors.NewBoxBehavior { ParentId = LastFocusedBoxId }; //UIGlobals.Do.HandleGlobalCommand(Globals.Commands.NEWITEM); var box = new Box { TimeType = Constants.TIMETYPE_NONE, Importance = Constants.IMPORTANCE_NORMAL, Visibility = Constants.VISIBILITY_NORMAL }; var ebox = new ExtBox(box, null); UIGlobals.Do.AddBoxToEditStack(ebox); UIGlobals.Do.ShowTimedMessge($"New note will be filed under selected note."); } return(base.HandleCommand(command)); }
/// <summary> /// Create a new task box whose time and chunk assignment are based on the current selection /// </summary> void NewTaskNearSelection() { var chunkVM = GetActiveChunk(); if (chunkVM == null) { return; } //create task box defaulted to the same time as the latest item in this chunk var box = BoxCreator.GetPreset(BoxCreator.TASK_PRESET_NO); box.BoxTime = Date + "0900"; if (chunkVM.Items.Any()) { string maxtime = chunkVM.Items.Max(b => b.Persistent.Box.BoxTime); if (maxtime.Length == 12) { box.BoxTime = Date + maxtime.Substring(8, 4); } } var ebox = new ExtBox(box, null); UIGlobals.Do.AddBoxToEditStack(ebox); //keep the chunk associated with the box, so after it is saved, it shows in the right chunk UIGlobals.Deferred.TaskAssigns.Add(new DeferredBehaviors.TaskAssignBehavior { Box = box, ChunkTitle = chunkVM.Title }); }
void FinishConstructor(ExtBox ebox, bool editMode) { VM = new ExtBoxVM(ebox, VMGotFocus, HandleCommand); if (editMode) { VM.IsEditMode = true; } //hook up VM events VM.FocusBarClicked = () => { ChangeMode(Mode.Edit, false); VisualUtils.DelayThen(10, () => { VM.GetMainControl?.Invoke()?.Focus(); }); }; VM.LinkClicked = linkItemVM => { UIGlobals.Do.OpenBlockFromLink(linkItemVM.Link, linkItemVM.OtherId); }; //handle deferred behaviors if (UIGlobals.Deferred.OnNewBox != null) { VM.ParentId = UIGlobals.Deferred.OnNewBox.ParentId; LinkToPersonIdOnSave = UIGlobals.Deferred.OnNewBox.LinkedPersonId; UIGlobals.Deferred.OnNewBox = null; } if (UIGlobals.Deferred.OnOpenBox != null) { if (UIGlobals.Deferred.OnOpenBox.MakeUndone) { VM.DoneDate = null; } UIGlobals.Deferred.OnOpenBox = null; } }
public ExtBoxController(ExtBox ebox, Action <BlockController> blockGotFocusHandler, Action <BlockController, bool> collapseRequested, bool editMode) : base(blockGotFocusHandler, collapseRequested) { FinishConstructor(ebox, editMode); }