コード例 #1
0
        void cPicker1_TextChanged2(object sender, EventArgs e)
        {
            Color c1 = ((LaMarvin.Windows.Forms.ColorPicker)sender).Color;

            AdobeColors.HSL hsl = AdobeColors.RGB_to_HSL(c1);
            selectedRow["h"] = hsl.H;
            selectedRow["s"] = hsl.S;
            selectedRow["v"] = hsl.L;
        }
コード例 #2
0
ファイル: ColorCellEditor.cs プロジェクト: zhuangyy/Motion
                    public frmColorPicker(Color starting_color)
                    {
                        InitializeComponent();

                        m_rgb = starting_color;
                        m_hsl = AdobeColors.RGB_to_HSL(m_rgb);
                        m_cmyk = AdobeColors.RGB_to_CMYK(m_rgb);

                        m_txt_Hue.Text =		Round(m_hsl.H * 360).ToString();
                        m_txt_Sat.Text =		Round(m_hsl.S * 100).ToString();
                        m_txt_Black.Text =		Round(m_hsl.L * 100).ToString();
                        m_txt_Red.Text =		m_rgb.R.ToString();
                        m_txt_Green.Text =		m_rgb.G.ToString();
                        m_txt_Blue.Text =		m_rgb.B.ToString();
                        m_txt_Cyan.Text =		Round(m_cmyk.C * 100).ToString();
                        m_txt_Magenta.Text =	Round(m_cmyk.M * 100).ToString();
                        m_txt_Yellow.Text =		Round(m_cmyk.Y * 100).ToString();
                        m_txt_K.Text =			Round(m_cmyk.K * 100).ToString();

                        m_txt_Hue.Update();
                        m_txt_Sat.Update();
                        m_txt_Lum.Update();
                        m_txt_Red.Update();
                        m_txt_Green.Update();
                        m_txt_Blue.Update();
                        m_txt_Cyan.Update();
                        m_txt_Magenta.Update();
                        m_txt_Yellow.Update();
                        m_txt_K.Update();

                        m_ctrl_BigBox.HSL = m_hsl;
                        m_ctrl_ThinBox.HSL = m_hsl;

                        m_lbl_Primary_Color.BackColor = starting_color;
                        m_lbl_Secondary_Color.BackColor = starting_color;

                        m_rbtn_Hue.Checked = true;

                        this.WriteHexData(m_rgb);
                    }
コード例 #3
0
ファイル: ColorCellEditor.cs プロジェクト: zhuangyy/Motion
 /// <summary>
 /// Resets the controls color (both HSL and RGB variables) based on the current slider position
 /// </summary>
 private void ResetHSLRGB()
 {
     switch (m_eDrawStyle)
     {
         case eDrawStyle.Hue :
             m_hsl.H = 1.0 - (double)m_iMarker_Start_Y/(this.Height - 9);
             m_rgb = AdobeColors.HSL_to_RGB(m_hsl);
             break;
         case eDrawStyle.Saturation :
             m_hsl.S = 1.0 - (double)m_iMarker_Start_Y/(this.Height - 9);
             m_rgb = AdobeColors.HSL_to_RGB(m_hsl);
             break;
         case eDrawStyle.Brightness :
             m_hsl.L = 1.0 - (double)m_iMarker_Start_Y/(this.Height - 9);
             m_rgb = AdobeColors.HSL_to_RGB(m_hsl);
             break;
         case eDrawStyle.Red :
             m_rgb = Color.FromArgb(255 - Round( 255 * (double)m_iMarker_Start_Y/(this.Height - 9) ), m_rgb.G, m_rgb.B);
             m_hsl = AdobeColors.RGB_to_HSL(m_rgb);
             break;
         case eDrawStyle.Green :
             m_rgb = Color.FromArgb(m_rgb.R, 255 - Round( 255 * (double)m_iMarker_Start_Y/(this.Height - 9) ), m_rgb.B);
             m_hsl = AdobeColors.RGB_to_HSL(m_rgb);
             break;
         case eDrawStyle.Blue :
             m_rgb = Color.FromArgb(m_rgb.R, m_rgb.G, 255 - Round( 255 * (double)m_iMarker_Start_Y/(this.Height - 9) ));
             m_hsl = AdobeColors.RGB_to_HSL(m_rgb);
             break;
     }
 }
コード例 #4
0
ファイル: ColorCellEditor.cs プロジェクト: zhuangyy/Motion
                    /// <summary>
                    /// Fills in the content of the control showing all values of Luminance (0 to 100%) for the given
                    /// Hue and Saturation.
                    /// </summary>
                    private void Draw_Style_Luminance()
                    {
                        Graphics g = this.CreateGraphics();

                        AdobeColors.HSL _hsl = new AdobeColors.HSL();
                        _hsl.H = m_hsl.H;	//	Use the H and S values of the current color (m_hsl)
                        _hsl.S = m_hsl.S;

                        for ( int i = 0; i < this.Height - 8; i++ ) //	i represents the current line of pixels we want to draw horizontally
                        {
                            _hsl.L = 1.0 - (double)i/(this.Height - 8);			//	L (Luminance) is based on the current vertical position
                            Pen pen = new Pen(AdobeColors.HSL_to_RGB(_hsl));	//	Get the Color for this line

                            g.DrawLine(pen, 11, i + 4, this.Width - 11, i + 4);	//	Draw the line and loop back for next line
                        }
                    }
コード例 #5
0
ファイル: ColorCellEditor.cs プロジェクト: zhuangyy/Motion
                    //    The following functions do the real work of the control, drawing the primary content (the area between the slider)
                    //    
                    /// <summary>
                    /// Fills in the content of the control showing all values of Hue (from 0 to 360)
                    /// </summary>
                    private void Draw_Style_Hue()
                    {
                        Graphics g = this.CreateGraphics();

                        AdobeColors.HSL _hsl = new AdobeColors.HSL();
                        _hsl.S = 1.0;	//	S and L will both be at 100% for this DrawStyle
                        _hsl.L = 1.0;

                        for ( int i = 0; i < this.Height - 8; i++ )	//	i represents the current line of pixels we want to draw horizontally
                        {
                            _hsl.H = 1.0 - (double)i/(this.Height - 8);			//	H (hue) is based on the current vertical position
                            Pen pen = new Pen(AdobeColors.HSL_to_RGB(_hsl));	//	Get the Color for this line

                            g.DrawLine(pen, 11, i + 4, this.Width - 11, i + 4);	//	Draw the line and loop back for next line
                        }
                    }
