コード例 #1
0
        private GradientFill FromString(object value)
        {
            string[] values = ((string)value).Split(',');
            if (values.Length != 3)
                throw new ArgumentException("Could not convert the value");

            try
            {
                GradientFill gradient = new GradientFill();

                ColorConverter converter = new ColorConverter();
                
                gradient.ColorA = (Color)converter.ConvertFromString(values[0]);
                gradient.ColorB = (Color)converter.ConvertFromString(values[1]);

                // Convert the name of the enumerated value into the corresponding
                // enumerated value (which is actually an integer constant).
                gradient.GradientFillStyle = (LinearGradientMode)Enum.Parse(
                  typeof(LinearGradientMode), values[2], true);

                return gradient;
            }
            catch
            {
                throw new ArgumentException("Could not convert the value");
            }
        }
コード例 #2
0
ファイル: frmOptions.cs プロジェクト: 100009/hberp
        public static Color ConvertColor(string colorstr, Color defcolor)
        {
            if (string.IsNullOrEmpty(colorstr))
            {
                return(defcolor);
            }
            Color retcolor = new Color();

            System.Drawing.ColorConverter colConvert = new System.Drawing.ColorConverter();
            try
            {
                retcolor = (Color)colConvert.ConvertFromString("#" + colorstr);
            }
            catch
            {
                try
                {
                    retcolor = (Color)colConvert.ConvertFromString(colorstr);
                }
                catch
                {
                    retcolor = defcolor;
                }
            }
            return(retcolor);
        }
コード例 #3
0
        private GradientTab FromString(object value)
        {
            var result = ((string)value).Split(',');
            if (result.Length != 6)
                throw new ArgumentException("Could not convert to value");

            try
            {
                var gradient = new GradientTab();

                // Retrieve the colors
                var converter = new ColorConverter();
                gradient.ColorStart = (Color)converter.ConvertFromString(result[0]);
                gradient.ColorEnd = (Color)converter.ConvertFromString(result[1]);
                gradient.GradientStyle = (LinearGradientMode)Enum.Parse(typeof(LinearGradientMode), result[2], true);
                gradient.TabPageTextColor = (Color)converter.ConvertFromString(result[3]);
                gradient.TabPageSelectedTextColor = (Color)converter.ConvertFromString(result[4]);
                gradient.SelectedTabFontStyle = (FontStyle)Enum.Parse(typeof(FontStyle), result[5], true);

                return gradient;
            }
            catch (Exception)
            {
                throw new ArgumentException("Could not convert to value");
            }
        }
        private ButtonsCaption FromString(object value)
        {
            var result = ((string)value).Split(',');
            if (result.Length != 2)
                throw new ArgumentException("Could not convert to value");

            try
            {
                var buttons = new ButtonsCaption();

                // Retrieve the colors
                var converter = new ColorConverter();
                var resultColor0 = converter.ConvertFromString(result[0]);
                if (resultColor0 != null)
                    buttons.ActiveCaptionButtonsColor = (Color)resultColor0;
                var resultColor1 = converter.ConvertFromString(result[1]);
                if (resultColor1 != null)
                    buttons.InactiveCaptionButtonsColor = (Color)resultColor1;

                return buttons;
            }
            catch (Exception)
            {
                throw new ArgumentException("Could not convert to value");
            }
        }
コード例 #5
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);
        }
コード例 #6
0
ファイル: ThresholdDataSet.cs プロジェクト: wshanshan/DDD
        public ThresholdDataSet(IController controller, Int32 configurationID)
        {
            organizationData = new ThresholdData("Organization");
            roleData = new ThresholdData("Role"); 
            billetData = new ThresholdData("Billet"); 
            informationProductData = new ThresholdData("Information Product"); 
            activityData = new ThresholdData("Activity");
            thresholdData = new ThresholdData[] { organizationData, roleData, billetData, informationProductData, activityData };
            
            XPathNodeIterator thresholds = controller.GetComponentAndChildren(configurationID, "Configuration", new ComponentOptions()).CreateNavigator().Select("/Components/Component/Component[@Type='Threshold']");
            if (thresholds.Count != 0)
            {
                ColorConverter cv = new ColorConverter();
                String baseString = "ComponentParameters/Parameter[@category='Threshold']/Parameter[@displayedName='";
                foreach (XPathNavigator threshold in thresholds)
                {
                    String name = threshold.GetAttribute("Name", "");
                    Double _lv = Double.Parse(threshold.SelectSingleNode(baseString + "LowerThresholdValue']/@value").ToString());
                    Double _mv1 = Double.Parse(threshold.SelectSingleNode(baseString + "MiddleThresholdValue1']/@value").ToString());
                    Double _mv2 = Double.Parse(threshold.SelectSingleNode(baseString + "MiddleThresholdValue2']/@value").ToString());
                    Double _uv = Double.Parse(threshold.SelectSingleNode(baseString + "UpperThresholdValue']/@value").ToString());
                    Boolean _lowerCheck = Boolean.Parse(threshold.SelectSingleNode(baseString + "LowerThresholdValueIsEqual']/@value").ToString());
                    Boolean _middleCheck1 = Boolean.Parse(threshold.SelectSingleNode(baseString + "MiddleThresholdValue1IsEqual']/@value").ToString());
                    Boolean _middleCheck2 = Boolean.Parse(threshold.SelectSingleNode(baseString + "MiddleThresholdValue2IsEqual']/@value").ToString());
                    Boolean _upperCheck = Boolean.Parse(threshold.SelectSingleNode(baseString + "UpperThresholdValueIsEqual']/@value").ToString());
                    Color _lowerColor = (Color)cv.ConvertFromString(threshold.SelectSingleNode(baseString + "LowerThresholdColor']/@value").ToString());
                    Color _middleColor = (Color)cv.ConvertFromString(threshold.SelectSingleNode(baseString + "MiddleThresholdColor']/@value").ToString());
                    Color _upperColor = (Color)cv.ConvertFromString(threshold.SelectSingleNode(baseString + "UpperThresholdColor']/@value").ToString());
                    bool found = false;
                    for(int i = 0; i < thresholdData.Length; i++)
                    {
                        ThresholdData data = thresholdData[i];
                        if (data.Name.Equals(name))
                        {
                            found = true;
                            data.LowerValue = _lv;
                            data.MiddleValue1 = _mv1;
                            data.MiddleValue2 = _mv2;
                            data.UpperValue = _uv;

                            data.LowerCheck = _lowerCheck;
                            data.MiddleCheck1 = _middleCheck1;
                            data.MiddleCheck2 = _middleCheck2;
                            data.UpperCheck = _upperCheck;

                            data.LowerColor = _lowerColor;
                            data.MiddleColor = _middleColor;
                            data.UpperColor = _upperColor;
                        }
                    }
                    if (!found)
                    {
                        throw new Exception("Could not find threshold data: " + name);
                    }
                }
            }
        }
