Beispiel #1
0
        public Editor(EditorItemFactory factory)
        {
            EntityEditorViewModel <TEntity> viewModel = new EntityEditorViewModel <TEntity>(BussinessApplication.Current.ContextBuilder.GetContext <TEntity>());

            viewModel.Item = Activator.CreateInstance <TEntity>();
            viewModel.Item.OnCreateCompleted();
            Initialize(viewModel, factory);
        }
 public TimelineMarkerGUI(TimelineMarker theMarker, TimelineAsset timeline, TimelineTrackGUI parent) : base(parent)
 {
     this.m_EditorItem = EditorItemFactory.GetEditorMarker(theMarker);
     if (parent.drawer != null)
     {
         parent.drawer.ConfigureUIEvent(this);
     }
 }
Beispiel #3
0
        public TimelineClipGUI(TimelineClip clip, TimelineTrackGUI parent) : base(parent)
        {
            this.m_EditorItem  = EditorItemFactory.GetEditorClip(clip);
            clip.dirtyHash     = 0;
            this.supportResize = true;
            if (parent.drawer != null)
            {
                parent.drawer.ConfigureUIClip(this);
            }
            DragClipHandle clipHandleManipulator = (!clip.SupportsClipIn()) ? new SimpleDragClipHandle() : new DragClipHandle();

            this.m_LeftHandle     = new TimelineClipHandle(this, TimelineClipHandle.DragDirection.Left, clipHandleManipulator);
            this.m_RightHandle    = new TimelineClipHandle(this, TimelineClipHandle.DragDirection.Right, clipHandleManipulator);
            this.m_BlendInHandle  = new TimelineBlendHandle(this, TimelineBlendHandle.DragDirection.Left);
            this.m_BlendOutHandle = new TimelineBlendHandle(this, TimelineBlendHandle.DragDirection.Right);
            base.AddChild(this.m_LeftHandle);
            base.AddChild(this.m_RightHandle);
            base.AddChild(this.m_BlendInHandle);
            base.AddChild(this.m_BlendOutHandle);
            TimelineItemGUI.s_ItemToItemGUI[clip] = this;
        }
Beispiel #4
0
        private void Initialize(EntityEditorViewModel <TEntity> viewModel, EditorItemFactory factory)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException("viewModel");
            }

            ViewModel = viewModel;
            Type type = typeof(TEntity);

            Grid grid = new Grid();

            grid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(100, GridUnitType.Star)
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(100, GridUnitType.Pixel)
            });
            ParentAttribute parent = type.GetCustomAttributes(typeof(ParentAttribute), true).FirstOrDefault() as ParentAttribute;

            Grid dataGrid = new Grid();

            dataGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(200, GridUnitType.Pixel)
            });
            dataGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            Items = new List <EditorItem>();
            foreach (var property in viewModel.ViewBuilder.EditableProperties)
            {
                dataGrid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Auto), MinHeight = 32
                });
                var name = new Label();
                name.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                name.VerticalAlignment   = System.Windows.VerticalAlignment.Center;
                name.Margin = new Thickness(4);
                var display = type.GetProperty(property).GetCustomAttributes(typeof(DisplayAttribute), false).FirstOrDefault() as DisplayAttribute;
                if (display == null)
                {
                    name.Content = property;
                }
                else
                {
                    name.Content = display.Name;
                    name.ToolTip = display.Description;
                }
                Grid.SetRow(name, dataGrid.RowDefinitions.Count - 1);
                dataGrid.Children.Add(name);

                EditorItem editor = factory.GetEditorItem(type.GetProperty(property));
                editor.Title = (string)name.Content;
                editor.Tag   = type.GetProperty(property);
                editor.Value = type.GetProperty(property).GetValue(viewModel.Item, null);
                Items.Add(editor);
                editor.Margin      = new Thickness(4);
                editor.Initialized = true;
                Grid.SetRow(editor, dataGrid.RowDefinitions.Count - 1);
                Grid.SetColumn(editor, 1);
                dataGrid.Children.Add(editor);
            }

            ScrollViewer scroll = new ScrollViewer();

            scroll.VerticalScrollBarVisibility   = ScrollBarVisibility.Auto;
            scroll.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
            scroll.PanningMode = PanningMode.VerticalOnly;
            scroll.Content     = dataGrid;
            grid.Children.Add(scroll);

            AppButtonPanel appButtonPanel = new AppButtonPanel();

            Grid.SetRow(appButtonPanel, 1);
            grid.Children.Add(appButtonPanel);

            AppButton ok = new AppButton(new CustomCommand(null, Ok));

            ok.Text  = "确定";
            ok.Image = (Canvas)Resources["appbar_check"];
            appButtonPanel.Items.Add(ok);

            AppButton cancel = new AppButton(new CustomCommand(null, Cancel));

            cancel.Text  = "取消";
            cancel.Image = (Canvas)Resources["appbar_close"];
            appButtonPanel.Items.Add(cancel);

            Content = grid;
        }
Beispiel #5
0
 public Editor(EntityEditorViewModel <TEntity> viewModel, EditorItemFactory factory)
 {
     Initialize(viewModel, factory);
 }