/// 
 public ContentElementAutomationPeer(ContentElement owner)
 { 
     if (owner == null) 
     {
         throw new ArgumentNullException("owner"); 
     }
     _owner = owner;
 }
 /// 
 public static AutomationPeer FromElement(ContentElement element)
 { 
     if (element == null)
     {
         throw new ArgumentNullException("element");
     } 
     return element.GetAutomationPeer();
 } 
 ///<summary>
 /// This static helper creates an AutomationPeer for the specified element and 
 /// caches it - that means the created peer is going to live long and shadow the 
 /// element for its lifetime. The peer will be used by Automation to proxy the element, and
 /// to fire events to the Automation when something happens with the element. 
 /// The created peer is returned from this method and also from subsequent calls to this method
 /// and <seealso cref="FromElement"/>. The type of the peer is determined by the
 /// <seealso cref="UIElement.OnCreateAutomationPeer"/> virtual callback. If FrameworkContentElement does not
 /// implement the callback, there will be no peer and this method will return 'null' (in other 
 /// words, there is no such thing as a 'default peer').
 ///</summary> 
 public static AutomationPeer CreatePeerForElement(ContentElement element) 
 {
     if (element == null) 
     {
         throw new ArgumentNullException("element");
     }
     return element.CreateAutomationPeer(); 
 }
Esempio n. 4
0
 /// <summary>
 /// Get the Visual parent of this ContentElement.
 /// </summary>
 public static DependencyObject GetParent(ContentElement reference)
 {
     if(reference == null)
     {
         throw new ArgumentNullException("reference");
     }
     
     return reference._parent;
 }
Esempio n. 5
0
        /// <summary>
        /// Set the Visual parent of this ContentElement.
        /// </summary>
        /// <remarks>
        ///     This is different than Visuals.  For Visuals, you have to
        ///     Add/Remove the visual from a children collection to change
        ///     the parent.  I think it is a better model, but I don't
        ///     know if we want to expose a full children collection for
        ///     content elements.
        /// </remarks>
        public static void SetParent(ContentElement reference, DependencyObject parent)
        {
            if(reference == null)
            {
                throw new ArgumentNullException("reference");
            }

            DependencyObject oldParent = reference._parent;
            reference._parent = parent;

            // Raise content parent changed notification
            reference.OnContentParentChanged(oldParent);
        }
 /// <summary>
 /// Returns the rectangles that are 'hot spots' for the specified element.
 /// </summary> 
 public ReadOnlyCollection<Rect> GetRectangles(ContentElement child)
 { 
     if (_basePage != null) 
     {
         return _basePage.GetRectangles(child); 
     }
     else
     {
         return new ReadOnlyCollection<Rect>(new List<Rect>(0)); 
     }
 } 
Esempio n. 7
0
        private static void FindCommandBinding(object sender, RoutedEventArgs e, ICommand command, bool execute)
        {
            // Check local command bindings
            CommandBindingCollection commandBindings = sender switch
            {
                UIElement uiElement => uiElement.CommandBindingsInternal,
                ContentElement contentElement => contentElement.CommandBindingsInternal,
                UIElement3D uiElement3d => uiElement3d.CommandBindingsInternal,
                                     _ => default
            };

            if (commandBindings is not null)
            {
                FindCommandBinding(commandBindings, sender, e, command, execute);
            }

            Type senderType = sender.GetType();

            // If no command binding is found, check class command bindings
            // First find the relevant command bindings, under the lock.
            // Most of the time there are no such bindings;  most of the rest of
            // the time there is only one.   Lazy-allocate with this in mind.
            ValueTuple <Type, CommandBinding>?        tuple = default; // zero or one binding
            List <ValueTuple <Type, CommandBinding> > list  = default; // more than one

            lock (_classCommandBindings.SyncRoot)
            {
                // Check from the current type to all the base types
                Type classType = senderType;
                while (classType is not null)
                {
                    if (_classCommandBindings[classType] is CommandBindingCollection classCommandBindings)
                    {
                        int index = 0;
                        while (true)
                        {
                            CommandBinding commandBinding = classCommandBindings.FindMatch(command, ref index);
                            if (commandBinding is null)
                            {
                                break;
                            }

                            if (tuple is null)
                            {
                                tuple = ValueTuple.Create(classType, commandBinding);
                            }
                            else
                            {
                                list ??= new List <ValueTuple <Type, CommandBinding> >(8)
                                {
                                    // We know that tuple cannot be null here
                                    tuple.Value
                                };
                                list.Add(new ValueTuple <Type, CommandBinding>(classType, commandBinding));
                            }
                        }
                    }
                    classType = classType.BaseType;
                }
            }

            // execute the bindings.  This can call into user code, so it must
            // be done outside the lock to avoid deadlock.
            if (list is not null)
            {
                // more than one binding
                ExecutedRoutedEventArgs exArgs = execute ? (ExecutedRoutedEventArgs)e : default;

                CanExecuteRoutedEventArgs canExArgs = execute ? default : (CanExecuteRoutedEventArgs)e;
                                                      for (int i = 0; i < list.Count; ++i)
                                                      {
                                                          // invoke the binding
                                                          if ((!execute || !ExecuteCommandBinding(sender, exArgs, list[i].Item2)) &&
                                                              (execute || !CanExecuteCommandBinding(sender, canExArgs, list[i].Item2)))
                                                          {
                                                              continue;
                                                          }
                                                          // if it succeeds, advance past the remaining bindings for this type
                                                          Type classType = list[i].Item1;
                                                          while (++i < list.Count && list[i].Item1 == classType)
                                                          {
                                                              // no body needed
                                                          }
                                                          --i; // back up, so that the outer for-loop advances to the right place
                                                      }
            }
            else if (tuple is var(_, commandBinding))
            {
                // only one binding
                if (execute)
                {
                    ExecuteCommandBinding(sender, (ExecutedRoutedEventArgs)e, commandBinding);
                }
                else
                {
                    CanExecuteCommandBinding(sender, (CanExecuteRoutedEventArgs)e, commandBinding);
                }
            }
        }
