示例#1
0
文件: LinkLabels.cs 项目: m13253/xwt
		public LinkLabels ()
		{
			var label = new LinkLabel ("This has no url and does nothing when clicked");
			PackStart (label);

			label = new LinkLabel ("This has no url and we've attached a handler");
			label.NavigateToUrl += (o, e) => {
				MessageDialog.ShowMessage ("You clicked me!");
			};
			PackStart (label);

			label = new LinkLabel ("Mono Url - Default Action") {
				Uri = new Uri ("http://www.mono-project.com")
			};
			PackStart (label);

			label = new LinkLabel ("Mono Url - Custom Action") {
				Uri = new Uri ("http://mono-project.com")
			};
			label.NavigateToUrl += (o, e) => {
				MessageDialog.ShowMessage ("You clicked me!");
				e.SetHandled ();
			};
			PackStart (label);

			label = new LinkLabel ("Mono Url - Custom Action and default action") {
				Uri = new Uri ("http://mono-project.com")
			};
			label.NavigateToUrl += (o, e) => {
				MessageDialog.ShowMessage ("When this dialog closes, the default action will happen");
			};
			PackStart (label);
		}
示例#2
0
        private void Build()
        {
            this.Icon = Xwt.Drawing.Image.FromResource("URMSimulator.Resources.urm.png");
            this.Title = "About";
            this.Resizable = false;
            this.Buttons.Add(new DialogButton(Command.Close));

            vbox1 = new VBox();

            image1 = new ImageView();
            image1.WidthRequest = 320;
            image1.HeightRequest = 270;
            vbox1.PackStart(image1);

            labelProgramName = new Label();
            labelProgramName.TextAlignment = Alignment.Center;
            vbox1.PackStart(labelProgramName);

            labelComments = new Label();
            labelComments.TextAlignment = Alignment.Center;
            vbox1.PackStart(labelComments);

            hbox1 = new HBox();

            hbox1.PackStart(new HBox(), true);

            labelWebsite = new LinkLabel();
            labelWebsite.TextAlignment = Alignment.Center; //text aligment doesn't work with Xwt.WPF
            hbox1.PackStart(labelWebsite, false);

            hbox1.PackStart(new HBox(), true);
            vbox1.PackStart(hbox1);

            this.Content = vbox1;
        }
示例#3
0
 /// <summary>
 /// Add link.
 /// </summary>
 /// <param name="desc"></param>
 /// <param name="linkDesc"></param>
 /// <param name="link"></param>
 void AddLink(String desc, String linkDesc, String link)
 {
     Informations.Add(new Label(desc), 0, TableX);
     LinkLabel _link = new LinkLabel(linkDesc)
     {
         Uri = new Uri(link)
     };
     Informations.Add(_link, 1, TableX);
     TableX++;
 }
