コード例 #1
0
        /// <summary>
        /// Generates Xml representation of this gadget
        /// </summary>
        /// <param name="doc">The Xml docment</param>
        /// <returns>XmlNode</returns>
        public override XmlNode Serialize(XmlDocument doc)
        {
            CombinedFrequencyParameters combFreqParameters = (CombinedFrequencyParameters)Parameters;

            System.Xml.XmlElement element = doc.CreateElement("combinedFrequencyGadget");
            //element.InnerXml = xmlString;
            element.AppendChild(SerializeFilters(doc));

            System.Xml.XmlAttribute id           = doc.CreateAttribute("id");
            System.Xml.XmlAttribute locationY    = doc.CreateAttribute("top");
            System.Xml.XmlAttribute locationX    = doc.CreateAttribute("left");
            System.Xml.XmlAttribute collapsed    = doc.CreateAttribute("collapsed");
            System.Xml.XmlAttribute type         = doc.CreateAttribute("gadgetType");
            System.Xml.XmlAttribute actualHeight = doc.CreateAttribute("actualHeight");

            id.Value           = this.UniqueIdentifier.ToString();
            locationY.Value    = Canvas.GetTop(this).ToString("F0");
            locationX.Value    = Canvas.GetLeft(this).ToString("F0");
            collapsed.Value    = IsCollapsed.ToString();
            type.Value         = "EpiDashboard.CombinedFrequencyControl";
            actualHeight.Value = this.ActualHeight.ToString();

            element.Attributes.Append(locationY);
            element.Attributes.Append(locationX);
            element.Attributes.Append(collapsed);
            element.Attributes.Append(type);
            element.Attributes.Append(id);
            if (IsCollapsed == false)
            {
                element.Attributes.Append(actualHeight);
            }

            XmlElement combineModeElement = doc.CreateElement("combineMode");

            combineModeElement.InnerText = combFreqParameters.CombineMode.ToString();
            element.AppendChild(combineModeElement);

            XmlElement trueValueElement = doc.CreateElement("trueValue");

            trueValueElement.InnerText = combFreqParameters.TrueValue.ToString();
            element.AppendChild(trueValueElement);

            XmlElement sortElement = doc.CreateElement("sort");

            if (combFreqParameters.SortHighToLow)
            {
                sortElement.InnerText = "hightolow";
            }
            element.AppendChild(sortElement);

            XmlElement showDenominatorElement = doc.CreateElement("showDenominator");

            showDenominatorElement.InnerText = combFreqParameters.ShowDenominator.ToString();
            element.AppendChild(showDenominatorElement);

            XmlElement customHeadingElement = doc.CreateElement("customHeading");

            customHeadingElement.InnerText = combFreqParameters.GadgetTitle.Replace("<", "&lt;");
            element.AppendChild(customHeadingElement);

            XmlElement customDescElement = doc.CreateElement("customDescription");

            customDescElement.InnerText = combFreqParameters.GadgetDescription.Replace("<", "&lt;");
            element.AppendChild(customDescElement);

            SerializeAnchors(element);

            XmlElement groupItemElement = doc.CreateElement("groupFields");

            string xmlGroupItemString = string.Empty;

            foreach (string columnName in combFreqParameters.ColumnNames)
            {
                xmlGroupItemString = xmlGroupItemString + "<groupField>" + columnName.Replace("<", "&lt;") + "</groupField>";
            }

            groupItemElement.InnerXml = xmlGroupItemString;

            if (!String.IsNullOrEmpty(xmlGroupItemString))
            {
                element.AppendChild(groupItemElement);
            }

            return(element);
        }
コード例 #2
0
        private void AddDataGrid(DataView dv, string strataValue)
        {
            DataGrid dg = new DataGrid();

            dg.Style = this.Resources["LineListDataGridStyle"] as Style;

            CombinedFrequencyParameters CombinedFrequencyParameters = (this.Parameters) as CombinedFrequencyParameters;

            FrameworkElementFactory datagridRowsPresenter = new FrameworkElementFactory(typeof(DataGridRowsPresenter));
            ItemsPanelTemplate      itemsPanelTemplate    = new ItemsPanelTemplate();

            itemsPanelTemplate.VisualTree = datagridRowsPresenter;
            GroupStyle groupStyle = new GroupStyle();

            groupStyle.ContainerStyle = this.Resources["DefaultGroupItemStyle"] as Style;
            groupStyle.Panel          = itemsPanelTemplate;
            dg.GroupStyle.Add(groupStyle);

            GroupStyle groupStyle2 = new GroupStyle();

            groupStyle2.HeaderTemplate = this.Resources["GroupDataTemplate"] as DataTemplate;
            //groupStyle.Panel = itemsPanelTemplate;
            dg.GroupStyle.Add(groupStyle2);

            string groupVar = String.Empty;

            //if (!String.IsNullOrEmpty(ListParameters.PrimaryGroupField.Trim()))
            //{
            //    groupVar = ListParameters.PrimaryGroupField.Trim();
            //    ListCollectionView lcv = new ListCollectionView(dv);
            //    lcv.GroupDescriptions.Add(new PropertyGroupDescription(groupVar));
            //    if (!String.IsNullOrEmpty(ListParameters.SecondaryGroupField.Trim()) && !ListParameters.SecondaryGroupField.Trim().Equals(groupVar))
            //    {
            //        lcv.GroupDescriptions.Add(new PropertyGroupDescription(ListParameters.SecondaryGroupField.Trim())); // for second category
            //    }
            //    dg.ItemsSource = lcv;
            //}
            //else
            //{
            dg.ItemsSource = dv;
            //}


            if (Parameters.Height.HasValue)
            {
                dg.MaxHeight = Parameters.Height.Value;
            }
            else
            {
                dg.MaxHeight = 700;
            }

            if (Parameters.Width.HasValue)
            {
                dg.MaxWidth = Parameters.Width.Value;
            }
            else
            {
                dg.MaxWidth = 900;
            }

            dg.AutoGeneratedColumns += new EventHandler(dg_AutoGeneratedColumns);
            dg.AutoGeneratingColumn += new EventHandler <DataGridAutoGeneratingColumnEventArgs>(dg_AutoGeneratingColumn);

            panelMain.Children.Add(dg);
        }