예제 #1
0
        public void TestReparenting_ShouldDrawALineInForm()
        {
            Gtk.Application.Init();

            Form testForm = new Form();
            testForm.Show();
            Application.DoEvents();

            var containerWindow = new Gtk.Window(Gtk.WindowType.Popup);
            containerWindow.ShowNow();
            containerWindow.Move(-5000, -5000);

            while (Gtk.Application.EventsPending()) {
                Gtk.Application.RunIteration(false);
            }

            var gdkWrapperOfForm = Gdk.Window.ForeignNewForDisplay(Gdk.Display.Default, (uint)testForm.Handle);
            containerWindow.GdkWindow.Reparent(gdkWrapperOfForm, 0, 0);

            Gdk.GC color = containerWindow.Style.DarkGC (Gtk.StateType.Normal);
            containerWindow.GdkWindow.DrawLine(color, 0, 0, 100, 100);

            while (Gtk.Application.EventsPending()) {
                Gtk.Application.RunIteration(false);
            }

            Application.DoEvents();
        }
예제 #2
0
 public ProgressBarWindow(Gtk.Window parent)
     : base(Gtk.WindowType.Toplevel)
 {
     _mainWin = parent;
     this.Build ();
     this.Shown += delegate { Dialogs.CenterChildToParent(parent,this); };
 }
예제 #3
0
		public void NativeWindowFrameHasCorrectScreenBounds ()
		{
			var nativeWindow = new Gtk.Window ("Foo");
			nativeWindow.Resize (450, 320);
			nativeWindow.Move (13, 50);
			nativeWindow.ShowAll ();

			WaitForEvents ();

			var window = Toolkit.CurrentEngine.WrapWindow (nativeWindow);
			var bounds = window.ScreenBounds;
			Assert.AreEqual (450, bounds.Width);
			Assert.AreEqual (320, bounds.Height);
			Assert.AreEqual (13, bounds.X);
			Assert.AreEqual (50, bounds.Y);

			nativeWindow.Move (30, 100);
			WaitForEvents ();
			bounds = window.ScreenBounds;
			Assert.AreEqual (30, bounds.X);
			Assert.AreEqual (100, bounds.Y);
			Assert.AreEqual (450, bounds.Width);
			Assert.AreEqual (320, bounds.Height);

			nativeWindow.Resize (100, 100);
			WaitForEvents ();
			bounds = window.ScreenBounds;
			Assert.AreEqual (30, bounds.X);
			Assert.AreEqual (100, bounds.Y);
			Assert.AreEqual (100, bounds.Width);
			Assert.AreEqual (100, bounds.Height);
		}
예제 #4
0
        public ServerListView(Gtk.Window parent, Glade.XML gladeXml)
        {
            Trace.Call(parent, gladeXml);

            if (parent == null) {
                throw new ArgumentNullException("parent");
            }

            _Parent = parent;
            _Controller = new ServerListController(Frontend.UserConfig);

            gladeXml.BindFields(this);

            _AddButton.Clicked += new EventHandler(OnAddButtonClicked);
            _EditButton.Clicked += new EventHandler(OnEditButtonClicked);
            _RemoveButton.Clicked += new EventHandler(OnRemoveButtonClicked);

            _TreeView.AppendColumn(_("Protocol"), new Gtk.CellRendererText(), "text", 1);
            _TreeView.AppendColumn(_("Hostname"), new Gtk.CellRendererText(), "text", 2);

            _TreeStore = new Gtk.TreeStore(typeof(ServerModel),
                                           typeof(string), // protocol
                                           typeof(string) // hostname
                                           );
            _TreeView.RowActivated += OnTreeViewRowActivated;
            _TreeView.Selection.Changed += OnTreeViewSelectionChanged;
            _TreeView.Model = _TreeStore;
        }
예제 #5
0
        public FlagsSelectorDialog(Gtk.Window parent, EnumDescriptor enumDesc, uint flags, string title)
        {
            this.flags = flags;
            this.parent = parent;

            Glade.XML xml = new Glade.XML (null, "stetic.glade", "FlagsSelectorDialog", null);
            xml.Autoconnect (this);

            store = new Gtk.ListStore (typeof(bool), typeof(string), typeof(uint));
            treeView.Model = store;

            Gtk.TreeViewColumn col = new Gtk.TreeViewColumn ();

            Gtk.CellRendererToggle tog = new Gtk.CellRendererToggle ();
            tog.Toggled += new Gtk.ToggledHandler (OnToggled);
            col.PackStart (tog, false);
            col.AddAttribute (tog, "active", 0);

            Gtk.CellRendererText crt = new Gtk.CellRendererText ();
            col.PackStart (crt, true);
            col.AddAttribute (crt, "text", 1);

            treeView.AppendColumn (col);

            foreach (Enum value in enumDesc.Values) {
                EnumValue eval = enumDesc[value];
                if (eval.Label == "")
                    continue;
                uint val = (uint) (int) eval.Value;
                store.AppendValues (((flags & val) != 0), eval.Label, val);
            }
        }
