コード例 #1
0
        private void CreateAndBindDynamicProperties(InstrumentComponent instrumentComponent, List<String> pidDocuments, List<String> specDocuments)
        {
            int rowCount = 5;

            var controlSystemComponentProperies = instrumentComponent.InstrumentComponentType.InstrumentComponentTypeProperties.OrderBy(x => x.Ordinal).ToList();

            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
            cmsWebServiceClient.GetAllPropertyListsCompleted += (s, e) =>
            {

                foreach (var controlSystemComponentProperty in controlSystemComponentProperies.Where(x => x.InstrumentProperty.IsVisible))
                {

                    Label label = new Label();

                    Binding labelBinding = new Binding("Name")
                    {
                        Mode = BindingMode.OneTime,
                        Source = controlSystemComponentProperty.InstrumentProperty
                    };

                    label.SetBinding(ContentControl.ContentProperty, labelBinding);
                    label.VerticalAlignment = VerticalAlignment.Center;
                    label.Margin = new Thickness(1);

                    PropertiesGrid.Children.Add(label);
                    Grid.SetRow(label, rowCount);
                    Grid.SetColumn(label, 0);

                    var propertyValue = GetPropertyValue(instrumentComponent, controlSystemComponentProperty);

                    var element = Utils.BindElement(controlSystemComponentProperty.InstrumentProperty, propertyValue, e.Result,
                        ComponentPropertyWrapViewModels, ControlChanged, pidDocuments, specDocuments);

                    PropertiesGrid.Children.Add(element);
                    Grid.SetRow((FrameworkElement)element, rowCount);
                    Grid.SetColumn((FrameworkElement)element, 1);

                    PropertiesGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(element.Height + 2) });

                    rowCount++;
                }

                LastInspectedTextBox.ResetOriginalValue();
                LastInspectedTextBox.ControlChanged += ControlChanged;

                NextInspectionTextBox.ResetOriginalValue();
                NextInspectionTextBox.ControlChanged += ControlChanged;

            };
            cmsWebServiceClient.GetAllPropertyListsAsync();
        }
コード例 #2
0
ファイル: DatabaseLoader.cs プロジェクト: barrett2474/CMS2
 public static Task<List<PropertyList>> GetAllPropertyLists()
 {
     var task = new TaskCompletionSource<List<PropertyList>>();
     var cee = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
     cee.GetAllPropertyListsCompleted += (s, e) => task.SetResult(e.Result);
     cee.GetAllPropertyListsAsync();
     return task.Task;
 }
コード例 #3
0
        private void CreateAndBindDynamicProperties(ControlSystemComponent controlSystemComponent, List<String> pidDocuments, List<String> specDocuments)
        {
            int rowCount = 5;

            var controlSystemComponentProperies = controlSystemComponent.ControlSystemComponentType.ControlSystemComponentTypeProperties.ToList();

            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
            cmsWebServiceClient.GetAllPropertyListsCompleted += (s, e) =>
            {
                List<ComponentTypeGroup> addedGroups = new List<ComponentTypeGroup>();

                foreach (var controlSystemComponentProperty in controlSystemComponentProperies.OrderBy(x => x.Ordinal).ThenBy(x => x.GroupOrdinal))
                {
                    //Skip Properties that are not visible
                    if (controlSystemComponentProperty.ControlSystemPropertyId.HasValue && !controlSystemComponentProperty.ControlSystemProperty.IsVisible) continue;

                    //Render Group
                    if (controlSystemComponentProperty.ComponentTypeGroupId.HasValue && !addedGroups.Contains(controlSystemComponentProperty.ComponentTypeGroup))
                    {
                        Label groupLabel = new Label
                        {
                            Content = controlSystemComponentProperty.ComponentTypeGroup.Name,
                            VerticalAlignment = VerticalAlignment.Center,
                            Margin = new Thickness(1),
                            FontWeight = FontWeights.Bold
                        };

                        PropertiesGrid.Children.Add(groupLabel);
                        Grid.SetRow(groupLabel, rowCount);
                        Grid.SetColumn(groupLabel, 0);
                        PropertiesGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(26) });
                        rowCount++;
                        addedGroups.Add(controlSystemComponentProperty.ComponentTypeGroup);

                        //This is a empty Group so don't need to render a Property
                        if (!controlSystemComponentProperty.ControlSystemPropertyId.HasValue) continue;
                    }

                    Label label = new Label();

                    Binding labelBinding = new Binding("Name")
                    {
                        Mode = BindingMode.OneTime,
                        Source = controlSystemComponentProperty.ControlSystemProperty
                    };

                    label.SetBinding(ContentControl.ContentProperty, labelBinding);
                    label.VerticalAlignment = VerticalAlignment.Center;
                    label.Margin = new Thickness(1);

                    PropertiesGrid.Children.Add(label);
                    Grid.SetRow(label, rowCount);
                    Grid.SetColumn(label, 0);

                    var propertyValue = GetPropertyValue(controlSystemComponent, controlSystemComponentProperty);

                    FrameworkElement element = Utils.BindElement(controlSystemComponentProperty.ControlSystemProperty, propertyValue,
                        e.Result, ComponentPropertyWrapViewModels, ControlChanged, pidDocuments, specDocuments);

                    PropertiesGrid.Children.Add(element);
                    Grid.SetRow((FrameworkElement)element, rowCount);
                    Grid.SetColumn((FrameworkElement)element, 1);

                    PropertiesGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(element.Height + 2) });

                    rowCount++;
                }

                LastInspectedTextBox.ResetOriginalValue();
                LastInspectedTextBox.ControlChanged += ControlChanged;

                NextInspectionTextBox.ResetOriginalValue();
                NextInspectionTextBox.ControlChanged += ControlChanged;
            };
            cmsWebServiceClient.GetAllPropertyListsAsync();
        }