コード例 #6
0
        public void updateChangedInfo(String propertyName, Object _changedValue)
        {
            String changedValue = _changedValue.ToString();

            //Update DataRow and Graphics (only certain props require graphical updating).
            if (propertyName == "SectorID")
            {
                dr["sector_id"] = int.Parse(changedValue);
            }
            else if (propertyName == "NavType")
            {
                dr["nav_type"] = changedValue;
            }
            else if (propertyName == "Signature")
            {
                dr["signature"] = float.Parse(changedValue);

                float imageWidth  = harvestableImage.Width;
                float imageHeight = harvestableImage.Height;
                float x           = harvestableImage.X;
                float y           = harvestableImage.Y;
                harvestableImage.GetChild(0).X      = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(0).Y      = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(0).Width  = (float.Parse(changedValue) * 2) / 100;
                harvestableImage.GetChild(0).Height = (float.Parse(changedValue) * 2) / 100;
            }
            else if (propertyName == "IsHuge")
            {
                dr["is_huge"] = bool.Parse(changedValue);
            }
            else if (propertyName == "BaseXP")
            {
                dr["base_xp"] = int.Parse(changedValue);
            }
            else if (propertyName == "ExplorationRange")
            {
                dr["exploration_range"] = float.Parse(changedValue);

                float imageWidth  = harvestableImage.Width;
                float imageHeight = harvestableImage.Height;
                float x           = harvestableImage.X;
                float y           = harvestableImage.Y;
                harvestableImage.GetChild(2).X      = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(2).Y      = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(2).Width  = (float.Parse(changedValue) * 2) / 100;
                harvestableImage.GetChild(2).Height = (float.Parse(changedValue) * 2) / 100;
            }
            else if (propertyName == "BaseAssetID")
            {
                dr["base_asset_id"] = int.Parse(changedValue);
                foreach (DataGridViewRow row in _dgv.SelectedRows)
                {
                    _dgv.Rows[row.Index].Cells["base_asset_id"].Value = int.Parse(changedValue);
                    _dgv.Update();
                    _dgv.Refresh();
                }
            }
            else if (propertyName == "Color")
            {
                Color           color = (Color)_changedValue;
                AdobeColors.HSL hsv   = AdobeColors.RGB_to_HSL(color);

                dr["h"] = hsv.H;
                dr["s"] = hsv.S;
                dr["v"] = hsv.L;
            }
            else if (propertyName == "Type")
            {
                _layer.RemoveChild(harvestableImage);

                /*
                 * if (changedValue == "Mobs")
                 * {
                 *  dr["type"] = 0;
                 *  new MobSprite(_layer, dr, _pg);
                 * }
                 * else if (changedValue == "Planets")
                 * {
                 *  dr["type"] = 3;
                 *  new PlanetSprite(_layer, dr, _pg);
                 * }
                 * else if (changedValue == "Stargates")
                 * {
                 *  dr["type"] = 11;
                 *  new StargateSprite(_layer, dr, _pg);
                 * }
                 * else if (changedValue == "Starbases")
                 * {
                 *  dr["type"] = 12;
                 *  new StarbaseSprite(_layer, dr, _pg);
                 * }
                 * else if (changedValue == "Decorations")
                 * {
                 *  dr["type"] = 37;
                 *  new DecorationSprite(_layer, dr, _pg);
                 * }*/

                _pg.SelectedObject = null;
            }
            else if (propertyName == "Scale")
            {
                dr["scale"] = float.Parse(changedValue);
            }
            else if (propertyName == "PositionX")
            {
                dr["position_x"] = float.Parse(changedValue);

                float dx = (float.Parse(changedValue) / 100) - harvestableImage.X;
                harvestableImage.TranslateBy(dx, 0);
            }
            else if (propertyName == "PositionY")
            {
                dr["position_y"] = float.Parse(changedValue);

                float dy = (float.Parse(changedValue) / 100) - harvestableImage.Y;
                harvestableImage.TranslateBy(0, dy);
            }
            else if (propertyName == "PositionZ")
            {
                dr["position_z"] = float.Parse(changedValue);
            }
            else if (propertyName == "Orientation_Yaw" || propertyName == "Orientation_Pitch" || propertyName == "Orientation_Roll")
            {
                QuaternionCalc qtmp = new QuaternionCalc();
                double[]       q1   = qtmp.AngleToQuat(dp.Orientation_Yaw, dp.Orientation_Pitch, dp.Orientation_Roll);

                dr["orientation_z"] = q1[0];
                dr["orientation_u"] = q1[1];
                dr["orientation_v"] = q1[2];
                dr["orientation_w"] = q1[3];
            }
            else if (propertyName == "Name")
            {
                dr["name"] = changedValue;

                float x    = harvestableImage.X;
                float y    = harvestableImage.Y;
                PText name = (PText)harvestableImage.GetChild(3);
                name.Text          = changedValue;
                name.TextAlignment = StringAlignment.Center;
                name.X             = x - (name.Width / 2);
                name.Y             = y - 20;

                foreach (DataGridViewRow row in _dgv.SelectedRows)
                {
                    _dgv.Rows[row.Index].Cells["name"].Value = changedValue;
                    _dgv.Update();
                    _dgv.Refresh();
                }
            }
            else if (propertyName == "AppearsInRadar")
            {
                dr["appears_in_radar"] = bool.Parse(changedValue);

                if (bool.Parse(changedValue) == true)
                {
                    changeImage(1);
                }
                else
                {
                    changeImage(0);
                }
            }
            else if (propertyName == "RadarRange")
            {
                dr["radar_range"] = float.Parse(changedValue);

                float imageWidth  = harvestableImage.Width;
                float imageHeight = harvestableImage.Height;
                float x           = harvestableImage.X;
                float y           = harvestableImage.Y;
                harvestableImage.GetChild(1).X      = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(1).Y      = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(1).Width  = (float.Parse(changedValue) * 2) / 100;
                harvestableImage.GetChild(1).Height = (float.Parse(changedValue) * 2) / 100;
            }
            else if (propertyName == "Destination")
            {
                dr["gate_to"] = int.Parse(changedValue);
            }
            else if (propertyName == "Level")
            {
                dr["level"] = changedValue;
            }
            else if (propertyName == "Field")
            {
                if (changedValue == "Random")
                {
                    dr["field"] = 0;
                }
                else if (changedValue == "Ring")
                {
                    dr["field"] = 1;
                }
                else if (changedValue == "Donut")
                {
                    dr["field"] = 2;
                }
                else if (changedValue == "Cylinder")
                {
                    dr["field"] = 3;
                }
                else if (changedValue == "Sphere")
                {
                    dr["field"] = 4;
                }
                else if (changedValue == "Gas Cloud Clump")
                {
                    dr["field"] = 5;
                }
            }
            else if (propertyName == "ResCount")
            {
                dr["res_count"] = int.Parse(changedValue);
            }
            else if (propertyName == "MaxFieldRadius")
            {
                dr["max_field_radius"] = float.Parse(changedValue);

                int navType   = int.Parse(dr["nav_type"].ToString());
                int nodeCount = (3 + navType) + 2;

                float imageWidth  = harvestableImage.Width;
                float imageHeight = harvestableImage.Height;
                float x           = harvestableImage.X;
                float y           = harvestableImage.Y;
                harvestableImage.GetChild(nodeCount).X      = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(nodeCount).Y      = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(nodeCount).Width  = (float.Parse(changedValue) * 2) / 100;
                harvestableImage.GetChild(nodeCount).Height = (float.Parse(changedValue) * 2) / 100;
            }
            else if (propertyName == "MobSpawnRadius")
            {
                dr["spawn_radius"] = float.Parse(changedValue);

                int navType   = int.Parse(dr["nav_type"].ToString());
                int nodeCount = (3 + navType) + 1;

                float imageWidth  = harvestableImage.Width;
                float imageHeight = harvestableImage.Height;
                float x           = harvestableImage.X;
                float y           = harvestableImage.Y;
                harvestableImage.GetChild(nodeCount).X      = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(nodeCount).Y      = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(nodeCount).Width  = (float.Parse(changedValue) * 2) / 100;
                harvestableImage.GetChild(nodeCount).Height = (float.Parse(changedValue) * 2) / 100;
            }
            else if (propertyName == "PopRockChance")
            {
                dr["pop_rock_chance"] = float.Parse(changedValue);
            }
            else if (propertyName == "SoundEffect")
            {
                dr["sound_effect_id"] = int.Parse(changedValue);
            }
            else if (propertyName == "SoundEffectRange")
            {
                dr["sound_effect_range"] = float.Parse(changedValue);
            }

            if (dr.RowState != DataRowState.Modified)
            {
                dr.SetModified();
            }
        }
コード例 #7
0
        private void setupData(DataRow r)
        {
            int    objectType = int.Parse(r["type"].ToString());
            String oType      = "";

            switch (objectType)
            {
            case 0:
                oType = "Mobs";
                break;

            case 3:
                oType = "Planets";
                break;

            case 11:
                oType = "Stargates";
                break;

            case 12:
                oType = "Starbases";
                break;

            case 37:
                oType = "Decorations";
                break;

            case 38:
                oType = "Harvestables";
                break;
            }

            dp = new StargateProps();

            //Base Props + Nav Point Props
            dp.SectorID         = int.Parse(r["sector_id"].ToString());
            dp.NavType          = r["nav_type"].ToString();
            dp.Signature        = float.Parse(r["signature"].ToString());
            dp.IsHuge           = (Boolean)r["is_huge"];
            dp.BaseXP           = int.Parse(r["base_xp"].ToString());
            dp.ExplorationRange = float.Parse(r["exploration_range"].ToString());

            dp.BaseAssetID = int.Parse(r["base_asset_id"].ToString());

            AdobeColors.HSL hslColor = new AdobeColors.HSL();
            hslColor.H = float.Parse(r["h"].ToString());
            hslColor.S = float.Parse(r["s"].ToString());
            hslColor.L = float.Parse(r["v"].ToString());
            Color newColor = AdobeColors.HSL_to_RGB(hslColor);

            dp.Color = newColor;

            dp.Type      = oType;
            dp.Scale     = float.Parse(r["scale"].ToString());;
            dp.PositionX = float.Parse(r["position_x"].ToString());
            dp.PositionY = float.Parse(r["position_y"].ToString());
            dp.PositionZ = float.Parse(r["position_z"].ToString());;

            double[] quat1 = new double[4];
            quat1[0] = double.Parse(r["orientation_z"].ToString());
            quat1[1] = double.Parse(r["orientation_u"].ToString());
            quat1[2] = double.Parse(r["orientation_v"].ToString());
            quat1[3] = double.Parse(r["orientation_w"].ToString());

            QuaternionCalc qc1 = new QuaternionCalc();

            double[] ang1 = qc1.QuatToAngle(quat1);
            if (ang1[0] == double.NaN)
            {
                ang1[0] = 0;
            }
            if (ang1[1] == double.NaN)
            {
                ang1[1] = 0;
            }
            if (ang1[2] == double.NaN)
            {
                ang1[2] = 0;
            }
            dp.Orientation_Yaw   = Math.Round(ang1[0], 0);
            dp.Orientation_Pitch = Math.Round(ang1[1], 0);
            dp.Orientation_Roll  = Math.Round(ang1[2], 0);

            dp.Name             = r["name"].ToString();
            dp.AppearsInRadar   = (Boolean)r["appears_in_radar"];
            dp.RadarRange       = float.Parse(r["radar_range"].ToString());
            dp.Destination      = int.Parse(r["gate_to"].ToString());
            dp.SoundEffect      = int.Parse(r["sound_effect_id"].ToString());
            dp.SoundEffectRange = float.Parse(r["sound_effect_range"].ToString());

            //Stargate Specific Props
            dp.IsClassSpecific = (Boolean)r["classSpecific"];

            //TODO: Get Faction Name from ID;
            String factionName = mainFrm.factions.findNameByID(int.Parse(r["faction_id"].ToString()));

            dp.FactionID = factionName;
        }