Esempio n. 8
0
        private bool ProcessStagingArea()
        {
            bool handled = false;

            // For performance reasons, try to reuse the input event args.
            // If we are reentrered, we have to start over with fresh event
            // args, so we clear the member variables before continuing.
            // Also, we cannot simply make an single instance of the
            // PreProcessedInputEventArgs and cast it to NotifyInputEventArgs
            // or ProcessInputEventArgs because a malicious user could upcast
            // the object and call inappropriate methods.
            NotifyInputEventArgs     notifyInputEventArgs     = (_notifyInputEventArgs != null) ? _notifyInputEventArgs : new NotifyInputEventArgs();
            ProcessInputEventArgs    processInputEventArgs    = (_processInputEventArgs != null) ? _processInputEventArgs : new ProcessInputEventArgs();
            PreProcessInputEventArgs preProcessInputEventArgs = (_preProcessInputEventArgs != null) ? _preProcessInputEventArgs : new PreProcessInputEventArgs();

            _notifyInputEventArgs     = null;
            _processInputEventArgs    = null;
            _preProcessInputEventArgs = null;

            // Because we can be reentered, we can't just enumerate over the
            // staging area - that could throw an exception if the queue
            // changes underneath us.  Instead, just loop until we find a
            // frame marker or until the staging area is empty.
            StagingAreaInputItem item = null;

            while ((item = PopInput()) != null)
            {
                // If we found a marker, we have reached the end of a
                // "section" of the staging area.  We just return from
                // the synchronous processing of the staging area.
                // If a dispatcher frame has been pushed by someone, this
                // will not return to the original ProcessInput.  Instead
                // it will unwind to the dispatcher and since we have
                // already pushed a work item to continue processing the
                // input, it will simply call back into us to do more
                // processing.  At which point we will continue to drain
                // the staging area.  This could cause strage behavior,
                // but it is deemed more acceptable than stalling input
                // processing.

                // In the future, in ordre to
                // make sure we all agree on this.  We could also
                // just delay the rest of the staging area until
                // the dispatcher frame finishes.  Unfortunately,
                // this means one could receive an input event for
                // something that happened a long time ago.
                if (item.IsMarker)
                {
                    break;
                }

                // Pre-Process the input.  This could modify the staging
                // area, and it could cancel the processing of this
                // input event.
                //
                // Because we use multi-cast delegates, we always have to
                // create a new multi-cast delegate when we add or remove
                // a handler.  This means we can just call the current
                // multi-cast delegate instance, and it is safe to iterate
                // over, even if we get reentered.
                if (_preProcessInput != null)
                {
                    preProcessInputEventArgs.Reset(item, this);

                    // Invoke the handlers in reverse order so that handlers that
                    // users add are invoked before handlers in the system.
                    Delegate[] handlers = _preProcessInput.GetInvocationList();
                    for (int i = (handlers.Length - 1); i >= 0; i--)
                    {
                        PreProcessInputEventHandler handler = (PreProcessInputEventHandler)handlers[i];
                        handler(this, preProcessInputEventArgs);
                    }
                }

                if (!preProcessInputEventArgs.Canceled)
                {
                    // Pre-Notify the input.
                    //
                    // Because we use multi-cast delegates, we always have to
                    // create a new multi-cast delegate when we add or remove
                    // a handler.  This means we can just call the current
                    // multi-cast delegate instance, and it is safe to iterate
                    // over, even if we get reentered.
                    if (_preNotifyInput != null)
                    {
                        notifyInputEventArgs.Reset(item, this);

                        // Invoke the handlers in reverse order so that handlers that
                        // users add are invoked before handlers in the system.
                        Delegate[] handlers = _preNotifyInput.GetInvocationList();
                        for (int i = (handlers.Length - 1); i >= 0; i--)
                        {
                            NotifyInputEventHandler handler = (NotifyInputEventHandler)handlers[i];
                            handler(this, notifyInputEventArgs);
                        }
                    }

                    // Raise the input event being processed.
                    InputEventArgs input = item.Input;

                    // Some input events are explicitly associated with
                    // an element.  Those that are not are associated with
                    // the target of the input device for this event.
                    DependencyObject eventSource = input.Source as DependencyObject;
                    if (eventSource == null || !InputElement.IsValid(eventSource as IInputElement))
                    {
                        if (input.Device != null)
                        {
                            eventSource = input.Device.Target as DependencyObject;
                        }
                    }

                    // During synchronized input processing, event should be discarded if not listening for this input type.
                    if (_isSynchronizedInput &&
                        SynchronizedInputHelper.IsMappedEvent(input) &&
                        Array.IndexOf(SynchronizedInputEvents, input.RoutedEvent) < 0 &&
                        Array.IndexOf(PairedSynchronizedInputEvents, input.RoutedEvent) < 0)
                    {
                        if (!SynchronizedInputHelper.ShouldContinueListening(input))
                        {
                            // Discard the event
                            _synchronizedInputState = SynchronizedInputStates.Discarded;
                            SynchronizedInputHelper.RaiseAutomationEvents();
                            CancelSynchronizedInput();
                        }
                        else
                        {
                            _synchronizedInputAsyncClearOperation = Dispatcher.BeginInvoke((Action) delegate
                            {
                                // Discard the event
                                _synchronizedInputState = SynchronizedInputStates.Discarded;
                                SynchronizedInputHelper.RaiseAutomationEvents();
                                CancelSynchronizedInput();
                            },
                                                                                           DispatcherPriority.Background);
                        }
                    }
                    else
                    {
                        if (eventSource != null)
                        {
                            if (InputElement.IsUIElement(eventSource))
                            {
                                UIElement e = (UIElement)eventSource;

                                e.RaiseEvent(input, true); // Call the "trusted" flavor of RaiseEvent.
                            }
                            else if (InputElement.IsContentElement(eventSource))
                            {
                                ContentElement ce = (ContentElement)eventSource;

                                ce.RaiseEvent(input, true);// Call the "trusted" flavor of RaiseEvent.
                            }
                            else if (InputElement.IsUIElement3D(eventSource))
                            {
                                UIElement3D e3D = (UIElement3D)eventSource;

                                e3D.RaiseEvent(input, true); // Call the "trusted" flavor of RaiseEvent
                            }

                            // If synchronized input raise appropriate automation event.

                            if (_isSynchronizedInput && SynchronizedInputHelper.IsListening(_listeningElement, input))
                            {
                                if (!SynchronizedInputHelper.ShouldContinueListening(input))
                                {
                                    SynchronizedInputHelper.RaiseAutomationEvents();
                                    CancelSynchronizedInput();
                                }
                                else
                                {
                                    _synchronizedInputAsyncClearOperation = Dispatcher.BeginInvoke((Action) delegate
                                    {
                                        SynchronizedInputHelper.RaiseAutomationEvents();
                                        CancelSynchronizedInput();
                                    },
                                                                                                   DispatcherPriority.Background);
                                }
                            }
                        }
                    }

                    // Post-Notify the input.
                    //
                    // Because we use multi-cast delegates, we always have to
                    // create a new multi-cast delegate when we add or remove
                    // a handler.  This means we can just call the current
                    // multi-cast delegate instance, and it is safe to iterate
                    // over, even if we get reentered.
                    if (_postNotifyInput != null)
                    {
                        notifyInputEventArgs.Reset(item, this);

                        // Invoke the handlers in reverse order so that handlers that
                        // users add are invoked before handlers in the system.
                        Delegate[] handlers = _postNotifyInput.GetInvocationList();
                        for (int i = (handlers.Length - 1); i >= 0; i--)
                        {
                            NotifyInputEventHandler handler = (NotifyInputEventHandler)handlers[i];
                            handler(this, notifyInputEventArgs);
                        }
                    }

                    // Post-Process the input.  This could modify the staging
                    // area.
                    //
                    // Because we use multi-cast delegates, we always have to
                    // create a new multi-cast delegate when we add or remove
                    // a handler.  This means we can just call the current
                    // multi-cast delegate instance, and it is safe to iterate
                    // over, even if we get reentered.
                    if (_postProcessInput != null)
                    {
                        processInputEventArgs.Reset(item, this);

                        RaiseProcessInputEventHandlers(_postProcessInput, processInputEventArgs);

                        // PreviewInputReport --> InputReport
                        if (item.Input.RoutedEvent == InputManager.PreviewInputReportEvent)
                        {
                            if (!item.Input.Handled)
                            {
                                InputReportEventArgs previewInputReport = (InputReportEventArgs)item.Input;

                                InputReportEventArgs inputReport = new InputReportEventArgs(previewInputReport.Device, previewInputReport.Report);
                                inputReport.RoutedEvent = InputManager.InputReportEvent;
                                PushInput(inputReport, item);
                            }
                        }
                    }

                    if (input.Handled)
                    {
                        handled = true;
                    }
                }
            }

            // Store our input event args so that we can use them again, and
            // avoid having to allocate more.
            _notifyInputEventArgs     = notifyInputEventArgs;
            _processInputEventArgs    = processInputEventArgs;
            _preProcessInputEventArgs = preProcessInputEventArgs;

            // Make sure to throw away the contents of the event args so
            // we don't keep refs around to things we don't mean to.
            _notifyInputEventArgs.Reset(null, null);
            _processInputEventArgs.Reset(null, null);
            _preProcessInputEventArgs.Reset(null, null);

            return(handled);
        }
