private bool Refresh(Friend friend, bool BringFront = false)//调整控件顺序 { FriendTag TempTag = friend.Tag; FlowLayoutPanel TempChatPanel = friend.ChatPanel; string TempString = friend.Name + "Tag"; int pos = -1; for (int i = 0; i < FriendLayoutPanel.Controls.Count; i++) { if (FriendLayoutPanel.Controls[i].Name == TempString) { pos = i; break; } } if (pos == -1) { FriendLayoutPanel.Controls.Add(TempTag); Controls.Add(TempChatPanel); TempChatPanel.BringToFront(); BasicInfo.CurrentFriend = friend.Name;//更新当前聊天好友 return(true); } else { FriendLayoutPanel.Controls.RemoveAt(pos); FriendLayoutPanel.Controls.Add(TempTag); FriendLayoutPanel.Controls.SetChildIndex(TempTag, pos);//更新标签里最新的时间与消息 pos = -1; TempString = friend.Name + "ChatPanel"; for (int i = 0; i < this.Controls.Count; i++) { if (this.Controls[i].Name == TempString) { pos = i; break; } } if (pos > -1) { Controls.RemoveAt(pos); Controls.Add(TempChatPanel); //Controls.Add(friend.ChatPanel); if (pos == 0 || BringFront || BasicInfo.CurrentFriend == friend.Name) { //friend.ChatPanel.BringToFront(); TempChatPanel.BringToFront(); } return(true); } else { Console.WriteLine("对应的对话框怎么没有好友标签?"); return(false); } } }
public FolderImages(Form _formMain, FlowLayoutPanel _layoutPanel) { formMain = _formMain; layoutPanel = new FlowLayoutPanel(); layoutPanel.Name = "layoutPanelImages"; layoutPanel.BackColor = Color.White; layoutPanel.AutoScroll = true; formMain.Controls.Add(layoutPanel); layoutPanel.Location = new Point(0, 0); layoutPanel.Size = new Size(formMain.Width, formMain.Height - 160); formMain.SizeChanged += FormMain_SizeChanged; layoutPanel.BorderStyle = BorderStyle.FixedSingle; layoutPanel.BringToFront(); Button buttonSelAll = (Button)formMain.Controls.Find("buttonSelAll", true)[0]; buttonSelAll.Click += null; buttonSelAll.Click += ButtonSelAll_Click; Button buttonDeSelAll = (Button)formMain.Controls.Find("buttonDeSelAll", true)[0]; buttonDeSelAll.Click += ButtonDeSelAll_Click; using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"snapshot.txt", true)) { file.WriteLine("selected_images"); } Button buttonBack = (Button)formMain.Controls.Find("buttonBack", true)[0]; buttonBack.Click += ButtonBack_Click; }
} //end void detail_Show() { isDetailOpened = true; foreach (Control ci in this.Parent.Controls) { ci.Visible = false; } this.Visible = true; ((Panel)this.Parent).AutoScroll = false; this.Tag = this.Location; this.Width = this.Parent.Width - 15; this.Height = this.Parent.Height - 15; this.Location = new Point(0, 0); _detail.Location = new Point(0, 24); _detail.Width = this.Width; _detail.Height = this.Height - 24; _detail.Visible = true; //_detail.BackColor = Color.Green; _detail.BringToFront(); if (_icon != null) { _icon.InActiveColor = Color.Orange; } _exit.Location = new Point(_detail.Width - 25, 3); _exit.Visible = true; } // end
/// <summary> /// Loads the report page where the user can select a report to run. /// </summary> private void CreateReportPage() { // Set the model indicating that there is currently no KPA or KPI being viewed. topHandleBarModel.Update("N/A", "N/A", "N/A"); FlowLayoutPanel wrapPanel = new FlowLayoutPanel() { Name = "Reports", Dock = DockStyle.Fill }; Control[] reportingControls = new Control[] { new ComparisonReportingWidget() { Margin = new Padding(10, 10, 0, 0) } }; // Add the controls to the wrap panel wrapPanel.Controls.AddRange(reportingControls); pnl_activePage.Controls.Add(wrapPanel); wrapPanel.BringToFront(); // Lock the navigation functionality navigationSettings.Visible = Navigation.Visibility.Open; // Create and register the reporting controller reportingWidgetsController = new ReportingController(reportingControls[0] as IComparisonReportingWidgetView); reportingWidgetsController.RegisterComparisonReportGenerationEvents(ComparisonReportGeneration); }
public CSToolbarBigControl() { _splitContainer.Dock = DockStyle.Fill; _splitContainer.IsSplitterFixed = true; _splitContainer.Orientation = Orientation.Vertical; _splitContainer.FixedPanel = FixedPanel.Panel2; _splitContainer.SplitterWidth = 1; _splitContainer.SplitterDistance = _splitContainer.Width - ITEM_WIDTH; this.Controls.Add(_splitContainer); // _dropdownPanel.Width = 300; _dropdownPanel.Height = 300; _dropdownPanel.BackColor = Color.Blue; _dropdownPanel.BringToFront(); _dropdownPanel.FlowDirection = FlowDirection.TopDown; this.Controls.Add(_dropdownPanel); _dropdownPanel.Show(); _btnDropdown.Dock = DockStyle.Fill; _btnDropdown.Text = "Others"; _btnDropdown.TextImageRelation = TextImageRelation.ImageAboveText; //_btnDropdown.ButtonElement.Children[0].Visibility = ElementVisibility.Hidden; _splitContainer.Panel2.Controls.Add(_btnDropdown); }
public void InitDataAndView() { if (ImageList != null && ImageList.Images.Count > 0) { FlowLayoutPanel flowPanel = new FlowLayoutPanel(); flowPanel.Height = this.Height; flowPanel.Width = ImageList.Images[0].Width; flowPanel.Location = new Point(Width - flowPanel.Width, 0); //flowPanel.Dock = DockStyle.Right; this.Controls.Add(flowPanel); flowPanel.BringToFront(); int index = 0; foreach (Image item in ImageList.Images) { PictureBox box = new PictureBox(); box.MouseClick += Box_MouseClick; box.Image = item; box.Width = item.Width; box.Height = item.Height; box.Tag = index; flowPanel.Controls.Add(box); PList.Add(box); index++; } OldPosition = this.Location; //确定宽高,以及位置 //int perHeight = (this.Height - TopPadding - BottomPadding - MenuPadding * (PList.Count - 1)) / PList.Count; foreach (PictureBox item in PList) { } } }
private void MoreLabelBtn_MouseClick(object sender, MouseEventArgs e) { projInfo.Hide(); editProj.Hide(); tasksPanel.Size = new Size(850, 400); tasksPanel.AutoScroll = true; tasksPanel.Location = new Point(350, 200); tasksPanel.BackColor = Color.Silver; ParentForm.Controls.Add(tasksPanel); tasksPanel.Controls.Clear(); tasksPanel.Show(); tasksPanel.BringToFront(); //here AdminClass adm = new AdminClass(); List <TaskClass> tasklist = new List <TaskClass>(); adm.showtask(ref tasklist, project.id); for (int i = 0; i < tasklist.Count; i++) { ViewTasksUC task = new ViewTasksUC(); task.taskStatus.Visible = true; task.InfoLabelBtn.Visible = false; task.AssignLabelBtn.Visible = false; task.CommentLabelBtn.Visible = false; task.TaskFinishedBtn.Visible = false; //here task.TaskName.Text = tasklist[i].name; task.ProjectName.Text = tasklist[i].project_name; task.TaskEmpLabel.Text = tasklist[i].employee_name; task.startDuration.Text = "Start on " + tasklist[i].start_time.Day + " / " + tasklist[i].start_time.Month + " / " + tasklist[i].start_time.Year; task.endDuration.Text = "End on " + tasklist[i].end_time.Day + " / " + tasklist[i].end_time.Month + " / " + tasklist[i].end_time.Year; task.taskStatus.Text = tasklist[i].status; tasksPanel.Controls.Add(task); } }
/// <summary> /// 给好友按钮注册的事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void bt1_Click(object sender, EventArgs e) { flb.Text = null; Button b = (Button)sender; string name = b.Text.ToString().Trim(); flb.Text = name; // listBox2.Items.Clear(); foreach (Control con in this.Controls) { if (con.Name.Contains("ptxt")) { FlowLayoutPanel coo = (FlowLayoutPanel)con; if (coo.Name.Contains(name)) { coo.Visible = true; //MessageBox.Show(name); //MessageBox.Show(coo.Name); coo.HorizontalScroll.Value = txtpanel.HorizontalScroll.Maximum; coo.VerticalScroll.Value = txtpanel.VerticalScroll.Maximum; coo.BringToFront(); } else { coo.Visible = false; } } } this.Refresh(); }
private void MousePressed(object sender, MouseEventArgs e) { Control pressedControl = (Control)sender; String name = pressedControl.Name; if (graphics != null && name.Equals("pictureBox")) { endLocation = new Point(e.X, e.Y); graphics.DrawLine(blackPen, startLocation, endLocation); pictureBox.Refresh(); graphics.Dispose(); graphics = null; int maxConversationID = 0; Control[] controls = tabPage2.Controls.Find("conversationNumber", true); foreach (Control control in controls) { if (Int32.Parse(control.Text) > maxConversationID) { maxConversationID = Int32.Parse(control.Text); } } int nextConversationID = maxConversationID + 1; QuestFlowPanel questFlowPanel = new QuestFlowPanel(endLocation, nextConversationID, this.QuestConnectButtonClicked, this.PanelClicked); FlowLayoutPanel panel = questFlowPanel.getQuestFlowPanel(); tabPage2.Controls.Add(panel); panel.BringToFront(); nextConversationLabel[0].Text = nextConversationLabel[0].Text + "," + nextConversationID; nextConversationLabel = null; CheckedListBox eventList = (CheckedListBox)panel.Controls.Find("questEvents", false)[0]; for (int i = 0; i < eventDataListView.Rows.Count - 1; i++) { string eventString = eventDataListView.Rows[i].Cells[0].Value.ToString(); eventList.Items.Add(eventString); } CheckedListBox conditionList = (CheckedListBox)panel.Controls.Find("questConditions", false)[0]; for (int i = 0; i < conditionDataListView.Rows.Count - 1; i++) { string conditionString = conditionDataListView.Rows[i].Cells[0].Value.ToString(); conditionList.Items.Add(conditionString); } ComboBox speakerList = (ComboBox)panel.Controls.Find("questSpeaker", false)[0]; for (int i = 0; i < npcListDataView.Rows.Count - 1; i++) { string speakerString = npcListDataView.Rows[i].Cells[0].Value.ToString(); speakerList.Items.Add(speakerString); } } }
private void generateSalleOrNiveau(String[,] tab) { Panel panel = new Panel(); Color color = Color.FromName("white"); panel.BackColor = color; panel.Margin = new System.Windows.Forms.Padding(10); panel.Width = widthBloc; panel.Height = 360; PictureBox pictureBox = new PictureBox(); Image newImage = Image.FromFile(pathImg + "ecole.png"); pictureBox.SizeMode = PictureBoxSizeMode.Normal; pictureBox.Image = newImage; pictureBox.Dock = DockStyle.Top; pictureBox.Width = widthBloc; pictureBox.Height = 180; panel.Controls.Add(pictureBox); Panel panelBtnDelete = new Panel(); string urlImg = pathIcon + "delete3.png"; Point location = new Point { X = 0, Y = -50 }; panelBtnDelete = this.generateBtn(urlImg, location); panelBtnDelete.Dock = DockStyle.None; panel.Controls.Add(panelBtnDelete); panelBtnDelete.BringToFront(); Panel panelBottom = new Panel(); FlowLayoutPanel flowLayout = generateText(tab); panelBottom.Dock = DockStyle.Bottom; panelBottom.Width = widthBloc; panelBottom.Height = 170; flowLayout.Dock = DockStyle.Fill; panelBottom.Controls.Add(flowLayout); flowLayout.BringToFront(); panel.Controls.Add(panelBottom); flowLayoutShowClass.Controls.Add(panel); }
/// <summary> /// アイコンパレードの末尾にアイコンを追加します /// </summary> /// <param name="path_image">イメージファイルへのパス</param> /// <param name="singer_name">歌手の名前</param> public void addIcon(string path_image, string singer_name) { IconParader p = new IconParader(); var img = IconParader.createIconImage(path_image, singer_name); p.setImage(img); p.MouseDown += new MouseEventHandler(handleMouseDown); p.MouseUp += new MouseEventHandler(handleMouseUp); p.MouseMove += new MouseEventHandler(handleMouseMove); panelIcon.BringToFront(); panelIcon.Controls.Add(p); }
/// <summary> /// Reloads the items. /// </summary> private void ReloadItems() { try { ControlHelper.FreezeControl(this, true); this.Controls.Clear(); if (items != null) { foreach (var item in items) { FlowLayoutPanel panelTitle = new FlowLayoutPanel(); panelTitle.Dock = DockStyle.Top; panelTitle.AutoScroll = false; panelTitle.Padding = new System.Windows.Forms.Padding(5); panelTitle.Name = "title_" + Guid.NewGuid().ToString(); Label lblTitle = new Label(); lblTitle.Dock = DockStyle.Top; lblTitle.AutoSize = true; lblTitle.Font = titleFont; lblTitle.ForeColor = titleForcolor; lblTitle.Text = item.Title; lblTitle.SizeChanged += item_SizeChanged; panelTitle.Controls.Add(lblTitle); this.Controls.Add(panelTitle); panelTitle.BringToFront(); FlowLayoutPanel panelDetails = new FlowLayoutPanel(); panelDetails.Dock = DockStyle.Top; panelDetails.AutoScroll = false; panelDetails.Padding = new System.Windows.Forms.Padding(5); panelDetails.Name = "details_" + Guid.NewGuid().ToString(); Label lblDetails = new Label(); lblDetails.AutoSize = true; lblDetails.Dock = DockStyle.Top; lblDetails.Font = detailsFont; lblDetails.ForeColor = detailsForcolor; lblDetails.Text = item.Details; lblDetails.SizeChanged += item_SizeChanged; panelDetails.Controls.Add(lblDetails); this.Controls.Add(panelDetails); panelDetails.BringToFront(); } } } finally { ControlHelper.FreezeControl(this, false); } }
/// <summary> /// 添加一个消息按钮在对话框 /// </summary> /// <param name="name">好友姓名</param> /// <param name="isself">是自己发送的吗?</param> private void Addnewbtmess(string name, string contxt, bool isself) { if (GetUserContxtPanel(name) != null) { } else { return; } if (GetUserContxtPanel(name).InvokeRequired) { addbtmessdelagete d = new addbtmessdelagete(Addnewbtmess); object[] par = new object[] { name, contxt, isself }; this.Invoke(d, par); } else { Button button = new Button(); if (isself) { button = setmessbt(button, my.Name + ":" + contxt, "msb.jpg", "", 10F, true); // button = setmessbt(button); } else { button = setmessbt(button, contxt, "msb.jpg", "微软雅黑", 10F, false); button.Anchor = System.Windows.Forms.AnchorStyles.Left; } FlowLayoutPanel coo = GetUserContxtPanel(name); if (coo.Name == name + "ptxt") { coo.Visible = true; coo.Controls.Add(button); coo.BringToFront(); coo.HorizontalScroll.Value = txtpanel.HorizontalScroll.Maximum; coo.VerticalScroll.Value = txtpanel.VerticalScroll.Maximum; } else { coo.Visible = false; coo.SendToBack(); } Refresh(); } }
private FlowLayoutPanel GetPanel(Meeting meeting) { // Panel settings FlowLayoutPanel panel = new FlowLayoutPanel(); panel.BackColor = GetColor(meeting.Date); panel.Margin = Padding.Empty; panel.Padding = new Padding(ELEMENT_PADDING_LEFT, ELEMENT_PADDING_TOP, ELEMENT_PADDING_RIGHT, ELEMENT_PADDING_BOTTOM); panel.FlowDirection = FlowDirection.TopDown; panel.Enabled = true; panel.BringToFront(); // Panel elements panel.Controls.Add(new Label() { Text = meeting.Title, Font = new Font(ELEMENT_TITLE_FONT, ELEMENT_TITLE_FONT_SIZE, FontStyle.Bold), AutoSize = false, Size = new Size(panel.Width, ELEMENT_TITLE_HEIGHT) }); panel.Controls.Add(new Label() { Text = meeting.Description, Font = new Font(ELEMENT_DESCRIPTION_FONT, ELEMENT_DESCRIPTION_FONT_SIZE), AutoSize = false, Size = new Size(panel.Width, ELEMENT_DESCRIPTION_HEIGHT) }); // Panel events & tooltip string toolTipText = meeting.Description + ". (" + meeting.Place + ")"; //MLHIDE panel.ContextMenuStrip = contextMenuMeeting; panel.DoubleClick += Meeting_Click; toolTipDescription.SetToolTip(panel, toolTipText); foreach (Control c in panel.Controls) { c.DoubleClick += Meeting_Click; toolTipDescription.SetToolTip(c, toolTipText); } // Panel data panel.Tag = meeting.IDMeeting; return(panel); }
public SimulationRenderHelper(Panel gamePanel, RenderZoneOptions renderZoneOptions, SimulationOptions options) { if (gamePanel == null) { throw new ArgumentNullException(nameof(gamePanel)); } gamePanel.Controls.Clear(); SimulationSession = new SimulationSession(options); _zoneSelectionPanel.Width = 160; _zoneSelectionPanel.Dock = DockStyle.Left; _viewportPanel.Dock = DockStyle.Fill; _viewportPanel.AutoScroll = true; gamePanel.Controls.Add(_viewportPanel); gamePanel.Controls.Add(_zoneSelectionPanel); _zoneSelectionPanel.BringToFront(); _viewportPanel.BringToFront(); if (renderZoneOptions == null) { throw new ArgumentNullException(nameof(renderZoneOptions)); } _canvasPanel = new Panel { BackColor = EmptyZoneConsumption.DefaultColor, Size = _tilesetAccessor.GetAreaSize(SimulationSession.Area), Dock = DockStyle.None }; _viewportPanel.Controls.Add(_canvasPanel); _zoneSelectionPanelBehaviour = new ZoneSelectionPanelCreator( area: SimulationSession.Area, targetPanel: _zoneSelectionPanel ); MouseEventHandler eventHandler = (sender, e) => { var point = _canvasPanel.PointToClient(Cursor.Position); var zone = GetZoneStateFor(point); var zoneConsumption = (e.Button == MouseButtons.Right) ? new EmptyZoneConsumption() : _zoneSelectionPanelBehaviour.CreateNewCurrentZoneConsumption(); var result = SimulationSession.ConsumeZoneAt(zone, zoneConsumption); if (result == null) { throw new InvalidOperationException(); } }; _canvasPanel.MouseDown += eventHandler; _canvasPanel.MouseMove += (sender, e) => { if (e.Button != MouseButtons.None && _zoneSelectionPanelBehaviour.IsCurrentlyNetworkZoning) { eventHandler(sender, e); } }; _zoneRenderInfos = SimulationSession.Area .EnumerateZoneInfos() .ToDictionary(x => x, zoneRenderInfo => new ZoneRenderInfo( zoneInfo: zoneRenderInfo, createRectangle: zonePoint => new Rectangle( x: zonePoint.Point.X * _tilesetAccessor.TileWidthAndSizeInPixels, y: zonePoint.Point.Y * _tilesetAccessor.TileWidthAndSizeInPixels, width: _tilesetAccessor.TileWidthAndSizeInPixels, height: _tilesetAccessor.TileWidthAndSizeInPixels ), tilesetAccessor: _tilesetAccessor, renderZoneOptions: renderZoneOptions )); _graphicsManager = CreateGraphicsManagerWrapperWithFactory(renderZoneOptions.SelectedGraphicsManager.Factory); }
public void BuildSubURLTabs(object sender, EventArgs ev, URLTabPlugin.TabTypes tt) { if (sender != null) { /* Create a panel, find the parent form and maximize it */ Panel p = (Panel)sender; TabPage c = (TabPage)p.Parent; Form f = c.FindForm(); f.WindowState = FormWindowState.Maximized; TabControl tc = new TabControl(); p.Controls.Add(tc); tc.Dock = DockStyle.Fill; /* Create a list of URLTabs */ this.propertyString = "URLTabPlugin+" + c.Text.Replace(" ", "_"); string result = objHost.GetSQL("SELECT Value FROM properties where Name LIKE '%" + this.propertyString + "%'"); var UTP = Activator.CreateInstance<List<URLTabPlugin>>(); if (result != "-9999") { using (var memoryStream = new MemoryStream(Encoding.Unicode.GetBytes(result))) { var serializer = new DataContractJsonSerializer(UTP.GetType()); UTP = (List<URLTabPlugin>)serializer.ReadObject(memoryStream); } foreach (URLTabPlugin utp in UTP) { if (utp.TabType == tt) { TabPage tp = new TabPage(utp.TabLabel); tc.Controls.Add(tp); tp.Dock = DockStyle.Fill; tp.BringToFront(); WebBrowser wb = new WebBrowser(); wb.AllowNavigation = true; wb.AllowWebBrowserDrop = false; wb.ScriptErrorsSuppressed = true; wb.ScrollBarsEnabled = true; wb.IsWebBrowserContextMenuEnabled = true; tp.Controls.Add(wb); wb.Dock = DockStyle.Fill; wb.BringToFront(); wb.Navigate(utp.TabUrl); wb.Refresh(); } } } /* Build the config tab */ TabPage tconfig = new TabPage("Config"); tc.Controls.Add(tconfig); tconfig.Dock = DockStyle.Fill; /* Dynamic flow layout to hold the buttons */ FlowLayoutPanel buttonFlowLayoutPanel = new FlowLayoutPanel(); buttonFlowLayoutPanel.BringToFront(); buttonFlowLayoutPanel.FlowDirection = FlowDirection.LeftToRight; buttonFlowLayoutPanel.Location = new System.Drawing.Point(8, 10); buttonFlowLayoutPanel.Size = new System.Drawing.Size(510, 32); tconfig.Controls.Add(buttonFlowLayoutPanel); Button btnSaveConfig = new Button(); btnSaveConfig.Text = "Save Config"; btnSaveConfig.Click += new EventHandler(btnSaveConfig_Click); Button btnAddTab = new Button(); btnAddTab.Text = "Add Tab"; btnAddTab.Click += new EventHandler(btnAddTab_Click); buttonFlowLayoutPanel.Controls.Add(btnSaveConfig); buttonFlowLayoutPanel.Controls.Add(btnAddTab); /* Dynamic Flow Layout to hold taburlconfigs */ dynamicFlowLayoutPanel = new FlowLayoutPanel(); dynamicFlowLayoutPanel.BringToFront(); dynamicFlowLayoutPanel.FlowDirection = FlowDirection.TopDown; dynamicFlowLayoutPanel.Location = new System.Drawing.Point(0, 40); dynamicFlowLayoutPanel.Size = new System.Drawing.Size(510,600); dynamicFlowLayoutPanel.AutoScroll = true; dynamicFlowLayoutPanel.WrapContents = false; tconfig.Controls.Add(dynamicFlowLayoutPanel); string results = objHost.GetSQL("SELECT Value FROM properties where Name LIKE '%" + propertyString + "%'"); if (results != "-9999") { List<string> TabsCompleted = new List<string>(); /* Rewrite, this doesn't make sense. Deserialize it instead and loop through those results. */ foreach (URLTabPlugin utp in UTP) { URLTabPluginConfigTab utpct; // If the tab isn't in the list yet, create it if (TabsCompleted.IndexOf(utp.TabLabel) < 0) { TabsCompleted.Add(utp.TabLabel); utpct = new URLTabPluginConfigTab(); utpct.tabLabel = utp.TabLabel; utpct.tabClientUrl = utp.TabUrl; utpct.tabClientCheck = CheckState.Checked; dynamicFlowLayoutPanel.Controls.Add(utpct); } // if it is, find it. else { Control[] utpcts = dynamicFlowLayoutPanel.Controls.Find("txtTabLabel",true); foreach(Control utpctss in utpcts) { if (utpctss.Text == utp.TabLabel) { /* ..And check and fill in the right datafields based on the Tab type */ if (utp.TabType == URLTabPlugin.TabTypes.Client) { utpctss.Parent.Controls.Find("txtClientUrl", true)[0].Text = utp.TabUrl; CheckBox ck = (CheckBox)utpctss.Parent.Controls.Find("chkClient", true)[0]; ck.CheckState = CheckState.Checked; } else if(utp.TabType == URLTabPlugin.TabTypes.Location) { utpctss.Parent.Controls.Find("txtLocationUrl", true)[0].Text = utp.TabUrl; CheckBox ck = (CheckBox)utpctss.Parent.Controls.Find("chkLocation", true)[0]; ck.CheckState = CheckState.Checked; } else if (utp.TabType == URLTabPlugin.TabTypes.Computer) { utpctss.Parent.Controls.Find("txtComputerUrl", true)[0].Text = utp.TabUrl; CheckBox ck = (CheckBox)utpctss.Parent.Controls.Find("chkComputer", true)[0]; ck.CheckState = CheckState.Checked; } } } } /* if (utp.TabType == URLTabPlugin.TabTypes.Client) { utpct.tabClientUrl = utp.TabUrl; }*/ } } } }
public FormModelAdd(IDataFile _db) : base("Model Add", true) { db = _db; ClientSize = new Size(fWidth, fHeight); countField = 0; #region [ === CONTROLS UI === ] Panel boi_DbName = new Panel() { Dock = DockStyle.Top, Height = 62, }; boi_DbName.MouseDown += FormMove_MouseDown; Label lbl_Name = new Label() { Left = 4, Width = 120, Top = 7, Text = "Model name", AutoSize = false, Height = 20, BackColor = Color.Gray, ForeColor = Color.Black, TextAlign = ContentAlignment.MiddleCenter }; TextBoxCustom txt_Name = new TextBoxCustom() { Left = 124, Top = 7, Width = 120, WaterMark = "Model name ...", BorderStyle = BorderStyle.FixedSingle, TextAlign = HorizontalAlignment.Center }; Label lbl_Caption = new Label() { Left = 252, Top = 7, Width = 120, Text = "Model caption", AutoSize = false, Height = 20, BackColor = Color.Gray, ForeColor = Color.Black, TextAlign = ContentAlignment.MiddleCenter }; TextBoxCustom txt_Caption = new TextBoxCustom() { Left = 372, Top = 7, Width = 120, WaterMark = "Model caption ...", BorderStyle = BorderStyle.FixedSingle, TextAlign = HorizontalAlignment.Center }; boi_DbName.Controls.AddRange(new Control[] { lbl_Name, lbl_Caption, txt_Name, txt_Caption, new ucModelTitle() { Left = 4, Top = 39, Height = 25, Width = fWidth - (SystemInformation.VerticalScrollBarWidth + 20) } }); FlowLayoutPanel boi_Filter = new FlowLayoutPanel() { Dock = DockStyle.Fill, AutoScroll = true, WrapContents = false, Padding = new Padding(0), BackColor = Color.WhiteSmoke, FlowDirection = FlowDirection.TopDown, }; boi_Filter.MouseDown += FormMove_MouseDown; form_Add(boi_Filter); form_Add(boi_Filter); Panel boi_Action = new Panel() { Dock = DockStyle.Bottom, Height = 25 }; Button btn_Add = new Button() { Dock = DockStyle.Right, Text = "ADD", BackColor = Color.WhiteSmoke, Width = 60, TextAlign = ContentAlignment.MiddleCenter }; //Button btn_Remove = new Button() { Dock = DockStyle.Right, Text = "REMOVE", BackColor = Color.WhiteSmoke, Width = 70, TextAlign = ContentAlignment.MiddleCenter }; Button btn_Submit = new Button() { Dock = DockStyle.Right, Text = "SUBMIT", BackColor = Color.WhiteSmoke, Width = 60, TextAlign = ContentAlignment.MiddleCenter }; boi_Action.Controls.AddRange(new Control[] { btn_Add, btn_Submit }); this.Controls.AddRange(new Control[] { boi_DbName, boi_Filter, boi_Action }); boi_DbName.BringToFront(); boi_Action.BringToFront(); boi_Filter.BringToFront(); btn_Submit.Focus(); btn_Add.Click += (se, ev) => form_Add(boi_Filter); //btn_Remove.Click += (se, ev) => form_Remove(boi_Filter); #endregion btn_Submit.Click += (se, ev) => form_Submit(txt_Name.Text, txt_Caption.Text, boi_Filter); HideScrollBar(boi_Filter.Handle, ScrollBarHide.SB_HORZ); }//end function init()
private void init_Control() { Label lbl_Title = new Label() { Text = "REGISTRY SYSTEM ", Dock = DockStyle.Top, AutoSize = false, Width = 80, Height = 24, BackColor = App.ColorBg, ForeColor = Color.White, TextAlign = System.Drawing.ContentAlignment.MiddleCenter }; lbl_Title.MouseDown += Label_MouseDown; this.Controls.Add(lbl_Title); FlowLayoutPanel box = new FlowLayoutPanel() { Dock = DockStyle.Fill, BackColor = Color.White, FlowDirection = FlowDirection.LeftToRight }; //box.MouseDown += Label_MouseDown; Label lbl_Username = new Label() { Text = "Username ", AutoSize = false, Width = 80, TextAlign = System.Drawing.ContentAlignment.MiddleRight }; Label lbl_Pass = new Label() { Text = "Password ", AutoSize = false, Width = 80, TextAlign = System.Drawing.ContentAlignment.MiddleRight }; TextBox txt_Username = new TextBox() { Width = 100, Text = "", BorderStyle = BorderStyle.FixedSingle }; TextBox txt_Pass = new TextBox() { Width = 100, PasswordChar = '*', Text = "", BorderStyle = BorderStyle.FixedSingle }; Label lbl_Space = new Label() { Text = "", AutoSize = false, Width = 10 }; Button btn_Add = new Button() { Text = "REGISTRY", Width = 80, TextAlign = System.Drawing.ContentAlignment.MiddleCenter }; Button btn_Close = new Button() { Text = "CLOSE", Width = 80, TextAlign = System.Drawing.ContentAlignment.MiddleCenter }; box.Controls.AddRange(new Control[] { lbl_Username, txt_Username, lbl_Pass, txt_Pass, lbl_Space, btn_Add, btn_Close, }); this.Controls.Add(box); box.BringToFront(); btn_Add.Focus(); btn_Close.Click += (se, ev) => { if (OnExit != null) { OnExit(); } }; btn_Add.Click += (se, ev) => { string user = txt_Username.Text.Trim(), pass = txt_Pass.Text.Trim(); if (string.IsNullOrEmpty(user) || string.IsNullOrEmpty(pass)) { MessageBox.Show("Username or password is empty", "REGISTRY USER"); return; } this.Hide(); if (OnSubmit != null) { OnSubmit(user, pass); } }; }
public FormItemEdit(IDataFile _db, string dbName, object _itemEdit) : base("EDIT ITEM SELECTED", true) { ItemEdit = _itemEdit; int _Hi = 0; db = _db; ClientSize = new Size(fWidth, Screen.PrimaryScreen.WorkingArea.Height - 80); Top = 40; //////////////////////////////////////////////////////////////////////////////// var model = db.GetModel(dbName); #region [ === CONTROLS UI === ] boi_Filter = new FlowLayoutPanel() { Dock = DockStyle.Fill, AutoScroll = true, WrapContents = true, Padding = new Padding(0), BackColor = Color.WhiteSmoke, FlowDirection = FlowDirection.LeftToRight, }; boi_Filter.MouseDown += FormMove_MouseDown; var fields = model.FIELDS.Where(x => x.IS_KEY_AUTO == false).OrderBy(x => x.ORDER_EDIT).ToArray(); Type typeItem = ItemEdit.GetType(); for (int ki = 0; ki < fields.Length; ki++) { var fd = fields[ki]; var po = typeItem.GetProperty(fd.NAME); if (po != null) { fd.Value = po.GetValue(ItemEdit, null); } var uc = new ucDataItemEdit(dbName, ki, fd, _db, this) { Name = "uc" + ki.ToString(), }; uc.Height = uc._Height; uc.Width = uc._Width; boi_Filter.Controls.Add(uc); } int kitMin = ((fields.Select(x => x.KIT).Where(x => x != ControlKit.HTML && x != ControlKit.TEXTAREA) .Count() / 2) + 1); int hi_Min = (kitMin * ucDataItemAdd.Height_Min) + (kitMin * 10); int hi_Max = fields.Select(x => x.KIT).Where(x => x == ControlKit.TEXTAREA) .Count() * ucDataItemAdd.Height_Max; int hi_Full = fields.Select(x => x.KIT).Where(x => x == ControlKit.HTML) .Count() * ucDataItemAdd.Height_Full; _Hi = hi_Min + hi_Max + hi_Full + 60; Panel boi_Action = new Panel() { Dock = DockStyle.Bottom, Height = 25 }; Button btn_DataTest = new Button() { Dock = DockStyle.Right, Text = "FILL DATA TEST", BackColor = Color.WhiteSmoke, Width = 123, TextAlign = ContentAlignment.MiddleCenter }; Button btn_Submit = new Button() { Dock = DockStyle.Right, Text = "SUBMIT", BackColor = Color.WhiteSmoke, Width = 60, TextAlign = ContentAlignment.MiddleCenter }; Button btn_Reset = new Button() { Dock = DockStyle.Right, Text = "RESET", BackColor = Color.WhiteSmoke, Width = 60, TextAlign = ContentAlignment.MiddleCenter }; boi_Action.Controls.AddRange(new Control[] { btn_DataTest, btn_Submit, btn_Reset }); boi_Action.MouseDown += FormMove_MouseDown; this.Controls.AddRange(new Control[] { boi_Filter, boi_Action }); boi_Action.BringToFront(); boi_Filter.BringToFront(); btn_Submit.Focus(); #endregion if (_Hi < Screen.PrimaryScreen.WorkingArea.Height) { if (_Hi < 200) { _Hi = 200; } ClientSize = new System.Drawing.Size(fWidth, _Hi); } btn_Submit.Click += (se, ev) => form_Submit(dbName); btn_DataTest.Click += (se, ev) => fill_DataTest(); HideScrollBar(boi_Filter.Handle, ScrollBarHide.SB_HORZ); //////////////////////////////////////////////////////////////////////////////// }
public OptionsControl(LuiConfig config) { SuspendLayout(); AutoScaleDimensions = new SizeF(6F, 13F); AutoScaleMode = AutoScaleMode.Inherit; Name = "OptionsControl"; #region Panels and list of options dialogs // Container for options dialogs. var OptionsPanel = new Panel { Dock = DockStyle.Fill }; Controls.Add(OptionsPanel); // Must add the DockStyle.Fill control first. var ListPanel = new Panel { Dock = DockStyle.Left // Panel will dock to the left. }; Controls.Add(ListPanel); OptionsListView = new OptionsListView { Dock = DockStyle.Fill, HideSelection = false, // Maintain highlighting if user changes control focus. MultiSelect = false, // Only select one item at a time. HeaderStyle = ColumnHeaderStyle.None, View = View.Details, ShowGroups = true }; OptionsListView.Columns.Add(new ColumnHeader()); OptionsListView.SelectedIndexChanged += HandleSelectedOptionsDialogChanged; ListPanel.Controls.Add(OptionsListView); #endregion Panels and list of options dialogs #region Options dialogs var General = new ListViewGroup("General", HorizontalAlignment.Left); OptionsListView.Groups.Add(General); var Instruments = new ListViewGroup("Instruments", HorizontalAlignment.Left); OptionsListView.Groups.Add(Instruments); // Logging Options var LoggingOptionsDialog = new LoggingOptionsDialog(OptionsPanel.Size) { Dock = DockStyle.Fill }; var LoggingOptionsItem = new ListViewItem("Logging", General) { Tag = LoggingOptionsDialog }; OptionsListView.Items.Add(LoggingOptionsItem); OptionsPanel.Controls.Add(LoggingOptionsDialog); // Beam Flag Options Dialog var BeamFlagOptionsDialog = new LuiOptionsListDialog <AbstractBeamFlags, BeamFlagsParameters>(OptionsPanel.Size); BeamFlagOptionsDialog.AddConfigPanel(new BeamFlagsConfigPanel()); BeamFlagOptionsDialog.AddConfigPanel(new DummyBeamFlagsConfigPanel()); BeamFlagOptionsDialog.SetDefaultSelectedItems(); BeamFlagOptionsDialog.Dock = DockStyle.Fill; var BeamFlagOptionsItem = new ListViewItem("Beam Flags", Instruments) { Tag = BeamFlagOptionsDialog }; OptionsListView.Items.Add(BeamFlagOptionsItem); OptionsPanel.Controls.Add(BeamFlagOptionsDialog); // CCD Camera Dialog var CameraOptionsDialog = new LuiOptionsListDialog <ICamera, CameraParameters>(OptionsPanel.Size); CameraOptionsDialog.AddConfigPanel(new AndorCameraConfigPanel()); CameraOptionsDialog.AddConfigPanel(new CameraTempControlledConfigPanel()); CameraOptionsDialog.AddConfigPanel(new DummyAndorCameraConfigPanel()); CameraOptionsDialog.AddConfigPanel(new DummyCameraConfigPanel()); CameraOptionsDialog.SetDefaultSelectedItems(); CameraOptionsDialog.Dock = DockStyle.Fill; var CameraOptionsItem = new ListViewItem("Camera", Instruments) { Tag = CameraOptionsDialog }; OptionsListView.Items.Add(CameraOptionsItem); OptionsPanel.Controls.Add(CameraOptionsDialog); // GPIB Options Dialog var GPIBOptionsDialog = new LuiOptionsListDialog <IGpibProvider, GpibProviderParameters>(OptionsPanel.Size); GPIBOptionsDialog.AddConfigPanel(new NIConfigPanel()); GPIBOptionsDialog.AddConfigPanel(new PrologixConfigPanel()); GPIBOptionsDialog.AddConfigPanel(new DummyGpibProviderConfigPanel()); GPIBOptionsDialog.SetDefaultSelectedItems(); GPIBOptionsDialog.Dock = DockStyle.Fill; var GPIBOptionsItem = new ListViewItem("GPIB Controllers", Instruments) { Tag = GPIBOptionsDialog }; OptionsListView.Items.Add(GPIBOptionsItem); OptionsPanel.Controls.Add(GPIBOptionsDialog); // DDG Options Dialog var DDGOptionsDialog = new LuiOptionsListDialog <IDigitalDelayGenerator, DelayGeneratorParameters>(OptionsPanel.Size); DDGOptionsDialog.AddConfigPanel(new DG535ConfigPanel(GPIBOptionsDialog)); DDGOptionsDialog.AddConfigPanel(new DummyDigitalDelayGeneratorConfigPanel()); DDGOptionsDialog.SetDefaultSelectedItems(); DDGOptionsDialog.Dock = DockStyle.Fill; var DDGOptionsItem = new ListViewItem("Digital Delay Generators", Instruments) { Tag = DDGOptionsDialog }; OptionsListView.Items.Add(DDGOptionsItem); OptionsPanel.Controls.Add(DDGOptionsDialog); // Syringe Pump Dialog var SyringePumpOptionsDialog = new LuiOptionsListDialog <ISyringePump, SyringePumpParameters>(OptionsPanel.Size); SyringePumpOptionsDialog.AddConfigPanel(new HarvardSyringePumpConfigPanel()); SyringePumpOptionsDialog.AddConfigPanel(new DummySyringePumpConfigPanel()); SyringePumpOptionsDialog.SetDefaultSelectedItems(); SyringePumpOptionsDialog.Dock = DockStyle.Fill; var SyringePumpOptionsItem = new ListViewItem("Syringe Pump", Instruments) { Tag = SyringePumpOptionsDialog }; OptionsListView.Items.Add(SyringePumpOptionsItem); OptionsPanel.Controls.Add(SyringePumpOptionsDialog); // Polarizer Dialog var PolarizerOptionsDialog = new LuiOptionsListDialog <IPolarizer, PolarizerParameters>(OptionsPanel.Size); PolarizerOptionsDialog.AddConfigPanel(new PolarizerConfigPanel()); PolarizerOptionsDialog.AddConfigPanel(new DummyPolarizerConfigPanel()); PolarizerOptionsDialog.SetDefaultSelectedItems(); PolarizerOptionsDialog.Dock = DockStyle.Fill; var PolarizerOptionsItem = new ListViewItem("Polarizer", Instruments) { Tag = PolarizerOptionsDialog }; OptionsListView.Items.Add(PolarizerOptionsItem); OptionsPanel.Controls.Add(PolarizerOptionsDialog); #endregion Options dialogs OptionsListView.Columns[0].Width = -1; // Sets width to that of widest item. // Note OptionsChanged and ConfigChanged handlers are not yet bound. Config = config; // Refers to the global config object. SetChildConfig(Config); // Sets options dialogs to reference & match this config. #region Buttons var ButtonPanel = new FlowLayoutPanel { FlowDirection = FlowDirection.RightToLeft, Anchor = AnchorStyles.Bottom | AnchorStyles.Right, AutoSize = true, // Fit to the buttons. AutoSizeMode = AutoSizeMode.GrowAndShrink }; // Container for the buttons. ApplyConfig = new Button { Text = "Apply", Size = new Size(91, 34), Enabled = false }; ApplyConfig.Click += ApplyConfig_Click; SaveConfig = new Button { Text = "Save", Size = new Size(91, 34), Enabled = false }; SaveConfig.Click += SaveConfig_Click; LoadConfig = new Button { Text = "Load", Size = new Size(91, 34) }; LoadConfig.Click += LoadConfig_Click; ButtonPanel.Controls.Add(LoadConfig); ButtonPanel.Controls.Add(SaveConfig); ButtonPanel.Controls.Add(ApplyConfig); OptionsPanel.Controls.Add(ButtonPanel); ButtonPanel.BringToFront(); // Display on top of any overlapping controls (OptionsPanel). #endregion Buttons ResumeLayout(false); }
public FormModelEdit(IDataFile _db) { db = _db; var fields = db.GetFields("Test"); FlowLayoutPanel boi_Filter = new FlowLayoutPanel() { Dock = DockStyle.Fill, Height = (((fields.Length / 3) + 0) * 25), AutoScroll = false, Padding = new Padding(0), BackColor = Color.WhiteSmoke }; boi_Filter.FlowDirection = FlowDirection.LeftToRight; boi_Filter.MouseDown += FormMove_MouseDown; Label lbl_Name = new Label() { Text = "Name", AutoSize = false, Width = 80, BackColor = Color.Gray, ForeColor = Color.Black, TextAlign = ContentAlignment.MiddleCenter }; Label lbl_Type = new Label() { Text = "Type", AutoSize = false, Width = 80, BackColor = Color.Gray, ForeColor = Color.Black, TextAlign = ContentAlignment.MiddleCenter }; Label lbl_Caption = new Label() { Text = "Caption", AutoSize = false, Width = 80, BackColor = Color.Gray, ForeColor = Color.Black, TextAlign = ContentAlignment.MiddleCenter }; boi_Filter.Controls.AddRange(new Control[] { lbl_Name, lbl_Type, lbl_Caption, }); StringBuilder wh_Contain = new StringBuilder(); for (int k = 0; k < fields.Length; k++) { var dp = fields[k]; wh_Contain.Append(dp.Name + (dp.Type.Name == "String" ? string.Empty : ".ToString()") + ".Contains(@0) "); if (k < fields.Length - 1) { wh_Contain.Append(" || "); } TextBox lbl = new TextBox() { Name = "lbl" + k.ToString(), Text = dp.Name, Width = 80, BorderStyle = BorderStyle.FixedSingle, TextAlign = HorizontalAlignment.Center }; ComboBox cbo = new ComboBox() { Name = "cbo" + k.ToString(), Width = 80, DropDownStyle = ComboBoxStyle.DropDownList, }; //if (dp.Type.Name == "String") // for (int ki = 0; ki < OpString.Length; ki++) cbo.Items.Add(OpString[ki]); //else // for (int ki = 0; ki < OpNumber.Length; ki++) cbo.Items.Add(OpNumber[ki]); //cbo.SelectedIndexChanged += (se, ev) => //{ //}; //cbo.DataSource = dp.Type.Name == "String" ? OpString : OpNumber; TextBox txt = new TextBox() { Name = "txt" + k.ToString(), Width = 80, BorderStyle = BorderStyle.FixedSingle, TextAlign = HorizontalAlignment.Center }; boi_Filter.Controls.AddRange(new Control[] { lbl, cbo, txt, }); if (k != 0 && k % 3 == 0) { Label sp = new Label() { Text = "", AutoSize = false, Width = App.Width, Height = 1, }; boi_Filter.Controls.Add(sp); } }//end for fields Panel boi_Footer = new Panel() { Dock = DockStyle.Bottom, Height = 25 }; Button btn_Add = new Button() { Dock = DockStyle.Right, Text = "ADD", BackColor = Color.WhiteSmoke, Width = 60, TextAlign = ContentAlignment.MiddleCenter }; Button btn_Remove = new Button() { Dock = DockStyle.Right, Text = "REMOVE", BackColor = Color.WhiteSmoke, Width = 70, TextAlign = ContentAlignment.MiddleCenter }; Button btn_Submit = new Button() { Dock = DockStyle.Right, Text = "SUBMIT", BackColor = Color.WhiteSmoke, Width = 60, TextAlign = ContentAlignment.MiddleCenter }; Button btn_Close = new Button() { Dock = DockStyle.Right, Text = "CLOSE", BackColor = Color.WhiteSmoke, Width = 60, TextAlign = ContentAlignment.MiddleCenter }; boi_Footer.Controls.AddRange(new Control[] { btn_Add, btn_Remove, btn_Submit, btn_Close }); this.Controls.AddRange(new Control[] { boi_Filter, boi_Footer, }); boi_Filter.BringToFront(); btn_Submit.Focus(); btn_Close.Click += (se, ev) => { this.Close(); }; btn_Submit.Click += (se, ev) => { }; new Thread(() => { this.Width = 270; }).Start(); }
private void btn_Click(object sender, EventArgs e) { this.Controls.RemoveByKey("runePanel"); FlowLayoutPanel panel = new FlowLayoutPanel(); panel.Name = "runePanel"; panel.Visible = true; panel.Location = new Point(39, 160); panel.Size = new Size(1000, 500); panel.BackColor = Color.Transparent; panel.BringToFront(); this.Controls.Add(panel); Button b = (Button)sender; foreach (var rune in runeList) { if (b.Name.Contains(rune.Name)) { panel.BackgroundImage = Image.FromFile(@"C:\Users\GD1\Desktop\Lol\LOLAPI\Resources\" + rune.Name + ".jpg"); panel.BackgroundImageLayout = ImageLayout.Stretch; foreach (var slots in rune.Slots) { FlowLayoutPanel firstPanel = new FlowLayoutPanel(); firstPanel.Size = new Size(900, 100); firstPanel.BackColor = Color.Transparent; panel.Controls.Add(firstPanel); Button mainButton = new Button(); mainButton.Name = "MainButton"; mainButton.BackColor = Color.Transparent; mainButton.Size = new Size(100, 90); firstPanel.Controls.Add(mainButton); foreach (var innerRune in slots) { Button subButton = new Button(); subButton.Click += new EventHandler(this.btnInnerRune_Click); foreach (var item in innerRuneList) { if (innerRune.Contains(item.Id.ToString())) { subButton.Name = item.Name; subButton.Size = new Size(80, 80); subButton.BackgroundImage = item.Image; subButton.BackgroundImageLayout = ImageLayout.Stretch; subButton.BackColor = Color.Transparent; } } firstPanel.Controls.Add(subButton); } Label lblDesc = new Label(); lblDesc.Size = new Size(350, 80); lblDesc.ForeColor = Color.White; lblDesc.Name = "Desc"; firstPanel.Controls.Add(lblDesc); } } } }
private void init_Control() { Label lbl_Title = new Label() { Text = "LOGIN SYSTEM ", Dock = DockStyle.Top, AutoSize = false, Width = 80, Height = 24, BackColor = App.ColorBg, ForeColor = Color.White, TextAlign = System.Drawing.ContentAlignment.MiddleCenter }; lbl_Title.MouseDown += Label_MouseDown; this.Controls.Add(lbl_Title); FlowLayoutPanel box = new FlowLayoutPanel() { Dock = DockStyle.Fill, BackColor = Color.White, FlowDirection = FlowDirection.LeftToRight }; //box.MouseDown += Label_MouseDown; Label lbl_Username = new Label() { Text = "Username ", AutoSize = false, Width = 80, TextAlign = System.Drawing.ContentAlignment.MiddleRight }; Label lbl_Pass = new Label() { Text = "Password ", AutoSize = false, Width = 80, TextAlign = System.Drawing.ContentAlignment.MiddleRight }; TextBox txt_Username = new TextBox() { Width = 100, Text = "admin", BorderStyle = BorderStyle.FixedSingle }; TextBox txt_Pass = new TextBox() { Width = 100, PasswordChar = '*', Text = "12345", BorderStyle = BorderStyle.FixedSingle }; Label lbl_Space = new Label() { Text = "", AutoSize = false, Width = 10 }; Button btn_Login = new Button() { Text = "LOGIN", Width = 80, TextAlign = System.Drawing.ContentAlignment.MiddleCenter }; Button btn_Close = new Button() { Text = "CLOSE", Width = 80, TextAlign = System.Drawing.ContentAlignment.MiddleCenter }; box.Controls.AddRange(new Control[] { lbl_Username, txt_Username, lbl_Pass, txt_Pass, lbl_Space, btn_Login, btn_Close, }); this.Controls.Add(box); box.BringToFront(); btn_Login.Focus(); btn_Close.Click += (se, ev) => { if (OnExit != null) { OnExit(); } }; btn_Login.Click += (se, ev) => { this.Hide(); if (OnLogin != null) { OnLogin(txt_Username.Text, txt_Pass.Text); } }; }
private void tabPage_CreateUI(string modelName) { var info = db.GetInfoSelectTop(modelName, selectTop); if (info == null) { tab.TabPages.Add(new TabPageCustom()); } else { TabPageCustom page = new TabPageCustom(info.Fields) { BackColor = Color.White, }; #region [ === BOX FILTER === ] int hi = (((info.Fields.Length / 3) + (info.Fields.Length % 3 == 0 ? 0 : 1) + 0) * 27); if (info.Fields.Length < 4) { hi = 27; } FlowLayoutPanel boi_Filter = new FlowLayoutPanel() { Visible = false, Dock = DockStyle.Top, Height = hi, AutoScroll = false, Padding = new Padding(0), BackColor = App.ColorBg }; boi_Filter.FlowDirection = FlowDirection.LeftToRight; boi_Filter.MouseDown += Label_MouseDown; for (int k = 1; k <= info.Fields.Length; k++) { var dp = info.Fields[k - 1]; Label lbl = new Label() { Name = "lbl" + k.ToString(), Text = dp.Name, AutoSize = false, Width = 120, ForeColor = Color.White, TextAlign = ContentAlignment.MiddleRight }; ComboBox cbo = new ComboBox() { Name = "cbo" + k.ToString(), Width = 80, BackColor = App.ColorControl, DropDownStyle = ComboBoxStyle.DropDownList }; if (dp.Type.Name == "String") { for (int ki = 0; ki < OpString.Length; ki++) { cbo.Items.Add(OpString[ki]); } } else { for (int ki = 0; ki < OpNumber.Length; ki++) { cbo.Items.Add(OpNumber[ki]); } } TextBox txt = new TextBox() { Name = "txt" + k.ToString(), Width = 80, BackColor = App.ColorControl, BorderStyle = BorderStyle.FixedSingle }; boi_Filter.Controls.AddRange(new Control[] { lbl, cbo, txt, }); if (k != 0 && k % 3 == 0) { Label sp = new Label() { Text = "", AutoSize = false, Width = App.Width - App.col_Left_Width, Height = 1, }; boi_Filter.Controls.Add(sp); } }//end for fields #endregion #region [ === BOX SEARCH - SHOW | HIDE FILTER === ] Panel boi_Action = new Panel() { Dock = DockStyle.Top, Height = 27, AutoScroll = false, Padding = new Padding(0, 5, 10, 3), BackColor = App.ColorBg }; boi_Action.MouseDown += Label_MouseDown; TextBox txt_Keyword = new TextBox() { Dock = DockStyle.Right, Width = 166, BorderStyle = BorderStyle.FixedSingle, BackColor = App.ColorControl }; ButtonCustom btn_Search = new ButtonCustom() { Text = "Search", Dock = DockStyle.Right, FlatStyle = System.Windows.Forms.FlatStyle.Flat, Width = 60, TextAlign = System.Drawing.ContentAlignment.MiddleCenter, BackColor = Color.Gray, ForeColor = Color.White, }; ButtonCustom btn_Filter = new ButtonCustom() { Text = "Filter", Dock = DockStyle.Right, FlatStyle = System.Windows.Forms.FlatStyle.Flat, Width = 50, TextAlign = System.Drawing.ContentAlignment.MiddleCenter, BackColor = Color.Gray, ForeColor = Color.White, }; boi_Action.Controls.AddRange(new Control[] { txt_Keyword, new Label() { Dock = DockStyle.Right, AutoSize = false, Width = 2, Height = 20, BackColor = App.ColorBg }, btn_Search, new Label() { Dock = DockStyle.Right, AutoSize = false, Width = 2, Height = 20, BackColor = App.ColorBg }, btn_Filter, }); #endregion #region [ === GRID === ] var grid = new ListViewModelItem() { Dock = DockStyle.Fill }; grid.SetDataBinding(info.Fields, info.DataSelectTop); #endregion #region [ === BOX FOOTER === ] Panel boi_Footer = new Panel() { Dock = DockStyle.Bottom, Height = 18, AutoScroll = false, Padding = new Padding(0), BackColor = App.ColorBg }; boi_Footer.MouseDown += Label_MouseDown; Label lbl_TotalRecord = new Label() { Dock = DockStyle.Left, Text = "Records: " + info.DataSelectTop.Count.ToString() + " / " + info.TotalRecord.ToString() + " ", AutoSize = false, Width = 199, Height = 18, Padding = new Padding(0), Font = new Font(new FontFamily("Arial"), 7F, FontStyle.Regular), ForeColor = Color.WhiteSmoke, TextAlign = ContentAlignment.MiddleLeft }; Label lbl_Port = new Label() { Dock = DockStyle.Left, Text = "Port HTTP: " + info.PortHTTP.ToString(), AutoSize = false, Width = 110, Height = 18, Padding = new Padding(4, 0, 0, 0), Font = new Font(new FontFamily("Arial"), 7F, FontStyle.Regular), ForeColor = Color.WhiteSmoke, TextAlign = ContentAlignment.MiddleLeft }; //ButtonCustom btn_Search = new ButtonCustom() { Text = "search", Dock = DockStyle.Right, FlatStyle = System.Windows.Forms.FlatStyle.Flat, Width = 80, TextAlign = System.Drawing.ContentAlignment.MiddleCenter, BackColor = Color.Gray, ForeColor = Color.White, }; ButtonCustom btn_PagePrev = new ButtonCustom() { Text = "<<<", Dock = DockStyle.Right, FlatStyle = System.Windows.Forms.FlatStyle.Flat, Width = 80, TextAlign = System.Drawing.ContentAlignment.MiddleCenter, BackColor = App.ColorBg, ForeColor = Color.White, }; ButtonCustom btn_PageNext = new ButtonCustom() { Text = ">>>", Dock = DockStyle.Right, FlatStyle = System.Windows.Forms.FlatStyle.Flat, Width = 80, TextAlign = System.Drawing.ContentAlignment.MiddleCenter, BackColor = App.ColorBg, ForeColor = Color.White, }; Label spa = new Label() { Text = "", AutoSize = false, Width = App.Width, Height = 1, }; Label lbl_PageCurrent = new Label() { Text = "1", Dock = DockStyle.Right, AutoSize = false, Width = 30, ForeColor = Color.White, TextAlign = ContentAlignment.MiddleCenter }; Label lbl_PageSP = new Label() { Text = " | ", Dock = DockStyle.Right, AutoSize = false, Width = 30, ForeColor = Color.White, TextAlign = ContentAlignment.MiddleCenter }; Label lbl_PageTotal = new Label() { Text = "1", Dock = DockStyle.Right, AutoSize = false, Width = 30, ForeColor = Color.White, TextAlign = ContentAlignment.MiddleCenter }; lbl_PageTotal.Text = ((int)(info.TotalRecord / selectTop) + (info.TotalRecord % selectTop == 0 ? 0 : 1)).ToString(); boi_Footer.Controls.AddRange(new Control[] { lbl_TotalRecord, lbl_Port, btn_PagePrev, lbl_PageCurrent, lbl_PageSP, lbl_PageTotal, btn_PageNext, }); #endregion page.Controls.AddRange(new Control[] { boi_Filter, boi_Action, grid, boi_Footer, }); tab.TabPages.Add(page); boi_Filter.BringToFront(); boi_Action.BringToFront(); grid.BringToFront(); btn_Filter.Click += (se, ev) => { if (boi_Filter.Visible) { boi_Filter.Visible = false; } else { boi_Filter.Visible = true; } }; ////////////////////////////////////////////////// btn_PageNext.Click += (se, ev) => tabPage_Next(modelName, info, page, grid, lbl_PageCurrent, lbl_PageTotal, lbl_TotalRecord); btn_PagePrev.Click += (se, ev) => tabPage_Prev(modelName, info, page, grid, lbl_PageCurrent, lbl_PageTotal, lbl_TotalRecord); ////////////////////////////////////////////////// txt_Keyword.KeyDown += (se, ev) => { if (ev.KeyCode == Keys.Enter) { tabPage_Search(txt_Keyword.Text, modelName, info, page, grid, lbl_PageCurrent, lbl_PageTotal, lbl_TotalRecord); } }; btn_Search.Click += (se, ev) => tabPage_Search(txt_Keyword.Text, modelName, info, page, grid, lbl_PageCurrent, lbl_PageTotal, lbl_TotalRecord); page.OnLoadData += () => { info = db.GetInfoSelectTop(modelName, selectTop); tabPage_Search(txt_Keyword.Text, modelName, info, page, grid, lbl_PageCurrent, lbl_PageTotal, lbl_TotalRecord); }; }//end bind info Model }
public void BuildSubURLTabs(object sender, EventArgs ev, URLTabPlugin.TabTypes tt) { if (sender != null) { /* Create a panel, find the parent form and maximize it */ Panel p = (Panel)sender; TabPage c = (TabPage)p.Parent; Form f = c.FindForm(); f.WindowState = FormWindowState.Maximized; TabControl tc = new TabControl(); p.Controls.Add(tc); tc.Dock = DockStyle.Fill; /* Create a list of URLTabs */ this.propertyString = "URLTabPlugin+" + c.Text.Replace(" ", "_"); string result = objHost.GetSQL("SELECT Value FROM properties where Name LIKE '%" + this.propertyString + "%'"); var UTP = Activator.CreateInstance <List <URLTabPlugin> >(); if (result != "-9999") { using (var memoryStream = new MemoryStream(Encoding.Unicode.GetBytes(result))) { var serializer = new DataContractJsonSerializer(UTP.GetType()); UTP = (List <URLTabPlugin>)serializer.ReadObject(memoryStream); } foreach (URLTabPlugin utp in UTP) { if (utp.TabType == tt) { TabPage tp = new TabPage(utp.TabLabel); tc.Controls.Add(tp); tp.Dock = DockStyle.Fill; tp.BringToFront(); WebBrowser wb = new WebBrowser(); wb.AllowNavigation = true; wb.AllowWebBrowserDrop = false; wb.ScriptErrorsSuppressed = true; wb.ScrollBarsEnabled = true; wb.IsWebBrowserContextMenuEnabled = true; tp.Controls.Add(wb); wb.Dock = DockStyle.Fill; wb.BringToFront(); wb.Navigate(utp.TabUrl); wb.Refresh(); } } } /* Build the config tab */ TabPage tconfig = new TabPage("Config"); tc.Controls.Add(tconfig); tconfig.Dock = DockStyle.Fill; /* Dynamic flow layout to hold the buttons */ FlowLayoutPanel buttonFlowLayoutPanel = new FlowLayoutPanel(); buttonFlowLayoutPanel.BringToFront(); buttonFlowLayoutPanel.FlowDirection = FlowDirection.LeftToRight; buttonFlowLayoutPanel.Location = new System.Drawing.Point(8, 10); buttonFlowLayoutPanel.Size = new System.Drawing.Size(510, 32); tconfig.Controls.Add(buttonFlowLayoutPanel); Button btnSaveConfig = new Button(); btnSaveConfig.Text = "Save Config"; btnSaveConfig.Click += new EventHandler(btnSaveConfig_Click); Button btnAddTab = new Button(); btnAddTab.Text = "Add Tab"; btnAddTab.Click += new EventHandler(btnAddTab_Click); buttonFlowLayoutPanel.Controls.Add(btnSaveConfig); buttonFlowLayoutPanel.Controls.Add(btnAddTab); /* Dynamic Flow Layout to hold taburlconfigs */ dynamicFlowLayoutPanel = new FlowLayoutPanel(); dynamicFlowLayoutPanel.BringToFront(); dynamicFlowLayoutPanel.FlowDirection = FlowDirection.TopDown; dynamicFlowLayoutPanel.Location = new System.Drawing.Point(0, 40); dynamicFlowLayoutPanel.Size = new System.Drawing.Size(510, 600); dynamicFlowLayoutPanel.AutoScroll = true; dynamicFlowLayoutPanel.WrapContents = false; tconfig.Controls.Add(dynamicFlowLayoutPanel); string results = objHost.GetSQL("SELECT Value FROM properties where Name LIKE '%" + propertyString + "%'"); if (results != "-9999") { List <string> TabsCompleted = new List <string>(); /* Rewrite, this doesn't make sense. Deserialize it instead and loop through those results. */ foreach (URLTabPlugin utp in UTP) { URLTabPluginConfigTab utpct; // If the tab isn't in the list yet, create it if (TabsCompleted.IndexOf(utp.TabLabel) < 0) { TabsCompleted.Add(utp.TabLabel); utpct = new URLTabPluginConfigTab(); utpct.tabLabel = utp.TabLabel; utpct.tabClientUrl = utp.TabUrl; utpct.tabClientCheck = CheckState.Checked; dynamicFlowLayoutPanel.Controls.Add(utpct); } // if it is, find it. else { Control[] utpcts = dynamicFlowLayoutPanel.Controls.Find("txtTabLabel", true); foreach (Control utpctss in utpcts) { if (utpctss.Text == utp.TabLabel) { /* ..And check and fill in the right datafields based on the Tab type */ if (utp.TabType == URLTabPlugin.TabTypes.Client) { utpctss.Parent.Controls.Find("txtClientUrl", true)[0].Text = utp.TabUrl; CheckBox ck = (CheckBox)utpctss.Parent.Controls.Find("chkClient", true)[0]; ck.CheckState = CheckState.Checked; } else if (utp.TabType == URLTabPlugin.TabTypes.Location) { utpctss.Parent.Controls.Find("txtLocationUrl", true)[0].Text = utp.TabUrl; CheckBox ck = (CheckBox)utpctss.Parent.Controls.Find("chkLocation", true)[0]; ck.CheckState = CheckState.Checked; } else if (utp.TabType == URLTabPlugin.TabTypes.Computer) { utpctss.Parent.Controls.Find("txtComputerUrl", true)[0].Text = utp.TabUrl; CheckBox ck = (CheckBox)utpctss.Parent.Controls.Find("chkComputer", true)[0]; ck.CheckState = CheckState.Checked; } } } } /* * if (utp.TabType == URLTabPlugin.TabTypes.Client) * { * utpct.tabClientUrl = utp.TabUrl; * * }*/ } } } }
public static void CreatePanelElements(PictureBox picturePanel, Elements.Type[] types) { flowPanel = new FlowLayoutPanel(); flowPanel.Left = 9; flowPanel.Top = 43; flowPanel.Width = 300; flowPanel.Height = 433; flowPanel.BackColor = Color.Transparent; flowPanel.AutoScroll = true; blocks = new TableLayoutPanel[types.Length]; pictureBlock = new PictureBox[types.Length]; title = new Label[types.Length]; for (int i = 0; i < types.Length; i++) { blocks[i] = new TableLayoutPanel(); blocks[i].RowCount = 2; blocks[i].Width = 135; blocks[i].Height = 104; blocks[i].BackColor = Color.Transparent; blocks[i].Margin = new Padding(1, 3, 1, 3); blocks[i].RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); blocks[i].RowStyles.Add(new RowStyle()); blocks[i].RowStyles.Add(new RowStyle(SizeType.Absolute, 20F)); pictureBlock[i] = new PictureBox(); pictureBlock[i].SizeMode = PictureBoxSizeMode.Zoom; pictureBlock[i].Dock = DockStyle.Fill; pictureBlock[i].Click += Click; pictureBlock[i].MouseEnter += MouseEnter; pictureBlock[i].MouseLeave += MouseLeave; title[i] = new Label(); title[i].Dock = DockStyle.Fill; title[i].Font = new Font("Calibri", 12F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(204))); title[i].TextAlign = ContentAlignment.MiddleCenter; title[i].ForeColor = Color.FromArgb(64, 64, 64); if (types[i] == Elements.Type.Ammeter) { pictureBlock[i].Name = "ammeter"; pictureBlock[i].Image = Properties.Resources.ammeter; title[i].Text = "Амперметр"; } else if (types[i] == Elements.Type.Voltmeter) { pictureBlock[i].Name = "voltmeter"; pictureBlock[i].Image = Properties.Resources.voltmeter; title[i].Text = "Вольтметр"; } else if (types[i] == Elements.Type.Multimeter) { pictureBlock[i].Name = "multimeter"; pictureBlock[i].Image = Properties.Resources.multimetr; title[i].Text = "Мультиметр"; } else if (types[i] == Elements.Type.Conductor) { pictureBlock[i].Name = "conductor"; pictureBlock[i].Image = Properties.Resources.conductor; title[i].Text = "Проводник"; } else if (types[i] == Elements.Type.Resistor) { pictureBlock[i].Name = "resistor"; pictureBlock[i].Image = Properties.Resources.resistor; title[i].Text = "Резистор"; } else if (types[i] == Elements.Type.Rheostat) { pictureBlock[i].Name = "rheostat"; pictureBlock[i].Image = Properties.Resources.rheostat; title[i].Text = "Реостат"; } else if (types[i] == Elements.Type.VoltageSource) { pictureBlock[i].Name = "voltage_source"; pictureBlock[i].Image = Properties.Resources.voltage; title[i].Text = "Ист.напряжения"; } else if (types[i] == Elements.Type.Capacitor) { pictureBlock[i].Name = "capacitor"; pictureBlock[i].Image = Properties.Resources.capacitor; title[i].Text = "Конденсатор"; } else if (types[i] == Elements.Type.SingleSwitch) { pictureBlock[i].Name = "single_switch"; pictureBlock[i].Image = Properties.Resources.s_switch0; title[i].Text = "Перекл. х1"; } else if (types[i] == Elements.Type.DoubleSwitch) { pictureBlock[i].Name = "double_switch"; pictureBlock[i].Image = Properties.Resources.d_switch; title[i].Text = "Перекл. х2"; } else if (types[i] == Elements.Type.Toggle) { pictureBlock[i].Name = "toggle"; pictureBlock[i].Image = Properties.Resources.toggle_off; title[i].Text = "Ключ"; } else if (types[i] == Elements.Type.Lamp) { pictureBlock[i].Name = "lamp"; pictureBlock[i].Image = Properties.Resources.lamp_off; title[i].Text = "Лампочка"; } else if (types[i] == Elements.Type.Stopwatch) { pictureBlock[i].Name = "stopwatch"; pictureBlock[i].Image = Properties.Resources.stopwatch; title[i].Text = "Секундомер"; } blocks[i].Controls.Add(pictureBlock[i]); blocks[i].Controls.Add(title[i]); flowPanel.Controls.Add(blocks[i]); flowPanel.BringToFront(); } picturePanel.Controls.Add(flowPanel); }
public FormLookupItem(IDataFile db) : base("LOOKUP ITEM", true) { FormBorderStyle = FormBorderStyle.None; AutoScaleBaseSize = new Size(5, 13); ClientSize = new Size(800, 400); string dbNameCurrent = "Test"; int selectTop = 100; string[] OpString = "Equals,NotEquals,Contains,StartsWith,EndsWith".Split(','); string[] OpNumber = "Equals,NotEquals,Contains,GreaterThan,LessThan,GreaterThanOrEqual,LessThanOrEqual".Split(','); var info = db.GetInfoSelectTop(dbNameCurrent, selectTop); if (info != null) { #region [ === CREATE NEW TAB PAGE === ] PanelCustom page = new PanelCustom(info.Fields) { Dock = DockStyle.Fill, BackColor = Color.White, }; int hi = (((info.Fields.Length / 3) + 1) * 25); if (info.Fields.Length < 4) { hi = 50; } FlowLayoutPanel boi_Filter = new FlowLayoutPanel() { Dock = DockStyle.Top, Height = hi, AutoScroll = false, Padding = new Padding(0), BackColor = App.ColorBg }; boi_Filter.FlowDirection = FlowDirection.LeftToRight; boi_Filter.MouseDown += FormMove_MouseDown; Label lbl_Keyword = new Label() { Width = 60, AutoSize = false, Text = "Search ", ForeColor = Color.White, TextAlign = ContentAlignment.MiddleRight }; TextBox txt_Keyword = new TextBox() { Width = 166, BorderStyle = BorderStyle.FixedSingle }; Label sp0 = new Label() { Text = "", AutoSize = false, Width = App.Width, Height = 1, }; boi_Filter.Controls.AddRange(new Control[] { lbl_Keyword, txt_Keyword, sp0 }); StringBuilder wh_Contain = new StringBuilder(); for (int k = 0; k < info.Fields.Length; k++) { var dp = info.Fields[k]; wh_Contain.Append(dp.NAME + (dp.Type.Name == "String" ? string.Empty : ".ToString()") + ".Contains(@0) "); if (k < info.Fields.Length - 1) { wh_Contain.Append(" || "); } Label lbl = new Label() { Name = "lbl" + k.ToString(), Text = dp.NAME, AutoSize = false, Width = 60, ForeColor = Color.White, TextAlign = ContentAlignment.MiddleRight }; ComboBox cbo = new ComboBox() { Name = "cbo" + k.ToString(), Width = 80, DropDownStyle = ComboBoxStyle.DropDownList, }; if (dp.Type.Name == "String") { for (int ki = 0; ki < OpString.Length; ki++) { cbo.Items.Add(OpString[ki]); } } else { for (int ki = 0; ki < OpNumber.Length; ki++) { cbo.Items.Add(OpNumber[ki]); } } TextBox txt = new TextBox() { Name = "txt" + k.ToString(), Width = 80, BorderStyle = BorderStyle.FixedSingle }; boi_Filter.Controls.AddRange(new Control[] { lbl, cbo, txt, }); if (k != 0 && k % 3 == 0) { Label sp = new Label() { Text = "", AutoSize = false, Width = App.Width, Height = 1, }; boi_Filter.Controls.Add(sp); } }//end for fields Panel boi_Action = new Panel() { Dock = DockStyle.Top, Height = 27, AutoScroll = false, Padding = new Padding(0, 5, 10, 3), BackColor = App.ColorBg }; boi_Action.MouseDown += FormMove_MouseDown; Label lbl_TotalRecord = new Label() { Dock = DockStyle.Left, Text = "Records: " + info.DataSelectTop.Count.ToString() + " / " + info.TotalRecord.ToString() + " ", AutoSize = false, Width = 199, Padding = new Padding(0), Font = new Font(new FontFamily("Arial"), 8F, FontStyle.Regular), ForeColor = Color.WhiteSmoke, TextAlign = ContentAlignment.BottomLeft }; Label lbl_Port = new Label() { Dock = DockStyle.Left, Text = "Port HTTP: " + info.PortHTTP.ToString(), AutoSize = false, Width = 110, Padding = new Padding(4, 0, 0, 0), Font = new Font(new FontFamily("Arial"), 8F, FontStyle.Regular), ForeColor = Color.WhiteSmoke, TextAlign = ContentAlignment.BottomLeft }; ButtonCustom btn_Search = new ButtonCustom() { Text = "search", Dock = DockStyle.Right, FlatStyle = System.Windows.Forms.FlatStyle.Flat, Width = 80, TextAlign = System.Drawing.ContentAlignment.MiddleCenter, BackColor = Color.Gray, ForeColor = Color.White, }; ButtonCustom btn_PagePrev = new ButtonCustom() { Text = "<<<", Dock = DockStyle.Right, FlatStyle = System.Windows.Forms.FlatStyle.Flat, Width = 80, TextAlign = System.Drawing.ContentAlignment.MiddleCenter, BackColor = App.ColorBg, ForeColor = Color.White, }; ButtonCustom btn_PageNext = new ButtonCustom() { Text = ">>>", Dock = DockStyle.Right, FlatStyle = System.Windows.Forms.FlatStyle.Flat, Width = 80, TextAlign = System.Drawing.ContentAlignment.MiddleCenter, BackColor = App.ColorBg, ForeColor = Color.White, }; Label spa = new Label() { Text = "", AutoSize = false, Width = App.Width, Height = 1, }; Label lbl_PageCurrent = new Label() { Text = "1", Dock = DockStyle.Right, AutoSize = false, Width = 30, ForeColor = Color.White, TextAlign = ContentAlignment.MiddleCenter }; Label lbl_PageSP = new Label() { Text = " | ", Dock = DockStyle.Right, AutoSize = false, Width = 30, ForeColor = Color.White, TextAlign = ContentAlignment.MiddleCenter }; Label lbl_PageTotal = new Label() { Text = "1", Dock = DockStyle.Right, AutoSize = false, Width = 30, ForeColor = Color.White, TextAlign = ContentAlignment.MiddleCenter }; lbl_PageTotal.Text = ((int)(info.TotalRecord / selectTop) + (info.TotalRecord % selectTop == 0 ? 0 : 1)).ToString(); boi_Action.Controls.AddRange(new Control[] { lbl_TotalRecord, lbl_Port, btn_PagePrev, lbl_PageCurrent, lbl_PageSP, lbl_PageTotal, btn_PageNext, btn_Search, spa, }); Panel boi_Data = new Panel() { Dock = DockStyle.Fill }; CustomScrollbar scrollGrig = new CustomScrollbar() { Dock = DockStyle.Right, ActiveBackColor = Color.White, BackColor = Color.White, LargeChange = 10, Location = new Point(306, 12), Maximum = 99, Minimum = 0, Size = new Size(13, 303), SmallChange = 1, TabIndex = 1, ThumbStyle = CustomScrollbar.ThumbStyleEnum.Auto, Value = 0, Margin = new Padding(0), Padding = new Padding(0), }; //ScrollbarStyleHelper.ApplyStyle(scrollGrig, ScrollbarStyleHelper.StyleTypeEnum.Blue); //ScrollbarStyleHelper.ApplyStyle(scrollGrig, ScrollbarStyleHelper.StyleTypeEnum.Black); CustomListView grid = new CustomListView() { VScrollbar = new ScrollbarCollector(scrollGrig), Dock = DockStyle.Fill, BackColor = Color.White, BorderStyle = BorderStyle.None, // Set the view to show details. View = View.Details, // Allow the user to edit item text. //LabelEdit = true, // Allow the user to rearrange columns. //AllowColumnReorder = true, // Select the item and subitems when selection is made. FullRowSelect = true, // Display grid lines. GridLines = true, // Sort the items in the list in ascending order. //Sorting = SortOrder.Ascending, //HeaderStyle = ColumnHeaderStyle.None, //FullRowSelect = true, //HideSelection = false, Location = new Point(12, 12), MultiSelect = false, Size = new Size(288, 303), UseCompatibleStateImageBehavior = false, //View = View.Details, HeaderStyle = ColumnHeaderStyle.Nonclickable, };; grid.SetDataBinding(info.Fields, info.DataSelectTop); boi_Data.Controls.AddRange(new Control[] { grid, scrollGrig, }); page.Controls.AddRange(new Control[] { boi_Filter, boi_Action, boi_Data, }); this.Controls.Add(page); boi_Filter.BringToFront(); boi_Action.BringToFront(); //grid.BringToFront(); boi_Data.BringToFront(); PanelHeader_SendToBack(); #endregion ////////////////////////////////////////////////// #region [ === PREV - NEXT === ] btn_PageNext.Click += (se, ev) => { SearchRequest sr = page.SearchRequest; SearchResult rs = page.SearchResult; if (sr == null) { int PageNumber = page.PageCurrent + 1; if (PageNumber > int.Parse(lbl_PageTotal.Text)) { return; } page.PageCurrent = PageNumber; lbl_PageCurrent.Text = page.PageCurrent.ToString(); grid.SetDataBinding(info.Fields, db.GetSelectPage(dbNameCurrent, PageNumber, selectTop)); } else { sr.PageNumber = sr.PageNumber + 1; if (sr.PageNumber > int.Parse(lbl_PageTotal.Text)) { return; } rs = db.Search(dbNameCurrent, sr); page.SearchRequest = sr; page.SearchResult = rs; if (rs != null) { page.PageCurrent = rs.PageNumber; lbl_PageCurrent.Text = page.PageCurrent.ToString(); lbl_TotalRecord.Text = "Records: " + rs.IDs.Length.ToString() + " / " + info.TotalRecord.ToString() + " "; grid.SetDataBinding(info.Fields, (IList)rs.Message); } } }; btn_PagePrev.Click += (se, ev) => { SearchRequest sr = page.SearchRequest; SearchResult rs = page.SearchResult; if (sr == null) { int PageNumber = page.PageCurrent - 1; if (PageNumber == 0) { return; } page.PageCurrent = PageNumber; lbl_PageCurrent.Text = page.PageCurrent.ToString(); grid.SetDataBinding(info.Fields, db.GetSelectPage(dbNameCurrent, PageNumber, selectTop)); } else { sr.PageNumber = rs.PageNumber - 1; if (sr.PageNumber == 0) { return; } rs = db.Search(dbNameCurrent, sr); page.SearchRequest = sr; page.SearchResult = rs; if (rs != null) { page.PageCurrent = rs.PageNumber; lbl_PageCurrent.Text = page.PageCurrent.ToString(); lbl_TotalRecord.Text = "Records: " + rs.IDs.Length.ToString() + " / " + info.TotalRecord.ToString() + " "; grid.SetDataBinding(info.Fields, (IList)rs.Message); } } }; #endregion ////////////////////////////////////////////////// #region [ === SEARCH === ] txt_Keyword.KeyDown += (se, ev) => { if (ev.KeyCode == Keys.Enter) { //grid.DataSource = null; string predicate = "", kw = txt_Keyword.Text; if (string.IsNullOrEmpty(kw)) { page.SearchRequest = null; page.SearchResult = null; page.PageCurrent = 1; lbl_PageCurrent.Text = page.PageCurrent.ToString(); int countPage = (int)(info.TotalRecord / selectTop) + (info.TotalRecord % selectTop == 0 ? 0 : 1); lbl_PageTotal.Text = countPage.ToString(); lbl_TotalRecord.Text = "Records: " + info.DataSelectTop.Count.ToString() + " / " + info.TotalRecord.ToString() + " "; grid.SetDataBinding(info.Fields, info.DataSelectTop); } else { List <object> lp = new List <object>(); predicate = wh_Contain.ToString(); lp.Add(kw); SearchRequest sr = new SearchRequest(selectTop, 1, predicate, lp.Count == 0 ? null : lp.ToArray()); SearchResult rs = db.Search(dbNameCurrent, sr); page.SearchRequest = sr; page.SearchResult = rs; if (rs != null) { page.PageCurrent = rs.PageNumber; lbl_PageCurrent.Text = page.PageCurrent.ToString(); int countPage = (int)(rs.Total / selectTop) + (rs.Total % selectTop == 0 ? 0 : 1); lbl_PageTotal.Text = countPage.ToString(); lbl_TotalRecord.Text = "Records: " + rs.IDs.Length.ToString() + " / " + info.TotalRecord.ToString() + " "; grid.SetDataBinding(info.Fields, (IList)rs.Message); } } } }; btn_Search.Click += (se, ev) => { //grid.DataSource = null; string predicate = "", kw = txt_Keyword.Text; if (string.IsNullOrEmpty(kw)) { page.SearchRequest = null; page.SearchResult = null; page.PageCurrent = 1; lbl_PageCurrent.Text = page.PageCurrent.ToString(); int countPage = (int)(info.TotalRecord / selectTop) + (info.TotalRecord % selectTop == 0 ? 0 : 1); lbl_PageTotal.Text = countPage.ToString(); lbl_TotalRecord.Text = "Records: " + info.DataSelectTop.Count.ToString() + " / " + info.TotalRecord.ToString() + " "; grid.SetDataBinding(info.Fields, info.DataSelectTop); } else { List <object> lp = new List <object>(); predicate = wh_Contain.ToString(); lp.Add(kw); SearchRequest sr = new SearchRequest(selectTop, 1, predicate, lp.Count == 0 ? null : lp.ToArray()); SearchResult rs = db.Search(dbNameCurrent, sr); page.SearchRequest = sr; page.SearchResult = rs; if (rs != null) { page.PageCurrent = rs.PageNumber; lbl_PageCurrent.Text = page.PageCurrent.ToString(); int countPage = (int)(rs.Total / selectTop) + (rs.Total % selectTop == 0 ? 0 : 1); lbl_PageTotal.Text = countPage.ToString(); lbl_TotalRecord.Text = "Records: " + rs.IDs.Length.ToString() + " / " + info.TotalRecord.ToString() + " "; grid.SetDataBinding(info.Fields, (IList)rs.Message); } } }; #endregion }//end bind info Model }
public FormItemAdd(IDataFile _db, string dbName) : base(true) { int _Hi = 0; db = _db; ClientSize = new Size(fWidth, Screen.PrimaryScreen.WorkingArea.Height - 80); Top = 40; var model = db.GetModel(dbName); #region [ === CONTROLS UI === ] FlowLayoutPanel boi_Filter = new FlowLayoutPanel() { Dock = DockStyle.Fill, AutoScroll = true, WrapContents = true, Padding = new Padding(0), BackColor = Color.WhiteSmoke, FlowDirection = FlowDirection.LeftToRight, }; boi_Filter.MouseDown += FormMove_MouseDown; var fields = model.Fields.Where(x => x.IsKeyAuto == false).ToArray(); for (int ki = 0; ki < fields.Length; ki++) { var uc = new ucDataItemAdd(ki, fields[ki]) { Name = "uc" + ki.ToString(), }; uc.Height = uc._Height; uc.Width = uc._Width; boi_Filter.Controls.Add(uc); } int kitMin = ((fields.Select(x => x.Kit).Where(x => x != ControlKit.HTML && x != ControlKit.TEXTAREA) .Count() / 2) + 1); int hi_Min = (kitMin * ucDataItemAdd.Height_Min) + (kitMin * 10); int hi_Max = fields.Select(x => x.Kit).Where(x => x == ControlKit.HTML || x == ControlKit.TEXTAREA) .Count() * ucDataItemAdd.Height_Max; _Hi = hi_Min + hi_Max + 60; Panel boi_Action = new Panel() { Dock = DockStyle.Bottom, Height = 25 }; Button btn_Submit = new Button() { Dock = DockStyle.Right, Text = "SUBMIT", BackColor = Color.WhiteSmoke, Width = 60, TextAlign = ContentAlignment.MiddleCenter }; Button btn_Reset = new Button() { Dock = DockStyle.Right, Text = "RESET", BackColor = Color.WhiteSmoke, Width = 60, TextAlign = ContentAlignment.MiddleCenter }; boi_Action.Controls.AddRange(new Control[] { btn_Submit, btn_Reset }); boi_Action.MouseDown += FormMove_MouseDown; this.Controls.AddRange(new Control[] { boi_Filter, boi_Action }); boi_Action.BringToFront(); boi_Filter.BringToFront(); btn_Submit.Focus(); #endregion if (_Hi < Screen.PrimaryScreen.WorkingArea.Height) { if (_Hi < 200) { _Hi = 200; } ClientSize = new System.Drawing.Size(fWidth, _Hi); } btn_Submit.Click += (se, ev) => form_Submit(dbName, boi_Filter); HideScrollBar(boi_Filter.Handle, ScrollBarHide.SB_HORZ); }
/// <summary> /// 输入框发生变化 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtInput_TextChanged(object sender, EventArgs e) { if (txtInput.Text != "") { if (!_search) { _search = true; return; } _district = ""; _city = ""; ((Action)(delegate() //异步调用API 获取建议位置 { PlaceSuggestionService pss = new PlaceSuggestionService(); JObject suggestion_places = pss.Suggestion(txtInput.Text, CurrentCity); //建议位置 if (suggestion_places != null) { this.Invoke((Action) delegate() { _suggestion_places.Controls.Clear(); _suggestion_places.Padding = new System.Windows.Forms.Padding(3); _suggestion_places.Width = Width; _suggestion_places.BackColor = Color.White; _suggestion_places.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; foreach (JObject place in suggestion_places["result"]) //返回JSON结构请参见百度API文档 { Label lbl = new Label(); lbl.MouseEnter += new EventHandler(lbl_MouseEnter); lbl.MouseLeave += new EventHandler(lbl_MouseLeave); lbl.Click += new EventHandler(lbl_Click); lbl.BackColor = Color.White; lbl.AutoSize = false; lbl.Padding = new System.Windows.Forms.Padding(0, 5, 0, 5); lbl.Font = new System.Drawing.Font("微软雅黑", 9); lbl.Width = _suggestion_places.Width - 15; lbl.Height = 30; lbl.TextAlign = ContentAlignment.MiddleLeft; lbl.Image = Properties.BMap.ico_search; lbl.ImageAlign = ContentAlignment.MiddleLeft; lbl.Tag = (string)place["name"] + "|" + (string)place["district"] + "|" + (string)place["city"]; lbl.Text = " " + (string)place["name"] + " " + (string)place["city"] + "-" + (string)place["district"]; //返回JSON结构请参见百度API文档 _suggestion_places.Controls.Add(lbl); } if (_suggestion_places.Controls.Count > 0) { Control top = FindTheTopControl(); if (top != null) { Point p = new Point(txtInput.Left - 1, txtInput.Top + txtInput.Height); //文本框在BPlaceBox中的位置 Point location = top.PointToClient(PointToScreen(p)); //文本框位置转换为最顶层控件坐标系中对应位置 _suggestion_places.Location = location; _suggestion_places.Height = _suggestion_places.Controls.Count * _suggestion_places.Controls[0].Height + 10; if (!top.Controls.Contains(_suggestion_places)) { top.Controls.Add(_suggestion_places); } _suggestion_places.Visible = true; _suggestion_places.BringToFront(); } } else { _suggestion_places.Visible = false; } }); } })).BeginInvoke(null, null); } else { _suggestion_places.Visible = false; } }