Example #1
0
        /// <summary>
        /// Parses the background colors of the status labels defined in the examples XML file.
        /// </summary>
        /// <param name="styleElement"></param>
        private void ParseStatusColors(NXmlElement styleElement)
        {
            m_StatusColorMap = new NMap <string, NColor>();
            if (styleElement == null)
            {
                return;
            }

            for (int i = 0, count = styleElement.ChildrenCount; i < count; i++)
            {
                NXmlElement child = styleElement.GetChildAt(i) as NXmlElement;
                if (child == null || child.Name != "status")
                {
                    continue;
                }

                // Get the status name
                string name = child.GetAttributeValue("name");
                if (name == null)
                {
                    continue;
                }

                // Parse the status color
                string colorStr = child.GetAttributeValue("color");
                NColor color;
                if (NColor.TryParse(colorStr, out color) == false)
                {
                    continue;
                }

                // Add the name/color pair to the status color map
                m_StatusColorMap.Set(name, color);
            }
        }
        protected override NWidget CreateExampleContent()
        {
            m_TreeView = new NTreeView();
            m_TreeView.SelectedPathChanged += OnTreeViewSelectedPathChanged;

            m_ResourcesMap = new NMap <NTreeViewItem, NEmbeddedResourceContainer>();
            m_TreeView.Items.Add(CreateRootItem(Nevron.Nov.Presentation.NResources.Instance));
            m_TreeView.Items.Add(CreateRootItem(Nevron.Nov.Diagram.NResources.Instance));
            m_TreeView.Items.Add(CreateRootItem(Nevron.Nov.Text.NResources.Instance));
            m_TreeView.Items.Add(CreateRootItem(Nevron.Nov.Schedule.NResources.Instance));
            m_TreeView.Items.Add(CreateRootItem(Nevron.Nov.Grid.NResources.Instance));

            // Create a data table
            m_DataTable = new NMemoryDataTable();
            m_DataTable.AddField(new NFieldInfo("Image", typeof(NImage)));
            m_DataTable.AddField(new NFieldInfo("Name", typeof(string)));
            m_DataTable.AddField(new NFieldInfo("Size", typeof(string)));
            m_DataTable.AddField(new NFieldInfo("Action", typeof(string)));

            // Create a grid view
            m_GridView = new NTableGridView();
            m_GridView.GroupingPanel.Visibility = ENVisibility.Collapsed;
            m_GridView.ReadOnly = true;

            NTableGrid tableGrid = m_GridView.Grid;

            tableGrid.AlternatingRows    = false;
            tableGrid.RowHeaders.Visible = false;
            tableGrid.AutoCreateColumn  += OnGridAutoCreateColumn;
            tableGrid.DataSource         = new NDataSource(m_DataTable);

            NSplitter splitter = new NSplitter(m_TreeView, m_GridView, ENSplitterSplitMode.OffsetFromNearSide, 200);

            return(splitter);
        }