예제 #6
0
        public AddressEditor(AppConfig config, Gtk.Window parent, Gtk.Container cont, JObject data = null)
        {
            this.Build ();

            this.config = config;
            ParentWin = parent;
            Cont = cont;

            myComboState = new MyCombo (comboState);
            myComboMuni = new MyCombo (comboMuni);
            myComboAsenta = new MyCombo (comboAsenta);

            buttonDelete.ConfirmClick += OnDeleteConfirm;

            WidgetPath = Util.GtkGetWidgetPath (this, config);

            if (GlobalDefaultStateID == -1)
                config.LoadWindowKey (WidgetPath, "default_state_id", out GlobalDefaultStateID);
            DefaultStateID = GlobalDefaultStateID;

            if (GlobalDefaultMuniID == -1)
                config.LoadWindowKey (WidgetPath, "default_muni_id", out GlobalDefaultMuniID);
            DefaultMuniID = GlobalDefaultMuniID;

            if (GlobalDefaultAsentaID == -1)
                config.LoadWindowKey (WidgetPath, "default_asenta_id", out GlobalDefaultAsentaID);
            DefaultAsentaID = GlobalDefaultAsentaID;

            LoadData (data);
        }
 public CommandManager(Gtk.Window root)
 {
     rootWidget = root;
     ActionCommand c = new ActionCommand (CommandSystemCommands.ToolbarList, "Toolbar List", null, null, ActionType.Check);
     c.CommandArray = true;
     RegisterCommand (c, "");
 }
예제 #8
0
 public WindowOpacityFader(Gtk.Window win, double target, double msec)
 {
     this.win = win;
     win.Mapped += HandleMapped;
     win.Unmapped += HandleUnmapped;
     fadin = new DoubleAnimation (0.0, target, TimeSpan.FromMilliseconds (msec), opacity => {
         CompositeUtils.SetWinOpacity (win, opacity);
     });
 }
예제 #9
0
 public override void Dispose()
 {
     base.Dispose();
     if(this.Window != null)
     {
         this.Window.Destroy();
         this.Window = null;
     }
 }
예제 #10
0
 public WindowBackend()
 {
     Window = new Gtk.Window ("");
     mainBox = new Gtk.VBox ();
     Window.Add (mainBox);
     mainBox.Show ();
     alignment = new Gtk.Alignment (0, 0, 1, 1);
     mainBox.PackStart (alignment, true, true, 0);
     alignment.Show ();
 }
        public PersistentWindowController(Gtk.Window window, WindowConfiguration windowConfig, WindowPersistOptions options)
        {
            this.window = window;
            this.options = options;
            this.window_config = windowConfig;

            window.ConfigureEvent += OnChanged;
            window.WindowStateEvent += OnChanged;
            window.DestroyEvent += OnDestroy;
        }
 public DateSelectorWindow (int x, int y, DateTime defDate, DateEventHandler handler, Gtk.Window parent) : base(Gtk.WindowType.Popup)
 {
     this.TransientFor = parent;
     _parent = parent;
     _parent.Modal = false;
     this.Modal = true;
     this.Build ();
     this.Move (x, y);
     this.WindowPosition = Gtk.WindowPosition.None;
     this.OnChange = handler;
     cal.Date = defDate;
 }
예제 #13
0
        public PhoneEditor(AppConfig config, Gtk.Window parent, Gtk.Container cont, JObject data = null)
        {
            this.Build ();

            this.config = config;
            ParentWin = parent;
            Cont = cont;

            buttonDelete.ConfirmClick += OnDeleteConfirm;

            LoadData (data);
        }
예제 #14
0
        public Activity(Gtk.Window form, string activityId, string bundleId)
        {
            _activityId=activityId;
            _bundleId=bundleId;
            _wnd=form;

            DBusActivity dbus=new DBusActivity(this);

            if (form.IsRealized) {
                System.Console.Out.WriteLine("Error, the Window is already Realized so it is possible that the form is not sugarized.");
            }
            _wnd.Realized += realizeEventHandler;
        }
