protected override void OnInitialized()
        {
            base.OnInitialized();
            element            = ExtendedItem.Component as FrameworkElement;
            editor             = new InPlaceEditor(ExtendedItem);
            editor.DataContext = element;
            editor.Visibility  = Visibility.Hidden;            // Hide the editor first, It's visibility is governed by mouse events.

            placement = new RelativePlacement(HorizontalAlignment.Left, VerticalAlignment.Top);
            adornerPanel.Children.Add(editor);
            Adorners.Add(adornerPanel);

            designPanel = ExtendedItem.Services.GetService <IDesignPanel>() as DesignPanel;
            Debug.Assert(designPanel != null);

            /* Add mouse event handlers */
            designPanel.PreviewMouseLeftButtonDown += MouseDown;
            designPanel.MouseLeftButtonUp          += MouseUp;
            designPanel.PreviewMouseMove           += MouseMove;

            /* To update the position of Editor in case of resize operation */
            ExtendedItem.PropertyChanged += PropertyChanged;

            eventsAdded = true;
        }
 /// <summary>
 /// Cancels editing the cell being edited, if any.
 /// </summary>
 internal void CancelEdit()
 {
     if (InPlaceEditor != null)
     {
         InPlaceEditor.CancelEdit();
     }
 }
 private static RowBinding <InPlaceEditor> MergeIntoInPlaceEditor <TEditing, TInert>(this RowInput <TEditing> rowInput, RowBinding <TInert> inertRowBinding)
     where TEditing : UIElement, new()
     where TInert : UIElement, new()
 {
     Debug.Assert(rowInput != null);
     Debug.Assert(inertRowBinding != null);
     return(InPlaceEditor.AddToInPlaceEditor(rowInput, inertRowBinding));
 }
 private static ScalarBinding <InPlaceEditor> MergeIntoInPlaceEditor <TEditing, TInert>(this ScalarInput <TEditing> scalarInput, ScalarBinding <TInert> inertScalarBinding)
     where TEditing : UIElement, new()
     where TInert : UIElement, new()
 {
     Debug.Assert(scalarInput != null);
     Debug.Assert(inertScalarBinding != null);
     return(InPlaceEditor.AddToInPlaceEditor(scalarInput, inertScalarBinding));
 }
            /// <inheritdoc/>
            public override bool ShouldEditTableColumn(NSTableView tableView, NSTableColumn tableColumn, nint row)
            {
                var programDescription = Programs.ArrangedObjects()[row] as ProgramDescriptionViewModel;
                var canEdit            = RomListCommandGroup.EditProgramNameCommand.CanExecute(ViewModel);

                if (canEdit)
                {
                    string initialValue = null;
                    var    column       = (RomListColumn)tableView.TableColumns().ToList().IndexOf(tableColumn);
                    int    maxLength    = -1;
                    System.Predicate <char> isValidCharacter = null;
                    switch (column)
                    {
                    case RomListColumn.Title:
                        canEdit      = true;
                        initialValue = programDescription.Name;
                        maxLength    = ProgramDescription.MaxProgramNameLength;
                        break;

                    case RomListColumn.Vendor:
                        canEdit      = true;
                        initialValue = programDescription.Vendor;
                        maxLength    = ProgramDescription.MaxVendorNameLength;
                        break;

                    case RomListColumn.Year:
                        canEdit          = true;
                        initialValue     = programDescription.Year;
                        maxLength        = ProgramDescription.MaxYearTextLength;
                        isValidCharacter = (c) => char.IsDigit(c);
                        break;

                    default:
                        break;
                    }
                    if (canEdit)
                    {
                        if (InPlaceEditor == null)
                        {
                            InPlaceEditor = new TextCellInPlaceEditor(tableView);
                        }
                        InPlaceEditor.EditingObject    = programDescription;
                        InPlaceEditor.InitialValue     = initialValue;
                        InPlaceEditor.MaxLength        = maxLength;
                        InPlaceEditor.IsValidCharacter = isValidCharacter;
                        InPlaceEditor.EditorClosed    += InPlaceEditor_EditorClosed;
                        InPlaceEditor.BeginEdit();
                    }
                }
                else if ((SingleInstanceApplication.Current.LastKeyPressed == 0x24) && (SingleInstanceApplication.Current.LastKeyPressedTimestamp != ReturnKeyTimestamp))
                {
                    // return was pressed
                    ReturnKeyTimestamp = SingleInstanceApplication.Current.LastKeyPressedTimestamp;
                    DebugItemChange(programDescription.Name);
                    ViewModel.Model.InvokeProgramFromDescription(programDescription.Model);
                }
                return(canEdit);
            }
