Ejemplo n.º 1
0
        protected virtual IHtmlString RenderContentPosition(ContentPosition contentPosition)
        {
            var site       = this.PageContext.PageRequestContext.Site;
            var repository = site.GetRepository();

            if (repository == null)
            {
                throw new KoobooException("The repository for site is null.");
            }
            var dataRule        = contentPosition.DataRule;
            var dataRuleContext = new DataRuleContext(this.PageContext.PageRequestContext.Site,
                                                      this.PageContext.PageRequestContext.Page)
            {
                ValueProvider = this.PageContext.PageRequestContext.GetValueProvider()
            };
            var    contentQuery = dataRule.Execute(dataRuleContext);
            string viewPath     = "";
            var    schema       = dataRule.GetSchema(repository);
            Object model        = contentQuery;

            switch (contentPosition.Type)
            {
            case ContentPositionType.Detail:
                viewPath = schema.GetFormTemplate(FormType.Detail);
                model    = contentQuery.FirstOrDefault();
                break;

            case ContentPositionType.List:
            default:
                viewPath = schema.GetFormTemplate(FormType.List);
                break;
            }
            return(RenderViewInternal(this.Html, viewPath, null, model));
        }
Ejemplo n.º 2
0
        public void SetContent(string label, object imageBackend, ContentPosition imagePosition)
        {
            Widget.Title = label ?? "";
            if (string.IsNullOrEmpty(label))
            {
                imagePosition = ContentPosition.Center;
            }
            if (imageBackend != null)
            {
                Widget.Image = (NSImage)imageBackend;
                switch (imagePosition)
                {
                case ContentPosition.Bottom: Widget.ImagePosition = NSCellImagePosition.ImageBelow; break;

                case ContentPosition.Left: Widget.ImagePosition = NSCellImagePosition.ImageLeft; break;

                case ContentPosition.Right: Widget.ImagePosition = NSCellImagePosition.ImageRight; break;

                case ContentPosition.Top: Widget.ImagePosition = NSCellImagePosition.ImageAbove; break;

                case ContentPosition.Center: Widget.ImagePosition = NSCellImagePosition.ImageOverlaps; break;
                }
            }
            Widget.SizeToFit();
        }
Ejemplo n.º 3
0
        public void SetContent(string label, ImageDescription image, ContentPosition imagePosition)
        {
            Widget.Title = label ?? "";
            if (string.IsNullOrEmpty(label))
            {
                imagePosition = ContentPosition.Center;
            }
            if (!image.IsNull)
            {
                var img = image.ToNSImage();
                Widget.Image           = (NSImage)img;
                Widget.Cell.ImageScale = NSImageScale.None;
                switch (imagePosition)
                {
                case ContentPosition.Bottom: Widget.ImagePosition = NSCellImagePosition.ImageBelow; break;

                case ContentPosition.Left: Widget.ImagePosition = NSCellImagePosition.ImageLeft; break;

                case ContentPosition.Right: Widget.ImagePosition = NSCellImagePosition.ImageRight; break;

                case ContentPosition.Top: Widget.ImagePosition = NSCellImagePosition.ImageAbove; break;

                case ContentPosition.Center: Widget.ImagePosition = string.IsNullOrEmpty(label) ? NSCellImagePosition.ImageOnly : NSCellImagePosition.ImageOverlaps; break;
                }
            }
            ResetFittingSize();
        }
Ejemplo n.º 4
0
        public void SetContent(string label, ImageDescription image, ContentPosition position)
        {
            if (image.IsNull)
            {
                Button.Content = label;
            }
            else
            {
                SWC.DockPanel grid = new SWC.DockPanel();

                var imageCtrl = new ImageBox(Context);
                imageCtrl.ImageSource = image;

                SWC.DockPanel.SetDock(imageCtrl, DataConverter.ToWpfDock(position));
                grid.Children.Add(imageCtrl);

                if (!string.IsNullOrEmpty(label))
                {
                    SWC.Label labelCtrl = new SWC.Label();
                    labelCtrl.Content = label;
                    grid.Children.Add(labelCtrl);
                }
                Button.Content = grid;
            }
            Button.InvalidateMeasure();
        }
Ejemplo n.º 5
0
        public void SetContent(string label, object imageBackend, ContentPosition position)
        {
            if (imageBackend == null)
            {
                Button.Content = label;
            }
            else
            {
                SWC.DockPanel grid = new SWC.DockPanel();

                var       img       = (SWMI.BitmapSource)imageBackend;
                SWC.Image imageCtrl = new SWC.Image
                {
                    Source = img,
                    Width  = img.Width,
                    Height = img.Height
                };

                SWC.DockPanel.SetDock(imageCtrl, DataConverter.ToWpfDock(position));
                grid.Children.Add(imageCtrl);

                SWC.Label labelCtrl = new SWC.Label();
                labelCtrl.Content = label;
                grid.Children.Add(labelCtrl);

                Button.Content = grid;
            }
        }
Ejemplo n.º 6
0
        public virtual ActionResult ProcessFolder(string PagePositionId, int Order, string Top, string Type, string UserKey)
        {
            var pos = new ContentPosition();

            pos.Type           = ParseEnum <ContentPositionType>(Type);
            pos.PagePositionId = PagePositionId;
            pos.Order          = Order;

            var dataRule = new FolderDataRule()
            {
                FolderName = Request.Form["DataRule.FolderName"],
                Top        = Top
            };

            if (pos.Type == ContentPositionType.Detail)
            {
                dataRule.WhereClauses = new WhereClause[]
                {
                    new WhereClause()
                    {
                        FieldName = "UserKey",
                        Operator  = Operator.Equals,
                        Value1    = string.IsNullOrEmpty(UserKey) ? "{UserKey}" : UserKey
                    }
                };
            }

            pos.DataRule = dataRule;

            return(Json(new { html = new PageDesignFolderContent(pos).ToHtmlString() }));
        }
    void GetPosition()
    {
        ContentPosition listModul = new ContentPosition();

        DdlPosition.Items.Clear();
        for (int i = 0; i < listModul.Text.Length; i++)
        {
            DdlPosition.Items.Add(new ListItem(listModul.Text[i], listModul.Values[i]));
        }
    }
Ejemplo n.º 8
0
        private void OnContentPositionChanged(DependencyPropertyChangedEventArgs args)
        {
            this.contentPositionCache = (ContentPosition)args.NewValue;

            if (this.infoContent == null)
            {
                return;
            }

            this.SynchInfoContentPosition();
        }
    string SetPosition(string ValuePosition)
    {
        string          str       = "";
        ContentPosition listModul = new ContentPosition();

        if (listModul.Text[Convert.ToInt16(ValuePosition)] != null)
        {
            str = listModul.Text[Convert.ToInt16(ValuePosition)];
        }

        return(str);
    }