예제 #15
0
파일: Main.cs 프로젝트: jassmith/ColorMaker
        public static void Main(string[] args)
        {
            GLib.Thread.Init ();
            Gtk.Application.Init ();

            ColorMaker maker = new ColorMaker ();

            Gtk.Window window = new Gtk.Window ("Test");
            window.Add (maker);
            window.ShowAll ();

            Gtk.Application.Run ();
        }
            public CairoPositionSnapshot(ArrayList pos,
						      int width, int height)
            {
                fm = new FigureManager ();
                Gtk.Window win =
                    new Gtk.Window (Gtk.WindowType.
                            Toplevel);
                win.Realize ();
                map = new Gdk.Pixmap (win.GdkWindow, width,
                              height);
                cairo = Gdk.CairoHelper.Create (map);

                FontDescription fontdesc =
                    GetFontDesc (width, height);
                  GetCoordLayoutDetails (win.PangoContext,
                             fontdesc);

                  border_color = new Cairo.Color (0, 0, 0);
                //                              blacksq_color = new Gdk.Color (200, 200, 200);
                //                              whitesq_color = new Gdk.Color (240, 240, 240);
                  blacksq_color =
                    new Cairo.Color (250 / 256.0,
                             120 / 256.0,
                             32 / 256.0);
                  whitesq_color =
                    new Cairo.Color (255 / 256.0,
                             250 / 256.0,
                             170 / 256.0);
                  background_color =
                    new Cairo.Color (1, 1, 1);
                  foreground_color =
                    new Cairo.Color (0, 0, 0);
                //                                arrow_color = new Gdk.Color (159, 148, 249);
                  arrow_color =
                    new Cairo.Color (117 / 256.0,
                             6 / 256.0,
                             6 / 256.0);

                //                      blacksq_color = new Gdk.Color(210, 60, 0);
                //                      whitesq_color = new Gdk.Color(236, 193, 130);
                // outer box, coord, inner box
                  ComputeSizes (width, height);

                  position = new Position (pos);

                  fm.SetSize (size);

                  DrawBackground ();
                  DrawPosition ();
            }
		public SendMessagesOverviewWindow()
		{
			// Create window
			Gtk.Window window = new Gtk.Window ( "Verzonden Berichten" );
			window.SetSizeRequest (700, 200);

			// Add tree to window
			Gtk.TreeView tree = new Gtk.TreeView ();
			window.Add (tree);

			// Create the column for displaying the telephone number.
			Gtk.TreeViewColumn numberReceiverColumn = new Gtk.TreeViewColumn ();
			numberReceiverColumn.Title = "Telefoon nummer";
			numberReceiverColumn.MinWidth = 200;
			// Create the text cell that will display the telephone number.
			Gtk.CellRendererText numberReceiverCell = new Gtk.CellRendererText ();
			// Add the cell to the column.
			numberReceiverColumn.PackStart (numberReceiverCell, true);

			// Create the column for displaing the message.
			Gtk.TreeViewColumn messageColumn = new Gtk.TreeViewColumn ();
			messageColumn.Title = "Bericht";
			messageColumn.MinWidth = 300;
			// Create the text cell that will display the message.
			Gtk.CellRendererText messageCell = new Gtk.CellRendererText ();
			messageColumn.PackStart (messageCell, true);

			// Create the column for displaying the date send.
			Gtk.TreeViewColumn sendAtColumn = new Gtk.TreeViewColumn ();
			sendAtColumn.Title = "Verstuurd op";
			sendAtColumn.MinWidth = 200;
			// Create the text cell that will display the date send.
			Gtk.CellRendererText sendAtCell = new Gtk.CellRendererText ();
			sendAtColumn.PackStart (sendAtCell, true);

			tree.AppendColumn (numberReceiverColumn);
			tree.AppendColumn (messageColumn);
			tree.AppendColumn (sendAtColumn);

			// Tell the cell renderers which items in the model to display
			numberReceiverColumn.AddAttribute (numberReceiverCell, "text", 0);
			messageColumn.AddAttribute (messageCell, "text", 1);
			sendAtColumn.AddAttribute (sendAtCell, "text", 2);

			// Assign the model to the TreeView
			tree.Model = this.getMessageList ();
			// Show the window and everythin on it.
			window.ShowAll ();
		}
예제 #18
0
		WindowTransparencyDecorator (Gtk.Window window)
		{
			this.window = window;
			//HACK: Workaround for GTK# crasher bug where GC collects internal wrapper delegates
			snoopFunc = TryBindGtkInternals (this);
			
			if (snoopFunc != null) {
				window.Shown += ShownHandler;
				window.Hidden += HiddenHandler;
				window.Destroyed += DestroyedHandler;
			} else {
				snoopFunc = null;
				window = null;
			}
		}
예제 #19
0
		public void Detach ()
		{
			if (window == null)
			return;
			
			//remove the snooper
			HiddenHandler (null,  null);
			
			//annul allreferences between this and the window
			window.Shown -= ShownHandler;
			window.Hidden -= HiddenHandler;
			window.Destroyed -= DestroyedHandler;
			snoopFunc = null;
			window = null;
		}
예제 #20
0
        public ScanWorks(Gtk.Window parent)
        {
            Images = new List<Pixbuf>();
            _parent = parent;

            if(Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                WorkWithTwain = true;
                SetupTwain();
            }
            else
            {
                WorkWithTwain = false;
                //FIXME Setup Linux scanner
            }
        }
		public FlagsSelectorDialog (Gtk.Window parent, Type enumDesc, ulong flags, string title)
		{
			this.flags = flags;
			this.parent = parent;

			Gtk.ScrolledWindow sc = new Gtk.ScrolledWindow ();
			sc.HscrollbarPolicy = Gtk.PolicyType.Automatic;
			sc.VscrollbarPolicy = Gtk.PolicyType.Automatic;
			sc.ShadowType = Gtk.ShadowType.In;
			sc.BorderWidth = 6;
			
			treeView = new Gtk.TreeView ();
			sc.Add (treeView);
			
			dialog = new Gtk.Dialog ();
			IdeTheme.ApplyTheme (dialog);
			dialog.VBox.Add (sc);
			dialog.AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
			dialog.AddButton (Gtk.Stock.Ok, Gtk.ResponseType.Ok);
			
			store = new Gtk.ListStore (typeof(bool), typeof(string), typeof(ulong));
			treeView.Model = store;
			treeView.HeadersVisible = false;
			
			Gtk.TreeViewColumn col = new Gtk.TreeViewColumn ();
			
			Gtk.CellRendererToggle tog = new Gtk.CellRendererToggle ();
			tog.Toggled += new Gtk.ToggledHandler (OnToggled);
			col.PackStart (tog, false);
			col.AddAttribute (tog, "active", 0);
			
			Gtk.CellRendererText crt = new Gtk.CellRendererText ();
			col.PackStart (crt, true);
			col.AddAttribute (crt, "text", 1);
			
			treeView.AppendColumn (col);

			values = System.Enum.GetValues (enumDesc);
			foreach (object value in values) {
				ulong val = Convert.ToUInt64 (value);
				store.AppendValues ((flags == 0 && val == 0) || ((flags & val) != 0), value.ToString (), val);
			}
		}
            public PositionSnapshot(ArrayList pos, int width,
						 int height)
            {
                Gtk.Window win =
                    new Gtk.Window (Gtk.WindowType.
                            Toplevel);
                win.Realize ();
                map = new Gdk.Pixmap (win.GdkWindow, width,
                              height);
                gc = new Gdk.GC (map);

                FontDescription fontdesc =
                    GetFontDesc (width, height);
                  GetCoordLayoutDetails (win.PangoContext,
                             fontdesc);

                  border_color = new Gdk.Color (0, 0, 0);
                //                              blacksq_color = new Gdk.Color (200, 200, 200);
                //                              whitesq_color = new Gdk.Color (240, 240, 240);
                  blacksq_color =
                    new Gdk.Color (250, 120, 32);
                  whitesq_color =
                    new Gdk.Color (255, 250, 170);
                  background_color =
                    new Gdk.Color (255, 255, 255);
                  foreground_color = new Gdk.Color (0, 0, 0);
                //                                arrow_color = new Gdk.Color (159, 148, 249);
                  arrow_color = new Gdk.Color (117, 6, 6);

                //                      blacksq_color = new Gdk.Color(210, 60, 0);
                //                      whitesq_color = new Gdk.Color(236, 193, 130);
                // outer box, coord, inner box
                  ComputeSizes (width, height);

                if (figure == null)
                    figure = new Figure ();
                  position = new Position (pos);

                  figure.SetSize (size);

                  DrawBackground ();
                  DrawPosition ();
            }
