Ejemplo n.º 1
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            this._dbSettingView = AutoUI.ViewFactory.CreateListView(typeof(DbSettingItem));
            this._dbSettingView.CheckingMode = CheckingMode.CheckingRow;

            dbContainer.Content = this._dbSettingView.Control;
        }
Ejemplo n.º 2
0
        public override bool CanExecute(ListLogicalView view)
        {
            bool canExecute = false;

            if (view.Data != null)
            {
                foreach (var item in view.Data)
                {
                    if (!this.CanShow(item))
                    {
                        canExecute = true;
                        break;
                    }
                }
            }

            //第一次运行时,执行过滤。
            if (canExecute && !this._initialized)
            {
                this.Execute(view);
                this._initialized = true;
            }

            return(canExecute);
        }
Ejemplo n.º 3
0
        public static ComboListControl CreateComboListControl(ListLogicalView view)
        {
            var titleProperty = view.Meta.TitleProperty;

            if (titleProperty == null)
            {
                throw new InvalidProgramException(view.EntityType.Name + "类没有设置 Title 属性。");
            }

            var ddl = new ComboListControl
            {
                InnerListView     = view,
                Name              = "下拉列表",
                VerticalAlignment = VerticalAlignment.Center,
                MinWidth          = 150,
            };

            ddl.DataContext = view;
            ddl.SetBinding(ComboListControl.TextProperty, "CurrentObject." + titleProperty);

            //当 View 发生 Refreshed 事件时,很可能表示有底层数据改变了,但是没有级联通知到界面上,
            //所以当 View 的控件被 Refresh 后,这个下拉框也需要主动进行刷新。
            view.Refreshed += (o, e) =>
            {
                ddl.GetBindingExpression(ComboListControl.TextProperty).UpdateTarget();
            };

            return(ddl);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 如果存在查询和导航面板,则刷新查询和导航面板的下拉列表框数据
        /// </summary>
        /// <param name="view"></param>
        public override void Execute(ListLogicalView view)
        {
            view.DataLoader.ReloadDataAsync();

            //QueryLogicalView queryView = view.NavigateQueryView;
            //if (queryView == null) { queryView = view.CondtionQueryView; }

            ////刷新查询或导航面板的下拉列表框数据
            //if (queryView != null)
            //{
            //    queryView.TryExecuteQuery(view);

            //    foreach (var item in queryView.PropertyEditors)
            //    {
            //        if (item.PropertyViewInfo.EditorName == WPFEditorNames.LookupDropDown)
            //        {
            //            (item as LookupListPropertyEditor).DataSourse = null;
            //        }
            //    }
            //    queryView.AttachNewQueryObject();
            //}
            //else
            //{
            //    view.DataLoader.LoadDataAsync();
            //}
        }
Ejemplo n.º 5
0
        public override void Execute(ListLogicalView view)
        {
            var plan = LocateCurrentSummarizingMonth(view);

            if (plan == null)
            {
                App.MessageBox.Show("没有找到本月正在进行中的计划。", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                return;
            }

            var block = new Block(typeof(WeekSummary));

            var ui = AutoUI.AggtUIFactory.GenerateControl(block);

            var weekView = ui.MainView as ListLogicalView;

            MPHelper.ModifyRowStyle(weekView, "WeekSummaryRowStyle");

            SetData(weekView, plan);

            weekView.ExpandAll();

            var btn = App.Windows.ShowDialog(ui.Control, win =>
            {
                win.Title   = string.Format("第 {0} 周计划与总结", TimeHelper.CurrentWeekIndex + 1);
                win.Buttons = ViewDialogButtons.YesNo;
            });

            if (btn == WindowButton.Yes)
            {
                ReadData(weekView, plan);
            }
        }
Ejemplo n.º 6
0
        public override bool CanExecute(ListLogicalView view)
        {
            //当选择了出库仓库时,才可以选择出库商品
            var move = view.Parent.Current as StorageMove;

            return(move != null && move.StorageFromId != 0);
        }
Ejemplo n.º 7
0
        public override void Execute(ListLogicalView view)
        {
            var barcode = BarcodeTextBoxGenerator.GetTextBoxParameter(this);

            if (!string.IsNullOrEmpty(barcode))
            {
                var list = view.Data;
                var item = list.Cast <ProductRefItem>().FirstOrDefault(i => i.Product.Barcode == barcode);
                if (item != null)
                {
                    item.Amount++;
                }
                else
                {
                    var product = RF.ResolveInstance <ProductRepository>().GetByBarcode(barcode);
                    if (product == null)
                    {
                        App.MessageBox.Show(string.Format("没有找到对应 {0} 的商品".Translate(), barcode), MessageBoxImage.Error);
                        return;
                    }

                    item         = view.CreateNewItem().CastTo <ProductRefItem>();
                    item.Product = product;
                    item.Amount  = 1;
                    list.Add(item);
                    view.RefreshControl();
                }

                view.Current = item;
            }
        }
Ejemplo n.º 8
0
        public static ComboListControl CreateComboListControl(ListLogicalView view)
        {
            var titleProperty = view.Meta.TitleProperty;
            if (titleProperty == null) throw new InvalidProgramException(view.EntityType.Name + "类没有设置 Title 属性。");

            var ddl = new ComboListControl
            {
                InnerListView = view,
                Name = "下拉列表",
                VerticalAlignment = VerticalAlignment.Center,
                MinWidth = 150,
            };

            ddl.DataContext = view;
            ddl.SetBinding(ComboListControl.TextProperty, "CurrentObject." + titleProperty);

            //当 View 发生 Refreshed 事件时,很可能表示有底层数据改变了,但是没有级联通知到界面上,
            //所以当 View 的控件被 Refresh 后,这个下拉框也需要主动进行刷新。
            view.Refreshed += (o, e) =>
            {
                ddl.GetBindingExpression(ComboListControl.TextProperty).UpdateTarget();
            };

            return ddl;
        }
Ejemplo n.º 9
0
        public override void Execute(ListLogicalView view)
        {
            var category = view.Current as TaskOrCategory;

            if (category.IsTaskRO)
            {
                category = category.TreeParent as TaskOrCategory;
            }

            var task = view.CreateNewItem() as TaskOrCategory;

            var weeksCount = task.MonthPlan.WeeksCountRO;

            for (int i = 0; i < weeksCount; i++)
            {
                task.WeekCompletionList.Add(new WeekCompletion
                {
                    Index = i + 1
                });
            }

            task.WeightInCategory = 1;
            task.Score            = 0;
            task.ObjectiveNum     = 1;//放在添加 WeekCompletionList 之后

            category.TreeChildren.Add(task);

            view.RefreshControl();

            view.Current = task;

            CommandsHelper.EditCurrent(view);
        }
Ejemplo n.º 10
0
        public override bool CanExecute(ListLogicalView view)
        {
            if (base.CanExecute(view))
            {
                var node = view.Current;

                //找到这个实体所在层级的列表
                IList <Entity> context = null;
                if (node.TreeParent == null)
                {
                    context = view.Data;
                }
                else
                {
                    context = node.TreeParent.TreeChildren;
                }

                if (this.MoveUp)
                {
                    return(context[0] != node);
                }
                return(context.Last() != node);
            }

            return(false);
        }
Ejemplo n.º 11
0
 public override bool CanExecute(ListLogicalView view)
 {
     return(base.CanExecute(view) &&
            view.Current != null &&
            view.Current.IsTreeParentLoaded &&
            view.Current.TreeParent != null);
 }
Ejemplo n.º 12
0
        private void InitListView()
        {
            if (this._listView == null)
            {
                var rvm = this._refViewMeta;
                if (rvm == null)
                {
                    throw new InvalidProgramException("还没有设置控件的 RefViewMeta 或者 RefEntityType 属性。");
                }

                var title = rvm.TitleProperty;
                if (title == null)
                {
                    throw new InvalidProgramException(string.Format("{0} 没有设置代表属性,无法为其生成下拉控件。", rvm.Name));
                }
                this._textPath = title.Name;

                //创建一个只读的 ListLogicalView
                var listView = AutoUI.ViewFactory.CreateListView(rvm, true);
                listView.IsReadOnly = ReadOnlyStatus.ReadOnly;
                if (this.IsMultiSelection)
                {
                    listView.CheckingMode = CheckingMode.CheckingRow;
                }
                listView.CurrentChanged += (s, e) => this.OnListViewSelectionChanged();

                //构造Timer
                if (!DesignerProperties.GetIsInDesignMode(this))
                {
                    this.InitLazyFilter();
                }

                this._listView = listView;
            }
        }
Ejemplo n.º 13
0
        public override void Execute(ListLogicalView view)
        {
            //创建一个临时的拷贝数据
            var listEntity = view.Current;
            var tmp        = Entity.New(view.EntityType);

            tmp.Clone(listEntity);

            var evm = view.Meta;
            var res = PopupEditingDialog(evm, tmp, w =>
            {
                w.Title = this.Meta.Label.Translate() + " " + evm.Label.Translate();
            });

            if (res == WindowButton.Yes)
            {
                //修改按钮如果使用新的 Id,则它下面子对象的父外键都将是错误的值。
                listEntity.Clone(tmp, new CloneOptions(
                                     CloneActions.NormalProperties | CloneActions.RefEntities
                                     ));

                listEntity.MarkModifiedIfUnchanged();

                view.RefreshControl();
            }
        }
Ejemplo n.º 14
0
        protected override Entity AddSelection(ListLogicalView view, Entity src)
        {
            var e = base.AddSelection(view, src) as PurchaseOrderItem;

            e.RawPrice = (src as Product).CaiGouDanjia;

            return(e);
        }
Ejemplo n.º 15
0
        public override void Execute(ListLogicalView view)
        {
            var fa      = view.Current as FileAttachement;
            var tmpFile = Path.Combine(Path.GetTempPath(), fa.FileName);

            File.WriteAllBytes(tmpFile, fa.ContentBytes);
            Process.Start(tmpFile);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 为被选择的对象添加一个引用实体属性值
        /// </summary>
        /// <param name="view"></param>
        /// <param name="selected"></param>
        /// <returns></returns>
        protected virtual Entity AddSelection(ListLogicalView view, Entity selected)
        {
            //把选中对象赋值到新增对象的引用属性上
            var newEntity = view.AddNew(false);

            newEntity.SetRefEntity(this.RefProperty.RefEntityProperty, selected);
            return(newEntity);
        }
Ejemplo n.º 17
0
        public override void Execute(ListLogicalView view)
        {
            var language = view.Current as Language;

            AsyncAction.Execute(() =>
            {
                TranslateByEngine(language);
            });
        }
Ejemplo n.º 18
0
        public override void Execute(ListLogicalView view)
        {
            TreeGrid tv = view.Control;

            if (tv != null)
            {
                tv.ExpandAll();
            }
        }
Ejemplo n.º 19
0
        public override void Execute(ListLogicalView view)
        {
            var tv = view.Control;

            foreach (var root in tv.RootItemsControl.ItemsSource)
            {
                tv.ExpandToDepth(root, this.Depth);
            }
        }
Ejemplo n.º 20
0
        public override void Execute(ListLogicalView view)
        {
            var plan = view.Current as MonthPlan;

            plan.PlanStatus = Status;
            RF.Save(plan);

            App.MessageBox.Show("状态设置成功。");
        }
Ejemplo n.º 21
0
        public override bool CanExecute(ListLogicalView view)
        {
            if (base.CanExecute(view))
            {
                var previous = FindPreviousNode(view.Current);
                return(previous != null);
            }

            return(false);
        }
Ejemplo n.º 22
0
        public override void Execute(ListLogicalView view)
        {
            var current  = view.Current;
            var previous = FindPreviousNode(current);

            current.TreeParent = previous;

            view.RefreshControl();
            view.Current = current;
        }
Ejemplo n.º 23
0
        protected override Entity AddSelection(ListLogicalView view, Entity selected)
        {
            var result = base.AddSelection(view, selected);

            this._firstSelection = this._firstSelection ?? result;

            (result as ProductRefItem).Amount = 1;

            return(result);
        }
Ejemplo n.º 24
0
        public override void Execute(ListLogicalView view)
        {
            //关于是放在 MP VersionLog 中的。
            var resource = Application.GetResourceStream(new Uri("/MonthPlan;component/_Other/MP VersionLog.txt", UriKind.RelativeOrAbsolute));

            using (var reader = new StreamReader(resource.Stream))
            {
                var content = reader.ReadToEnd();
                App.MessageBox.Show(content, "关于", MessageBoxButton.OK, MessageBoxImage.Asterisk);
            }
        }
Ejemplo n.º 25
0
        public override void Execute(ListLogicalView view)
        {
            DbTranslator.Instance.AutoSave();

            if (view.Data == null || !view.Data.IsDirty)
            {
                view.DataLoader.LoadDataAsync();
            }

            App.MessageBox.Show("更新完成。".Translate());
        }
Ejemplo n.º 26
0
 private static void ReadData(ListLogicalView weekView, MonthPlan plan)
 {
     foreach (WeekSummary week in weekView.Data)
     {
         if (week.IsTask)
         {
             var completion = week.WeekCompletion;
             completion.NumCompleted = week.NumCompleted;
             completion.Note         = week.WeekSummaryNote;
         }
     }
 }
Ejemplo n.º 27
0
        public override void Execute(ListLogicalView view)
        {
            var dg = new OpenFileDialog();

            if (dg.ShowDialog() == true)
            {
                var fileName    = dg.FileName;
                var attachement = view.AddNew(true) as FileAttachement;
                attachement.FileName     = Path.GetFileName(fileName);
                attachement.UploadDate   = DateTime.Today;
                attachement.ContentBytes = File.ReadAllBytes(fileName);
            }
        }
Ejemplo n.º 28
0
 public override void Execute(ListLogicalView view)
 {
     if (view.Filter != null)
     {
         view.Filter = null;
         this.Label  = this.Meta.Label;
     }
     else
     {
         view.Filter = this.CanShow;
         this.Label  = "显示全部";
     }
 }
Ejemplo n.º 29
0
        public override void Execute(ListLogicalView view)
        {
            var plan = view.Current as MonthPlan;
            var btn  = App.MessageBox.Show(string.Format("目前得分:{0},提交总结后不可再修改总结及得分,是否继续?", plan.FinalScore), MessageBoxButton.YesNo);

            if (btn == MessageBoxResult.Yes)
            {
                plan.CompleteTime = DateTime.Now;
                plan.PlanStatus   = MonthPlanStatus.Completed;
                RF.Save(plan);

                App.MessageBox.Show("计划总结已完成,状态锁定!");
            }
        }
Ejemplo n.º 30
0
        public override bool CanExecute(ListLogicalView view)
        {
            if (!this._initialized)
            {
                this._view        = view;
                view.DataChanged += this.OnDataChanged;

                //默认处于展开状态。
                this.SetExpanded(true);

                this._initialized = true;
            }

            return(view.Data != null && view.Data.Count > 0);
        }
Ejemplo n.º 31
0
        public override void Execute(ListLogicalView view)
        {
            var category = view.CreateNewItem() as TaskOrCategory;

            category.MonthPercent = 0;
            category.MonthScore   = 0;

            view.Data.Add(category);

            view.RefreshControl();

            view.Current = category;

            CommandsHelper.EditCurrent(view);
        }
Ejemplo n.º 32
0
        protected override FrameworkElement CreateEditingElement()
        {
            var refInfo = this.Meta.SelectionViewMeta;

            var listView = AutoUI.ViewFactory.CreateListView(refInfo.RefTypeDefaultView.AsWPFView(), true);
            this.ListView = listView;

            listView.IsReadOnly = ReadOnlyStatus.ReadOnly;
            this.RefreshDataSource();
            listView.CurrentChanged += (o, e) =>
            {
                this.SyncSelectionToValue(listView.SelectedEntities);
            };

            return listView.Control;
        }
Ejemplo n.º 33
0
        public void Arrange(UIComponents components)
        {
            //使用下拉框显示主区域。
            var control = components.Main;
            if (control != null)
            {
                this._mainView = control.MainView as ListLogicalView;
                this._mainView.Control.RemoveFromParent();

                ////选中数据的第一行。
                ////由于模板都会自动获取数据,而UI线程一直在构造界面,所以这里直接监听数据到达函数就可以了。
                //view.DataLoader.ListenDataChangedOnce(() =>
                //{
                //    if (view.Data.Count > 0)
                //    {
                //        view.CurrentObject = view.Data[0] as Entity;
                //    }
                //});

                var cmbList = ControlHelper.CreateComboListControl(this._mainView);
                AutomationHelper.SetEditingElement(cmbList);

                main.Content = cmbList;
            }
            else
            {
                main.RemoveFromParent();
            }

            var toolBar = components.CommandsContainer;
            if (toolBar != null)
            {
                toolBarContainer.Content = toolBar.Control;
            }
            else
            {
                toolBarContainer.RemoveFromParent();
            }

            //Children
            components.ArrangeChildrenByTabControl(childrenTab);
        }
Ejemplo n.º 34
0
        /// <summary>
        /// 根据当前的值(PropertyValue),找到并定位到当前对象
        /// </summary>
        protected void SyncValueToSelection(ListLogicalView listView)
        {
            if (listView == null) throw new ArgumentNullException("listView");

            var items = listView.Data;
            if (items == null || items.Count == 0) return;

            //找到值对应的数据项
            var selectedItems = new List<Entity>();
            if (this.Context.CurrentObject != null && this.Meta != null)
            {
                //根据设置的 SelectedValuePath 来对比属性值 this.PropertyValue,如果相同,则找到对应的CurrentObject
                var targetValue = this.PropertyValue;
                if (this.IsMultiSelection && targetValue != null)
                {
                    var splitter = this.Meta.SelectionViewMeta.SplitterIfMulti;
                    var values = targetValue.ToString().Split(
                        new string[] { splitter }, StringSplitOptions.RemoveEmptyEntries
                        );
                    foreach (var selectedValue in values)
                    {
                        AddToListBySelectedValue(items, selectedItems, selectedValue);
                    }
                }
                else
                {
                    AddToListBySelectedValue(items, selectedItems, targetValue);
                }
            }

            //定位 SelectedObjects
            var selectedObjects = listView.SelectedEntities;
            selectedObjects.Clear();
            foreach (var item in selectedItems) { selectedObjects.Add(item); }
        }
Ejemplo n.º 35
0
        public override void Execute(ListLogicalView view)
        {
            var txt = TextBoxButtonItemGenerator.GetTextBoxParameter(this);

            if (string.IsNullOrEmpty(txt))
            {
                view.Filter = null;
            }
            else
            {
                var titleManagedProperty = view.Meta.TitleProperty.PropertyMeta.ManagedProperty;
                view.Filter = e =>
                {
                    var title = e.GetProperty(titleManagedProperty) as string;
                    return title.Contains(txt);
                };
            }
        }
Ejemplo n.º 36
0
 public override void Execute(ListLogicalView view)
 {
     view.Current = null;
 }