public static void AppendItem(this Statusbar tb, ToolItem item, uint padding = 0) { item.Show(); tb.PackEnd(item, false, false, padding); }
/// <summary> /// Initializes a new instance of the <see cref="Scrabble.GUI.ScrabbleWindow"/> class. /// </summary> /// <param name='isClient'> /// Is client. /// </param> /// <exception cref='System.NullReferenceException'> /// Is thrown when there is an attempt to dereference a null object reference. /// </exception> public ScrabbleWindow(bool isClient = false) : base(Gtk.WindowType.Toplevel) { #region Basic window properties // Basic window properties this.Title = "Scrabble - Hrací deska" + (isClient ? " (klient)" : ""); this.Name = "MainWindow"; this.DoubleBuffered = true; this.SetPosition(WindowPosition.Center); this.Icon = Scrabble.Game.InitialConfig.icon; this.DeleteEvent += new global::Gtk.DeleteEventHandler(this.OnDeleteEvent); this.DefaultWidth = 550; this.DefaultHeight = 700; #endregion this.client = isClient; if (Scrabble.Game.InitialConfig.game == null) { throw new System.NullReferenceException("During Scrabble main widow initialization is Scrabble.Game.InitialConfig.game == null"); } this.game = Scrabble.Game.InitialConfig.game; // General GUI classes this.menu = new MenuHover(this); this.desk = new Desk(this.game); this.rack = new Rack(this.game); this.control = new Control(this.game); this.info = new Info(this.game); this.bottomVbox = new VBox(true, 4); this.bottomVbox.PackStart(rack); this.bottomVbox.PackEnd(control); this.bottomVbox.ShowAll(); this.vertical = new HPaned(); this.vertical.HeightRequest = 100; // Use only CLIENT clientNotice = new Label(); clientNotice.Markup = "<b>Čekám</b> na aktualizaci dat o hře."; clientNotice.TooltipText = "Na portu " + Scrabble.Game.InitialConfig.port.ToString(); // STATUSBAR statusbar = new Statusbar(); statusbar.HeightRequest = 20; statusbar.Homogeneous = true; StatusLabelLast = new Label("Poslední tah:"); StatusLabelBest = new Label("Nejlepší tah:"); OnTurnLabel = new Label("Na tahu:"); statusbar.PackStart(OnTurnLabel, false, false, 0); statusbar.Add(StatusLabelLast); statusbar.PackEnd(StatusLabelBest, false, false, 0); // Vertical divide at bottom this.vertical = new HPaned(); this.vertical.HeightRequest = 100; this.vertical.Add1(bottomVbox); this.vertical.Add2(info); this.mainVbox = new VBox(false, 5); if (isClient) { this.mainVbox.PackStart(clientNotice, false, false, 5); } else { this.mainVbox.PackStart(menu.menuBar, false, false, 0); } this.mainVbox.Add(desk); this.mainVbox.Add(vertical); this.mainVbox.PackEnd(statusbar, false, false, 0); this.Add(mainVbox); this.changePlayer(game.GetActualPlayer()); if (isClient) { DisableButtons(); } }
// private MenuButton languageSelectorButton; public RoboPad(WindowType type, String[] args) : base(type) { noOfWindows++; SetDefaultSize(500, 500); Maximize(); DeleteEvent += (sender, s) => { if (!isChangeSaved) { MessageDialog dialog = new MessageDialog(this, DialogFlags.DestroyWithParent, MessageType.Warning, ButtonsType.OkCancel, "Changes Unsaved Are You Sure You Want To Exit "); // Dialog dialog=new Dialog() var response = dialog.Run(); noOfWindows--; if (response == (int)Gtk.ResponseType.Ok) { if (noOfWindows <= 0) { Gtk.Application.Quit(); } } else { s.RetVal = true; } dialog.Dispose(); } else { noOfWindows--; if (noOfWindows <= 0) { Gtk.Application.Quit(); } } }; VBox vBox = new VBox(); List <String> newTextList = new(); var lm = LanguageManager.Default; sourceView = new(); sourceView.Buffer.HighlightSyntax = true; sourceView.WrapMode = WrapMode.Word; sourceView.AutoIndent = true; sourceView.ShowLineNumbers = true; StyleSchemeManager schemeManager = StyleSchemeManager.Default; // StyleScheme styleScheme = schemeManager.GetScheme("pop-light"); // sourceView.Buffer.StyleScheme = styleScheme; sourceView.KeyPressEvent += (o, eventArgs) => { if (Keyval.Name(eventArgs.Event.KeyValue) == "s") { saveFile(o, eventArgs); } else if (Keyval.Name(eventArgs.Event.KeyValue) == "S") { saveAsFile(o, eventArgs); } else if (Keyval.Name(eventArgs.Event.KeyValue) == "o") { openFile(o, eventArgs); } }; headerBar = new HeaderBar(); ScrolledWindow scrolledWindow = new ScrolledWindow(); scrolledWindow.Add(sourceView); headerBar.ShowCloseButton = true; headerBar.Title = "RoboPad"; headerBarOringalText = headerBar.Title; sourceView.Buffer.Changed += (sender, eventArgs) => { headerBar.Title = "*" + headerBarOringalText; if (sourceView.Buffer.Text != previousText) { isChangeSaved = false; } else { isChangeSaved = true; headerBar.Title = headerBarOringalText; } }; ToolButtonHandler toolbar = new ToolButtonHandler(this, sourceView); // Menu menu = new Menu(); // MenuItem openItem = new RadioMenuItem("test"); // menu.Add(openItem); // // menu.ShowAll(); // PopOverMenuHandler popoverMenu = new(this); MenuButton menuButton = new MenuButton(); menuButton.Popover = popoverMenu; Image image = Gtk.Image.NewFromIconName("view-more-symbolic", IconSize.LargeToolbar); menuButton.Image = image; headerBar.PackEnd(menuButton); Statusbar statusbar = new Statusbar(); statusBarLabel = new(""); statusbar.PackStart(statusBarLabel, false, false, 5); languageSelectorButton = new LanguageSelectorButton(sourceView); statusbar.PackEnd(languageSelectorButton, false, false, 5); // Box box = new Box(Gtk.Orientation.Vertical,2); Titlebar = headerBar; vBox.PackStart(toolbar, false, false, 0); vBox.PackStart(scrolledWindow, true, true, 0); vBox.PackStart(statusbar, false, false, 0); Add(vBox); ShowAll(); Show(); if (args != null) { if (args.Length >= 1) { if (!String.IsNullOrWhiteSpace(args[0])) { openFileWithArgs(args[0]); } } } }