示例#1
0
        private void ChangeFont()
        {
            fontDialog.Font = textBoxCopiesDone.Font ;
            fontDialog.Color = textBoxCopiesDone.ForeColor ;

            DialogResult res = fontDialog.ShowDialog(this) ;
            if(res == DialogResult.OK){
                textBoxCopiesFailed.Font = fontDialog.Font ;
                textBoxCopiesDone.Font = fontDialog.Font ;
                textBoxDeletionsDone.Font = fontDialog.Font ;
                textBoxDeletionsFailed.Font = fontDialog.Font ;

                //use FontConverter to 'serialize' the current Font object into string
                FontConverter fontCon = new FontConverter() ;
                properties[REG_LOGS_FONT] = fontCon.ConvertToString(fontDialog.Font) ;

                textBoxCopiesDone.ForeColor = fontDialog.Color ;
                textBoxCopiesFailed.ForeColor = fontDialog.Color ;
                textBoxDeletionsDone.ForeColor = fontDialog.Color ;
                textBoxDeletionsFailed.ForeColor = fontDialog.Color ;

                //use ColorConverter to 'serialize' the current Color object into string
                ColorConverter colorCon = new ColorConverter() ;
                properties[REG_LOGS_FORE_COLOR] = colorCon.ConvertToString(fontDialog.Color) ;
            }
        }
示例#2
0
        public override void deserializeFromXml( XmlNode element )
        {
            if (element.ChildNodes.Count < 1)
                return;

            XmlElement e = element.ChildNodes[0] as XmlElement;
            if (e == null)
            {
                return;
            }

            _text = e.InnerText;

            FontConverter fontConverter = new FontConverter();
            ColorConverter colorConverter = new ColorConverter();

            if (e.HasAttribute("Color")) {
                //_color = (Color)colorConverter.ConvertFromString(e.Attributes["Color"].Value);
                _color  = (Color)colorConverter.ConvertFromString(null, System.Globalization.CultureInfo.InvariantCulture, e.Attributes["Color"].Value);
            }

            if (e.HasAttribute("Background") ) {
                _background = (Color)colorConverter.ConvertFromString(null,System.Globalization.CultureInfo.InvariantCulture, e.Attributes["Background"].Value);
            }

            if (e.HasAttribute("Font")) {
                _font = fontConverter.ConvertFromString(null, System.Globalization.CultureInfo.InvariantCulture, e.Attributes["Font"].Value ) as Font;
            } else {
                _font = SystemFonts.DefaultFont;
            }

            if ( e.HasAttribute("Alignment"))
                _alignment =  StringToAlignment(e.Attributes["Alignment"].Value);
        }
示例#3
0
		public void Deserialize(XmlNode node)
		{
			var converter = new FontConverter();
			foreach (XmlNode childNode in node.ChildNodes)
			{
				switch (childNode.Name)
				{
					case "Identifier":
						Guid tempGuid;
						if (Guid.TryParse(childNode.InnerText, out tempGuid))
							Identifier = tempGuid;
						break;
					case "Font":
						try
						{
							Font = (Font)converter.ConvertFromString(childNode.InnerText);
						}
						catch { }
						break;
					case "ForeColor":
						int tempInt;
						if (int.TryParse(childNode.InnerText, out tempInt))
							_foreColor = Color.FromArgb(tempInt);
						break;
					case "Note":
						_note = childNode.InnerText;
						break;
				}
			}
		}
示例#4
0
		public virtual FormButtons Show
			(
			FontConverter aFontPlusEC,
			string strInput,
			string strOutput
			)
		{
			m_aFontPlusEC = aFontPlusEC;

			if (m_aFontPlusEC.Font != null)
				this.textBoxInput.Font = m_aFontPlusEC.Font;

			if (m_aFontPlusEC.RhsFont != null)
				this.textBoxConverted.Font = m_aFontPlusEC.RhsFont;

			InputString = strInput;
			ForwardString = strOutput;

			UpdateLhsUniCodes(InputString, this.labelInputCodePoints);
			UpdateRhsUniCodes(ForwardString, this.labelForwardCodePoints);

			// get some info to show in the title bar
			this.Text = String.Format("{0}: {1}", Connect.cstrCaption, m_aFontPlusEC.ToString());

			ShowDialog();

			return ButtonPressed;
		}
示例#5
0
 public MainForm()
 {
     InitializeComponent();
     rightSplitContainer.SplitterWidth = 12;
     var fc = new FontConverter();
     tbInfo.Font = fc.ConvertFromInvariantString(Settings.Default.InfoFont) as Font;
     _visualiser = new Visualiser(Settings.Default.VisualisationCellSize);
 }
示例#6
0
        public void ConvertFile()
        {
//			return;
            var dds = System.IO.Directory.GetDirectories(@"C:\Users\0115289\Documents\SharpDevelop Projects\SpoonSystem\TemplatePrint\bin\Debug\templates");

            foreach (var ds in dds)
            {
                foreach (var f in System.IO.Directory.GetFiles(ds, "*.xml"))
                {
//					System.Diagnostics.Debug.WriteLine(f);
                    if (System.IO.Path.GetExtension(f) != ".xml")
                    {
                        continue;
                    }
                    var olddoc = new System.Xml.XmlDocument();

                    olddoc.Load(f);

                    var     doc    = Helper.XmlHelper.NewDocment();
                    wCanvas canvas = new wCanvas();
                    canvas.Author = "Elder Yao";

                    var size = olddoc.SelectSingleNode("/layout/size");
                    canvas.Size = new System.Drawing.Size(int.Parse(size.Attributes["width"].Value), int.Parse(size.Attributes["height"].Value));

                    var background = olddoc.SelectSingleNode("/layout/background");
                    canvas.BackgroundPath = @"C:\Users\0115289\Documents\SharpDevelop Projects\SpoonSystem\TemplatePrint\bin\Debug\" + background.Attributes["path"].Value;
                    var ss = float.Parse(background.Attributes["scale"].Value);
                    canvas.BackgroundRect = new Rectangle(0, 0, (int)(canvas.BackgroundImage.Width * ss), (int)(canvas.BackgroundImage.Height * ss));

                    foreach (System.Xml.XmlNode item in olddoc.SelectSingleNode("/layout/items").ChildNodes)
                    {
                        var lbl = new Controls.wLabel();
                        lbl.ShowBorder = false;
                        lbl.Name       = item.Attributes["name"].Value;
                        lbl.Text       = item.Attributes["value"].Value;
                        lbl.Rectangle  = new System.Drawing.Rectangle(
                            int.Parse(item.Attributes["left"].Value),
                            int.Parse(item.Attributes["top"].Value),
                            int.Parse(item.Attributes["width"].Value),
                            int.Parse(item.Attributes["height"].Value)
                            );
                        var fc = new System.Drawing.FontConverter();
                        lbl.Font = fc.ConvertFromString(item.Attributes["font"].Value) as System.Drawing.Font;

//						lbl.ShowBorder = true;
                        canvas.Controls.Add(lbl);
                    }

                    doc.AppendChild(canvas.ToXml(doc));
//					doc.Save(f + "x");

                    Helper.UnitHelper.ArchiveFiles(doc, f.Replace(".xml", ".bg"));
                }
            }
            System.Diagnostics.Debug.WriteLine("OK");
        }
 public ToolBarComboBox(Codon codon, object caller)
 {
     this.RightToLeft = RightToLeft.Inherit;
     base.ComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
     base.ComboBox.SelectedIndexChanged += new EventHandler(this.selectionChanged);
     base.ComboBox.KeyDown += new KeyEventHandler(this.ComboBoxKeyDown);
     this.caller = caller;
     this.codon = codon;
     if (codon.Properties.Contains("width"))
     {
         this.Size = new Size(Convert.ToInt32(codon.Properties["width"]), base.Height);
     }
     if (codon.Properties.Contains("dropdownwidth"))
     {
         base.DropDownWidth = Convert.ToInt32(codon.Properties["dropdownwidth"]);
     }
     if (codon.Properties.Contains("font"))
     {
         string str = codon.Properties["font"];
         FontConverter converter = new FontConverter();
         try
         {
             this.Font = (Font) converter.ConvertFrom(str);
         }
         catch (Exception exception)
         {
             LoggingService.Warn(exception);
         }
     }
     this.CreateCommand(codon);
     if (base.ComboBox.Items.Count > 0)
     {
         if (codon.Properties.Contains("selectindex"))
         {
             try
             {
                 base.ComboBox.SelectedIndex = Convert.ToInt32(codon.Properties["selectindex"]);
             }
             catch (Exception exception2)
             {
                 LoggingService.Warn(exception2);
             }
         }
         else
         {
             base.ComboBox.SelectedIndex = 0;
         }
     }
     if (this.menuCommand == null)
     {
         throw new NullReferenceException("Can't create combobox menu command");
     }
     this.UpdateText();
     this.UpdateStatus();
 }