コード例 #8
0
ファイル: ColorCellEditor.cs プロジェクト: zhuangyy/Motion
                    private void m_txt_Blue_Leave(object sender, System.EventArgs e)
                    {
                        string text = m_txt_Blue.Text;
                        bool has_illegal_chars = false;

                        if ( text.Length <= 0 )
                            has_illegal_chars = true;
                        else
                            foreach ( char letter in text )
                            {
                                if ( !char.IsNumber(letter) )
                                {
                                    has_illegal_chars = true;
                                    break;
                                }
                            }

                        if ( has_illegal_chars )
                        {
                            MessageBox.Show("Blue must be a number value between 0 and 255");
                            UpdateTextBoxes();
                            return;
                        }

                        int blue = int.Parse(text);

                        if ( blue < 0 )
                        {
                            MessageBox.Show("An integer between 0 and 255 is required.\nClosest value inserted.");
                            m_txt_Blue.Text = "0";
                            m_rgb = Color.FromArgb(m_rgb.R, m_rgb.G, 0);
                        }
                        else if ( blue > 255 )
                        {
                            MessageBox.Show("An integer between 0 and 255 is required.\nClosest value inserted.");
                            m_txt_Blue.Text = "255";
                            m_rgb = Color.FromArgb(m_rgb.R, m_rgb.G, 255);
                        }
                        else
                        {
                            m_rgb = Color.FromArgb(m_rgb.R, m_rgb.G, blue);
                        }

                        m_hsl = AdobeColors.RGB_to_HSL(m_rgb);
                        m_cmyk = AdobeColors.RGB_to_CMYK(m_rgb);
                        m_ctrl_BigBox.HSL = m_hsl;
                        m_ctrl_ThinBox.HSL = m_hsl;
                        m_lbl_Primary_Color.BackColor = m_rgb;

                        UpdateTextBoxes();
                    }
コード例 #9
0
ファイル: ColorCellEditor.cs プロジェクト: zhuangyy/Motion
                    /// <summary>
                    /// Draws the content of the control filling in all color values with the provided Luminance or Brightness value.
                    /// </summary>
                    private void Draw_Style_Luminance()
                    {
                        Graphics g = this.CreateGraphics();

                        AdobeColors.HSL hsl_start = new AdobeColors.HSL();
                        AdobeColors.HSL hsl_end = new AdobeColors.HSL();
                        hsl_start.L = m_hsl.L;
                        hsl_end.L = m_hsl.L;
                        hsl_start.S = 1.0;
                        hsl_end.S = 0.0;

                        for ( int i = 0; i < this.Width - 4; i++ )		//	For each vertical line in the control:
                        {
                            hsl_start.H = (double)i/(this.Width - 4);	//	Calculate Hue at this line (Saturation and Luminance are constant)
                            hsl_end.H = hsl_start.H;

                            LinearGradientBrush br = new LinearGradientBrush(new Rectangle(2,2, 1, this.Height - 4), AdobeColors.HSL_to_RGB(hsl_start), AdobeColors.HSL_to_RGB(hsl_end), 90, false);
                            g.FillRectangle(br,new Rectangle(i + 2, 2, 1, this.Height - 4));
                        }
                    }
