Example #1
0
        public Preview(Drawable drawable, CoordinateList <int> coordinates) :
            base(drawable)
        {
            _coordinates = coordinates;

            PreviewArea area = Area;

            area.Events = EventMask.ButtonPressMask | EventMask.ButtonReleaseMask |
                          EventMask.PointerMotionHintMask | EventMask.PointerMotionMask |
                          EventMask.LeaveNotifyMask;

            ButtonPressEvent += (sender, args) =>
            {
                // Fix me: calculate real-world coordinates
                _coordinates.Add(new Coordinate <int>((int)args.Event.X,
                                                      (int)args.Event.Y));
            };

            ExposeEvent += delegate
            {
                var layout = new Pango.Layout(area.PangoContext);
                layout.FontDescription = FontDescription.FromString("Tahoma 16");

                int i = 0;
                foreach (var coordinate in _coordinates)
                {
                    layout.SetMarkup(String.Format("{0}", i));
                    // Fix me: transfer from real-world coordinates
                    area.GdkWindow.DrawLayout(Style.TextGC(StateType.Normal),
                                              coordinate.X, coordinate.Y,
                                              layout);
                    i++;
                }
            };
        }
Example #2
0
        private async void Loop()
        {
            while (HiddenWindows.ContainsKey(Window) && Window.Exists)
            {
                await Task.Delay(100);

                if (!State && PreviewArea.Contains(Mouse.Position) && Window.IsOnCurrentDesktop)
                {
                    if (Window.HasAnimation())
                    {
                        Window.StopAnimation();
                        Window.Move(HiddenArea);
                        Window.SetOpacity(0);
                        await Task.Yield();
                    }

                    PreviewShow();
                    bool flick = await WaitForFlick();

                    if (flick)
                    {
                        Show();
                    }
                    else
                    {
                        PreviewHide();
                    }
                    await WaitForLeave();
                }
                else if (State && (!ActiveArea.Contains(Mouse.Position) || !Window.IsOnCurrentDesktop))
                {
                    Hide();
                }
            }

            Program.OnExit -= Deactivate;
            if (noCleanup)
            {
                return;
            }
            if (!Window.Exists)
            {
                return;
            }
            if (!IsAlwaysOnTop)
            {
                Window.SetAlwaysOnTop(false);
            }
            Show();
        }
        private PreviewArea CreatePreviewArea(PreviewDisplayOption previewDisplayOption, ContentReference contentReference)
        {
            var item = new ContentAreaItem
            {
                ContentLink = contentReference
            };

            var contentArea = _websiteDependencies.ContextResolver.AddContentAreaItem(new ContentArea(), item);

            var areaModel = new PreviewArea
            {
                ContentArea = contentArea,
                Supported   = previewDisplayOption.IsSupported,
                AreaTag     = previewDisplayOption.Tag,
                AreaName    = previewDisplayOption.Name,
            };

            return(areaModel);
        }
Example #4
0
        private PreviewArea CreatePreviewArea(PreviewDisplayOption previewDisplayOption)
        {
            var contentArea = new ContentArea();
            var item        = new ContentAreaItem
            {
                ContentLink = currentContent.ContentLink
            };

            contentArea.Items.Add(item);

            var areaModel = new PreviewArea
            {
                ContentArea = contentArea,
                Supported   = previewDisplayOption.IsSupported,
                AreaTag     = previewDisplayOption.Tag,
                AreaName    = previewDisplayOption.Name,
            };

            return(areaModel);
        }
