예제 #1
0
        /// <summary>
        /// Gets the specified control from the user interface.
        /// </summary>
        /// <param name="controlName">The name of the control to retrieves.</param>
        /// <returns>Returns null if the control does not exist.</returns>
        internal dynamic GetControl(System.String controlName)
        {
            dynamic dynamic = _userInterface.FindName(controlName);

            return(dynamic);
        }
예제 #2
0
        public void СохранитьЗначение(decimal id_node, System.Windows.FrameworkElement content)
        {
            if (content == null)
            {
                return;
            }

            using (ConfigurationClient conf = new ConfigurationClient(RosService.Client.DefaultBinding, new EndpointAddress(string.Format(RosService.Client.DefaultEndpointAddress, "Configuration"))))
            {
                var node = ПолучитьРаздел(id_node, Хранилище.Оперативное);
                if (node == null)
                {
                    return;
                }

                var values = new Dictionary <string, object>();
                foreach (var item in conf.СписокАтрибутов(node.ТипДанных))
                {
                    if (item.IsReadOnly)
                    {
                        continue;
                    }
                    if (values.ContainsKey(item.Name))
                    {
                        continue;
                    }

                    var name    = string.Format("{0}_{1}", node.ТипДанных, item.Name.Replace(".", "_"));
                    var control = content.FindName(name) as System.Windows.FrameworkElement;
                    if (control == null)
                    {
                        continue;
                    }

                    //MessageBox.Show(string.Format("{0} : {1}", control.Name, control.GetType().FullName));

                    object value = null;
                    if (control is System.Windows.Controls.TextBox)
                    {
                        value = control.GetValue(System.Windows.Controls.TextBox.TextProperty);
                    }
                    else if (control is System.Windows.Controls.TextBlock)
                    {
                        value = control.GetValue(System.Windows.Controls.TextBlock.TextProperty);
                    }
                    else if (control is System.Windows.Controls.Primitives.ToggleButton)
                    {
                        value = control.GetValue(System.Windows.Controls.Primitives.ToggleButton.IsCheckedProperty);
                    }
                    else if (control is System.Windows.Controls.ContentControl)
                    {
                        value = control.GetValue(System.Windows.Controls.ContentControl.ContentProperty);
                    }
                    else if (control is System.Windows.Controls.ComboBox)
                    {
                        value = control.GetValue(System.Windows.Controls.ComboBox.SelectedValueProperty);
                    }
                    else if (control is System.Windows.Controls.Primitives.Selector)
                    {
                        value = control.GetValue(System.Windows.Controls.Primitives.Selector.SelectedValueProperty);
                    }
                    else if (control.GetType().FullName == "RosControl.UI.DatePicker")
                    {
                        var field = control.GetType().GetField("SelectedDateProperty");
                        if (field != null)
                        {
                            var dp = field.GetValue(control) as System.Windows.DependencyProperty;
                            if (dp != null)
                            {
                                value = control.GetValue(dp);
                            }
                        }
                    }
                    //else if (control.GetType().FullName == "RosService.UI.SearchTextBox") throw new Exception("Не реализованно"); // value = control.GetValue(Selector.SelectedValueProperty);
                    else if (control is System.Windows.Controls.ItemsControl && control.GetValue(System.Windows.Controls.ItemsControl.ItemsSourceProperty) is System.Data.DataTable)
                    {
                        value = control.GetValue(System.Windows.Controls.ItemsControl.ItemsSourceProperty);
                    }

                    values.Add(item.Name, value);
                }
                СохранитьЗначение(id_node, values, Хранилище.Оперативное);
            }
        }