Ejemplo n.º 1
0
        private void comboBoxEditSavedConnectionOracle_SelectedIndexChanged(object sender, EventArgs e)
        {
            _selectedConnectionId = string.Empty;

            textEditAliasPostgres.Text    = string.Empty;
            textEditHostOrIPPostgres.Text = string.Empty;
            textEditPasswordOracle.Text   = string.Empty;
            textEditUsernameOracle.Text   = string.Empty;


            var secili = DxHelper.GetSelectedItem(comboBoxEditSavedConnectionOracle);

            if (secili.Value.ToString() != "-1")
            {
                var data = AppHelper.GetSavedConnections(true).FirstOrDefault(a => a.Id == secili.Value.ToString());
                if (data != null)
                {
                    textEditAliasOracle.Text = data.Alias;
                    DxHelper.SetSelectedValue(comboBoxEditTnsNamesOracle, data.HostOrIp);
                    textEditUsernameOracle.Text = data.Username;
                    textEditPasswordOracle.Text = data.Password;
                    _selectedConnectionId       = data.Id;
                }
            }
        }
Ejemplo n.º 2
0
 private void LoadSettings()
 {
     for (var i = 0; i < Program.MainSettings.BoardInfomation.Count; i++)
     {
         var item = Program.MainSettings.BoardInfomation[i];
         Boards.Add(new Board(item.Width, item.Height));
         Boards[i].VisibleBoard = item.VisibleBoard;
         for (var j = 0; j < item.BoardPointInfomation.Count; j++)
         {
             var item2 = item.BoardPointInfomation[j];
             Boards[i].SetColor(item2.X, item2.Y, item2.Color);
             Boards[i].SetVisible(item2.X, item2.Y, item2.Visible);
             if (item2.ImagePath != null)
             {
                 Boards[i].SetNormalImage(item2.X, item2.Y,
                                          DxHelper.LoadFromFile(Path.Combine(_resPath, item2.ImagePath)));
             }
             if (item2.ImagePathA != null)
             {
                 Boards[i].SetActiveImage(item2.X, item2.Y,
                                          DxHelper.LoadFromFile(Path.Combine(_resPath, item2.ImagePathA)));
             }
         }
     }
 }
Ejemplo n.º 3
0
        private void comboBoxEditSavedConnectionPostgres_SelectedIndexChanged(object sender, EventArgs e)
        {
            _selectedConnectionId = string.Empty;

            textEditAliasPostgres.Text    = string.Empty;
            textEditDatabasePostgres.Text = string.Empty;
            textEditHostOrIPPostgres.Text = string.Empty;
            textEditPasswordPostgres.Text = string.Empty;
            textEditPortPostgres.Text     = "5432";
            textEditUsernamePostgres.Text = string.Empty;


            var secili = DxHelper.GetSelectedItem(comboBoxEditSavedConnectionPostgres);

            if (secili.Value.ToString() != "-1")
            {
                var data = AppHelper.GetSavedConnections(true).FirstOrDefault(a => a.Id == secili.Value.ToString());
                if (data != null)
                {
                    textEditAliasPostgres.Text    = data.Alias;
                    textEditDatabasePostgres.Text = data.Database;
                    textEditHostOrIPPostgres.Text = data.HostOrIp;
                    textEditPasswordPostgres.Text = data.Password;
                    textEditPortPostgres.Text     = data.Port.ToString();
                    textEditUsernamePostgres.Text = data.Username;
                    _selectedConnectionId         = data.Id;
                }
            }
        }
        private void comboBoxEditSavedConnection_SelectedIndexChanged(object sender, EventArgs e)
        {
            var selected = DxHelper.GetSelectedItem(comboBoxEditSavedConnection);

            treeListTableList.DataSource = null;
            if (selected.Value.ToString() != "-1")
            {
                var list       = new List <DbTableModelItem>();
                var connection = AppHelper.GetSavedConnections().FirstOrDefault(a => a.Id == selected.Value.ToString());
                if (connection.DatabaseType == Models.DbType.Oracle)
                {
                    string _connectionString = "User Id=" + connection.Username + ";Password="******";Data Source=" + connection.HostOrIp + ";";
                    using (OracleConnection cnn = new OracleConnection(_connectionString))
                    {
                        cnn.Open();
                        OracleDataAdapter da = new OracleDataAdapter("Select table_name from user_tables where table_name like '%_GEO_%' order by table_name", cnn);
                        DataTable         dt = new DataTable();
                        da.Fill(dt);

                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            list.Add(new DbTableModelItem()
                            {
                                Connection = connection,
                                IsOpen     = Program.mainForm.OpenedTables.Any(async => async.TableName == dt.Rows[i][0].ToString() && async.Connection.Id == connection.Id),
                                TableName  = dt.Rows[i][0].ToString()
                            });
                        }
                    }
                }
                treeListTableList.DataSource = list;
            }
        }