Ejemplo n.º 10
0
        // Token: 0x06007012 RID: 28690 RVA: 0x00203190 File Offset: 0x00201390
        public override int GetPageNumber(ContentPosition contentPosition)
        {
            this._dispatcherObject.VerifyAccess();
            if (contentPosition == null)
            {
                throw new ArgumentNullException("contentPosition");
            }
            TextPointer textPointer = contentPosition as TextPointer;

            if (textPointer == null)
            {
                throw new ArgumentException(SR.Get("IDPInvalidContentPosition"), "contentPosition");
            }
            if (textPointer.TextContainer != this._document.StructuralCache.TextContainer)
            {
                throw new ArgumentException(SR.Get("IDPInvalidContentPosition"), "contentPosition");
            }
            if (this._document.StructuralCache.IsFormattingInProgress)
            {
                throw new InvalidOperationException(SR.Get("FlowDocumentFormattingReentrancy"));
            }
            if (this._document.StructuralCache.IsContentChangeInProgress)
            {
                throw new InvalidOperationException(SR.Get("TextContainerChangingReentrancyInvalid"));
            }
            int num;

            using (this._document.Dispatcher.DisableProcessing())
            {
                this._document.StructuralCache.IsFormattingInProgress = true;
                num = 0;
                try
                {
                    while (!this._brt.GetPageNumberForContentPosition(textPointer, ref num))
                    {
                        if (this._brt.IsClean)
                        {
                            num = -1;
                            break;
                        }
                        this.FormatPage(num);
                    }
                }
                finally
                {
                    this._document.StructuralCache.IsFormattingInProgress = false;
                }
            }
            return(num);
        }