示例#8
0
        void IXmlSerializable.ReadXml(XmlReader reader)
        {
            if (reader.IsEmptyElement) { return; }

            FontConverter fconv = new FontConverter();
            if (reader.NodeType != System.Xml.XmlNodeType.EndElement) {
                this._font = (Font)fconv.ConvertFromString(reader.ReadString());
            }
            reader.MoveToContent();
            reader.ReadEndElement();
        }
		public virtual FormButtons Show
			(
			FontConverter aFontPlusEC,
			string strInput,
			string strOutput,
			string strRoundtrip
			)
		{
			m_aFontPlusEC = aFontPlusEC;
			RoundTripString = strRoundtrip;

			if (m_aFontPlusEC.Font != null)
				this.textBoxRoundTrip.Font = m_aFontPlusEC.Font;

			UpdateLhsUniCodes(RoundTripString, this.labelRoundTripCodePoints);

			return base.Show(aFontPlusEC, strInput, strOutput);
		}
示例#10
0
        public void Convert()
        {
            var olddoc = new System.Xml.XmlDocument();

            olddoc.Load(@"C:\Users\0115289\Documents\SharpDevelop Projects\SpoonSystem\TemplatePrint\bin\Debug\templates\1. 顺丰\sf.xml");

            var     doc    = Helper.XmlHelper.NewDocment();
            wCanvas canvas = new wCanvas();

            canvas.Author = "Elder Yao";

            var size = olddoc.SelectSingleNode("/layout/size");

            canvas.Size = new System.Drawing.Size(int.Parse(size.Attributes["width"].Value), int.Parse(size.Attributes["height"].Value));

            var background = olddoc.SelectSingleNode("/layout/background");

            canvas.BackgroundPath  = background.Attributes["path"].Value;
            canvas.BackgroundScale = float.Parse(background.Attributes["scale"].Value);

            foreach (System.Xml.XmlNode item in olddoc.SelectSingleNode("/layout/items").ChildNodes)
            {
                var lbl = new Controls.wLabel();
                lbl.Name      = item.Attributes["name"].Value;
                lbl.Text      = item.Attributes["value"].Value;
                lbl.Rectangle = new System.Drawing.Rectangle(
                    int.Parse(item.Attributes["left"].Value),
                    int.Parse(item.Attributes["top"].Value),
                    int.Parse(item.Attributes["width"].Value),
                    int.Parse(item.Attributes["height"].Value)
                    );
                var fc = new System.Drawing.FontConverter();
                lbl.Font = fc.ConvertFromString(item.Attributes["font"].Value) as System.Drawing.Font;

                lbl.ShowBorder = false;
                canvas.Controls.Add(lbl);
            }

            doc.AppendChild(canvas.ToXml(doc));
            doc.Save(@"C:\Users\0115289\Documents\SharpDevelop Projects\SpoonSystem\TemplatePrint\bin\Debug\templates\1. 顺丰\sf.xmlx");
        }
示例#11
0
 public static void SetValue(string key, string value)
 {
     try
     {
         var type = Default[key].GetType()
                                .Name;
         switch (type)
         {
             case "Boolean":
                 Default[key] = Convert.ToBoolean(value);
                 break;
             case "Color":
                 var cc = new ColorConverter();
                 var color = cc.ConvertFrom(value);
                 Default[key] = color ?? Colors.Black;
                 break;
             case "Double":
                 Default[key] = Convert.ToDouble(value);
                 break;
             case "Font":
                 var fc = new FontConverter();
                 var font = fc.ConvertFromString(value);
                 Default[key] = font ?? new Font(new FontFamily("Microsoft Sans Serif"), 12);
                 break;
             default:
                 Default[key] = value;
                 break;
         }
     }
     catch (SettingsPropertyNotFoundException ex)
     {
         Logging.Log(LogManager.GetCurrentClassLogger(), "", ex);
     }
     catch (SettingsPropertyWrongTypeException ex)
     {
         Logging.Log(LogManager.GetCurrentClassLogger(), "", ex);
     }
 }
 public void SetValue(string key, string value, CultureInfo cultureInfo)
 {
     try
     {
         var type = Default[key].GetType()
                                .Name;
         switch (type)
         {
             case "Boolean":
                 Default[key] = Boolean.Parse(value);
                 break;
             case "Color":
                 var cc = new ColorConverter();
                 var color = cc.ConvertFrom(value);
                 Default[key] = color ?? Colors.Black;
                 break;
             case "Double":
                 Default[key] = Double.Parse(value, cultureInfo);
                 break;
             case "Font":
                 var fc = new FontConverter();
                 var font = fc.ConvertFromString(value);
                 Default[key] = font ?? new Font(new FontFamily("Microsoft Sans Serif"), 12);
                 break;
             case "Int32":
                 Default[key] = Int32.Parse(value, cultureInfo);
                 break;
             default:
                 Default[key] = value;
                 break;
         }
     }
     catch (Exception ex)
     {
         Logging.Log(LogManager.GetCurrentClassLogger(), "", ex);
     }
     RaisePropertyChanged(key);
 }
示例#13
0
        public Font GetFontEx(string name)
        {
            if (GdiCacheFonts.ContainsKey(name))
                return GdiCacheFonts[name];
            else
            {
                string fontName = name;
                string fontSize = "";
                if (name.IndexOf(',') != -1)
                {
                    fontName = name.Substring(0, name.IndexOf(',')).Trim();
                    fontSize = name.Substring(name.IndexOf(',') + 1).Trim();
                }

                double userBaseSize = Engine.Instance.Storage.GetFloat("gui.font.normal.size");
                if (userBaseSize == 0)
                {
                    string systemFont = Core.Platform.Instance.GetSystemFont();
                    int posSize = systemFont.IndexOf(",");

                    string strSize = systemFont.Substring(posSize + 1);
                    if (posSize != -1)
                        double.TryParse(strSize, out userBaseSize);

                    if (userBaseSize == 0)
                        userBaseSize = 10;
                }

                if ((fontName == "System") || (fontName == "SystemMonospace"))
                {
                    string systemFont = "";
                    if (fontName == "System")
                    {
                        if(Engine.Instance.Storage.Get("gui.font.normal.name") != "")
                            systemFont = Engine.Instance.Storage.Get("gui.font.normal.name");
                        else
                            systemFont = Core.Platform.Instance.GetSystemFont();
                    }

                    else if (fontName == "SystemMonospace")
                            systemFont = Core.Platform.Instance.GetSystemFontMonospace();
                    int posSize = systemFont.IndexOf(",");
                    if (posSize != -1)
                        systemFont = systemFont.Substring(0, posSize);
                    fontName = systemFont;
                }

                if (fontSize == "normal")
                    fontSize = userBaseSize.ToString(CultureInfo.InvariantCulture) + "pt";
                else if (fontSize == "big")
                    fontSize = (userBaseSize * 1.25).ToString(CultureInfo.InvariantCulture) + "pt";

                string name2 = fontName + "," + fontSize;

                FontConverter fontConverter = new FontConverter();
                Font f = fontConverter.ConvertFromInvariantString(name2) as Font;
                GdiCacheFonts[name] = f;

                return f;
            }
        }
示例#14
0
        private void InitUI()
        {
            try {
                int left ;
                if(int.TryParse(properties[REG_LOGS_LEFT], out left))
                    this.Left = left ;

                int top ;
                if(int.TryParse(properties[REG_LOGS_TOP], out top))
                    this.Top = top ;

                int height ;
                if(int.TryParse(properties[REG_LOGS_HEIGHT], out height))
                    this.Height = height ;

                int width ;
                if(int.TryParse(properties[REG_LOGS_WIDTH], out width))
                    this.Width = width ;

                bool maximized ;
                bool.TryParse(properties[REG_LOGS_MAXIMIZED], out maximized) ;
                this.WindowState = (maximized) ? FormWindowState.Maximized : FormWindowState.Normal ;

                string lang = properties[REG_LANGUAGE] ;
                if(lang.Length == 2 && lang != "en") //for languages used the ISO 639-1, two-letter codes format
                    LoadLang(lang) ;

                //use FontConverter to 'deserialize' the current Font object from string
                string storedFont = properties[REG_LOGS_FONT] ;
                if(storedFont != ""){
                    FontConverter fontCon = new FontConverter() ;
                    Font font = (Font) fontCon.ConvertFromString(storedFont) ;
                    textBoxCopiesFailed.Font = font ;
                    textBoxCopiesDone.Font = font ;
                    textBoxDeletionsDone.Font = font ;
                    textBoxDeletionsFailed.Font = font ;
                }

                //use ColorConverter to 'deserialize' the current Color object from string
                string storedColor = properties[REG_LOGS_FORE_COLOR] ;
                if(storedColor != ""){
                    ColorConverter colorCon = new ColorConverter() ;
                    Color color = (Color) colorCon.ConvertFromString(storedColor) ;
                    textBoxCopiesDone.ForeColor = color ;
                    textBoxCopiesFailed.ForeColor = color ;
                    textBoxDeletionsDone.ForeColor = color ;
                    textBoxDeletionsFailed.ForeColor = color ;

                    //change backcolor to white instead of readonly gray, to make fore color visible
                    textBoxCopiesDone.BackColor = Color.White ;
                    textBoxCopiesFailed.BackColor = Color.White ;
                    textBoxDeletionsDone.BackColor = Color.White ;
                    textBoxDeletionsFailed.BackColor = Color.White ;
                }
            } catch (Exception) { }
        }
 public Font GetEditorFont()
 {
     var cvt = new FontConverter();
     return cvt.ConvertFromString(editorFont) as Font;
 }
 public void SetEditorFont(Font font)
 {
     var cvt = new FontConverter();
     editorFont = cvt.ConvertToString(font);
 }