コード例 #10
0
ファイル: ColorCellEditor.cs プロジェクト: zhuangyy/Motion
                    /// <summary>
                    /// Redraws only the content over the marker
                    /// </summary>
                    private void ClearMarker()
                    {
                        Graphics g = this.CreateGraphics();

                        //	Determine the area that needs to be redrawn
                        int start_x, start_y, end_x, end_y;
                        int red = 0; int green = 0; int blue = 0;
                        AdobeColors.HSL hsl_start = new AdobeColors.HSL();
                        AdobeColors.HSL hsl_end = new AdobeColors.HSL();

                        //	Find the markers corners
                        start_x = m_iMarker_X - 5;
                        start_y = m_iMarker_Y - 5;
                        end_x = m_iMarker_X + 5;
                        end_y = m_iMarker_Y + 5;
                        //	Adjust the area if part of it hangs outside the content area
                        if ( start_x < 0 ) start_x = 0;
                        if ( start_y < 0 ) start_y = 0;
                        if ( end_x > this.Width - 4 ) end_x = this.Width - 4;
                        if ( end_y > this.Height - 4 ) end_y = this.Height - 4;

                        //	Redraw the content based on the current draw style:
                        //	The code get's a little messy from here
                        switch (m_eDrawStyle)
                        {
                                //		  S=0,S=1,S=2,S=3.....S=100
                                //	L=100
                                //	L=99
                                //	L=98		Drawstyle
                                //	L=97		   Hue
                                //	...
                                //	L=0
                            case eDrawStyle.Hue :

                                hsl_start.H = m_hsl.H;	hsl_end.H = m_hsl.H;	//	Hue is constant
                                hsl_start.S = (double)start_x/(this.Width - 4);	//	Because we're drawing horizontal lines, s will not change
                                hsl_end.S = (double)end_x/(this.Width - 4);		//	from line to line

                                for ( int i = start_y; i <= end_y; i++ )		//	For each horizontal line:
                                {
                                    hsl_start.L = 1.0 - (double)i/(this.Height - 4);	//	Brightness (L) WILL change for each horizontal
                                    hsl_end.L = hsl_start.L;							//	line drawn

                                    LinearGradientBrush br = new LinearGradientBrush(new Rectangle(start_x + 1,i + 2, end_x - start_x + 1, 1), AdobeColors.HSL_to_RGB(hsl_start), AdobeColors.HSL_to_RGB(hsl_end), 0, false);
                                    g.FillRectangle(br,new Rectangle(start_x + 2,i + 2, end_x - start_x + 1 , 1));
                                }

                                break;
                                //		  H=0,H=1,H=2,H=3.....H=360
                                //	L=100
                                //	L=99
                                //	L=98		Drawstyle
                                //	L=97		Saturation
                                //	...
                                //	L=0
                            case eDrawStyle.Saturation :

                                hsl_start.S = m_hsl.S;	hsl_end.S = m_hsl.S;			//	Saturation is constant
                                hsl_start.L = 1.0 - (double)start_y/(this.Height - 4);	//	Because we're drawing vertical lines, L will
                                hsl_end.L = 1.0 - (double)end_y/(this.Height - 4);		//	not change from line to line

                                for ( int i = start_x; i <= end_x; i++ )				//	For each vertical line:
                                {
                                    hsl_start.H = (double)i/(this.Width - 4);			//	Hue (H) WILL change for each vertical
                                    hsl_end.H = hsl_start.H;							//	line drawn

                                    LinearGradientBrush br = new LinearGradientBrush(new Rectangle(i + 2,start_y + 1, 1, end_y - start_y + 2), AdobeColors.HSL_to_RGB(hsl_start), AdobeColors.HSL_to_RGB(hsl_end), 90, false);
                                    g.FillRectangle(br,new Rectangle(i + 2, start_y + 2, 1, end_y - start_y + 1));
                                }
                                break;
                                //		  H=0,H=1,H=2,H=3.....H=360
                                //	S=100
                                //	S=99
                                //	S=98		Drawstyle
                                //	S=97		Brightness
                                //	...
                                //	S=0
                            case eDrawStyle.Brightness :

                                hsl_start.L = m_hsl.L;	hsl_end.L = m_hsl.L;			//	Luminance is constant
                                hsl_start.S = 1.0 - (double)start_y/(this.Height - 4);	//	Because we're drawing vertical lines, S will
                                hsl_end.S = 1.0 - (double)end_y/(this.Height - 4);		//	not change from line to line

                                for ( int i = start_x; i <= end_x; i++ )				//	For each vertical line:
                                {
                                    hsl_start.H = (double)i/(this.Width - 4);			//	Hue (H) WILL change for each vertical
                                    hsl_end.H = hsl_start.H;							//	line drawn

                                    LinearGradientBrush br = new LinearGradientBrush(new Rectangle(i + 2,start_y + 1, 1, end_y - start_y + 2), AdobeColors.HSL_to_RGB(hsl_start), AdobeColors.HSL_to_RGB(hsl_end), 90, false);
                                    g.FillRectangle(br,new Rectangle(i + 2, start_y + 2, 1, end_y - start_y + 1));
                                }

                                break;
                                //		  B=0,B=1,B=2,B=3.....B=100
                                //	G=100
                                //	G=99
                                //	G=98		Drawstyle
                                //	G=97		   Red
                                //	...
                                //	G=0
                            case eDrawStyle.Red :

                                red = m_rgb.R;													//	Red is constant
                                int start_b = Round(255 * (double)start_x/(this.Width - 4));	//	Because we're drawing horizontal lines, B
                                int end_b = Round(255 * (double)end_x/(this.Width - 4));		//	will not change from line to line

                                for ( int i = start_y; i <= end_y; i++ )						//	For each horizontal line:
                                {
                                    green = Round(255 - (255 * (double)i/(this.Height - 4)));	//	green WILL change for each horizontal line drawn

                                    LinearGradientBrush br = new LinearGradientBrush(new Rectangle(start_x + 1,i + 2, end_x - start_x + 1, 1), Color.FromArgb(red, green, start_b), Color.FromArgb(red, green, end_b), 0, false);
                                    g.FillRectangle(br,new Rectangle(start_x + 2,i + 2, end_x - start_x + 1 , 1));
                                }

                                break;
                                //		  B=0,B=1,B=2,B=3.....B=100
                                //	R=100
                                //	R=99
                                //	R=98		Drawstyle
                                //	R=97		  Green
                                //	...
                                //	R=0
                            case eDrawStyle.Green :

                                green = m_rgb.G;;												//	Green is constant
                                int start_b2 = Round(255 * (double)start_x/(this.Width - 4));	//	Because we're drawing horizontal lines, B
                                int end_b2 = Round(255 * (double)end_x/(this.Width - 4));		//	will not change from line to line

                                for ( int i = start_y; i <= end_y; i++ )						//	For each horizontal line:
                                {
                                    red = Round(255 - (255 * (double)i/(this.Height - 4)));		//	red WILL change for each horizontal line drawn

                                    LinearGradientBrush br = new LinearGradientBrush(new Rectangle(start_x + 1,i + 2, end_x - start_x + 1, 1), Color.FromArgb(red, green, start_b2), Color.FromArgb(red, green, end_b2), 0, false);
                                    g.FillRectangle(br,new Rectangle(start_x + 2,i + 2, end_x - start_x + 1 , 1));
                                }

                                break;
                                //		  R=0,R=1,R=2,R=3.....R=100
                                //	G=100
                                //	G=99
                                //	G=98		Drawstyle
                                //	G=97		   Blue
                                //	...
                                //	G=0
                            case eDrawStyle.Blue :

                                blue = m_rgb.B;;												//	Blue is constant
                                int start_r = Round(255 * (double)start_x/(this.Width - 4));	//	Because we're drawing horizontal lines, R
                                int end_r = Round(255 * (double)end_x/(this.Width - 4));		//	will not change from line to line

                                for ( int i = start_y; i <= end_y; i++ )						//	For each horizontal line:
                                {
                                    green = Round(255 - (255 * (double)i/(this.Height - 4)));	//	green WILL change for each horizontal line drawn

                                    LinearGradientBrush br = new LinearGradientBrush(new Rectangle(start_x + 1,i + 2, end_x - start_x + 1, 1), Color.FromArgb(start_r, green, blue), Color.FromArgb(end_r, green, blue), 0, false);
                                    g.FillRectangle(br,new Rectangle(start_x + 2,i + 2, end_x - start_x + 1 , 1));
                                }

                                break;
                        }
                    }