예제 #23
0
        public MusicSource()
            : base("Google Music", "Google Music", 30)
        {
            api = new Google.Music.Api();
            downloadWrapper = new MusicDownloadWrapper(api);
            downloadWrapper.Start();

            TypeUniqueId = "google-music";
            Properties.Set<Gdk.Pixbuf>("Icon.Pixbuf_16", Gdk.Pixbuf.LoadFromResource("google-music-favicon"));

            var win = new Gtk.Window("Google Music Login");
            var loginWidget = new LoginWidget();
            loginWidget.UserLoggedIn += (cookies) => {
                api.SetCookies(cookies);
                AsyncUserJob.Create(() => {
                    Refetch();
                }, "Fetching playlist");

                win.Destroy();
            };
            win.Add(loginWidget);
            win.ShowAll();
        }
예제 #24
0
        public PlayListWindow(MainWindow win, Config cfg)
        {
            //musicListStore = sngs;
            // Create a Window
            config = cfg;
            foreach (tagInfo song in config.playlist)
            {
                addSongs(song);
            }


            Gtk.Window window = new Gtk.Window("TreeView Example");
            window.SetSizeRequest(500, 200);

            // Create our TreeView

            tree.Selection.Changed += new EventHandler(change);

            // Add our tree to the window
            window.Add(tree);
            tree.Model          = musicListStore;
            tree.HeadersVisible = true;
            // Create a column for the artist name
            Gtk.TreeViewColumn artistColumn = new Gtk.TreeViewColumn();
            artistColumn.Title = "Artist";

            // Create the text cell that will display the artist name
            Gtk.CellRendererText artistNameCell = new Gtk.CellRendererText();

            // Add the cell to the column
            artistColumn.PackStart(artistNameCell, true);

            // Create a column for the song title
            Gtk.TreeViewColumn songColumn = new Gtk.TreeViewColumn();
            songColumn.Title = "Song Title";

            // Do the same for the song title column
            Gtk.CellRendererText songTitleCell = new Gtk.CellRendererText();
            songTitleCell.Foreground     = "red";
            songTitleCell.Background     = "black";
            songTitleCell.CellBackground = "green";
            songColumn.PackStart(songTitleCell, true);

            Gtk.TreeViewColumn timeColumn = new Gtk.TreeViewColumn();
            timeColumn.Title    = "time";
            timeColumn.MaxWidth = 50;
            songColumn.MinWidth = 150;
            // Add the columns to the TreeView
            tree.AppendColumn(artistColumn);
            tree.AppendColumn(songColumn);
            tree.AppendColumn(timeColumn);

            // Tell the Cell Renderers which items in the model to display
            artistColumn.AddAttribute(artistNameCell, "text", 0);
            songColumn.AddAttribute(songTitleCell, "text", 1);
            timeColumn.AddAttribute(songTitleCell, "text", 2);

            // Create a model that will hold two strings - Artist Name and Song Title
            // Assign the model to the TreeView


            // Show the window and everything on it
            window.ShowAll();
        }
예제 #25
0
 public override bool IsInteractive(TextEditor editor, Gtk.Window tipWindow)
 {
     return(DebuggingService.IsDebugging);
 }
예제 #26
0
 internal virtual void SetMainWindowDecorations(Gtk.Window window)
 {
 }
예제 #27
0
 /// <summary>
 /// Grab the desktop focus for the window.
 /// </summary>
 public virtual void GrabDesktopFocus(Gtk.Window window)
 {
     window.Present();
 }
예제 #28
0
 internal static MainToolbarController CreateMainToolbar(Gtk.Window window)
 {
     return(new MainToolbarController(PlatformService.CreateMainToolbar(window)));
 }
예제 #29
0
 public void SpawnWindow()
 {
     Gtk.Window w = new Gtk.Window(Name);
     w.Add(Instantiate());
     w.ShowAll();
 }
예제 #30
0
 public EngineAssistant(Gtk.Window parent, FrontendConfig config) :
     this(parent, config, null)
 {
     Trace.Call(parent, config);
 }
 public override void GrabDesktopFocus(Gtk.Window window)
 {
     window.Present();
     NSApplication.SharedApplication.ActivateIgnoringOtherApps(true);
 }