コード例 #7
0
ファイル: Matcher.cs プロジェクト: bleemus/YATP
        public Matcher(string mS)
        {
            var array = mS.Split(new[] { ";;" }, StringSplitOptions.None);

            Enabled = bool.Parse(array[0]);
            Name = array[1];

            var cc = new ColorConverter();
            BackColor = (Color)cc.ConvertFromString(array[2]);
            ForeColor = (Color)cc.ConvertFromString(array[3]);

            Expression = array[4];
        }
コード例 #8
0
ファイル: SquareDetector.cs プロジェクト: TheInvoker/Card
        public static List<Shape> GetShapeFromPoints(List<List<int>> points, string hexcolor, int width, int height, string outName)
        {
            List<Pixel> square = new List<Pixel>();
            ColorConverter cc = new ColorConverter();
            Color color = (Color) cc.ConvertFromString(hexcolor);

            Point p0 = new Point(points.ElementAt(0).ElementAt(0), points.ElementAt(0).ElementAt(1));
            Point p1 = new Point(points.ElementAt(1).ElementAt(0), points.ElementAt(1).ElementAt(1));
            Point p2 = new Point(points.ElementAt(2).ElementAt(0), points.ElementAt(2).ElementAt(1));
            Point p3 = new Point(points.ElementAt(3).ElementAt(0), points.ElementAt(3).ElementAt(1));

            Pixel[] corners = new Pixel[4];
            corners[0] = new Pixel(color, p0.X, p0.Y);
            corners[1] = new Pixel(color, p1.X, p1.Y);
            corners[2] = new Pixel(color, p2.X, p2.Y);
            corners[3] = new Pixel(color, p3.X, p3.Y);

            for (int x=0; x< width; x+=1)
            {
                for(int y=0;y< height;y+=1)
                {
                    if (PointChecker.PointInQuad(new Point(x, y), p0, p1, p2, p3))
                    {
                        square.Add(new Pixel(color, x, y));
                    }
                }
            }

            Shape shape = new Shape(square, corners);
            return new List<Shape>() { shape };
        }
コード例 #9
0
        private static void OutPut(string text = null, string foregroundColor = null, string backgroundColor = null)
        {
            Func<string, Color> getColor = (s) =>
            {
                var colorConverter = new ColorConverter();
                return (Color)colorConverter.ConvertFromString(s);
            };

            Predicate<string> notNullofEmpty = x => !string.IsNullOrEmpty(x);

            if (notNullofEmpty(backgroundColor))
            {
                ColorSetter.BackgroundColor = getColor(backgroundColor);
            }
            if (notNullofEmpty(foregroundColor))
            {
                ColorSetter.ForegroundColor = getColor(foregroundColor);
            }
            if (notNullofEmpty(text))
            {
                Console.Write(text);
            }

            ColorSetter.BackgroundColor = getColor(GameConfig.ColorStrings[0]);
        }
コード例 #10
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            if (reader.IsEmptyElement) { return; }

            ColorConverter cconv = new ColorConverter();
            if (reader.NodeType != System.Xml.XmlNodeType.EndElement) {
                this._color = (Color)cconv.ConvertFromString(reader.ReadString());
            }
            reader.MoveToContent();
            reader.ReadEndElement();
        }
コード例 #11
0
        /// <summary>
        /// 获取验证码图片
        /// </summary>
        /// <param name="checkCode">验证码</param>
        /// <returns></returns>
        public System.IO.MemoryStream CreateImage(string checkCode)
        {
            int iwidth = (int)(checkCode.Length * 12);
            ColorConverter colConvert = new ColorConverter();
            System.Drawing.Bitmap image = new System.Drawing.Bitmap(iwidth, 20);
            Graphics g = Graphics.FromImage(image);
            Font f = new System.Drawing.Font("Arial", 10, System.Drawing.FontStyle.Bold);
            Brush b = new System.Drawing.SolidBrush((Color)colConvert.ConvertFromString("#FFFFFF"));

            Color color = (System.Drawing.Color)colConvert.ConvertFromString("#315CA1");
            g.Clear(color);
            g.DrawString(checkCode, f, b, 3, 3);

            Pen blackPen = new Pen(Color.Red, 0);
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
            g.Dispose();
            image.Dispose();
            return ms;
        }
コード例 #12
0
ファイル: Common.cs プロジェクト: ZixiangBoy/YongERP
 /// <summary>
 /// 字符串转颜色
 /// </summary>
 /// <param name="colorString"></param>
 /// <returns></returns>
 public static Color GetColorFromString(string colorString)
 {
     Color color = Color.Empty;
     ColorConverter converter = new ColorConverter();
     //try
     //{
     color = (Color)converter.ConvertFromString(colorString);
     //}
     //catch
     //{ }
     return color;
 }
コード例 #13
0
ファイル: ColorString.cs プロジェクト: nebtrx/sidewired
 private Color ConvertToColor(string colorString)
 {
     try
     {
         var colorConverter = new ColorConverter();
         return (Color) colorConverter.ConvertFromString(colorString);
     }
     catch (Exception)
     {
         throw new InvalidCastException("String provided is not in a recognized Hex format.");
     }
 }
        private CaptionGradient FromString(object value)
        {
            string[] result = ((string)value).Split(',');
            if (result.Length != 8)
                throw new ArgumentException("Could not convert to value");

            try
            {
                CaptionGradient gradient = new CaptionGradient();

                // Retrieve the colors
                ColorConverter converter = new ColorConverter();
                gradient.ActiveCaptionColorStart = (Color)converter.ConvertFromString(result[0]);
                gradient.ActiveCaptionColorEnd = (Color)converter.ConvertFromString(result[1]);
                gradient.InactiveCaptionColorStart = (Color)converter.ConvertFromString(result[2]);
                gradient.InactiveCaptionColorEnd = (Color)converter.ConvertFromString(result[3]);
                gradient.CaptionGradientStyle = (LinearGradientMode)Enum.Parse(typeof(LinearGradientMode), result[4], true);
                gradient.InactiveCaptionTextColor = (Color)converter.ConvertFromString(result[5]);
                gradient.ActiveCaptionTextColor = (Color)converter.ConvertFromString(result[6]);
                gradient.ActiveCaptionFontStyle = (FontStyle)Enum.Parse(typeof(FontStyle), result[7], true);

                return gradient;
            }
            catch (Exception)
            {
                throw new ArgumentException("Could not convert to value");
            }
        }