コード例 #4
0
        private void OkButtonHander(object parameter)
        {
            if (AreAllValid())
            {
                CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

                cmsWebServiceClient.SavePropertyListNameCompleted +=
                    (s1, e1) =>
                    {
                        View.PropertyListName = e1.Result.EntityResult;

                        cmsWebServiceClient.GetAllPropertyListsCompleted += (s, e) =>
                        {
                            var exisitingPropertyList = (from x in e.Result where x.Id == View.PropertyListName.PropertyListId select x).FirstOrDefault();
                            if (exisitingPropertyList != null)
                            {
                                var exisitingPropertyListName = (from x in exisitingPropertyList.PropertyListNames where x.Id == View.PropertyListName.Id select x).FirstOrDefault();
                                if (exisitingPropertyListName != null)
                                {
                                    exisitingPropertyListName.Name = View.PropertyListName.Name;
                                    exisitingPropertyListName.Ordinal = View.PropertyListName.Ordinal;
                                }
                                else
                                {
                                    exisitingPropertyList.PropertyListNames.Add(View.PropertyListName);
                                }
                            }

                            View.DialogResult = true;

                        };
                        cmsWebServiceClient.GetAllPropertyListsAsync();

                    };
                cmsWebServiceClient.SavePropertyListNameAsync(mPropertyListName);
            }
        }
コード例 #5
0
        private void LoadAllPropertyLists()
        {
            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
            cmsWebServiceClient.GetAllPropertyListsCompleted += (s, e) =>
            {
                PropertyLists = e.Result;
                mListsLoaded = true;
                OnDataLoaded();

            };
            cmsWebServiceClient.GetAllPropertyListsAsync();
        }
