Пример #1
0
        private static void mnuKeyTable_Click(object sender, EventArgs e)
        {
            // Generate the list of key shortcuts in HTML
            string filename = FileDialog.ShowSave(FileDialog.Context.OtherTechnical, "*.html|*.html");

            if (string.IsNullOrEmpty(filename))
            {
                return;
            }
            System.Text.StringBuilder output = new System.Text.StringBuilder();
            output.AppendLine("<HTML>").AppendLine("<HEAD></HEAD><BODY><TABLE>");
            output.AppendLine("<tr><th>Key</th><th>-</th><th>+Shift</th><th>+Control</th><th>+Shift+Control</th></tr>");
            Keys previousKey = Keys.None;             // some keys seem to get reported more than once; filter this out

            foreach (Keys key in Enum.GetValues(typeof(Keys)))
            {
                // hopefully they will come out in some sort of sensible order
                if (key != previousKey)
                {
                    string line = GenerateKeyLine(key);
                    if (!string.IsNullOrEmpty(line))
                    {
                        output.Append(line);
                    }
                    line = GenerateKeyLine(key | Keys.Alt);
                    if (!string.IsNullOrEmpty(line))
                    {
                        output.Append(line);
                    }
                }
                previousKey = key;
            }
            output.AppendLine("</TABLE></BODY></HTML>");
            System.IO.StreamWriter fs = new System.IO.StreamWriter(filename, false);
            fs.Write(output.ToString());
            fs.Close();
            // I wanted to put it on the clipboard, but it turns out that HTML on the clipboard is complicated (and largely undocumented)
            MessageBox.Show("Saved");
        }
Пример #2
0
        public void btnAddImage_Click(object sender, EventArgs e)
        {
            string filename = FileDialog.ShowOpen(FileDialog.Context.Image);

            if (string.IsNullOrEmpty(filename))
            {
                return;
            }
            try
            {
                if (m_Style.CustomImage[(int)State] == null)
                {
                    m_Style.CustomImage[(int)State] = new ScalableImage();
                }
                Img.AddImageFromDisc(filename);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
            m_ImageIndex = Img.Images.Count - 1;
            DisplayImageIndex();
        }
Пример #3
0
        public void lnkBackgroundImage_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            // Alternate filter used; non-bitmaps may not work (especially if tiling)
            string filename = FileDialog.ShowOpen(FileDialog.Context.Image, "[Filter_Image1]");

            if (string.IsNullOrEmpty(filename))
            {
                return;
            }
            m_Page.BackgroundImage = (SharedImage)Globals.Root.CurrentDocument.AddSharedResourceFromFile(filename, m_Transaction);
            if (m_Page.BackgroundImage != null)                       // just in case
            {
                SizeF imageSize = m_Page.BackgroundImage.GetSize(64); // small size provided here means a resource (!?!) doesn't trigger
                if (imageSize.Width > 100 && imageSize.Height > 100 && Globals.Root.CurrentDocument.Count == 1)
                {
                    // This is only done if the document has a single page.
                    if (GUIUtilities.QuestionBox(Strings.Item("Paper_MatchImageSize"), MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        SetSizeToMatchImage();
                    }
                }
            }
            ReflectPaper();
        }