コード例 #15
0
ファイル: SSAReader.cs プロジェクト: jesszgc/VideoConvert
        public static Color GetCorrectColor(string input)
        {
            ColorConverter converter = new ColorConverter();
            object fromString = converter.ConvertFromString(input);
            if (fromString == null) return Color.Black;

            Color converted = (Color) fromString;
            if (converted.A == 0)
            {
                converted = Color.FromArgb(255, converted);
            }
            return Color.FromArgb(converted.A, converted.B, converted.G, converted.R);
        }
コード例 #16
0
        public void ColorListView()
        {
            ColorConverter c = new ColorConverter();

            //lstVw_ActorsList.BackColor = Color.Ivory;
            //lstVw_ActorsList.BackColor = Color.Lavender;
            lstVw_ActorsList.ForeColor = (Color)c.ConvertFromString("#333333");
            for (int i = 0; i < lstVw_ActorsList.Items.Count; i++)
            {
                //if (i % 2 == 0)
                //{
                //    lstVw_ActorsList.Items[i].BackColor = (Color)c.ConvertFromString("#dedeff");
                //}
                //else
                //{
                //    lstVw_ActorsList.Items[i].BackColor = (Color)c.ConvertFromString("#bfbff7");
                //}
                if (lstVw_ActorsList.Items[i].SubItems[10].Text == "Deactivated")
                {
                    //Use of gray color.
                    lstVw_ActorsList.Items[i].BackColor = (Color)c.ConvertFromString("#dadada");
                }
            }
        }
コード例 #17
0
        private Hatcher FromString(object value)
        {
            string[] result = ((string)value).Split(',');
            if (result.Length != 3)
                throw new ArgumentException("Could not convert to value");

            try
            {
                Hatcher hatch = new Hatcher();

                // Retrieve the colors
                ColorConverter converter = new ColorConverter();

                hatch.ForeColor = (Color)converter.ConvertFromString(result[0]);
                hatch.BackColor = (Color)converter.ConvertFromString(result[1]);
                hatch.HatchStyle = result[2];

                return hatch;
            }
            catch (Exception)
            {
                throw new ArgumentException("Could not convert to value");
            }
        }