Example #3
0
        /// <summary>
        /// Creates the product groups stack panel.
        /// </summary>
        /// <param name="root"></param>
        /// <returns></returns>
        private NStackPanel CreateProductGroupsStack(NXmlElement root)
        {
            NMap <string, NStackPanel> stackMap = new NMap <string, NStackPanel>();

            // Create the main stack
            NStackPanel mainStack = new NStackPanel();

            mainStack.Direction = ENHVDirection.LeftToRight;
            mainStack.Margins   = new NMargins(0, LaneSpacing * 2);

            // Create a stack panel for each license groups and add it to the main stack
            int count = root.ChildrenCount;

            for (int i = 0; i < count; i++)
            {
                NXmlElement categoryElement = root.GetChildAt(i) as NXmlElement;
                if (categoryElement == null)
                {
                    continue;
                }

                string license = categoryElement.GetAttributeValue("license");

                NStackPanel licenseGroupStack;
                if (!stackMap.TryGet(license, out licenseGroupStack))
                {
                    // A stack panel for the license group not found, so create one
                    licenseGroupStack = CreateProductGroupStack();
                    stackMap.Add(license, licenseGroupStack);

                    // Create a stack for the current group and its name
                    NStackPanel stack = new NStackPanel();
                    stack.Direction = ENHVDirection.TopToBottom;

                    // 1. Add the license group stack
                    stack.Add(licenseGroupStack);

                    // 2. Add the bracket
                    NColor  color   = NColor.Parse(categoryElement.GetAttributeValue("color"));
                    NWidget bracket = CreateLicenseGroupBracket(color);
                    stack.Add(bracket);

                    // 3. Add the label
                    NLabel label = new NLabel(license);
                    label.HorizontalPlacement = ENHorizontalPlacement.Center;
                    label.TextFill            = new NColorFill(color);
                    label.Font = new NFont(NFontDescriptor.DefaultSansFamilyName, InfoFontSize);
                    stack.Add(label);

                    mainStack.Add(stack);
                }

                // Create an image box for the current category
                NImageBox imageBox = CreateImageBox(categoryElement);
                licenseGroupStack.Add(imageBox);
            }

            return(mainStack);
        }
        internal static string GetImageDescription(NMap <string, string> descriptions, string resourceName)
        {
            string desc;

            if (descriptions.TryGet(ResourceNameToFileName(resourceName), out desc))
            {
                return(desc);
            }

            return(string.Empty);
        }
        internal static NMap <string, string> LoadDescriptions(string descriptionTextFileContent)
        {
            NMap <string, string> descriptions = new NMap <string, string>();

            using (StringReader reader = new StringReader(descriptionTextFileContent))
            {
                string line;

                while ((line = reader.ReadLine()) != null)
                {
                    int dashIndex = line.IndexOf("-", 0);
                    if (dashIndex > 0)
                    {
                        string name        = line.Remove(dashIndex).Trim();
                        string description = line.Remove(0, dashIndex + 1).Trim();
                        descriptions.Add(name, description);
                    }
                }
            }

            return(descriptions);
        }
Example #6
0
 public NElementInfo(string name)
 {
     Name       = name;
     Attributes = new NMap <string, string>();
 }
        protected override NWidget CreateExampleContent()
        {
            string[] colHeadings = new string[]
            {
                "Image",
                "Description",
                "Decoded with NOV Decoders",
                "Decoded with Native Decoders"
            };

            int colCount = colHeadings.Length;

            NTableFlowPanel table = new NTableFlowPanel();

            table.HorizontalPlacement = ENHorizontalPlacement.Left;
            table.VerticalPlacement   = ENVerticalPlacement.Top;
            table.Padding             = new NMargins(30);
            table.HorizontalSpacing   = 30;
            table.VerticalSpacing     = 30;
            table.MaxOrdinal          = colCount;

            NList <string>        imageNames   = NImageDecodingExampleHelper.GetImageNames("JpegSuite", "jpg");
            NMap <string, string> descriptions = NImageDecodingExampleHelper.LoadDescriptions(NResources.String_JpegSuite_txt);

            for (int i = 0; i < colCount; i++)
            {
                NLabel label = new NLabel(colHeadings[i]);
                label.Font = new NFont(NFontDescriptor.DefaultSansFamilyName, 9, ENFontStyle.Bold);
                table.Add(label);
            }

            int rowCount = imageNames.Count;

            for (int i = 0; i < rowCount; i++)
            {
                string resourceName = imageNames[i];
                string description  = NImageDecodingExampleHelper.GetImageDescription(descriptions, resourceName);

                NLabel nameLabel = new NLabel(resourceName);
                nameLabel.MaxWidth = 200;

                NLabel descriptionLabel = new NLabel(description);
                descriptionLabel.MaxWidth     = 200;
                descriptionLabel.TextWrapMode = ENTextWrapMode.WordWrap;

                NImage    novImage    = NImageDecodingExampleHelper.LoadImage(resourceName, ENCodecPreference.OnlyNOV);
                NImageBox novImageBox = new NImageBox(novImage);
                novImageBox.ImageMapping = new NAlignTextureMapping(ENHorizontalAlignment.Center, ENVerticalAlignment.Center);

                NImage    nativeImage    = NImageDecodingExampleHelper.LoadImage(resourceName, ENCodecPreference.PreferNative);
                NImageBox nativeImageBox = new NImageBox(nativeImage);
                nativeImageBox.ImageMapping = new NAlignTextureMapping(ENHorizontalAlignment.Center, ENVerticalAlignment.Center);

                table.Add(nameLabel);
                table.Add(descriptionLabel);
                table.Add(novImageBox);
                table.Add(nativeImageBox);
            }

            // The table must be scrollable
            NScrollContent scroll = new NScrollContent();

            scroll.Content = table;
            return(scroll);
        }
Example #8
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 public NEmfDecompressor()
 {
     m_ImageMap = new NMap <string, byte[]>();
 }