Example #5
0
        private void BuildDialog()
        {
            // Layout table for preset, width, and height
            var layout_table = new Table(3, 2, false);

            layout_table.RowSpacing    = 5;
            layout_table.ColumnSpacing = 6;

            // Preset Combo
            var size_label = new Label(Catalog.GetString("Preset:"));

            size_label.SetAlignment(1f, .5f);

            var preset_entries = new List <string> ();

            if (has_clipboard)
            {
                preset_entries.Add(Catalog.GetString("Clipboard"));
            }

            preset_entries.Add(Catalog.GetString("Custom"));
            preset_entries.AddRange(preset_sizes.Select(p => string.Format("{0} x {1}", p.Width, p.Height)));

            preset_combo        = new ComboBox(preset_entries.ToArray());
            preset_combo.Active = 0;

            layout_table.Attach(size_label, 0, 1, 0, 1, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Fill, 0, 0);
            layout_table.Attach(preset_combo, 1, 2, 0, 1, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Fill, 0, 0);

            // Width Entry
            var width_label = new Label(Catalog.GetString("Width:"));

            width_label.SetAlignment(1f, .5f);

            width_entry = new Entry();
            width_entry.WidthRequest     = 50;
            width_entry.ActivatesDefault = true;

            var width_units = new Label(Catalog.GetString("pixels"));

            var width_hbox = new HBox();

            width_hbox.PackStart(width_entry, false, false, 0);
            width_hbox.PackStart(width_units, false, false, 5);

            layout_table.Attach(width_label, 0, 1, 1, 2, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Fill, 0, 0);
            layout_table.Attach(width_hbox, 1, 2, 1, 2, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Fill, 0, 0);

            // Height Entry
            var height_label = new Label(Catalog.GetString("Height:"));

            height_label.SetAlignment(1f, .5f);

            height_entry = new Entry();
            height_entry.WidthRequest     = 50;
            height_entry.ActivatesDefault = true;

            var height_units = new Label(Catalog.GetString("pixels"));

            var height_hbox = new HBox();

            height_hbox.PackStart(height_entry, false, false, 0);
            height_hbox.PackStart(height_units, false, false, 5);

            layout_table.Attach(height_label, 0, 1, 2, 3, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Fill, 0, 0);
            layout_table.Attach(height_hbox, 1, 2, 2, 3, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Fill, 0, 0);

            // Orientation Radio options
            var orientation_label = new Label(Catalog.GetString("Orientation:"));

            orientation_label.SetAlignment(0f, .5f);

            portrait_radio = new RadioButton(Catalog.GetString("Portrait"));
            var portrait_image = new Image(PintaCore.Resources.GetIcon(Stock.OrientationPortrait, 16));

            var portrait_hbox = new HBox();

            portrait_hbox.PackStart(portrait_image, false, false, 7);
            portrait_hbox.PackStart(portrait_radio, false, false, 0);

            landscape_radio = new RadioButton(portrait_radio, Catalog.GetString("Landscape"));
            var landscape_image = new Image(PintaCore.Resources.GetIcon(Stock.OrientationLandscape, 16));

            var landscape_hbox = new HBox();

            landscape_hbox.PackStart(landscape_image, false, false, 7);
            landscape_hbox.PackStart(landscape_radio, false, false, 0);

            // Orientation VBox
            var orientation_vbox = new VBox();

            orientation_vbox.PackStart(orientation_label, false, false, 4);
            orientation_vbox.PackStart(portrait_hbox, false, false, 0);
            orientation_vbox.PackStart(landscape_hbox, false, false, 0);

            // Background Color options
            var background_label = new Label(Catalog.GetString("Background:"));

            background_label.SetAlignment(0f, .5f);

            white_bg_radio = new RadioButton(Catalog.GetString("White"));
            var image_white = new Image(GdkExtensions.CreateColorSwatch(16, new Gdk.Color(255, 255, 255)));

            var hbox_white = new HBox();

            hbox_white.PackStart(image_white, false, false, 7);
            hbox_white.PackStart(white_bg_radio, false, false, 0);

            secondary_bg_radio = new RadioButton(white_bg_radio, Catalog.GetString("Background Color"));
            var image_bg = new Image(GdkExtensions.CreateColorSwatch(16, PintaCore.Palette.SecondaryColor.ToGdkColor()));

            var hbox_bg = new HBox();

            hbox_bg.PackStart(image_bg, false, false, 7);
            hbox_bg.PackStart(secondary_bg_radio, false, false, 0);

            trans_bg_radio = new RadioButton(secondary_bg_radio, Catalog.GetString("Transparent"));
            var image_trans = new Image(GdkExtensions.CreateTransparentColorSwatch(true));

            var hbox_trans = new HBox();

            hbox_trans.PackStart(image_trans, false, false, 7);
            hbox_trans.PackStart(trans_bg_radio, false, false, 0);

            // Background VBox
            var background_vbox = new VBox();

            background_vbox.PackStart(background_label, false, false, 4);
            background_vbox.PackStart(hbox_white, false, false, 0);

            if (allow_background_color)
            {
                background_vbox.PackStart(hbox_bg, false, false, 0);
            }

            background_vbox.PackStart(hbox_trans, false, false, 0);

            // Put all the options together
            var options_vbox = new VBox();

            options_vbox.Spacing = 10;

            options_vbox.PackStart(layout_table, false, false, 3);
            options_vbox.PackStart(orientation_vbox, false, false, 0);
            options_vbox.PackStart(background_vbox, false, false, 4);

            // Layout the preview + the options
            preview = new PreviewArea();

            var preview_label = new Label(Catalog.GetString("Preview"));

            var preview_vbox = new VBox();

            preview_vbox.PackStart(preview_label, false, false, 0);
            preview_vbox.PackStart(preview, true, true, 0);


            var main_hbox = new HBox(false, 10);

            main_hbox.PackStart(options_vbox, false, false, 0);
            main_hbox.PackStart(preview_vbox, true, true, 0);

            VBox.Add(main_hbox);

            ShowAll();
        }