示例#17
0
 public void SetFont(Font font)
 {
     Font = new FontConverter().ConvertToInvariantString(font);
 }
        internal static string ToQueryString(
            string source,
            int? width,
            int? height,
            int clientCacheDuration,
            int serverCacheDuration,
            RotateFlipType rotateFlip,
            bool drawGrayscale,
            bool drawSepia,
            DynamicText text,
            DynamicImageFormat imageFormat,
            KeyValuePair<Type, IDictionary<string, string>>? imageCreator,
            Dictionary<Type, IDictionary<string, string>> imageTransformations)
        {
            HttpServerUtility server = HttpContext.Current.Server;

            string parameterFormat = "{0}={1}";

            Dictionary<string, string> parameters = new Dictionary<string, string>();

            // width

            if (width.HasValue && (0 < width.Value))
            {
                parameters.Add(
                    ResizeImageTransformation.SIZEW_KEY,
                    string.Format(parameterFormat, ResizeImageTransformation.SIZEW_KEY, width.Value));
            }

            // height

            if (height.HasValue && (0 < height.Value))
            {
                parameters.Add(
                    ResizeImageTransformation.SIZEH_KEY,
                    string.Format(parameterFormat, ResizeImageTransformation.SIZEH_KEY, height.Value));
            }

            // client cache duration

            if (0 < clientCacheDuration)
            {
                parameters.Add(
                    DynamicImageProvider.CLIENTCACHEDUR_KEY,
                    string.Format(parameterFormat, DynamicImageProvider.CLIENTCACHEDUR_KEY, clientCacheDuration));
            }

            // server cache duration

            if (0 < serverCacheDuration)
            {
                parameters.Add(
                    DynamicImageProvider.SERVERCACHEDUR_KEY,
                    string.Format(parameterFormat, DynamicImageProvider.SERVERCACHEDUR_KEY, serverCacheDuration));
            }

            // rotate flip

            if (RotateFlipType.RotateNoneFlipNone != rotateFlip)
            {
                parameters.Add(
                    RotateFlipImageTransformation.ROTATETYPE_KEY,
                    string.Format(parameterFormat, RotateFlipImageTransformation.ROTATETYPE_KEY, rotateFlip));
            }

            // grayscale

            if (drawGrayscale)
            {
                parameters.Add(
                    GrayscaleImageTransformation.GRAYSCALE_KEY,
                    string.Format(parameterFormat, GrayscaleImageTransformation.GRAYSCALE_KEY, drawGrayscale));
            }

            // sepia

            if (drawSepia)
            {
                parameters.Add(
                    SepiaImageTransformation.SEPIA_KEY,
                    string.Format(parameterFormat, SepiaImageTransformation.SEPIA_KEY, drawSepia));
            }

            if ((null != text) && !string.IsNullOrEmpty(text.Value))
            {
                // text

                parameters.Add(
                    TextImageTransformation.TEXTVALUE_KEY,
                    string.Format(parameterFormat, TextImageTransformation.TEXTVALUE_KEY, server.UrlEncode(text.Value)));

                // text font

                if (null != text.Font)
                {
                    string stringFont = new FontConverter().ConvertToString(text.Font);
                    if ("Arial;10.0f" != stringFont)
                    {
                        parameters.Add(
                            TextImageTransformation.TEXTFONT_KEY,
                            string.Format(parameterFormat, TextImageTransformation.TEXTFONT_KEY, server.UrlEncode(stringFont)));
                    }
                }

                // text color

                if (Color.Black != text.Color)
                {
                    parameters.Add(
                        TextImageTransformation.TEXTCOLOR_KEY,
                        string.Format(parameterFormat, TextImageTransformation.TEXTCOLOR_KEY, text.Color.ToArgb()));
                }

                // text halignment

                if (StringAlignment.Far != text.HorizontalAlign)
                {
                    parameters.Add(
                        TextImageTransformation.TEXTHEIGHTALIGN_KEY,
                        string.Format(parameterFormat, TextImageTransformation.TEXTHEIGHTALIGN_KEY, text.HorizontalAlign));
                }

                // text valignment

                if (StringAlignment.Far != text.VerticalAlign)
                {
                    parameters.Add(
                        TextImageTransformation.TEXTWIDTHALIGN_KEY,
                        string.Format(parameterFormat, TextImageTransformation.TEXTWIDTHALIGN_KEY, text.VerticalAlign));
                }
            }

            // image format

            if (DynamicImageFormat.Original != imageFormat)
            {
                parameters.Add(
                    DynamicImageProvider.IMAGEFORMAT_KEY,
                    string.Format(parameterFormat, DynamicImageProvider.IMAGEFORMAT_KEY, imageFormat));
            }

            if ((null == imageCreator) || (null == imageCreator.Value.Key))
            {
                // source

                if (!string.IsNullOrEmpty(source))
                {
                    parameters.Add(
                        LocalizedImageCreation.SOURCE_KEY,
                        string.Format(parameterFormat, LocalizedImageCreation.SOURCE_KEY, server.UrlEncode(source)));
                }
            }

            // set for last the custom creators and transformations
            // to be able to yield duplicate keys

            // image creation type

            if ((null != imageCreator) && (null != imageCreator.Value.Key))
            {
                parameters.Add(
                    DynamicImageProvider.CREATIONTYPE_KEY,
                    string.Format(parameterFormat, DynamicImageProvider.CREATIONTYPE_KEY, server.UrlEncode(imageCreator.Value.Key.AssemblyQualifiedName)));

                if ((null != imageCreator.Value.Value) && (0 < imageCreator.Value.Value.Count))
                {
                    foreach (KeyValuePair<string, string> param in imageCreator.Value.Value)
                    {
                        if (!string.IsNullOrEmpty(param.Key))
                        {
                            if (parameters.ContainsKey(param.Key) || param.Key.StartsWith(DynamicImageProvider.TRANSFTYPEPREFIX_KEY, StringComparison.InvariantCultureIgnoreCase))
                            {
                                throw new InvalidOperationException("Duplicate parameter key in query string (creation type).");
                            }

                            parameters.Add(param.Key, string.Format(parameterFormat, server.UrlEncode(param.Key), server.UrlEncode(param.Value)));
                        }
                    }
                }
            }

            // image tranformations types
            if ((null != imageTransformations) && (0 < imageTransformations.Count))
            {
                int i = 0;
                foreach (Type t in imageTransformations.Keys)
                {
                    string typeKey = string.Format("{0}{1}", DynamicImageProvider.TRANSFTYPEPREFIX_KEY, i++);

                    parameters.Add(
                        typeKey,
                        string.Format(parameterFormat, typeKey, server.UrlEncode(t.AssemblyQualifiedName)));

                    if ((null != imageTransformations[t]) && (0 < imageTransformations[t].Count))
                    {
                        foreach (KeyValuePair<string, string> param in imageTransformations[t])
                        {
                            if (parameters.ContainsKey(param.Key) || param.Key.StartsWith(DynamicImageProvider.TRANSFTYPEPREFIX_KEY, StringComparison.InvariantCultureIgnoreCase))
                            {
                                throw new InvalidOperationException("Duplicate parameter key in query string (creation type).");
                            }

                            parameters.Add(param.Key, string.Format(parameterFormat, server.UrlEncode(param.Key), server.UrlEncode(param.Value)));
                        }
                    }
                }
            }

            return (parameters.Count > 0) ? string.Join("&", new List<string>(parameters.Values).ToArray()) : string.Empty;
        }
示例#19
0
		protected override FormButtons ConvertProcessing(OfficeRange aWordRange, FontConverter aThisFC, string strInput, ref int nCharIndex, ref string strReplace)
		{
			// here's the meat of the RoundTripChecker engine: process the word both in the
			// forward and reverse directions and compare the 2nd output with the input
			string strOutput = aThisFC.DirectableEncConverter.Convert(strInput);
			string strRoundtrip = aThisFC.DirectableEncConverter.ConvertDirectionOpposite(strOutput);

			// our 'form' is really a RoundTripProcessorForm (which has special methods/properties we need to call)
			RoundTripProcessorForm form = (RoundTripProcessorForm)Form;
			FormButtons res = FormButtons.None;
			if (!form.SkipIdenticalValues || (strInput != strRoundtrip))
			{
				if (ReplaceAll)
				{
					strReplace = strRoundtrip;
					res = FormButtons.ReplaceAll;
				}
				else
				{
					res = form.Show(aThisFC, strInput, strOutput, strRoundtrip);

					// just in case it's Replace or ReplaceAll, our replacement string is the 'RoundTripString'
					strReplace = form.RoundTripString;
				}
			}

			return res;
		}
