コード例 #1
0
        public static void ExportView(ViewBase view)
        {
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }

            string fileName = ViewImportExportManager.AskForExportFileName();

            if (fileName.Length > 0)
            {
                ViewImportExportManager.ExportViewToXaml(view, fileName);
            }
        }
コード例 #2
0
        public static void ImportView(ViewBase view)
        {
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }

            ResourceDictionary resourceDictionary = ViewImportExportManager.AskForResourceDictionary();

            if (resourceDictionary != null)
            {
                ViewImportExportManager.ImportViewFromResourceDictionary(view, resourceDictionary);
            }
        }
コード例 #3
0
        // In a typical application, this way of applying a style would be undesirable. The
        // style would rather simply be added to a ResourceDictionary as implicit.
        // Here, we want to set all CardflowView3D properties so that the ConfigurationPanel
        // reflects them.
        public static void ImportViewFromStyle(ViewBase view, Style viewStyle)
        {
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }

            // Remove the local values on the CardflowView3D so that the newly selected preset
            // is applied in its entirety. The properties set in a style have a priority less
            // than a local value (set by the various sliders and checkboxes).
            ViewImportExportManager.ClearViewPropertyValues(view);

            if (viewStyle != null)
            {
                foreach (Setter setter in viewStyle.Setters)
                {
                    view.SetValue(setter.Property, setter.Value);
                }
            }
        }
コード例 #4
0
        public static void ImportViewFromResourceDictionary(ViewBase view, ResourceDictionary resourceDictionary)
        {
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }

            if (resourceDictionary == null)
            {
                throw new ArgumentNullException("resourceDictionary");
            }

            Type viewType = view.GetType();

            // Try extracting a implicit style for the specified view from the ResourceDictionary.
            Style viewStyle = resourceDictionary[viewType] as Style;

            if (viewStyle == null)
            {
                // There is no implicit style for the specified view in the ResourceDictionary.
                // Use the first Style having the view type as TargetType.
                Style tempStyle;

                foreach (object value in resourceDictionary.Values)
                {
                    tempStyle = value as Style;

                    if ((tempStyle != null) && (tempStyle.TargetType == viewType))
                    {
                        viewStyle = tempStyle;
                        break;
                    }
                }
            }

            ViewImportExportManager.ImportViewFromStyle(view, viewStyle);
        }