Ejemplo n.º 11
0
        //Splits { <value>:<value>, <value>:<value> } and [ <value>, <value> ] into a list of <value> strings
        static List <ContentPosition> Split(string json)
        {
            List <ContentPosition> splitArray = new List <ContentPosition>();

            if (json.Length == 2)
            {
                return(splitArray);
            }
            int             parseDepth = 0;
            ContentPosition current    = new ContentPosition();

            for (int i = 1; i < json.Length - 1; i++)
            {
                switch (json[i])
                {
                case '[':
                case '{':
                    parseDepth++;
                    break;

                case ']':
                case '}':
                    parseDepth--;
                    break;

                case '"':
                    i = current.AppendUntilStringEnd(true, i, json);
                    continue;

                case ',':
                case ':':
                    if (parseDepth == 0)
                    {
                        splitArray.Add(current);
                        current = new ContentPosition();
                        continue;
                    }
                    break;
                }

                current.Append(i);
            }

            splitArray.Add(current);

            return(splitArray);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Async version of <see cref="DynamicDocumentPaginator.GetPageNumber"/>
        /// </summary>
        /// <param name="contentPosition">Content position.</param>
        /// <param name="userState">Unique identifier for the asynchronous task.</param>
        /// <exception cref="ArgumentException">
        /// Throws ArgumentException if the ContentPosition does not exist within
        /// this element’s tree.
        /// </exception>
        public override void GetPageNumberAsync(ContentPosition contentPosition, object userState)
        {
            // Content position cannot be null.
            if (contentPosition == null)
            {
                throw new ArgumentNullException("contentPosition");
            }
            // Content position cannot be Missing.
            if (contentPosition == ContentPosition.Missing)
            {
                throw new ArgumentException(SR.Get(SRID.IDPInvalidContentPosition), "contentPosition");
            }

            // ContentPosition must be of appropriate type and must be part of
            // the content.
            TextPointer flowContentPosition = contentPosition as TextPointer;

            if (flowContentPosition == null)
            {
                throw new ArgumentException(SR.Get(SRID.IDPInvalidContentPosition), "contentPosition");
            }
            if (flowContentPosition.TextContainer != _document.StructuralCache.TextContainer)
            {
                throw new ArgumentException(SR.Get(SRID.IDPInvalidContentPosition), "contentPosition");
            }

            int pageNumber = 0;

            if (!_backgroundPagination)
            {
                pageNumber = GetPageNumber(contentPosition);
                OnGetPageNumberCompleted(new GetPageNumberCompletedEventArgs(contentPosition, pageNumber, null, false, userState));
            }
            else
            {
                if (_brt.GetPageNumberForContentPosition(flowContentPosition, ref pageNumber))
                {
                    OnGetPageNumberCompleted(new GetPageNumberCompletedEventArgs(contentPosition, pageNumber, null, false, userState));
                }
                else
                {
                    _asyncRequests.Add(new GetPageNumberAsyncRequest(flowContentPosition, userState, this));
                    InitiateNextAsyncOperation();
                }
            }
        }
Ejemplo n.º 13
0
        // Dock

        public static SW.Controls.Dock ToWpfDock(ContentPosition value)
        {
            if (value == ContentPosition.Left)
            {
                return(SW.Controls.Dock.Left);
            }
            if (value == ContentPosition.Top)
            {
                return(SW.Controls.Dock.Top);
            }
            if (value == ContentPosition.Bottom)
            {
                return(SW.Controls.Dock.Bottom);
            }

            return(SW.Controls.Dock.Right);
        }
Ejemplo n.º 14
0
        public void SetContent(string label, object imageBackend, ContentPosition imagePosition)
        {
            Widget.Title = label;
            if (imageBackend != null)
            {
                Widget.Image = (NSImage)imageBackend;
                switch (imagePosition)
                {
                case ContentPosition.Bottom: Widget.ImagePosition = NSCellImagePosition.ImageBelow; break;

                case ContentPosition.Left: Widget.ImagePosition = NSCellImagePosition.ImageLeft; break;

                case ContentPosition.Right: Widget.ImagePosition = NSCellImagePosition.ImageRight; break;

                case ContentPosition.Top: Widget.ImagePosition = NSCellImagePosition.ImageAbove; break;
                }
            }
            Widget.SizeToFit();
        }
Ejemplo n.º 15
0
        public PageDesignFolderContent(ContentPosition pos)
            : base(pos)
        {
            this.Parameter.Add("ContentPositionType", pos.Type.ToString());
            var dataRule = pos.DataRule as FolderDataRule;

            if (dataRule != null)
            {
                var dataRuleJson = new
                {
                    FolderName   = dataRule.FolderName,
                    Top          = dataRule.Top,
                    WhereClauses = dataRule.WhereClauses
                };
                var serializer         = new JavaScriptSerializer();
                var dataRuleJsonString = serializer.Serialize(dataRuleJson);
                this.Parameter.Add("DataRule", PageDesignContent.Code(dataRuleJsonString));
            }
        }
Ejemplo n.º 16
0
		public void SetContent (string label, bool useMnemonic, ImageDescription image, ContentPosition imagePosition)
		{
			switch (((Button)Frontend).Type) {
			case ButtonType.Help:
			case ButtonType.Disclosure:
				return;
			}
			if (useMnemonic)
				label = label.RemoveMnemonic ();
			if (customLabelColor.HasValue) {
				Widget.Title = label;
				var ns = new NSMutableAttributedString (Widget.AttributedTitle);
				ns.BeginEditing ();
				var r = new NSRange (0, label.Length);
				ns.RemoveAttribute (NSStringAttributeKey.ForegroundColor, r);
				ns.AddAttribute (NSStringAttributeKey.ForegroundColor, customLabelColor.Value.ToNSColor (), r);
				ns.EndEditing ();
				Widget.AttributedTitle = ns;
			} else
				Widget.Title = label ?? "";
			if (string.IsNullOrEmpty (label))
				imagePosition = ContentPosition.Center;
			if (!image.IsNull) {
				var img = image.ToNSImage ();
				Widget.Image = (NSImage)img;
				Widget.Cell.ImageScale = NSImageScale.None;
				switch (imagePosition) {
				case ContentPosition.Bottom: Widget.ImagePosition = NSCellImagePosition.ImageBelow; break;
				case ContentPosition.Left: Widget.ImagePosition = NSCellImagePosition.ImageLeft; break;
				case ContentPosition.Right: Widget.ImagePosition = NSCellImagePosition.ImageRight; break;
				case ContentPosition.Top: Widget.ImagePosition = NSCellImagePosition.ImageAbove; break;
				case ContentPosition.Center: Widget.ImagePosition = string.IsNullOrEmpty (label) ? NSCellImagePosition.ImageOnly : NSCellImagePosition.ImageOverlaps; break;
				}
			} else {
				Widget.ImagePosition = NSCellImagePosition.NoImage;
				Widget.Image = null;
			}
			SetButtonStyle (currentStyle);
			ResetFittingSize ();
		}
Ejemplo n.º 17
0
        protected virtual IHtmlString RenderContentPosition(ContentPosition contentPosition)
        {
            var site       = this.PageContext.PageRequestContext.Site;
            var repository = site.GetRepository();

            if (repository == null)
            {
                throw new KoobooException("The repository for site is null.");
            }
            var dataRule        = (IContentDataRule)(contentPosition.DataRule);
            var dataRuleContext = new DataRuleContext(this.PageContext.PageRequestContext.Site,
                                                      this.PageContext.PageRequestContext.Page)
            {
                ValueProvider = this.PageContext.PageRequestContext.GetValueProvider()
            };

            string        viewPath = "";
            TakeOperation operation;
            var           schema = dataRule.GetSchema(repository);

            switch (contentPosition.Type)
            {
            case ContentPositionType.Detail:
                viewPath  = schema.GetFormTemplate(FormType.Detail);
                operation = TakeOperation.First;
                break;

            case ContentPositionType.List:
            default:
                viewPath  = schema.GetFormTemplate(FormType.List);
                operation = TakeOperation.List;
                break;
            }
            var model = dataRule.Execute(dataRuleContext, operation, 0);

            return(ViewRender.RenderViewInternal(this.Html, viewPath, null, model));
        }
Ejemplo n.º 18
0
        public void SetContent(string label, object imageBackend, ContentPosition position)
        {
            if (imageBackend == null)
            {
                Button.Content = label;
            }
            else if (String.IsNullOrEmpty(label))
            {
                Button.Content = new SWC.Image {
                    Source = DataConverter.AsImageSource(imageBackend)
                }
            }
            ;
            else
            {
                SWC.DockPanel grid = new SWC.DockPanel();

                var       img       = DataConverter.AsImageSource(imageBackend);
                SWC.Image imageCtrl = new SWC.Image
                {
                    Source = img,
                    Width  = img.Width,
                    Height = img.Height
                };

                SWC.DockPanel.SetDock(imageCtrl, DataConverter.ToWpfDock(position));
                grid.Children.Add(imageCtrl);

                SWC.Label labelCtrl = new SWC.Label();
                labelCtrl.Content = label;
                grid.Children.Add(labelCtrl);

                Button.Content = grid;
            }
            Button.InvalidateMeasure();
        }
Ejemplo n.º 19
0
        // Token: 0x06007011 RID: 28689 RVA: 0x002030AC File Offset: 0x002012AC
        public override void GetPageNumberAsync(ContentPosition contentPosition, object userState)
        {
            if (contentPosition == null)
            {
                throw new ArgumentNullException("contentPosition");
            }
            if (contentPosition == ContentPosition.Missing)
            {
                throw new ArgumentException(SR.Get("IDPInvalidContentPosition"), "contentPosition");
            }
            TextPointer textPointer = contentPosition as TextPointer;

            if (textPointer == null)
            {
                throw new ArgumentException(SR.Get("IDPInvalidContentPosition"), "contentPosition");
            }
            if (textPointer.TextContainer != this._document.StructuralCache.TextContainer)
            {
                throw new ArgumentException(SR.Get("IDPInvalidContentPosition"), "contentPosition");
            }
            int pageNumber = 0;

            if (!this._backgroundPagination)
            {
                pageNumber = this.GetPageNumber(contentPosition);
                this.OnGetPageNumberCompleted(new GetPageNumberCompletedEventArgs(contentPosition, pageNumber, null, false, userState));
                return;
            }
            if (this._brt.GetPageNumberForContentPosition(textPointer, ref pageNumber))
            {
                this.OnGetPageNumberCompleted(new GetPageNumberCompletedEventArgs(contentPosition, pageNumber, null, false, userState));
                return;
            }
            this._asyncRequests.Add(new FlowDocumentPaginator.GetPageNumberAsyncRequest(textPointer, userState, this));
            this.InitiateNextAsyncOperation();
        }
Ejemplo n.º 20
0
        public void SetContent(string label, bool useMnemonic, ImageDescription image, ContentPosition imagePosition)
        {
            switch (((Button)Frontend).Type)
            {
            case ButtonType.Help:
            case ButtonType.Disclosure:
                return;
            }
            if (useMnemonic)
            {
                label = label.RemoveMnemonic();
            }
            Widget.Title = label ?? "";
            if (string.IsNullOrEmpty(label))
            {
                imagePosition = ContentPosition.Center;
            }
            if (!image.IsNull)
            {
                var img = image.ToNSImage();
                Widget.Image           = (NSImage)img;
                Widget.Cell.ImageScale = NSImageScale.None;
                switch (imagePosition)
                {
                case ContentPosition.Bottom: Widget.ImagePosition = NSCellImagePosition.ImageBelow; break;

                case ContentPosition.Left: Widget.ImagePosition = NSCellImagePosition.ImageLeft; break;

                case ContentPosition.Right: Widget.ImagePosition = NSCellImagePosition.ImageRight; break;

                case ContentPosition.Top: Widget.ImagePosition = NSCellImagePosition.ImageAbove; break;

                case ContentPosition.Center: Widget.ImagePosition = string.IsNullOrEmpty(label) ? NSCellImagePosition.ImageOnly : NSCellImagePosition.ImageOverlaps; break;
                }
            }
            ResetFittingSize();
        }
Ejemplo n.º 21
0
        public void SetContent(string label, bool useMnemonic, ImageDescription image, ContentPosition position)
        {
            Widget.UseUnderline = useMnemonic;
            this.image          = image;

            if (label != null && label.Length == 0)
            {
                label = null;
            }

            Button b = (Button)Frontend;

            if (label != null && image.Backend == null && b.Type == ButtonType.Normal)
            {
                Widget.Label = label;
                return;
            }

            if (b.Type == ButtonType.Disclosure)
            {
                Widget.Label = null;
                Widget.Image = new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out);
                Widget.Image.ShowAll();
                return;
            }

            Gtk.Widget contentWidget = null;

            Gtk.Widget imageWidget = null;
            if (image.Backend != null)
            {
                imageWidget = new ImageBox(ApplicationContext, image.WithDefaultSize(Gtk.IconSize.Button));
            }

            Gtk.Label labelWidget = null;

            if (label != null && imageWidget == null)
            {
                contentWidget = labelWidget = new Gtk.Label(label);
            }
            else if (label == null && imageWidget != null)
            {
                contentWidget = imageWidget;
            }
            else if (label != null && imageWidget != null)
            {
                Gtk.Box box = position == ContentPosition.Left || position == ContentPosition.Right ? (Gtk.Box) new Gtk.HBox(false, 3) : (Gtk.Box) new Gtk.VBox(false, 3);
                labelWidget = new Gtk.Label(label)
                {
                    UseUnderline = useMnemonic
                };

                if (position == ContentPosition.Left || position == ContentPosition.Top)
                {
                    box.PackStart(imageWidget, false, false, 0);
                    box.PackStart(labelWidget, false, false, 0);
                }
                else
                {
                    box.PackStart(labelWidget, false, false, 0);
                    box.PackStart(imageWidget, false, false, 0);
                }

                contentWidget = box;
            }
            var expandButtonContent = false;

            if (b.Type == ButtonType.DropDown)
            {
                if (contentWidget != null)
                {
                    Gtk.HBox box = new Gtk.HBox(false, 3);
                    box.PackStart(contentWidget, true, true, 3);
                    box.PackStart(new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out), false, false, 0);
                    contentWidget       = box;
                    expandButtonContent = true;
                }
                else
                {
                    contentWidget = new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out);
                }
            }
            if (contentWidget != null)
            {
                contentWidget.ShowAll();
                Widget.Label = null;
                Widget.Image = contentWidget;
                if (expandButtonContent)
                {
                    var alignment = Widget.Child as Gtk.Alignment;
                    if (alignment != null)
                    {
                        var box = alignment.Child as Gtk.Box;
                        if (box != null)
                        {
                            alignment.Xscale = 1;
                            box.SetChildPacking(box.Children [0], true, true, 0, Gtk.PackType.Start);
                            if (labelWidget != null)
                            {
                                labelWidget.Xalign = 0;
                            }
                        }
                    }
                }
                if (labelWidget != null)
                {
                    labelWidget.UseUnderline = useMnemonic;
                    if (customFont != null)
                    {
                        labelWidget.ModifyFont(customFont);
                    }
                }
            }
            else
            {
                Widget.Label = null;
            }
        }
