Exemple #1
0
        protected override void Render(Drawable window, Widget widget, Rectangle background_area, Rectangle cell_area, Rectangle expose_area, CellRendererState flags)
        {
            if (Template == null)
            {
                DrawTemplateCategoryText(window, widget, cell_area, flags);
                return;
            }

            using (var ctx = CairoHelper.Create(window)) {
                using (var layout = new Pango.Layout(widget.PangoContext)) {
                    Rectangle iconRect = DrawIcon(window, widget, cell_area, flags);

                    if (!Template.AvailableLanguages.Any() || !IsTemplateRowSelected(widget, flags))
                    {
                        DrawTemplateNameText(window, widget, cell_area, iconRect, Rectangle.Zero, flags);
                        return;
                    }

                    int textHeight = 0;
                    int textWidth  = 0;

                    SetMarkup(layout, GetSelectedLanguage());
                    layout.GetPixelSize(out textWidth, out textHeight);

                    double scale = GtkWorkarounds.GetPixelScale();
                    languageRect = GetLanguageButtonRectangle(window, widget, cell_area, textHeight, textWidth, scale);

                    DrawTemplateNameText(window, widget, cell_area, iconRect, languageRect, flags);

                    RoundBorder(ctx, languageRect.X, languageRect.Y, languageRect.Width, languageRect.Height);
                    SetSourceColor(ctx, Styles.NewProjectDialog.TemplateLanguageButtonBackground.ToCairoColor());
                    ctx.Fill();

                    int languageTextX = languageRect.X + GetLanguageLeftHandPadding(scale);
                    if (!TemplateHasMultipleLanguages())
                    {
                        languageTextX = languageRect.X + (languageRect.Width - textWidth) / 2;
                    }
                    int languageTextY = languageRect.Y + (languageRect.Height - textHeight) / 2;

                    window.DrawLayout(widget.Style.TextGC(StateType.Normal), languageTextX, languageTextY, layout);

                    if (TemplateHasMultipleLanguages())
                    {
                        int triangleX = languageTextX + textWidth + GetLanguageRightHandPadding(scale);
                        int triangleY = languageRect.Y + (languageRect.Height - ((int)(scale * dropdownTriangleHeight))) / 2;
                        DrawTriangle(ctx, triangleX, triangleY, scale);
                    }
                }
            }
        }