Esempio n. 9
0
 /// <summary>
 /// Focuses the first control on the ContentElement.
 /// </summary>
 /// <param name="element">Reference to the current <see cref="ContentElement"/>.</param>
 /// <param name="focusParentsFirst">if set to <c>true</c>, the parents are focused first.</param>
 public static void FocusFirstControl(this ContentElement element, bool focusParentsFirst = true)
 {
     FocusFirstControl((object)element, focusParentsFirst);
 }
Esempio n. 10
0
        internal static Uri GetBaseUriCore(DependencyObject element)
        {
            Uri baseUri = null;
            DependencyObject doCurrent;

            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            try
            {
                //
                // Search the tree to find the closest parent which implements
                // IUriContext or have set value for BaseUri property.
                //
                doCurrent = element;

                while (doCurrent != null)
                {
                    // Try to get BaseUri property value from current node.
                    baseUri = doCurrent.GetValue(BaseUriProperty) as Uri;

                    if (baseUri != null)
                    {
                        // Got the right node which is the closest to original element.
                        // Stop searching here.
                        break;
                    }

                    IUriContext uriContext = doCurrent as IUriContext;

                    if (uriContext != null)
                    {
                        // If the element implements IUriContext, and if the BaseUri
                        // is not null, just take the BaseUri from there.
                        // and stop the search loop.
                        baseUri = uriContext.BaseUri;

                        if (baseUri != null)
                        {
                            break;
                        }
                    }

                    //
                    // The current node doesn't contain BaseUri value,
                    // try its parent node in the tree.

                    UIElement uie = doCurrent as UIElement;

                    if (uie != null)
                    {
                        // Do the tree walk up
                        doCurrent = uie.GetUIParent(true);
                    }
                    else
                    {
                        ContentElement ce = doCurrent as ContentElement;

                        if (ce != null)
                        {
                            doCurrent = ce.Parent;
                        }
                        else
                        {
                            Visual vis = doCurrent as Visual;

                            if (vis != null)
                            {
                                // Try the Visual tree search
                                doCurrent = VisualTreeHelper.GetParent(vis);
                            }
                            else
                            {
                                // Not a Visual.
                                // Stop here for the tree searching to aviod an infinite loop.
                                break;
                            }
                        }
                    }
                }
            }
            finally
            {
                //
                // Putting the permission demand in finally block can prevent from exposing a bogus
                // and dangerous uri to the code in upper frame.
                //
                if (baseUri != null)
                {
                    SecurityHelper.DemandUriDiscoveryPermission(baseUri);
                }
            }

            return(baseUri);
        }
Esempio n. 11
0
        // helper used by GetPreferVisualParent - doesn't check InheritanceBehavior
        private FrameworkObject GetRawPreferVisualParent()
        {
            // the null object has no parent
            if (_do == null)
            {
                return(new FrameworkObject(null));
            }

            // get visual parent
            DependencyObject visualParent;

            if (IsFE)
            {
                visualParent = VisualTreeHelper.GetParent(_fe);
            }
            else if (IsFCE)
            {
                visualParent = null;
            }
            else if (_do != null)
            {
                Visual visual = _do as Visual;
                visualParent = (visual != null) ? VisualTreeHelper.GetParent(visual) : null;
            }
            else
            {
                visualParent = null;
            }

            if (visualParent != null)
            {
                return(new FrameworkObject(visualParent));
            }

            // if no visual parent, get logical parent
            DependencyObject logicalParent;

            if (IsFE)
            {
                logicalParent = _fe.Parent;
            }
            else if (IsFCE)
            {
                logicalParent = _fce.Parent;
            }
            else if (_do != null)
            {
                ContentElement ce = _do as ContentElement;
                logicalParent = (ce != null) ? ContentOperations.GetParent(ce) : null;
            }
            else
            {
                logicalParent = null;
            }

            if (logicalParent != null)
            {
                return(new FrameworkObject(logicalParent));
            }

            // if no logical or visual parent, get "uiCore" parent
            UIElement        uiElement;
            ContentElement   contentElement;
            DependencyObject uiCoreParent;

            if ((uiElement = _do as UIElement) != null)
            {
                uiCoreParent = uiElement.GetUIParentCore();
            }
            else if ((contentElement = _do as ContentElement) != null)
            {
                uiCoreParent = contentElement.GetUIParentCore();
            }
            else
            {
                uiCoreParent = null;
            }

            if (uiCoreParent != null)
            {
                return(new FrameworkObject(uiCoreParent));
            }

            // if all else fails, use InheritanceContext
            return(new FrameworkObject(_do.InheritanceContext));
        }
 private bool PropertyCodenameConstantIsAlreadyPresent(ContentElement element)
 {
     return(PropertyCodenameConstants.Exists(e => e.Codename == element.Codename));
 }