예제 #32
0
 /// <summary>
 /// Grab the desktop focus for the window.
 /// </summary>
 internal static void GrabDesktopFocus(Gtk.Window window)
 {
     PlatformService.GrabDesktopFocus(window);
 }
예제 #33
0
		void TopLevelDestroyed (object o, EventArgs args)
		{
			RegisterUserInteraction ();

			Gtk.Window w = (Gtk.Window) o;
			w.Destroyed -= TopLevelDestroyed;
			w.KeyPressEvent -= OnKeyPressed;
			w.ButtonPressEvent -= HandleButtonPressEvent;
			topLevelWindows.Remove (w);
			if (w == lastFocused)
				lastFocused = null;
		}
예제 #34
0
		Gtk.Window GetActiveWindow (Gtk.Window win)
		{
			Gtk.Window[] wins = Gtk.Window.ListToplevels ();
			
			bool hasFocus = false;
			bool lastFocusedExists = lastFocused == null;
			Gtk.Window newFocused = null;
			foreach (Gtk.Window w in wins) {
				if (w.Visible) {
					if (w.HasToplevelFocus) {
						hasFocus = true;
						newFocused = w;
					}
					if (w.IsActive && w.Type == Gtk.WindowType.Toplevel && !(w is Gtk.Dialog)) {
						if (win == null)
							win = w;
					}
					if (lastFocused == w) {
						lastFocusedExists = true;
					}
				}
			}
			
			lastFocused = newFocused;
			UpdateAppFocusStatus (hasFocus, lastFocusedExists);
			
			if (win != null && win.IsRealized) {
				RegisterTopWindow (win);
				return win;
			}
			else
				return null;
		}
 internal override IMainToolbarView CreateMainToolbar(Gtk.Window window)
 {
     return(new MonoDevelop.MacIntegration.MainToolbar.MainToolbar(window));
 }