コード例 #11
0
        private void populateFields(int objectID)
        {
            equippedAmmoGroup       = new ListViewGroup("Ammo", HorizontalAlignment.Left);
            equippedDevicesGroup    = new ListViewGroup("Devices", HorizontalAlignment.Left);
            equippedEnginesGroup    = new ListViewGroup("Engines", HorizontalAlignment.Left);
            equippedReactorsGroup   = new ListViewGroup("Reactors", HorizontalAlignment.Left);
            equippedShieldsGroup    = new ListViewGroup("Shields", HorizontalAlignment.Left);
            equippedMissileGroup    = new ListViewGroup("Missile Weapon", HorizontalAlignment.Left);
            equippedProjectileGroup = new ListViewGroup("Projectile Weapon", HorizontalAlignment.Left);
            equippedBeamGroup       = new ListViewGroup("Beam Weapon", HorizontalAlignment.Left);

            listView1.Groups.AddRange(new ListViewGroup[] { equippedAmmoGroup, equippedDevicesGroup, equippedEnginesGroup,
                                                            equippedReactorsGroup, equippedShieldsGroup, equippedMissileGroup,
                                                            equippedProjectileGroup, equippedBeamGroup });

            inventoryAmmoGroup       = new ListViewGroup("Ammo", HorizontalAlignment.Left);
            inventoryDevicesGroup    = new ListViewGroup("Devices", HorizontalAlignment.Left);
            inventoryEnginesGroup    = new ListViewGroup("Engines", HorizontalAlignment.Left);
            inventoryReactorsGroup   = new ListViewGroup("Reactors", HorizontalAlignment.Left);
            inventoryShieldsGroup    = new ListViewGroup("Shields", HorizontalAlignment.Left);
            inventoryMissileGroup    = new ListViewGroup("Missile Weapon", HorizontalAlignment.Left);
            inventoryProjectileGroup = new ListViewGroup("Projectile Weapon", HorizontalAlignment.Left);
            inventoryBeamGroup       = new ListViewGroup("Beam Weapon", HorizontalAlignment.Left);
            inventoryComponentsGroup = new ListViewGroup("Components", HorizontalAlignment.Left);
            inventoryOreGroup        = new ListViewGroup("Ore & Resources", HorizontalAlignment.Left);
            inventoryMiscGroup       = new ListViewGroup("Misc. Loot", HorizontalAlignment.Left);

            listView2.Groups.AddRange(new ListViewGroup[] { inventoryAmmoGroup, inventoryDevicesGroup,
                                                            inventoryEnginesGroup, inventoryReactorsGroup, inventoryShieldsGroup,
                                                            inventoryMissileGroup, inventoryProjectileGroup, inventoryBeamGroup,
                                                            inventoryComponentsGroup, inventoryOreGroup, inventoryMiscGroup });

            selectedRow = mobs.getRowByID(objectID);

            //General Details.
            String name           = selectedRow["name"].ToString();
            int    level          = int.Parse(selectedRow["level"].ToString());
            int    type           = int.Parse(selectedRow["type"].ToString());
            int    intelligence   = int.Parse(selectedRow["intelligence"].ToString());
            int    bravery        = int.Parse(selectedRow["bravery"].ToString());
            int    factionID      = int.Parse(selectedRow["faction_id"].ToString());
            int    baseAssetID    = int.Parse(selectedRow["base_asset_id"].ToString());
            int    altruism       = int.Parse(selectedRow["altruism"].ToString());
            int    aggressiveness = int.Parse(selectedRow["aggressiveness"].ToString());
            float  h     = float.Parse(selectedRow["h"].ToString());
            float  s     = float.Parse(selectedRow["s"].ToString());
            float  v     = float.Parse(selectedRow["v"].ToString());
            float  scale = float.Parse(selectedRow["scale"].ToString());
            String ai    = selectedRow["ai"].ToString();

            nameText.Text           = name;
            levelCombo.SelectedItem = level;
            baseAssetText.Text      = baseAssetID.ToString();
            scaleText.Text          = scale.ToString();
            aiText.Text             = ai;

            AdobeColors.HSL hsl = new AdobeColors.HSL();
            hsl.H          = h;
            hsl.S          = s;
            hsl.L          = v;
            cPicker1.Color = AdobeColors.HSL_to_RGB(hsl);

            switch (type)
            {
            case 0:
                typeCombo.SelectedItem = "Cybernetic";
                break;

            case 1:
                typeCombo.SelectedItem = "Structural";
                break;

            case 2:
                typeCombo.SelectedItem = "Organic_Red";
                break;

            case 3:
                typeCombo.SelectedItem = "Organic_Green";
                break;

            case 4:
                typeCombo.SelectedItem = "Crystalline";
                break;

            case 5:
                typeCombo.SelectedItem = "Energy";
                break;

            case 6:
                typeCombo.SelectedItem = "Rock Based";
                break;
            }

            String factionName = factions.findNameByID(factionID);

            if (factionName != "None")
            {
                factionCombo.SelectedItem = factionName;
            }
            else
            {
                factionCombo.SelectedItem = "Please Make A Selection";
            }

            //Equipped Items & Inventory
            DataRow[] mobItems = mobItemsSql.getRowsByID(objectID);

            listView1.Items.Clear();
            listView2.Items.Clear();

            for (int i = 0; i < mobItems.Length; i++)
            {
                int itemBaseID = int.Parse(mobItems[i]["item_base_id"].ToString());
                int itemType   = int.Parse(mobItems[i]["type"].ToString());
                int itemUsage  = int.Parse(mobItems[i]["usage_chance"].ToString());
                int itemDrop   = int.Parse(mobItems[i]["drop_chance"].ToString());

                DataRow inDR     = itemBase.getRowByID(itemBaseID);
                String  itemName = inDR["name"].ToString();
                int     itemCat  = int.Parse(inDR["sub_category"].ToString());
                int     asset_2d = int.Parse(inDR["2d_asset"].ToString());

                String imageFileName = baseAssets.getFileNameByID(asset_2d);

                if (itemType == 0)
                {
                    ListViewItem lvi1 = new ListViewItem(itemName, imageFileName);
                    lvi1.Tag         = mobItems[i];
                    lvi1.ToolTipText = itemName;

                    switch (itemCat)
                    {
                    case 100:
                        lvi1.Group = equippedBeamGroup;
                        break;

                    case 101:
                        lvi1.Group = equippedProjectileGroup;
                        break;

                    case 102:
                        lvi1.Group = equippedMissileGroup;
                        break;

                    case 103:
                        lvi1.Group = equippedAmmoGroup;
                        break;

                    case 110:
                        lvi1.Group = equippedDevicesGroup;
                        break;

                    case 120:
                        lvi1.Group = equippedReactorsGroup;
                        break;

                    case 121:
                        lvi1.Group = equippedEnginesGroup;
                        break;

                    case 122:
                        lvi1.Group = equippedShieldsGroup;
                        break;
                    }

                    listView1.Items.Add(lvi1);
                }
                else
                {
                    ListViewItem lvi2 = new ListViewItem(itemName, imageFileName);
                    lvi2.ToolTipText = itemName;
                    lvi2.Tag         = mobItems[i];

                    switch (itemCat)
                    {
                    case -1:
                        lvi2.Group = inventoryMiscGroup;
                        break;

                    case 100:
                        lvi2.Group = inventoryBeamGroup;
                        break;

                    case 101:
                        lvi2.Group = inventoryProjectileGroup;
                        break;

                    case 102:
                        lvi2.Group = inventoryMissileGroup;
                        break;

                    case 103:
                        lvi2.Group = inventoryAmmoGroup;
                        break;

                    case 110:
                        lvi2.Group = inventoryDevicesGroup;
                        break;

                    case 120:
                        lvi2.Group = inventoryReactorsGroup;
                        break;

                    case 121:
                        lvi2.Group = inventoryEnginesGroup;
                        break;

                    case 122:
                        lvi2.Group = inventoryShieldsGroup;
                        break;

                    case 500:
                        lvi2.Group = inventoryComponentsGroup;
                        break;

                    case 800:
                        lvi2.Group = inventoryOreGroup;
                        break;
                    }

                    listView2.Items.Add(lvi2);
                }
            }

            //Skills

            setupMainImage(baseAssetID);
        }
コード例 #12
0
        private void setupData(DataRow r)
        {
            int    objectType = int.Parse(r["type"].ToString());
            String oType      = "";

            switch (objectType)
            {
            case 0:
                oType = "Mobs";
                break;

            case 3:
                oType = "Planets";
                break;

            case 11:
                oType = "Stargates";
                break;

            case 12:
                oType = "Starbases";
                break;

            case 37:
                oType = "Decorations";
                break;

            case 38:
                oType = "Harvestables";
                break;
            }

            dp                  = new MobProps();
            dp.SectorID         = int.Parse(r["sector_id"].ToString());
            dp.NavType          = r["nav_type"].ToString();
            dp.Signature        = float.Parse(r["signature"].ToString());
            dp.IsHuge           = (Boolean)r["is_huge"];
            dp.BaseXP           = int.Parse(r["base_xp"].ToString());
            dp.ExplorationRange = float.Parse(r["exploration_range"].ToString());

            dp.BaseAssetID = int.Parse(r["base_asset_id"].ToString());

            AdobeColors.HSL hslColor = new AdobeColors.HSL();
            hslColor.H = float.Parse(r["h"].ToString());
            hslColor.S = float.Parse(r["s"].ToString());
            hslColor.L = float.Parse(r["v"].ToString());
            Color newColor = AdobeColors.HSL_to_RGB(hslColor);

            dp.Color = newColor;

            dp.Type      = oType;
            dp.Scale     = float.Parse(r["scale"].ToString());;
            dp.PositionX = float.Parse(r["position_x"].ToString());
            dp.PositionY = float.Parse(r["position_y"].ToString());
            dp.PositionZ = float.Parse(r["position_z"].ToString());;

            double[] quat1 = new double[4];
            quat1[0] = double.Parse(r["orientation_z"].ToString());
            quat1[1] = double.Parse(r["orientation_u"].ToString());
            quat1[2] = double.Parse(r["orientation_v"].ToString());
            quat1[3] = double.Parse(r["orientation_w"].ToString());

            QuaternionCalc qc1 = new QuaternionCalc();

            double[] ang1 = qc1.QuatToAngle(quat1);
            if (ang1[0] == double.NaN)
            {
                ang1[0] = 0;
            }
            if (ang1[1] == double.NaN)
            {
                ang1[1] = 0;
            }
            if (ang1[2] == double.NaN)
            {
                ang1[2] = 0;
            }
            dp.Orientation_Yaw   = Math.Round(ang1[0], 0);
            dp.Orientation_Pitch = Math.Round(ang1[1], 0);
            dp.Orientation_Roll  = Math.Round(ang1[2], 0);

            dp.Name             = r["name"].ToString();
            dp.AppearsInRadar   = (Boolean)r["appears_in_radar"];
            dp.RadarRange       = float.Parse(r["radar_range"].ToString());
            dp.Destination      = int.Parse(r["gate_to"].ToString());
            dp.SoundEffect      = int.Parse(r["sound_effect_id"].ToString());
            dp.SoundEffectRange = float.Parse(r["sound_effect_range"].ToString());

            dp.SpawnGroup   = "<Collection...>";
            dp.Count        = int.Parse(r["mob_count"].ToString());
            dp.SpawnRadius  = float.Parse(r["mob_spawn_radius"].ToString());
            dp.RespawnTime  = float.Parse(r["respawn_time"].ToString());
            dp.DelayedSpawn = (Boolean)r["delayed_spawn"];
        }