Ejemplo n.º 22
0
        public void SetContent(string label, bool useMnemonic, ImageDescription image, ContentPosition position)
        {
            var accessText = new SWC.AccessText ();
            accessText.Text = label;
            if (image.IsNull)
                if (useMnemonic)
                    Button.Content = accessText;
                else
                    Button.Content = accessText.Text.Replace ("_", "__");
            else {
                SWC.DockPanel grid = new SWC.DockPanel ();

                var imageCtrl = new ImageBox (Context);
                imageCtrl.ImageSource = image;

                SWC.DockPanel.SetDock (imageCtrl, DataConverter.ToWpfDock (position));
                grid.Children.Add (imageCtrl);

                if (!string.IsNullOrEmpty (label)) {
                    SWC.Label labelCtrl = new SWC.Label ();
                    if (useMnemonic)
                        labelCtrl.Content = accessText;
                    else
                        labelCtrl.Content = label;
                    labelCtrl.SetBinding (SWC.Label.ForegroundProperty, new Binding ("Foreground") { Source = Button });
                    grid.Children.Add (labelCtrl);
                }
                Button.Content = grid;
            }
            Button.InvalidateMeasure ();
        }
Ejemplo n.º 23
0
        public void SetContent(string label, object imageBackend, ContentPosition position)
        {
            if (label != null && label.Length == 0)
                label = null;

            Button b = (Button) Frontend;
            if (label != null && imageBackend == null && b.Type == ButtonType.Normal) {
                Widget.Label = label;
                return;
            }

            if (b.Type == ButtonType.Disclosure) {
                Widget.Label = null;
                Widget.Image = new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out);
                Widget.Image.ShowAll ();
                return;
            }

            Gtk.Widget contentWidget = null;

            Gtk.Widget imageWidget = null;
            if (imageBackend != null)
                imageWidget = new Gtk.Image ((Gdk.Pixbuf)imageBackend);

            if (label != null && imageWidget == null) {
                contentWidget = new Gtk.Label (label);
            }
            else if (label == null && imageWidget != null) {
                contentWidget = imageWidget;
            }
            else if (label != null && imageWidget != null) {
                Gtk.Box box = position == ContentPosition.Left || position == ContentPosition.Right ? (Gtk.Box) new Gtk.HBox (false, 3) : (Gtk.Box) new Gtk.VBox (false, 3);
                var lab = new Gtk.Label (label);

                if (position == ContentPosition.Left || position == ContentPosition.Top) {
                    box.PackStart (imageWidget, false, false, 0);
                    box.PackStart (lab, false, false, 0);
                } else {
                    box.PackStart (lab, false, false, 0);
                    box.PackStart (imageWidget, false, false, 0);
                }

                contentWidget = box;
            }
            if (b.Type == ButtonType.DropDown) {
                if (contentWidget != null) {
                    Gtk.HBox box = new Gtk.HBox (false, 3);
                    box.PackStart (contentWidget, true, true, 0);
                    box.PackStart (new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out), false, false, 0);
                    contentWidget = box;
                } else
                    contentWidget = new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out);
            }
            if (contentWidget != null) {
                contentWidget.ShowAll ();
                Widget.Label = null;
                Widget.Image = contentWidget;
            } else
                Widget.Label = null;
        }