예제 #36
0
        /// <summary>Writes PDF for specified auto-doc commands.</summary>
        /// <param name="section">The writer to write to.</param>
        /// <param name="tags">The autodoc tags.</param>
        private void TagsToMigraDoc(Section section, List <AutoDocumentation.ITag> tags)
        {
            int figureNumber = 0;

            foreach (AutoDocumentation.ITag tag in tags)
            {
                if (tag is AutoDocumentation.Heading)
                {
                    AutoDocumentation.Heading heading = tag as AutoDocumentation.Heading;
                    if (heading.headingLevel > 0 && heading.headingLevel <= 6)
                    {
                        Paragraph para = section.AddParagraph(heading.text, "Heading" + heading.headingLevel);
                        para.Format.KeepWithNext = true;
                        int posSpace = heading.text.IndexOf(' ');
                        if (posSpace > 0)
                        {
                            para.AddBookmark(heading.text.Substring(posSpace + 1));
                        }
                        if (heading.headingLevel == 1)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level1;
                        }
                        else if (heading.headingLevel == 2)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level2;
                        }
                        else if (heading.headingLevel == 3)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level3;
                        }
                        else if (heading.headingLevel == 4)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level4;
                        }
                        else if (heading.headingLevel == 5)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level5;
                        }
                        else if (heading.headingLevel == 6)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level6;
                        }
                    }
                }
                else if (tag is AutoDocumentation.Paragraph)
                {
                    AutoDocumentation.Paragraph paragraph = tag as AutoDocumentation.Paragraph;
                    if (paragraph.text.Contains("![Alt Text]"))
                    {
                        figureNumber++;
                    }
                    paragraph.text = paragraph.text.Replace("[FigureNumber]", figureNumber.ToString());
                    AddFormattedParagraphToSection(section, paragraph);
                }
                else if (tag is AutoDocumentation.GraphAndTable)
                {
                    CreateGraphPDF(section, tag as AutoDocumentation.GraphAndTable);
                }
                else if (tag is GraphPage)
                {
                    CreateGraphPage(section, tag as GraphPage);
                }
                else if (tag is AutoDocumentation.NewPage)
                {
                    section.AddPageBreak();
                    if ((tag as AutoDocumentation.NewPage).Portrait)
                    {
                        section.PageSetup.Orientation = Orientation.Portrait;
                    }
                    else
                    {
                        section.PageSetup.Orientation = Orientation.Landscape;
                    }
                }
                else if (tag is AutoDocumentation.PageSetup)
                {
                    if ((tag as AutoDocumentation.PageSetup).Portrait)
                    {
                        section.PageSetup.Orientation = Orientation.Portrait;
                    }
                    else
                    {
                        section.PageSetup.Orientation = Orientation.Landscape;
                    }
                }
                else if (tag is AutoDocumentation.Table)
                {
                    CreateTable(section, tag as AutoDocumentation.Table);
                }
                else if (tag is Graph)
                {
                    GraphPresenter graphPresenter = new GraphPresenter();
                    explorerPresenter.ApsimXFile.Links.Resolve(graphPresenter);
                    GraphView graphView = new GraphView();
                    graphView.BackColor        = OxyPlot.OxyColors.White;
                    graphView.ForegroundColour = OxyPlot.OxyColors.Black;
                    graphView.FontSize         = 12;
                    graphView.Width            = 500;
                    graphView.Height           = 500;
                    graphPresenter.Attach(tag, graphView, explorerPresenter);
                    string pngFileName = graphPresenter.ExportToPNG(WorkingDirectory);
                    section.AddResizeImage(pngFileName);
                    string caption = (tag as Graph).Caption;
                    if (caption != null)
                    {
                        section.AddParagraph(caption);
                    }
                    graphPresenter.Detach();
                    graphView.MainWidget.Cleanup();
                }
                else if (tag is Map && (tag as Map).GetCoordinates().Count > 0)
                {
#if NETFRAMEWORK
                    MapPresenter mapPresenter = new MapPresenter();
                    MapView      mapView      = new MapView(null);
                    mapPresenter.Attach(tag, mapView, explorerPresenter);
                    var    map         = mapView.Export();
                    string pngFileName = Path.ChangeExtension(Path.GetTempFileName(), ".png");
                    if (map.Width > section.PageSetup.PageWidth)
                    {
                        map = ImageUtilities.ResizeImage(map, section.PageSetup.PageWidth, double.MaxValue);
                    }
                    map.Save(pngFileName);
                    if (!String.IsNullOrEmpty(pngFileName))
                    {
                        section.AddResizeImage(pngFileName);
                    }
                    mapPresenter.Detach();
                    mapView.MainWidget.Destroy();
#else
                    section.AddParagraph("MapView has not been implemented in gtk3. Use the framework/gtk2 build instead.");
#endif
                }
                else if (tag is AutoDocumentation.Image)
                {
                    AutoDocumentation.Image imageTag = tag as AutoDocumentation.Image;
                    string pngFileName = Path.Combine(WorkingDirectory, $"{imageTag.name}.png");
                    imageTag.image.Save(pngFileName, System.Drawing.Imaging.ImageFormat.Png);
                    section.AddResizeImage(pngFileName);
                    figureNumber++;
                }
                else if (tag is AutoDocumentation.ModelView)
                {
                    try
                    {
                        AutoDocumentation.ModelView modelView     = tag as AutoDocumentation.ModelView;
                        ViewNameAttribute           viewName      = ReflectionUtilities.GetAttribute(modelView.model.GetType(), typeof(ViewNameAttribute), false) as ViewNameAttribute;
                        PresenterNameAttribute      presenterName = ReflectionUtilities.GetAttribute(modelView.model.GetType(), typeof(PresenterNameAttribute), false) as PresenterNameAttribute;
                        if (viewName != null && presenterName != null)
                        {
                            ViewBase owner = ViewBase.MasterView as ViewBase;
                            if (viewName.ToString() == "UserInterface.Views.MapView")
                            {
                                owner = null;
                            }

                            ViewBase   view      = Assembly.GetExecutingAssembly().CreateInstance(viewName.ToString(), false, BindingFlags.Default, null, new object[] { owner }, null, null) as ViewBase;
                            IPresenter presenter = Assembly.GetExecutingAssembly().CreateInstance(presenterName.ToString()) as IPresenter;

                            if (view != null && presenter != null)
                            {
                                explorerPresenter.ApsimXFile.Links.Resolve(presenter);
                                presenter.Attach(modelView.model, view, explorerPresenter);

#if NETFRAMEWORK
                                Gtk.Window popupWin = new Gtk.Window(Gtk.WindowType.Popup);
#endif
                                try
                                {
#if NETFRAMEWORK
                                    popupWin.SetSizeRequest(700, 700);
                                    popupWin.Add(view.MainWidget);
#endif

                                    if (view is MapView map)
                                    {
                                        map.HideZoomControls();
                                    }
#if NETFRAMEWORK
                                    popupWin.ShowAll();
#endif
                                    while (Gtk.Application.EventsPending())
                                    {
                                        Gtk.Application.RunIteration();
                                    }

                                    // From MapView:
                                    // With WebKit, it appears we need to give it time to actually update the display
                                    // Really only a problem with the temporary windows used for generating documentation
                                    string pngFileName;
                                    if (view is MapView mapView)
                                    {
                                        var img = mapView.Export();
                                        pngFileName = Path.ChangeExtension(Path.GetTempFileName(), ".png");
                                        if (section.PageSetup.PageWidth > 0 && img.Width > section.PageSetup.PageWidth)
                                        {
                                            img = ImageUtilities.ResizeImage(img, section.PageSetup.PageWidth, double.MaxValue);
                                        }
                                        img.Save(pngFileName);
                                    }
                                    else
                                    {
                                        pngFileName = (presenter as IExportable).ExportToPNG(WorkingDirectory);
                                    }
                                    section.AddResizeImage(pngFileName);
                                    presenter.Detach();
                                    view.MainWidget.Cleanup();
                                }
                                finally
                                {
#if NETFRAMEWORK
                                    popupWin.Cleanup();
#endif
                                    while (GLib.MainContext.Iteration())
                                    {
                                        ;
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception err)
                    {
                        Console.WriteLine(err);
                    }
                }
            }
        }
예제 #37
0
        /// <summary>Writes PDF for specified auto-doc commands.</summary>
        /// <param name="section">The writer to write to.</param>
        /// <param name="tags">The autodoc tags.</param>
        /// <param name="workingDirectory">The working directory.</param>
        private void TagsToMigraDoc(Section section, List <AutoDocumentation.ITag> tags, string workingDirectory)
        {
            int figureNumber = 0;

            foreach (AutoDocumentation.ITag tag in tags)
            {
                if (tag is AutoDocumentation.Heading)
                {
                    AutoDocumentation.Heading heading = tag as AutoDocumentation.Heading;
                    if (heading.headingLevel > 0 && heading.headingLevel <= 6)
                    {
                        Paragraph para = section.AddParagraph(heading.text, "Heading" + heading.headingLevel);
                        para.Format.KeepWithNext = true;
                        if (heading.headingLevel == 1)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level1;
                        }
                        else if (heading.headingLevel == 2)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level2;
                        }
                        else if (heading.headingLevel == 3)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level3;
                        }
                        else if (heading.headingLevel == 4)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level4;
                        }
                        else if (heading.headingLevel == 5)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level5;
                        }
                        else if (heading.headingLevel == 6)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level6;
                        }
                    }
                }
                else if (tag is AutoDocumentation.Paragraph)
                {
                    AutoDocumentation.Paragraph paragraph = tag as AutoDocumentation.Paragraph;
                    if (paragraph.text.Contains("![Alt Text]"))
                    {
                        figureNumber++;
                    }
                    paragraph.text = paragraph.text.Replace("[FigureNumber]", figureNumber.ToString());
                    AddFormattedParagraphToSection(section, paragraph);
                }
                else if (tag is AutoDocumentation.GraphAndTable)
                {
                    CreateGraphPDF(section, tag as AutoDocumentation.GraphAndTable, workingDirectory);
                }
                else if (tag is GraphPage)
                {
                    CreateGraphPage(section, tag as GraphPage, workingDirectory);
                }
                else if (tag is AutoDocumentation.NewPage)
                {
                    section.AddPageBreak();
                }
                else if (tag is AutoDocumentation.Table)
                {
                    CreateTable(section, tag as AutoDocumentation.Table, workingDirectory);
                }
                else if (tag is Graph)
                {
                    GraphPresenter graphPresenter = new GraphPresenter();
                    explorerPresenter.ApsimXFile.Links.Resolve(graphPresenter);
                    GraphView graphView = new GraphView();
                    graphView.BackColor        = OxyPlot.OxyColors.White;
                    graphView.ForegroundColour = OxyPlot.OxyColors.Black;
                    graphView.FontSize         = 12;
                    graphView.Width            = 500;
                    graphView.Height           = 500;
                    graphPresenter.Attach(tag, graphView, explorerPresenter);
                    string pngFileName = graphPresenter.ExportToPNG(workingDirectory);
                    section.AddImage(pngFileName);
                    string caption = (tag as Graph).Caption;
                    if (caption != null)
                    {
                        section.AddParagraph(caption);
                    }
                    graphPresenter.Detach();
                    graphView.MainWidget.Destroy();
                }
                else if (tag is Map && (tag as Map).GetCoordinates().Count > 0)
                {
                    MapPresenter mapPresenter = new MapPresenter();
                    MapView      mapView      = new MapView(null);
                    mapPresenter.Attach(tag, mapView, explorerPresenter);
                    string pngFileName = mapPresenter.ExportToPNG(workingDirectory);
                    if (!String.IsNullOrEmpty(pngFileName))
                    {
                        section.AddImage(pngFileName);
                    }
                    mapPresenter.Detach();
                    mapView.MainWidget.Destroy();
                }
                else if (tag is AutoDocumentation.Image)
                {
                    AutoDocumentation.Image imageTag = tag as AutoDocumentation.Image;
                    if (imageTag.image.Width > 700)
                    {
                        imageTag.image = ImageUtilities.ResizeImage(imageTag.image, 700, 500);
                    }
                    string pngFileName = Path.Combine(workingDirectory, imageTag.name);
                    imageTag.image.Save(pngFileName, System.Drawing.Imaging.ImageFormat.Png);
                    section.AddImage(pngFileName);
                    figureNumber++;
                }
                else if (tag is AutoDocumentation.ModelView)
                {
                    AutoDocumentation.ModelView modelView     = tag as AutoDocumentation.ModelView;
                    ViewNameAttribute           viewName      = ReflectionUtilities.GetAttribute(modelView.model.GetType(), typeof(ViewNameAttribute), false) as ViewNameAttribute;
                    PresenterNameAttribute      presenterName = ReflectionUtilities.GetAttribute(modelView.model.GetType(), typeof(PresenterNameAttribute), false) as PresenterNameAttribute;
                    if (viewName != null && presenterName != null)
                    {
                        ViewBase   view      = Assembly.GetExecutingAssembly().CreateInstance(viewName.ToString(), false, BindingFlags.Default, null, new object[] { ViewBase.MasterView }, null, null) as ViewBase;
                        IPresenter presenter = Assembly.GetExecutingAssembly().CreateInstance(presenterName.ToString()) as IPresenter;

                        if (view != null && presenter != null)
                        {
                            explorerPresenter.ApsimXFile.Links.Resolve(presenter);
                            presenter.Attach(modelView.model, view, explorerPresenter);

                            Gtk.Window popupWin = null;
                            if (view is MapView)
                            {
                                popupWin = (view as MapView)?.GetPopupWin();
                                popupWin?.SetSizeRequest(515, 500);
                            }
                            if (popupWin == null)
                            {
                                popupWin = new Gtk.Window(Gtk.WindowType.Popup);
                                popupWin.SetSizeRequest(800, 800);
                                popupWin.Add(view.MainWidget);
                            }
                            popupWin.ShowAll();
                            while (Gtk.Application.EventsPending())
                            {
                                Gtk.Application.RunIteration();
                            }

                            string pngFileName = (presenter as IExportable).ExportToPNG(workingDirectory);
                            section.AddImage(pngFileName);
                            presenter.Detach();
                            view.MainWidget.Destroy();
                            popupWin.Destroy();
                        }
                    }
                }
            }
        }
