Ejemplo n.º 1
0
        public void SearchRequested()
        {
            VisualUtils.LoseRegainFocus();
            var persons = Globals.UI.LoadFilteredPersons(VM.TermCri, VM.IncludeDetailsCri, VM.CatIdCri, false);

            VM.Results.Clear();
            if (persons == null)
            {
                return;
            }
            foreach (var p in persons)
            {
                VM.Results.Add(new PersonSearchVM.ResultItem {
                    PersonId = p.RowId, Name = p.Name
                });
            }
            var searchBtn = VM.GetPreResultsControl?.Invoke();

            if (searchBtn != null && persons.Length > 0)
            {
                VisualUtils.DelayThen(20, () =>
                {
                    searchBtn.Focus();
                    searchBtn.MoveFocus(new System.Windows.Input.TraversalRequest(System.Windows.Input.FocusNavigationDirection.Next));
                });
            }
        }
Ejemplo n.º 2
0
        public TodayController(bool isToday, Action <BlockController> blockGotFocusHandler, Action <BlockController, bool> collapseRequested)
            : base(blockGotFocusHandler, collapseRequested)
        {
            IsToday = isToday;
            DateTime dt = DateTime.Now;

            if (!isToday)
            {
                dt = dt.AddDays(1);
            }
            string dateS = DateUtil.ToYMD(dt);

            Date = dateS;
            VM   = new TodayVM(isToday, dateS, VMGotFocus);

            //hook up VM events
            VM.ChunkGotFocus = idx =>
            {
                LastFocusedChunk = VM.Chunks[idx];
            };
            VM.RequestAddChunk = () =>
            {
                VM.Chunks.Add(new TodayVM.ChunkVM(VM, UserRemovedChunk)
                {
                    Title   = VM.NewChunkTitle,
                    IsDirty = true
                });
                VM.NewChunkTitle = "";
            };
            VM.DropOnChunkRequested = (BoxDragInfo di, TodayVM.ChunkVM chunkVM) =>
            {
                MoveBoxToChunk(di.Box, chunkVM, true);
            };
            VM.FocusBarClicked = () =>
            {
                VisualUtils.DelayThen(30, () =>
                {
                    VM.GetMainControl?.Invoke()?.Focus();
                });
            };

            Refresh(null);
        }
Ejemplo n.º 3
0
        public void SearchRequested()
        {
            VisualUtils.LoseRegainFocus();
            string doneSince = null;

            if (VM.DoneMode)
            {
                doneSince = VM.DoneSinceCri.Date;
                if (doneSince == null)
                {
                    return;                    //must have done date in done mode
                }
            }
            var cachedBoxes = Globals.UI.LoadBoxesByKeyword(VM.TermCri, VM.IncludeDetailsCri, doneSince);

            VM.Results.Clear();
            if (cachedBoxes == null)
            {
                return;
            }
            foreach (var cb in cachedBoxes)
            {
                VM.Results.Add(new BoxPreviewVM(new AgendaEntry {
                    Box = cb, Time = cb.BoxTime
                }, null, ItemGotFocus));
            }
            foreach (var vm in VM.Results)
            {
                vm.TimeClicked = HandleTimeClicked;
            }

            var searchBtn = VM.GetPreResultsControl?.Invoke();

            if (searchBtn != null && cachedBoxes.Length > 0)
            {
                VisualUtils.DelayThen(20, () =>
                {
                    searchBtn.Focus();
                    searchBtn.MoveFocus(new System.Windows.Input.TraversalRequest(System.Windows.Input.FocusNavigationDirection.Next));
                });
            }
        }
Ejemplo n.º 4
0
        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;
            }
        }
Ejemplo n.º 5
0
            VM = new ExtPersonVM(ep, VMGotFocus)
            {
                CustomLabel1 = customLabel(0),
                CustomLabel2 = customLabel(1),
                CustomLabel3 = customLabel(2),
                CustomLabel4 = customLabel(3),
                CustomLabel5 = customLabel(4)
            };
            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.OnNewPerson != null)
            {
                BoxToLinkOnSave = UIGlobals.Deferred.OnNewPerson.LinkedBoxId;
                UIGlobals.Deferred.OnNewPerson = null;
            }

            //edit mode only for new record
            VM.IsEditMode = editMode || ep.Person.RowId == 0;
        }
Ejemplo n.º 6
0
        void FocusNotes()
        {
            var ctrl = VisualUtils.GetByUid(this, "eNotes") as RichTextView;

            VisualUtils.DelayThen(20, () => ctrl?.FocusMainControl());
        }
Ejemplo n.º 7
0
        void FocusDate()
        {
            var ctrl = VisualUtils.GetByUid(this, "eDate") as DateView;

            VisualUtils.DelayThen(20, () => ctrl?.FocusMainControl());
        }