Ejemplo n.º 24
0
        public void SetContent(string label, object imageBackend, ContentPosition position)
        {
            if (imageBackend == null)
            {
                Button.Content = label;
            }
            else
            {
                SWC.DockPanel grid = new SWC.DockPanel ();

                var img = (SWMI.BitmapSource)imageBackend;
                SWC.Image imageCtrl = new SWC.Image
                {
                    Source = img,
                    Width = img.Width,
                    Height = img.Height
                };

                SWC.DockPanel.SetDock (imageCtrl, DataConverter.ToWpfDock (position));
                grid.Children.Add (imageCtrl);

                SWC.Label labelCtrl = new SWC.Label ();
                labelCtrl.Content = label;
                grid.Children.Add (labelCtrl);

                Button.Content = grid;
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Returns the page number on which the ContentPosition appears.
        /// </summary>
        /// <param name="contentPosition">Content position.</param>
        /// <returns>
        /// Returns the page number on which the ContentPosition appears.
        /// </returns>
        /// <exception cref="ArgumentException">
        /// Throws ArgumentException if the ContentPosition does not exist within
        /// this element's tree.
        /// </exception>
        public override int GetPageNumber(ContentPosition contentPosition)
        {
            TextPointer flowContentPosition;
            int         pageNumber;

            // Ensure usage from just one Dispatcher object.
            // FlowDocumentPaginator runs its own layout, hence there is a need
            // to protect it from random access from other threads.
            _dispatcherObject.VerifyAccess();

            // ContentPosition cannot be null.
            if (contentPosition == null)
            {
                throw new ArgumentNullException("contentPosition");
            }
            // ContentPosition must be of appropriate type and must be part of
            // the content.
            flowContentPosition = contentPosition as TextPointer;
            if (flowContentPosition == null)
            {
                throw new ArgumentException(SR.Get(SRID.IDPInvalidContentPosition), "contentPosition");
            }
            if (flowContentPosition.TextContainer != _document.StructuralCache.TextContainer)
            {
                throw new ArgumentException(SR.Get(SRID.IDPInvalidContentPosition), "contentPosition");
            }

            // We are about to perform synchronous pagination, so need to check for
            // reentrancy.
            if (_document.StructuralCache.IsFormattingInProgress)
            {
                throw new InvalidOperationException(SR.Get(SRID.FlowDocumentFormattingReentrancy));
            }
            if (_document.StructuralCache.IsContentChangeInProgress)
            {
                throw new InvalidOperationException(SR.Get(SRID.TextContainerChangingReentrancyInvalid));
            }

            // Disable processing of the queue during blocking operations to prevent unrelated reentrancy.
            using (_document.Dispatcher.DisableProcessing())
            {
                _document.StructuralCache.IsFormattingInProgress = true; // Set reentrancy flag.
                pageNumber = 0;
                try
                {
                    while (!_brt.GetPageNumberForContentPosition(flowContentPosition, ref pageNumber))
                    {
                        // If failed to get PageNumber and BreakRecordTable is clean,
                        // the input ContentPosition does not belong to the content.
                        // But according to check above, it does belong to the content.
                        // Break and return -1 in this case
                        if (_brt.IsClean)
                        {
                            pageNumber = -1;
                            break;
                        }

                        // Do synchronous pagination for the next missing page number.
                        FormatPage(pageNumber);
                    }
                }
                finally
                {
                    _document.StructuralCache.IsFormattingInProgress = false; // Clear reentrancy flag.
                }
            }

            return(pageNumber);
        }
Ejemplo n.º 26
0
 public void SetContent(string label, bool useMnemonic, ImageDescription image, ContentPosition position)
 {
     SetContent(label, useMnemonic, image, position, false);
 }
Ejemplo n.º 27
0
        public void SetContent(string label, ImageDescription image, ContentPosition position)
        {
            if (image.IsNull)
                Button.Content = label;
            else
            {
                SWC.DockPanel grid = new SWC.DockPanel ();

                var imageCtrl = new ImageBox (Context);
                imageCtrl.ImageSource = image;

                SWC.DockPanel.SetDock (imageCtrl, DataConverter.ToWpfDock (position));
                grid.Children.Add (imageCtrl);

                if (!string.IsNullOrEmpty (label)) {
                    SWC.Label labelCtrl = new SWC.Label ();
                    labelCtrl.Content = label;
                    grid.Children.Add (labelCtrl);
                }
                Button.Content = grid;
            }
            Button.InvalidateMeasure ();
        }
Ejemplo n.º 28
0
		public void SetContent (string label, bool useMnemonic, ImageDescription image, ContentPosition position)
		{			
			Widget.UseUnderline = useMnemonic;
			this.image = image;

			if (label != null && label.Length == 0)
				label = null;
			
			Button b = (Button) Frontend;
			if (label != null && image.Backend == null && b.Type == ButtonType.Normal) {
				Widget.Label = label;
				return;
			}
			
			if (b.Type == ButtonType.Disclosure) {
				Widget.Label = null;
				Widget.Image = new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out);
				Widget.Image.ShowAll ();
				return;
			}
			
			Gtk.Widget contentWidget = null;
			
			Gtk.Widget imageWidget = null;
			if (image.Backend != null)
				imageWidget = new ImageBox (ApplicationContext, image.WithDefaultSize (Gtk.IconSize.Button));

			Gtk.Label labelWidget = null;

			if (label != null && imageWidget == null) {
				contentWidget = labelWidget = new Gtk.Label (label);
			}
			else if (label == null && imageWidget != null) {
				contentWidget = imageWidget;
			}
			else if (label != null && imageWidget != null) {
				Gtk.Box box = position == ContentPosition.Left || position == ContentPosition.Right ? (Gtk.Box) new Gtk.HBox (false, 3) : (Gtk.Box) new Gtk.VBox (false, 3);
				labelWidget = new Gtk.Label (label) { UseUnderline = useMnemonic };
				
				if (position == ContentPosition.Left || position == ContentPosition.Top) {
					box.PackStart (imageWidget, false, false, 0);
					box.PackStart (labelWidget, false, false, 0);
				} else {
					box.PackStart (labelWidget, false, false, 0);
					box.PackStart (imageWidget, false, false, 0);
				}
				
				contentWidget = box;
			}
			var expandButtonContent = false;
			if (b.Type == ButtonType.DropDown) {
				if (contentWidget != null) {
					Gtk.HBox box = new Gtk.HBox (false, 3);
					box.PackStart (contentWidget, true, true, 3);
					box.PackStart (new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out), false, false, 0);
					contentWidget = box;
					expandButtonContent = true;
				} else
					contentWidget = new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out);
			}
			if (contentWidget != null) {
				contentWidget.ShowAll ();
				Widget.Label = null;
				Widget.Image = contentWidget;
				if (expandButtonContent) {
					var alignment = Widget.Child as Gtk.Alignment;
					if (alignment != null) {
						var box = alignment.Child as Gtk.Box;
						if (box != null) {
							alignment.Xscale = 1;
							box.SetChildPacking (box.Children [0], true, true, 0, Gtk.PackType.Start);
							if (labelWidget != null)
								labelWidget.Xalign = 0;
						}
					}
				}
				if (labelWidget != null) {
					labelWidget.UseUnderline = useMnemonic;
					if (customFont != null)
						labelWidget.ModifyFont (customFont);
				}
			} else
				Widget.Label = null;
		}
Ejemplo n.º 29
0
        public void SetContent(string label, object imageBackend, ContentPosition position)
        {
            if (imageBackend == null)
                Button.Content = label;
            else
            {
                SWC.DockPanel grid = new SWC.DockPanel ();

                var img = DataConverter.AsImageSource (imageBackend);
                SWC.Image imageCtrl = new SWC.Image
                {
                    Source = img,
                    Width = img.Width,
                    Height = img.Height
                };

                SWC.DockPanel.SetDock (imageCtrl, DataConverter.ToWpfDock (position));
                grid.Children.Add (imageCtrl);

                if (!string.IsNullOrEmpty (label)) {
                    SWC.Label labelCtrl = new SWC.Label ();
                    labelCtrl.Content = label;
                    grid.Children.Add (labelCtrl);
                }
                Button.Content = grid;
            }
            Button.InvalidateMeasure ();
        }