Exemple #2
0
        static void AddToIconFactory(string stockId, Gdk.Pixbuf pixbuf, Gdk.Pixbuf pixbuf2x, Gtk.IconSize iconSize)
        {
            Gtk.IconSet iconSet = iconFactory.Lookup(stockId);
            if (iconSet == null)
            {
                iconSet = new Gtk.IconSet();
                iconFactory.Add(stockId, iconSet);
            }

            Gtk.IconSource source   = new Gtk.IconSource();
            Gtk.IconSource source2x = null;

            if (Platform.IsWindows)
            {
                var pixel_scale = GtkWorkarounds.GetPixelScale();
                source.Pixbuf = pixbuf.ScaleSimple((int)(pixbuf.Width * pixel_scale), (int)(pixbuf.Height * pixel_scale), Gdk.InterpType.Bilinear);
            }
            else
            {
                source.Pixbuf = pixbuf;
            }

            source.Size           = iconSize;
            source.SizeWildcarded = iconSize == Gtk.IconSize.Invalid;

            if (pixbuf2x != null)
            {
                if (GtkWorkarounds.SetSourceScale(source, 1))
                {
                    GtkWorkarounds.SetSourceScaleWildcarded(source, false);
                    source2x                = new Gtk.IconSource();
                    source2x.Pixbuf         = pixbuf2x;
                    source2x.Size           = iconSize;
                    source2x.SizeWildcarded = iconSize == Gtk.IconSize.Invalid;
                    GtkWorkarounds.SetSourceScale(source2x, 2);
                    GtkWorkarounds.SetSourceScaleWildcarded(source2x, false);
                }
            }
            else
            {
                GtkWorkarounds.SetSourceScaleWildcarded(source, true);
            }

            iconSet.AddSource(source);
            if (source2x != null)
            {
                iconSet.AddSource(source2x);
            }
        }
        public GtkAspNetProjectTemplateWizardPageWidget()
        {
            this.Build();

            if (Platform.IsMac)
            {
                int labelPaddingHeight = 5;
                if (IsYosemiteOrHigher())
                {
                    labelPaddingHeight--;
                }
                includeLabelPadding.HeightRequest = labelPaddingHeight;
                testingLabelPadding.HeightRequest = labelPaddingHeight;

                int leftPaddingWidth = 28;
                mvcDescriptionLeftHandPadding.WidthRequest      = leftPaddingWidth;
                webFormsDescriptionLeftHandPadding.WidthRequest = leftPaddingWidth;
                webApiDescriptionLeftHandPadding.WidthRequest   = leftPaddingWidth;
                includeUnitTestProjectDescriptionLeftHandPadding.WidthRequest = leftPaddingWidth;
            }

            double scale = GtkWorkarounds.GetPixelScale();

            backgroundImage            = Xwt.Drawing.Image.FromResource("aspnet-wizard-page.png");
            backgroundImageView        = new ImageView(backgroundImage);
            backgroundImageView.Xalign = (float)(1 / scale);
            backgroundImageView.Yalign = (float)(1 / scale);
            backgroundLargeImageVBox.PackStart(backgroundImageView, true, true, 0);

            var separatorColor  = Ide.Gui.Styles.NewProjectDialog.ProjectConfigurationSeparatorColor.ToGdkColor();
            var backgroundColor = Ide.Gui.Styles.NewProjectDialog.ProjectConfigurationLeftHandBackgroundColor.ToGdkColor();

            testingSeparator.ModifyBg(StateType.Normal, separatorColor);

            leftBorderEventBox.ModifyBg(StateType.Normal, backgroundColor);
            configurationTopEventBox.ModifyBg(StateType.Normal, backgroundColor);
            configurationTableEventBox.ModifyBg(StateType.Normal, backgroundColor);
            configurationBottomEventBox.ModifyBg(StateType.Normal, backgroundColor);
            backgroundLargeImageEventBox.ModifyBg(StateType.Normal, backgroundColor);

            if (Platform.IsWindows && scale > 1.0)
            {
                ScaleWidgets(scale);
            }
        }
        public MainToolbar()
        {
            executionTargetsChanged = DispatchService.GuiDispatch(new EventHandler(HandleExecutionTargetsChanged));

            IdeApp.Workspace.ActiveConfigurationChanged += (sender, e) => UpdateCombos();
            IdeApp.Workspace.ConfigurationsChanged      += (sender, e) => UpdateCombos();

            IdeApp.Workspace.SolutionLoaded   += (sender, e) => UpdateCombos();
            IdeApp.Workspace.SolutionUnloaded += (sender, e) => UpdateCombos();

            IdeApp.ProjectOperations.CurrentSelectedSolutionChanged += HandleCurrentSelectedSolutionChanged;

            WidgetFlags |= Gtk.WidgetFlags.AppPaintable;

            AddWidget(button);
            AddSpace(8);

            configurationCombo       = new Gtk.ComboBox();
            configurationCombo.Model = configurationStore;
            var ctx = new Gtk.CellRendererText();

            configurationCombo.PackStart(ctx, true);
            configurationCombo.AddAttribute(ctx, "text", 0);

            configurationCombosBox = new HBox(false, 8);

            var configurationComboVBox = new VBox();

            configurationComboVBox.PackStart(configurationCombo, true, false, 0);
            configurationCombosBox.PackStart(configurationComboVBox, false, false, 0);

            runtimeCombo       = new Gtk.ComboBox();
            runtimeCombo.Model = runtimeStore;
            ctx = new Gtk.CellRendererText();
            runtimeCombo.PackStart(ctx, true);
            runtimeCombo.SetCellDataFunc(ctx, RuntimeRenderCell);
            runtimeCombo.RowSeparatorFunc = RuntimeIsSeparator;

            var runtimeComboVBox = new VBox();

            runtimeComboVBox.PackStart(runtimeCombo, true, false, 0);
            configurationCombosBox.PackStart(runtimeComboVBox, false, false, 0);
            AddWidget(configurationCombosBox);

            buttonBarBox             = new Alignment(0.5f, 0.5f, 0, 0);
            buttonBarBox.LeftPadding = (uint)7;
            buttonBarBox.Add(buttonBar);
            buttonBarBox.NoShowAll = true;
            AddWidget(buttonBarBox);
            AddSpace(24);

            statusArea = new StatusArea();
            statusArea.ShowMessage(BrandingService.ApplicationName);

            var statusAreaAlign = new Alignment(0, 0, 1, 1);

            statusAreaAlign.Add(statusArea);
            contentBox.PackStart(statusAreaAlign, true, true, 0);
            AddSpace(24);

            statusAreaAlign.SizeAllocated += (object o, SizeAllocatedArgs args) => {
                Gtk.Widget toplevel = this.Toplevel;
                if (toplevel == null)
                {
                    return;
                }

                var pixel_scale = GtkWorkarounds.GetPixelScale();

                int  windowWidth   = toplevel.Allocation.Width;
                int  center        = windowWidth / 2;
                int  left          = Math.Max(center - (int)(300 * pixel_scale), args.Allocation.Left);
                int  right         = Math.Min(left + (int)(600 * pixel_scale), args.Allocation.Right);
                uint left_padding  = (uint)(left - args.Allocation.Left);
                uint right_padding = (uint)(args.Allocation.Right - right);

                if (left_padding != statusAreaAlign.LeftPadding || right_padding != statusAreaAlign.RightPadding)
                {
                    statusAreaAlign.SetPadding(0, 0, (uint)left_padding, (uint)right_padding);
                }
            };

            matchEntry = new SearchEntry();

            var searchFiles = this.matchEntry.AddMenuItem(GettextCatalog.GetString("Search Files"));

            searchFiles.Activated += delegate {
                SetSearchCategory("files");
            };
            var searchTypes = this.matchEntry.AddMenuItem(GettextCatalog.GetString("Search Types"));

            searchTypes.Activated += delegate {
                SetSearchCategory("type");
            };
            var searchMembers = this.matchEntry.AddMenuItem(GettextCatalog.GetString("Search Members"));

            searchMembers.Activated += delegate {
                SetSearchCategory("member");
            };

            matchEntry.ForceFilterButtonVisible = true;
            matchEntry.Entry.FocusOutEvent     += delegate {
                matchEntry.Entry.Text = "";
            };
            var cmd = IdeApp.CommandService.GetCommand(Commands.NavigateTo);

            cmd.KeyBindingChanged += delegate {
                UpdateSearchEntryLabel();
            };
            UpdateSearchEntryLabel();

            matchEntry.Ready       = true;
            matchEntry.Visible     = true;
            matchEntry.IsCheckMenu = true;
            matchEntry.Entry.ModifyBase(StateType.Normal, Style.White);
            matchEntry.WidthRequest = 240;
            if (!Platform.IsMac && !Platform.IsWindows)
            {
                matchEntry.Entry.ModifyFont(Pango.FontDescription.FromString("Sans 9"));                   // TODO: VV: "Segoe UI 9"
            }
            matchEntry.RoundedShape   = true;
            matchEntry.Entry.Changed += HandleSearchEntryChanged;
            matchEntry.Activated     += (sender, e) => {
                var pattern = SearchPopupSearchPattern.ParsePattern(matchEntry.Entry.Text);
                if (pattern.Pattern == null && pattern.LineNumber > 0)
                {
                    popup.Destroy();
                    var doc = IdeApp.Workbench.ActiveDocument;
                    if (doc != null && doc.Editor != null)
                    {
                        doc.Select();
                        doc.Editor.Caret.Location = new Mono.TextEditor.DocumentLocation(pattern.LineNumber, pattern.Column > 0 ? pattern.Column : 1);
                        doc.Editor.CenterToCaret();
                        doc.Editor.Parent.StartCaretPulseAnimation();
                    }
                    return;
                }
                if (popup != null)
                {
                    popup.OpenFile();
                }
            };
            matchEntry.Entry.KeyPressEvent += (o, args) => {
                if (args.Event.Key == Gdk.Key.Escape)
                {
                    var doc = IdeApp.Workbench.ActiveDocument;
                    if (doc != null)
                    {
                        if (popup != null)
                        {
                            popup.Destroy();
                        }
                        doc.Select();
                    }
                    return;
                }
                if (popup != null)
                {
                    args.RetVal = popup.ProcessKey(args.Event.Key, args.Event.State);
                }
            };
            IdeApp.Workbench.RootWindow.WidgetEvent += delegate(object o, WidgetEventArgs args) {
                if (args.Event is Gdk.EventConfigure)
                {
                    PositionPopup();
                }
            };
            SizeAllocated += delegate {
                PositionPopup();
            };

            BuildToolbar();
            IdeApp.CommandService.RegisterCommandBar(buttonBar);

            AddinManager.ExtensionChanged += OnExtensionChanged;

            contentBox.PackStart(matchEntry, false, false, 0);

            var align = new Gtk.Alignment(0, 0, 1f, 1f);

            align.Show();
            align.TopPadding    = (uint)5;
            align.LeftPadding   = (uint)9;
            align.RightPadding  = (uint)18;
            align.BottomPadding = (uint)10;
            align.Add(contentBox);

            Add(align);
            SetDefaultSizes(-1, 21);

            configurationCombo.Changed += HandleConfigurationChanged;
            runtimeCombo.Changed       += HandleRuntimeChanged;
            UpdateCombos();

            button.Clicked += HandleStartButtonClicked;
            IdeApp.CommandService.RegisterCommandBar(this);

            IdeApp.CommandService.ActiveWidgetChanged += (sender, e) => {
                lastCommandTarget = new WeakReference(e.OldActiveWidget);
            };

            this.ShowAll();
            this.statusArea.statusIconBox.HideAll();
        }
