Beispiel #1
0
        protected static bool AskEnterMeasureTreeData(IApplicationSettings appSettings, IDialogService dialogService)
        {
            if (!appSettings.EnableAskEnterTreeData)
            {
                return(false);
            }

            return(dialogService.AskYesNo("Would you like to enter tree data now?", "Sample", false));
        }
Beispiel #2
0
        //public void HandleKPIChanging(Tree tree, float newKPI, bool doSample, out bool cancel)
        //{
        //    if (tree == null)
        //    {
        //        cancel = true;
        //        return;
        //    }
        //    if (tree.SampleGroup == null)
        //    {
        //        _dialogService.ShowMessage("Select Sample Group before entering KPI");
        //        cancel = true;
        //        return;
        //    }
        //    if (!tree.KPI.EqualsEx(0.0F))
        //    {
        //        string message = string.Format("Tree RecID:{0} KPI changed from {1} to {2}"
        //            , tree.Tree_CN
        //            , tree.KPI
        //            , newKPI);
        //        DataService.LogMessage(message, "I");
        //    }
        //    else if (doSample)
        //    {
        //        CountTree count = tree.FindCountRecord();
        //        if (count != null && count.SampleGroup.Sampler is ThreePSelecter)
        //        {
        //            ThreePItem item = (ThreePItem)count.SampleGroup.Sampler.NextItem();
        //            if (item.KPI < newKPI)
        //            {
        //                tree.CountOrMeasure = "M";
        //                _soundService.SignalMeasureTree();
        //                _dialogService.ShowMessage("Measure Tree");
        //            }
        //            else
        //            {
        //                tree.CountOrMeasure = "C";
        //            }
        //            //count.SumKPI += (long)newKPI;
        //        }
        //    }
        //    cancel = false;
        //}

        public void HandleViewClosing(CancelEventArgs e)
        {
            ViewController.ShowWait();

            try
            {
                ITreeView view;
                //Go through all the tree views and validate
                //if a tree view has invalid trees lets ask the user if they want to continue
                if (!this.ValidateTreeViews(out view) &&
                    !_dialogService.AskYesNo("Error(s) found on tree records. Would you like to continue", "Continue?", true))
                {
                    e.Cancel = true;
                    this.View.GoToPage(view);
                    return;
                }

                if (DataService.Region == 10)
                {
                    foreach (var treeView in View.Layouts.OfType <ITreeView>())
                    {
                        var treeNums = treeView.Trees.OrEmpty()
                                       .Where(t => t.CountOrMeasure == "M" && t.LogCountActual == 0)
                                       .Select(t => t.TreeNumber.ToString()).ToArray();
                        if (treeNums.Length > 0)
                        {
                            if (!_dialogService.AskYesNo("Tree(s) " + String.Join(", ", treeNums) + " have no logs", "Continue?", true))
                            {
                                e.Cancel = true;
                                //View.GoToPageIndex(View.Layouts.IndexOf(treeView));
                                View.GoToPage(treeView);
                                return;
                            }
                        }
                    }
                }
            }
            finally
            {
                ViewController.HideWait();
            }
        }
        //validate plot before switching plots
        protected bool ValidatePlot(Plot plot)
        {
            if (plot != null)
            {
                EndEdit();
                if (!(plot is Plot3PPNT) &&
                    !plot.IsNull &&
                    (plot.Trees != null && plot.Trees.Count == 0) &&
                    _dialogService.AskYesNo("Plot contains no tree records. Make it a NULL plot?", "Mark Plot Empty?"))
                {
                    plot.IsNull = true;
                    DataService.DataStore.Save(plot);
                    _BS_Plots.ResetItem(_BS_Plots.IndexOf(plot));//call reset item to cause the binding source to update view
                }

                string error;
                if (!plot.ValidatePlot(out error))
                {
                    return(_dialogService.AskYesNo(error
                                                   , "Continue?", true));
                }
            }
            return(true);
        }