コード例 #13
0
        private void setupData(DataRow r)
        {
            int    objectType = int.Parse(r["type"].ToString());
            String oType      = "";

            switch (objectType)
            {
            case 0:
                oType = "Mobs";
                break;

            case 3:
                oType = "Planets";
                break;

            case 11:
                oType = "Stargates";
                break;

            case 12:
                oType = "Starbases";
                break;

            case 37:
                oType = "Decorations";
                break;

            case 38:
                oType = "Harvestables";
                break;
            }

            dp = new PlanetProps();

            //Base Props
            dp.SectorID         = int.Parse(r["sector_id"].ToString());
            dp.NavType          = r["nav_type"].ToString();
            dp.Signature        = float.Parse(r["signature"].ToString());
            dp.IsHuge           = (Boolean)r["is_huge"];
            dp.BaseXP           = int.Parse(r["base_xp"].ToString());
            dp.ExplorationRange = float.Parse(r["exploration_range"].ToString());

            dp.BaseAssetID = int.Parse(r["base_asset_id"].ToString());

            AdobeColors.HSL hslColor = new AdobeColors.HSL();
            hslColor.H = float.Parse(r["h"].ToString());
            hslColor.S = float.Parse(r["s"].ToString());
            hslColor.L = float.Parse(r["v"].ToString());
            Color newColor = AdobeColors.HSL_to_RGB(hslColor);

            dp.Color = newColor;

            dp.Type      = oType;
            dp.Scale     = float.Parse(r["scale"].ToString());;
            dp.PositionX = float.Parse(r["position_x"].ToString());
            dp.PositionY = float.Parse(r["position_y"].ToString());
            dp.PositionZ = float.Parse(r["position_z"].ToString());;

            double[] quat1 = new double[4];
            quat1[0] = double.Parse(r["orientation_z"].ToString());
            quat1[1] = double.Parse(r["orientation_u"].ToString());
            quat1[2] = double.Parse(r["orientation_v"].ToString());
            quat1[3] = double.Parse(r["orientation_w"].ToString());

            QuaternionCalc qc1 = new QuaternionCalc();

            double[] ang1 = qc1.QuatToAngle(quat1);
            if (ang1[0] == double.NaN)
            {
                ang1[0] = 0;
            }
            if (ang1[1] == double.NaN)
            {
                ang1[1] = 0;
            }
            if (ang1[2] == double.NaN)
            {
                ang1[2] = 0;
            }
            dp.Orientation_Yaw   = Math.Round(ang1[0], 0);
            dp.Orientation_Pitch = Math.Round(ang1[1], 0);
            dp.Orientation_Roll  = Math.Round(ang1[2], 0);

            dp.Name             = r["name"].ToString();
            dp.AppearsInRadar   = (Boolean)r["appears_in_radar"];
            dp.RadarRange       = float.Parse(r["radar_range"].ToString());
            dp.Destination      = int.Parse(r["gate_to"].ToString());
            dp.SoundEffect      = int.Parse(r["sound_effect_id"].ToString());
            dp.SoundEffectRange = float.Parse(r["sound_effect_range"].ToString());

            try
            {
                //Planet Props
                dp.OrbitID     = int.Parse(r["orbit_id"].ToString());
                dp.OrbitDist   = float.Parse(r["orbit_dist"].ToString());
                dp.OrbitAngle  = float.Parse(r["orbit_angle"].ToString());
                dp.OrbitRate   = float.Parse(r["orbit_rate"].ToString());
                dp.RotateAngle = float.Parse(r["rotate_angle"].ToString());
                dp.RotateRate  = float.Parse(r["rotate_rate"].ToString());
                dp.TiltAngle   = float.Parse(r["tilt_angle"].ToString());
                dp.IsLandable  = bool.Parse(r["is_landable"].ToString());
            }
            catch (Exception)
            {
                dp.OrbitID     = 0;
                dp.OrbitDist   = 0;
                dp.OrbitAngle  = 0;
                dp.OrbitRate   = 0;
                dp.RotateAngle = 0;
                dp.RotateRate  = 0;
                dp.TiltAngle   = 0;
                dp.IsLandable  = false;
            }
        }
コード例 #14
0
ファイル: ColorCellEditor.cs プロジェクト: zhuangyy/Motion
                    private void m_txt_Hex_Leave(object sender, System.EventArgs e)
                    {
                        string text = m_txt_Hex.Text.ToUpper();
                        bool has_illegal_chars = false;

                        if ( text.Length <= 0 )
                            has_illegal_chars = true;
                        foreach ( char letter in text )
                        {
                            if ( !char.IsNumber(letter) )
                            {
                                if ( letter >= 'A' && letter <= 'F' )
                                    continue;
                                has_illegal_chars = true;
                                break;
                            }
                        }

                        if ( has_illegal_chars )
                        {
                            MessageBox.Show("Hex must be a hex value between 0x000000 and 0xFFFFFF");
                            WriteHexData(m_rgb);
                            return;
                        }

                        m_rgb = ParseHexData(text);
                        m_hsl = AdobeColors.RGB_to_HSL(m_rgb);
                        m_cmyk = AdobeColors.RGB_to_CMYK(m_rgb);

                        m_ctrl_BigBox.HSL = m_hsl;
                        m_ctrl_ThinBox.HSL = m_hsl;
                        m_lbl_Primary_Color.BackColor = m_rgb;

                        UpdateTextBoxes();
                    }
コード例 #15
0
ファイル: ColorCellEditor.cs プロジェクト: zhuangyy/Motion
                    /// <summary>
                    /// Resets the controls color (both HSL and RGB variables) based on the current marker position
                    /// </summary>
                    private void ResetHSLRGB()
                    {
                        int red, green, blue;

                        switch (m_eDrawStyle)
                        {
                            case eDrawStyle.Hue :
                                m_hsl.S = (double)m_iMarker_X/(this.Width - 4);
                                m_hsl.L = 1.0 - (double)m_iMarker_Y/(this.Height - 4);
                                m_rgb = AdobeColors.HSL_to_RGB(m_hsl);
                                break;
                            case eDrawStyle.Saturation :
                                m_hsl.H = (double)m_iMarker_X/(this.Width - 4);
                                m_hsl.L = 1.0 - (double)m_iMarker_Y/(this.Height - 4);
                                m_rgb = AdobeColors.HSL_to_RGB(m_hsl);
                                break;
                            case eDrawStyle.Brightness :
                                m_hsl.H = (double)m_iMarker_X/(this.Width - 4);
                                m_hsl.S = 1.0 - (double)m_iMarker_Y/(this.Height - 4);
                                m_rgb = AdobeColors.HSL_to_RGB(m_hsl);
                                break;
                            case eDrawStyle.Red :
                                blue = Round(255 * (double)m_iMarker_X/(this.Width - 4));
                                green = Round(255 * (1.0 - (double)m_iMarker_Y/(this.Height - 4)));
                                m_rgb = Color.FromArgb(m_rgb.R, green, blue);
                                m_hsl = AdobeColors.RGB_to_HSL(m_rgb);
                                break;
                            case eDrawStyle.Green :
                                blue = Round(255 * (double)m_iMarker_X/(this.Width - 4));
                                red = Round(255 * (1.0 - (double)m_iMarker_Y/(this.Height - 4)));
                                m_rgb = Color.FromArgb(red, m_rgb.G, blue);
                                m_hsl = AdobeColors.RGB_to_HSL(m_rgb);
                                break;
                            case eDrawStyle.Blue :
                                red = Round(255 * (double)m_iMarker_X/(this.Width - 4));
                                green = Round(255 * (1.0 - (double)m_iMarker_Y/(this.Height - 4)));
                                m_rgb = Color.FromArgb(red, green, m_rgb.B);
                                m_hsl = AdobeColors.RGB_to_HSL(m_rgb);
                                break;
                        }
                    }
コード例 #16
0
ファイル: ColorCellEditor.cs プロジェクト: zhuangyy/Motion
                    private void m_lbl_Secondary_Color_Click(object sender, System.EventArgs e)
                    {
                        m_rgb = m_lbl_Secondary_Color.BackColor;
                        m_hsl = AdobeColors.RGB_to_HSL(m_rgb);

                        m_ctrl_BigBox.HSL = m_hsl;
                        m_ctrl_ThinBox.HSL = m_hsl;

                        m_lbl_Primary_Color.BackColor = m_rgb;
                        m_lbl_Primary_Color.Update();

                        m_cmyk = AdobeColors.RGB_to_CMYK(m_rgb);

                        m_txt_Hue.Text =		Round(m_hsl.H * 360).ToString();
                        m_txt_Sat.Text =		Round(m_hsl.S * 100).ToString();
                        m_txt_Black.Text =		Round(m_hsl.L * 100).ToString();
                        m_txt_Red.Text =		m_rgb.R.ToString();
                        m_txt_Green.Text =		m_rgb.G.ToString();
                        m_txt_Blue.Text =		m_rgb.B.ToString();
                        m_txt_Cyan.Text =		Round(m_cmyk.C * 100).ToString();
                        m_txt_Magenta.Text =	Round(m_cmyk.M * 100).ToString();
                        m_txt_Yellow.Text =		Round(m_cmyk.Y * 100).ToString();
                        m_txt_K.Text =			Round(m_cmyk.K * 100).ToString();

                        m_txt_Hue.Update();
                        m_txt_Sat.Update();
                        m_txt_Lum.Update();
                        m_txt_Red.Update();
                        m_txt_Green.Update();
                        m_txt_Blue.Update();
                        m_txt_Cyan.Update();
                        m_txt_Magenta.Update();
                        m_txt_Yellow.Update();
                        m_txt_K.Update();
                    }
