Esempio n. 1
0
        protected override void OnPreviewKeyDown(KeyEventArgs e)
        {
            base.OnPreviewKeyDown(e);

            if (e.Handled)
            {
                return;
            }

            if (!DoNotActionOnEnterKey && e.Key == Key.Enter && Keyboard.Modifiers == ModifierKeys.None && RclGridControl.SelectedItem != null)
            {
                e.Handled = true;
                OnSelect(ValueDataFieldConstants.CreateDefaultParameter(ValueDataFieldConstants.Value));
                return;
            }

            if ((AllowAutoShowAutoFilterRow || ShowAutoFilterRow) && IsNotFunctionalKey(e.Key))
            {
                if (!ShowAutoFilterRow)
                {
                    ShowAutoFilterRow = true;
                }

                RclGridControl.SetFocusRow(DataControlBase.AutoFilterRowHandle);
            }
        }
Esempio n. 2
0
        private void OnSelect(ValueDataField parameter)
        {
            if (!CanSelect(parameter))
            {
                return;
            }

            CommandParameter = ValueDataFieldConstants.CreateDefaultParameter(ValueDataFieldConstants.Value);
            ExecuteCommandSource(this);
        }
Esempio n. 3
0
        private void OnSelectCommand()
        {
            if (!CanSelectCommand())
            {
                return;
            }

            if (MenuAction != null)
            {
                MenuAction(ValueDataFieldConstants.CreateDefaultParameter(string.Empty));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// MEGA-HACK: получаем переменные из WF и выбираем значение нужной переменной.
        /// </summary>
        public static void SetWorkFlowPropertyValue(ActivityContext context, Collection <ValueDataField> fields)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (fields == null)
            {
                throw new ArgumentNullException("fields");
            }

            var dataContext = context.DataContext;
            var propertyDescriptorCollection = dataContext.GetProperties();

            foreach (var field in fields)
            {
                foreach (PropertyDescriptor propertyDesc in propertyDescriptorCollection)
                {
                    var key          = ValueDataFieldConstants.WfPropertyName + "Value";
                    var propertyName = field.Get <object>(key) ?? ValueDataFieldConstants.GetWfVariablePropertyName(field.Value);
                    if (propertyName != null && propertyDesc.Name.Equals(propertyName))
                    {
                        field.Value = propertyDesc.GetValue(dataContext);
                        //break;
                    }

                    key          = ValueDataFieldConstants.WfPropertyName + "LookupFilterExt";
                    propertyName = field.Get <string>(key) ?? ValueDataFieldConstants.GetWfVariablePropertyName(field.LookupFilterExt);
                    if (propertyName != null && propertyDesc.Name.Equals(propertyName))
                    {
                        var lookupFilterExtValue = propertyDesc.GetValue(dataContext);
                        if (lookupFilterExtValue != null)
                        {
                            field.LookupFilterExt = lookupFilterExtValue.ToString();
                        }
                        //break;
                    }

                    foreach (var prop in field.Properties.Where(p => p.Value != null).ToArray())
                    {
                        propertyName = ValueDataFieldConstants.GetWfVariablePropertyName(prop.Value);
                        if (propertyName != null && propertyDesc.Name.Equals(propertyName))
                        {
                            field.Set(prop.Key, propertyDesc.GetValue(dataContext));
                        }
                    }
                }
            }
        }
        private ValueDataFieldPropertiesEditorDialog.ValueDataFieldProperty CreateValueDataFieldProperty(KeyValuePair <string, object> property)
        {
            var result = new ValueDataFieldPropertiesEditorDialog.ValueDataFieldProperty
            {
                Name          = property.Key,
                Type          = property.Value == null ? typeof(object) : property.Value.GetType(),
                Value         = property.Value,
                UseWfVariable = ValueDataFieldConstants.ValidateUseWfVariable(property.Value)
            };

            if (result.UseWfVariable)
            {
                result.Value = ValueDataFieldConstants.GetWfVariablePropertyName(result.Value);
                if (result.Type == typeof(string))
                {
                    result.Type = typeof(object);
                }
            }
            return(result);
        }
        //Нет в 13.2
        //protected override FrameworkElement CreateContent(Type valueType, DataType? dataType)
        protected override FrameworkElement CreateContentAndInitializeUI()
        {
            FrameworkElement result = null;

            if (!string.IsNullOrEmpty(LookUpCode) && LookupType == RclLookupType.None)
            {
                LookupType = RclLookupType.Default;
            }

            switch (LookupType)
            {
            case RclLookupType.Default:
            case RclLookupType.DefaultGrid:
                var customComboBoxEditRcl = new CustomComboBoxEditRcl
                {
                    Name                      = string.Format("{0}_{1}", Name, LookupType),
                    IsWfDesignMode            = IsWfDesignMode,
                    LookupType                = LookupType,
                    LookUpCodeEditorFilterExt =
                        IsWfDesignMode ? WfDesignModeLookUpCodeEditorFilterExt : LookUpFilterExt,
                    LookUpCodeEditor    = LookUpCode,
                    UseFunctionKeys     = UseFunctionKeys,
                    ParentKeyPreview    = ParentKeyPreview,
                    HotKey              = HotKey,
                    CustomDisplayMember = CustomDisplayMember,
                    LookupTitle         = DisplayName
                };
                if (MaxRowsOnPage.HasValue)
                {
                    customComboBoxEditRcl.MaxRowsOnPage = MaxRowsOnPage.Value;
                }
                result = customComboBoxEditRcl;
                break;

            case RclLookupType.SelectControl:
                VerticalAlignment = VerticalAlignment.Stretch;
                var select = new CustomSelectControl
                {
                    LookUpCodeEditorFilterExt =
                        IsWfDesignMode ? WfDesignModeLookUpCodeEditorFilterExt : LookUpFilterExt,
                    LookUpCodeEditor    = LookUpCode,
                    UseFunctionKeys     = UseFunctionKeys,
                    ParentKeyPreview    = ParentKeyPreview,
                    CustomDisplayMember = CustomDisplayMember,
                    ExternalItemsSource = ItemsSource,
                    DisplayMember       = DisplayMember,
                    ValueMember         = ValueMember
                };
                if (MaxRowsOnPage.HasValue)
                {
                    select.MaxRowsOnPage = MaxRowsOnPage.Value;
                }
                if ((CloseDialogOnSelectedItemChanged || CloseDialog) && CloseDialogCommand != null)
                {
                    select.CommandParameter = ValueDataFieldConstants.CreateDefaultParameter(ValueDataFieldConstants.Value);
                    select.Command          = CloseDialogCommand;
                }
                result = select;
                break;

            case RclLookupType.SelectGridControl:
            case RclLookupType.List:
                VerticalAlignment = VerticalAlignment.Stretch;

                //debug
                //if (IsWfDesignMode)
                //    Fields = GetGridFields();
                //

                var customSelectView = new CustomSelectView
                {
                    ItemsSourceType = FieldType,
                    IsWfDesignMode  = IsWfDesignMode,
                    AutoShowAutoFilterRowWhenRowsCountMoreThan = -1,
                    LookUpCodeEditorFilterExt =
                        IsWfDesignMode ? WfDesignModeLookUpCodeEditorFilterExt : LookUpFilterExt,
                    LookUpCodeEditor           = LookUpCode,
                    Source                     = ItemsSource,
                    DisplaySetting             = DisplaySetting.HasValue ? DisplaySetting.Value : SettingDisplay.List,
                    VerifyColumnsSourceChanged = true,
                    ShowSelectMenuItem         = LookupType == RclLookupType.SelectGridControl,
                    MaxRows                    = MaxRows,
                    Fields                     = Fields != null && Fields.Any() ? new ObservableCollection <DataField>(Fields) : null,
                    AllowAutoShowAutoFilterRow = AllowAutoShowAutoFilterRow,
                    DoNotAllowUpdateShowAutoFilterRowFromXml = DoNotAllowUpdateShowAutoFilterRowFromXml,
                    ShowAutoFilterRow     = ShowAutoFilterRow,
                    ShowTotalRow          = ShowTotalRow,
                    DoNotActionOnEnterKey = DoNotActionOnEnterKey,
                    BestFitColumnNames    = BestFitColumnNames,
                    FormatConditions      = FormatConditions
                };

                if (ShowControlMenu.HasValue)
                {
                    customSelectView.ShowMenu = ShowControlMenu.Value;
                }

                if (IsWfDesignMode && string.IsNullOrEmpty(customSelectView.LookUpCodeEditor) &&
                    customSelectView.Source == null && FieldType != null)
                {
                    customSelectView.Source = new[] { Activator.CreateInstance(FieldType) };
                }

                if (FooterMenu != null && FooterMenu.Length > 0)
                {
                    customSelectView.AddFooterMenuItems(FooterMenu, FontSize, IsWfDesignMode);
                }

                if ((CloseDialogOnSelectedItemChanged || CloseDialog) && CloseDialogCommand != null)
                {
                    customSelectView.Command = CloseDialogCommand;
                }

                result = customSelectView;
                break;
            }

            if (IsMemoView)
            {
                result = new MemoEdit
                {
                    ShowIcon = false,
                    //PopupWidth = 250,
                    MemoTextWrapping = TextWrapping.Wrap,
                    MemoVerticalScrollBarVisibility   = ScrollBarVisibility.Hidden,
                    MemoHorizontalScrollBarVisibility = ScrollBarVisibility.Hidden
                };
            }

            if (typeof(IList).IsAssignableFrom(FieldType))
            {
                result = CreateContentSubListView(FieldType);
            }

            if (result == null)
            {
                result = CreateContentInternal();
            }

            if (result == null)
            {
                result = base.CreateContentAndInitializeUI();
                var textEdit = result as TextEdit;
                if (textEdit != null)
                {
                    textEdit.TextWrapping = TextWrapping.Wrap;
                    if (textEdit.TextWrapping == TextWrapping.Wrap)
                    {
                        textEdit.HorizontalContentAlignment = HorizontalAlignment.Left;
                        textEdit.VerticalContentAlignment   = VerticalAlignment.Top;
                    }
                    if (!String.IsNullOrEmpty(BackGroundColor))
                    {
                        var brushconverter = new BrushConverter();
                        ((TextEdit)result).Background = brushconverter.ConvertFromString(BackGroundColor) as Brush;
                    }
                }
            }

            var termilalUi = result as IRclUi;

            if (termilalUi == null)
            {
                //Гридам не навязывать стандартную обработку клавиш.
                if (LookupType != RclLookupType.SelectGridControl && LookupType != RclLookupType.List)
                {
                    if (CloseDialog)
                    {
                        KeyHelper.SetCloseDialogElement(result);
                    }
                    if (IsDoNotMovedFocusOnNextControl)
                    {
                        KeyHelper.SetDoNotMovedFocusOnNextControl(result);
                    }
                    result.PreviewKeyDown += (s, e) => KeyHelper.PreviewKeyDown(result, e);
                }
            }
            else
            {
                termilalUi.IsMovedFocusOnNextControl = !CloseDialog;
            }

            if (IsFocused || SetFocus)
            {
                result.BackgroundFocus();
            }

            if (IsWfDesignMode)
            {
                var themeName = ThemeManager.GetThemeName(this);
                if (string.IsNullOrEmpty(themeName))
                {
                    themeName = StyleKeys.RclDefaultThemeName;
                }
                ThemeManager.SetThemeName(result, themeName);
            }

            return(result);
        }