Esempio n. 13
0
        private bool IsDescendant(DependencyObject reference, DependencyObject node)
        {
            DependencyObject o = node;

            while (o != null)
            {
                if (o == reference)
                {
                    return(true);
                }
                Popup popup = o as Popup;
                if (popup != null)
                {
                    o = popup.Parent;
                    if (o == null)
                    {
                        o = popup.PlacementTarget;
                    }
                }
                else
                {
                    //handle content elements separately
                    ContentElement contentElement = o as ContentElement;
                    if (contentElement != null)
                    {
                        DependencyObject parent = ContentOperations.GetParent(contentElement);
                        if (parent != null)
                        {
                            o = parent;
                        }
                        FrameworkContentElement fce = contentElement as FrameworkContentElement;
                        if (fce != null)
                        {
                            o = fce.Parent;
                        }
                        else
                        {
                            o = null;
                        }
                    }
                    else
                    {
                        //also try searching for parent in framework elements (such as DockPanel, etc)
                        FrameworkElement frameworkElement = o as FrameworkElement;
                        if (frameworkElement != null)
                        {
                            DependencyObject parent = frameworkElement.Parent;
                            if (parent != null)
                            {
                                o = parent;
                                continue;
                            }
                        }

                        //if it's not a ContentElement/FrameworkElement, rely on VisualTreeHelper
                        o = VisualTreeHelper.GetParent(o);
                    }
                }
            }
            return(false);
        }
Esempio n. 14
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as Subscription;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (Identifier != null)
            {
                dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
            }
            if (NameElement != null)
            {
                dest.NameElement = (Hl7.Fhir.Model.FhirString)NameElement.DeepCopy();
            }
            if (StatusElement != null)
            {
                dest.StatusElement = (Code <Hl7.Fhir.Model.SubscriptionState>)StatusElement.DeepCopy();
            }
            if (Topic != null)
            {
                dest.Topic = (Hl7.Fhir.Model.ResourceReference)Topic.DeepCopy();
            }
            if (Contact != null)
            {
                dest.Contact = new List <Hl7.Fhir.Model.ContactPoint>(Contact.DeepCopy());
            }
            if (EndElement != null)
            {
                dest.EndElement = (Hl7.Fhir.Model.Instant)EndElement.DeepCopy();
            }
            if (ReasonElement != null)
            {
                dest.ReasonElement = (Hl7.Fhir.Model.FhirString)ReasonElement.DeepCopy();
            }
            if (FilterBy != null)
            {
                dest.FilterBy = new List <Hl7.Fhir.Model.Subscription.FilterByComponent>(FilterBy.DeepCopy());
            }
            if (ChannelType != null)
            {
                dest.ChannelType = (Hl7.Fhir.Model.Coding)ChannelType.DeepCopy();
            }
            if (EndpointElement != null)
            {
                dest.EndpointElement = (Hl7.Fhir.Model.FhirUrl)EndpointElement.DeepCopy();
            }
            if (HeaderElement != null)
            {
                dest.HeaderElement = new List <Hl7.Fhir.Model.FhirString>(HeaderElement.DeepCopy());
            }
            if (HeartbeatPeriodElement != null)
            {
                dest.HeartbeatPeriodElement = (Hl7.Fhir.Model.UnsignedInt)HeartbeatPeriodElement.DeepCopy();
            }
            if (TimeoutElement != null)
            {
                dest.TimeoutElement = (Hl7.Fhir.Model.UnsignedInt)TimeoutElement.DeepCopy();
            }
            if (ContentTypeElement != null)
            {
                dest.ContentTypeElement = (Hl7.Fhir.Model.Code)ContentTypeElement.DeepCopy();
            }
            if (ContentElement != null)
            {
                dest.ContentElement = (Code <Hl7.Fhir.Model.Subscription.SubscriptionPayloadContent>)ContentElement.DeepCopy();
            }
            return(dest);
        }
Esempio n. 15
0
        // Walk up the parent chain to find the closest element with IsFocusScope=true
        private static DependencyObject _GetFocusScope(DependencyObject d)
        {
            if (d == null)
            {
                return(null);
            }

            if ((bool)d.GetValue(IsFocusScopeProperty))
            {
                return(d);
            }

            // Step 1: Walk up the logical tree
            UIElement uiElement = d as UIElement;

            if (uiElement != null)
            {
                DependencyObject logicalParent = uiElement.GetUIParentCore();
                if (logicalParent != null)
                {
                    return(GetFocusScope(logicalParent));
                }
            }
            else
            {
                ContentElement ce = d as ContentElement;
                if (ce != null)
                {
                    DependencyObject logicalParent = ce.GetUIParent(true);
                    if (logicalParent != null)
                    {
                        return(_GetFocusScope(logicalParent));
                    }
                }
                else
                {
                    UIElement3D uiElement3D = d as UIElement3D;
                    if (uiElement3D != null)
                    {
                        DependencyObject logicalParent = uiElement3D.GetUIParentCore();
                        if (logicalParent != null)
                        {
                            return(GetFocusScope(logicalParent));
                        }
                    }
                }
            }

            // Step 2: Walk up the visual tree
            if (d is Visual || d is Visual3D)
            {
                DependencyObject visualParent = VisualTreeHelper.GetParent(d);
                if (visualParent != null)
                {
                    return(_GetFocusScope(visualParent));
                }
            }

            // If visual and logical parent is null - then the element is implicit focus scope
            return(d);
        }