Ejemplo n.º 30
0
        // public method
        public static List <PagePosition> ParsePagePositions(string clientJson)
        {
            clientJson = HttpUtility.UrlDecode(clientJson);

            var positions = new List <PagePosition>();
            var list      = ParseJson <List <Dictionary <string, object> > >(clientJson);

            foreach (var item in list)
            {
                PagePosition pos = null;
                var          t   = item.Str("Type");
                if (t == PageDesignViewContent.TypeKey)
                {
                    bool skipError = false;
                    bool.TryParse(item.Str("SkipError"), out skipError);
                    pos = new ViewPosition()
                    {
                        ViewName    = item.Str("ViewName"),
                        SkipError   = skipError,
                        Parameters  = ParseViewParameters(item.Str("Parameters")),
                        OutputCache = ParseJson <CacheSettings>(item.Str("OutputCache"))
                    };
                }
                else if (t == PageDesignModuleContent.TypeKey)
                {
                    bool skipError = false;
                    bool.TryParse(item.Str("SkipError"), out skipError);
                    pos = new ModulePosition()
                    {
                        ModuleName = item.Str("ModuleName"),
                        SkipError  = skipError,
                        Exclusive  = (item.Str("Exclusive") == "true"),
                        Entry      = ParseModuleEntry(item)
                    };
                }
                else if (t == PageDesignFolderContent.TypeKey)
                {
                    pos = new ContentPosition()
                    {
                        Type     = ParseEnum <ContentPositionType>(item.Str("ContentPositionType")),
                        DataRule = ParseJson <FolderDataRule>(item.Str("DataRule"))
                    };
                }
                else if (t == PageDesignHtmlContent.TypeKey)
                {
                    pos = new HtmlPosition()
                    {
                        Html = item.Str("Html")
                    };
                }
                else if (t == PageDesignHtmlBlockContent.TypeKey)
                {
                    pos = new HtmlBlockPosition()
                    {
                        BlockName = item.Str("BlockName")
                    };
                }
                else if (t == PageDesignProxyContent.TypeKey)
                {
                    pos = new ProxyPosition()
                    {
                        Host        = item.Str("Host"),
                        RequestPath = item.Str("RequestPath"),
                        NoProxy     = item.Str("NoProxy") == "true",
                        //ProxyStylesheet = item.Str("ProxyStylesheet") == "true",
                        OutputCache = ParseJson <CacheSettings>(item.Str("OutputCache"))
                    };
                }
                // add
                if (pos != null)
                {
                    pos.LayoutPositionId = item.Str("LayoutPositionId");
                    pos.PagePositionId   = item.Str("PagePositionId");
                    pos.Order            = item.Int("Order");
                    positions.Add(pos);
                }
            }
            // ret
            return(positions);
        }
Ejemplo n.º 31
0
        // public method
        public static List <PagePosition> ParsePagePositions(string clientJson)
        {
            clientJson = HttpUtility.UrlDecode(clientJson);

            var positions = new List <PagePosition>();
            var list      = ParseJson <List <Dictionary <string, object> > >(clientJson);

            foreach (var item in list)
            {
                PagePosition pos = null;
                var          t   = item.Str("Type");
                if (t == PageDesignViewContent.TypeKey)
                {
                    pos = new ViewPosition()
                    {
                        ViewName    = item.Str("ViewName"),
                        Parameters  = ParseViewParameters(item.Str("Parameters")),
                        OutputCache = ParseJson <CacheSettings>(item.Str("OutputCache"))
                    };
                }
                else if (t == PageDesignModuleContent.TypeKey)
                {
                    pos = new ModulePosition()
                    {
                        ModuleName = item.Str("ModuleName"),
                        Exclusive  = (item.Str("Exclusive") == "true"),
                        Entry      = ParseModuleEntry(item.Str("EntryAction"), item.Str("EntryController"))
                    };
                }
                else if (t == PageDesignFolderContent.TypeKey)
                {
                    pos = new ContentPosition()
                    {
                        Type     = ParseEnum <ContentPositionType>(item.Str("ContentPositionType")),
                        DataRule = ParseJson <FolderDataRule>(item.Str("DataRule"))
                    };
                }
                else if (t == PageDesignHtmlContent.TypeKey)
                {
                    pos = new HtmlPosition()
                    {
                        Html = item.Str("Html")
                    };
                }
                else if (t == PageDesignHtmlBlockContent.TypeKey)
                {
                    pos = new HtmlBlockPosition()
                    {
                        BlockName = item.Str("BlockName")
                    };
                }
                // add
                if (pos != null)
                {
                    pos.LayoutPositionId = item.Str("LayoutPositionId");
                    pos.PagePositionId   = item.Str("PagePositionId");
                    pos.Order            = item.Int("Order");
                    positions.Add(pos);
                }
            }
            // ret
            return(positions);
        }
 // Token: 0x06006FDE RID: 28638 RVA: 0x0020279B File Offset: 0x0020099B
 public override int GetPageNumber(ContentPosition contentPosition)
 {
     return(this._document.GetPageNumber(contentPosition));
 }
Ejemplo n.º 33
0
        public void SetContent(string label, object imageBackend, ContentPosition position)
        {
            if (label != null && label.Length == 0)
            {
                label = null;
            }

            Button b = (Button)Frontend;

            if (label != null && imageBackend == null && b.Type == ButtonType.Normal)
            {
                Widget.Label = label;
                return;
            }

            if (b.Type == ButtonType.Disclosure)
            {
                Widget.Label = null;
                Widget.Image = new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out);
                Widget.Image.ShowAll();
                return;
            }

            Gtk.Widget contentWidget = null;

            Gtk.Widget imageWidget = null;
            if (imageBackend != null)
            {
                imageWidget = new Gtk.Image((Gdk.Pixbuf)imageBackend);
            }

            if (label != null && imageWidget == null)
            {
                contentWidget = new Gtk.Label(label);
            }
            else if (label == null && imageWidget != null)
            {
                contentWidget = imageWidget;
            }
            else if (label != null && imageWidget != null)
            {
                Gtk.Box box = position == ContentPosition.Left || position == ContentPosition.Right ? (Gtk.Box) new Gtk.HBox(false, 3) : (Gtk.Box) new Gtk.VBox(false, 3);
                var     lab = new Gtk.Label(label);

                if (position == ContentPosition.Left || position == ContentPosition.Top)
                {
                    box.PackStart(imageWidget, false, false, 0);
                    box.PackStart(lab, false, false, 0);
                }
                else
                {
                    box.PackStart(lab, false, false, 0);
                    box.PackStart(imageWidget, false, false, 0);
                }

                contentWidget = box;
            }
            if (b.Type == ButtonType.DropDown)
            {
                if (contentWidget != null)
                {
                    Gtk.HBox box = new Gtk.HBox(false, 3);
                    box.PackStart(contentWidget, true, true, 3);
                    box.PackStart(new Gtk.VSeparator(), true, true, 0);
                    box.PackStart(new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out), false, false, 0);
                    contentWidget = box;
                }
                else
                {
                    contentWidget = new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out);
                }
            }
            if (contentWidget != null)
            {
                contentWidget.ShowAll();
                Widget.Label = null;
                Widget.Image = contentWidget;
            }
            else
            {
                Widget.Label = null;
            }
        }