Example #6
0
        private void BuildDialog ()
        {
            // Layout table for preset, width, and height
            var layout_table = new Table (3, 2, false);

            layout_table.RowSpacing = 5;
            layout_table.ColumnSpacing = 6;

            // Preset Combo
            var size_label = new Label (Catalog.GetString ("Preset:"));
            size_label.SetAlignment (1f, .5f);

            var preset_entries = new List<string> ();

            if (has_clipboard)
                preset_entries.Add (Catalog.GetString ("Clipboard"));

            preset_entries.Add (Catalog.GetString ("Custom"));            
            preset_entries.AddRange (preset_sizes.Select (p => string.Format ("{0} x {1}", p.Width, p.Height)));

            preset_combo = new ComboBox (preset_entries.ToArray ());
            preset_combo.Active = 0;

            layout_table.Attach (size_label, 0, 1, 0, 1, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Fill, 0, 0);
            layout_table.Attach (preset_combo, 1, 2, 0, 1, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Fill, 0, 0);
            
            // Width Entry
            var width_label = new Label (Catalog.GetString ("Width:"));
            width_label.SetAlignment (1f, .5f);

            width_entry = new Entry ();
            width_entry.WidthRequest = 50;
            width_entry.ActivatesDefault = true;

            var width_units = new Label (Catalog.GetString ("pixels"));

            var width_hbox = new HBox ();
            width_hbox.PackStart (width_entry, false, false, 0);
            width_hbox.PackStart (width_units, false, false, 5);

            layout_table.Attach (width_label, 0, 1, 1, 2, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Fill, 0, 0);
            layout_table.Attach (width_hbox, 1, 2, 1, 2, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Fill, 0, 0);

            // Height Entry
            var height_label = new Label (Catalog.GetString ("Height:"));
            height_label.SetAlignment (1f, .5f);

            height_entry = new Entry ();
            height_entry.WidthRequest = 50;
            height_entry.ActivatesDefault = true;

            var height_units = new Label (Catalog.GetString ("pixels"));

            var height_hbox = new HBox ();
            height_hbox.PackStart (height_entry, false, false, 0);
            height_hbox.PackStart (height_units, false, false, 5);

            layout_table.Attach (height_label, 0, 1, 2, 3, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Fill, 0, 0);
            layout_table.Attach (height_hbox, 1, 2, 2, 3, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Fill, 0, 0);

            // Orientation Radio options
            var orientation_label = new Label (Catalog.GetString ("Orientation:"));
            orientation_label.SetAlignment (0f, .5f);

            portrait_radio = new RadioButton (Catalog.GetString ("Portrait"));
            var portrait_image = new Image (PintaCore.Resources.GetIcon (Stock.OrientationPortrait, 16));
            
            var portrait_hbox = new HBox ();

            portrait_hbox.PackStart (portrait_image, false, false, 7);
            portrait_hbox.PackStart (portrait_radio, false, false, 0);
            
            landscape_radio = new RadioButton (portrait_radio, Catalog.GetString ("Landscape"));
            var landscape_image = new Image (PintaCore.Resources.GetIcon (Stock.OrientationLandscape, 16));
            
            var landscape_hbox = new HBox ();

            landscape_hbox.PackStart (landscape_image, false, false, 7);
            landscape_hbox.PackStart (landscape_radio, false, false, 0);

            // Orientation VBox
            var orientation_vbox = new VBox ();
            orientation_vbox.PackStart (orientation_label, false, false, 4);
            orientation_vbox.PackStart (portrait_hbox, false, false, 0);
            orientation_vbox.PackStart (landscape_hbox, false, false, 0);
            
            // Background Color options
            var background_label = new Label (Catalog.GetString ("Background:"));
            background_label.SetAlignment (0f, .5f);

            white_bg_radio = new RadioButton (Catalog.GetString ("White"));
            var image_white = new Image (GdkExtensions.CreateColorSwatch (16, new Gdk.Color (255, 255, 255)));
            
            var hbox_white = new HBox ();

            hbox_white.PackStart (image_white, false, false, 7);
            hbox_white.PackStart (white_bg_radio, false, false, 0);

            secondary_bg_radio = new RadioButton (white_bg_radio, Catalog.GetString ("Background Color"));
            var image_bg = new Image (GdkExtensions.CreateColorSwatch (16, PintaCore.Palette.SecondaryColor.ToGdkColor ()));

            var hbox_bg = new HBox ();

            hbox_bg.PackStart (image_bg, false, false, 7);
            hbox_bg.PackStart (secondary_bg_radio, false, false, 0);

            trans_bg_radio = new RadioButton (secondary_bg_radio, Catalog.GetString ("Transparent"));
            var image_trans = new Image (GdkExtensions.CreateTransparentColorSwatch (true));

            var hbox_trans = new HBox ();

            hbox_trans.PackStart (image_trans, false, false, 7);
            hbox_trans.PackStart (trans_bg_radio, false, false, 0);

            // Background VBox
            var background_vbox = new VBox ();
            background_vbox.PackStart (background_label, false, false, 4);
            background_vbox.PackStart (hbox_white, false, false, 0);

            if (allow_background_color)
                background_vbox.PackStart (hbox_bg, false, false, 0);

            background_vbox.PackStart (hbox_trans, false, false, 0);

            // Put all the options together
            var options_vbox = new VBox ();
            options_vbox.Spacing = 10;

            options_vbox.PackStart (layout_table, false, false, 3);
            options_vbox.PackStart (orientation_vbox, false, false, 0);
            options_vbox.PackStart (background_vbox, false, false, 4);

            // Layout the preview + the options
            preview = new PreviewArea ();

            var preview_label = new Label (Catalog.GetString ("Preview"));

            var preview_vbox = new VBox ();
            preview_vbox.PackStart (preview_label, false, false, 0);
            preview_vbox.PackStart (preview, true, true, 0);


            var main_hbox = new HBox (false, 10);

            main_hbox.PackStart (options_vbox, false, false, 0);
            main_hbox.PackStart (preview_vbox, true, true, 0);

            VBox.Add (main_hbox);

            ShowAll ();
        }