Esempio n. 16
0
 /// <summary>
 /// Extracts identifier sets from a content element response.
 /// </summary>
 /// <param name="response">The <see cref="ContentElement"/> response.</param>
 /// <returns>Identifiers of all formats of the element.</returns>
 public IEnumerable <IdentifierSet> GetContentElementDependencies(ContentElement response)
 {
     return(GetContentElementDependenciesInternal(KenticoCloudCacheHelper.CONTENT_ELEMENT_IDENTIFIER, response).Distinct());
 }
Esempio n. 17
0
        internal static Uri GetBaseUriCore(DependencyObject element)
        {
            Uri uri = null;

            if (element != null)
            {
                try {
                    DependencyObject dependencyObject = element;
                    while (true)
                    {
                        if (dependencyObject == null)
                        {
                            return(uri);
                        }
                        uri = (dependencyObject.GetValue(BaseUriProperty) as Uri);
                        if (uri != null)
                        {
                            return(uri);
                        }
                        IUriContext uriContext = dependencyObject as IUriContext;
                        if (uriContext != null)
                        {
                            uri = uriContext.BaseUri;
                            if (uri != null)
                            {
                                return(uri);
                            }
                        }
                        UIElement uIElement = dependencyObject as UIElement;
                        if (uIElement != null)
                        {
                            dependencyObject = uIElement.GetUIParent(true);
                        }
                        else
                        {
                            ContentElement contentElement = dependencyObject as ContentElement;
                            if (contentElement != null)
                            {
                                dependencyObject = contentElement.Parent;
                            }
                            else
                            {
                                Visual visual = dependencyObject as Visual;
                                if (visual == null)
                                {
                                    break;
                                }
                                dependencyObject = VisualTreeHelper.GetParent(visual);
                            }
                        }
                    }
                    return(uri);
                } finally {
                    if (uri != null)
                    {
                        SecurityHelper.DemandUriDiscoveryPermission(uri);
                    }
                }
            }
            throw new ArgumentNullException(nameof(element));
        }
Esempio n. 18
0
 private static void CastInputElement(IInputElement element, out UIElement uiElement, out ContentElement contentElement, out UIElement3D uiElement3D)
 {
     uiElement      = element as UIElement;
     contentElement = (uiElement == null) ? element as ContentElement : null;
     uiElement3D    = ((uiElement == null) && (contentElement == null)) ? element as UIElement3D : null;
 }
Esempio n. 19
0
        private IInputElement CriticalHitTest(Point point, bool isSynchronize)
        {
            IInputElement over = null;

            if (_activeSource != null)
            {
                switch (_captureMode)
                {
                case CaptureMode.None:
                    // No capture, do a regular hit-test.
                    if (_isDown)
                    {
                        if (isSynchronize)
                        {
                            // In a synchronize call, we need to hit-test the window in addition to the element
                            over = GlobalHitTest(point, _activeSource);
                        }
                        else
                        {
                            // Just hit-test the element
                            over = LocalHitTest(point, _activeSource);
                        }

                        EnsureValid(ref over);
                    }
                    break;

                case CaptureMode.Element:
                    // Capture is to a specific element, so the device will always be over that element.
                    over = _captured;
                    break;

                case CaptureMode.SubTree:
                    // Capture is set to an entire subtree. Hit-test to determine the element (and window)
                    // the device is over. If the element is within the captured sub-tree (which can span
                    // multiple windows), then the device is over that element. If the element is not within
                    // the sub-tree, then the device is over the captured element.
                {
                    IInputElement capture = InputElement.GetContainingInputElement(_captured as DependencyObject);
                    if (capture != null)
                    {
                        // We need to re-hit-test to get the "real" UIElement we are over.
                        // This allows us to have our capture-to-subtree span multiple windows.

                        // GlobalHitTest always returns an IInputElement, so we are sure to have one.
                        over = GlobalHitTest(point, _activeSource);
                    }

                    EnsureValid(ref over);

                    // Make sure that the element we hit is acutally underneath
                    // our captured element.  Because we did a global hit test, we
                    // could have hit an element in a completely different window.
                    //
                    // Note that we support the child being in a completely different window.
                    // So we use the GetUIParent method instead of just looking at
                    // visual/content parents.
                    if (over != null)
                    {
                        IInputElement ieTest = over;
                        while ((ieTest != null) && (ieTest != _captured))
                        {
                            UIElement eTest = ieTest as UIElement;

                            if (eTest != null)
                            {
                                ieTest = InputElement.GetContainingInputElement(eTest.GetUIParent(true));
                            }
                            else
                            {
                                ContentElement ceTest = ieTest as ContentElement;

                                if (ceTest != null)
                                {
                                    ieTest = InputElement.GetContainingInputElement(ceTest.GetUIParent(true));
                                }
                                else
                                {
                                    UIElement3D e3DTest = (UIElement3D)ieTest;
                                    ieTest = InputElement.GetContainingInputElement(e3DTest.GetUIParent(true));
                                }
                            }
                        }

                        if (ieTest != _captured)
                        {
                            // If we missed the capture point, consider the device over the capture point.
                            over = _captured;
                        }
                    }
                    else
                    {
                        // If we didn't hit anything, consider the device over the capture point.
                        over = _captured;
                    }
                }
                break;
                }
            }

            return(over);
        }
Esempio n. 20
0
 public ContentElement Save(ContentElement contentElement)
 {
     return(_contentRepository.Save(contentElement));
 }
Esempio n. 21
0
 internal override void FireNotifications(UIElement uie, ContentElement ce, UIElement3D uie3D, bool oldValue)
 {
 }
Esempio n. 22
0
 protected bool ValidateContentElementForCapture(ContentElement element)
 {
     return(element.IsEnabled);
 }
Esempio n. 23
0
 // Token: 0x06006733 RID: 26419 RVA: 0x001CDCDB File Offset: 0x001CBEDB
 internal virtual List <Rect> GetRectangles(ContentElement e, int start, int length)
 {
     return(new List <Rect>());
 }
Esempio n. 24
0
 private DependencyObject FindContentElementParent(ContentElement ce)
 {
     throw new NotImplementedException();
 }
Esempio n. 25
0
//<SnippetFocus>
        void FocusOnParagraph(object sender, RoutedEventArgs e)
        {
            ContentElement ce = this.FindName("focusableP") as ContentElement;

            ce.Focus();
        }