コード例 #18
0
ファイル: Program.cs プロジェクト: TheBritz/Sprite-Analyzer
        /// <summary>
        /// Extracts the individual parts of a color argument
        /// </summary>
        /// <param name="arg">The argument</param>
        /// <param name="name">The name of the analysis data</param>
        /// <param name="color">The color source of this analysis</param>
        /// <param name="analyzerDLL">The name of the analyzer component</param>
        private static void GetColorArgParts(string arg, out string name,
                                             out DRAW.Color color, out string analyzerDLL, out string analyzerID)
        {
            string colorStr = string.Empty;

            name        = string.Empty;
            analyzerDLL = string.Empty;
            analyzerID  = string.Empty;
            if (arg.ElementAt(0) == '-' && arg.Contains("=") && arg.Contains("|"))
            {
                //This argument contains a name for this color, get both
                string[] thisArgElements = arg.Split
                                               ("-=|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                name        = thisArgElements[0];
                colorStr    = thisArgElements[1];
                analyzerDLL = thisArgElements[2];
                analyzerID  = thisArgElements[3];
            }
            else
            {
                colorStr = arg;
            }

            //Try to instantiate the color from the raw color string in case
            //it's a name
            color = DRAW.Color.FromName(colorStr);

            //Instantiate a color converter
            DRAW.ColorConverter colConverter = new DRAW.ColorConverter();

            //Check if this is a valid color
            if (color.Equals(DRAW.Color.FromName("Invalid")))
            {
                //Sanitize color string
                if (colorStr.ElementAt(0) != '#')
                {
                    colorStr = "#" + colorStr;
                }

                color = (DRAW.Color)colConverter.ConvertFromString(colorStr);
            }
        }
コード例 #19
0
 public ICommand CreateCommand(string stringCommand)
 {
     _wordsBrushes = new List<SolidBrush>();
     var pattern = "colors:<.+>";
     var converter = new ColorConverter();
     if (!Regex.IsMatch(stringCommand, pattern))
         throw new Exception();
     stringCommand = stringCommand.Substring(8, stringCommand.Length - 9);
     var splited = stringCommand.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
     Color tempColor;
     foreach (var color in splited)
     {
         try
         {
             tempColor = (Color)converter.ConvertFromString(color);
         }
         catch (Exception)
         {
             throw new Exception("Can not convert" + color);
         }
         _wordsBrushes.Add(new SolidBrush(tempColor));
     }
     return this;
 }
コード例 #20
0
        /// <summary>
        /// 得到二维码
        /// </summary>
        /// <param name="qRCodeControl"></param>
        /// <param name="content">二维码内容</param>
        /// <param name="icon">二维码图标</param>
        /// <returns></returns>
        private static ImageSource GetQRCodeImage(QRCodeControl qrCodeControl)
        {
            System.Drawing.ColorConverter colorConverter = new System.Drawing.ColorConverter();
            using (QRCodeGenerator qrGenerator = new QRCodeGenerator())
            {
                using (QRCodeData qRCodeData = qrGenerator.CreateQrCode(qrCodeControl.QrCodeContent, QRCodeGenerator.ECCLevel.L))
                {
                    using (QRCode qrCode = new QRCode(qRCodeData))
                    {
                        Bitmap codeImage = qrCode.GetGraphic(
                            qrCodeControl.QrCodePixelsPerModule,
                            (System.Drawing.Color)colorConverter.ConvertFromString(qrCodeControl.Foreground.ToString()),
                            System.Drawing.Color.FromName(((SolidColorBrush)qrCodeControl.Background).Color.ToString()),
                            ImageBitmapConverter.ToBitmap(qrCodeControl.QrCodeIcon),
                            qrCodeControl.QrCodeIconSizePercent,
                            qrCodeControl.QrCodeIconBorderWidth);

                        qrCodeControl.QRCodeImage = ImageBitmapConverter.ToImageSource(codeImage);
                        //qrCodeControl.QRCodeImage = Imaging.CreateBitmapSourceFromHBitmap(codeImage.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                        return(qrCodeControl.QRCodeImage);
                    }
                }
            }
        }
コード例 #21
0
        public static void GetMsgBoard()
        {
            try
            {
                Thread.Sleep(500);

                using (MySqlConnection conn = new MySqlConnection(Connector.BarrierStringConnecting))
                {
                    conn.Open();

                    (Application.OpenForms[1] as AuthFormClassic).Invoke((MethodInvoker)(delegate() { MainFormClassic.msgdesk.ListViewMsg.Items.Clear(); }));

                    MySqlCommand cmd = new MySqlCommand("SELECT u.username,m.msg,m.msg_color,m.msg_datetime,m.msg_id FROM users u,message m WHERE u.id = m.userid ORDER BY m.msg_priority", conn);

                    using (MySqlDataReader dr = cmd.ExecuteReader())
                    {
                        if (dr == null || !dr.HasRows) { return; }

                        while (dr.Read())
                        {
                            Application.DoEvents();

                            string username = dr.GetString(0);
                            string msg = dr.GetString(1);
                            Color color = Color.FromName(dr.GetString(2));
                            UInt64 id_msg = dr.GetUInt64(4);

                            if (color.ToString().Contains("ff"))
                            {
                                ColorConverter colcon = new ColorConverter();

                                color = (Color)colcon.ConvertFromString("#" + color.Name);
                            }

                            DateTime datetime = dr.GetDateTime(3);

                            string _CompleteMsg = id_msg + ": [" + datetime.ToString("dd.MM") + "] [" + datetime.ToShortTimeString() + "] " + " [" + username + "] " + msg;

                            if (_CompleteMsg.Length > 115 && _CompleteMsg.Length <= 230)
                            {
                                string part1 = _CompleteMsg.Substring(0, 115);
                                string part2 = _CompleteMsg.Substring(115, _CompleteMsg.Length - 115);

                                (Application.OpenForms[1] as AuthFormClassic).Invoke((MethodInvoker)(delegate() {
                                    MainFormClassic.msgdesk.ListViewMsg.Items.Add(part1); MainFormClassic.msgdesk.ListViewMsg.Items[MainFormClassic.msgdesk.ListViewMsg.Items.Count - 1].ForeColor = color;
                                    MainFormClassic.msgdesk.ListViewMsg.Items.Add(part2); MainFormClassic.msgdesk.ListViewMsg.Items[MainFormClassic.msgdesk.ListViewMsg.Items.Count - 1].ForeColor = color;

                                }));

                                continue;
                            }

                            if (_CompleteMsg.Length > 230 && _CompleteMsg.Length <= 345)
                            {
                                string part1 = _CompleteMsg.Substring(0, 115);
                                string part2 = _CompleteMsg.Substring(115, 115);
                                string part3 = _CompleteMsg.Substring(230, _CompleteMsg.Length - 230);

                                (Application.OpenForms[1] as AuthFormClassic).Invoke((MethodInvoker)(delegate() {
                                    MainFormClassic.msgdesk.ListViewMsg.Items.Add(part1); MainFormClassic.msgdesk.ListViewMsg.Items[MainFormClassic.msgdesk.ListViewMsg.Items.Count - 1].ForeColor = color;
                                    MainFormClassic.msgdesk.ListViewMsg.Items.Add(part2); MainFormClassic.msgdesk.ListViewMsg.Items[MainFormClassic.msgdesk.ListViewMsg.Items.Count - 1].ForeColor = color;
                                    MainFormClassic.msgdesk.ListViewMsg.Items.Add(part3); MainFormClassic.msgdesk.ListViewMsg.Items[MainFormClassic.msgdesk.ListViewMsg.Items.Count - 1].ForeColor = color;

                                }));

                                continue;
                            }

                            if (_CompleteMsg.Length > 345 && _CompleteMsg.Length <= 460)
                            {
                                string part1 = _CompleteMsg.Substring(0, 115);
                                string part2 = _CompleteMsg.Substring(115, 115);
                                string part3 = _CompleteMsg.Substring(230, 115);
                                string part4 = _CompleteMsg.Substring(345, _CompleteMsg.Length - 345);

                                (Application.OpenForms[1] as AuthFormClassic).Invoke((MethodInvoker)(delegate() {
                                     MainFormClassic.msgdesk.ListViewMsg.Items.Add(part1); MainFormClassic.msgdesk.ListViewMsg.Items[MainFormClassic.msgdesk.ListViewMsg.Items.Count - 1].ForeColor = color;
                                     MainFormClassic.msgdesk.ListViewMsg.Items.Add(part2); MainFormClassic.msgdesk.ListViewMsg.Items[MainFormClassic.msgdesk.ListViewMsg.Items.Count - 1].ForeColor = color;
                                     MainFormClassic.msgdesk.ListViewMsg.Items.Add(part3); MainFormClassic.msgdesk.ListViewMsg.Items[MainFormClassic.msgdesk.ListViewMsg.Items.Count - 1].ForeColor = color;
                                     MainFormClassic.msgdesk.ListViewMsg.Items.Add(part4); MainFormClassic.msgdesk.ListViewMsg.Items[MainFormClassic.msgdesk.ListViewMsg.Items.Count - 1].ForeColor = color;

                               }));

                                continue;
                            }

                            if (_CompleteMsg.Length < 115)
                            {
                                (Application.OpenForms[1] as AuthFormClassic).Invoke((MethodInvoker)(delegate() {
                                    MainFormClassic.msgdesk.ListViewMsg.Items.Add(_CompleteMsg);
                                    MainFormClassic.msgdesk.ListViewMsg.Items[MainFormClassic.msgdesk.ListViewMsg.Items.Count - 1].ForeColor = color;
                                }));
                                continue;
                            }
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
                Log.ExcWrite("[GetMsgBoard] " + exc.Message);
            }
        }
コード例 #22
0
ファイル: Form1.cs プロジェクト: andrew-x/COBWEB-3D
        public void OpenFilepro_FileOk(System.Object sender, System.ComponentModel.CancelEventArgs e)
        {
            System.IO.StreamReader objreader = new System.IO.StreamReader(OpenFilepro.FileName);
            save = objreader.ReadToEnd();
            objreader.Close();

            string[] import = new string[401];
            int n;

            for (var i = 1; i <= 400; i++)
            {
                n = 0;
                while (!(save.Substring(n, 1) == "_"))
                {
                    n++;
                    import[i] = save.Substring(0, n);
                }
                if (save.Substring(n + 1, 1) == "|")
                {
                    break;
                }
                save = save.Substring(System.Convert.ToInt32(1 + n));
            }

            //....

            xn = int.Parse(import[1]);
            yn = int.Parse(import[2]);
            zn = int.Parse(import[3]);
            agent = int.Parse(import[4]);

            float ratio1 = yn / xn;
            float ratio2 = zn / xn;
            float ratio3 = yn / zn;
            int res = 2073600;

            sizexyx = System.Convert.ToInt32(Math.Pow((res / ratio1), 0.5));
            sizexyy = System.Convert.ToInt32(ratio1 * sizexyx);

            sizexzx = System.Convert.ToInt32(Math.Pow((res / ratio2), 0.5));
            sizexzz = System.Convert.ToInt32(ratio2 * sizexzx);

            sizezyz = System.Convert.ToInt32(Math.Pow((res / ratio3), 0.5));
            sizezyy = System.Convert.ToInt32(ratio3 * sizezyz);

            cellxyx = sizexyx / xn;
            cellxyy = sizexyy / yn;

            cellxzx = sizexzx / xn;
            cellxzz = sizexzz / zn;

            cellzyz = sizezyz / zn;
            cellzyy = sizezyy / yn;

            generator.Default.Close();
            generator.Default.Show();

            SizeToolStripMenuItem.Enabled = true;
            AIToolStripMenuItem.Enabled = true;
            collisionToolStripMenuItem.Enabled = true;

            //....

            int lastimport = System.Convert.ToInt32(0);

            for (var i = 1; i <= agent; i++)
            {
                lastimport = System.Convert.ToInt32(4 + i);
                generator.Default.agentname[i] = import[lastimport];
            }

            for (var i = 1; i <= agent; i++)
            {
                lastimport++;
                generator.Default.agentcount[i] = int.Parse(import[lastimport]);
            }

            for (var i = 1; i <= agent; i++)
            {
                lastimport++;
                generator.Default.initialenergy[i] = int.Parse(import[lastimport]);
            }

            for (var i = 1; i <= agent; i++)
            {
                lastimport++;
                generator.Default.stepenergy[i] = int.Parse(import[lastimport]);
            }

            for (var i = 1; i <= agent; i++)
            {
                lastimport++;
                generator.Default.bumpenergy[i] = int.Parse(import[lastimport]);
            }

            for (var i = 1; i <= agent; i++)
            {
                lastimport++;
                generator.Default.aging[i] = bool.Parse(import[lastimport]);
            }

            for (var i = 1; i <= agent; i++)
            {
                lastimport++;
                generator.Default.agelimit[i] = int.Parse(import[lastimport]);
            }

            for (var i = 1; i <= agent; i++)
            {
                lastimport++;
                generator.Default.asr[i] = bool.Parse(import[lastimport]);
            }

            for (var i = 1; i <= agent; i++)
            {
                lastimport++;
                generator.Default.asrtime[i] = int.Parse(import[lastimport]);
            }

            for (var i = 1; i <= agent; i++)
            {
                lastimport++;
                generator.Default.asrenergy[i] = int.Parse(import[lastimport]);
            }

            for (var i = 1; i <= agent; i++)
            {
                lastimport++;
                System.Drawing.ColorConverter colourconverter = new System.Drawing.ColorConverter();
                generator.Default.agentcolour[i] =  (System.Drawing.Color) (colourconverter.ConvertFromString(import[lastimport]));
            }

            for (var i = 1; i <= agent; i++)
            {
                lastimport++;
                generator.Default.agentrangeabsolute[i] = bool.Parse(import[lastimport]);
            }

            for (var a = 1; a <= agent; a++)
            {
                for (var b = 0; b <= 2; b++)
                {
                    for (var c = 0; c <= 1; c++)
                    {
                        lastimport++;
                        generator.Default.agentrange[a, b, c] = int.Parse(import[lastimport]);
                    }
                }
            }

            for (var a = 1; a <= agent; a++)
            {
                for (var b = 1; b <= agent; b++)
                {
                    for (var c = 1; c <= 6; c++)
                    {
                        lastimport++;
                        generator.Default.action[a, b, c] = int.Parse(import[lastimport]);
                    }
                }
            }

            //........applying the setting..............
            VBMath.Randomize();
            total = 0;

            int number = System.Convert.ToInt32(0);
            for (var a = 1; a <= agent; a++)
            {
                for (var i = 1; i <= generator.Default.agentcount[a]; i++)
                {
                    number++;
                    int x = (System.Convert.ToInt32(Math.Floor(System.Convert.ToDecimal((xn) * VBMath.Rnd())))) + 1;
                    int y = (System.Convert.ToInt32(Math.Floor(System.Convert.ToDecimal((yn) * VBMath.Rnd())))) + 1;
                    int z = (System.Convert.ToInt32(Math.Floor(System.Convert.ToDecimal((zn) * VBMath.Rnd())))) + 1;

                    int dx;
                    int dy;
                    int dz;

                    int rangexupper = generator.Default.agentrange[a, 0, 1];
                    int rangexlower = generator.Default.agentrange[a, 0, 0];
                    int rangeyupper = generator.Default.agentrange[a, 1, 1];
                    int rangeylower = generator.Default.agentrange[a, 1, 0];
                    int rangezupper = generator.Default.agentrange[a, 2, 1];
                    int rangezlower = generator.Default.agentrange[a, 2, 0];

                    dx = (System.Convert.ToInt32(Math.Floor(System.Convert.ToDecimal((rangexupper - rangexlower + 1) * VBMath.Rnd())))) + rangexlower;
                    dy = (System.Convert.ToInt32(Math.Floor(System.Convert.ToDecimal((rangeyupper - rangeylower + 1) * VBMath.Rnd())))) + rangeylower;
                    dz = (System.Convert.ToInt32(Math.Floor(System.Convert.ToDecimal((rangezupper - rangezlower + 1) * VBMath.Rnd())))) + rangezlower;

                    while (generator.Default.occupied[x, y, z] == true)
                    {
                        x = (System.Convert.ToInt32(Math.Floor(System.Convert.ToDecimal((xn) * VBMath.Rnd())))) + 1;
                        y = (System.Convert.ToInt32(Math.Floor(System.Convert.ToDecimal((yn) * VBMath.Rnd())))) + 1;
                        z = (System.Convert.ToInt32(Math.Floor(System.Convert.ToDecimal((zn) * VBMath.Rnd())))) + 1;
                    }

                    generator.Default.occupied[x, y, z] = true;

                    int d = (System.Convert.ToInt32(Math.Floor(System.Convert.ToDecimal((6) * VBMath.Rnd())))) + 1;
                    generator.Default.agentlocation[number, 0] = x;
                    generator.Default.agentlocation[number, 1] = y;
                    generator.Default.agentlocation[number, 2] = z;
                    generator.Default.agentlocation[number, 3] = d;
                    generator.Default.agentlocation[number, 4] = System.Convert.ToInt32(a);
                    generator.Default.agentlocation[number, 5] = dx;
                    generator.Default.agentlocation[number, 6] = dy;
                    generator.Default.agentlocation[number, 7] = dz;
                    generator.Default.agentlocation[number, 8] = generator.Default.initialenergy[a];
                    generator.Default.agentlocation[number, 9] = 0;
                    generator.Default.agentlocation[number, 10] = 0;

                }

            }

            //...........................................................................................................

            for (var i = 1; i <= agent; i++)
            {
                total = total + generator.Default.agentcount[i];
            }

            for (var index = 2; index <= total; index++)
            {
                int tempz = generator.Default.agentlocation[index, 2];
                int tempx = generator.Default.agentlocation[index, 0];
                int tempy = generator.Default.agentlocation[index, 1];
                int tempd = generator.Default.agentlocation[index, 3];
                int tempa = generator.Default.agentlocation[index, 4];

                int tempdx = generator.Default.agentlocation[index, 5];
                int tempdy = generator.Default.agentlocation[index, 6];
                int tempdz = generator.Default.agentlocation[index, 7];

                int tempenergy = generator.Default.agentlocation[index, 8];
                int tempage = generator.Default.agentlocation[index, 9];
                int tempasr = generator.Default.agentlocation[index, 10];

                int previousposition = System.Convert.ToInt32(index - 1);
                while (tempz > generator.Default.agentlocation[previousposition, 2] && previousposition >= 1)
                {
                    generator.Default.agentlocation[previousposition + 1, 0] = generator.Default.agentlocation[previousposition, 0];
                    generator.Default.agentlocation[previousposition + 1, 1] = generator.Default.agentlocation[previousposition, 1];
                    generator.Default.agentlocation[previousposition + 1, 2] = generator.Default.agentlocation[previousposition, 2];
                    generator.Default.agentlocation[previousposition + 1, 3] = generator.Default.agentlocation[previousposition, 3];
                    generator.Default.agentlocation[previousposition + 1, 4] = generator.Default.agentlocation[previousposition, 4];

                    generator.Default.agentlocation[previousposition + 1, 5] = generator.Default.agentlocation[previousposition, 5];
                    generator.Default.agentlocation[previousposition + 1, 6] = generator.Default.agentlocation[previousposition, 6];
                    generator.Default.agentlocation[previousposition + 1, 7] = generator.Default.agentlocation[previousposition, 7];

                    generator.Default.agentlocation[previousposition + 1, 8] = generator.Default.agentlocation[previousposition, 8];
                    generator.Default.agentlocation[previousposition + 1, 9] = generator.Default.agentlocation[previousposition, 9];
                    generator.Default.agentlocation[previousposition + 1, 10] = generator.Default.agentlocation[previousposition, 10];

                    previousposition--;
                }
                generator.Default.agentlocation[previousposition + 1, 2] = tempz;
                generator.Default.agentlocation[previousposition + 1, 0] = tempx;
                generator.Default.agentlocation[previousposition + 1, 1] = tempy;
                generator.Default.agentlocation[previousposition + 1, 3] = tempd;
                generator.Default.agentlocation[previousposition + 1, 4] = tempa;

                generator.Default.agentlocation[previousposition + 1, 5] = tempdx;
                generator.Default.agentlocation[previousposition + 1, 6] = tempdy;
                generator.Default.agentlocation[previousposition + 1, 7] = tempdz;

                generator.Default.agentlocation[previousposition + 1, 8] = tempenergy;
                generator.Default.agentlocation[previousposition + 1, 9] = tempage;
                generator.Default.agentlocation[previousposition + 1, 10] = tempasr;

            }

            generator.Default.gfxxy.Clear(Color.White);
            generator.Default.gridxy();

            // placing the agents
            for (var i = 1; i <= total; i++)
            {
                int x = generator.Default.agentlocation[i, 0];
                int y = generator.Default.agentlocation[i, 1];
                int z = generator.Default.agentlocation[i, 2];
                int d = generator.Default.agentlocation[i, 3];
                int ag = generator.Default.agentlocation[i, 4];
                if (d == 1)
                {
                    creator(x.ToString(), y, z, "down", generator.Default.agentcolour[ag]);
                }
                else if (d == 2)
                {
                    creator(x.ToString(), y, z, "up", generator.Default.agentcolour[ag]);
                }
                else if (d == 3)
                {
                    creator(x.ToString(), y, z, "left", generator.Default.agentcolour[ag]);
                }
                else if (d == 4)
                {
                    creator(x.ToString(), y, z, "right", generator.Default.agentcolour[ag]);
                }
                else if (d == 5)
                {
                    creator(x.ToString(), y, z, "front", generator.Default.agentcolour[ag]);
                }
                else if (d == 6)
                {
                    creator(x.ToString(), y, z, "back", generator.Default.agentcolour[ag]);
                }
            }

            generator.Default.topgridxy();
            picshow();

            tick = 0;
        }
コード例 #23
0
 public void ConvertFromString_Name(string name)
 {
     var conv = new ColorConverter();
     var color = Color.FromName(name);
     Assert.Equal(color, (Color) conv.ConvertFromString(name));
 }
コード例 #24
0
ファイル: ThumbnailSetting.cs プロジェクト: hazychill/oog
        public static ThumbnailSettings Load(XmlDocument document)
        {
            Size size;
              InterpolationMode interpolationMode;
              Color backColor;
              ThreadPriority threadPriority;

              SizeConverter sizeConv = new SizeConverter();
              XmlElement sizeElem = document.SelectSingleNode("settings/thumbnail/size") as XmlElement;
              if (sizeElem != null) {
            try {
              size = (Size)sizeConv.ConvertFromString(sizeElem.GetAttribute("value"));
            }
            catch {
              size = DefaultSize;
            }
              }
              else {
            size = DefaultSize;
              }

              EnumConverter ipConv = new EnumConverter(typeof(InterpolationMode));
              XmlElement ipmodeElem = document.SelectSingleNode("settings/thumbnail/interpolationMode") as XmlElement;
              if (ipmodeElem != null) {
            try {
              interpolationMode = (InterpolationMode)ipConv.ConvertFromString(ipmodeElem.GetAttribute("value"));
            }
            catch {
              interpolationMode = DefaultInterpolationMode;
            }
              }
              else {
            interpolationMode = DefaultInterpolationMode;
              }

              ColorConverter colorConv = new ColorConverter();
              XmlElement bcolorElem = document.SelectSingleNode("settings/thumbnail/backColor") as XmlElement;
              if (bcolorElem != null) {
            try {
              backColor = (Color)colorConv.ConvertFromString(bcolorElem.GetAttribute("value"));
            }
            catch {
              backColor = DefaultBackColor;
            }
              }
              else {
            backColor = DefaultBackColor;
              }

              EnumConverter priorityConv = new EnumConverter(typeof(ThreadPriority));
              XmlElement priorityElem = document.SelectSingleNode("settings/thumbnail/threadPriority") as XmlElement;
              if (priorityElem != null) {
            try {
              threadPriority = (ThreadPriority)priorityConv.ConvertFromString(priorityElem.GetAttribute("value"));
            }
            catch {
              threadPriority = DefaultThumbnailThreadPriority;
            }
              }
              else {
            threadPriority = DefaultThumbnailThreadPriority;
              }

              return new ThumbnailSettings(size, interpolationMode, backColor, threadPriority);
        }
コード例 #25
0
        private static void Main(string[] args)
        {
            switch (args[0])
            {
                case null:
                    Console.WriteLine("");
                    Console.WriteLine(@"Please format your command as shown: commandthing [color|image] [hex code|image path]");
                    Console.WriteLine("");
                    Console.WriteLine(@"Press any key to exit.");
                    Console.ReadKey();
                    return;

                case "authors":
                    Console.WriteLine("");
                    Console.WriteLine(@"Syrexide | https://github.com/Syrexide/");
                    Console.WriteLine(@"Toyz | https://github.com/Toyz/");
                    return;

                case "color":
                    var hex = args[3];
                    var isHex = TestIfHex(hex);
                    if (isHex == true)
                    {
                        var converter = new System.Drawing.ColorConverter();
                        Color color = (Color)converter.ConvertFromString(hex);

                        ChangeColor(color);
                    }
                    else
                    {
                        Console.WriteLine("");
                        Console.WriteLine(@"""{0}"" is not a valid hex color code!", hex);
                    }

                    return;

                case "image":
                    var filedir = args[0];
                    if (File.Exists(filedir) && (Path.GetExtension(filedir) == ".jpg") ||
                        (Path.GetExtension(filedir) == ".png") || (Path.GetExtension(filedir) == ".bmp") ||
                        (Path.GetExtension(filedir) == ".tif") || (Path.GetExtension(filedir) == ".tiff"))
                    {
                        ChangeImage(filedir);
                    }
                    else
                    {
                        Console.WriteLine("");
                        Console.WriteLine(@"File ""{0}"" does not exist, or the file is not an image file!", filedir);
                    }
                    return;

                case "restore":
                    Restore();
                    return;
            }
        }
コード例 #26
0
ファイル: WorkWindow.cs プロジェクト: ionutmodo/.NET.CWM
 private void SetColors()
 {
     ColorConverter conv = new ColorConverter();
     redClicked = Color.Red;
     redUnclicked = Color.FromArgb(192, 0, 0);
     blueClicked = (Color)conv.ConvertFromString("#4297DD");//alb. deschis
     blueUnclicked = (Color)conv.ConvertFromString("#0C6CBB");//alb. inchis
     greenClicked = (Color)conv.ConvertFromString("#00C000");
     greenUnclicked = Color.ForestGreen;
     myActivityMenuButton.FlatAppearance.MouseDownBackColor = blueClicked;
     myActivityMenuButton.FlatAppearance.MouseOverBackColor = blueClicked;
     teamActivityMenuButton.FlatAppearance.MouseDownBackColor = blueClicked;
     teamActivityMenuButton.FlatAppearance.MouseOverBackColor = blueClicked;
     projectsMenuButton.FlatAppearance.MouseDownBackColor = blueClicked;
     projectsMenuButton.FlatAppearance.MouseOverBackColor = blueClicked;
     tasksMenuButton.FlatAppearance.MouseDownBackColor = blueClicked;
     tasksMenuButton.FlatAppearance.MouseOverBackColor = blueClicked;
 }
コード例 #27
0
ファイル: LogsForm.cs プロジェクト: multipetros/Antigrafon
        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) { }
        }
コード例 #28
0
        public BackdropSettings ToBackdropSettings()
        {
            var colorConverter = new ColorConverter();

            return new BackdropSettings
            {
                Width = this.Width,
                Height = this.Height,
                VerticalCenterOfGravity = this.VerticalCenterOfGravity,
                BrightnessFactor = this.BrightnessFactor,
                ContrastFactor = this.ContrastFactor,
                OverlayColor = (Color)colorConverter.ConvertFromString(this.OverlayColor),
                NumberOfDominantColors = this.NumberOfDominantColors
            };
        }
コード例 #29
0
        private static void Main(string[] args)
        {
            TakeOwnership();
            foreach (var arg in args)
            {
                switch (arg.Substring(0, 2).ToUpper())
                {
                    case "/A":
                        try
                        {
                            Console.ForegroundColor = ConsoleColor.Green;
                            Console.WriteLine("");
                            Console.WriteLine(@"Syrexide | https://github.com/Syrexide/");
                            Console.WriteLine(@"Toyz | https://github.com/Toyz/");
                            Console.ForegroundColor = ConsoleColor.White;
                        }
                        catch (Exception e)
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("");
                            Console.WriteLine(@"An error occurred: '{0}'", e);
                            Console.ForegroundColor = ConsoleColor.White;
                        }
                        break;

                    case "/C":
                        var hex = arg.Substring(2);
                        try
                        {
                            if (hex.IsHex())
                            {
                                var converter = new ColorConverter();
                                var convertFromString = converter.ConvertFromString(hex);
                                if (convertFromString != null)
                                {
                                    var color = (Color)convertFromString;

                                    ChangeColor(color);
                                }
                                else
                                {
                                    return;
                                }

                                Console.ForegroundColor = ConsoleColor.Green;
                                Console.WriteLine("");
                                Console.WriteLine("Success!");
                                Console.ForegroundColor = ConsoleColor.White;
                            }
                            else
                            {
                                Console.WriteLine("");
                                Console.WriteLine(@"""{0}"" is not a valid hex color code!", hex);
                            }
                        }
                        catch (Exception e)
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("");
                            Console.WriteLine(@"An error occurred: '{0}'", e);
                            Console.ForegroundColor = ConsoleColor.White;
                        }
                        break;

                    case "/H":
                        Console.WriteLine("");
                        Console.WriteLine("HELP");
                        Console.WriteLine("=====");
                        Console.WriteLine("");
                        Console.WriteLine("AUTHORS - /A");
                        Console.WriteLine("COLOR - /C [HEX CODE]");
                        Console.WriteLine("IMAGE - /I [IMAGE PATH]");
                        Console.WriteLine("RESTORE - /R");
                        Console.WriteLine("HELP - /H");
                        break;

                    case "/I":
                        var filedir = arg.Substring(2);
                        try
                        {
                            if (File.Exists(filedir) && (Path.GetExtension(filedir) == ".jpg") ||
                                (Path.GetExtension(filedir) == ".png") || (Path.GetExtension(filedir) == ".bmp") ||
                                (Path.GetExtension(filedir) == ".tif") || (Path.GetExtension(filedir) == ".tiff"))
                            {
                                ChangeImage(filedir);
                                Console.ForegroundColor = ConsoleColor.Green;
                                Console.WriteLine("");
                                Console.WriteLine("Success!");
                                Console.ForegroundColor = ConsoleColor.White;
                            }
                            else
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.WriteLine("");
                                Console.WriteLine("An error occurred: The file \"" + filedir + "\" is not a valid file!");
                                Console.ForegroundColor = ConsoleColor.White;
                            }
                        }
                        catch (Exception e)
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("");
                            Console.WriteLine(@"An error occurred: '{0}'", e);
                            Console.ForegroundColor = ConsoleColor.White;
                        }
                        break;

                    case "/R":
                        try
                        {
                            Restore();
                            Console.ForegroundColor = ConsoleColor.Green;
                            Console.WriteLine("");
                            Console.WriteLine("Success!");
                            Console.ForegroundColor = ConsoleColor.White;
                        }
                        catch (Exception e)
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("");
                            Console.WriteLine(@"An error occurred: '{0}'", e);
                            Console.ForegroundColor = ConsoleColor.White;
                        }
                        break;

                    default:
                        Console.WriteLine("");
                        Console.WriteLine(
                            @"Please format your command as shown: exe [/A|/C|/H|/I|/R] [/CHEX CODE|/IFILE PATH]");
                        Console.WriteLine("");
                        Console.WriteLine(@"Press any key to exit.");
                        Console.ReadKey();
                        break;
                }
            }
        }