Exemple #5
0
        public MainToolbar()
        {
            WidgetFlags |= Gtk.WidgetFlags.AppPaintable;

            AddWidget(button);
            AddSpace(8);

            configurationCombo       = new Gtk.ComboBox();
            configurationCombo.Model = configurationStore;
            var ctx = new Gtk.CellRendererText();

            configurationCombo.PackStart(ctx, true);
            configurationCombo.AddAttribute(ctx, "text", 0);

            configurationCombosBox = new HBox(false, 8);

            var configurationComboVBox = new VBox();

            configurationComboVBox.PackStart(configurationCombo, true, false, 0);
            configurationCombosBox.PackStart(configurationComboVBox, false, false, 0);

            // bold attributes for running runtime targets / (emulators)
            boldAttributes.Insert(new Pango.AttrWeight(Pango.Weight.Bold));

            runtimeCombo       = new Gtk.ComboBox();
            runtimeCombo.Model = runtimeStore;
            ctx = new Gtk.CellRendererText();
            if (Platform.IsWindows)
            {
                ctx.Ellipsize = Pango.EllipsizeMode.Middle;
            }
            runtimeCombo.PackStart(ctx, true);
            runtimeCombo.SetCellDataFunc(ctx, RuntimeRenderCell);
            runtimeCombo.RowSeparatorFunc = RuntimeIsSeparator;

            var runtimeComboVBox = new VBox();

            runtimeComboVBox.PackStart(runtimeCombo, true, false, 0);
            configurationCombosBox.PackStart(runtimeComboVBox, false, false, 0);
            AddWidget(configurationCombosBox);

            buttonBarBox             = new Alignment(0.5f, 0.5f, 0, 0);
            buttonBarBox.LeftPadding = (uint)7;
            buttonBarBox.Add(buttonBar);
            buttonBarBox.NoShowAll = true;
            AddWidget(buttonBarBox);
            AddSpace(24);

            statusArea = new StatusArea();
            statusArea.ShowMessage(BrandingService.ApplicationName);

            var statusAreaAlign = new Alignment(0, 0, 1, 1);

            statusAreaAlign.Add(statusArea);
            contentBox.PackStart(statusAreaAlign, true, true, 0);
            AddSpace(24);

            statusAreaAlign.SizeAllocated += (object o, SizeAllocatedArgs args) => {
                Gtk.Widget toplevel = this.Toplevel;
                if (toplevel == null)
                {
                    return;
                }

                var pixel_scale = GtkWorkarounds.GetPixelScale();

                int  windowWidth   = toplevel.Allocation.Width;
                int  center        = windowWidth / 2;
                int  left          = Math.Max(center - (int)(300 * pixel_scale), args.Allocation.Left);
                int  right         = Math.Min(left + (int)(600 * pixel_scale), args.Allocation.Right);
                uint left_padding  = (uint)(left - args.Allocation.Left);
                uint right_padding = (uint)(args.Allocation.Right - right);

                if (left_padding != statusAreaAlign.LeftPadding || right_padding != statusAreaAlign.RightPadding)
                {
                    statusAreaAlign.SetPadding(0, 0, (uint)left_padding, (uint)right_padding);
                }
            };

            matchEntry = new SearchEntry();

            matchEntry.ForceFilterButtonVisible = true;
            matchEntry.Entry.FocusOutEvent     += (o, e) => {
                if (SearchEntryLostFocus != null)
                {
                    SearchEntryLostFocus(o, e);
                }
            };

            matchEntry.Ready       = true;
            matchEntry.Visible     = true;
            matchEntry.IsCheckMenu = true;
            matchEntry.Entry.ModifyBase(StateType.Normal, Style.White);
            matchEntry.WidthRequest = 240;
            if (!Platform.IsMac && !Platform.IsWindows)
            {
                matchEntry.Entry.ModifyFont(Pango.FontDescription.FromString("Sans 9"));                   // TODO: VV: "Segoe UI 9"
            }
            matchEntry.RoundedShape         = true;
            matchEntry.Entry.Changed       += HandleSearchEntryChanged;
            matchEntry.Activated           += HandleSearchEntryActivated;
            matchEntry.Entry.KeyPressEvent += HandleSearchEntryKeyPressed;
            SizeAllocated += (o, e) => {
                if (SearchEntryResized != null)
                {
                    SearchEntryResized(o, e);
                }
            };

            contentBox.PackStart(matchEntry, false, false, 0);

            var align = new Gtk.Alignment(0, 0, 1f, 1f);

            align.Show();
            align.TopPadding    = (uint)5;
            align.LeftPadding   = (uint)9;
            align.RightPadding  = (uint)18;
            align.BottomPadding = (uint)10;
            align.Add(contentBox);

            Add(align);
            SetDefaultSizes(-1, (int)(21 * GtkWorkarounds.GetPixelScale()));

            configurationCombo.Changed += (o, e) => {
                if (ConfigurationChanged != null)
                {
                    ConfigurationChanged(o, e);
                }
            };
            runtimeCombo.Changed += (o, e) => {
                var ea = new HandledEventArgs();
                if (RuntimeChanged != null)
                {
                    RuntimeChanged(o, ea);
                }

                TreeIter it;
                if (runtimeCombo.GetActiveIter(out it))
                {
                    if (ea.Handled)
                    {
                        runtimeCombo.SetActiveIter(lastSelection);
                        return;
                    }
                    lastSelection = it;
                }
            };

            button.Clicked += HandleStartButtonClicked;

            IdeApp.CommandService.ActiveWidgetChanged += (sender, e) => {
                lastCommandTarget = new WeakReference(e.OldActiveWidget);
            };

            this.ShowAll();
            this.statusArea.statusIconBox.HideAll();
        }