Esempio n. 26
0
        /// <summary>
        ///     Captures the stylus to a particular element.
        /// </summary>
        internal override bool Capture(IInputElement element, CaptureMode captureMode)
        {
            int timeStamp = Environment.TickCount;

            VerifyAccess();

            if (!(captureMode == CaptureMode.None || captureMode == CaptureMode.Element || captureMode == CaptureMode.SubTree))
            {
                throw new System.ComponentModel.InvalidEnumArgumentException("captureMode", (int)captureMode, typeof(CaptureMode));
            }

            if (element == null)
            {
                captureMode = CaptureMode.None;
            }

            if (captureMode == CaptureMode.None)
            {
                element = null;
            }

            // Validate that element is either a UIElement or a ContentElement
            DependencyObject doStylusCapture = element as DependencyObject;

            if (doStylusCapture != null && !InputElement.IsValid(element))
            {
                throw new InvalidOperationException(SR.Get(SRID.Invalid_IInputElement, doStylusCapture.GetType()));
            }

            doStylusCapture?.VerifyAccess();

            bool success = false;

            // The element we are capturing to must be both enabled and visible.
            UIElement e = element as UIElement;

            if ((e?.IsVisible ?? false) || (e?.IsEnabled ?? false))
            {
                success = true;
            }
            else
            {
                ContentElement ce = element as ContentElement;

                if (ce?.IsEnabled ?? false)
                {
                    success = true;
                }
                else
                {
                    // Setting capture to null.
                    success = true;
                }
            }

            if (success)
            {
                ChangeStylusCapture(element, captureMode, timeStamp);
            }

            return(success);
        }
Esempio n. 27
0
 /// <summary>
 /// Moves the focus in a specific direction.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <param name="direction">The direction.</param>
 /// <param name="hops">The hops.</param>
 public static void MoveFocus(this ContentElement element, FocusNavigationDirection direction, int hops)
 {
     MoveFocus((object)element, direction, hops);
 }
Esempio n. 28
0
        internal IInputElement FindTarget(PresentationSource inputSource, Point position)
        {
            IInputElement stylusOver = null;

            switch (_captureMode)
            {
            case CaptureMode.None:
            {
                stylusOver = StylusDevice.GlobalHitTest(inputSource, position);

                // We understand UIElements and ContentElements.
                // If we are over something else (like a raw visual)
                // find the containing element.
                if (!InputElement.IsValid(stylusOver))
                {
                    stylusOver = InputElement.GetContainingInputElement(stylusOver as DependencyObject);
                }
            }
            break;

            case CaptureMode.Element:
                stylusOver = _stylusCapture;
                break;

            case CaptureMode.SubTree:
            {
                IInputElement stylusCapture = InputElement.GetContainingInputElement(_stylusCapture as DependencyObject);

                if (stylusCapture != null && inputSource != null)
                {
                    // We need to re-hit-test to get the "real" UIElement we are over.
                    // This allows us to have our capture-to-subtree span multiple windows.

                    // GlobalHitTest always returns an IInputElement, so we are sure to have one.
                    stylusOver = StylusDevice.GlobalHitTest(inputSource, position);
                }

                if (stylusOver != null && !InputElement.IsValid(stylusOver))
                {
                    stylusOver = InputElement.GetContainingInputElement(stylusOver as DependencyObject);
                }

                // Make sure that the element we hit is acutally underneath
                // our captured element.  Because we did a global hit test, we
                // could have hit an element in a completely different window.
                //
                // Note that we support the child being in a completely different window.
                // So we use the GetUIParent method instead of just looking at
                // visual/content parents.
                if (stylusOver != null)
                {
                    IInputElement  ieTest = stylusOver;
                    UIElement      eTest  = null;
                    ContentElement ceTest = null;

                    while (ieTest != null && ieTest != stylusCapture)
                    {
                        eTest = ieTest as UIElement;

                        if (eTest != null)
                        {
                            ieTest = InputElement.GetContainingInputElement(eTest.GetUIParent(true));
                        }
                        else
                        {
                            ceTest = ieTest as ContentElement;         // Should never fail.

                            ieTest = InputElement.GetContainingInputElement(ceTest.GetUIParent(true));
                        }
                    }

                    // If we missed the capture point, we didn't hit anything.
                    if (ieTest != stylusCapture)
                    {
                        stylusOver = _stylusCapture;
                    }
                }
                else
                {
                    // We didn't hit anything.  Consider the stylus over the capture point.
                    stylusOver = _stylusCapture;
                }
            }
            break;
            }

            return(stylusOver);
        }
Esempio n. 29
0
        public static void Run()
        {
            ContentType    targetType    = null;
            ContentElement targetElement = null;

            Google.Apis.Drive.v3.Data.File sourceFile = null;
            bool update   = false;
            bool hasError = false;

            var files = driveHelper.ListFiles();

            if (files != null && files.Count > 0)
            {
                sourceFile = VerifySourceFile(files);
            }
            else
            {
                Program.ShowError("No files found.");
                Console.ReadKey();
                return;
            }

            if (!DriveHelper.IsAsset(sourceFile))
            {
                var types = KontentHelper.ListContentTypes();
                targetType = VerifyContentType(types);

                // If imported file is not a spreadsheet, get target element
                if (!DriveHelper.IsSpreadsheet(sourceFile))
                {
                    targetElement = VerifyContentElement(targetType);
                }

                update = AskUpdate();
            }

            // Verify data and begin import
            Console.WriteLine();
            if (!CanImport(sourceFile, targetElement, targetType))
            {
                ShowError("Something went wrong.. Please press any key to close.");
                Console.ReadKey();
                return;
            }
            else
            {
                try
                {
                    var stream = driveHelper.DownloadFile(sourceFile);
                    if (stream != null)
                    {
                        KontentHelper.BeginImport(stream, sourceFile, targetElement, targetType, update);
                    }
                }
                catch (Exception e)
                {
                    hasError = true;
                    ShowError(e.Message);
                }
                finally
                {
                    Console.WriteLine(hasError ? "Import completed with error(s), please check error messages" : "Import complete");
                    // Ask if user wants to run import again
                    Console.WriteLine("Do you want to perform another import? [Enter = Yes, Any other key = Quit]");
                    if (Console.ReadKey().Key == ConsoleKey.Enter)
                    {
                        Run();
                    }
                }
            }
        }
