Пример #1
0
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            Dictionary <string, string> parames = new Dictionary <string, string>();

            if (values.Length == 4)
            {
                string strReason = values[0].ToString();
                parames.Add("取消原因", strReason);

                for (int i = 1; i < values.Length; i++)
                {
                    string          strInfo  = string.Empty;
                    Grid            grid     = values[i] as Grid;
                    List <CheckBox> tempList = VisualTreeFinder.GetChildObjects <CheckBox>(grid, typeof(CheckBox));
                    foreach (CheckBox cb in tempList)
                    {
                        if ((bool)cb.IsChecked)
                        {
                            strInfo += cb.Content.ToString() + ",";
                        }
                    }

                    parames.Add(grid.Name, strInfo);
                }
            }

            return(parames);
        }
Пример #2
0
        /// <summary>
        /// 检查数据有效
        /// </summary>
        protected override bool CheckData()
        {
            bool result = true;
            List <RichTextBox> rtcList       = VisualTreeFinder.GetChildObjects <RichTextBox>(this.mainGrid, typeof(RichTextBox));
            RichTextBox        tbReason      = rtcList.Find(x => x.Name.Equals("tbReason"));
            RichTextBox        tbMeasure     = rtcList.Find(x => x.Name.Equals("tbMeasure"));
            RichTextBox        tbDocAndNurse = rtcList.Find(x => x.Name.Equals("tbDocAndNurse"));

            if (null == tbReason || null == tbMeasure || null == tbDocAndNurse)
            {
                this.ShowMessageBox("获取界面信息失败,请联系管理员", MessageBoxButton.OK, MessageBoxImage.Warning);
                result = false;
                return(result);
            }

            // 获取信息
            TextRange tempTextRange = new TextRange(tbReason.Document.ContentStart, tbReason.Document.ContentEnd);

            this.strReason = tempTextRange.Text;

            tempTextRange   = new TextRange(tbMeasure.Document.ContentStart, tbMeasure.Document.ContentEnd);
            this.StrMeasure = tempTextRange.Text;

            tempTextRange       = new TextRange(tbDocAndNurse.Document.ContentStart, tbDocAndNurse.Document.ContentEnd);
            this.StrDocAndNurse = tempTextRange.Text;

            if (result && (this.strReason.Trim().Equals("\r\n") || string.IsNullOrEmpty(this.strReason.Trim())))
            {
                this.ShowMessageBox("抢救原因不能为空,请重新录入!", MessageBoxButton.OK, MessageBoxImage.Warning);
                result = false;
                return(result);
            }

            if (result && (this.StrMeasure.Trim().Equals("\r\n") || string.IsNullOrEmpty(this.StrMeasure.Trim())))
            {
                this.ShowMessageBox("抢救措施不能为空,请重新录入!", MessageBoxButton.OK, MessageBoxImage.Warning);
                result = false;
                return(result);
            }

            if (result && (this.StrDocAndNurse.Trim().Equals("\r\n") || string.IsNullOrEmpty(this.StrDocAndNurse.Trim())))
            {
                this.ShowMessageBox("抢救参与人员不能为空,请重新录入!", MessageBoxButton.OK, MessageBoxImage.Warning);
                result = false;
                return(result);
            }

            if (this.EndDateTime < this.StartDateTime)
            {
                this.EndDateTime = this.StartDateTime;
                this.ShowMessageBox("抢救结束时间小于开始时间,请重新填写", MessageBoxButton.OK, MessageBoxImage.Warning);
                result = false;
                return(result);
            }

            return(result);
        }
Пример #3
0
        private void SetControlIndex()
        {
            List <ComboBoxEx> cbos = VisualTreeFinder.GetChildsByName <ComboBoxEx>(this, "InnerCboex");
            int count = 0;

            foreach (var item in cbos)
            {
                item.Tag = count;
                //item.RemoveHandler(TextBoxBase.TextChangedEvent, new RoutedEventHandler(MyTextChanged));
                //item.AddHandler(TextBoxBase.TextChangedEvent, new RoutedEventHandler(MyTextChanged));
                count++;
            }
        }
Пример #4
0
        private void DbHistoryListBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ListBoxItem      listBoxItem;
            ContentPresenter myContentPresenter;
            DataTemplate     myDataTemplate;
            RadioButton      radioButton;
            var selectedIndex = DbHistoryListBox.SelectedIndex;

            if (selectedIndex >= 0)
            {
                if (DataContext is ExportEntityViewModel viewModel)
                {
                    viewModel.CurrentDbServerInfoItem = new DbServerInfo
                    {
                        Ip           = viewModel.DbServerHistoryItems[selectedIndex].Ip,
                        Database     = viewModel.DbServerHistoryItems[selectedIndex].Database,
                        DatabaseType = viewModel.DbServerHistoryItems[selectedIndex].DatabaseType,
                        Encoding     = viewModel.DbServerHistoryItems[selectedIndex].Encoding,
                        Password     = viewModel.DbServerHistoryItems[selectedIndex].Password,
                        TcpIpPort    = viewModel.DbServerHistoryItems[selectedIndex].TcpIpPort,
                        UserId       = viewModel.DbServerHistoryItems[selectedIndex].UserId
                    };
                }

                listBoxItem = (ListBoxItem)DbHistoryListBox.ItemContainerGenerator.ContainerFromItem(DbHistoryListBox.Items[DbHistoryListBox.SelectedIndex]);
                var visualTreeFinder = new VisualTreeFinder();
                myContentPresenter = visualTreeFinder.FindVisualChild <ContentPresenter>(listBoxItem);
                myDataTemplate     = myContentPresenter.ContentTemplate;
                radioButton        = myDataTemplate.FindName("IpRadioButton", myContentPresenter) as RadioButton;
                if (radioButton != null)
                {
                    radioButton.IsChecked = true;
                }
            }
            else
            {
                foreach (var item in DbHistoryListBox.Items)
                {
                    listBoxItem = (ListBoxItem)DbHistoryListBox.ItemContainerGenerator.ContainerFromItem(item);
                    var visualTreeFinder = new VisualTreeFinder();
                    myContentPresenter = visualTreeFinder.FindVisualChild <ContentPresenter>(listBoxItem);
                    myDataTemplate     = myContentPresenter.ContentTemplate;
                    radioButton        = myDataTemplate.FindName("IpRadioButton", myContentPresenter) as RadioButton;
                    if (radioButton != null)
                    {
                        radioButton.IsChecked = false;
                    }
                }
            }
        }
        private static void Ok_OnClick(object sender, RoutedEventArgs e)
        {
            if (!(sender is DependencyObject))
            {
                return;
            }

            var parent = VisualTreeFinder.FindParentControl <Window>(sender as DependencyObject);

            if (parent == null)
            {
                return;
            }

            if (ComponentDispatcher.IsThreadModal)
            {
                parent.DialogResult = true;
            }
            else
            {
                parent.Close();
            }
        }
Пример #6
0
        public bool ValidateEditingBranch()
        {
            ItemsControl condGroupControl = VisualTreeFinder.FindChild <ItemsControl>(this, "condGroupControl");

            return(Validator.Validate(condGroupControl));
        }