コード例 #6
0
        private void PopulatePropertyValues(ControlSystemComponent controlSystemComponent)
        {
            int rowCount = 1;
            const int rowHeight = 25;

            //var controlSystemComponentProperies = controlSystemComponent.ControlSystemComponentType.ControlSystemComponentTypeProperties.OrderBy(x => x.Ordinal).ToList();
            var controlSystemComponentTypeTuningProperties =
                controlSystemComponent.ControlSystemComponentType.ControlSystemComponentTypeTuningProperties.OrderBy(x => x.Ordinal).ToList();

            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
            cmsWebServiceClient.GetAllPropertyListsCompleted += (s, e) =>
            {
                List<ComponentTypeGroup> addedGroups = new List<ComponentTypeGroup>();
                //controlSystemComponentProperies.Where(x => x.ComponentTypeGroupId.HasValue).ToList().ForEach(x => x.Ordinal = x.ComponentTypeGroup.Ordinal);
                controlSystemComponentTypeTuningProperties = controlSystemComponentTypeTuningProperties.
                    OrderBy(x => x.Ordinal).ThenBy(x => x.GroupOrdinal).ToList();

                foreach (var controlSystemComponentTypeTuningProperty in controlSystemComponentTypeTuningProperties.Where(x => x.ControlSystemTuningProperty.IsVisible))
                {
                    if (controlSystemComponentTypeTuningProperty.ComponentTypeGroupId.HasValue && !addedGroups.Contains(controlSystemComponentTypeTuningProperty.ComponentTypeGroup))
                    {
                        Label groupLabel = new Label
                        {
                            Content = controlSystemComponentTypeTuningProperty.ComponentTypeGroup.Name,
                            VerticalAlignment = VerticalAlignment.Center,
                            Margin = new Thickness(1),
                            FontWeight = FontWeights.Bold
                        };

                        PropertiesGrid.Children.Add(groupLabel);
                        Grid.SetRow(groupLabel, rowCount);
                        Grid.SetColumn(groupLabel, 0);
                        PropertiesGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(26) });
                        rowCount++;
                        addedGroups.Add(controlSystemComponentTypeTuningProperty.ComponentTypeGroup);
                    }

                    //Property Label
                    Label label = new Label();

                    Binding labelBinding = new Binding("Name")
                    {
                        Mode = BindingMode.OneTime,
                        Source = controlSystemComponentTypeTuningProperty.ControlSystemTuningProperty
                    };

                    label.SetBinding(ContentControl.ContentProperty, labelBinding);
                    label.VerticalAlignment = VerticalAlignment.Center;
                    label.Margin = new Thickness(1);

                    Silverlight.Controls.ToolTips.ToolTip nameTip = new Silverlight.Controls.ToolTips.ToolTip
                    {
                        Content = controlSystemComponentTypeTuningProperty.ControlSystemTuningProperty.Description
                    };
                    ToolTipService.SetToolTip(label, nameTip);

                    PropertiesGrid.Children.Add(label);
                    Grid.SetRow(label, rowCount);
                    Grid.SetColumn(label, 0);

                    var propertyValue = GetPropertyValue(controlSystemComponent, controlSystemComponentTypeTuningProperty);

                    var tuningPropertyWrapViewModel = new TuningPropertyWrapViewModel(controlSystemComponentTypeTuningProperty.ControlSystemTuningProperty, propertyValue);
                    TuningPropertyWrapViewModels.Add(tuningPropertyWrapViewModel);

                    //Property VALUE
                    var element = BindElementValue(tuningPropertyWrapViewModel, e.Result);
                    PropertiesGrid.Children.Add(element);
                    Grid.SetRow((FrameworkElement) element, rowCount);
                    Grid.SetColumn((FrameworkElement) element, 1);

                    //PCS Value
                    var pcsValueElement = BindElementPcsvalue(tuningPropertyWrapViewModel, "PcsValue");
                    pcsValueElement.IsHitTestVisible = false;
                    //((CmsTextBox)pcsValueElement).Background = new SolidColorBrush(Color.FromArgb(255, 239, 239, 239));

                    PropertiesGrid.Children.Add(pcsValueElement);
                    Grid.SetRow((FrameworkElement) pcsValueElement, rowCount);
                    Grid.SetColumn((FrameworkElement) pcsValueElement, 2);

                    //Trended
                    var trendedElement = BindCheckBoxElement(tuningPropertyWrapViewModel, "Trended");
                    ((FrameworkElement) trendedElement).HorizontalAlignment = HorizontalAlignment.Center;

                    PropertiesGrid.Children.Add(trendedElement);
                    Grid.SetRow((FrameworkElement) trendedElement, rowCount);
                    Grid.SetColumn((FrameworkElement) trendedElement, 3);

                    //Notes
                    var notesElement = BindElementTextBox(tuningPropertyWrapViewModel, "Notes");

                    PropertiesGrid.Children.Add(notesElement);
                    Grid.SetRow((FrameworkElement) notesElement, rowCount);
                    Grid.SetColumn((FrameworkElement) notesElement, 4);

                    //Accept
                    Button acceptButton = new Button {Content = "Accept"};
                    acceptButton.Height = 23;
                    acceptButton.DataContext = tuningPropertyWrapViewModel;
                    acceptButton.Command = tuningPropertyWrapViewModel.AcceptCommand;
                    acceptButton.IsEnabled = controlSystemComponentTypeTuningProperty.ControlSystemTuningProperty.IsEditable;

                    Binding visibilityBinding = new Binding("AcceptButtonVisibility")
                    {
                        Mode = BindingMode.OneWay,
                        Source = tuningPropertyWrapViewModel
                    };
                    acceptButton.SetBinding(VisibilityProperty, visibilityBinding);

                    acceptButton.Width = 60;
                    PropertiesGrid.Children.Add(acceptButton);
                    Grid.SetRow((FrameworkElement) acceptButton, rowCount);
                    Grid.SetColumn((FrameworkElement) acceptButton, 5);

                    //ModfiedUserDate
                    var modfiedUserDate = BindElementLabel(tuningPropertyWrapViewModel, "ModfiedUserDate");
                    PropertiesGrid.Children.Add(modfiedUserDate);
                    Grid.SetRow((FrameworkElement) modfiedUserDate, rowCount);
                    Grid.SetColumn((FrameworkElement) modfiedUserDate, 6);

                    PropertiesGrid.RowDefinitions.Add(new RowDefinition {Height = new GridLength(rowHeight)});

                    rowCount++;
                }
            };
            cmsWebServiceClient.GetAllPropertyListsAsync();
        }