Ejemplo n.º 5
0
        public new void Draw()
        {
            Sprite.BasicEffect.View = Matrix.CreateScale(scaleModel) *
                                      Matrix.CreateBillboard(position, Camara.Position, Vector3.Up, Camara.ForwardVector) *
                                      Matrix.CreateRotationY(Helper.DegreeToRad(angle)) *
                                      Camara.View;

            DxHelper.DrawSquare(textureID);

            Sprite.BasicEffect.View = Camara.View;
        }
Ejemplo n.º 6
0
        private void ConnectToDb_Load(object sender, EventArgs e)
        {
            var data = AppHelper.GetSavedConnections().OrderBy(a => a.Alias).ToList();

            var lstPostgres = new List <ControlItemModel>();

            foreach (var item in data.Where(a => a.DatabaseType == Models.DbType.PostgreSQL))
            {
                lstPostgres.Add(new ControlItemModel()
                {
                    Text  = item.Alias + " (" + item.HostOrIp + ")",
                    Value = item.Id
                });
            }
            DxHelper.FillItems(comboBoxEditSavedConnectionPostgres, lstPostgres, "Choose...");

            var lstOracle = new List <ControlItemModel>();

            foreach (var item in data.Where(a => a.DatabaseType == Models.DbType.Oracle))
            {
                lstOracle.Add(new ControlItemModel()
                {
                    Text  = item.Alias + " (" + item.HostOrIp + ")",
                    Value = item.Id
                });
            }
            DxHelper.FillItems(comboBoxEditSavedConnectionOracle, lstOracle, "Choose...");

            var tnsAdmin = Environment.GetEnvironmentVariable("TNS_ADMIN");

            if (!string.IsNullOrEmpty(tnsAdmin))
            {
                using (StreamReader reader = new StreamReader(tnsAdmin + "\\tnsnames.ora"))
                {
                    var connections = reader.ReadToEnd();
                    var tnsNames    = new List <ControlItemModel>();
                    foreach (Match m in Regex.Matches(connections, AppHelper.TnsRegexParsers))
                    {
                        string name = m.Groups["name"].Value;
                        tnsNames.Add(new ControlItemModel()
                        {
                            Text  = name,
                            Value = name
                        });
                    }
                    DxHelper.FillItems(comboBoxEditTnsNamesOracle, tnsNames.OrderBy(a => a.Text).ToList(), "Choose...");
                }
            }
        }
        private void OpenTableFromDatabaseForm_Load(object sender, EventArgs e)
        {
            var data           = AppHelper.GetSavedConnections().OrderBy(a => a.Alias).ToList();
            var lstConnections = new List <ControlItemModel>();

            foreach (var item in data)
            {
                lstConnections.Add(new ControlItemModel()
                {
                    Text  = item.Alias + " (" + item.HostOrIp + ")",
                    Value = item.Id
                });
            }
            DxHelper.FillItems(comboBoxEditSavedConnection, lstConnections, "Choose...");
        }