Ejemplo n.º 34
0
        public void SetContent(string label, bool useMnemonic, ImageDescription image, ContentPosition position)
        {
            var accessText = new SWC.AccessText();

            accessText.Text = label;
            if (image.IsNull)
            {
                if (useMnemonic)
                {
                    Button.Content = accessText;
                }
                else
                {
                    Button.Content = accessText.Text.Replace("_", "__");
                }
            }
            else
            {
                SWC.DockPanel grid = new SWC.DockPanel();

                var imageCtrl = new ImageBox(Context);
                imageCtrl.ImageSource = image;

                SWC.DockPanel.SetDock(imageCtrl, DataConverter.ToWpfDock(position));
                grid.Children.Add(imageCtrl);

                if (!string.IsNullOrEmpty(label))
                {
                    SWC.Label labelCtrl = new SWC.Label();
                    if (useMnemonic)
                    {
                        labelCtrl.Content = accessText;
                    }
                    else
                    {
                        labelCtrl.Content = label;
                    }
                    labelCtrl.SetBinding(SWC.Label.ForegroundProperty, new Binding("Foreground")
                    {
                        Source = Button
                    });
                    grid.Children.Add(labelCtrl);
                }
                Button.Content = grid;
            }
            Button.InvalidateMeasure();
        }
Ejemplo n.º 35
0
        public void SetContent(string label, bool useMnemonic, ImageDescription image, ContentPosition position)
        {
            Widget.UseUnderline = useMnemonic;
            this.image = image;

            if (label != null && label.Length == 0)
                label = null;

            Button b = (Button) Frontend;
            if (label != null && image.Backend == null && b.Type == ButtonType.Normal) {
                Widget.Label = label;
                return;
            }

            if (b.Type == ButtonType.Disclosure) {
                Widget.Label = null;
                Widget.Image = new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out);
                Widget.Image.ShowAll ();
                return;
            }

            Gtk.Widget contentWidget = null;

            Gtk.Widget imageWidget = null;
            if (image.Backend != null)
                imageWidget = new ImageBox (ApplicationContext, image.WithDefaultSize (Gtk.IconSize.Button));

            labelWidget = null;

            if (label != null && imageWidget == null) {
                contentWidget = labelWidget = new Gtk.Label (label);
            }
            else if (label == null && imageWidget != null) {
                contentWidget = imageWidget;
            }
            else if (label != null && imageWidget != null) {
                Gtk.Box box = position == ContentPosition.Left || position == ContentPosition.Right ? (Gtk.Box) new Gtk.HBox (false, 3) : (Gtk.Box) new Gtk.VBox (false, 3);
                labelWidget = new Gtk.Label (label) { UseUnderline = useMnemonic };

                if (position == ContentPosition.Left || position == ContentPosition.Top) {
                    box.PackStart (imageWidget, false, false, 0);
                    box.PackStart (labelWidget, false, false, 0);
                } else {
                    box.PackStart (labelWidget, false, false, 0);
                    box.PackStart (imageWidget, false, false, 0);
                }

                contentWidget = box;
            }
            var expandButtonContent = false;
            if (b.Type == ButtonType.DropDown) {
                if (contentWidget != null) {
                    Gtk.HBox box = new Gtk.HBox (false, 3);
                    box.PackStart (contentWidget, true, true, 3);
                    box.PackStart (new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out), false, false, 0);
                    contentWidget = box;
                    expandButtonContent = true;
                } else
                    contentWidget = new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out);
            }
            if (contentWidget != null) {
                contentWidget.ShowAll ();
                Widget.Label = null;
                Widget.Image = contentWidget;
                var alignment = Widget.Child as Gtk.Alignment;
                if (alignment != null) {
                    if (expandButtonContent) {
                        var box = alignment.Child as Gtk.Box;
                        if (box != null) {
                            alignment.Xscale = 1;
                            box.SetChildPacking (box.Children [0], true, true, 0, Gtk.PackType.Start);
                            if (labelWidget != null)
                                labelWidget.Xalign = 0;
                        }
                    } else if (position == ContentPosition.Left && (contentWidget is Gtk.Box)) {
                        // in case the button is wider than its natural size and has text and an image on the left,
                        // optimize its alignment to make the text more centered.
                        // FIXME: more sophisticated size calculation
                        alignment.Xalign = 0.475f;
                    }
                }
                if (labelWidget != null) {
                    labelWidget.UseUnderline = useMnemonic;
                    if (customFont != null)
                        labelWidget.ModifyFont (customFont);
                    if (customLabelColor.HasValue) {
                        labelWidget.SetForegroundColor (customLabelColor.Value);
                        labelWidget.SetForegroundColor (Gtk.StateType.Prelight, customLabelColor.Value);
                    }
                }
            } else
                Widget.Label = null;
        }
Ejemplo n.º 36
0
        public void SetContent(string label, bool useMnemonic, ImageDescription image, ContentPosition position)
        {
            Widget.UseUnderline = useMnemonic;
            this.image = image;

            if (label != null && label.Length == 0)
                label = null;

            Button b = (Button) Frontend;
            if (label != null && image.Backend == null && b.Type == ButtonType.Normal) {
                Widget.Label = label;
                return;
            }

            if (b.Type == ButtonType.Disclosure) {
                Widget.Label = null;
                Widget.Image = new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out);
                Widget.Image.ShowAll ();
                return;
            }

            Gtk.Widget contentWidget = null;

            Gtk.Widget imageWidget = null;
            if (image.Backend != null)
                imageWidget = new ImageBox (ApplicationContext, image.WithDefaultSize (Gtk.IconSize.Button));

            if (label != null && imageWidget == null) {
                contentWidget = new Gtk.Label (label) { UseUnderline = useMnemonic };
            }
            else if (label == null && imageWidget != null) {
                contentWidget = imageWidget;
            }
            else if (label != null && imageWidget != null) {
                Gtk.Box box = position == ContentPosition.Left || position == ContentPosition.Right ? (Gtk.Box) new Gtk.HBox (false, 3) : (Gtk.Box) new Gtk.VBox (false, 3);
                var lab = new Gtk.Label (label) { UseUnderline = useMnemonic };

                if (position == ContentPosition.Left || position == ContentPosition.Top) {
                    box.PackStart (imageWidget, false, false, 0);
                    box.PackStart (lab, false, false, 0);
                } else {
                    box.PackStart (lab, false, false, 0);
                    box.PackStart (imageWidget, false, false, 0);
                }

                contentWidget = box;
            }
            if (b.Type == ButtonType.DropDown) {
                if (contentWidget != null) {
                    Gtk.HBox box = new Gtk.HBox (false, 3);
                    box.PackStart (contentWidget, true, true, 3);
                    box.PackStart (new Gtk.VSeparator (), true, true, 0);
                    box.PackStart (new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out), false, false, 0);
                    contentWidget = box;
                } else
                    contentWidget = new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out);
            }
            if (contentWidget != null) {
                contentWidget.ShowAll ();
                Widget.Label = null;
                Widget.Image = contentWidget;
            } else
                Widget.Label = null;
        }