Esempio n. 30
0
 private static bool ContainsContentElement(TextBlock textBlock, ContentElement element)
 {
     if (textBlock._complexContent == null || !(textBlock._complexContent.TextContainer is TextContainer))
     {
         return false;
     }
     else if (element is TextElement)
     {
         if (textBlock._complexContent.TextContainer != ((TextElement)element).TextContainer)
         {
             return false;
         }
         else
         {
             return true;
         }
     }
     return false;
 }
Esempio n. 31
0
 /// <summary>
 /// Begins adjustable animation for a GridlengthAnimation.
 /// Holds animation end value without Holding it. i.e. Allows it to change after animation without resetting it. Should be possible in WPF...maybe it is.
 /// </summary>
 /// <param name="element">Element to start animation on.</param>
 /// <param name="dp">Property to animate.</param>
 /// <param name="anim">Animation to perform. GridLengthAnimation only for now.</param>
 public static void BeginAdjustableAnimation(this ContentElement element, DependencyProperty dp, GridLengthAnimation anim)
 {
     element.BeginAdjustableAnimation(dp, anim, anim.To);
 }
Esempio n. 32
0
 protected static void AssertInputable(ContentElement element)
 {
     Assert.IsTrue(element.IsEnabled, element.ToString());
 }
Esempio n. 33
0
        /// <summary>
        /// Returns an ICollection of bounding rectangles for the given ContentElement
        /// </summary>
        /// <param name="child">
        /// Content element for which rectangles are required
        /// </param>
        /// <remarks>
        /// Looks at the ContentElement e line by line and gets rectangle bounds for each line
        /// </remarks>
        protected virtual ReadOnlyCollection<Rect> GetRectanglesCore(ContentElement child)
        {
            if (child == null)
            {
                throw new ArgumentNullException("child");
            }

            // If layout data is not updated we assume that we will not be able to find the element we need and throw excception
            if (!IsLayoutDataValid)
            {
                // return empty collection
                return new ReadOnlyCollection<Rect>(new List<Rect>(0));
            }

            // Line props may be invalid, even if Measure/Arrange is valid - rendering only props are changing.
            LineProperties lineProperties = GetLineProperties();

            // Check for complex content
            if (_complexContent == null || !(_complexContent.TextContainer is TextContainer))
            {
                // return empty collection
                return new ReadOnlyCollection<Rect>(new List<Rect>(0));
            }

            // First find the element start and end position
            TextPointer start = FindElementPosition((IInputElement)child);
            if (start == null)
            {
                return new ReadOnlyCollection<Rect>(new List<Rect>(0));
            }

            TextPointer end = null;
            if (child is TextElement)
            {
                end = new TextPointer(((TextElement)child).ElementEnd);
            }
            else if (child is FrameworkContentElement)
            {
                end = new TextPointer(start);
                end.MoveByOffset(+1);
            }

            if (end == null)
            {
                return new ReadOnlyCollection<Rect>(new List<Rect>(0));
            }

            int startOffset = _complexContent.TextContainer.Start.GetOffsetToPosition(start);
            int endOffset = _complexContent.TextContainer.Start.GetOffsetToPosition(end);

            int lineIndex = 0;
            int lineOffset = 0;
            double lineHeightOffset = 0;
            int lineCount = LineCount;
            while (startOffset >= (lineOffset + GetLine(lineIndex).Length) && lineIndex < lineCount)
            {
Debug.Assert(lineCount == LineCount);
                lineOffset += GetLine(lineIndex).Length;
                lineIndex++;
                lineHeightOffset += GetLine(lineIndex).Height;
            }
            Debug.Assert(lineIndex < lineCount);

            int lineStart = lineOffset;
            List<Rect> rectangles = new List<Rect>();
            double wrappingWidth = CalcWrappingWidth(RenderSize.Width);

            TextRunCache textRunCache = new TextRunCache();

            Vector contentOffset = CalcContentOffset(RenderSize, wrappingWidth);
            do
            {
Debug.Assert(lineCount == LineCount);
                // Check that line index never exceeds line count
                Debug.Assert(lineIndex < lineCount);

                // Create lines as long as they are spanned by the element
                LineMetrics lineMetrics = GetLine(lineIndex);

                Line line = CreateLine(lineProperties);

                using (line)
                {
                    // Check if paragraph ellipsis are rendered
                    bool ellipsis = ParagraphEllipsisShownOnLine(lineIndex, lineOffset);
                    line.Format(lineStart, wrappingWidth, GetLineProperties(lineIndex == 0, lineProperties), lineMetrics.TextLineBreak, textRunCache, ellipsis);

                    // Verify consistency of line formatting
                    // 
                    if (lineMetrics.Length == line.Length)
                    {
                        //MS.Internal.Invariant.Assert(lineMetrics.Length == line.Length, "Line length is out of [....]");
                        //Debug.Assert(DoubleUtil.AreClose(CalcLineAdvance(line.Height, lineProperties), lineMetrics.Height), "Line height is out of [....].");

                        int boundStart = (startOffset >= lineStart) ? startOffset : lineStart;
                        int boundEnd = (endOffset < lineStart + lineMetrics.Length) ? endOffset : lineStart + lineMetrics.Length;

                        double xOffset = contentOffset.X;
                        double yOffset = contentOffset.Y + lineHeightOffset;
                        List<Rect> lineBounds = line.GetRangeBounds(boundStart, boundEnd - boundStart, xOffset, yOffset);
                        Debug.Assert(lineBounds.Count > 0);
                        rectangles.AddRange(lineBounds);
                    }
                }

                lineStart += lineMetrics.Length;
                lineHeightOffset += lineMetrics.Height;
                lineIndex++;
            }
            while (endOffset > lineStart);

            // Rectangles collection must be non-null
            Invariant.Assert(rectangles != null);
            return new ReadOnlyCollection<Rect>(rectangles);
        }
        /// <summary>
        /// Signs the range of document pages using given certificate and signature image.
        /// </summary>
        /// <param name="doc">Document to sign.</param>
        /// <param name="signingCertificate">Signing certificate's data stream.</param>
        /// <param name="certPassword">Certificate's password.</param>
        /// <param name="signatureText">The text of the signature.</param>
        /// <param name="signatureBoundary">Visual signature boundaries.</param>
        /// <param name="signaturePageIndexStart">The index of the first page to sign.</param>
        /// <param name="signaturePageIndexEnd">The index of the last page to sign.</param>
        /// <param name="outputStream">Output stream, optional. If not set, incremental save will be performed.</param>
        /// <returns>Identifier assigned to the created signature field. Using this id you can find this field in doc's AcroForm dictionary.</returns>
        public static string Sign(this FixedDocument doc, Stream signingCertificate,
                                  string certPassword, string signatureText, Boundary signatureBoundary,
                                  int signaturePageIndexStart = 0, int signaturePageIndexEnd = 0, Stream outputStream = null)
        {
            if (doc == null)
            {
                throw new ArgumentNullException(nameof(doc));
            }

            if (signingCertificate == null)
            {
                throw new ArgumentNullException(nameof(signingCertificate));
            }

            if (certPassword == null)
            {
                throw new ArgumentNullException(nameof(certPassword));
            }

            if (signatureBoundary == null)
            {
                throw new ArgumentNullException(nameof(signatureBoundary));
            }

            if (signaturePageIndexStart < 0 || signaturePageIndexStart > doc.Pages.Count - 1)
            {
                throw new ArgumentOutOfRangeException(nameof(signaturePageIndexStart));
            }

            if (signaturePageIndexEnd < signaturePageIndexStart || signaturePageIndexEnd > doc.Pages.Count - 1)
            {
                throw new ArgumentOutOfRangeException(nameof(signaturePageIndexEnd));
            }

            // create textual resource
            FixedContent signatureTextXObject = new FixedContent(Guid.NewGuid().ToString("N"), new Boundary(0, 0, signatureBoundary.Width, signatureBoundary.Height));

            Section section = new Section();

            if (!string.IsNullOrEmpty(signatureText))
            {
                var newLineString = "<br/>";
                signatureText = signatureText.Replace("\r\n", newLineString)
                                .Replace("\n", newLineString)
                                .Replace("\r", newLineString);

                foreach (ContentElement contentElement in ContentElement.FromMarkup(signatureText))
                {
                    contentElement.Font = new Font("TimesNewRoman", 12);
                    section.Add(contentElement);
                }

                signatureTextXObject.Content.AppendContentElement(section, signatureBoundary.Width, signatureBoundary.Height);
            }

            doc.ResourceManager.RegisterResource(signatureTextXObject);

            string signatureFieldId = Guid.NewGuid().ToString("N");

            // create signature field and initialize it using a stored
            // password protected certificate
            SignatureField signatureField = new SignatureField(signatureFieldId);

            signatureField.Signature = Signature.Create(new Pkcs12Store(signingCertificate, certPassword));

            // add signature field to a document
            doc.AcroForm.Fields.Add(signatureField);

            // create signature view using the image resource
            SignatureFieldView signatureView = new SignatureFieldView(signatureField, signatureBoundary);

            signatureView.ViewSettings.Graphic           = Graphic.XObject;
            signatureView.ViewSettings.GraphicResourceID = signatureTextXObject.ID;
            signatureView.ViewSettings.Description       = Description.None;

            // add view to pages' annotations
            for (int i = signaturePageIndexStart; i <= signaturePageIndexEnd; ++i)
            {
                doc.Pages[i].Annotations.Add(signatureView);
            }

            // save to specified file or do an incremental update
            if (outputStream != null)
            {
                doc.Save(outputStream);
            }
            else
            {
                doc.Save();
            }

            return(signatureFieldId);
        }
