Beispiel #1
0
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
 {
     switch (connectionId)
     {
     case 1:
         this.SkeletonListShell = ((System.Windows.Controls.HeaderedItemsControl)(target));
         return;
     }
     this._contentLoaded = true;
 }
 private void uncheckGroup(HeaderedItemsControl parent)
 {
     foreach (var elem in parent.Items)
     {
         if (elem is RadioButton)
         {
             (elem as RadioButton).IsChecked = false;
         }
     }
 }
        private void InitializeMapLegend(int d1, int d2, int d3, HeaderedItemsControl headeredIC, Location location)
        {
            List<MapLegendData> data = new List<MapLegendData>();
            data.Add(new MapLegendData(d1 + "% (0 - 18)", new SolidColorBrush(Color.FromArgb(0xFF, 0x8E, 0xBC, 0x00))));
            data.Add(new MapLegendData(d2 + "% (18 - 65)", new SolidColorBrush(Color.FromArgb(0xFF, 0x25, 0xA0, 0xDA))));
            data.Add(new MapLegendData(d3 + "% (65+)", new SolidColorBrush(Color.FromArgb(0xFF, 0xEB, 0x7A, 0x2A))));

            headeredIC.ItemTemplate = this.Resources["CustomDataTemplate"] as DataTemplate;
            headeredIC.Padding = new Thickness(0, 10, 0, 0);
            headeredIC.ItemsSource = data;
            headeredIC.SetValue(MapLayer.LocationProperty, location);
           
            this.VisualizationLayer.Items.Add(headeredIC);
        }
        private void InitializeChart(RadPieChart chart, Location location)
        {
            this.SetChartDimensions(chart);

            randoms = new double[] { rand.Next(10000, 50000), rand.Next(10000, 50000), rand.Next(10000, 50000) };
            double sum = randoms[0] + randoms[1] + randoms[2];

            PieSeries series = new PieSeries() { ShowLabels = false };
            series.ItemsSource = new double[] { randoms[0], randoms[1], randoms[2] };
            chart.Series.Add(series);
            chart.Palette = ChartPalettes.Windows8;

            chart.SetValue(MapLayer.LocationProperty, location);
            this.VisualizationLayer.Items.Add(chart);

            HeaderedItemsControl legend = new HeaderedItemsControl();

            this.InitializeMapLegend((int)((randoms[0] * 100) / sum), (int)((randoms[1] * 100) / sum), (int)((randoms[2] * 100) / sum), legend, legendLocations[i++]);
        }        
        public void PopulateToolPanelFromXml(XElement rootElement)
        {
            try
            {
                if (rootElement.HasAttributes)
                {
                    XAttribute att = rootElement.Attribute(Constants.TOOLPANEL_ORIENTATION);
                    if (att != null && string.Compare(att.Value, Orientation.Vertical.ToString(), StringComparison.InvariantCultureIgnoreCase) == 0)
                        this.Orientation = Orientation.Vertical;

                    att = rootElement.Attribute(Constants.TOOLPANEL_CONTAINER_NAME);
                    if (att != null)
                        this.ContainerName = att.Value;

                    att = rootElement.Attribute(Constants.TOOLPANEL_NAME);
                    if (att != null)
                        this.Name = att.Value;
                    this.isPopupToolPanel = this.ContainerName.ToLower().StartsWith("popup", StringComparison.Ordinal);
                }
                if (rootElement.HasElements)
                {
                    XElement tools = rootElement.Element(Constants.TOOLS);
                    if (tools != null && tools.HasElements)
                    {
                        foreach (XElement childNode in tools.Elements())
                        {
                            if (Constants.SEPARATOR.Equals(childNode.Name.LocalName, StringComparison.InvariantCultureIgnoreCase))
                            {
                                this.AddToolPanelSeparatorElement(this.ToolPanelItems, true);
                            }
                            else if (Constants.GROUP.Equals(childNode.Name.LocalName, StringComparison.InvariantCultureIgnoreCase))
                            {

                                ButtonDisplayInfo displayInfo = getButtonDisplayInfoForXmlNode(childNode);
                                HeaderedItemsControl toolContainer = new HeaderedItemsControl()
                                {
                                    Header = displayInfo,
                                    DataContext = displayInfo,
                                    Style = ToolPanelLayoutStyleHelper.Instance.GetStyle("GroupContainerStyle"),
                                };
                                this.ToolPanelItems.Add(toolContainer);

                                if (childNode.HasElements)
                                {
                                    ObservableCollection<FrameworkElement> toolItems = new ObservableCollection<FrameworkElement>();
                                    foreach (XElement element in childNode.Elements())
                                    {
                                        if (Constants.MENU.Equals(element.Name.LocalName, StringComparison.InvariantCultureIgnoreCase))
                                        {
                                            this.parseMenu(element, toolItems);
                                        }
                                        else if (Constants.TOOL.Equals(element.Name.LocalName, StringComparison.InvariantCultureIgnoreCase))
                                        {
                                            string path = !string.IsNullOrEmpty(this.Name) ? this.Name : "";
                                            if (!string.IsNullOrEmpty(displayInfo.Label))
                                                path = path + "->" + displayInfo.Label;
                                            this.parseTool(element, toolItems, path);
                                        }
                                        else if (Constants.SEPARATOR.Equals(element.Name.LocalName, StringComparison.InvariantCultureIgnoreCase))
                                        {
                                            this.AddToolPanelSeparatorElement(toolItems, true);
                                        }
                                    }
                                    toolContainer.ItemsSource = toolItems;
                                }
                            }
                            else if (Constants.MENU.Equals(childNode.Name.LocalName, StringComparison.InvariantCultureIgnoreCase))
                            {
                                this.parseMenu(childNode, this.ToolPanelItems);
                            }
                            else if (Constants.TOOL.Equals(childNode.Name.LocalName, StringComparison.InvariantCultureIgnoreCase))
                            {
                                this.parseTool(childNode, this.ToolPanelItems, !string.IsNullOrEmpty(this.Name) ? this.Name : "");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.LogError(ex);
            }
        }
        /// <summary>
        /// Prepare a PrepareHeaderedItemsControlContainer container for an
        /// item.
        /// </summary>
        /// <param name="control">Container to prepare.</param>
        /// <param name="item">Item to be placed in the container.</param>
        /// <param name="parentItemsControl">The parent ItemsControl.</param>
        /// <param name="parentItemContainerStyle">
        /// The ItemContainerStyle for the parent ItemsControl.
        /// </param>
        private static void PrepareHeaderedItemsControlContainer(HeaderedItemsControl control, object item, ItemsControl parentItemsControl, Style parentItemContainerStyle)
        {
            if (control != item)
            {
                // Copy the ItemsControl properties from parent to child
                DataTemplate parentItemTemplate = parentItemsControl.ItemTemplate;
                if (parentItemTemplate != null)
                {
                    control.SetValue(HeaderedItemsControl.ItemTemplateProperty, parentItemTemplate);
                }
                if (parentItemContainerStyle != null && HasDefaultValue(control, HeaderedItemsControl.ItemContainerStyleProperty))
                {
                    control.SetValue(HeaderedItemsControl.ItemContainerStyleProperty, parentItemContainerStyle);
                }

                // Copy the Header properties from parent to child
                if (control.HeaderIsItem || HasDefaultValue(control, HeaderedItemsControl.HeaderProperty))
                {
                    control.Header = item;
                    control.HeaderIsItem = true;
                }
                if (parentItemTemplate != null)
                {
                    control.SetValue(HeaderedItemsControl.HeaderTemplateProperty, parentItemTemplate);
                }
                if (parentItemContainerStyle != null && control.Style == null)
                {
                    control.SetValue(HeaderedItemsControl.StyleProperty, parentItemContainerStyle);
                }

                // Note: this is where we would apply the HeaderTemplateSelector
                // (if implemented) or attempt to lookup the implicit template
                // for the type of the item if the headerTemplate were null.

                // Setup a hierarchical template
                HierarchicalDataTemplate headerTemplate = parentItemTemplate as HierarchicalDataTemplate;
                if (headerTemplate != null)
                {
                    if (headerTemplate.ItemsSource != null && HasDefaultValue(control, HeaderedItemsControl.ItemsSourceProperty))
                    {
                        control.SetBinding(
                            HeaderedItemsControl.ItemsSourceProperty,
                            new Binding
                            {
                                Converter = headerTemplate.ItemsSource.Converter,
                                ConverterCulture = headerTemplate.ItemsSource.ConverterCulture,
                                ConverterParameter = headerTemplate.ItemsSource.ConverterParameter,
                                Mode = headerTemplate.ItemsSource.Mode,
                                NotifyOnValidationError = headerTemplate.ItemsSource.NotifyOnValidationError,
                                Path = headerTemplate.ItemsSource.Path,
                                Source = control.Header,
                                ValidatesOnExceptions = headerTemplate.ItemsSource.ValidatesOnExceptions
                            });
                    }
                    if (headerTemplate.IsItemTemplateSet && control.ItemTemplate == parentItemTemplate)
                    {
                        control.ClearValue(HeaderedItemsControl.ItemTemplateProperty);
                        if (headerTemplate.ItemTemplate != null)
                        {
                            control.ItemTemplate = headerTemplate.ItemTemplate;
                        }
                    }
                    if (headerTemplate.IsItemContainerStyleSet && control.ItemContainerStyle == parentItemContainerStyle)
                    {
                        control.ClearValue(HeaderedItemsControl.ItemContainerStyleProperty);
                        if (headerTemplate.ItemContainerStyle != null)
                        {
                            control.ItemContainerStyle = headerTemplate.ItemContainerStyle;
                        }
                    }
                }
            }
        }
        private static void translateHeader(HeaderedItemsControl control) {
            if (control.Header == null) {
                control.Header = Strings.getInterfaceString(null)[StringType.Label].interpret();
                return;
            }
            string string_title = control.Header.ToString();

            TranslateableString str = Strings.getInterfaceString(string_title)[StringType.Label];
            if (control is RibbonTab) {
                RibbonTab tab = control as RibbonTab;
                if (str.HasHotKey) {
                    tab.KeyTip = str.HotKey;
                }
            }
            control.Header = str.interpret();
        }
Beispiel #8
0
        /// <summary>
        ///     Called when HeaderStringFormatProperty is invalidated on "d."
        /// </summary>
        private static void OnHeaderStringFormatChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            HeaderedItemsControl ctrl = (HeaderedItemsControl)d;

            ctrl.OnHeaderStringFormatChanged((String)e.OldValue, (String)e.NewValue);
        }
Beispiel #9
0
        /// <summary>
        ///     Called when HeaderTemplateSelectorProperty is invalidated on "d."
        /// </summary>
        private static void OnHeaderTemplateSelectorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            HeaderedItemsControl ctrl = (HeaderedItemsControl)d;

            ctrl.OnHeaderTemplateSelectorChanged((DataTemplateSelector)e.OldValue, (DataTemplateSelector)e.NewValue);
        }
        internal HeaderedItemsModelTreeEnumerator(HeaderedItemsControl headeredItemsControl, IEnumerator items, object header) : base(header) 
        {
            Debug.Assert(headeredItemsControl != null, "headeredItemsControl should be non-null."); 
            Debug.Assert(items != null, "items should be non-null."); 
            Debug.Assert(header != null, "header should be non-null. If Header was null, the base ItemsControl enumerator should have been used.");
 
            _owner = headeredItemsControl;
            _items = items;
        }