예제 #38
0
 public void ShowGlobalPreferencesDialog(Gtk.Window parentWindow)
 {
     ShowGlobalPreferencesDialog(parentWindow, null);
 }
예제 #39
0
 internal static void PlaceWindow(Gtk.Window window, int x, int y, int width, int height)
 {
     PlatformService.PlaceWindow(window, x, y, width, height);
 }
예제 #40
0
 public bool IsValid(Gtk.Window window)
 {
     return(true);
 }
예제 #41
0
 internal static void RemoveChildWindow(Gtk.Window parent, Gtk.Window child)
 {
     PlatformService.RemoveChildWindow(parent, child);
 }
예제 #42
0
 public virtual bool GetIsFullscreen(Gtk.Window window)
 {
     return(((bool?)window.Data ["isFullScreen"]) ?? false);
 }
예제 #43
0
 internal virtual MainToolbar CreateMainToolbar(Gtk.Window window)
 {
     return(new MainToolbar());
 }
예제 #44
0
 internal virtual void RemoveWindowShadow(Gtk.Window window)
 {
 }
예제 #45
0
        /// <summary>
        /// Creates window which emulates selection.
        /// </summary>
        private void CreateWindow()
        {
            this.window = new Gtk.Window(Gtk.WindowType.Toplevel);
            this.window.SetDefaultSize(1, 1);
            this.window.AppPaintable = true;
            this.window.Decorated = false;
            this.window.KeepAbove = true;
            this.window.SkipPagerHint = true;
            this.window.SkipTaskbarHint = true;
            this.composited = this.window.Screen.IsComposited;

            Colormap map = this.composited ? this.window.Screen.RgbaColormap : this.window.Screen.RgbColormap;

            this.window.ScreenChanged += (s, e) => this.window.Colormap = map;
            this.window.ExposeEvent += (object s, Gtk.ExposeEventArgs args) =>
            {
                if (this.rectangle == null)
                    return;

                using (Cairo.Context context = CairoHelper.Create(this.window.GdkWindow))
                {
                    context.Operator = Cairo.Operator.Source;

                    if (this.composited)
                        context.SetSourceRGBA(0.0, 0.0, 0.0, 0.3);
                    else
                        context.SetSourceRGB(0.3, 0.3, 0.3);

                    context.Rectangle(0, 0, this.rectangle.Width, this.rectangle.Height);
                    context.Fill();
                    context.Stroke();
                }
            };

            this.window.Colormap = map;
            this.window.ShowAll();
        }