Esempio n. 6
0
        void InPlaceEditor_LabelEditingCompleted(object sender, LabelEditingCompletedEventArgs evtArgs)
        {
            InPlaceEditor label = new InPlaceEditor(diagram1.Controller);
            PathNode      node  = evtArgs.NodeAffected as PathNode;

            if (node.Labels[0].FontStyle.Size > 24)
            {
                node.Labels[0].FontStyle.Size = 24;
                MessageBox.Show("Please set Font size less than 24 for clear view");
            }
        }
 IEnumerable <CommandEntry> InPlaceEditor.ICommandService.GetCommandEntries(InPlaceEditor inPlaceEditor)
 {
     yield return(RowView.Commands.BeginEdit.Bind(BeginEdit, CanBeginEdit, new MouseGesture(MouseAction.LeftClick)));
 }
            /// <inheritdoc />
            public override bool ShouldEditTableColumn(NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item)
            {
                DebugDelegatePrint("***************** SHOULD EDIT CALLED");
                var canEdit = MenuLayoutCommandGroup.EditLongNameCommand.CanExecute(ViewModel.HostPCMenuLayout);

                if (canEdit)
                {
                    var treeNode = item as NSTreeNode;
                    EditingColumn = (EditableOutlineViewColumn)outlineView.TableColumns().ToList().IndexOf(tableColumn);
                    var    editingObject = treeNode.RepresentedObject as FileNodeViewModel;
                    string initialValue  = null;
                    int    maxLength     = -1;
                    switch (EditingColumn)
                    {
                    case EditableOutlineViewColumn.LongName:
                        canEdit      = true;
                        initialValue = editingObject.LongName;
                        maxLength    = INTV.LtoFlash.Model.FileSystemConstants.MaxLongNameLength;
                        break;

                    case EditableOutlineViewColumn.ShortName:
                        canEdit      = true;
                        initialValue = editingObject.ShortName;
                        maxLength    = INTV.LtoFlash.Model.FileSystemConstants.MaxShortNameLength;
                        break;

                    default:
                        ErrorReporting.ReportError("Unsupported edit column");
                        break;
                    }
                    if (InPlaceEditor == null)
                    {
                        InPlaceEditor = new TextCellInPlaceEditor(outlineView);
                    }
                    InPlaceEditor.EditingObject    = editingObject;
                    InPlaceEditor.InitialValue     = initialValue;
                    InPlaceEditor.MaxLength        = maxLength;
                    InPlaceEditor.IsValidCharacter = (c) => INTV.Core.Model.Grom.Characters.Contains(c);
                    InPlaceEditor.EditorClosed    += InPlaceEditor_EditorClosed;
                    InPlaceEditor.BeginEdit();
                }
                else if ((SingleInstanceApplication.Current.LastKeyPressed == TextCellInPlaceEditor.ReturnKey) && (SingleInstanceApplication.Current.LastKeyPressedTimestamp != ReturnKeyTimestamp))
                {
                    // return was pressed -- do we need to check for <enter> vs. <return> (on laptops, Fn+return)?
                    ReturnKeyTimestamp = SingleInstanceApplication.Current.LastKeyPressedTimestamp;
                    if (!outlineView.IsExpandable(item) && DownloadCommandGroup.DownloadAndPlayCommand.CanExecute(ViewModel))
                    {
                        var program = ViewModel.HostPCMenuLayout.CurrentSelection as ProgramViewModel;
                        if ((program != null) && DownloadCommandGroup.DownloadAndPlayCommand.CanExecute(ViewModel))
                        {
                            DownloadCommandGroup.DownloadAndPlay(ViewModel.ActiveLtoFlashDevice.Device, program.ProgramDescription);
                        }
                    }
                    else
                    {
                        // On a directory. If so, toggle state.
                        if (outlineView.IsItemExpanded(item))
                        {
                            outlineView.CollapseItem(item);
                        }
                        else
                        {
                            outlineView.ExpandItem(item);
                        }
                    }
                }
                return(canEdit);
            }