コード例 #17
0
ファイル: ColorCellEditor.cs プロジェクト: zhuangyy/Motion
                    /// <summary>
                    /// Returns the graphed color at the x,y position on the control
                    /// </summary>
                    /// <param name="x"></param>
                    /// <param name="y"></param>
                    /// <returns></returns>
                    private AdobeColors.HSL GetColor(int x, int y)
                    {
                        AdobeColors.HSL _hsl = new AdobeColors.HSL();

                        switch (m_eDrawStyle)
                        {
                            case eDrawStyle.Hue :
                                _hsl.H = m_hsl.H;
                                _hsl.S = (double)x/(this.Width - 4);
                                _hsl.L = 1.0 - (double)y/(this.Height - 4);
                                break;
                            case eDrawStyle.Saturation :
                                _hsl.S = m_hsl.S;
                                _hsl.H = (double)x/(this.Width - 4);
                                _hsl.L = 1.0 - (double)y/(this.Height - 4);
                                break;
                            case eDrawStyle.Brightness :
                                _hsl.L = m_hsl.L;
                                _hsl.H = (double)x/(this.Width - 4);
                                _hsl.S = 1.0 - (double)y/(this.Height - 4);
                                break;
                            case eDrawStyle.Red :
                                _hsl = AdobeColors.RGB_to_HSL(Color.FromArgb(m_rgb.R, Round(255 * (1.0 - (double)y/(this.Height - 4))), Round(255 * (double)x/(this.Width - 4))));
                                break;
                            case eDrawStyle.Green :
                                _hsl = AdobeColors.RGB_to_HSL(Color.FromArgb(Round(255 * (1.0 - (double)y/(this.Height - 4))), m_rgb.G, Round(255 * (double)x/(this.Width - 4))));
                                break;
                            case eDrawStyle.Blue :
                                _hsl = AdobeColors.RGB_to_HSL(Color.FromArgb(Round(255 * (double)x/(this.Width - 4)), Round(255 * (1.0 - (double)y/(this.Height - 4))), m_rgb.B));
                                break;
                        }

                        return _hsl;
                    }
コード例 #18
0
ファイル: ColorCellEditor.cs プロジェクト: zhuangyy/Motion
                    private void m_txt_K_Leave(object sender, System.EventArgs e)
                    {
                        string text = m_txt_K.Text;
                        bool has_illegal_chars = false;

                        if ( text.Length <= 0 )
                            has_illegal_chars = true;
                        else
                            foreach ( char letter in text )
                            {
                                if ( !char.IsNumber(letter) )
                                {
                                    has_illegal_chars = true;
                                    break;
                                }
                            }

                        if ( has_illegal_chars )
                        {
                            MessageBox.Show("Key must be a number value between 0 and 100");
                            UpdateTextBoxes();
                            return;
                        }

                        int key = int.Parse(text);

                        if ( key < 0 )
                        {
                            MessageBox.Show("An integer between 0 and 100 is required.\nClosest value inserted.");
                            m_txt_K.Text = "0";
                            m_cmyk.K = 0.0;
                        }
                        else if ( key > 100 )
                        {
                            MessageBox.Show("An integer between 0 and 100 is required.\nClosest value inserted.");
                            m_txt_K.Text = "100";
                            m_cmyk.K = 1.0;
                        }
                        else
                        {
                            m_cmyk.K = (double)key/100;
                        }

                        m_rgb = AdobeColors.CMYK_to_RGB(m_cmyk);
                        m_hsl = AdobeColors.RGB_to_HSL(m_rgb);
                        m_ctrl_BigBox.HSL = m_hsl;
                        m_ctrl_ThinBox.HSL = m_hsl;
                        m_lbl_Primary_Color.BackColor = m_rgb;

                        UpdateTextBoxes();
                    }
コード例 #19
0
ファイル: ColorCellEditor.cs プロジェクト: zhuangyy/Motion
                    public ctrlVerticalColorSlider()
                    {
                        // This call is required by the Windows.Forms Form Designer.
                        InitializeComponent();

                        //	Initialize Colors
                        m_hsl = new AdobeColors.HSL();
                        m_hsl.H = 1.0;
                        m_hsl.S = 1.0;
                        m_hsl.L = 1.0;
                        m_rgb = AdobeColors.HSL_to_RGB(m_hsl);
                        m_eDrawStyle = eDrawStyle.Hue;
                    }
