protected virtual void InitializeParentPage() { ParentPage = new Page(); var privateObject = new PrivateObject(ParentPage); privateObject.SetField(FieldRequest, HttpContext.Current.Request); PrivateControl.SetField(FieldPage, ParentPage); }
protected virtual T GetField <T>(string fieldName) where T : class { var field = PrivateControl.GetField(fieldName) as T; field.ShouldNotBeNull($"The field {field} of type {typeof(T).Name} cannot be null"); return(field); }
public void AddContent(PrivateControl.DetailContent item) { if ( item == null ) return; this.TitleText = item.Caption; item.Margin = new System.Windows.Forms.Padding(0); item.ContentValidatedChanged += new EventHandler(item_SaveButtonVisibleChanged); item.SaveButtonVisibleChanged += new EventHandler(item_SaveButtonVisibleChanged); item.CancelButtonVisibleChanged += new EventHandler(item_CancelButtonVisibleChanged); item.LoadingChanged += new EventHandler(item_LoadingChanged); item.LoadingChanged += new EventHandler(item_SaveButtonVisibleChanged); item.LoadingChanged += new EventHandler(item_CancelButtonVisibleChanged); //item.BackColor = Color.Transparent; items.Add(item); flowLayoutPanel1.Controls.Add(item); }
public void AddDetailItem(PrivateControl.DetailContent content) { detailPane1.AddDetailItem(content); }
public DeliverDetailContentEventArgs(PrivateControl.DetailContent detail_content) { this.Detail_Content = detail_content; }
//public void SetLayout(XElement layout) //{ // if (layout == null) return; // ItemComparer comparer = new ItemComparer(layout, DetailItemOriginOrder); // LayoutXml = layout; // List<string> groups = new List<string>(_Containers.Keys); // //groups.Sort((x, y) => // //{ // // return comparer.Compare(x, y); // //}); // List<System.Windows.Forms.Control> controls = new List<System.Windows.Forms.Control>(_Containers.Values); // Dictionary<string, FlowLayoutPanel> links = new Dictionary<string, FlowLayoutPanel>(); // foreach (FlowLayoutPanel link in ContentLinks.Controls) // { // string name = (link.Controls[1] as LinkLabel).Text; //寫死了 @@'' // links.Add(name, link); // } // DetailItemContainers.Controls.Clear(); // ContentLinks.Controls.Clear(); // int count = 0; // foreach (string group in groups) // { // DetailItemContainers.Controls.Add(_Containers[group]); // AddContentLink(links[group], count++); // } //} public void DeleteDetailItem(PrivateControl.DetailContent content) { if (content == null) return; //DetailItemContainers.SuspendLayout(); if (_Containers.ContainsKey(content.Group)) { //_Containers[content.Group].RemoveContent(content); DetailItemContainers.Controls.Remove(_Containers[content.Group]); _Containers.Remove(content.Group); } if (_CheckBoxs.ContainsKey(content.Group)) _CheckBoxs.Remove(content.Group); if (_Labels.ContainsKey(content.Group)) _Labels.Remove(content.Group); if (DetailItemOriginOrder.Contains(content.Group)) DetailItemOriginOrder.Remove(content.Group); List<FlowLayoutPanel> links = new List<FlowLayoutPanel>(); foreach (FlowLayoutPanel link in ContentLinks.Controls) { string Group = (link.Controls[1] as LinkLabel).Tag + ""; if (Group == content.Group) continue; links.Add(link); } //You need to set AutoScroll = false, remove rows, then set AutoScroll = true. This will force the panel to recalculate the correct size. //ContentLinks.AutoScroll = true; ContentLinks.Controls.Clear(); ContentLinks.RowCount = 0; int count = 0; foreach (FlowLayoutPanel link in links) { AddContentLink(link, count++); } ContentLinks.AutoScroll = false; //DetailItemContainers.ResumeLayout(false); }
public void AddDetailItem(PrivateControl.DetailContent content) { if (content == null) return; //this.SuspendLayout(); DetailItemContainer container; if (!_Containers.ContainsKey(content.Group)) { DetailItemOriginOrder.Add(content.Group); container = new DetailItemContainer(); CheckBoxX checkbox = new CheckBoxX(); LinkLabel label = new LinkLabel(); FlowLayoutPanel panel = new FlowLayoutPanel(); //panel.SuspendLayout(); //DetailItemContainers.SuspendLayout(); checkbox.Tag = content.Group; checkbox.Checked = true; label.Tag = content.Group; label.Text = content.Title; label.Click += new EventHandler(label_Click); checkbox.CheckedChanged += new EventHandler(checkbox_CheckedChanged); //container.Visible = false; //panel.SuspendLayout(); //DetailItemContainers.SuspendLayout(); panel.Controls.Add(checkbox); panel.Controls.Add(label); panel.AutoSize = true; panel.Dock = System.Windows.Forms.DockStyle.Fill; panel.Margin = new System.Windows.Forms.Padding(2, 0, 10, 0); panel.Padding = new System.Windows.Forms.Padding(2, 2, 2, 0); checkbox.Anchor = System.Windows.Forms.AnchorStyles.None; checkbox.Size = new System.Drawing.Size(20, 15); checkbox.FocusCuesEnabled = false; checkbox.TextVisible = false; checkbox.Margin = new System.Windows.Forms.Padding(0); label.Anchor = System.Windows.Forms.AnchorStyles.None; label.AutoSize = true; label.Margin = new System.Windows.Forms.Padding(0); AddContentLink(panel, _Containers.Count); DetailItemContainers.Controls.Add(container); _Containers.Add(content.Group, container); _CheckBoxs.Add(content.Group, checkbox); _Labels.Add(content.Group, label); //panel.ResumeLayout(false); //DetailItemContainers.ResumeLayout(false); //checkbox.Checked = (PreferenceProvider["ContentsVisible"].GetAttribute(fixName(content.Group)) == "True"); //checkbox.Checked = Preference.GetBoolean(content.Group, false); } else container = _Containers[content.Group]; List<PrivateControl.DetailContent> contents = new List<DetailContent>(); _Containers.Values.ToList().ForEach((x) => { x.GetContents().ForEach(y => contents.Add(y)); }); if (content.DisplayOrder == null) { decimal Max_Display_Order = 0; foreach(DetailContent x in contents) { if (x.HierarchyTitle != content.HierarchyTitle) continue; if ((x.DisplayOrder.HasValue ? x.DisplayOrder.Value : 0) > Max_Display_Order) Max_Display_Order = (x.DisplayOrder.HasValue ? x.DisplayOrder.Value : 0); } content.DisplayOrder = Max_Display_Order + 1; } //container.SuspendLayout(); container.AddContent(content); //container.ResumeLayout(false); //this.ResumeLayout(false); }
public void RemoveContent(PrivateControl.DetailContent item) { if (item == null) return; flowLayoutPanel1.Controls.Remove(item); }