public ToolBarComboBox(int width, int activeIndex, bool allowEntry, params string[] contents) { if (allowEntry) { ComboBox = ComboBoxText.NewWithEntry(); } else { ComboBox = new ComboBoxText(); } foreach (string entry in contents) { ComboBox.AppendText(entry); } ComboBox.AddEvents((int)Gdk.EventMask.ButtonPressMask); ComboBox.WidthRequest = width; if (activeIndex >= 0) { ComboBox.Active = activeIndex; } ComboBox.Show(); Add(ComboBox); Show(); }
public OpenLocationDialog() : base(Catalog.GetString("Open Location")) { var location_box = new HBox() { Spacing = 6 }; address_entry = ComboBoxText.NewWithEntry(); address_entry.Entry.Activated += (o, e) => Respond(ResponseType.Ok); var browse_button = new Button(Catalog.GetString("Browse...")); browse_button.Clicked += OnBrowseClicked; location_box.PackStart(address_entry, true, true, 0); location_box.PackStart(browse_button, false, false, 0); VBox.Spacing = 6; VBox.PackStart(new Label() { Xalign = 0.0f, Text = Catalog.GetString( "Enter the address of the file you would like to open:") }, false, false, 0); VBox.PackStart(location_box, false, false, 0); VBox.ShowAll(); AddStockButton(Stock.Cancel, ResponseType.Cancel); AddStockButton(Stock.Open, ResponseType.Ok, true); LoadHistory(); address_entry.Entry.HasFocus = true; }
public OpenRemoteServer() : base(Catalog.GetString("Open remote DAAP server"), null) { VBox.Spacing = 6; VBox.PackStart(new Label() { Xalign = 0.0f, Text = Catalog.GetString("Enter server IP address and port:") }, true, true, 0); HBox box = new HBox(); box.Spacing = 12; VBox.PackStart(box, false, false, 0); address_entry = ComboBoxText.NewWithEntry(); address_entry.Entry.Activated += OnEntryActivated; address_entry.Entry.WidthChars = 30; address_entry.Show(); port_entry = new SpinButton(1d, 65535d, 1d); port_entry.Value = 3689; port_entry.Show(); box.PackStart(address_entry, true, true, 0); box.PackEnd(port_entry, false, false, 0); address_entry.HasFocus = true; VBox.ShowAll(); AddStockButton(Stock.Cancel, ResponseType.Cancel); AddStockButton(Stock.Add, ResponseType.Ok, true); LoadHistory(); }
public (string, Widget) CreateEditableComboBox() { var combo = ComboBoxText.NewWithEntry(); combo.AppendText("Example 1"); combo.AppendText("Example 2"); combo.AppendText("Example 3"); combo.AppendText("Example 4"); // combos with entry have a real entry inside it // we can use it by combo.Entry.PlaceholderText = "Write something"; return("Combo with entry:", combo); }
public static Gtk.Window Create() { window = new Window("GtkComboBox"); window.SetDefaultSize(200, 100); VBox box1 = new VBox(false, 0); window.Add(box1); VBox box2 = new VBox(false, 10); box2.BorderWidth = 10; box1.PackStart(box2, true, true, 0); ComboBoxText combo = ComboBoxText.NewWithEntry(); combo.AppendText("Foo"); combo.AppendText("Bar"); combo.Changed += new EventHandler(OnComboActivated); combo.Entry.Changed += new EventHandler(OnComboEntryChanged); box2.PackStart(combo, true, true, 0); HSeparator separator = new HSeparator(); box1.PackStart(separator, false, false, 0); box2 = new VBox(false, 10); box2.BorderWidth = 10; box1.PackStart(box2, false, false, 0); Button button = new Button(Stock.Close); button.Clicked += new EventHandler(OnCloseClicked); button.CanDefault = true; box2.PackStart(button, true, true, 0); button.GrabDefault(); return(window); }
/// <summary> /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.gbReceive = new Frame(); this.txtReceiveScrolledWindow = new ScrolledWindow(); this.txtReceive = new TextView(); //this.menuReceive = new ContextMenuStrip(this.components); //this.toolStripMenuItem1 = new ToolStripMenuItem(); //this.mi日志着色 = new ToolStripMenuItem(); //this.toolStripMenuItem3 = new ToolStripSeparator(); //this.mi显示应用日志 = new ToolStripMenuItem(); //this.mi显示编码日志 = new ToolStripMenuItem(); //this.mi显示发送数据 = new ToolStripMenuItem(); //this.mi显示接收数据 = new ToolStripMenuItem(); //this.mi显示统计信息 = new ToolStripMenuItem(); //this.menuSend = new ContextMenuStrip(this.components); //this.mi清空2 = new ToolStripMenuItem(); this.btnConnect = new Button(); //this.timer1 = new Timer(this.components); //this.fontDialog1 = new FontDialog(); //this.colorDialog1 = new ColorDialog(); this.label1 = new Label(); this.lbAddr = new Label(); this.cbMode = new ComboBox(new string[] {}); this.cbLocal = new ComboBox(new string[] { }); this.cbRemote = ComboBoxText.NewWithEntry(); this.pnlSetting = new HBox(); this.numPort = new SpinButton(1, 63353, 1); this.label5 = new Label(); this.gbSend = new Frame(); this.boxSend = new VBox(); this.boxSendSetting = new HBox(); this.numThreads = new SpinButton(1, 100000, 1); this.numSleep = new SpinButton(1000, 1000000, 1); this.txtSendScrolledWindow = new ScrolledWindow(); this.txtSend = new TextView(); this.btnSend = new Button(); this.numMutilSend = new SpinButton(1, 1000000, 1); this.label2 = new Label(); this.label7 = new Label(); this.label8 = new Label(); //this.toolTip1 = new ToolTip(this.components); //this.menuReceive.SuspendLayout(); //this.menuSend.SuspendLayout(); //this.SuspendLayout(); // // gbReceive // this.gbReceive.Add(this.txtReceiveScrolledWindow); this.gbReceive.Margin = 2; this.gbReceive.Name = "gbReceive"; //this.gbReceive.SetSizeRequest(878, 298); // gbReceive.Margin = 10; this.gbReceive.Label = "接收区:已接收0字节"; //this.gbReceive.Halign = Align.Fill; //this.gbReceive.Valign = Align.Fill; this.gbReceive.ShadowType = ShadowType.Out; // // txtReceiveScrolledWindow // this.txtReceiveScrolledWindow.Add(this.txtReceive); this.txtReceiveScrolledWindow.CanFocus = true; this.txtReceiveScrolledWindow.ShadowType = ShadowType.In; //this.txtReceiveScrolledWindow.Vexpand = true; // // txtReceive // // this.txtReceive.ContextMenuStrip = this.menuReceive; // this.txtReceive.Dock = DockStyle.Fill; // this.txtReceive.HideSelection = false; // this.txtReceive.Location = new System.Drawing.Point(4, 25); this.txtReceive.Margin = 1; this.txtReceive.Name = "txtReceive"; // this.txtReceive.Size = new System.Drawing.Size(970, 269); this.txtReceive.Editable = false; // 滚动方法 https://stackoverflow.com/questions/37824865/gtk-textview-auto-scroll-when-text-is-added-to-text-buffer this.txtReceive.SizeAllocated += TxtReceive_SizeAllocated; //// //// menuReceive //// //this.menuReceive.ImageScalingSize = new System.Drawing.Size(32, 32); //this.menuReceive.Items.AddRange(new ToolStripItem[] { //this.toolStripMenuItem1, //this.mi日志着色, //this.toolStripMenuItem3, //this.mi显示应用日志, //this.mi显示编码日志, //this.mi显示发送数据, //this.mi显示接收数据, //this.mi显示统计信息}); //this.menuReceive.Name = "menuSend"; //this.menuReceive.Size = new System.Drawing.Size(189, 206); //// //// toolStripMenuItem1 //// //this.toolStripMenuItem1.Name = "toolStripMenuItem1"; //this.toolStripMenuItem1.Size = new System.Drawing.Size(188, 28); //this.toolStripMenuItem1.Text = "清空"; //this.toolStripMenuItem1.Click += new System.EventHandler(this.mi清空_Click); //// //// mi日志着色 //// //this.mi日志着色.Name = "mi日志着色"; //this.mi日志着色.Size = new System.Drawing.Size(188, 28); //this.mi日志着色.Text = "日志着色"; //this.mi日志着色.Click += new System.EventHandler(this.miCheck_Click); //// //// toolStripMenuItem3 //// //this.toolStripMenuItem3.Name = "toolStripMenuItem3"; //this.toolStripMenuItem3.Size = new System.Drawing.Size(185, 6); //// //// mi显示应用日志 //// //this.mi显示应用日志.Name = "mi显示应用日志"; //this.mi显示应用日志.Size = new System.Drawing.Size(188, 28); //this.mi显示应用日志.Text = "显示应用日志"; //this.mi显示应用日志.Click += new System.EventHandler(this.miCheck_Click); //// //// mi显示编码日志 //// //this.mi显示编码日志.Name = "mi显示编码日志"; //this.mi显示编码日志.Size = new System.Drawing.Size(188, 28); //this.mi显示编码日志.Text = "显示编码日志"; //this.mi显示编码日志.Click += new System.EventHandler(this.miCheck_Click); //// //// mi显示发送数据 //// //this.mi显示发送数据.Name = "mi显示发送数据"; //this.mi显示发送数据.Size = new System.Drawing.Size(188, 28); //this.mi显示发送数据.Text = "显示发送数据"; //this.mi显示发送数据.Click += new System.EventHandler(this.miCheck_Click); //// //// mi显示接收数据 //// //this.mi显示接收数据.Name = "mi显示接收数据"; //this.mi显示接收数据.Size = new System.Drawing.Size(188, 28); //this.mi显示接收数据.Text = "显示接收数据"; //this.mi显示接收数据.Click += new System.EventHandler(this.miCheck_Click); //// //// mi显示统计信息 //// //this.mi显示统计信息.Name = "mi显示统计信息"; //this.mi显示统计信息.Size = new System.Drawing.Size(188, 28); //this.mi显示统计信息.Text = "显示统计信息"; //this.mi显示统计信息.Click += new System.EventHandler(this.miCheck_Click); //// //// menuSend //// //this.menuSend.ImageScalingSize = new System.Drawing.Size(32, 32); //this.menuSend.Items.AddRange(new ToolStripItem[] { //this.mi清空2}); //this.menuSend.Name = "menuSend"; //this.menuSend.Size = new System.Drawing.Size(117, 32); //// //// mi清空2 //// //this.mi清空2.Name = "mi清空2"; //this.mi清空2.Size = new System.Drawing.Size(116, 28); //this.mi清空2.Text = "清空"; //this.mi清空2.Click += new System.EventHandler(this.mi清空2_Click); // // btnConnect // // this.btnConnect.Location = new System.Drawing.Point(748, 12); this.btnConnect.Margin = 4; this.btnConnect.Name = "btnConnect"; // this.btnConnect.Size = new System.Drawing.Size(100, 44); // this.btnConnect.TabIndex = 3; this.btnConnect.Label = "打开"; this.btnConnect.Clicked += new System.EventHandler(this.btnConnect_Click); //// //// timer1 //// //this.timer1.Enabled = true; //this.timer1.Interval = 300; //this.timer1.Tick += new System.EventHandler(this.timer1_Tick); // // label1 // //this.label1.AutoSize = true; this.label1.Xalign = 0.8F; this.label1.Yalign = 0.5F; this.label1.MarginTop = 4; this.label1.MarginBottom = 4; this.label1.Name = "label1"; //this.label1.WidthRequest = 62; //this.label1.HeightRequest = 18; this.label1.Text = "模式:"; // // lbAddr // // this.lbAddr.AutoSize = true; // this.lbAddr.Location = new System.Drawing.Point(374, 14); this.lbAddr.Xalign = 0.8F; this.lbAddr.Yalign = 0.5F; this.lbAddr.MarginTop = 4; this.lbAddr.MarginBottom = 4; this.lbAddr.Name = "lbAddr"; //this.lbAddr.WidthRequest = 62; //this.lbAddr.HeightRequest = 18; this.lbAddr.Text = "远程:"; // // cbMode // //this.cbMode.DropDownStyle = ComboBoxStyle.DropDownList; //this.cbMode.FormattingEnabled = true; //this.cbMode.Location = new System.Drawing.Point(72, 11); //this.cbMode.Margin = 4; this.cbMode.Active = 1; this.cbMode.Name = "cbMode"; //this.cbMode.SetSizeRequest(1, 1); this.cbMode.Changed += new System.EventHandler(this.cbMode_SelectedIndexChanged); // // cbLocal // //this.cbLocal.Active = 1; this.cbLocal.Name = "cbLocal"; //this.cbLocal.SetSizeRequest(1, 1); //this.cbLocal.Changed += new System.EventHandler(this.cbLocal_SelectedIndexChanged); // // cbRemote // //this.cbRemote.Margin = 4; this.cbRemote.Name = "cbRemote"; //this.cbRemote.SetSizeRequest(200, 18); // this.cbRemote.Size = new System.Drawing.Size(247, 26); this.cbRemote.Sensitive = true; //this.cbRemote. // // pnlSetting // this.pnlSetting.PackStart(this.label1, false, false, 1); this.pnlSetting.PackStart(this.cbMode, false, false, 1); this.pnlSetting.PackStart(this.label5, false, false, 1); this.pnlSetting.PackStart(this.cbLocal, false, false, 1); this.pnlSetting.PackStart(this.lbAddr, false, false, 1); this.pnlSetting.PackStart(this.cbRemote, false, false, 1); this.pnlSetting.PackStart(this.numPort, false, false, 1); this.pnlSetting.PackStart(this.btnConnect, false, false, 1); //this.pnlSetting.Add(); //this.pnlSetting.Position = 5;// .Location = new System.Drawing.Point(14, 12); this.pnlSetting.Margin = 2; this.pnlSetting.Name = "pnlSetting"; // this.pnlSetting.Valign = Align.Fill; // this.pnlSetting.Halign = Align.Fill; // this.pnlSetting.SetSizeRequest(708, 20); // pnlSetting.Orientation = Orientation.Horizontal; //this.pnlSetting.Size = new System.Drawing.Size(708, 46); //this.pnlSetting.TabIndex = 13; // // numPort // // this.numPort.Location = new System.Drawing.Point(270, 10); this.numPort.Margin = 4; this.numPort.Name = "numPort"; this.numPort.Value = 8080; //this.numPort.SetSizeRequest(94, 28); // // label5 // //this.label5.AutoSize = true; //this.label5.Location = new System.Drawing.Point(218, 14); this.label5.Xalign = 0.8F; this.label5.Yalign = 0.5F; this.label5.MarginTop = 4; this.label5.MarginBottom = 4; this.label5.Name = "label5"; //this.label5.SetSizeRequest(62, 18); this.label5.Text = "本地:"; // // gbSend // this.gbSend.Add(this.boxSend); // this.gbSend.Controls.Add(this.numThreads); // this.gbSend.Controls.Add(this.numSleep); // this.gbSend.Controls.Add(this.btnSend); // this.gbSend.Controls.Add(this.numMutilSend); // this.gbSend.Controls.Add(this.label2); // this.gbSend.Controls.Add(this.label7); // this.gbSend.Location = new System.Drawing.Point(14, 424); this.gbSend.Margin = 1; this.gbSend.Name = "gbSend"; //this.gbSend.SetSizeRequest(778, 126); this.gbSend.Label = "发送区:已发送0字节"; // // boxSend // this.boxSend.PackStart(this.txtSendScrolledWindow, false, false, 2); this.boxSend.PackStart(this.boxSendSetting, false, false, 2); // this.boxSend.Orientation = Orientation.Vertical; this.boxSend.Margin = 1; this.boxSend.Name = "boxSend"; // // boxSendSetting // this.boxSendSetting.PackStart(this.label7, false, false, 2); this.boxSendSetting.PackStart(this.numMutilSend, false, false, 2); this.boxSendSetting.PackStart(this.label8, false, false, 2); this.boxSendSetting.PackStart(this.numThreads, false, false, 2); this.boxSendSetting.PackStart(this.label2, false, false, 2); this.boxSendSetting.PackStart(this.numSleep, false, false, 2); this.boxSendSetting.PackStart(this.btnSend, false, false, 2); this.boxSendSetting.Margin = 1; this.boxSendSetting.Name = "sendSetting"; // // numThreads // this.numThreads.Margin = 4; this.numThreads.Name = "numThreads"; //this.numThreads.SetSizeRequest(78, 28); // this.toolTip1.SetToolTip(this.numThreads, "模拟多客户端发送,用于压力测试!"); // // numSleep // this.numSleep.Margin = 1; this.numSleep.Name = "numSleep"; //this.numSleep.SetSizeRequest(109, 28); // // txtSendScrolledWindow // this.txtSendScrolledWindow.CanFocus = true; this.txtSendScrolledWindow.ShadowType = ShadowType.In; this.txtSendScrolledWindow.Vexpand = true; this.txtSendScrolledWindow.Add(this.txtSend); // // txtSend // // this.txtSend.ContextMenuStrip = this.menuSend; // this.txtSend.Location = new System.Drawing.Point(0, 28); this.txtSend.Margin = 4; this.txtSend.Name = "txtSend"; //this.txtSend.SetSizeRequest(621, 86); this.txtSend.WrapMode = WrapMode.Word; //this.txtSend.Editable = false; // // btnSend // this.btnSend.Margin = 4; this.btnSend.Name = "btnSend"; //this.btnSend.SetSizeRequest(75, 45); this.btnSend.Label = "发送"; this.btnSend.Clicked += new System.EventHandler(this.btnSend_Click); // // numMutilSend // this.numMutilSend.Margin = 4; this.numMutilSend.Name = "numMutilSend"; //this.numMutilSend.SetSizeRequest(109, 28); // // label2 // // this.label2.Location = new System.Drawing.Point(729, 87); this.label2.Margin = 4; this.label2.Name = "label2"; //this.label2.SetSizeRequest(62, 18); this.label2.Text = "间隔:"; // // label7 // // this.label7.Location = new System.Drawing.Point(729, 39); this.label7.Margin = 4; this.label7.Name = "label7"; //this.label7.SetSizeRequest(62, 18); this.label7.Text = "次数:"; // // label8 // this.label8.Margin = 4; this.label8.Name = "label8"; //this.label8.SetSizeRequest(62, 18); this.label8.Text = "线程:"; //// //// FrmMain //// //this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F); //this.AutoScaleMode = AutoScaleMode.Font; //this.ClientSize = new System.Drawing.Size(1000, 568); this.PackStart(this.pnlSetting, false, false, 2); this.PackStart(this.gbReceive, true, true, 2); this.PackStart(this.gbSend, false, false, 2); //this.Margin = new Padding(4); //this.Name = "FrmMain"; //this.StartPosition = FormStartPosition.CenterScreen; //this.Text = "Api调试"; this.Shown += new System.EventHandler(this.FrmMain_Load); //this.menuReceive.ResumeLayout(false); //this.menuSend.ResumeLayout(false); //this.pnlSetting.ResumeLayout(false); //this.pnlSetting.PerformLayout(); //((System.ComponentModel.ISupportInitialize)(this.numPort)).EndInit(); //((System.ComponentModel.ISupportInitialize)(this.numThreads)).EndInit(); //((System.ComponentModel.ISupportInitialize)(this.numSleep)).EndInit(); //((System.ComponentModel.ISupportInitialize)(this.numMutilSend)).EndInit(); //this.ResumeLayout(false); //this.PerformLayout(); //this.Fill = true; //this.Halign = Align.Fill; //this.Valign = Align.Fill; this.Orientation = Orientation.Vertical; }
public StationEditor(DatabaseTrackInfo track) : base() { AccelGroup accel_group = new AccelGroup(); AddAccelGroup(accel_group); Title = String.Empty; SkipTaskbarHint = true; Modal = true; this.track = track; string title = track == null ? Catalog.GetString("Add new radio station") : Catalog.GetString("Edit radio station"); BorderWidth = 6; DefaultResponse = ResponseType.Ok; Modal = true; ContentArea.Spacing = 6; HBox split_box = new HBox(); split_box.Spacing = 12; split_box.BorderWidth = 6; Image image = new Image(); image.IconSize = (int)IconSize.Dialog; image.IconName = "radio"; image.Yalign = 0.0f; image.Show(); VBox main_box = new VBox(); main_box.BorderWidth = 5; main_box.Spacing = 10; Label header = new Label(); header.Markup = String.Format("<big><b>{0}</b></big>", GLib.Markup.EscapeText(title)); header.Xalign = 0.0f; header.Show(); Label message = new Label(); message.Text = Catalog.GetString("Enter the Genre, Title and URL of the radio station you wish to add. A description is optional."); message.Xalign = 0.0f; message.Wrap = true; message.Show(); table = new Table(5, 2, false); table.RowSpacing = 6; table.ColumnSpacing = 6; genre_entry = ComboBoxText.NewWithEntry(); foreach (string genre in ServiceManager.DbConnection.QueryEnumerable <string> ("SELECT DISTINCT Genre FROM CoreTracks ORDER BY Genre")) { if (!String.IsNullOrEmpty(genre)) { genre_entry.AppendText(genre); } } if (track != null && !String.IsNullOrEmpty(track.Genre)) { genre_entry.Entry.Text = track.Genre; } AddRow(Catalog.GetString("Station Genre:"), genre_entry); name_entry = AddEntryRow(Catalog.GetString("Station Name:")); stream_entry = AddEntryRow(Catalog.GetString("Stream URL:")); creator_entry = AddEntryRow(Catalog.GetString("Station Creator:")); description_entry = AddEntryRow(Catalog.GetString("Description:")); rating_entry = new RatingEntry(); HBox rating_box = new HBox(); rating_box.PackStart(rating_entry, false, false, 0); AddRow(Catalog.GetString("Rating:"), rating_box); table.ShowAll(); main_box.PackStart(header, false, false, 0); main_box.PackStart(message, false, false, 0); main_box.PackStart(table, false, false, 0); main_box.Show(); split_box.PackStart(image, false, false, 0); split_box.PackStart(main_box, true, true, 0); split_box.Show(); ContentArea.PackStart(split_box, true, true, 0); Button cancel_button = new Button(Stock.Cancel); cancel_button.CanDefault = false; cancel_button.UseStock = true; cancel_button.Show(); AddActionWidget(cancel_button, ResponseType.Close); cancel_button.AddAccelerator("activate", accel_group, (uint)Gdk.Key.Escape, 0, Gtk.AccelFlags.Visible); save_button = new Button(Stock.Save); save_button.CanDefault = true; save_button.UseStock = true; save_button.Sensitive = false; save_button.Show(); AddActionWidget(save_button, ResponseType.Ok); save_button.AddAccelerator("activate", accel_group, (uint)Gdk.Key.Return, 0, Gtk.AccelFlags.Visible); name_entry.HasFocus = true; if (track != null) { if (!String.IsNullOrEmpty(track.TrackTitle)) { name_entry.Text = track.TrackTitle; } if (!String.IsNullOrEmpty(track.Uri.AbsoluteUri)) { stream_entry.Text = track.Uri.AbsoluteUri; } if (!String.IsNullOrEmpty(track.Comment)) { description_entry.Text = track.Comment; } if (!String.IsNullOrEmpty(track.ArtistName)) { creator_entry.Text = track.ArtistName; } rating_entry.Value = track.Rating; } error_container = new Alignment(0.0f, 0.0f, 1.0f, 1.0f); error_container.TopPadding = 6; HBox error_box = new HBox(); error_box.Spacing = 4; Image error_image = new Image(); error_image.Stock = Stock.DialogError; error_image.IconSize = (int)IconSize.Menu; error_image.Show(); error = new Label(); error.Xalign = 0.0f; error.Show(); error_box.PackStart(error_image, false, false, 0); error_box.PackStart(error, true, true, 0); error_box.Show(); error_container.Add(error_box); table.Attach(error_container, 0, 2, 6, 7, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Shrink, 0, 0); genre_entry.Entry.Changed += OnFieldsChanged; name_entry.Changed += OnFieldsChanged; stream_entry.Changed += OnFieldsChanged; OnFieldsChanged(this, EventArgs.Empty); }