示例#20
0
        //----------------------------------------------------------------------
        // Form Closing event
        //----------------------------------------------------------------------
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (richTextBox1.Modified == true)
            {
                //"問い合わせ"
                //"編集中のファイルがあります。保存してから終了しますか?"
                //"Question"
                //"This file being edited. Do you wish to save before exiting?"
                DialogResult ret = MessageBox.Show(Resources.MsgSaveFileToEnd,
                Resources.DialogTitleQuestion, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

                if (ret == DialogResult.Yes)
                {
                    if (SaveToEditingFile() == true)
                    {
                        _fNoTitle = false;
                    }
                    else
                    {
                        //キャンセルで抜けてきた
                        //user cancel
                        e.Cancel = true;
                        return;
                    }
                }
                else if (ret == DialogResult.Cancel)
                {
                    e.Cancel = true;
                    return;
                }
            }

            _fConstraintChange = true;

            //無題ファイルのまま編集しているのなら削除
            //Delete file if the file is no title
            if (_fNoTitle == true)
            {
                if (File.Exists(_MarkDownTextFilePath) == true)
                {
                    try
                    {
                        File.Delete(_MarkDownTextFilePath);
                    }
                    catch
                    {
                    }
                }
            }

            //データバージョン
            //Data version
            System.Reflection.Assembly asmbly = System.Reflection.Assembly.GetExecutingAssembly();
            System.Version ver = asmbly.GetName().Version;
            MarkDownSharpEditor.AppSettings.Instance.Version = ver.Major * 1000 + ver.Minor * 100 + ver.Build * 10 + ver.Revision;

            //フォーム位置・サイズ ( Form position & size )
            if (this.WindowState == FormWindowState.Minimized)
            {	//最小化 ( Minimize )
                MarkDownSharpEditor.AppSettings.Instance.FormState = 1;
                //一時記憶していた位置・サイズを保存 ( Save temporary position & size value )
                MarkDownSharpEditor.AppSettings.Instance.FormPos = new Point(_preFormPos.X, _preFormPos.Y);
                MarkDownSharpEditor.AppSettings.Instance.FormSize = new Size(_preFormSize.Width, _preFormSize.Height);
            }
            else if (this.WindowState == FormWindowState.Maximized)
            {	//最大化 ( Maximize )
                MarkDownSharpEditor.AppSettings.Instance.FormState = 2;
                //一時記憶していた位置・サイズを保存 ( Save temporary position & size value )
                MarkDownSharpEditor.AppSettings.Instance.FormPos = new Point(_preFormPos.X, _preFormPos.Y);
                MarkDownSharpEditor.AppSettings.Instance.FormSize = new Size(_preFormSize.Width, _preFormSize.Height);
            }
            else
            {	//通常 ( Normal window )
                MarkDownSharpEditor.AppSettings.Instance.FormState = 0;
                MarkDownSharpEditor.AppSettings.Instance.FormPos = new Point(this.Left, this.Top);
                MarkDownSharpEditor.AppSettings.Instance.FormSize = new Size(this.Width, this.Height);
            }

            MarkDownSharpEditor.AppSettings.Instance.richEditWidth = this.richTextBox1.Width;
            FontConverter fc = new FontConverter();
            MarkDownSharpEditor.AppSettings.Instance.FontFormat = fc.ConvertToString(richTextBox1.Font);
            MarkDownSharpEditor.AppSettings.Instance.richEditForeColor = richTextBox1.ForeColor.ToArgb();

            //表示オプションなど
            //Save view options etc
            MarkDownSharpEditor.AppSettings.Instance.fViewToolBar = this.menuViewToolBar.Checked;
            MarkDownSharpEditor.AppSettings.Instance.fViewStatusBar = this.menuViewStatusBar.Checked;
            MarkDownSharpEditor.AppSettings.Instance.fSplitBarWidthEvenly = this.menuViewWidthEvenly.Checked;

            //検索オプション
            //Save search options
            MarkDownSharpEditor.AppSettings.Instance.fSearchOptionIgnoreCase = chkOptionCase.Checked ? false : true;

            if (File.Exists(_MarkDownTextFilePath) == true)
            {
                //編集中のファイルパス
                //Save editing file path
                foreach (AppHistory data in MarkDownSharpEditor.AppSettings.Instance.ArrayHistoryEditedFiles)
                {
                    if (data.md == _MarkDownTextFilePath)
                    { //いったん削除して ( delete once ... )
                        MarkDownSharpEditor.AppSettings.Instance.ArrayHistoryEditedFiles.Remove(data);
                        break;
                    }
                }
                AppHistory HistroyData = new AppHistory();
                HistroyData.md = _MarkDownTextFilePath;
                HistroyData.css = _SelectedCssFilePath;
                MarkDownSharpEditor.AppSettings.Instance.ArrayHistoryEditedFiles.Insert(0, HistroyData);	//先頭に挿入 ( Insert at the top )
            }

            //設定の保存
            //Save settings
            MarkDownSharpEditor.AppSettings.Instance.SaveToXMLFile();
            //MarkDownSharpEditor.AppSettings.Instance.SaveToJsonFile();

            timer1.Enabled = false;

            //webBrowser1.Navigate("about:blank");
            //クリック音対策
            //Constraint click sounds
            if (webBrowser1.Document != null)
            {
                webBrowser1.Document.OpenNew(true);
                webBrowser1.Document.Write("");
            }
        }
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     System.Drawing.FontConverter     fontConverter1 = new System.Drawing.FontConverter();
     System.Drawing.Design.FontEditor fontEditor1    = new System.Drawing.Design.FontEditor();
     this.valueEditor1 = new Microsoft.Practices.WizardFramework.ValueEditor();
     this.label1       = new System.Windows.Forms.Label();
     this.textBox1     = new System.Windows.Forms.TextBox();
     this.label2       = new System.Windows.Forms.Label();
     this.label3       = new System.Windows.Forms.Label();
     ((System.ComponentModel.ISupportInitialize)(this.valueEditor1)).BeginInit();
     ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
     this.SuspendLayout();
     //
     // valueEditor1
     //
     this.valueEditor1.BackColor         = System.Drawing.SystemColors.Info;
     this.valueEditor1.BorderStyle       = System.Windows.Forms.BorderStyle.Fixed3D;
     this.valueEditor1.ConverterInstance = fontConverter1;
     this.valueEditor1.EditorInstance    = fontEditor1;
     this.valueEditor1.EditorType        = typeof(System.Drawing.Design.FontEditor);
     this.valueEditor1.ForeColor         = System.Drawing.SystemColors.HotTrack;
     this.valueEditor1.Location          = new System.Drawing.Point(29, 150);
     this.valueEditor1.Name          = "valueEditor1";
     this.valueEditor1.ReadOnly      = false;
     this.valueEditor1.Size          = new System.Drawing.Size(328, 18);
     this.valueEditor1.TabIndex      = 0;
     this.valueEditor1.ToolTip       = "Tooltip for argument";
     this.valueEditor1.ValueRequired = true;
     this.valueEditor1.ValueType     = typeof(System.Drawing.Font);
     this.valueEditor1.ValueChanged += new System.ComponentModel.Design.ComponentChangedEventHandler(this.valueEditor1_ValueChanged);
     //
     // label1
     //
     this.label1.AutoSize  = true;
     this.label1.Font      = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.label1.ForeColor = System.Drawing.Color.Gray;
     this.label1.Location  = new System.Drawing.Point(24, 23);
     this.label1.Name      = "label1";
     this.label1.Size      = new System.Drawing.Size(350, 20);
     this.label1.TabIndex  = 1;
     this.label1.Text      = "Enter value of Argument2 in the field below";
     this.label1.Click    += new System.EventHandler(this.label1_Click);
     //
     // textBox1
     //
     this.textBox1.BackColor    = System.Drawing.Color.Aquamarine;
     this.textBox1.Font         = new System.Drawing.Font("Microsoft Sans Serif", 20F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.textBox1.ForeColor    = System.Drawing.Color.Blue;
     this.textBox1.Location     = new System.Drawing.Point(28, 50);
     this.textBox1.Name         = "textBox1";
     this.textBox1.Size         = new System.Drawing.Size(329, 38);
     this.textBox1.TabIndex     = 9;
     this.textBox1.Text         = "Custom Page 2";
     this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
     //
     // label2
     //
     this.label2.AutoSize  = true;
     this.label2.Font      = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.label2.ForeColor = System.Drawing.Color.Gray;
     this.label2.Location  = new System.Drawing.Point(28, 120);
     this.label2.Name      = "label2";
     this.label2.Size      = new System.Drawing.Size(279, 20);
     this.label2.TabIndex  = 10;
     this.label2.Text      = "Specify Font (value of Argument3)";
     //
     // label3
     //
     this.label3.AutoSize  = true;
     this.label3.Font      = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.label3.ForeColor = System.Drawing.SystemColors.ControlText;
     this.label3.Location  = new System.Drawing.Point(27, 180);
     this.label3.Name      = "label3";
     this.label3.Size      = new System.Drawing.Size(351, 25);
     this.label3.TabIndex  = 11;
     this.label3.Text      = "Sample of the font you have chosen";
     //
     // CustomWizPage2
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
     this.Controls.Add(this.valueEditor1);
     this.Controls.Add(this.label3);
     this.Controls.Add(this.label2);
     this.Controls.Add(this.textBox1);
     this.Controls.Add(this.label1);
     this.Headline      = "Second Headline";
     this.InfoRTBoxSize = new System.Drawing.Size(500, 50);
     this.InfoRTBoxText = "You can change the size of this info-box and put text in it by manipulating Info" +
                          "RTBox element of the related Designer class";
     this.Name          = "CustomWizPage2";
     this.ShowInfoPanel = true;
     this.Size          = new System.Drawing.Size(527, 350);
     this.Skippable     = true;
     this.StepTitle     = "Second custom step";
     this.Controls.SetChildIndex(this.label1, 0);
     this.Controls.SetChildIndex(this.textBox1, 0);
     this.Controls.SetChildIndex(this.label2, 0);
     this.Controls.SetChildIndex(this.label3, 0);
     this.Controls.SetChildIndex(this.valueEditor1, 0);
     ((System.ComponentModel.ISupportInitialize)(this.valueEditor1)).EndInit();
     ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
     this.ResumeLayout(false);
     this.PerformLayout();
 }
