public void ValidateCode(object sender, RoutedEventArgs e)
        {
            object context             = Utils.GetDataContext(sender);
            IEnumerable <XmlNode> data = Utils.GetXmlDataContext(context);

            if (null != data)
            {
                foreach (XmlNode node in data)
                {
                    XmlNode attr = node.SelectSingleNode("languageCode/@value");
                    if (null != attr)
                    {
                        string code = attr.Value;
                        if (2 == code.Length)
                        {
                            string threeLetter = LanguageConverter.GetThreeLetterCode(code);
                            if (null != threeLetter)
                            {
                                attr.Value = threeLetter;
                                MetadataEditorControl.UpdateDataContext(this as DependencyObject);
                            }
                        }
                    }
                    break; // just one
                }
            }
        }
        public void ShowControl_NoLicense()
        {
            var m = new Metadata();

            m.CopyrightNotice = "copyright me";
            m.Creator         = "you";
            m.AttributionUrl  = "http://google.com";
            m.License         = new NullLicense();
            var c = new MetadataEditorControl();

            c.Metadata = m;
            var dlg = new Form();

            dlg.Height = c.Height;
            dlg.Width  = c.Width + 20;
            c.Dock     = DockStyle.Fill;
            dlg.Controls.Add(c);
            dlg.ShowDialog();
        }
예제 #3
0
        /// <summary>
        /// handle the tooltip opening
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UpdateStatusOpenTip(object sender, ToolTipEventArgs e)
        {
            e.Handled = true;

            if (e.Source is FrameworkElement)
            {
                FrameworkElement fe      = e.Source as FrameworkElement;
                string           tooltip = fe.ToolTip as string;

                // do nothing if null
                if (null == tooltip)
                {
                    return;
                }

                MetadataEditorControl me = Utils.GetMetadataEditorControl(fe);
                me.UpdateStatus(tooltip);
            }
        }
        public void ShowControl()
        {
            var m = new Metadata();

            m.CopyrightNotice = "copyright me";
            m.Creator         = "you";
            m.AttributionUrl  = "http://google.com";
            m.License         = new CreativeCommonsLicense(true, false, CreativeCommonsLicense.DerivativeRules.DerivativesWithShareAndShareAlike);
            var c = new MetadataEditorControl();

            c.Metadata = m;
            var dlg = new Form();

            dlg.Height = c.Height;
            dlg.Width  = c.Width + 20;
            c.Dock     = DockStyle.Fill;
            dlg.Controls.Add(c);
            dlg.ShowDialog();
        }