Пример #1
0
        private void CreateCaptionForControl(UIElement control)
        {
            DialogPanel.AddCaptionChangedEventHandler(control, this.ControlCaptionChanged);

            object Caption = DialogPanel.GetCaption(control);

            if (Caption != null)
            {
                UIElement CaptionControl;
                if (Caption is UIElement)
                {
                    CaptionControl = (UIElement)Caption;
                }
                else
                {
                    ContentPresenter Presenter = new ContentPresenter();
                    Presenter.SetBinding(ContentPresenter.ContentProperty, new Binding {
                        Source = control, Path = new PropertyPath(DialogPanel.CaptionProperty), BindsDirectlyToSource = true
                    });
                    Presenter.SetBinding(ContentPresenter.ContentTemplateProperty, new Binding {
                        BindsDirectlyToSource = true, Source = this, Path = new PropertyPath("CaptionTemplate")
                    });
                    CaptionControl = Presenter;
                }

                this.captionControls.Add(control, CaptionControl);
                this.AddVisualChild(CaptionControl);
            }
            else
            {
                //Ignore: there is no caption, This means, the control shall have full width
            }

            this.InvalidateMeasure();
        }
Пример #2
0
 public void RemoveMember(DialogPanel panel)
 {
     this.members.Remove(panel);
     panel.IsVisibleChanged -= this.PanelIsVisibleChanged;
     panel.LayoutUpdated    -= this.PanelLayoutChanged;
     this.Update(null);
 }
Пример #3
0
 public void AddMember(DialogPanel panel)
 {
     this.members.Add(panel);
     panel.IsVisibleChanged += this.PanelIsVisibleChanged;
     panel.LayoutUpdated    += this.PanelLayoutChanged;
     this.Update(null);
 }
Пример #4
0
 private void DisposeCaptionForControl(UIElement control)
 {
     DialogPanel.RemoveCaptionChangedEventHandler(control, this.ControlCaptionChanged);
     if (this.captionControls.ContainsKey(control))
     {
         UIElement CaptionControl = this.captionControls[control];
         this.RemoveVisualChild(CaptionControl);
         this.captionControls.Remove(control);
     }
 }
Пример #5
0
            private void Update(DialogPanel sender)
            {
                this.CaptionWidth = (from Panel in this.members where Panel.IsVisible select Panel.CalculatedCaptionWidth).Union(new[] { 0d }).Max();

                foreach (DialogPanel Panel in this.members)
                {
                    // Force update on all panels with different captions width.
                    // Sender is skipped, because it is in middle of calculation and will consider new value automatically
                    if (Panel != sender && Panel.UsedCaptionWidth != this.CaptionWidth)
                    {
                        Panel.InvalidateMeasure();
                    }
                }
            }
Пример #6
0
        private static void OnPrivateSynchronisationRootPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
        {
            DialogPanel Panel = (DialogPanel)dependencyObject;

            PanelSynchronisationRoot SynchronisationRoot = (PanelSynchronisationRoot)e.NewValue;

            if (Panel.synchronisationRoot != null)
            {
                //  if definition is already registered And shared size scope is changing,
                //  then un-register the definition from the current shared size state object.
                Panel.synchronisationRoot.RemoveMember(Panel);
                Panel.synchronisationRoot = null;
            }

            if ((Panel.synchronisationRoot == null) && (SynchronisationRoot != null))
            {
                //  if definition is not registered and both: shared size group id AND private shared scope
                //  are available, then register definition.
                Panel.synchronisationRoot = SynchronisationRoot;
                Panel.synchronisationRoot.AddMember(Panel);
            }
        }
Пример #7
0
 public void NotifyMeasured(DialogPanel dialogPanel)
 {
     this.Update(dialogPanel);
 }