コード例 #30
0
ファイル: Standard.xaml.cs プロジェクト: mhack/gamenoise
        /// <summary>
        /// Clock for the visualization. Every tick the visualization will be drawed
        /// </summary>
        private void ClockVisTick()
        {
            System.Drawing.ColorConverter trans = new System.Drawing.ColorConverter();

            if (mainWindow.Fill == null)
                return;

            System.Drawing.Color back = (System.Drawing.Color)trans.ConvertFromString(mainWindow.Fill.ToString());

            switch (_currentVis)
            {

                case (1):
                    _aVisualization.CreateSpectrumLine(new Visualization.SpectrumLineParams(canvasVis, ABassWrapperGui.getFFTData(), 110, 50, System.Drawing.Color.Orange, System.Drawing.Color.OrangeRed, back, 10, 2, false, true, 3, 1, true));
                    break;
                case (2):
                    _aVisualization.CreateSpectrumLine(new Visualization.SpectrumLineParams(canvasVis, ABassWrapperGui.getFFTData(), 110, 50, System.Drawing.Color.Orange, System.Drawing.Color.Orange, back, 2, 0, false, false, 3, 1, true));
                    break;
                case (3):
                    _aVisualization.CreateSpectrumLine(new Visualization.SpectrumLineParams(canvasVis, ABassWrapperGui.getFFTData(), 110, 50, System.Drawing.Color.Orange, System.Drawing.Color.Orange, back, 1, 0, true, false, 3, 1, true));
                    break;
                case (0):
                case (4):
                    _aVisualization.CreateSpectrumLine(new Visualization.SpectrumLineParams(canvasVis, ABassWrapperGui.getFFTData(), 110, 50, System.Drawing.Color.Orange, System.Drawing.Color.Orange, back, 1, 0, true, false, 3, 1, true));
                    canvasVis.Children.Clear();
                    break;
            }
        }