示例#22
0
        //----------------------------------------------------------------------
        // フォームをロード ( Load main form )
        //----------------------------------------------------------------------
        private void Form1_Load(object sender, EventArgs e)
        {
            var obj = MarkDownSharpEditor.AppSettings.Instance;

            //-----------------------------------
            //フォーム位置・サイズ ( Form position & size )
            //-----------------------------------

            this.Location = obj.FormPos;
            this.Size = obj.FormSize;
            this.richTextBox1.Width = obj.richEditWidth;

            //ウィンドウ位置の調整(へんなところに行かないように戻す)
            // Ajust window position ( Set position into Desktop range )
            if (this.Left < 0 || this.Left > Screen.PrimaryScreen.Bounds.Width)
            {
                this.Left = 0;
            }
            if (this.Top < 0 || this.Top > Screen.PrimaryScreen.Bounds.Height)
            {
                this.Top = 0;
            }

            if (obj.FormState == 1)
            {	//最小化 ( Minimize )
                this.WindowState = FormWindowState.Minimized;
            }
            else if (obj.FormState == 2)
            {	//最大化 ( Maximize )
                this.WindowState = FormWindowState.Maximized;
            }

            //メインメニュー表示
            //View main menu
            this.menuViewToolBar.Checked = obj.fViewToolBar;
            this.toolStrip1.Visible = obj.fViewToolBar;
            this.menuViewStatusBar.Checked = obj.fViewStatusBar;
            this.statusStrip1.Visible = obj.fViewStatusBar;
            this.menuViewWidthEvenly.Checked = obj.fSplitBarWidthEvenly;

            //言語 ( Language )
            if (obj.Lang == "ja")
            {
                menuViewJapanese.Checked = true;
                menuViewEnglish.Checked = false;
            }
            else
            {
                menuViewJapanese.Checked = false;
                menuViewEnglish.Checked = true;
            }

            //ブラウザープレビューまでの間隔
            //Interval time of browser preview
            if (obj.AutoBrowserPreviewInterval > 0)
            {
                timer1.Interval = obj.AutoBrowserPreviewInterval;
            }

            //-----------------------------------
            //RichEditBox font
            FontConverter fc = new FontConverter();
            try { richTextBox1.Font = (Font)fc.ConvertFromString(obj.FontFormat); }
            catch { }
            //RichEditBox font color
            richTextBox1.ForeColor = Color.FromArgb(obj.richEditForeColor);
            //ステータスバーに表示
            //View in statusbar
            toolStripStatusLabelFontInfo.Text =
                richTextBox1.Font.Name + "," + richTextBox1.Font.Size.ToString() + "pt";

            //エディターのシンタックスハイライター設定の反映
            //Syntax highlighter of editor window is enabled
            _MarkdownSyntaxKeywordAarray = MarkdownSyntaxKeyword.CreateKeywordList();

            //-----------------------------------
            //選択中のエンコーディングを表示
            //View selected character encoding name
            foreach (EncodingInfo ei in Encoding.GetEncodings())
            {
                if (ei.GetEncoding().IsBrowserDisplay == true)
                {
                    if (ei.CodePage == obj.CodePageNumber)
                    {
                        toolStripStatusLabelHtmlEncoding.Text = ei.DisplayName;
                        break;
                    }
                }
            }

            //-----------------------------------
            //指定されたCSSファイル名を表示
            //View selected CSS file name
            toolStripStatusLabelCssFileName.Text = Resources.toolTipCssFileName; //"CSSファイル指定なし"; ( No CSS file )

            if (obj.ArrayCssFileList.Count > 0)
            {
                string FilePath = (string)obj.ArrayCssFileList[0];
                if (File.Exists(FilePath) == true)
                {
                    toolStripStatusLabelCssFileName.Text = Path.GetFileName(FilePath);
                    _SelectedCssFilePath = FilePath;
                }
            }

            //-----------------------------------
            //出力するHTMLエンコーディング表示
            //View HTML charcter encoding name for output
            if (obj.HtmlEncodingOption == 0)
            {
                // 編集中(RichEditBox側)のエンコーディング
                // 基本的にはテキストファイルが読み込まれたときに表示する
                // View encoding name of editor window
                toolStripStatusLabelHtmlEncoding.Text = _EditingFileEncoding.EncodingName;
            }
            else
            {
                //エンコーディングを指定する(&C)
                //Select encoding
                Encoding enc = Encoding.GetEncoding(obj.CodePageNumber);
                toolStripStatusLabelHtmlEncoding.Text = enc.EncodingName;
            }

            //-----------------------------------
            //検索フォーム・オプション
            //Search form options
            chkOptionCase.Checked = obj.fSearchOptionIgnoreCase ? false : true;
        }
示例#23
0
        //----------------------------------------------------------------------
        // OpenFile [ .mdファイルを開く ]
        //----------------------------------------------------------------------
        private bool OpenFile(string FilePath, bool fOpenDialog = false)
        {
            //引数 FilePath = "" の場合は「無題」編集で開始する
            // Argument "FilePath" = "" => Start editing in 'no title'

            if (FilePath == "")
            {
                _fNoTitle = true;  // No title flag
            }
            else
            {
                _fNoTitle = false;
            }

            //-----------------------------------
            //編集中のファイルがある
            if (richTextBox1.Modified == true)
            {
                //"問い合わせ"
                //"編集中のファイルがあります。保存してから終了しますか?"
                //"Question"
                //"This file being edited. Do you wish to save before exiting?"
                DialogResult ret = MessageBox.Show(Resources.MsgSaveFileToEnd,
                Resources.DialogTitleQuestion, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                if (ret == DialogResult.Yes)
                {
                    if (SaveToEditingFile() == false)
                    {
                        //キャンセルで抜けてきた
                        //Cancel
                        return (false);
                    }
                }
                else if (ret == DialogResult.Cancel)
                {
                    return (false);
                }

                //編集履歴に残す
                //Save file path to editing history
                foreach (AppHistory data in MarkDownSharpEditor.AppSettings.Instance.ArrayHistoryEditedFiles)
                {
                    if (data.md == _MarkDownTextFilePath)
                    {   //いったん削除して ( delete once ... )
                        MarkDownSharpEditor.AppSettings.Instance.ArrayHistoryEditedFiles.Remove(data);
                        break;
                    }
                }
                AppHistory HistroyData = new AppHistory();
                HistroyData.md = _MarkDownTextFilePath;
                HistroyData.css = _SelectedCssFilePath;
                MarkDownSharpEditor.AppSettings.Instance.ArrayHistoryEditedFiles.Insert(0, HistroyData);	//先頭に挿入 ( Insert at the top )
            }

            //-----------------------------------
            //オープンダイアログ表示
            //View open file dialog
            if (fOpenDialog == true)
            {
                if (File.Exists(_MarkDownTextFilePath) == true)
                {	//編集中のファイルがあればそのディレクトリを初期フォルダーに
                    //Set parent directory of editing file to initial folder
                    openFileDialog1.InitialDirectory = Path.GetDirectoryName(_MarkDownTextFilePath);
                    //テンポラリファイルがあればここで削除
                    //Delete it if temporary file exists
                    Delete_TemporaryHtmlFilePath();
                }
                openFileDialog1.FileName = "";
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    FilePath = openFileDialog1.FileName;
                }
                else
                {
                    return (false);
                }
            }

            //編集中のファイルパスとする
            //Set this file to 'editing file' path
            _MarkDownTextFilePath = FilePath;

            //-----------------------------------
            //文字コードを調査するためにテキストファイルを開く
            //Detect encoding
            if (_fNoTitle == false)
            {
                byte[] bs;
                using (FileStream fs = new FileStream(FilePath, FileMode.Open, FileAccess.Read))
                {
                    bs = new byte[fs.Length];
                    fs.Read(bs, 0, bs.Length);
                }
                //文字コードを取得する
                //Get charcter encoding
                _EditingFileEncoding = GetCode(bs);
            }
            else
            {
                //「無題」はデフォルトのエンコーディング
                // Set this file to default encoding in 'No title'
                _EditingFileEncoding = Encoding.UTF8;
            }

            //ステータスバーに表示
            //View in statusbar
            toolStripStatusLabelTextEncoding.Text = _EditingFileEncoding.EncodingName;
            //編集中のエンコーディングを使用する(&D)か
            //Use encoding of editing file
            if (MarkDownSharpEditor.AppSettings.Instance.HtmlEncodingOption == 0)
            {
                toolStripStatusLabelHtmlEncoding.Text = _EditingFileEncoding.EncodingName;
            }

            //-----------------------------------
            //ペアとなるCSSファイルがあるか探索してあれば適用する
            //Apply that the pair CSS file to this file exists
            foreach (AppHistory data in MarkDownSharpEditor.AppSettings.Instance.ArrayHistoryEditedFiles)
            {
                if (data.md == _MarkDownTextFilePath)
                {
                    if (File.Exists(data.css) == true)
                    {
                        _SelectedCssFilePath = data.css;
                        break;
                    }
                }
            }

            //選択中のCSSファイル名をステータスバーに表示
            //View selected CSS file name to stausbar
            if (File.Exists(_SelectedCssFilePath) == true)
            {
                toolStripStatusLabelCssFileName.Text = Path.GetFileName(_SelectedCssFilePath);
            }
            else
            {
                toolStripStatusLabelCssFileName.Text = Resources.toolTipCssFileName; //"CSSファイル指定なし"; ( not selected CSS file)
            }

            _fConstraintChange = true;
            richTextBox1.Clear();

            //RichEditBoxの「フォント」設定
            // richTextBox1 font name setting
            var obj = MarkDownSharpEditor.AppSettings.Instance;
            FontConverter fc = new FontConverter();
            try { richTextBox1.Font = (Font)fc.ConvertFromString(obj.FontFormat); }
            catch { }
            //RichEditBoxの「フォントカラー」設定
            // richTextBox1 font color setting
            richTextBox1.ForeColor = Color.FromArgb(obj.richEditForeColor);
            //View them in statusbar
            toolStripStatusLabelFontInfo.Text = richTextBox1.Font.Name + "," + richTextBox1.Font.Size.ToString() + "pt";

            //-----------------------------------
            //テキストファイルの読み込み
            //Read text file
            if (File.Exists(FilePath) == true)
            {
                richTextBox1.Text = File.ReadAllText(FilePath, _EditingFileEncoding);
            }
            richTextBox1.BeginUpdate();
            richTextBox1.SelectionStart = richTextBox1.Text.Length;
            richTextBox1.ScrollToCaret();
            //richTextBox1の全高さを求める
            //Get height of richTextBox1 ( for webBrowser sync )
            _richEditBoxInternalHeight = richTextBox1.VerticalPosition;
            //カーソル位置を戻す
            //Restore cursor position
            richTextBox1.SelectionStart = 0;
            richTextBox1.EndUpdate();

            //変更フラグOFF
            richTextBox1.Modified = false;

            //Undoバッファに追加
            //Add all text to undo buffer
            UndoBuffer.Clear();
            UndoBuffer.Add(richTextBox1.Rtf);
            undoCounter = UndoBuffer.Count;

            //プレビュー更新
            PreviewToBrowser();

            _fConstraintChange = false;
            FormTextChange();

            return (true);
        }