예제 #46
0
 public override void Initialize()
 {
     Window = new Gtk.Window ("");
     Window.Add (CreateMainLayout ());
 }
예제 #47
0
		/// <summary>
		/// Sets the root window. The manager will start the command route at this window, if no other is active.
		/// </summary>
		public void SetRootWindow (Gtk.Window root)
		{
			if (rootWidget != null)
				rootWidget.KeyPressEvent -= OnKeyPressed;
			
			rootWidget = root;
			rootWidget.AddAccelGroup (AccelGroup);
			RegisterTopWindow (rootWidget);
		}
 public bool IsInteractive(Mono.TextEditor.TextEditor editor, Gtk.Window tipWindow)
 {
     return(true);
 }
예제 #49
0
		public void Dispose ()
		{
			disposed = true;
			bindings.Dispose ();
			lastFocused = null;
		}
예제 #50
0
		public MessageDialog (Gtk.Window parent_window, DialogFlags flags, MessageType type, ButtonsType bt, string format, params object[] args) : this (parent_window, flags, type, bt, true, format, args) {}
예제 #51
0
파일: DND.cs 프로젝트: mono/stetic
        // Drag function for automatic sources, called from DragBegin
        static void Drag(Gtk.Widget source, Gdk.DragContext ctx, WidgetDropCallback dropCallback, Gtk.Widget dragWidget)
        {
            if (ctx == null)
                return;

            Gtk.Window dragWin;
            Gtk.Requisition req;

            ShowFaults ();
            DND.dragWidget = dragWidget;
            DND.dropCallback = dropCallback;

            dragWin = new Gtk.Window (Gtk.WindowType.Popup);
            dragWin.Add (dragWidget);

            req = dragWidget.SizeRequest ();
            if (req.Width < 20 && req.Height < 20)
                dragWin.SetSizeRequest (20, 20);
            else if (req.Width < 20)
                dragWin.SetSizeRequest (20, -1);
            else if (req.Height < 20)
                dragWin.SetSizeRequest (-1, 20);

            req = dragWin.SizeRequest ();

            int px, py, rx, ry;
            Gdk.ModifierType pmask;
            ctx.SourceWindow.GetPointer (out px, out py, out pmask);
            ctx.SourceWindow.GetRootOrigin (out rx, out ry);

            dragWin.Move (rx + px, ry + py);
            dragWin.Show ();

            dragHotX = req.Width / 2;
            dragHotY = -3;

            Gtk.Drag.SetIconWidget (ctx, dragWin, dragHotX, dragHotY);

            if (source != null) {
                source.DragDataGet += DragDataGet;
                source.DragEnd += DragEnded;
            }
        }
 public void GetRequiredPosition(Mono.TextEditor.TextEditor editor, Gtk.Window tipWindow, out int requiredWidth, out double xalign)
 {
     xalign        = 0.1;
     requiredWidth = tipWindow.SizeRequest().Width;
 }