Ejemplo n.º 8
0
        public Particle(int count)
        {
            _particleCount = count;

            // Load bitmap
            FileInfo[] fis = new DirectoryInfo("element").GetFiles("*.png", SearchOption.TopDirectoryOnly);
            _oriBitmaps = new D2D.Bitmap[fis.Length];
            for (int i = 0; i < _oriBitmaps.Length; i++)
            {
                _oriBitmaps[i] = DxHelper.LoadFromFile(fis[i].FullName);
            }

            _startPos = new Mathe.RawVector2[count];
            _nowPos   = new Mathe.RawVector2[count];
            _speeds   = new float[count];
            _timings  = new float[count];
            _bitmaps  = new D2D.Bitmap[count];

            _r           = new float[count];
            _startF      = new float[count];
            _f           = new float[count];
            _shakeOffset = new float[count];
            _shakeCycle  = new float[count];

            for (int i = 0; i < count; i++)
            {
                _bitmaps[i]  = _oriBitmaps[_rnd.Next(0, _oriBitmaps.Length)];
                _r[i]        = (float)(_rnd.NextDouble() * 20);
                _startF[i]   = (float)_rnd.NextDouble();
                _speeds[i]   = _r[i] * _r[i] * 0.0005f;
                _timings[i]  = 1 / _speeds[i] * 1000;
                _startPos[i] =
                    new Mathe.RawVector2(_rnd.Next(0, RenderForm.Width), RenderForm.Height + _rnd.Next(40, 50));
                _shakeCycle[i]  = 1 / _speeds[i] * 500;
                _shakeOffset[i] = (float)_rnd.NextDouble() * _shakeCycle[i];
            }

            _sw = new Stopwatch();
            _sw.Restart();
        }
Ejemplo n.º 9
0
        public new void Draw()
        {
            Sprite.BasicEffect.View = Matrix.CreateScale(4) *
                                      Matrix.CreateBillboard(position, Camara.Position, Vector3.Up, Camara.ForwardVector) *
                                      Camara.View;

            DxHelper.DrawSquare(textureID);

            Sprite.BasicEffect.Alpha = lightIntensity;

            Sprite.BasicEffect.View = Matrix.CreateTranslation(0, 0, -1) * Sprite.BasicEffect.View;
            Sprite.BasicEffect.View = Matrix.CreateScale(4) * Sprite.BasicEffect.View;



            DxHelper.DrawSquare(sunGlow);
            Sprite.BasicEffect.Alpha = 1;


            //Gl.glDisable(//Gl.GL_FOG);
            //Gl.glPushMatrix();
            //Gl.glBlendFunc(//Gl.GL_SRC_ALPHA, //Gl.GL_ONE_MINUS_SRC_ALPHA);
            //Gl.glEnable(//Gl.GL_TEXTURE_2D);
            //Gl.glEnable(//Gl.GL_BLEND);
            //Gl.glTranslatef(position.X, position.Y, position.Z);
            //Gl.glRotatef(-Camara.Yaw, 0, 1, 0);
            //Gl.glRotatef(-Camara.Pitch, 1, 0, 0);
            //Gl.glScalef(12, 12, 1);
            //Gl.glColor4f(1, 1, 1, lightIntensity);
            //Gl.glBindTexture(//Gl.GL_TEXTURE_2D, sunGlow);
            //Gl.glCallList(initList);
            //Gl.glColor4f(1, 1, 1, 1);
            //Gl.glBindTexture(//Gl.GL_TEXTURE_2D, textureID);
            //Gl.glScalef(0.22f, 0.22f, 1);
            //Gl.glCallList(initList);
            //Gl.glDisable(//Gl.GL_BLEND);
            //Gl.glPopMatrix();
            //Gl.glEnable(//Gl.GL_FOG);
        }
