public int?ChooseTemplate(SiteExplorerNodeType templateType)
        {
            var picklist = new PickListWindow(User, "Select Template", () => {
                var service = new MaterialService(User);
                List <SiteExplorerNode> list = new List <SiteExplorerNode>();
                switch (templateType)
                {
                case SiteExplorerNodeType.Site:
                    list.AddRange(service.GetSiteTemplates());
                    break;

                case SiteExplorerNodeType.SiteVisit:
                    list.AddRange(service.GetSiteVisitTemplates());
                    break;

                case SiteExplorerNodeType.Material:
                    list.AddRange(service.GetMaterialTemplates());
                    break;
                }
                return(list.ConvertAll((node) => {
                    return new SiteExplorerNodeViewModel(node);
                }));
            }, null);

            if (picklist.ShowDialog().GetValueOrDefault(false))
            {
                var selected = picklist.SelectedValue as SiteExplorerNodeViewModel;
                if (selected != null)
                {
                    return(selected.ElemID);
                }
            }

            return(null);
        }
Ejemplo n.º 2
0
        private void txtCollector_Click(object sender, RoutedEventArgs e)
        {
            Func <IEnumerable <string> > itemsFunc = () => {
                var service = new MaterialService(User);
                return(service.GetDistinctCollectors());
            };

            PickListWindow frm = new PickListWindow(User, "Select a collector", itemsFunc, null);

            if (frm.ShowDialog().ValueOrFalse())
            {
                if (String.IsNullOrWhiteSpace(txtCollector.Text))
                {
                    txtCollector.Text = frm.SelectedValue as string;
                }
                else
                {
                    txtCollector.Text += ", " + frm.SelectedValue;
                }
            }
        }
        private void DoFind(bool PositionUnderControl)
        {
            var preSelectionLength = txt.SelectionLength;

            Func <IEnumerable <string> > itemsFunc = () => {
                var service = new MaterialService(User);
                return(service.GetDistinctCollectors());
            };

            Control owner = null;

            if (PositionUnderControl)
            {
                owner = txt;
            }

            PickListWindow frm = new PickListWindow(User, "Select a collector", itemsFunc, null, txt.Text, owner, this);

            if (frm.ShowDialog().ValueOrFalse())
            {
                txt.SelectedText = frm.SelectedValue as string;
            }
        }
        private void PublishResponseDataNodes(XElement publishElt)
        {
            IEnumerable <XElement> DataNodes = publishElt.Elements(Common.Data.Node);
            IEnumerator            ie        = DataNodes.GetEnumerator();

            while (ie.MoveNext())
            {
                try
                {
                    XElement data = (XElement)ie.Current;
                    string   id   = string.Empty;

                    if (data.Attribute(Common.IDAttrib) != null)
                    {
                        id = data.Attribute(Common.IDAttrib).Value;
                    }

                    if (id == Common.Picklist)
                    {
                        #if WPF
                        var PL = new PickListWindow(this, data);
                        PL.ShowDialog();
                        #endif
                    }
                    else
                    {
                        bool process = true;

                        if (FixedContext != null)
                        {
                            if (id.StartsWith(FixedContext))
                            {
                                id = id.Remove(0, FixedContext.Length + 1);
                            }
                        }

                        if (process)
                        {
                            if (DataControls.ContainsKey(id))
                            {
                                if (DataControls[id] is ExpanzControlDetails)
                                {
                                    // Control has not registered itself with the activity yet. Cache the data for when it does.
                                    _controlDataCache[id] = data;
                                }
                                else
                                {
                                    // Sometimes data controls need to know the field info both before and after
                                    // it has been fed the data. Therefore, find the corresponding field info
                                    // (if a field ID has been assigned), and pass that field info to the control
                                    // to process before the data is published to it.
                                    if (DataControls[id].FieldId != null)
                                    {
                                        // Find the corresponding field information for this control
                                        XElement fieldElement = publishElt.Elements(Common.FieldNode).Where(x => x.Attribute(Common.IDAttrib).Value == DataControls[id].FieldId).FirstOrDefault();

                                        if (fieldElement != null)
                                        {
                                            DataControls[id].PreDataPublishXml(fieldElement);
                                        }
                                    }


                                    DataControls[id].PublishData(data);
                                }
                            }
                            //else if (this.container is ViewModelBase)
                            //{
                            //    var vm = this.container as ViewModelBase;
                            //    vm.PublishData(data);
                            //}
                        }
                    }
                }
                catch (Exception e)
                {
                    Logging.LogException(e);
                }
            }
        }