コード例 #31
0
 /// <summary>
 /// 获取验证码图片
 /// </summary>
 public void GetRandomCode()
 {
     Util.RandomCode randomCode = new Util.RandomCode();
     Session["CheckCode"] = randomCode.CreateRandomCode(5);
     ColorConverter colConvert = new ColorConverter();
     System.IO.MemoryStream img = randomCode.CreateImage(Session["CheckCode"].ToString(), (Color)colConvert.ConvertFromString("#312bff"), (Color)colConvert.ConvertFromString("#c5babc"));
     Response.ClearContent();
     Response.ContentType = "image/Jpeg";
     Response.BinaryWrite(img.ToArray());
 }
コード例 #32
0
 public void ConvertFromString_NotNumber()
 {
     var conv = new ColorConverter();
     var ex = Assert.Throws<Exception>(() =>
     {
         conv.ConvertFromString("hello");
     });
     Assert.NotNull(ex.InnerException);
     Assert.IsType<FormatException>(ex.InnerException);
 }
コード例 #33
0
 public void ConvertFromString_Invalid()
 {
     var conv = new ColorConverter();
     Assert.Throws<ArgumentException>(() =>
     {
         conv.ConvertFromString(string.Format("1{0} 2{0} 3{0} 4{0} 5", CultureInfo.CurrentCulture.TextInfo.ListSeparator));
     });
 }