示例#24
0
        //----------------------------------------------------------------------
        // フォームをロード
        //----------------------------------------------------------------------
        private void Form1_Load(object sender, EventArgs e)
        {
            var obj = MarkDownSharpEditor.AppSettings.Instance;

            //-----------------------------------
            //フォーム位置・サイズ
            //-----------------------------------
            this.Left = obj.FormPos.X;
            this.Top = obj.FormPos.Y;
            this.Width = obj.FormSize.Width;
            this.Height = obj.FormSize.Height;
            this.richTextBox1.Width = obj.richEditWidth;

            //メインメニュー表示
            this.menuViewToolBar.Checked = obj.fViewToolBar;
            this.toolStrip1.Visible = obj.fViewToolBar;
            this.menuViewStatusBar.Checked = obj.fViewStatusBar;
            this.statusStrip1.Visible = obj.fViewStatusBar;
            this.menuViewWidthEvenly.Checked = obj.fSplitBarWidthEvenly;

            //ブラウザープレビューまでの間隔
            if (obj.AutoBrowserPreviewInterval > 0)
            {
                timer1.Interval = obj.AutoBrowserPreviewInterval;
            }

            //-----------------------------------
            //RichEditBoxフォント
            FontConverter fc = new FontConverter();
            try { richTextBox1.Font = (Font)fc.ConvertFromString(obj.FontFormat); }
            catch { }
            //RichEditBoxフォントカラー
            richTextBox1.ForeColor = Color.FromArgb(obj.richEditForeColor);
            //ステータスバーに表示
            toolStripStatusLabelFontInfo.Text =
                richTextBox1.Font.Name + "," + richTextBox1.Font.Size.ToString() + "pt";

            //エディターのシンタックスハイライター設定の反映
            RefreshSyntaxHightlighterKeyword();

            //-----------------------------------
            //選択中のエンコーディングを表示
            foreach (EncodingInfo ei in Encoding.GetEncodings())
            {
                if (ei.GetEncoding().IsBrowserDisplay == true)
                {
                    if (ei.CodePage == obj.CodePageNumber)
                    {
                        toolStripStatusLabelHtmlEncoding.Text = ei.DisplayName;
                        break;
                    }
                }
            }

            //-----------------------------------
            //指定されたCSSファイル名を表示
            toolStripStatusLabelCssFileName.Text = "CSSファイル指定なし";

            if (obj.ArrayCssFileList.Count > 0)
            {
                string FilePath = (string)obj.ArrayCssFileList[0];
                if (File.Exists(FilePath) == true)
                {
                    toolStripStatusLabelCssFileName.Text = Path.GetFileName(FilePath);
                    SelectedCssFilePath = FilePath;
                }
            }

            //-----------------------------------
            //出力するHTMLエンコーディング表示
            if (obj.HtmlEncodingOption == 0)
            {
                // 編集中(RichEditBox側)のエンコーディング
                // デフォルト
                // 基本的にはテキストファイルが読み込まれたときに表示する
                toolStripStatusLabelHtmlEncoding.Text = EditingFileEncoding.EncodingName;
            }
            else
            {
                //エンコーディングを指定する(&C)
                Encoding enc = Encoding.GetEncoding(obj.CodePageNumber);
                toolStripStatusLabelHtmlEncoding.Text = enc.EncodingName;
            }
        }
示例#25
0
 public FontConverter()
 {
     this._converter = new System.Drawing.FontConverter();
 }
示例#26
0
        public override XmlElement serializeToXml( XmlDocument document)
        {
            XmlElement element = base.serializeToXml(document);

            XmlElement DocumentElement = document.CreateElement("Text");

            XmlAttribute color = document.CreateAttribute("Color");
            ColorConverter converter = new ColorConverter();
            color.Value = converter.ConvertToString(null, System.Globalization.CultureInfo.InvariantCulture, _color);
            DocumentElement.Attributes.Append(color);

            XmlAttribute background = document.CreateAttribute("Background");
            background.Value = converter.ConvertToString(null, System.Globalization.CultureInfo.InvariantCulture, _background);
            DocumentElement.Attributes.Append(background);

            if (_font != null)
            {
                XmlAttribute font = document.CreateAttribute("Font");
                FontConverter fontConverter = new FontConverter();
                font.Value = fontConverter.ConvertToString(null, System.Globalization.CultureInfo.InvariantCulture, _font);
                DocumentElement.Attributes.Append(font);
            }

            XmlAttribute alignment = document.CreateAttribute("Alignment");

            alignment.Value = AlignmentString(_alignment);
            DocumentElement.Attributes.Append(alignment);

            DocumentElement.InnerText = _text;
            element.AppendChild(DocumentElement);

            return element;
        }