Esempio n. 35
0
 /// <summary>
 /// Returns an ICollection of bounding rectangles for the given ContentElement
 /// </summary>
 /// <param name="child">
 /// Content element for which rectangles are required
 /// </param>
 /// <remarks>
 /// Looks at the ContentElement e line by line and gets rectangle bounds for each line
 /// </remarks>
 ReadOnlyCollection<Rect> IContentHost.GetRectangles(ContentElement child)
 {
     return this.GetRectanglesCore(child);
 }
Esempio n. 36
0
 /// <summary>
 /// <see cref="IContentHost.GetRectangles"/>
 /// </summary>
 ReadOnlyCollection <Rect> IContentHost.GetRectangles(ContentElement child)
 {
     return(new ReadOnlyCollection <Rect>(new List <Rect>()));
 }
Esempio n. 37
0
 public ContentElementProxy(ContentElement proxied) : base(proxied)
 {
 }
Esempio n. 38
0
        public void AddContent(ContentElement content, int sectionId)
        {
            var section = _sections.FirstOrDefault(s => s.SectionId == sectionId);

            section.AddContent(content);
        }
Esempio n. 39
0
 // ------------------------------------------------------------------
 // Returns ArrayList of rectangles for the ContentElement e.
 // Returns empty list if the paraClient does not contain e.
 // start: int representing start offset of e
 // length: int representing number of characters occupied by e.
 // parentOffset: indicates offset of parent element. Used only by
 //               subpage para clients when calculating rectangles
 // ------------------------------------------------------------------
 internal virtual List <Rect> GetRectangles(ContentElement e, int start, int length)
 {
     // Return empty collection as default
     return(new List <Rect>());
 }
Esempio n. 40
0
        private void ShowElement(ContentElement element)
        {
            _miniWindow.SuspendLayout();
            if (_miniWindow == null)
                return;
            _miniWindow.lblTitleName.Text = element.Name;
            switch (element.Type)
            {
                case ContentType.Text:
                    _miniWindow.lblContent.Font = ((TextSettings)element.Settings).Font;
                    _miniWindow.lblContent.BackColor = ((TextSettings)element.Settings).BackgroundColor;
                    _miniWindow.lblContent.ForeColor = ((TextSettings)element.Settings).FontColor;
                    _miniWindow.lblContent.Text = (string)element.Data;
                    if (MiniWindowSettings.Default.FontAutoSize)
                        MakeTxtFitInLabel(_miniWindow.lblContent);
                    _miniWindow.picContent.Hide();
                    _miniWindow.lblContent.Show();
                    break;

                case ContentType.Image:
                    _miniWindow.picContent.Image = FileManager.ByteArrayToImage((byte[])element.Data);
                    _miniWindow.picContent.BackColor = ((ImageSettings)element.Settings).BackgroundColor;
                    _miniWindow.picContent.SizeMode = ((ImageSettings)element.Settings).SizeMode;
                    _miniWindow.lblContent.Hide();
                    _miniWindow.picContent.Show();
                    break;

                default:
                    throw new NotImplementedException();
            }
            _miniWindow.PerformLayout();
            return;
        }