示例#4
0
        public LicensesWindow()
        {
            Icon = App.Icon;

            var vbox = new VBox();
            var scroll = new ScrollView(vbox);
            Content = scroll;

            Width = 600;
            Height = 500;

            Title = "Licenses";

            Font labelFont;
            RichTextView rtv;

            // XWT FRAMEWORK
            var lbl = new LinkLabel() { Text = "Xwt Framework", Uri = new Uri("https://github.com/mono/xwt/") };
            labelFont = lbl.Font = lbl.Font.WithScaledSize(2);
            vbox.PackStart(lbl);
            vbox.PackStart(rtv = new RichTextView() { MarginLeft = 8 });
            rtv.LoadText(@"The MIT License (MIT)

            Copyright (c) 2014 Xamarin, Inc

            Permission is hereby granted, free of charge, to any person obtaining a copy
            of this software and associated documentation files (the ""Software""), to deal
            in the Software without restriction, including without limitation the rights
            to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
            copies of the Software, and to permit persons to whom the Software is
            furnished to do so, subject to the following conditions:

            The above copyright notice and this permission notice shall be included in all
            copies or substantial portions of the Software.

            THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
            FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
            AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
            LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
            OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
            SOFTWARE.", ProperPlainTextFormat.Proper);

            //vbox.PackStart(new LinkLabel() { Font = labelFont, Text = "Splashy Icons", Uri = new Uri("http://splashyfish.com/icons/") });
            //vbox.PackStart(rtv = new RichTextView() { MarginLeft = 8 });
            //rtv.LoadText(@"It's free as in free.", ProperPlainTextFormat.Proper);

            //            vbox.PackStart(new LinkLabel() { Font = labelFont, Text = "DefaultIcon", Uri = new Uri("http://www.defaulticon.com/") });
            //            vbox.PackStart(rtv = new RichTextView() { MarginLeft = 8 });
            //            rtv.LoadText(@"Released under ""Creative Commons Attribution-No Derivative Works 3.0.""
            //No changes where made to the images.", ProperPlainTextFormat.Proper);
            //
            //            vbox.PackStart(new LinkLabel(){ MarginLeft = 14, Text="http://creativecommons.org/licenses/by-nd/3.0/", Uri = new Uri("http://creativecommons.org/licenses/by-nd/3.0/")});
            //            vbox.PackStart(new LinkLabel() { MarginLeft = 14, Text = "http://creativecommons.org/licenses/by-nd/3.0/legalcode", Uri = new Uri("http://creativecommons.org/licenses/by-nd/3.0/legalcode") });

            vbox.PackStart(new LinkLabel() { Font = labelFont, Text = "ZipStorer", Uri = new Uri("http://zipstorer.codeplex.com/") });
            vbox.PackStart(rtv = new RichTextView() { MarginLeft = 8 });
            rtv.LoadText(@"The code/library supplied is totally free for either personal or commercial use, with no warranties.
            Please use the ""Powered by ZipStorer"" logo (below) wherever is possible, pointing to this site.", ProperPlainTextFormat.Proper);
            ImageView imgView;
            vbox.PackStart(imgView = new ImageView(Resources.GetImage("zipstorer.png")));
        }
		void Build ()
		{
			Title = Catalog.GetString ("Add Packages");
			Width = 820;
			Height = 520;
			Padding = new WidgetSpacing ();

			// Top part of dialog:
			// Package sources and search.
			var topHBox = new HBox ();
			topHBox.Margin = new WidgetSpacing (8, 5, 6, 5);

			packageSourceComboBox = new ComboBox ();
			packageSourceComboBox.MinWidth = 200;
			topHBox.PackStart (packageSourceComboBox);

			packageSearchEntry = new SearchTextEntry ();
			packageSearchEntry.WidthRequest = 187;
			topHBox.PackEnd (packageSearchEntry);

			this.HeaderContent = topHBox;

			// Middle of dialog:
			// Packages and package information.
			var mainVBox = new VBox ();
			Content = mainVBox;

			var middleHBox = new HBox ();
			middleHBox.Spacing = 0;
			var middleFrame = new FrameBox ();
			middleFrame.Content = middleHBox;
			middleFrame.BorderWidth = new WidgetSpacing (0, 0, 0, 1);
			middleFrame.BorderColor = lineBorderColor;
			mainVBox.PackStart (middleFrame, true, true);

			// Error information.
			var packagesListVBox = new VBox ();
			packagesListVBox.Spacing = 0;
			errorMessageHBox = new HBox ();
			errorMessageHBox.Margin = new WidgetSpacing ();
			errorMessageHBox.BackgroundColor = Colors.Orange;
			errorMessageHBox.Visible = false;
			var errorImage = new ImageView ();
			errorImage.Margin = new WidgetSpacing (10, 0, 0, 0);
			errorImage.Image = ImageService.GetIcon (Stock.Warning, Gtk.IconSize.Menu);
			errorImage.HorizontalPlacement = WidgetPlacement.End;
			errorMessageHBox.PackStart (errorImage);
			errorMessageLabel = new Label ();
			errorMessageLabel.TextColor = Colors.White;
			errorMessageLabel.Margin = new WidgetSpacing (5, 5, 5, 5);
			errorMessageLabel.Wrap = WrapMode.Word;
			errorMessageHBox.PackStart (errorMessageLabel, true);
			packagesListVBox.PackStart (errorMessageHBox);

			// Packages list.
			middleHBox.PackStart (packagesListVBox, true, true);
			packagesListView = new ListView ();
			packagesListView.BorderVisible = false;
			packagesListView.HeadersVisible = false;
			packagesListVBox.PackStart (packagesListView, true, true);

			// Loading spinner.
			var loadingSpinnerHBox = new HBox ();
			loadingSpinnerHBox.HorizontalPlacement = WidgetPlacement.Center;
			var loadingSpinner = new Spinner ();
			loadingSpinner.Animate = true;
			loadingSpinner.MinWidth = 20;
			loadingSpinnerHBox.PackStart (loadingSpinner);

			loadingSpinnerLabel = new Label ();
			loadingSpinnerLabel.Text = Catalog.GetString ("Loading package list...");
			loadingSpinnerHBox.PackEnd (loadingSpinnerLabel);

			loadingSpinnerFrame = new FrameBox ();
			loadingSpinnerFrame.Visible = false;
			loadingSpinnerFrame.BackgroundColor = Colors.White;
			loadingSpinnerFrame.Content = loadingSpinnerHBox;
			loadingSpinnerFrame.BorderWidth = new WidgetSpacing ();
			packagesListVBox.PackStart (loadingSpinnerFrame, true, true);

			// No packages found label.
			var noPackagesFoundHBox = new HBox ();
			noPackagesFoundHBox.HorizontalPlacement = WidgetPlacement.Center;

			var noPackagesFoundLabel = new Label ();
			noPackagesFoundLabel.Text = Catalog.GetString ("No matching packages found.");
			noPackagesFoundHBox.PackEnd (noPackagesFoundLabel);

			noPackagesFoundFrame = new FrameBox ();
			noPackagesFoundFrame.Visible = false;
			noPackagesFoundFrame.BackgroundColor = Colors.White;
			noPackagesFoundFrame.Content = noPackagesFoundHBox;
			noPackagesFoundFrame.BorderWidth = new WidgetSpacing ();
			packagesListVBox.PackStart (noPackagesFoundFrame, true, true);

			// Package information
			packageInfoVBox = new VBox ();
			var packageInfoFrame = new FrameBox ();
			packageInfoFrame.BackgroundColor = packageInfoBackgroundColor;
			packageInfoFrame.BorderWidth = new WidgetSpacing ();
			packageInfoFrame.Content = packageInfoVBox;
			packageInfoVBox.Margin = new WidgetSpacing (15, 12, 15, 12);
			var packageInfoContainerVBox = new VBox ();
			packageInfoContainerVBox.WidthRequest = 240;
			packageInfoContainerVBox.PackStart (packageInfoFrame, true, true);

			var packageInfoScrollView = new ScrollView ();
			packageInfoScrollView.BorderVisible = false;
			packageInfoScrollView.HorizontalScrollPolicy = ScrollPolicy.Never;
			packageInfoScrollView.Content = packageInfoContainerVBox;
			packageInfoScrollView.BackgroundColor = packageInfoBackgroundColor;
			var packageInfoScrollViewFrame = new FrameBox ();
			packageInfoScrollViewFrame.BackgroundColor = packageInfoBackgroundColor;
			packageInfoScrollViewFrame.BorderWidth = new WidgetSpacing (1, 0, 0, 0);
			packageInfoScrollViewFrame.BorderColor = lineBorderColor;
			packageInfoScrollViewFrame.Content = packageInfoScrollView;
			middleHBox.PackEnd (packageInfoScrollViewFrame);

			// Package name and version.
			var packageNameHBox = new HBox ();
			packageInfoVBox.PackStart (packageNameHBox);

			packageNameLabel = new Label ();
			packageNameLabel.Ellipsize = EllipsizeMode.End;
			Font packageInfoSmallFont = packageNameLabel.Font.WithScaledSize (0.8);
			packageNameHBox.PackStart (packageNameLabel, true);

			packageVersionLabel = new Label ();
			packageVersionLabel.TextAlignment = Alignment.End;
			packageNameHBox.PackEnd (packageVersionLabel);

			// Package description.
			packageDescription = new Label ();
			packageDescription.Wrap = WrapMode.Word;
			packageDescription.Font = packageNameLabel.Font.WithScaledSize (0.9);
			packageDescription.BackgroundColor = packageInfoBackgroundColor;
			packageInfoVBox.PackStart (packageDescription);

			// Package id.
			var packageIdHBox = new HBox ();
			packageIdHBox.MarginTop = 7;
			packageInfoVBox.PackStart (packageIdHBox);

			var packageIdLabel = new Label ();
			packageIdLabel.Font = packageInfoSmallFont;
			packageIdLabel.Markup = Catalog.GetString ("<b>Id</b>");
			packageIdHBox.PackStart (packageIdLabel);

			packageId = new Label ();
			packageId.Ellipsize = EllipsizeMode.End;
			packageId.TextAlignment = Alignment.End;
			packageId.Font = packageInfoSmallFont;
			packageIdLink = new LinkLabel ();
			packageIdLink.Ellipsize = EllipsizeMode.End;
			packageIdLink.TextAlignment = Alignment.End;
			packageIdLink.Font = packageInfoSmallFont;
			packageIdHBox.PackEnd (packageIdLink, true);
			packageIdHBox.PackEnd (packageId, true);

			// Package author
			var packageAuthorHBox = new HBox ();
			packageInfoVBox.PackStart (packageAuthorHBox);

			var packageAuthorLabel = new Label ();
			packageAuthorLabel.Markup = Catalog.GetString ("<b>Author</b>");
			packageAuthorLabel.Font = packageInfoSmallFont;
			packageAuthorHBox.PackStart (packageAuthorLabel);

			packageAuthor = new Label ();
			packageAuthor.TextAlignment = Alignment.End;
			packageAuthor.Ellipsize = EllipsizeMode.End;
			packageAuthor.Font = packageInfoSmallFont;
			packageAuthorHBox.PackEnd (packageAuthor, true);

			// Package published
			var packagePublishedHBox = new HBox ();
			packageInfoVBox.PackStart (packagePublishedHBox);

			var packagePublishedLabel = new Label ();
			packagePublishedLabel.Markup = Catalog.GetString ("<b>Published</b>");
			packagePublishedLabel.Font = packageInfoSmallFont;
			packagePublishedHBox.PackStart (packagePublishedLabel);

			packagePublishedDate = new Label ();
			packagePublishedDate.Font = packageInfoSmallFont;
			packagePublishedHBox.PackEnd (packagePublishedDate);

			// Package downloads
			var packageDownloadsHBox = new HBox ();
			packageInfoVBox.PackStart (packageDownloadsHBox);

			var packageDownloadsLabel = new Label ();
			packageDownloadsLabel.Markup = Catalog.GetString ("<b>Downloads</b>");
			packageDownloadsLabel.Font = packageInfoSmallFont;
			packageDownloadsHBox.PackStart (packageDownloadsLabel);

			packageDownloads = new Label ();
			packageDownloads.Font = packageInfoSmallFont;
			packageDownloadsHBox.PackEnd (packageDownloads);

			// Package license.
			var packageLicenseHBox = new HBox ();
			packageInfoVBox.PackStart (packageLicenseHBox);

			var packageLicenseLabel = new Label ();
			packageLicenseLabel.Markup = Catalog.GetString ("<b>License</b>");
			packageLicenseLabel.Font = packageInfoSmallFont;
			packageLicenseHBox.PackStart (packageLicenseLabel);

			packageLicenseLink = new LinkLabel ();
			packageLicenseLink.Text = Catalog.GetString ("View License");
			packageLicenseLink.Font = packageInfoSmallFont;
			packageLicenseHBox.PackEnd (packageLicenseLink);

			// Package project page.
			var packageProjectPageHBox = new HBox ();
			packageInfoVBox.PackStart (packageProjectPageHBox);

			var packageProjectPageLabel = new Label ();
			packageProjectPageLabel.Markup = Catalog.GetString ("<b>Project Page</b>");
			packageProjectPageLabel.Font = packageInfoSmallFont;
			packageProjectPageHBox.PackStart (packageProjectPageLabel);

			packageProjectPageLink = new LinkLabel ();
			packageProjectPageLink.Text = Catalog.GetString ("Visit Page");
			packageProjectPageLink.Font = packageInfoSmallFont;
			packageProjectPageHBox.PackEnd (packageProjectPageLink);

			// Package dependencies
			var packageDependenciesHBox = new HBox ();
			packageInfoVBox.PackStart (packageDependenciesHBox);

			var packageDependenciesLabel = new Label ();
			packageDependenciesLabel.Markup = Catalog.GetString ("<b>Dependencies</b>");
			packageDependenciesLabel.Font = packageInfoSmallFont;
			packageDependenciesHBox.PackStart (packageDependenciesLabel);

			packageDependenciesNoneLabel = new Label ();
			packageDependenciesNoneLabel.Text = Catalog.GetString ("None");
			packageDependenciesNoneLabel.Font = packageInfoSmallFont;
			packageDependenciesHBox.PackEnd (packageDependenciesNoneLabel);

			// Package dependencies list.
			packageDependenciesListHBox = new HBox ();
			packageDependenciesListHBox.Visible = false;
			packageInfoVBox.PackStart (packageDependenciesListHBox);

			packageDependenciesList = new Label ();
			packageDependenciesList.Wrap = WrapMode.WordAndCharacter;
			packageDependenciesList.Margin = new WidgetSpacing (5);
			packageDependenciesList.Font = packageInfoSmallFont;
			packageDependenciesListHBox.PackStart (packageDependenciesList, true);

			// Bottom part of dialog:
			// Show pre-release packages and Close/Add to Project buttons.
			var bottomHBox = new HBox ();
			bottomHBox.Margin = new WidgetSpacing (8, 5, 14, 10);
			bottomHBox.Spacing = 5;
			mainVBox.PackStart (bottomHBox);

			showPrereleaseCheckBox = new CheckBox ();
			showPrereleaseCheckBox.Label = Catalog.GetString ("Show pre-release packages");
			bottomHBox.PackStart (showPrereleaseCheckBox);

			addPackagesButton = new Button ();
			addPackagesButton.MinWidth = 120;
			addPackagesButton.MinHeight = 25;
			addPackagesButton.Label = Catalog.GetString ("Add Package");
			bottomHBox.PackEnd (addPackagesButton);

			var closeButton = new Button ();
			closeButton.MinWidth = 120;
			closeButton.MinHeight = 25;
			closeButton.Label = Catalog.GetString ("Close");
			closeButton.Clicked += (sender, e) => Close ();
			bottomHBox.PackEnd (closeButton);

			packageSearchEntry.SetFocus ();
			packageInfoVBox.Visible = false;
		}
示例#6
0
        public void SetBuffer(IRichTextBuffer buffer)
        {
            var buf = buffer as RichTextBuffer;
            if (buf == null)
                throw new ArgumentException ("Passed buffer is of incorrect type", "buffer");

            if (links != null) {
                foreach (var link in links)
                    link.NavigateToUrl -= HandleNavigateToUrl;
            }

            Widget.Buffer = buf;
            links = new LinkLabel [buf.Links.Count];
            for (var i = 0; i < links.Length; i++) {
                var link = buf.Links [i];
                var label = new LinkLabel (link.Text)
                {
                    Uri = link.Href
                };
                label.NavigateToUrl += HandleNavigateToUrl;
                Widget.AddChildAtAnchor ((Gtk.Widget) ApplicationContext.Toolkit.GetNativeWidget (label), link.Anchor);
                links [i] = label;
            }
        }
示例#7
0
 void BuildContent()
 {
     VBox mainContent = new VBox ();
     _programName = new Label ();
     _programName.Font = _programName.Font.WithScaledSize (1.5).WithWeight (FontWeight.Bold);
     mainContent.PackStart (_programName);
     _comments = new Label ();
     _comments.Wrap = WrapMode.Word;
     mainContent.PackStart (_comments);
     _copyright = new Label ();
     _copyright.Font = _copyright.Font.WithScaledSize (0.8);
     mainContent.PackStart (_copyright);
     _website = new LinkLabel ();
     _website.Font = _website.Font.WithScaledSize (0.8);
     mainContent.PackStart (_website);
     HBox buttonRow = new HBox ();
     Button authors = new Button {
         Label = I18N._ ("Authors"),
         Image = Icons.Info
     };
     authors.Clicked += (sender, args) => ShowAuthors ();
     buttonRow.PackStart (authors);
     Button license = new Button {
         Label = I18N._ ("License"),
         Image = Icons.Info
     };
     license.Clicked += (sender, args) => ShowLicense ();
     buttonRow.PackStart (license);
     Button ok = new Button { Label = I18N._ ("Close"), Image = Icons.Ok };
     ok.Clicked += (sender, args) => Close ();
     buttonRow.PackEnd (ok);
     mainContent.PackEnd (buttonRow);
     Content = mainContent;
 }
示例#8
0
        /// <summary>
        /// Initialize whole layout!
        /// </summary>
        private void _intializeBoxes()
        {
            // Create HPaned main box
            MainBox = new HBox();
            MainBox.ExpandVertical = true;
            MainBox.ExpandHorizontal = true;
            MainBox.Spacing = 3;

            // Create tree view
            CurrentServer = new TreeView();
            CurrentServer.WidthRequest = 230;
            CurrentServer.SelectionMode = SelectionMode.Single;
            CurrentServer.SelectionChanged += UpdateControlView;

            // Create tree view!
            ServerStore = new TreeStore(ColumnName, ColumnImage, ColumnType);
            CurrentServer.Columns.Add("Server", ColumnImage, ColumnName); // Dummy column, not sure why?
            CurrentServer.HeadersVisible = false;

            // Net item parsing
            CurrentServer.ButtonPressed += HandleMouseOnTreeView;

            // Set data source
            CurrentServer.DataSource = ServerStore;

            // Add server to main box
            MainBox.PackStart(CurrentServer);

            // Prepare content box
            ContentBox = new VBox()
            {
                MarginLeft = 10
            };
            SetContentBoxControl(DirectorHomepage);

            // Add to panel
            MainBox.PackStart(ContentBox, expand: true, fill: true);

            // Control box with bottom info panel
            VBox MainContent = new VBox();
            MainContent.PackStart(MainBox, expand: true, fill: true);

            // Create Info label with link
            LinkLabel _info = new LinkLabel("Copyright 2014 NetBrick, s.r.o.")
            {
                Uri = new Uri("http://director.strnadj.eu/")
            };
            MainContent.PackStart(_info, vpos: WidgetPlacement.End, hpos: WidgetPlacement.End);

            // Clear tree view!
            ClearCurrentServerTree();

            // Set content to main box
            Content = MainContent;
        }
		void AddPackage (PackageLicenseViewModel package)
		{
			var titleBox = new VBox ();
			titleBox.Spacing = 0;
			titleBox.MarginBottom = 4;
			titleBox.PackStart (new Label {
				Markup = string.Format ("<span weight='bold'>{0}</span> – {1}", package.Id, package.Author),
			});
			var licenseLabel = new LinkLabel (GettextCatalog.GetString ("View License"));
			licenseLabel.Uri = package.LicenseUrl;
			licenseLabel.LinkClicked += (sender, e) => DesktopService.ShowUrl (e.Target.AbsoluteUri);
			titleBox.PackStart (licenseLabel);

			var rowBox = new HBox ();
			rowBox.Margin = rowMargin;

			var icon = new ImageView (ImageService.GetIcon ("md-package", Gtk.IconSize.Dnd));

			if (package.IconUrl != null && !string.IsNullOrEmpty (package.IconUrl.AbsoluteUri))
				imageLoader.LoadFrom (package.IconUrl, icon);

			rowBox.PackStart (icon);
			rowBox.PackStart (titleBox, true);

			packagesList.PackStart (rowBox);
		}
		void ShowUri (LinkLabel linkLabel, Uri uri)
		{
			if (uri == null) {
				linkLabel.Visible = false;
			} else {
				linkLabel.Visible = true;
				linkLabel.Uri = uri;
			}
		}
		void ShowUri (LinkLabel linkLabel, Uri uri, string label)
		{
			linkLabel.Text = label;
			ShowUri (linkLabel, uri);
		}