示例#27
0
        //----------------------------------------------------------------------
        // TODO: .mdファイルを開く(OpenFile)
        //----------------------------------------------------------------------
        private bool OpenFile(string FilePath)
        {
            if (richTextBox1.Modified == true)
            {
                DialogResult ret = MessageBox.Show(
                    "編集中のファイルがあります。保存してか らファイルを開きますか?",
                    "問い合わせ", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

                if (ret == DialogResult.Yes)
                {
                    if (SaveToEditingFile() == false)
                    {
                        //キャンセルで抜けてきた
                        return (false);
                    }
                }
                else if (ret == DialogResult.Cancel)
                {
                    return (false);
                }

                //編集履歴に残す
                foreach (AppHistory data in MarkDownSharpEditor.AppSettings.Instance.ArrayHistoryEditedFiles)
                {
                    if (data.md == MarkDownTextFilePath)
                    {   //いったん削除して
                        MarkDownSharpEditor.AppSettings.Instance.ArrayHistoryEditedFiles.Remove(data);
                        break;
                    }
                }
                AppHistory HistroyData = new AppHistory();
                HistroyData.md = MarkDownTextFilePath;
                HistroyData.css = SelectedCssFilePath;
                MarkDownSharpEditor.AppSettings.Instance.ArrayHistoryEditedFiles.Insert(0, HistroyData);	//先頭に挿入
            }

            //ファイル名指定で来ている(ドラッグ&ドロップされた等)
            if (File.Exists(FilePath) == true)
            {
            }
            else
            {
                //オープンダイアログ表示
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    FilePath = openFileDialog1.FileName;
                }
                else
                {
                    return (false);
                }
            }

            //テンポラリファイルがあればここで削除
            DeleteTemporaryHtmlFilePath();

            //テキストファイルを開く
            byte[] bs;
            using (FileStream fs = new FileStream(FilePath, FileMode.Open, FileAccess.Read))
            {
                bs = new byte[fs.Length];
                fs.Read(bs, 0, bs.Length);
            }

            //文字コードを取得する
            EditingFileEncoding = GetCode(bs);

            //ステータスバーに表示
            toolStripStatusLabelTextEncoding.Text = EditingFileEncoding.EncodingName;

            //編集中のエンコーディングを使用する(&D)か
            if (MarkDownSharpEditor.AppSettings.Instance.HtmlEncodingOption == 0)
            {
                toolStripStatusLabelHtmlEncoding.Text = EditingFileEncoding.EncodingName;
            }

            fConstraintChange = true;
            MarkDownTextFilePath = FilePath;	//編集中のファイルパスとする
            fNoTitle = false;                   //無題フラグOFF

            //ペアとなるCSSファイルがあるか探索してあれば適用する
            foreach (AppHistory data in MarkDownSharpEditor.AppSettings.Instance.ArrayHistoryEditedFiles)
            {
                if (data.md == MarkDownTextFilePath)
                {
                    if (File.Exists(data.css) == true)
                    {
                        SelectedCssFilePath = data.css;
                        break;
                    }
                }

            }

            //選択中のCSSファイル名をステータスバーに表示
            if (File.Exists(SelectedCssFilePath) == true)
            {
                toolStripStatusLabelCssFileName.Text = Path.GetFileName(SelectedCssFilePath);
            }
            else
            {
                toolStripStatusLabelCssFileName.Text = "CSSファイル指定なし";
            }

            //RichEditBoxに表示
            fConstraintChange = true;
            richTextBox1.Clear();

            //RichEditBoxの「フォント」設定
            var obj = MarkDownSharpEditor.AppSettings.Instance;
            FontConverter fc = new FontConverter();
            try { richTextBox1.Font = (Font)fc.ConvertFromString(obj.FontFormat); }
            catch { }
            //RichEditBoxの「フォントカラー」設定
            richTextBox1.ForeColor = Color.FromArgb(obj.richEditForeColor);
            //ステータスバーに表示
            toolStripStatusLabelFontInfo.Text =	richTextBox1.Font.Name + "," + richTextBox1.Font.Size.ToString() + "pt";

            //テキストファイルの読み込み
            richTextBox1.Text = File.ReadAllText(FilePath, EditingFileEncoding);
            richTextBox1.Modified = false;

            //Undoバッファに追加
            undoCount = 0;
            UndoBuffer.Clear();
            UndoBuffer.Add(richTextBox1.Text.ToString());

            fConstraintChange = false;
            FormTextChange();

            //シンタックスハイライター
            SyntaxHightlighterWidthRegex();

            //PreviewToBrowser();
            if (timer1.Enabled == false)
            {
                timer1.Enabled = true;
            }

            return (true);
        }
示例#28
0
        //----------------------------------------------------------------------
        //フォームを閉じる前イベント
        //----------------------------------------------------------------------
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (richTextBox1.Modified == true)
            {
                DialogResult ret = MessageBox.Show("編集中のファイルがあります。保存してから終了しますか?",
                "問い合わせ", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);

                if (ret == DialogResult.Yes)
                {
                    if (SaveToEditingFile() == true )
                    {
                        fNoTitle = false;
                    }
                    else{
                        //キャンセルで抜けてきた
                        e.Cancel = true;
                        return;
                    }

                }
                else if (ret == DialogResult.Cancel)
                {
                    e.Cancel = true;
                    return;
                }
            }

            fConstraintChange = true;

            //無題ファイルのまま編集しているのなら削除
            if (fNoTitle == true)
            {
                if (File.Exists(MarkDownTextFilePath) == true)
                {
                    try
                    {
                        File.Delete(MarkDownTextFilePath);
                    }
                    catch
                    {
                    }
                }
            }

            //データバージョン
            System.Reflection.Assembly asmbly =	System.Reflection.Assembly.GetExecutingAssembly();
            System.Version ver = asmbly.GetName().Version;
            MarkDownSharpEditor.AppSettings.Instance.Version = ver.Major*1000+ver.Minor*100+ver.Build*10+ver.Revision;

            //フォーム位置・サイズ
            MarkDownSharpEditor.AppSettings.Instance.FormPos = new Point(this.Left, this.Top);
            MarkDownSharpEditor.AppSettings.Instance.FormSize = new Size(this.Width, this.Height);
            MarkDownSharpEditor.AppSettings.Instance.richEditWidth = this.richTextBox1.Width;
            FontConverter fc = new FontConverter();
            MarkDownSharpEditor.AppSettings.Instance.FontFormat = fc.ConvertToString(richTextBox1.Font);
            MarkDownSharpEditor.AppSettings.Instance.richEditForeColor = richTextBox1.ForeColor.ToArgb();

            //表示オプションなど
            MarkDownSharpEditor.AppSettings.Instance.fViewToolBar = this.menuViewToolBar.Checked;
            MarkDownSharpEditor.AppSettings.Instance.fViewStatusBar = this.menuViewStatusBar.Checked;
            MarkDownSharpEditor.AppSettings.Instance.fSplitBarWidthEvenly = this.menuViewWidthEvenly.Checked;

            if (File.Exists(MarkDownTextFilePath) == true)
            {
                //編集中のファイルパス
                foreach (AppHistory data in MarkDownSharpEditor.AppSettings.Instance.ArrayHistoryEditedFiles)
                {
                    if (data.md == MarkDownTextFilePath)
                    {   //いったん削除して
                        MarkDownSharpEditor.AppSettings.Instance.ArrayHistoryEditedFiles.Remove(data);
                        break;
                    }
                }
                AppHistory HistroyData = new AppHistory();
                HistroyData.md = MarkDownTextFilePath;
                HistroyData.css = SelectedCssFilePath;
                MarkDownSharpEditor.AppSettings.Instance.ArrayHistoryEditedFiles.Insert(0, HistroyData);	//先頭に挿入
            }

            //設定の保存
            MarkDownSharpEditor.AppSettings.Instance.SaveToXMLFile();
            //MarkDownSharpEditor.AppSettings.Instance.SaveToJsonFile();

            //ブラウザを空白にする
            webBrowser1.Navigate("about:blank");
        }
示例#29
0
		void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
		{
			// Serialize the desired values for this class
			info.AddValue("foreColor1", foreColor1);
			info.AddValue("foreColor2", foreColor2);
			info.AddValue("backColor1", backColor1);
			info.AddValue("backColor2", backColor2);
			info.AddValue("text", text);
			info.AddValue("alignment", alignment);
			info.AddValue("lineAlignment", lineAlignment);
			info.AddValue("trimming", trimming);
			info.AddValue("wrap", wrap);
			info.AddValue("vertical", vertical);
			info.AddValue("readOnly", readOnly);
			info.AddValue("autoSize", autoSize);

			FontConverter fc = new FontConverter();
			info.AddValue("font", fc.ConvertToString(font));

			// Get the set of serializable members for our class and base classes
			Type thisType = typeof(LabelElement);
			MemberInfo[] mi = FormatterServices.GetSerializableMembers(thisType, context);

			// Serialize the base class's fields to the info object
			for (int i = 0 ; i < mi.Length; i++)
			{
				// Don't serialize fields for this class
				if (mi[i].DeclaringType == thisType) continue;
				info.AddValue(mi[i].Name, ((FieldInfo) mi[i]).GetValue(this));
			}
		}
示例#30
0
		protected LabelElement(SerializationInfo info, StreamingContext context)
		{

			// Get the set of serializable members for our class and base classes
			Type thisType = typeof(LabelElement);
			MemberInfo[] mi = FormatterServices.GetSerializableMembers(thisType, context);

			// Deserialize the base class's fields from the info object
			for (Int32 i = 0 ; i < mi.Length; i++) 
			{
				// Don't deserialize fields for this class
				if (mi[i].DeclaringType == thisType) continue;

				// To ease coding, treat the member as a FieldInfo object
				FieldInfo fi = (FieldInfo) mi[i];

				// Set the field to the deserialized value
				fi.SetValue(this, info.GetValue(fi.Name, fi.FieldType));
			}

			// Deserialize the values that were serialized for this class
			this.ForeColor1 = (Color) info.GetValue("foreColor1", typeof(Color));
			this.ForeColor2 = (Color) info.GetValue("foreColor2", typeof(Color));
			this.BackColor1 = (Color) info.GetValue("backColor1", typeof(Color));
			this.BackColor2 = (Color) info.GetValue("backColor2", typeof(Color));
			this.Text = info.GetString("text");
			this.Alignment = (StringAlignment) info.GetValue("alignment", typeof(StringAlignment));
			this.LineAlignment = (StringAlignment) info.GetValue("lineAlignment", typeof(StringAlignment));
			this.Trimming = (StringTrimming) info.GetValue("trimming", typeof(StringTrimming));
			this.Wrap = info.GetBoolean("wrap");
			this.Vertical = info.GetBoolean("vertical");
			this.ReadOnly = info.GetBoolean("readOnly");
			this.AutoSize = info.GetBoolean("autoSize");
			
			FontConverter fc = new FontConverter();
			this.Font = (Font) fc.ConvertFromString(info.GetString("font"));
			
		}
