public static void AddNewWordToDic(object sender, EventArgs e) { var win = new Gtk.Window("Přidej slovo"); win.SetPosition( WindowPosition.Mouse ); Label l = new Label(); l.Text = "Vloží slovo do aktuálně načteného slovníku, avšak nezmění zdroj (např. soubor dic.txt )"; Entry entry = new Entry(); Button b = new Button("Přidej"); VBox vbox = new VBox(); HBox hbox = new HBox(); vbox.BorderWidth = 10; vbox.PackStart( l ); vbox.PackEnd( hbox ); hbox.PackStart( entry ); hbox.PackEnd( b ); b.Clicked += delegate { game.dictionary.Add( entry.Text ); win.HideAll(); win.Destroy(); win.Dispose(); }; win.Add(vbox); win.ShowAll(); }
public static void AddNewWordToDic(object sender, EventArgs e) { var win = new Gtk.Window("Přidej slovo"); win.SetPosition(WindowPosition.Mouse); Label l = new Label(); l.Text = "Vloží slovo do aktuálně načteného slovníku, avšak nezmění zdroj (např. soubor dic.txt )"; Entry entry = new Entry(); Button b = new Button("Přidej"); VBox vbox = new VBox(); HBox hbox = new HBox(); vbox.BorderWidth = 10; vbox.PackStart(l); vbox.PackEnd(hbox); hbox.PackStart(entry); hbox.PackEnd(b); b.Clicked += delegate { game.dictionary.Add(entry.Text); win.HideAll(); win.Destroy(); win.Dispose(); }; win.Add(vbox); win.ShowAll(); }
/* * invaders constructor, creates a 512x512 game window and calls the * update handler every 1/10 of a second. */ invaders() { /* 100/1000 is the 1/10 second time interval. */ mytimer = GLib.Timeout.Add(100, new GLib.TimeoutHandler(update_handler)); win = new Gtk.Window("Space Invaders"); win.SetDefaultSize(window_size, window_size); win.SetPosition(WindowPosition.Center); /* add what to do when a delete event is processed. */ win.DeleteEvent += new DeleteEventHandler(handle_quit); area = new DrawingArea(); area.AddEvents((int) (EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.KeyPressMask | EventMask.PointerMotionMask)); area.AddEvents((int)EventMask.ButtonPressMask); area.ButtonPressEvent += new ButtonPressEventHandler(MyHandler); System.Console.WriteLine("before win.Add"); win.Add(area); System.Console.WriteLine("before win.ShowAll"); win.ShowAll(); System.Console.WriteLine("before context"); context = Gdk.CairoHelper.Create(area.GdkWindow); System.Console.WriteLine("finish gamewindow"); }
private void creaVentana() { window=new Window("Editar categoria"); window.SetDefaultSize (300, 100); window.SetPosition(WindowPosition.Center); VBox vbox=new VBox(); tabla=new Table(2,2,false); separaFilas(tabla,10); vbox.PackStart(tabla,false,false,0); window.Add(vbox); }
public gamewindow() { System.Console.WriteLine("inside gamewindow"); win = new Gtk.Window("Breakout"); win.SetDefaultSize(breakout_definitions.x_win, breakout_definitions.y_win); win.SetPosition(WindowPosition.Center); DeleteEvent += delegate { Application.Quit(); }; area = new DrawingArea(); area.AddEvents((int)(EventMask.ButtonPressMask | EventMask.ButtonReleaseMask)); area.ExposeEvent += OnDrawingAreaExposed; area.KeyPressEvent += new KeyPressEventHandler(key_handler); area.ButtonPressEvent += new ButtonPressEventHandler(ButtonPressHandler); area.ButtonReleaseEvent += new ButtonReleaseEventHandler(ButtonReleaseHandler); MenuBar mb = new MenuBar(); Menu file_menu = new Menu(); MenuItem file = new MenuItem("File"); file.Submenu = file_menu; MenuItem run = new MenuItem("Run"); run.Activated += do_run; file_menu.Append(run); MenuItem exit = new MenuItem("Exit"); exit.Activated += do_exit; file_menu.Append(exit); mb.Append(file); VBox vbox = new VBox(false, 3); vbox.PackStart(mb, false, false, 0); HBox hbox = new HBox(); hbox.Add(area); vbox.Add(hbox); System.Console.WriteLine("before win.Add"); win.Add(vbox); System.Console.WriteLine("before win.ShowAll"); win.ShowAll(); System.Console.WriteLine("before context"); context = Gdk.CairoHelper.Create(area.GdkWindow); System.Console.WriteLine("finish gamewindow"); }
private static bool HandlePopupCallback() { if (!popped_up) { if (popup_window == null) { Button button; Table table; popup_window = new Gtk.Window(Gtk.WindowType.Popup); popup_window.SetPosition(WindowPosition.Mouse); table = new Table(3, 3, false); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { string label = String.Format("{0},{1}", i, j); button = Button.NewWithLabel(label); table.Attach(button, (uint)i, (uint)i + 1, (uint)j, (uint)j + 1, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Expand | AttachOptions.Fill, 0, 0); Gtk.Drag.DestSet(button, DestDefaults.All, target_table, DragAction.Copy | DragAction.Move); button.DragMotion += new DragMotionHandler(HandlePopupMotion); button.DragLeave += new DragLeaveHandler(HandlePopupLeave); } } table.ShowAll(); popup_window.Add(table); } popup_window.Show(); popped_up = true; } popdown_timer = GLib.Timeout.Add(500, new TimeoutHandler(HandlePopdownCallback)); popup_timer = 0; return(false); }
public void ShowSongInfoPopup(string filepath) { string sDuration = _parent.SecondsToHumanTime(_parent.oXbmc.Media.GetMusicTagByFilepath(filepath, "duration")); string songInfo = "\n\nartist: " + _parent.oXbmc.Media.GetMusicTagByFilepath(filepath, "artist"); songInfo += "\ntitle: " + _parent.oXbmc.Media.GetMusicTagByFilepath(filepath, "title"); songInfo += "\nalbum: " + _parent.oXbmc.Media.GetMusicTagByFilepath(filepath, "album"); songInfo += "\ngenre: " + _parent.oXbmc.Media.GetMusicTagByFilepath(filepath, "genre"); songInfo += "\nduration: " + sDuration; Gtk.Window wSongInfo = new Gtk.Window("Song Info"); wSongInfo.SetPosition(WindowPosition.CenterAlways); wSongInfo.SetIconFromFile("images/icon.png"); Pango.FontDescription fd = Pango.FontDescription.FromString("Verdana Bold 9"); /* * string thumbLocation = _parent.oXbmc.Media.GetFileThumbnailLocation(filepath); * * if (thumbLocation != null) * { * MemoryStream msThumbnail = _parent.oXbmc.Media.FileDownload(thumbLocation); * * if (msThumbnail != null) * wSongInfo.Add(new Gtk.Image(new Gdk.Pixbuf(msThumbnail))); * } */ Label lArtist = new Label(songInfo); lArtist.ModifyFont(fd); lArtist.Xpad = 20; lArtist.Ypad = 20; wSongInfo.Add(lArtist); //Gtk.Image iCoverart = new Gtk.Image(new Gdk.Pixbuf(_parent.oXbmc.Media.GetFileThumbnailLocation(filepath))); //wSongInfo.Add(iCoverart); wSongInfo.ShowAll(); }
static void OnShowReadyEvent() { Gtk.Application.Invoke(delegate { BuildMainForm(); MainForm.SetDefaultSize(1280, 800); MainForm.SetPosition(WindowPosition.Center); MainForm.Icon = m_imageIconGray.Pixbuf; m_scrolledWindow = new ScrolledWindow(); m_webBrowser = new WebView(); m_webBrowser.Editable = false; m_webBrowser.Open("http://localhost:4649/index.html?mode=UI.Linux"); m_scrolledWindow.Add(m_webBrowser); MainForm.Add(m_scrolledWindow); MainForm.ShowAll(); Splash.Destroy(); }); }
public LoSDemo() { win = new Window ("main window"); win.SetDefaultSize(width, height); win.SetPosition(WindowPosition.Center); win.DeleteEvent += delegate { Application.Quit(); }; win.Add(drawArea); win.KeyPressEvent += onKeyPress; win.ButtonPressEvent += onButtonPress; drawArea.AddEvents ((int)Gdk.EventMask.ButtonPressMask); win.ShowAll(); player.setPosition (new PointD (80, 40)); GLib.Timeout.Add (frameTime, update); }
public PopupWindow() { Color bg = new Color(85, 87, 83); Color fg = new Color(211, 215, 207); EventBox box = new EventBox(); vbox = new VBox(); box.ButtonPressEvent += HandleButtonEvent; box.Add(vbox); win.Decorated = false; win.BorderWidth = 6; win.SetPosition(WindowPosition.CenterAlways); image = new Gtk.Image(); label = new Label(); label.CanFocus = false; label.Wrap = true; urlLabel = new LinkLabel(); urlLabel.Clicked += HandleClick; win.Add(box); win.ModifyBg(StateType.Normal, bg); label.ModifyFg(StateType.Normal, fg); box.ModifyBg(StateType.Normal, bg); urlLabel.ModifyBg(StateType.Selected, bg); urlLabel.ModifyBg(StateType.Normal, bg); vbox.PackStart(image, true, true, 0); vbox.PackStart(label, false, false, 0); vbox.PackStart(urlLabel, false, false, 0); vbox.Spacing = 6; box.ShowAll(); }
public void ShowSongInfoPopup(string filepath) { string sDuration = _parent.SecondsToHumanTime(_parent.oXbmc.Media.GetMusicTagByFilepath(filepath, "duration")); string songInfo = "\n\nartist: " + _parent.oXbmc.Media.GetMusicTagByFilepath(filepath, "artist"); songInfo += "\ntitle: " + _parent.oXbmc.Media.GetMusicTagByFilepath(filepath, "title"); songInfo += "\nalbum: " + _parent.oXbmc.Media.GetMusicTagByFilepath(filepath, "album"); songInfo += "\ngenre: " + _parent.oXbmc.Media.GetMusicTagByFilepath(filepath, "genre"); songInfo += "\nduration: " + sDuration; Gtk.Window wSongInfo = new Gtk.Window("Song Info"); wSongInfo.SetPosition(WindowPosition.CenterAlways); wSongInfo.SetIconFromFile("images/icon.png"); Pango.FontDescription fd = Pango.FontDescription.FromString("Verdana Bold 9"); /* string thumbLocation = _parent.oXbmc.Media.GetFileThumbnailLocation(filepath); if (thumbLocation != null) { MemoryStream msThumbnail = _parent.oXbmc.Media.FileDownload(thumbLocation); if (msThumbnail != null) wSongInfo.Add(new Gtk.Image(new Gdk.Pixbuf(msThumbnail))); } */ Label lArtist = new Label(songInfo); lArtist.ModifyFont(fd); lArtist.Xpad = 20; lArtist.Ypad = 20; wSongInfo.Add(lArtist); //Gtk.Image iCoverart = new Gtk.Image(new Gdk.Pixbuf(_parent.oXbmc.Media.GetFileThumbnailLocation(filepath))); //wSongInfo.Add(iCoverart); wSongInfo.ShowAll(); }
public static void Main() { Application.Init (); //Create the new window Window myWindow = new Window (""); myWindow.Resize (300, 300); myWindow.SetPosition (WindowPosition.Center); myWindow.ModifyBg (StateType.Normal, new Gdk.Color (174, 229, 218)); //Creamos una etiqueta Label label = new Label (); label.Text = "Mi 1.º aplicación con GTK"; //Añadimos la etiqueta al formulario myWindow.Add (label); //Ver todo myWindow.ShowAll (); Application.Run (); }
public void GetFileInfo() { TreeModel selectedModel; TreeIter selectedIter = new TreeIter(); if (_parent._tvShares.Selection.GetSelected(out selectedModel, out selectedIter)) { string filepath = selectedModel.GetValue(selectedIter, 2).ToString(); string sDuration = _parent.oHelper.SecondsToHumanTime(_parent.oXbmc.Media.GetMusicTagByFilepath(filepath, "duration")); string songInfo = "artist: " + _parent.oXbmc.Media.GetMusicTagByFilepath(filepath, "artist"); songInfo += "\ntitle: " + _parent.oXbmc.Media.GetMusicTagByFilepath(filepath, "title"); songInfo += "\nalbum: " + _parent.oXbmc.Media.GetMusicTagByFilepath(filepath, "album"); songInfo += "\ngenre: " + _parent.oXbmc.Media.GetMusicTagByFilepath(filepath, "genre"); songInfo += "\nduration: " + sDuration; Window wSongInfo = new Window("Song Info"); wSongInfo.SetPosition(WindowPosition.CenterAlways); wSongInfo.SetIconFromFile("images/icon.png"); Pango.FontDescription fd = Pango.FontDescription.FromString("Verdana Bold 9"); Label lArtist = new Label(songInfo); lArtist.ModifyFont(fd); lArtist.Xpad = 20; lArtist.Ypad = 20; wSongInfo.Add(lArtist); //Gtk.Image iCoverart = new Gtk.Image(new Gdk.Pixbuf(_parent.oXbmc.Media.GetFileThumbnailLocation(filepath))); //wSongInfo.Add(iCoverart); wSongInfo.ShowAll(); //_parent.Messagebox(songInfo); } }
public notas_medicas(string LoginEmp, string NomEmpleado_, string AppEmpleado_, string ApmEmpleado_, string title_window, string name_field_, string pidpaciente_, string folioservicio_, string iddoctor_, string nombredoctor_, string nombrepaciente_, bool altapaciente_, string edadpaciente_, string diagnosticoadmision_) { connectionString = conexion_a_DB._url_servidor + conexion_a_DB._port_DB + conexion_a_DB._usuario_DB + conexion_a_DB._passwrd_user_DB; nombrebd = conexion_a_DB._nombrebd; LoginEmpleado = LoginEmp; NomEmpleado = NomEmpleado_; AppEmpleado = AppEmpleado_; ApmEmpleado = ApmEmpleado_; name_field = name_field_; pidpaciente = pidpaciente_; folioservicio = folioservicio_; nombredoctor = nombredoctor_; diagnosticoadmision = diagnosticoadmision_; sql_pidpaciente = " AND osiris_his_informacion_medica.pid_paciente = '" + pidpaciente + "' "; sql_folioservicio = " AND osiris_his_informacion_medica.folio_de_servicio = '" + folioservicio + "' "; sql_filtronotasblanco = " AND " + name_field + " <> '' "; Glade.XML gxml = new Glade.XML(null, "hospitalizacion.glade", "notas_medicas_enfermeria", null); gxml.Autoconnect(this); notas_medicas_enfermeria.Show(); notas_medicas_enfermeria.SetPosition(WindowPosition.Center); // centra la ventana en la pantalla notas_medicas_enfermeria.Title = title_window; button_salir.Clicked += new EventHandler(on_cierraventanas_clicked); button_guardar.Clicked += new EventHandler(on_button_guardar_clicked); button_imprimir_notas.Clicked += new EventHandler(on_button_imprimir_notas_clicked); checkbutton_selectall.Clicked += new EventHandler(on_checkbutton_selectall_clicked); entry_fechanotas.Text = (string)DateTime.Now.ToString("yyyy-MM-dd"); entry_pid_paciente.Text = (string)pidpaciente; entry_nombre_paciente.Text = (string)nombrepaciente_; entry_numerotencion.Text = (string)folioservicio; entry_id_doctor.Text = (string)iddoctor_; entry_doctor.Text = (string)nombredoctor_; entry_edad_paciente.Text = (string)edadpaciente_; // action somatometria button_guardar_somato.Clicked += new EventHandler(on_button_guardar_somato_clicked); // Cambiando el color del fondo para distinguir la ventana switch (name_field) { case "notas_de_evolucion": textview1.ModifyBase(StateType.Normal, new Gdk.Color(255, 243, 169)); // Color Amarillo break; case "notas_de_enfermeria": textview1.ModifyBase(StateType.Normal, new Gdk.Color(255, 179, 235)); // Color Rosa break; case "indicaciones_medicas": textview1.ModifyBase(StateType.Normal, new Gdk.Color(152, 255, 255)); // Color Rosa break; } if (altapaciente_ == false) { button_guardar.Sensitive = false; textview2.Sensitive = false; entry_fechanotas.Sensitive = false; combobox_hora_nota.Sensitive = false; combobox_minutos_nota.Sensitive = false; } crea_treeview_notas(); crea_treeview_somatometria(); llena_horas_notas(); llenando_informacion(); }
public static void CheckWordDialog(object sender, EventArgs e) { var lab = new Gtk.Label("Zadejte slovo: "); var ent = new Gtk.Entry(); var but = new Gtk.Button("OK"); var div = new Gtk.HBox(false, 1); div.PackStart(lab); div.Add(ent); div.PackEnd(but); var checkWin = new Gtk.Window(Gtk.WindowType.Popup); checkWin.Add(div); checkWin.BorderWidth = 0; checkWin.Modal = true; checkWin.CanFocus = true; checkWin.SetPosition(WindowPosition.Mouse); checkWin.ShowAll(); ent.Activated += delegate { but.Click(); }; but.Clicked += delegate { checkWin.HideAll(); if (game.dictionary.Content(ent.Text)) { Gtk.MessageDialog ans = new Gtk.MessageDialog( game.Window, DialogFlags.DestroyWithParent, MessageType.Info, ButtonsType.Close, "Slovo \"" + ent.Text + "\" <b>je</b> ve slovníku" ); ans.Run(); ans.Destroy(); } else { Gtk.MessageDialog ans = new Gtk.MessageDialog( game.Window, DialogFlags.DestroyWithParent, MessageType.Info, ButtonsType.Close, "Slovo \"" + ent.Text + "\" <b>není</b> ve slovníku" ); ans.Run(); ans.Destroy(); } checkWin.Dispose(); checkWin.Destroy(); }; checkWin.KeyPressEvent += delegate(object o, KeyPressEventArgs args) { switch (args.Event.Key) { case Gdk.Key.Escape: checkWin.HideAll(); checkWin.Dispose(); checkWin.Destroy(); break; case Gdk.Key.ISO_Enter: but.Click(); break; } }; }
public void Start() { window = new Window(WindowType.Toplevel); window.SetPosition(WindowPosition.Mouse); window.KeepAbove = true; window.Resize(200, 150); window.Title = "Dimensions"; window.Deletable = false; Fixed fix = new Fixed(); // width widthLabel = new Label(); widthLabel.Text = "Width"; fix.Put(widthLabel, 15, 25); widthInputEntry = new Entry(); widthInputEntry.SetSizeRequest(100, 25); widthInputEntry.TextInserted += OnlyNumber; widthInputEntry.TextInserted += ChangeWidth; widthInputEntry.TextDeleted += ChangeWidth; fix.Put(widthInputEntry, 80, 20); // height heightLabel = new Label(); heightLabel.Text = "Height"; fix.Put(heightLabel, 15, 75); heightInputEntry = new Entry(); heightInputEntry.SetSizeRequest(100, 25); heightInputEntry.TextInserted += OnlyNumber; heightInputEntry.TextInserted += ChangeHeight; heightInputEntry.TextDeleted += ChangeHeight; fix.Put(heightInputEntry, 80, 70); // Buttons okButton = new Button(); okButton.Label = "OK"; okButton.SetSizeRequest(80, 30); okButton.Clicked += okButton_Clicked; fix.Put(okButton, 10, 110); cancelButton = new Button(); cancelButton.Label = "Cancel"; cancelButton.SetSizeRequest(80, 30); cancelButton.Clicked += cancelButton_Clicked; fix.Put(cancelButton, 110, 110); window.Add(fix); window.ShowAll(); widthInputEntry.Text = "" + width; heightInputEntry.Text = "" + height; }
public void Run() { Gtk.Application.Init(); SetupTheme(); ApiExtensibility.Register(typeof(Windows.UI.Core.ICoreWindowExtension), o => new GtkCoreWindowExtension(o)); ApiExtensibility.Register <Windows.UI.Xaml.Application>(typeof(Uno.UI.Xaml.IApplicationExtension), o => new GtkApplicationExtension(o)); ApiExtensibility.Register(typeof(Windows.UI.ViewManagement.IApplicationViewExtension), o => new GtkApplicationViewExtension(o)); ApiExtensibility.Register(typeof(ISystemThemeHelperExtension), o => new GtkSystemThemeHelperExtension(o)); ApiExtensibility.Register(typeof(Windows.Graphics.Display.IDisplayInformationExtension), o => _displayInformationExtension ??= new GtkDisplayInformationExtension(o, _window)); ApiExtensibility.Register <TextBoxView>(typeof(ITextBoxViewExtension), o => new TextBoxViewExtension(o, _window)); ApiExtensibility.Register(typeof(ILauncherExtension), o => new LauncherExtension(o)); ApiExtensibility.Register <FileOpenPicker>(typeof(IFileOpenPickerExtension), o => new FileOpenPickerExtension(o)); ApiExtensibility.Register <FolderPicker>(typeof(IFolderPickerExtension), o => new FolderPickerExtension(o)); ApiExtensibility.Register(typeof(IClipboardExtension), o => new ClipboardExtensions(o)); ApiExtensibility.Register <FileSavePicker>(typeof(IFileSavePickerExtension), o => new FileSavePickerExtension(o)); _isDispatcherThread = true; _window = new Gtk.Window("Uno Host"); Size preferredWindowSize = ApplicationView.PreferredLaunchViewSize; if (preferredWindowSize != Size.Empty) { _window.SetDefaultSize((int)preferredWindowSize.Width, (int)preferredWindowSize.Height); } else { _window.SetDefaultSize(1024, 800); } _window.SetPosition(Gtk.WindowPosition.Center); _window.Realized += (s, e) => { // Load the correct cursors before the window is shown // but after the window has been initialized. Cursors.Reload(); }; _window.DeleteEvent += delegate { Gtk.Application.Quit(); }; bool EnqueueNative(DispatcherQueuePriority priority, DispatcherQueueHandler callback) { Dispatch(() => callback()); return(true); } Windows.System.DispatcherQueue.EnqueueNativeOverride = EnqueueNative; void Dispatch(System.Action d) { if (Gtk.Application.EventsPending()) { Gtk.Application.RunIteration(false); } GLib.Idle.Add(delegate { if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Trace)) { this.Log().Trace($"Iteration"); } try { d(); } catch (Exception e) { Console.WriteLine(e); } return(false); }); } Windows.UI.Core.CoreDispatcher.DispatchOverride = Dispatch; Windows.UI.Core.CoreDispatcher.HasThreadAccessOverride = () => _isDispatcherThread; _window.Realized += (s, e) => { WUX.Window.Current.OnNativeSizeChanged(new Windows.Foundation.Size(_window.AllocatedWidth, _window.AllocatedHeight)); }; _window.SizeAllocated += (s, e) => { WUX.Window.Current.OnNativeSizeChanged(new Windows.Foundation.Size(e.Allocation.Width, e.Allocation.Height)); }; _window.WindowStateEvent += OnWindowStateChanged; var overlay = new Overlay(); _eventBox = new EventBox(); _area = new UnoDrawingArea(); _fix = new Fixed(); overlay.Add(_area); overlay.AddOverlay(_fix); _eventBox.Add(overlay); _window.Add(_eventBox); /* avoids double invokes at window level */ _area.AddEvents((int)GtkCoreWindowExtension.RequestedEvents); _window.ShowAll(); void CreateApp(ApplicationInitializationCallbackParams _) { var app = _appBuilder(); app.Host = this; } WUX.Application.Start(CreateApp, _args); UpdateWindowPropertiesFromPackage(); Gtk.Application.Run(); }
protected void OpenFile(object sender, EventArgs e) { FileChooserDialog fc = new FileChooserDialog("Choose the directory containing the hives to open", this, FileChooserAction.SelectFolder, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept); if (fc.Run() == (int)ResponseType.Accept) { string dir = fc.Filename; fc.Destroy(); List <Thread> threads = new List <Thread>(); Window window = new Gtk.Window(Gtk.WindowType.Toplevel); VBox progressBox = new VBox(false, 5); reading = new Label("Reading hives, please wait..."); pulseBar = new ProgressBar(); progressBox.PackStart(reading, true, true, 0); progressBox.PackStart(pulseBar, true, true, 0); reading.Show(); pulseBar.Show(); progressBox.Show(); window.Add(progressBox); window.SetPosition(Gtk.WindowPosition.CenterOnParent); window.SetSizeRequest(500, 100); window.Title = "Loading..."; window.Show(); _hives = new List <RegistryHive>(); _filenames = new List <string>(); foreach (var file in System.IO.Directory.GetFiles(dir)) { using (BinaryReader reader = new BinaryReader(File.OpenRead(file))) { reader.BaseStream.Position = 0; if (reader.BaseStream.Length > 4) { byte[] magic = reader.ReadBytes(4); if (magic[0] == 'r' && magic[1] == 'e' && magic[2] == 'g' && magic[3] == 'f') { _total += reader.BaseStream.Length; _filenames.Add(file); } } } } threads = GetReadThreads(); foreach (Thread thread in threads) { thread.Start(); } new Thread(new ThreadStart(delegate { foreach (Thread thread in threads) { while (thread.IsAlive) { Application.Invoke(delegate { pulseBar.Pulse(); }); System.Threading.Thread.Sleep(100); } } Application.Invoke(delegate { window.Destroy(); Populate(); }); })).Start(); } else { fc.Destroy(); } }
void okButton_Clicked(object sender, EventArgs e) { if(width > max || height > max) { Window messageWindow = new Window("Info"); messageWindow.SetSizeRequest(250, 100); messageWindow.SetPosition(WindowPosition.Mouse); MessageDialog messageDialog = new MessageDialog(messageWindow, DialogFlags.DestroyWithParent, MessageType.Info, ButtonsType.Close, "Width and height have to be below 6000"); messageDialog.Run(); messageDialog.Destroy(); return; } response = ResponseType.Ok; }
public MainWindow() : base(Gtk.WindowType.Toplevel) { Build (); InfoAction.Sensitive=false; addAction.Sensitive=true; deleteAction.Sensitive=false; refreshAction.Sensitive=true; mySqlConnection.Open(); string sql="Select * from categoria"; string sql2="Select * from articulo"; if(notebook1.GetTabLabelText(notebook1.GetNthPage(0)).Equals("Categoria")){ tree1=new TreeViewHelper(treeview2,mySqlConnection,sql); } if(notebook1.GetTabLabelText(notebook1.GetNthPage(1)).Equals("Articulo")){ tree2=new TreeViewHelper(treeview1,mySqlConnection,sql2); } InfoAction.Activated +=delegate{ listStore=creaListStore(); string op=listStore.GetValue(iter,1).ToString(); MessageDialog md = new MessageDialog (this, DialogFlags.Modal, MessageType.Info, ButtonsType.Close,op); md.Run(); md.Destroy(); }; addAction.Activated +=delegate{ win = new Window ("Test"); win.SetDefaultSize (300, 100); win.SetPosition(WindowPosition.Center); hbox=new HBox(false,0); vbox=new VBox(false,0); vbox2=new VBox(false,0); win.Add(hbox); hbox.PackStart(vbox,false,false,0); //hbox.PackStart(vbox2,false,false,0); if(esCategoria()){ creaVentanaCategoria(); } else{ win.SetDefaultSize (300, 200); creaVentanaArticulo(); } }; deleteAction.Activated +=delegate{ if(esCategoria()){ listStore=creaListStore(); string nombre=listStore.GetValue(iter,1).ToString(); MessageDialog md2 = new MessageDialog (this, DialogFlags.Modal, MessageType.Warning, ButtonsType.YesNo,"¿Seguro que quieres borrarlo? \n Borrar: "+nombre); ResponseType result = (ResponseType)md2.Run (); string op=listStore.GetValue(iter,0).ToString(); if (result == ResponseType.Yes){ MySqlCommand delete=mySqlConnection.CreateCommand(); delete.CommandText= "Delete from categoria where id="+op+""; delete.ExecuteNonQuery(); md2.Destroy(); } else{ md2.Destroy(); } } else{ listStore=creaListStore(); string nombre=listStore.GetValue(iter,1).ToString(); MessageDialog md2 = new MessageDialog (this, DialogFlags.Modal, MessageType.Warning, ButtonsType.YesNo,"¿Seguro que quieres borrarlo? \n Borrar: "+nombre); ResponseType result = (ResponseType)md2.Run (); string op=listStore.GetValue(iter,0).ToString(); if (result == ResponseType.Yes){ MySqlCommand delete=mySqlConnection.CreateCommand(); delete.CommandText= "Delete from articulo where id="+op+""; delete.ExecuteNonQuery(); md2.Destroy(); } else{ md2.Destroy(); } } }; notebook1.SwitchPage+=delegate{ if(esCategoria()){ bool isSelected=treeview2.Selection.GetSelected(out iter); if(isSelected){ InfoAction.Sensitive=true; addAction.Sensitive=true; deleteAction.Sensitive=true; refreshAction.Sensitive=true; } else{ InfoAction.Sensitive=false; //addAction.Sensitive=false; deleteAction.Sensitive=false; //refreshAction.Sensitive=false; } } else{ bool isSelected=treeview1.Selection.GetSelected(out iter); if(isSelected){ InfoAction.Sensitive=true; addAction.Sensitive=true; deleteAction.Sensitive=true; refreshAction.Sensitive=true; } else{ InfoAction.Sensitive=false; //addAction.Sensitive=false; deleteAction.Sensitive=false; //refreshAction.Sensitive=false; } } }; treeview1.Selection.Changed +=delegate{ if(!esCategoria()){ bool isSelected=treeview1.Selection.GetSelected(out iter); if(isSelected){ InfoAction.Sensitive=true; //addAction.Sensitive=true; deleteAction.Sensitive=true; refreshAction.Sensitive=true; } else{ InfoAction.Sensitive=false; //addAction.Sensitive=false; deleteAction.Sensitive=false; //refreshAction.Sensitive=false; } } }; treeview2.Selection.Changed +=delegate{ if(esCategoria()){ bool isSelected=treeview2.Selection.GetSelected(out iter); if(isSelected){ InfoAction.Sensitive=true; //addAction.Sensitive=true; deleteAction.Sensitive=true; refreshAction.Sensitive=true; } else{ InfoAction.Sensitive=false; //addAction.Sensitive=false; deleteAction.Sensitive=false; //refreshAction.Sensitive=false; } } }; refreshAction.Activated +=delegate{ if(esCategoria()){ listStore=tree1.ListStore; fielCountCategoria=tree1.getFieldCount(); for (int i=0;i<fielCountCategoria;i++){//elimina columnas treeview2.RemoveColumn(treeview2.GetColumn(0)); } listStore.Clear(); listStore=tree1.ListStore; tree1.actualizar(dbCommand,listStore); } else{ listStore=tree2.ListStore; fieldCountArticulo=tree2.getFieldCount(); for (int i=0;i<fieldCountArticulo;i++){//elimina columnas treeview1.RemoveColumn(treeview1.GetColumn(0)); } listStore.Clear(); listStore=tree2.ListStore; tree2.actualizar(dbCommand,listStore); } }; }
protected void Populate() { this.SetDefaultSize(1024,768); Window pingpong = new Window(Gtk.WindowType.Toplevel); pingpong.SetDefaultSize(500,50); pingpong.SetPosition(Gtk.WindowPosition.CenterOnParent); pingpong.Title = "Loading..."; _pulseBar = new ProgressBar(); pingpong.Add(_pulseBar); pingpong.ShowAll(); pingpong.Show(); while (_currentStrs == null) { Application.Invoke( delegate { _pulseBar.Pulse(); }); Thread.Sleep(100); } Application.Invoke( delegate { pingpong.Destroy(); this.Remove(_vbox); _vbox = new VBox(false, 10); MenuBar bar = new MenuBar (); Menu fileMenu = new Menu (); MenuItem fileMenuItem = new MenuItem ("File"); fileMenuItem.Submenu = fileMenu; MenuItem exit = new MenuItem ("Exit"); exit.Activated += delegate(object sender, EventArgs e) { Application.Quit (); }; MenuItem openFile = new MenuItem ("Open file..."); openFile.Activated += OpenFile; fileMenu.Append (openFile); fileMenu.Append (exit); bar.Append (fileMenuItem); _vbox.PackStart(bar, false, false, 0); _regxTitle = ComboBox.NewText(); _regxTitle.Changed += HandleChanged; foreach (KeyValuePair<string, string> pair in _regexes) _regxTitle.AppendText(pair.Key); _regx = new Entry(); _regx.IsEditable = false; _regx.CanFocus = false; HBox comboRegexBox = new HBox(true, 10); comboRegexBox.SetSizeRequest(768, 50); comboRegexBox.PackStart(_regxTitle, false,false, 0); comboRegexBox.PackStart(_regx, true, true, 0); Button search = new Button("Search!"); search.Clicked += HandleClicked; comboRegexBox.PackStart(search, false, false, 20); _vbox.PackStart(comboRegexBox, true, true, 10); ScrolledWindow sw = new ScrolledWindow(); _tv = new TreeView(); sw.Add(_tv); CellRendererText tsText = new CellRendererText(); TreeViewColumn match = new TreeViewColumn(); match.Title = "Match"; match.PackStart(tsText, true); match.AddAttribute(tsText, "text", 0); _tv.AppendColumn(match); TreeStore store = new TreeStore(typeof(string)); foreach (string str in _currentStrs) store.AppendValues(str); _tv.Model = store; sw.SetSizeRequest(768,600); _vbox.PackStart(sw, false, false, 0); this.Add(_vbox); this.ShowAll(); }); }
static void LoginRequest(){ form = new LoginFormUI (); form.Build (); start = new Gtk.Window ("ログインフォーム"); start.SetPosition(Gtk.WindowPosition.Center); start.Add (form.table1); start.DeleteEvent += new DeleteEventHandler (OnQuit); start.ShowAll (); }
private void PushButton(object sender, EventArgs e) { Gtk.CheckButton check = new Gtk.CheckButton("Down"); Gtk.Entry input = new Gtk.Entry(15); Gtk.HBox divide = new Gtk.HBox(false, 0); Gtk.Button but = new Gtk.Button("OK"); input.Activated += delegate { but.Click(); }; divide.PackStart(input); divide.Add(check); divide.PackEnd(but); Gtk.Window w = new Gtk.Window(Gtk.WindowType.Popup); w.SetPosition(WindowPosition.Mouse); w.Add(divide); w.BorderWidth = 0; w.Modal = true; w.CanFocus = true; w.ShowAll(); but.Clicked += delegate { if (input.Text == "") { return; } int i, j; string[] name = ((Gtk.Button)sender).Name.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); i = int.Parse(name [1]); j = int.Parse(name [2]); w.HideAll(); if (this.game.GetActualPlayer().DoMove( new Lexicon.Move(new System.Drawing.Point(i - 1, j - 1), input.Text.ToUpperInvariant(), check.Active)) ) { w.Destroy(); if (!Scrabble.Game.InitialConfig.client) { this.game.changePlayer(); } } }; w.KeyPressEvent += delegate(object o, KeyPressEventArgs args) { switch (args.Event.Key) { case Gdk.Key.Escape: w.HideAll(); w.Dispose(); w.Destroy(); break; } }; }
public static void CheckWordDialog(object sender, EventArgs e) { var lab = new Gtk.Label("Zadejte slovo: "); var ent = new Gtk.Entry(); var but = new Gtk.Button("OK"); var div = new Gtk.HBox(false, 1 ); div.PackStart( lab ); div.Add( ent ); div.PackEnd( but ); var checkWin = new Gtk.Window( Gtk.WindowType.Popup ); checkWin.Add ( div ); checkWin.BorderWidth = 0; checkWin.Modal = true; checkWin.CanFocus = true; checkWin.SetPosition( WindowPosition.Mouse ); checkWin.ShowAll(); ent.Activated += delegate { but.Click(); }; but.Clicked += delegate { checkWin.HideAll(); if( game.dictionary.Content( ent.Text ) ) { Gtk.MessageDialog ans = new Gtk.MessageDialog( game.Window, DialogFlags.DestroyWithParent, MessageType.Info, ButtonsType.Close, "Slovo \""+ent.Text+"\" <b>je</b> ve slovníku" ); ans.Run(); ans.Destroy(); } else { Gtk.MessageDialog ans = new Gtk.MessageDialog( game.Window, DialogFlags.DestroyWithParent, MessageType.Info, ButtonsType.Close, "Slovo \""+ent.Text+"\" <b>není</b> ve slovníku" ); ans.Run(); ans.Destroy(); } checkWin.Dispose(); checkWin.Destroy(); }; checkWin.KeyPressEvent += delegate(object o, KeyPressEventArgs args) { switch( args.Event.Key ) { case Gdk.Key.Escape: checkWin.HideAll(); checkWin.Dispose(); checkWin.Destroy(); break; case Gdk.Key.ISO_Enter: but.Click(); break; } }; }
protected void OpenFile(object sender, EventArgs e) { FileChooserDialog fc = new FileChooserDialog ("Choose the directory containing the hives to open", this, FileChooserAction.SelectFolder, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept); if (fc.Run () == (int)ResponseType.Accept) { string dir = fc.Filename; fc.Destroy(); List<Thread> threads = new List<Thread>(); Window window = new Gtk.Window(Gtk.WindowType.Toplevel); VBox progressBox = new VBox(false, 5); reading = new Label("Reading hives, please wait..."); pulseBar = new ProgressBar(); progressBox.PackStart(reading, true, true, 0); progressBox.PackStart(pulseBar, true, true, 0); reading.Show(); pulseBar.Show (); progressBox.Show(); window.Add(progressBox); window.SetPosition(Gtk.WindowPosition.CenterOnParent); window.SetSizeRequest(500,100); window.Title = "Loading..."; window.Show(); _hives = new List<RegistryHive>(); _filenames = new List<string>(); foreach (var file in System.IO.Directory.GetFiles(dir)) { using (BinaryReader reader = new BinaryReader(File.OpenRead(file))) { reader.BaseStream.Position = 0; if (reader.BaseStream.Length > 4) { byte[] magic = reader.ReadBytes(4); if (magic[0] == 'r' && magic[1] == 'e' && magic[2] == 'g' && magic[3] == 'f') { _total += reader.BaseStream.Length; _filenames.Add(file); } } } } threads = GetReadThreads (); foreach (Thread thread in threads) thread.Start(); new Thread(new ThreadStart(delegate { foreach (Thread thread in threads) { while (thread.IsAlive) { Application.Invoke(delegate { pulseBar.Pulse(); }); System.Threading.Thread.Sleep(100); } } Application.Invoke(delegate { window.Destroy(); Populate(); }); })).Start(); } else fc.Destroy(); }
//////////////////////////////////////////////////////////////////// ///<summary> ///ThrowMessage receives a msg and show a window. ///Is intended to show exception messages ///</summary> // FIXME: Draw a better interface with l10n messages public static void ThrowMessage(string Msg, string short_msg) { Gtk.Window msgwindow = new Gtk.Window("Exception"); Gtk.VBox box = new Gtk.VBox(false, 0); Gtk.ScrolledWindow scrWin = new Gtk.ScrolledWindow(); Gtk.TextView txtView = new Gtk.TextView(); Gtk.TextBuffer buffer = txtView.Buffer; buffer.Text = "Critical exception: " + short_msg; buffer.Text += "\r\n \r\nReport for developers : " + Msg; Gtk.Button buttonAccept = new Button("Accept"); Gtk.Button buttonExit = new Button("Exit"); msgwindow.DeleteEvent += new DeleteEventHandler(OnDelete); buttonExit.Clicked += new EventHandler(OnDelete); msgwindow.DestroyEvent += new DestroyEventHandler(OnContinue); buttonAccept.Clicked += new EventHandler(OnContinue); msgwindow.Add(scrWin); scrWin.Add(txtView); box.Spacing = 20; box.PackStart(scrWin); box.PackStart(buttonExit); box.PackStart(buttonAccept); //txtView.Show(); //buttonExit.Show(); //box.Show(); msgwindow.DefaultHeight = 300; msgwindow.DefaultWidth = 600; msgwindow.SetPosition(WindowPosition.Center); msgwindow.ShowAll(); msgwindow.Present(); }
void ensure_error_window() { if (error_window != null) return; TextView text_view; ScrolledWindow sw; error_window = new Window (Mono.Unix.Catalog.GetString ("Errors from the capture process")); error_window.SetDefaultSize (400, 300); /* this sucks */ error_window.TransientFor = this; error_window.SetPosition (WindowPosition.CenterOnParent); sw = new ScrolledWindow (null, null); sw.HscrollbarPolicy = PolicyType.Automatic; sw.VscrollbarPolicy = PolicyType.Automatic; error_window.Add (sw); text_view = new TextView (); text_view.Editable = false; text_view.WrapMode = WrapMode.WordChar; sw.Add (text_view); sw.ShowAll (); error_buffer = text_view.Buffer; }
private void ventana(string titulo) { window = new Window (titulo); window.SetDefaultSize (300, 200); window.SetPosition(WindowPosition.Center); vbox=new VBox(); tabla=new Table(4,2,false); separaFilas(tabla,10); vbox.PackStart(tabla,false,false,0); }
public ClientErrorMessages(string Msg) { try { msgwindow = new Gtk.Window("Error"); vbox = new Gtk.VBox(false, 0); hbox = new Gtk.HBox(true, 1); label = new Gtk.Label(Msg); buttonAccept = new Button("Aceptar"); msgwindow.DeleteEvent += new DeleteEventHandler(OnDelete); msgwindow.DestroyEvent += new DestroyEventHandler(OnContinue); buttonAccept.Clicked += new EventHandler(OnContinue); msgwindow.Modal = true; msgwindow.Add(vbox); vbox.Spacing = 20; vbox.PackStart(label, false, false, 10); vbox.PackEnd(hbox, false, false, 10); hbox.PackEnd(buttonAccept, false, false, 10); //msgwindow.DefaultHeight = 150; //msgwindow.DefaultWidth = 400; msgwindow.SetPosition(WindowPosition.Center); msgwindow.ShowAll(); msgwindow.Present(); } catch (Exception ex) { Console.WriteLine("Excepcion grave"); } }
private static bool HandlePopupCallback () { if (! popped_up) { if (popup_window == null) { Button button; Table table; popup_window = new Gtk.Window (Gtk.WindowType.Popup); popup_window.SetPosition (WindowPosition.Mouse); table = new Table (3, 3, false); for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) { string label = String.Format ("{0},{1}", i, j); button = Button.NewWithLabel (label); table.Attach (button, (uint) i, (uint) i + 1, (uint) j, (uint) j + 1, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Expand | AttachOptions.Fill, 0, 0); Gtk.Drag.DestSet (button, DestDefaults.All, target_table, DragAction.Copy | DragAction.Move); button.DragMotion += new DragMotionHandler (HandlePopupMotion); button.DragLeave += new DragLeaveHandler (HandlePopupLeave); } table.ShowAll (); popup_window.Add (table); } popup_window.Show (); popped_up = true; } popdown_timer = GLib.Timeout.Add (500, new TimeoutHandler (HandlePopdownCallback)); popup_timer = 0; return false; }