public static bool ShowDialog(DialogSourceViewModel model, out string menuResult)
        {
            menuResult = "0";
            var viewService = IoC.Instance.Resolve <IViewService>();

            if (viewService.ShowDialogWindow(model, false) != true)
            {
                return(false);
            }

            if (model.Fields != null)
            {
                foreach (var field in model.Fields)
                {
                    if (!model.ContainsKey(field.Name))
                    {
                        continue;
                    }

                    var value = model[field.Name];
                    if (!Equals(field.Value, value))
                    {
                        field.Value = value;
                    }
                }
            }

            menuResult = string.Format("1{0}", string.IsNullOrEmpty(model.MenuResult) ? string.Empty : model.MenuResult);
            return(true);
        }
 private void ChangeActiveAll(DialogSourceViewModel model, bool isValue)
 {
     foreach (var m in _user2MandantList)
     {
         m.User2MandantIsActive = isValue;
     }
 }
 private void RefreshBinding(DialogSourceViewModel model)
 {
     if (model == null)
     {
         return;
     }
     FillGroup(objectDataLayout, model);
 }
Exemple #4
0
        private decimal?SelectWorker(string filter)
        {
            var workerModel = new DialogSourceViewModel
            {
                PanelCaption  = Resources.StringResources.SelectWorkerPanelCaption,
                FontSize      = 14,
                IsMenuVisible = false,
            };

            var lstWorkers = new ValueDataField
            {
                Name          = "lstWorkers",
                LabelPosition = "Top",
                Caption       = Resources.StringResources.WorkerList
            };

            lstWorkers.FieldName                   = lstWorkers.Name;
            lstWorkers.SourceName                  = lstWorkers.Name;
            lstWorkers.FieldType                   = typeof(Object);
            lstWorkers.LookupCode                  = "WORKER_WORKERFIO_RCL";
            lstWorkers.LookupFilterExt             = filter;
            lstWorkers.Properties["MaxRowsOnPage"] = 6;
            lstWorkers.Properties["CloseDialogOnSelectedItemChanged"] = true;
            lstWorkers.Properties["LookupType"] = "SelectControl";
            lstWorkers.SetFocus = true;
            workerModel.Fields.Add(lstWorkers);
            workerModel.UpdateSource();

            var vs = IoC.Instance.Resolve <IViewService>();

            while (true)
            {
                if (vs.ShowDialogWindow(workerModel, false) != true)
                {
                    vs.ShowDialog(Resources.StringResources.RCL, Resources.StringResources.WorkerNotSelect, MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
                    continue;
                }

                switch (workerModel.MenuResult)
                {
                case "Value":
                    var     worker = workerModel["lstWorkers"];
                    decimal workerId;
                    if (!decimal.TryParse(worker.ToString(), out workerId))
                    {
                        throw new DeveloperException(string.Format("Bad workerId value '{0}'.",
                                                                   worker));
                    }

                    return(workerId);

                default:
                    continue;
                }
            }
        }
Exemple #5
0
        private bool ShowDialog(DialogSourceViewModel model)
        {
            var viewService = IoC.Instance.Resolve <IViewService>();

            if (viewService.ShowDialogWindow(model, false) != true)
            {
                return(false);
            }
            return(true);
        }
        private DialogSourceViewModel CreateDialogModel(ValueDataField[] footerMenu)
        {
            var result = new DialogSourceViewModel
            {
                PanelCaption  = "Активные манданты",
                FontSize      = FontSize.Get(_context),
                IsMenuVisible = true,
            };

            var field = new ValueDataField
            {
                Name          = FieldName,
                FieldType     = typeof(User2Mandant),
                Caption       = string.Empty,
                LabelPosition = "Left",
                IsEnabled     = true,
                SetFocus      = true,
                CloseDialog   = true
            };

            field.Set(ValueDataFieldConstants.LookupType, RclLookupType.SelectGridControl.ToString());
            field.Set(ValueDataFieldConstants.ShowTotalRow, false);
            field.Set(ValueDataFieldConstants.ShowControlMenu, false);
            field.Set(ValueDataFieldConstants.AllowAutoShowAutoFilterRow, true);
            field.Set(ValueDataFieldConstants.ShowAutoFilterRow, false);
            field.Set(ValueDataFieldConstants.DoNotActionOnEnterKey, true);

            //Получаем поля для грида
            var names     = new[] { User2Mandant.User2MandantIsActivePropertyName, User2Mandant.MandantCodePropertyName, User2Mandant.MandantNamePropertyName, User2Mandant.MandantIDPropertyName };
            var fieldList = names.Select(propertyName => DataFieldHelper.Instance.GetDataFields(typeof(User2Mandant), SettingDisplay.List).ToList().FirstOrDefault(p => p.Name.EqIgnoreCase(propertyName)))
                            .Where(f => f != null)
                            .ToArray();


            fieldList[0].Set(ValueDataFieldConstants.ColumnWidth, "60");
            fieldList[1].Set(ValueDataFieldConstants.ColumnWidth, "100");
            fieldList[2].Set(ValueDataFieldConstants.ColumnWidth, "250");

            field.Set(ValueDataFieldConstants.Fields, fieldList);
            field.Set(ValueDataFieldConstants.ItemsSource, _user2MandantList);

            if (footerMenu != null)
            {
                field.Set(ValueDataFieldConstants.FooterMenu, footerMenu);
            }

            field.FieldName  = field.Name;
            field.SourceName = field.Name;
            result.Fields.Add(field);

            result.UpdateSource();
            return(result);
        }
        private DialogSourceViewModel GetMainModel(NativeActivityContext context, ValueDataField property, bool canMovePrev = true)
        {
            var model = new DialogSourceViewModel
            {
                PanelCaption  = PanelCaption.Get(context),
                FontSize      = FontSize.Get(context),
                IsMenuVisible = false,
            };

            // добавим параметр
            property.SetFocus = true;
            model.Fields.Add(property);

            var footerMenuItem = new ValueDataField
            {
                Name      = "footerMenu",
                FieldType = typeof(IFooterMenu),
                Visible   = true,
                IsEnabled = true
            };

            footerMenuItem.FieldName  = footerMenuItem.Name;
            footerMenuItem.SourceName = footerMenuItem.Name;
            model.Fields.Add(footerMenuItem);

            var footerMenu = new List <ValueDataField>();

            if (canMovePrev)
            {
                var prevBtn = new ValueDataField {
                    Name = "F2", Caption = "Назад", FieldType = typeof(Button)
                };
                prevBtn.FieldName  = prevBtn.Name;
                prevBtn.SourceName = prevBtn.Name;
                prevBtn.Value      = prevBtn.Name;
                footerMenu.Add(prevBtn);
            }

            var nextBtn = new ValueDataField {
                Name = "F1", Caption = "Далее", FieldType = typeof(Button)
            };

            nextBtn.FieldName  = nextBtn.Name;
            nextBtn.SourceName = nextBtn.Name;
            nextBtn.Value      = nextBtn.Name;
            footerMenu.Add(nextBtn);

            footerMenuItem.Set(ValueDataFieldConstants.FooterMenu, footerMenu.ToArray());

            model.UpdateSource();
            return(model);
        }
        private DialogSourceViewModel CreateDialogModel(ActivityContext context, ValueDataField property)
        {
            var model = new DialogSourceViewModel
            {
                PanelCaption  = "Введите значение",
                FontSize      = FontSize.Get(context),
                IsMenuVisible = false,
            };

            // добавим параметр
            property.SetFocus = true;
            model.Fields.Add(property);

            var footerMenu = new List <ValueDataField>();

            var footerMenuItem = new ValueDataField
            {
                Name    = "Menu0",
                Caption = "Назад",
                Value   = "Escape"
            };

            footerMenuItem.Set(ValueDataFieldConstants.Row, 0);
            footerMenuItem.Set(ValueDataFieldConstants.Column, 0);
            footerMenu.Add(footerMenuItem);

            footerMenuItem = new ValueDataField
            {
                Name    = "Menu1",
                Caption = "Далее",
                Value   = "Enter"
            };
            footerMenuItem.Set(ValueDataFieldConstants.Row, 0);
            footerMenuItem.Set(ValueDataFieldConstants.Column, 1);
            footerMenu.Add(footerMenuItem);

            var footerMenufield = new ValueDataField
            {
                Name      = ValueDataFieldConstants.FooterMenu,
                Caption   = ValueDataFieldConstants.FooterMenu,
                FieldType = typeof(FooterMenu),
                IsEnabled = true
            };

            footerMenufield.Set(ValueDataFieldConstants.FooterMenu, footerMenu.ToArray());
            model.Fields.Add(footerMenufield);

            model.UpdateSource();
            return(model);
        }
        private void ChangeActive(DialogSourceViewModel model)
        {
            var id = model[FieldName] as decimal?;

            if (!id.HasValue)
            {
                return;
            }
            var row = _user2MandantList.FirstOrDefault(p => p.GetKey <decimal>() == id.Value);

            if (row == null)
            {
                return;
            }
            row.User2MandantIsActive = !row.User2MandantIsActive;
        }
        private DialogSourceViewModel GetMainModel(List <Product> prdList)
        {
            if (_mainModel == null)
            {
                _mainModel = new DialogSourceViewModel
                {
                    PanelCaption  = "Выбор товара",
                    IsMenuVisible = false,
                    FontSize      = 15
                };

                var prdLst = new ValueDataField
                {
                    Name          = ProductListModelPropertyName,
                    Caption       = string.Empty,
                    FieldType     = typeof(Product),
                    LabelPosition = "None",
                    IsEnabled     = true,
                    SetFocus      = true,
                    CloseDialog   = true
                };

                prdLst.Set(ValueDataFieldConstants.LookupType, RclLookupType.SelectGridControl.ToString());
                prdLst.Set(ValueDataFieldConstants.ShowControlMenu, true);
                prdLst.Set(ValueDataFieldConstants.AllowAutoShowAutoFilterRow, false);
                prdLst.Set(ValueDataFieldConstants.ShowAutoFilterRow, false);
                prdLst.Set(ValueDataFieldConstants.DoNotActionOnEnterKey, false);
                prdLst.Set(ValueDataFieldConstants.ItemsSource, prdList);
                prdLst.Set(ValueDataFieldConstants.CloseDialogOnSelectedItemChanged, true);

                var grdFields = GetGridFields(prdLst.FieldType, DisplaySetting);

                prdLst.Set(ValueDataFieldConstants.Fields, grdFields.ToArray());

                _mainModel.Fields.Add(prdLst);
            }
            else
            {
                _mainModel.GetField(ProductListModelPropertyName).Set(ValueDataFieldConstants.ItemsSource, prdList);
            }

            _mainModel.UpdateSource();

            return(_mainModel);
        }
        private DialogSourceViewModel GetMainModel(List <MutableTuple <Int32, PL, TE> > activePlList)
        {
            if (_mainModel == null)
            {
                _mainModel = new DialogSourceViewModel
                {
                    PanelCaption  = "Списки пикинга",
                    IsMenuVisible = false,
                    FontSize      = 15
                };

                var plLst = new ValueDataField
                {
                    Name          = PlListPropertyName,
                    Caption       = string.Empty,
                    FieldType     = typeof(MutableTuple <Int32, PL, TE>),
                    LabelPosition = "Left",
                    IsEnabled     = true,
                    SetFocus      = true,
                    CloseDialog   = true
                };

                plLst.Set(ValueDataFieldConstants.LookupType, RclLookupType.SelectGridControl.ToString());
                plLst.Set(ValueDataFieldConstants.ShowControlMenu, true);
                plLst.Set(ValueDataFieldConstants.AllowAutoShowAutoFilterRow, false);
                plLst.Set(ValueDataFieldConstants.ShowAutoFilterRow, false);
                plLst.Set(ValueDataFieldConstants.DoNotActionOnEnterKey, false);
                plLst.Set(ValueDataFieldConstants.ItemsSource, activePlList);
                plLst.Set(ValueDataFieldConstants.CloseDialogOnSelectedItemChanged, true);

                var grdFields = GetGridFields(plLst.FieldType, DisplaySetting);

                plLst.Set(ValueDataFieldConstants.Fields, grdFields.ToArray());

                _mainModel.Fields.Add(plLst);
            }
            else
            {
                _mainModel.GetField(PlListPropertyName).Set(ValueDataFieldConstants.ItemsSource, activePlList);
            }

            _mainModel.UpdateSource();

            return(_mainModel);
        }
Exemple #12
0
        private DialogSourceViewModel GetMainModel(NativeActivityContext context, ValueDataField property)
        {
            var model = new DialogSourceViewModel
            {
                PanelCaption  = "Введите значение",
                FontSize      = FontSize.Get(context),
                IsMenuVisible = false,
            };

            // добавим параметр
            property.SetFocus = true;
            model.Fields.Add(property);

            var footerMenuItem = new ValueDataField
            {
                Name      = "footerMenu",
                FieldType = typeof(IFooterMenu),
                Visible   = true,
                IsEnabled = true
            };

            footerMenuItem.FieldName  = footerMenuItem.Name;
            footerMenuItem.SourceName = footerMenuItem.Name;
            model.Fields.Add(footerMenuItem);

            var nextBtn = new ValueDataField
            {
                Name      = "F1",
                Caption   = "Далее",
                FieldType = typeof(Button),
            };

            nextBtn.FieldName  = nextBtn.Name;
            nextBtn.SourceName = nextBtn.Name;
            nextBtn.Value      = nextBtn.Name;
            nextBtn.Set(ValueDataFieldConstants.Row, 0);
            nextBtn.Set(ValueDataFieldConstants.Column, 1);

            footerMenuItem.Set(ValueDataFieldConstants.FooterMenu, new[] { nextBtn });

            model.UpdateSource();
            return(model);
        }
        protected override void Execute(NativeActivityContext context)
        {
            var model    = Model.Get(context);
            var source   = Source.Get(context);
            var dlgmodel = new DialogSourceViewModel
            {
                PanelCaption  = model.Header,
                IsMenuVisible = IsMenuVisible.Get(context),
                FontSize      = model.FontSize
            };

            var menu = MenuItems.Get(context);

            if (menu != null && menu.Length > 0)
            {
                dlgmodel.MenuItems.AddRange(menu);
                dlgmodel.CreateMenu();
            }

            UpdateFields(source, model);
            dlgmodel.Fields.AddRange(model.Fields);
            dlgmodel.UpdateSource();
            dlgmodel.LayoutValue = Layout.Get(context);

            string menuResult;
            var    dialogResult = ShowDialog(dlgmodel, out menuResult);

            if (dialogResult)
            {
                model.Fields.Clear();
                model.Fields.AddRange(dlgmodel.Fields);
                Model.Set(context, model);
            }

            DialogResult.Set(context, dialogResult);
            if (DialogResultWithMenu != null)
            {
                DialogResultWithMenu.Set(context, menuResult);
            }
        }
        private void FillGroup(LayoutGroup group, DialogSourceViewModel vm)
        {
            //TODO: по хорошему нужно писать свой контрол на остнове DataLayout-а (научить правильно биндиться, понимать аттрибуты и т.д.)
            if (vm.Source != null)
            {
                group.DataContext = vm.Source;
            }
            group.Children.Clear();
            var setfocus = false;

            var layoutGroups = new Dictionary <string, LayoutGroup>();

            foreach (var field in vm.Fields.OrderBy(p => p.Order).ToArray())
            {
                var oldLayout = FindName(field.Name);
                if (oldLayout != null)
                {
                    continue;
                }
                if (field.SetFocus)
                {
                    setfocus = true;
                }

                UIElement child = null;
                if (field.FieldType == typeof(Button) || field.FieldType == typeof(CustomButton))
                {
                    var layoutItem = new LayoutItem
                    {
                        Name       = field.Name,
                        IsEnabled  = field.IsEnabled.HasValue && field.IsEnabled.Value,
                        Visibility = field.Visible ? Visibility.Visible : Visibility.Collapsed,
                        Content    = MenuHelper.CreateCustomButton(field, vm.MenuCommand, vm.FontSize, false)
                    };
                    RegisterName(field.Name, layoutItem);
                    child = layoutItem;
                }
                else if (field.FieldType == typeof(IFooterMenu) || field.FieldType == typeof(FooterMenu))
                {
                    MenuHelper.CreateFooterMenu(footerMenuControl, field, vm.MenuCommand, vm.FontSize, false);
                    continue;
                }
                else
                {
                    var layoutItem = new CustomDataLayoutItem(vm.IsWfDesignMode, field)
                    {
                        IsVisibilitySetOutside    = true,
                        IsDisplayFormatSetOutside = true,

                        FontSize = vm.FontSize,

                        IsReadOnlySetOutside = true,
                        TooltipDisable       = true,
                        CloseDialogCommand   = vm.MenuCommand
                    };
                    RegisterName(field.Name, layoutItem);

                    var layoutGroupName = LayoutGroupHelper.GetLayoutGroupNameFromField(field, vm.IsWfDesignMode);
                    if (string.IsNullOrEmpty(layoutGroupName))
                    {
                        child = layoutItem;
                    }
                    else
                    {
                        LayoutGroup layoutGroup;
                        if (!layoutGroups.ContainsKey(layoutGroupName))
                        {
                            layoutGroup = LayoutGroupHelper.CreateLayoutGroup(layoutGroupName);
                            layoutGroups[layoutGroupName] = layoutGroup;
                            RegisterName(layoutGroupName, layoutGroup);
                            group.Children.Add(layoutGroup);
                        }

                        layoutGroup = layoutGroups[layoutGroupName];
                        layoutGroup.Children.Add(layoutItem);
                    }
                }

                if (child != null)
                {
                    group.Children.Add(child);
                }
            }

            if (!setfocus)
            {
                KeyHelper.SetFocusElement(group.Children);
            }

            objectDataLayout.RestoreLayout(vm.LayoutValue);
        }
Exemple #15
0
        private DialogSourceViewModel GetTimerFormModel()
        {
            var result = new DialogSourceViewModel
            {
                PanelCaption  = DialogTitle.Get(_context),
                FontSize      = FontSize.Get(_context),
                IsMenuVisible = false,
            };

            var footerMenu = new List <ValueDataField>();
            var menuNext   = new ValueDataField
            {
                Name    = "Menu0",
                Caption = "Далее",
                Value   = Key.Enter.ToString()
            };

            menuNext.Set(ValueDataFieldConstants.Row, 0);
            menuNext.Set(ValueDataFieldConstants.Column, 1);
            footerMenu.Add(menuNext);

            ValueDataField field;
            var            message = Message.Get(_context);

            if (!string.IsNullOrEmpty(message))
            {
                field = new ValueDataField
                {
                    Name          = "txtMessage",
                    FieldType     = typeof(string),
                    LabelPosition = "None",
                    IsEnabled     = false,
                    Value         = message
                };
                field.FieldName  = field.Name;
                field.SourceName = field.Name;
                result.Fields.Add(field);
            }

            var dateFrom = DateFrom.Get(_context);

            if (dateFrom.HasValue)
            {
                field = new ValueDataField
                {
                    Name          = "dtDateFrom",
                    Caption       = "С",
                    FieldType     = typeof(DateTime),
                    LabelPosition = "Left",
                    Value         = dateFrom.Value,
                    DisplayFormat = DefaultDateTimeFormat,
                    IsEnabled     = false,
                    SetFocus      = false,
                    CloseDialog   = false
                };
                field.FieldName  = field.Name;
                field.SourceName = field.Name;
                result.Fields.Add(field);
            }

            var timevalue = TimeSpan.FromSeconds(dateFrom.HasValue ? (DateTime.Now - dateFrom.Value).TotalSeconds - TimerOffset.Get(_context) : 0);

            field = new ValueDataField
            {
                Name          = TimerFieldName,
                Caption       = "Таймер",
                FieldType     = typeof(TimeSpan),
                LabelPosition = "Left",
                DisplayFormat = "hh\\:mm\\:ss",
                Value         = timevalue,
                IsEnabled     = false,
                SetFocus      = false,
                CloseDialog   = false
            };
            field.FieldName  = field.Name;
            field.SourceName = field.Name;
            result.Fields.Add(field);

            var fieldFooterMenu = new ValueDataField
            {
                Name      = "footerMenu",
                FieldType = typeof(IFooterMenu)
            };

            fieldFooterMenu.FieldName  = fieldFooterMenu.Name;
            fieldFooterMenu.SourceName = fieldFooterMenu.Name;
            fieldFooterMenu.Properties["FooterMenu"] = footerMenu.ToArray();
            result.Fields.Add(fieldFooterMenu);

            result.UpdateSource();
            return(result);
        }