コード例 #20
0
        public void updateChangedInfo(String propertyName, Object _changedValue)
        {
            String changedValue = _changedValue.ToString();

            //Update DataRow and Graphics (only certain props require graphical updating).
            if (propertyName == "SectorID")
            {
                dr["sector_id"] = int.Parse(changedValue);
            }
            else if (propertyName == "NavType")
            {
                dr["nav_type"] = changedValue;
            }
            else if (propertyName == "Signature")
            {
                dr["signature"] = float.Parse(changedValue);

                float imageWidth  = stargateImage.Width;
                float imageHeight = stargateImage.Height;
                float x           = stargateImage.X;
                float y           = stargateImage.Y;
                stargateImage.GetChild(0).X      = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100);
                stargateImage.GetChild(0).Y      = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100);
                stargateImage.GetChild(0).Width  = (float.Parse(changedValue) * 2) / 100;
                stargateImage.GetChild(0).Height = (float.Parse(changedValue) * 2) / 100;
            }
            else if (propertyName == "IsHuge")
            {
                dr["is_huge"] = bool.Parse(changedValue);
            }
            else if (propertyName == "BaseXP")
            {
                dr["base_xp"] = int.Parse(changedValue);
            }
            else if (propertyName == "ExplorationRange")
            {
                dr["exploration_range"] = float.Parse(changedValue);

                float imageWidth  = stargateImage.Width;
                float imageHeight = stargateImage.Height;
                float x           = stargateImage.X;
                float y           = stargateImage.Y;
                stargateImage.GetChild(2).X      = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100);
                stargateImage.GetChild(2).Y      = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100);
                stargateImage.GetChild(2).Width  = (float.Parse(changedValue) * 2) / 100;
                stargateImage.GetChild(2).Height = (float.Parse(changedValue) * 2) / 100;
            }
            else if (propertyName == "BaseAssetID")
            {
                dr["base_asset_id"] = int.Parse(changedValue);
                foreach (DataGridViewRow row in _dgv.SelectedRows)
                {
                    _dgv.Rows[row.Index].Cells["base_asset_id"].Value = int.Parse(changedValue);
                    _dgv.Update();
                    _dgv.Refresh();
                }
            }
            else if (propertyName == "Color")
            {
                Color           color = (Color)_changedValue;
                AdobeColors.HSL hsv   = AdobeColors.RGB_to_HSL(color);

                dr["h"] = hsv.H;
                dr["s"] = hsv.S;
                dr["v"] = hsv.L;
            }
            else if (propertyName == "Type")
            {
                _layer.RemoveChild(stargateImage);

                /*
                 * if (changedValue == "Mobs")
                 * {
                 *  dr["type"] = 0;
                 *  new MobSprite(_layer, dr, _pg);
                 * }
                 * else if (changedValue == "Planets")
                 * {
                 *  dr["type"] = 3;
                 *  new PlanetSprite(_layer, dr, _pg);
                 * }
                 * else if (changedValue == "Starbases")
                 * {
                 *  dr["type"] = 12;
                 *  new StarbaseSprite(_layer, dr, _pg);
                 * }
                 * else if (changedValue == "Decorations")
                 * {
                 *  dr["type"] = 37;
                 *  new DecorationSprite(_layer, dr, _pg);
                 * }
                 * else if (changedValue == "Harvestables")
                 * {
                 *  dr["type"] = 38;
                 *  new HarvestableSprite(_layer, dr, _pg);
                 * }*/

                _pg.SelectedObject = null;
            }
            else if (propertyName == "Scale")
            {
                dr["scale"] = float.Parse(changedValue);
            }
            else if (propertyName == "PositionX")
            {
                dr["position_x"] = float.Parse(changedValue);

                float dx = (float.Parse(changedValue) / 100) - stargateImage.X;
                stargateImage.TranslateBy(dx, 0);
            }
            else if (propertyName == "PositionY")
            {
                dr["position_y"] = float.Parse(changedValue);

                float dy = (float.Parse(changedValue) / 100) - stargateImage.Y;
                stargateImage.TranslateBy(0, dy);
            }
            else if (propertyName == "PositionZ")
            {
                dr["position_z"] = float.Parse(changedValue);
            }
            else if (propertyName == "Orientation_Yaw" || propertyName == "Orientation_Pitch" || propertyName == "Orientation_Roll")
            {
                QuaternionCalc qtmp = new QuaternionCalc();
                double[]       q1   = qtmp.AngleToQuat(dp.Orientation_Yaw, dp.Orientation_Pitch, dp.Orientation_Roll);

                dr["orientation_z"] = q1[0];
                dr["orientation_u"] = q1[1];
                dr["orientation_v"] = q1[2];
                dr["orientation_w"] = q1[3];
            }
            else if (propertyName == "Name")
            {
                dr["name"] = changedValue;

                float x    = stargateImage.X;
                float y    = stargateImage.Y;
                PText name = (PText)stargateImage.GetChild(3);
                name.Text          = changedValue;
                name.TextAlignment = StringAlignment.Center;
                name.X             = x - (name.Width / 2);
                name.Y             = y - 20;

                foreach (DataGridViewRow row in _dgv.SelectedRows)
                {
                    _dgv.Rows[row.Index].Cells["name"].Value = changedValue;
                    _dgv.Update();
                    _dgv.Refresh();
                }
            }
            else if (propertyName == "AppearsInRadar")
            {
                dr["appears_in_radar"] = bool.Parse(changedValue);

                if (bool.Parse(changedValue) == true)
                {
                    changeImage(1);
                }
                else
                {
                    changeImage(0);
                }
            }
            else if (propertyName == "RadarRange")
            {
                dr["radar_range"] = float.Parse(changedValue);

                float imageWidth  = stargateImage.Width;
                float imageHeight = stargateImage.Height;
                float x           = stargateImage.X;
                float y           = stargateImage.Y;
                stargateImage.GetChild(1).X      = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100);
                stargateImage.GetChild(1).Y      = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100);
                stargateImage.GetChild(1).Width  = (float.Parse(changedValue) * 2) / 100;
                stargateImage.GetChild(1).Height = (float.Parse(changedValue) * 2) / 100;
            }
            else if (propertyName == "Destination")
            {
                dr["gate_to"] = int.Parse(changedValue);
            }
            else if (propertyName == "IsClassSpecific")
            {
                dr["classSpecific"] = bool.Parse(changedValue);

                if (bool.Parse(changedValue) == true)
                {
                    changeImage(2);
                }
                else
                {
                    if (bool.Parse(dr["appears_in_radar"].ToString()) == true)
                    {
                        changeImage(1);
                    }
                    else
                    {
                        changeImage(0);
                    }

                    if (int.Parse(dr["faction_id"].ToString()) > 0)
                    {
                        changeImage(3);
                    }
                }
            }
            else if (propertyName == "FactionID")
            {
                //get id from name;
                int id = mainFrm.factions.findIDbyName(changedValue);

                dr["faction_id"] = id;

                if (id > 0)
                {
                    Console.Out.WriteLine("test2");
                    changeImage(3);
                }
                else
                {
                    if (bool.Parse(dr["appears_in_radar"].ToString()) == true)
                    {
                        changeImage(1);
                    }
                    else
                    {
                        changeImage(0);
                    }

                    if (bool.Parse(dr["classSpecific"].ToString()) == true)
                    {
                        changeImage(2);
                    }
                }
            }
            else if (propertyName == "SoundEffect")
            {
                dr["sound_effect_id"] = int.Parse(changedValue);
            }
            else if (propertyName == "SoundEffectRange")
            {
                dr["sound_effect_range"] = float.Parse(changedValue);
            }

            if (dr.RowState != DataRowState.Modified)
            {
                dr.SetModified();
            }
        }
コード例 #21
0
        private void setupData(DataRow r)
        {
            int    objectType = int.Parse(r["type"].ToString());
            String oType      = "";

            switch (objectType)
            {
            case 0:
                oType = "Mobs";
                break;

            case 3:
                oType = "Planets";
                break;

            case 11:
                oType = "Stargates";
                break;

            case 12:
                oType = "Starbases";
                break;

            case 37:
                oType = "Decorations";
                break;

            case 38:
                oType = "Harvestables";
                break;
            }

            dp = new HarvestableProps();

            //Base Props
            dp.SectorID         = int.Parse(r["sector_id"].ToString());
            dp.NavType          = r["nav_type"].ToString();
            dp.Signature        = float.Parse(r["signature"].ToString());
            dp.IsHuge           = (Boolean)r["is_huge"];
            dp.BaseXP           = int.Parse(r["base_xp"].ToString());
            dp.ExplorationRange = float.Parse(r["exploration_range"].ToString());

            dp.BaseAssetID = int.Parse(r["base_asset_id"].ToString());

            AdobeColors.HSL hslColor = new AdobeColors.HSL();
            hslColor.H = float.Parse(r["h"].ToString());
            hslColor.S = float.Parse(r["s"].ToString());
            hslColor.L = float.Parse(r["v"].ToString());
            Color newColor = AdobeColors.HSL_to_RGB(hslColor);

            dp.Color = newColor;

            dp.Type      = oType;
            dp.Scale     = float.Parse(r["scale"].ToString());;
            dp.PositionX = float.Parse(r["position_x"].ToString());
            dp.PositionY = float.Parse(r["position_y"].ToString());
            dp.PositionZ = float.Parse(r["position_z"].ToString());;

            double[] quat1 = new double[4];
            quat1[0] = double.Parse(r["orientation_z"].ToString());
            quat1[1] = double.Parse(r["orientation_u"].ToString());
            quat1[2] = double.Parse(r["orientation_v"].ToString());
            quat1[3] = double.Parse(r["orientation_w"].ToString());

            QuaternionCalc qc1 = new QuaternionCalc();

            double[] ang1 = qc1.QuatToAngle(quat1);
            if (ang1[0] == double.NaN)
            {
                ang1[0] = 0;
            }
            if (ang1[1] == double.NaN)
            {
                ang1[1] = 0;
            }
            if (ang1[2] == double.NaN)
            {
                ang1[2] = 0;
            }
            dp.Orientation_Yaw   = Math.Round(ang1[0], 0);
            dp.Orientation_Pitch = Math.Round(ang1[1], 0);
            dp.Orientation_Roll  = Math.Round(ang1[2], 0);

            dp.Name             = r["name"].ToString();
            dp.AppearsInRadar   = (Boolean)r["appears_in_radar"];
            dp.RadarRange       = float.Parse(r["radar_range"].ToString());
            dp.Destination      = int.Parse(r["gate_to"].ToString());
            dp.SoundEffect      = int.Parse(r["sound_effect_id"].ToString());
            dp.SoundEffectRange = float.Parse(r["sound_effect_range"].ToString());

            //Harvestable Props
            try
            {
                dp.Level          = r["level"].ToString();
                dp.ResType        = "<Collection...>";
                dp.ResCount       = int.Parse(r["res_count"].ToString());
                dp.MobSpawnRadius = float.Parse(r["spawn_radius"].ToString());
                dp.PopRockChance  = int.Parse(r["pop_rock_chance"].ToString());
                dp.SpawnGroup     = "<Collection...>";
                dp.MaxFieldRadius = float.Parse(r["max_field_radius"].ToString());

                String fieldName = "";
                switch (int.Parse(r["field"].ToString()))
                {
                case 0:
                    fieldName = "Random";
                    break;

                case 1:
                    fieldName = "Ring";
                    break;

                case 2:
                    fieldName = "Donut";
                    break;

                case 3:
                    fieldName = "Cylinder";
                    break;

                case 4:
                    fieldName = "Sphere";
                    break;

                case 5:
                    fieldName = "Gas Cloud Clump";
                    break;
                }

                dp.Field = fieldName;
            }
            catch (Exception)
            {
                dp.Level          = "1";
                dp.Field          = "Single";
                dp.ResCount       = 0;
                dp.MaxFieldRadius = 0;
                dp.MobSpawnRadius = 0;
                dp.PopRockChance  = 0;
                dp.SpawnGroup     = "<Collection...>";
            }
        }