示例#31
0
		public void Deserialize(XmlNode node)
		{
			var converter = new FontConverter();

			foreach (XmlNode childNode in node.ChildNodes)
			{
				int tempInt;
				bool tempBool;
				switch (childNode.Name)
				{
					case "Name":
						_name = childNode.InnerText;
						break;
					case "ColumnOrder":
						if (int.TryParse(childNode.InnerText, out tempInt))
							_columnOrder = tempInt;
						break;
					case "BackgroundColor":
						if (int.TryParse(childNode.InnerText, out tempInt))
							_backgroundColor = Color.FromArgb(tempInt);
						break;
					case "ForeColor":
						if (int.TryParse(childNode.InnerText, out tempInt))
							_foreColor = Color.FromArgb(tempInt);
						break;
					case "HeaderFont":
						try
						{
							_headerFont = converter.ConvertFromString(childNode.InnerText) as Font;
						}
						catch { }
						break;
					case "EnableText":
						if (bool.TryParse(childNode.InnerText, out tempBool))
							_enableText = tempBool;
						break;
					case "HeaderAligment":
						if (int.TryParse(childNode.InnerText, out tempInt))
							_headerAlignment = (Alignment)tempInt;
						break;
					case "EnableWidget":
						if (bool.TryParse(childNode.InnerText, out tempBool))
							_enableWidget = tempBool;
						break;
					case "Widget":
						if (!string.IsNullOrEmpty(childNode.InnerText))
							_widget = new Bitmap(new MemoryStream(Convert.FromBase64String(childNode.InnerText)));
						break;
					case "BannerProperties":
						BannerProperties.Deserialize(childNode);
						break;
					case "LastChanged":
						DateTime tempDateTime;
						if (DateTime.TryParse(childNode.InnerText, out tempDateTime))
							_lastChanged = tempDateTime;
						break;
				}
			}
		}
示例#32
0
        //----------------------------------------------------------------------
        // TODO: OpenFile [ .mdファイルを開く ]
        //----------------------------------------------------------------------
        private bool OpenFile(string FilePath)
        {
            //引数 FilePath = "" の場合は「無題」編集で開始する

            if (FilePath == "")
            {
                fNoTitle = true;  //無題フラグON
            }
            else
            {
                fNoTitle = false;
            }

            //-----------------------------------
            //編集中のファイルがある
            if (richTextBox1.Modified == true)
            {
                DialogResult ret = MessageBox.Show(
                    "編集中のファイルがあります。保存してか らファイルを開きますか?",
                    "問い合わせ", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

                if (ret == DialogResult.Yes)
                {
                    if (SaveToEditingFile() == false)
                    {
                        //キャンセルで抜けてきた
                        return (false);
                    }
                }
                else if (ret == DialogResult.Cancel)
                {
                    return (false);
                }

                //編集履歴に残す
                foreach (AppHistory data in MarkDownSharpEditor.AppSettings.Instance.ArrayHistoryEditedFiles)
                {
                    if (data.md == MarkDownTextFilePath)
                    {   //いったん削除して
                        MarkDownSharpEditor.AppSettings.Instance.ArrayHistoryEditedFiles.Remove(data);
                        break;
                    }
                }
                AppHistory HistroyData = new AppHistory();
                HistroyData.md = MarkDownTextFilePath;
                HistroyData.css = SelectedCssFilePath;
                MarkDownSharpEditor.AppSettings.Instance.ArrayHistoryEditedFiles.Insert(0, HistroyData);	//先頭に挿入
            }

            //-----------------------------------
            //オープンダイアログ表示
            if (fNoTitle == false && File.Exists(FilePath) == false)
            {
                if (File.Exists(MarkDownTextFilePath) == true)
                {	//編集中のファイルがあればそのディレクトリを初期フォルダーに
                    openFileDialog1.InitialDirectory = Path.GetDirectoryName(MarkDownTextFilePath);
                    //テンポラリファイルがあればここで削除
                    DeleteTemporaryHtmlFilePath();
                }
                openFileDialog1.FileName = "";
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    FilePath = openFileDialog1.FileName;
                }
                else
                {
                    return (false);
                }
            }

            //編集中のファイルパスとする
            MarkDownTextFilePath = FilePath;

            //-----------------------------------
            //文字コードを調査するためにテキストファイルを開く
            if (fNoTitle ==  false)
            {
                byte[] bs;
                using (FileStream fs = new FileStream(FilePath, FileMode.Open, FileAccess.Read))
                {
                    bs = new byte[fs.Length];
                    fs.Read(bs, 0, bs.Length);
                }
                //文字コードを取得する
                EditingFileEncoding = GetCode(bs);
            }
            else
            {
                //「無題」はデフォルトのエンコーディング
                EditingFileEncoding = Encoding.UTF8;
            }

            //ステータスバーに表示
            toolStripStatusLabelTextEncoding.Text = EditingFileEncoding.EncodingName;
            //編集中のエンコーディングを使用する(&D)か
            if (MarkDownSharpEditor.AppSettings.Instance.HtmlEncodingOption == 0)
            {
                toolStripStatusLabelHtmlEncoding.Text = EditingFileEncoding.EncodingName;
            }

            //-----------------------------------
            //ペアとなるCSSファイルがあるか探索してあれば適用する
            foreach (AppHistory data in MarkDownSharpEditor.AppSettings.Instance.ArrayHistoryEditedFiles)
            {
                if (data.md == MarkDownTextFilePath)
                {
                    if (File.Exists(data.css) == true)
                    {
                        SelectedCssFilePath = data.css;
                        break;
                    }
                }
            }

            //選択中のCSSファイル名をステータスバーに表示
            if (File.Exists(SelectedCssFilePath) == true)
            {
                toolStripStatusLabelCssFileName.Text = Path.GetFileName(SelectedCssFilePath);
            }
            else
            {
                toolStripStatusLabelCssFileName.Text = "CSSファイル指定なし";
            }

            //-----------------------------------
            //RichEditBoxに表示
            fConstraintChange = true;
            richTextBox1.Clear();

            //RichEditBoxの「フォント」設定
            var obj = MarkDownSharpEditor.AppSettings.Instance;
            FontConverter fc = new FontConverter();
            try { richTextBox1.Font = (Font)fc.ConvertFromString(obj.FontFormat); }
            catch { }
            //RichEditBoxの「フォントカラー」設定
            richTextBox1.ForeColor = Color.FromArgb(obj.richEditForeColor);
            //ステータスバーに表示
            toolStripStatusLabelFontInfo.Text =	richTextBox1.Font.Name + "," + richTextBox1.Font.Size.ToString() + "pt";

            //-----------------------------------
            //テキストファイルの読み込み
            if (fNoTitle == false)
            {
                richTextBox1.Text = File.ReadAllText(FilePath, EditingFileEncoding);
            }
            richTextBox1.BeginUpdate();
            richTextBox1.SelectionStart = richTextBox1.Text.Length;
            richTextBox1.ScrollToCaret();
            //richTextBox1の全高さを求める
            richEditBoxInternalHeight = richTextBox1.VerticalPosition;
            //カーソル位置を戻す
            richTextBox1.SelectionStart = 0;
            richTextBox1.EndUpdate();

            //変更フラグOFF
            richTextBox1.Modified = false;

            //Undoバッファに追加
            undoCounter = 0;
            UndoBuffer.Clear();
            UndoBuffer.Add(richTextBox1.Text.ToString());

            //シンタックスハイライター
            SyntaxHightlighterWidthRegex();
            //プレビュー更新
            PreviewToBrowser();

            fConstraintChange = false;
            FormTextChange();

            return (true);
        }
示例#33
-1
        private void buttonChangeFont_Click(object sender, EventArgs e)
        {
            FontDialog d = new FontDialog();
            FontConverter fc = new FontConverter();

            d.Font = (Font)fc.ConvertFromString(textBoxFont.Text);

            if (d.ShowDialog() == DialogResult.OK)
            {
                textBoxFont.Text = fc.ConvertToString(d.Font);
            }
        }
示例#34
-1
        public bool EditValue(IWin32Window owner, XmlSchemaType type, string input, out string output)
        {
            output = input;
            FontConverter fc = new FontConverter();
            Font f = null;
            try {
                f = (Font)fc.ConvertFromString(input);
                fd.Font = f;
            } catch {
            }

            if (fd.ShowDialog(owner) == DialogResult.OK) {
                output = fc.ConvertToString(fd.Font);
                return true;
            } else {
                return false;
            }
        }