Ejemplo n.º 10
0
        private void simpleButtonConnect_Click(object sender, EventArgs e)
        {
            if (xtraTabControlMain.SelectedTabPageIndex == 0) // Postgresql
            {
                var model = new DbConnectionModel();
                model.Alias    = textEditAliasPostgres.Text.Trim();
                model.Database = textEditDatabasePostgres.Text.Trim();
                model.HostOrIp = textEditHostOrIPPostgres.Text.Trim();
                model.Password = textEditPasswordPostgres.Text.Trim();
                model.Port     = int.Parse(textEditPortPostgres.Text.Trim());
                model.Username = textEditUsernamePostgres.Text.Trim();

                string _connectionString = "Server = " + model.HostOrIp + "; Port = " + model.Port + "; Database = " + model.Database + "; User Id = " + model.Username + "; Password = "******";";
                try
                {
                    using (NpgsqlConnection cnn = new NpgsqlConnection(_connectionString))
                    {
                        cnn.Open();
                        NpgsqlDataAdapter da = new NpgsqlDataAdapter("Select 1", cnn);
                        DataTable         dt = new DataTable();
                        da.Fill(dt);

                        if (dt.Rows.Count > 0)
                        {
                            if (toggleSwitchSaveConnectionPostgres.IsOn)
                            {
                                if (!string.IsNullOrEmpty(_selectedConnectionId))
                                {
                                    AppHelper.RemoveConnection(_selectedConnectionId);
                                }
                                model.DatabaseType = Models.DbType.PostgreSQL;
                                AppHelper.SaveConnection(model);
                                this.Close();
                            }
                        }
                        else
                        {
                            XtraMessageBox.Show("Cannot connect to database. Please check");
                            this.DialogResult = DialogResult.None;
                        }
                    }
                }
                catch (Exception ex)
                {
                    XtraMessageBox.Show("Cannot connect to database. Please check");
                    this.DialogResult = DialogResult.None;
                }
            }
            else if (xtraTabControlMain.SelectedTabPageIndex == 1) // Oracle
            {
                var tns = DxHelper.GetSelectedItem(comboBoxEditTnsNamesOracle);
                if (tns.Value.ToString() != "-1")
                {
                    var model = new DbConnectionModel();
                    model.Alias    = textEditAliasOracle.Text.Trim();
                    model.HostOrIp = tns.Text.Trim();
                    model.Password = textEditPasswordOracle.Text.Trim();
                    model.Username = textEditUsernameOracle.Text.Trim();

                    string _connectionString = "User Id=" + model.Username + ";Password="******";Data Source=" + model.HostOrIp + ";";
                    try
                    {
                        using (OracleConnection cnn = new OracleConnection(_connectionString))
                        {
                            cnn.Open();
                            OracleDataAdapter da = new OracleDataAdapter("Select 1 from dual", cnn);
                            DataTable         dt = new DataTable();
                            da.Fill(dt);

                            if (dt.Rows.Count > 0)
                            {
                                if (toggleSwitchIsSaveConnectionOracle.IsOn)
                                {
                                    if (!string.IsNullOrEmpty(_selectedConnectionId))
                                    {
                                        AppHelper.RemoveConnection(_selectedConnectionId);
                                    }
                                    model.DatabaseType = Models.DbType.Oracle;
                                    AppHelper.SaveConnection(model);
                                    this.Close();
                                }
                            }
                            else
                            {
                                XtraMessageBox.Show("Cannot connect to database. Please check");
                                this.DialogResult = DialogResult.None;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        XtraMessageBox.Show("Cannot connect to database. Please check");
                        this.DialogResult = DialogResult.None;
                    }
                }
            }
        }
Ejemplo n.º 11
0
 public Background()
 {
     _bgBitmap = DxHelper.LoadFromFile(Path.Combine(_resPath, Program.MainSettings.Background));
 }
Ejemplo n.º 12
0
        private void ShowBox(MouseEventArgs e, Mathe.RawRectangleF recF, int i)
        {
            if (e.Button == MouseButtons.Right)
            {
                if (true)
                {
                    switch (i)
                    {
                    case 24:
                        Boards[1].IsActive[0, 2] = !Boards[1].IsActive[0, 2];
                        break;

                    case 25:
                        Boards[1].IsActive[1, 1] = !Boards[1].IsActive[1, 1];
                        break;

                    case 26:
                        Boards[1].IsActive[1, 2] = !Boards[1].IsActive[1, 2];
                        break;

                    case 27:
                        Boards[1].IsActive[1, 3] = !Boards[1].IsActive[1, 3];
                        break;

                    case 28:
                        Boards[1].IsActive[2, 0] = !Boards[1].IsActive[2, 0];
                        break;

                    case 29:
                        Boards[1].IsActive[2, 1] = !Boards[1].IsActive[2, 1];
                        break;

                    case 30:
                        if (!Boards[1].IsActive[2, 2])
                        {
                            Boards[1].IsActive[2, 2] = true;
                        }
                        else
                        {
                            switch (_sevenLv)
                            {
                            case 0:
                                Boards[1].SetActiveImage(2, 2,
                                                         DxHelper.LoadFromFile(Path.Combine(_resPath, "7B.png")));
                                _sevenLv = 1;
                                break;

                            case 1:
                                Boards[1].SetActiveImage(2, 2,
                                                         DxHelper.LoadFromFile(Path.Combine(_resPath, "7C.png")));
                                _sevenLv = 2;
                                break;

                            default:
                                Boards[1].IsActive[2, 2] = false;
                                Boards[1].SetActiveImage(2, 2,
                                                         DxHelper.LoadFromFile(Path.Combine(_resPath, "7A.png")));
                                _sevenLv = 0;
                                break;
                            }
                        }
                        break;

                    case 31:
                        Boards[1].IsActive[2, 3] = !Boards[1].IsActive[2, 3];
                        break;

                    case 32:
                        Boards[1].IsActive[2, 4] = !Boards[1].IsActive[2, 4];
                        break;

                    case 33:
                        Boards[1].IsActive[3, 1] = !Boards[1].IsActive[3, 1];
                        break;

                    case 34:
                        Boards[1].IsActive[3, 2] = !Boards[1].IsActive[3, 2];
                        break;

                    case 35:
                        Boards[1].IsActive[3, 3] = !Boards[1].IsActive[3, 3];
                        break;

                    case 36:
                        Boards[1].IsActive[4, 2] = !Boards[1].IsActive[4, 2];
                        break;
                    }
                }
                switch (i)
                {
                case 0:
                case 16:
                    if (Boards[0].IsActive[0, 2] && Boards[0].IsActive[4, 6])
                    {
                        Boards[1].IsActive[0, 2] = false;
                        Boards[1].IsActive[1, 3] = false;
                        Boards[1].IsActive[2, 4] = false;
                        Boards[0].IsActive[0, 2] = false;
                        Boards[0].IsActive[4, 6] = false;
                        HasActive = false;
                    }
                    break;

                case 1:
                case 22:
                    if (Boards[0].IsActive[0, 3] && Boards[0].IsActive[6, 3])
                    {
                        Boards[1].IsActive[0, 2] = false;
                        Boards[1].IsActive[1, 2] = false;
                        Boards[1].IsActive[2, 2] = false;
                        Boards[1].IsActive[3, 2] = false;
                        Boards[1].IsActive[4, 2] = false;
                        Boards[0].IsActive[0, 3] = false;
                        Boards[0].IsActive[6, 3] = false;
                        HasActive = false;
                    }
                    break;

                case 2:
                case 13:
                    if (Boards[0].IsActive[0, 4] && Boards[0].IsActive[4, 0])
                    {
                        Boards[1].IsActive[0, 2] = false;
                        Boards[1].IsActive[1, 1] = false;
                        Boards[1].IsActive[2, 0] = false;
                        Boards[0].IsActive[0, 4] = false;
                        Boards[0].IsActive[4, 0] = false;
                        HasActive = false;
                    }
                    break;

                case 3:
                case 20:
                    if (Boards[0].IsActive[1, 1] && Boards[0].IsActive[5, 5])
                    {
                        Boards[1].IsActive[1, 1] = false;
                        Boards[1].IsActive[2, 2] = false;
                        Boards[1].IsActive[3, 3] = false;
                        Boards[0].IsActive[1, 1] = false;
                        Boards[0].IsActive[5, 5] = false;
                        HasActive = false;
                    }
                    break;

                case 4:
                case 18:
                    if (Boards[0].IsActive[1, 2] && Boards[0].IsActive[5, 2])
                    {
                        Boards[1].IsActive[1, 1] = false;
                        Boards[1].IsActive[2, 1] = false;
                        Boards[1].IsActive[3, 1] = false;
                        Boards[0].IsActive[1, 2] = false;
                        Boards[0].IsActive[5, 2] = false;
                        HasActive = false;
                    }
                    break;

                case 5:
                case 19:
                    if (Boards[0].IsActive[1, 4] && Boards[0].IsActive[5, 4])
                    {
                        Boards[1].IsActive[1, 3] = false;
                        Boards[1].IsActive[2, 3] = false;
                        Boards[1].IsActive[3, 3] = false;
                        Boards[0].IsActive[1, 4] = false;
                        Boards[0].IsActive[5, 4] = false;
                        HasActive = false;
                    }
                    break;

                case 6:
                case 17:
                    if (Boards[0].IsActive[1, 5] && Boards[0].IsActive[5, 1])
                    {
                        Boards[1].IsActive[1, 3] = false;
                        Boards[1].IsActive[2, 2] = false;
                        Boards[1].IsActive[3, 1] = false;
                        Boards[0].IsActive[1, 5] = false;
                        Boards[0].IsActive[5, 1] = false;
                        HasActive = false;
                    }
                    break;

                case 7:
                case 23:
                    if (Boards[0].IsActive[2, 0] && Boards[0].IsActive[6, 4])
                    {
                        Boards[1].IsActive[2, 0] = false;
                        Boards[1].IsActive[3, 1] = false;
                        Boards[1].IsActive[4, 2] = false;
                        Boards[0].IsActive[2, 0] = false;
                        Boards[0].IsActive[6, 4] = false;
                        HasActive = false;
                    }
                    break;

                case 8:
                case 9:
                    if (Boards[0].IsActive[2, 1] && Boards[0].IsActive[2, 5])
                    {
                        Boards[1].IsActive[1, 1] = false;
                        Boards[1].IsActive[1, 2] = false;
                        Boards[1].IsActive[1, 3] = false;
                        Boards[0].IsActive[2, 1] = false;
                        Boards[0].IsActive[2, 5] = false;
                        HasActive = false;
                    }
                    break;

                case 10:
                case 21:
                    if (Boards[0].IsActive[2, 6] && Boards[0].IsActive[6, 2])
                    {
                        Boards[1].IsActive[2, 4] = false;
                        Boards[1].IsActive[3, 3] = false;
                        Boards[1].IsActive[4, 2] = false;
                        Boards[0].IsActive[2, 6] = false;
                        Boards[0].IsActive[6, 2] = false;
                        HasActive = false;
                    }
                    break;

                case 11:
                case 12:
                    if (Boards[0].IsActive[3, 0] && Boards[0].IsActive[3, 6])
                    {
                        Boards[1].IsActive[2, 0] = false;
                        Boards[1].IsActive[2, 1] = false;
                        Boards[1].IsActive[2, 2] = false;
                        Boards[1].IsActive[2, 3] = false;
                        Boards[1].IsActive[2, 4] = false;
                        Boards[0].IsActive[3, 0] = false;
                        Boards[0].IsActive[3, 6] = false;
                        HasActive = false;
                    }
                    break;

                case 14:
                case 15:
                    if (Boards[0].IsActive[4, 1] && Boards[0].IsActive[4, 5])
                    {
                        Boards[1].IsActive[3, 1] = false;
                        Boards[1].IsActive[3, 2] = false;
                        Boards[1].IsActive[3, 3] = false;
                        Boards[0].IsActive[4, 1] = false;
                        Boards[0].IsActive[4, 5] = false;
                        HasActive = false;
                    }
                    break;

                default:
                    return;
                }
                return;
            }
            string fileName;

            switch (i)
            {
            case 0:
            case 16:
                fileName = "des_7.png";
                break;

            case 1:
            case 22:
                fileName = "des_5.png";
                break;

            case 2:
            case 13:
                fileName = "des_10.png";
                break;

            case 3:
            case 20:
                fileName = "des_11.png";
                break;

            case 4:
            case 18:
                fileName = "des_3.png";
                break;

            case 5:
            case 19:
                fileName = "des_2.png";
                break;

            case 6:
            case 17:
                fileName = "des_4.png";
                break;

            case 7:
            case 23:
                fileName = "des_12.png";
                break;

            case 8:
            case 9:
                fileName = "des_9.png";
                break;

            case 10:
            case 21:
                fileName = "des_0.png";
                break;

            case 11:
            case 12:
                fileName = "des_6.png";
                break;

            case 14:
            case 15:
                fileName = "des_8.png";
                break;

            case 30:
                fileName = "des_1.png";
                break;

            default:
                return;
            }

            PointF loc = new PointF(recF.Left, recF.Top);

            _boxBitmap = DxHelper.LoadFromFile(Path.Combine(_resPath, fileName));

            const float scaled  = 2f;
            float       scaledW = _boxBitmap.Size.Width / scaled,
                        scaledH = _boxBitmap.Size.Height / scaled;
            float left          = loc.X - 35,
                  top           = loc.Y - scaledH + 30,
                  right         = left + scaledW,
                  bottom        = top + scaledH;

            _boxRec        = new Mathe.RawRectangleF(left, top, right, bottom);
            _tmpRectangles = Rectangles.ToArray().ToList();
            Rectangles.Clear();
            Rectangles.AddRange(new[]
            {
                new Mathe.RawRectangleF(0, 0, RenderForm.Width, top),
                new Mathe.RawRectangleF(0, top, left, bottom),
                new Mathe.RawRectangleF(right, top, RenderForm.Width, bottom),
                new Mathe.RawRectangleF(0, bottom, RenderForm.Width, RenderForm.Height),
            });
            _isBoxing = true;
        }
Ejemplo n.º 13
0
    public void Compile(string codeText, string output, string fxName, ShaderProfile shaderProfile = ShaderProfile.ps_2_0)
    {
        IsCompiled = false;
        string path            = output;
        IntPtr defines         = IntPtr.Zero;
        IntPtr includes        = IntPtr.Zero;
        IntPtr ppConstantTable = IntPtr.Zero;
        string methodName      = "main";
        string targetProfile2  = "ps_2_0";

        targetProfile2 = ((shaderProfile != ShaderProfile.ps_3_0) ? "ps_2_0" : "ps_3_0");
        bool        useDx10 = false;
        int         hr2     = 0;
        ID3DXBuffer ppShader2;
        ID3DXBuffer ppErrorMsgs2;

        if (!useDx10)
        {
            hr2 = ((IntPtr.Size != 8) ?
                   DxHelper.D3DXCompileShader(codeText, codeText.Length, defines, includes, methodName, targetProfile2, 0, out ppShader2, out ppErrorMsgs2, out ppConstantTable)
                                :
                   DxHelper.D3DXCompileShader64Bit(codeText, codeText.Length, defines, includes, methodName, targetProfile2, 0, out ppShader2, out ppErrorMsgs2, out ppConstantTable));
        }
        else
        {
            int pHr = 0;
            hr2 = DxHelper.D3DX10CompileFromMemory(codeText, codeText.Length, string.Empty, IntPtr.Zero, IntPtr.Zero, methodName, targetProfile2, 0, 0, IntPtr.Zero, out ppShader2, out ppErrorMsgs2, ref pHr);
        }
        if (hr2 != 0)
        {
            IntPtr errors = ppErrorMsgs2.GetBufferPointer();
            ppErrorMsgs2.GetBufferSize();
            ErrorText  = Marshal.PtrToStringAnsi(errors);
            IsCompiled = false;
        }
        else
        {
            ErrorText  = "";
            IsCompiled = true;
            string psPath         = path + fxName;
            IntPtr pCompiledPs    = ppShader2.GetBufferPointer();
            int    compiledPsSize = ppShader2.GetBufferSize();
            byte[] compiledPs     = new byte[compiledPsSize];
            Marshal.Copy(pCompiledPs, compiledPs, 0, compiledPs.Length);
            using (FileStream psFile = File.Open(psPath, FileMode.Create, FileAccess.Write))
            {
                psFile.Write(compiledPs, 0, compiledPs.Length);
            }
        }
        if (ppShader2 != null)
        {
            Marshal.ReleaseComObject(ppShader2);
        }
        ppShader2 = null;
        if (ppErrorMsgs2 != null)
        {
            Marshal.ReleaseComObject(ppErrorMsgs2);
        }
        ppErrorMsgs2 = null;
        CompileFinished();
    }