Ejemplo n.º 37
0
        public void SetContent(string label, bool useMnemonic, ImageDescription image, ContentPosition position)
        {
            Widget.UseUnderline = useMnemonic;
            this.image          = image;

            if (label != null && label.Length == 0)
            {
                label = null;
            }

            Button b = (Button)Frontend;

            if (label != null && image.Backend == null && b.Type == ButtonType.Normal)
            {
                Widget.Label = label;
                return;
            }

            if (b.Type == ButtonType.Disclosure)
            {
                Widget.Label = null;
                Widget.Image = new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out);
                Widget.Image.ShowAll();
                return;
            }

            Gtk.Widget contentWidget = null;

            Gtk.Widget imageWidget = null;
            if (image.Backend != null)
            {
                imageWidget = new ImageBox(ApplicationContext, image.WithDefaultSize(Gtk.IconSize.Button));
            }

            labelWidget = null;

            if (label != null && imageWidget == null)
            {
                contentWidget = labelWidget = new Gtk.Label(label);
            }
            else if (label == null && imageWidget != null)
            {
                contentWidget = imageWidget;
            }
            else if (label != null && imageWidget != null)
            {
                Gtk.Box box = position == ContentPosition.Left || position == ContentPosition.Right ? (Gtk.Box) new Gtk.HBox(false, 3) : (Gtk.Box) new Gtk.VBox(false, 3);
                labelWidget = new Gtk.Label(label)
                {
                    UseUnderline = useMnemonic
                };

                if (position == ContentPosition.Left || position == ContentPosition.Top)
                {
                    box.PackStart(imageWidget, false, false, 0);
                    box.PackStart(labelWidget, false, false, 0);
                }
                else
                {
                    box.PackStart(labelWidget, false, false, 0);
                    box.PackStart(imageWidget, false, false, 0);
                }

                contentWidget = box;
            }
            var expandButtonContent = false;

            if (b.Type == ButtonType.DropDown)
            {
                if (contentWidget != null)
                {
                    Gtk.HBox box = new Gtk.HBox(false, 3);
                    box.PackStart(contentWidget, true, true, 3);
                    box.PackStart(new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out), false, false, 0);
                    contentWidget       = box;
                    expandButtonContent = true;
                }
                else
                {
                    contentWidget = new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out);
                }
            }
            if (contentWidget != null)
            {
                contentWidget.ShowAll();
                Widget.Label = null;
                Widget.Image = contentWidget;
                var alignment = Widget.Child as Gtk.Alignment;
                if (alignment != null)
                {
                    if (expandButtonContent)
                    {
                        var box = alignment.Child as Gtk.Box;
                        if (box != null)
                        {
                            alignment.Xscale = 1;
                            box.SetChildPacking(box.Children [0], true, true, 0, Gtk.PackType.Start);
                            if (labelWidget != null)
                            {
                                labelWidget.Xalign = 0;
                            }
                        }
                    }
                    else if (position == ContentPosition.Left && (contentWidget is Gtk.Box))
                    {
                        // in case the button is wider than its natural size and has text and an image on the left,
                        // optimize its alignment to make the text more centered.
                        // FIXME: more sophisticated size calculation
                        alignment.Xalign = 0.475f;
                    }
                }
                if (labelWidget != null)
                {
                    labelWidget.UseUnderline = useMnemonic;
                    if (customFont != null)
                    {
                        labelWidget.ModifyFont(customFont);
                    }
                    if (customLabelColor.HasValue)
                    {
                        labelWidget.SetForegroundColor(customLabelColor.Value);
                        labelWidget.SetForegroundColor(Gtk.StateType.Prelight, customLabelColor.Value);
                    }
                }
            }
            else
            {
                Widget.Label = null;
            }
        }
Ejemplo n.º 38
0
        public void SetContent(string label, bool useMnemonic, ImageDescription image, ContentPosition position)
        {
            Widget.UseUnderline = useMnemonic;
            this.image          = image;

            if (label != null && label.Length == 0)
            {
                label = null;
            }

            Button b = (Button)Frontend;

            if (label != null && image.Backend == null && b.Type == ButtonType.Normal)
            {
                Widget.Label = label;
                return;
            }

            if (b.Type == ButtonType.Disclosure)
            {
                Widget.Label = null;
                Widget.Image = new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out);
                Widget.Image.ShowAll();
                return;
            }

            Gtk.Widget contentWidget = null;

            Gtk.Widget imageWidget = null;
            if (image.Backend != null)
            {
                imageWidget = new ImageBox(ApplicationContext, image.WithDefaultSize(Gtk.IconSize.Button));
            }

            if (label != null && imageWidget == null)
            {
                contentWidget = new Gtk.Label(label)
                {
                    UseUnderline = useMnemonic
                };
            }
            else if (label == null && imageWidget != null)
            {
                contentWidget = imageWidget;
            }
            else if (label != null && imageWidget != null)
            {
                Gtk.Box box = position == ContentPosition.Left || position == ContentPosition.Right ? (Gtk.Box) new Gtk.HBox(false, 3) : (Gtk.Box) new Gtk.VBox(false, 3);
                var     lab = new Gtk.Label(label)
                {
                    UseUnderline = useMnemonic
                };

                if (position == ContentPosition.Left || position == ContentPosition.Top)
                {
                    box.PackStart(imageWidget, false, false, 0);
                    box.PackStart(lab, false, false, 0);
                }
                else
                {
                    box.PackStart(lab, false, false, 0);
                    box.PackStart(imageWidget, false, false, 0);
                }

                contentWidget = box;
            }
            if (b.Type == ButtonType.DropDown)
            {
                if (contentWidget != null)
                {
                    Gtk.HBox box = new Gtk.HBox(false, 3);
                    box.PackStart(contentWidget, true, true, 3);
                    box.PackStart(new Gtk.VSeparator(), true, true, 0);
                    box.PackStart(new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out), false, false, 0);
                    contentWidget = box;
                }
                else
                {
                    contentWidget = new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out);
                }
            }
            if (contentWidget != null)
            {
                contentWidget.ShowAll();
                Widget.Label = null;
                Widget.Image = contentWidget;
            }
            else
            {
                Widget.Label = null;
            }
        }