0

I'm using linq on a array and I need to find the index of the linq result. Is this possible? how?
My thanks in advanced.

This is my code:

Vector3[] vertices=mesh.vertices;

var V3=(from cur in vertices
        where (cur.x==point.PointX) && (cur.y==point.PointY)
        select cur).FirstOrDefault();
0

When I save an image into the database, the image field has the following information in the field:
<Binary Data>
But when I read the image from the database I get a "X" or a number like "4172726179" and the image is not displayed.
I'm using this code for displaying the image:
<?php
...
print "<img src='" . $row["image"] . "' alt='test' width='128' height='128' />"

...
?>

How can I display the image in the database?

My thanks in advanced

0

I need to change the background image of a button that is declared in xaml, like this:

 <Button x:Name="btnBorder" Content="Moldura" Width="80" Height="80"
         Margin="10,6,10,6"
         Click="btnBorder_Click"
         >
         <Button.Background>
            <ImageBrush ImageSource="/Images/arrow-expand.png" AlignmentX="Center"  Stretch="None" x:Name="imgSourceArrow" />
         </Button.Background>

</Button>

and I'm trying to change the ImageSource of the ImageBrush. For that, I'm using this code in the code-behind:

ImageBrush imgb = new ImageBrush(new BitmapImage(new Uri("/Resources/arrow-expand.png")));
W.btnBorder.Background = imgb;

But when I run the Application, I get an error "UriFormatException was unhandled", "Invalid Uri"...
How can I reference the "arrow-expand.png" image inside the resources and transform it into an Uri String to be passed into the "new Uri" constructor?

My thanks in advanced

0

I'm trying to create an ASP .NET MVC WebSite that allows the user to enter the website
without providing any additional information or by specifying an id or a name. Is this possible?
How?
I've tried the following method but it's not working

 public void Index()
        {
            //...
            ProcessClient();
        }

        public void Index(int id)
        {
            //...
            ProcessClient();

        }

        public void Index(String guid)
        {
            //...
            ProcessClient();

        }

        public ActionResult ProcessClient()
        {
            return View("Index");
        }

My thanks in advanced

0

I've made a rectangle with another 3D point inside. The rectangle is textured with an image. Now, I need to move the point that is inside the rectangle to another 3D position. Does anyone knows how this is possible?
The only way I found, that is no good for what I need to achieve was to create another function similar to the one I post here, clear the viewport and redefine the point. This doesn't work in my case because I want the texture to follow the point that was already defined when the texture was set, meaning that the point has to be moved, not created again.
Can you please help?
My thanks in advanced.

Here is my code:

        private void Draw2()
        {

            //Points
            Point3D point0 = new Point3D(0, 0, 0);
            Point3D point1 = new Point3D(2, 0, 0);
            Point3D point4 = new Point3D(1, 0, -1);
            Point3D point2 = new Point3D(2, 0, -4);
            Point3D point3 = new Point3D(0, 0, -4);

            //triangleMesh
            triangleMesh.Positions.Add(point0);

            triangleMesh.Positions.Add(point1);
            triangleMesh.Positions.Add(point4);

            triangleMesh.Positions.Add(point2);
            triangleMesh.Positions.Add(point3);

            triangleMesh.TriangleIndices.Add(0);
            triangleMesh.TriangleIndices.Add(1);
            triangleMesh.TriangleIndices.Add(2);

            triangleMesh.TriangleIndices.Add(2);
            triangleMesh.TriangleIndices.Add(1);
            triangleMesh.TriangleIndices.Add(3);

            triangleMesh.TriangleIndices.Add(2);
            triangleMesh.TriangleIndices.Add(3);
            triangleMesh.TriangleIndices.Add(4);

            triangleMesh.TriangleIndices.Add(2);
            triangleMesh.TriangleIndices.Add(4);
            triangleMesh.TriangleIndices.Add(0);

            triangleMesh.TextureCoordinates.Add(new System.Windows.Point(0, 0));
            triangleMesh.TextureCoordinates.Add(new System.Windows.Point(0, 1));
            triangleMesh.TextureCoordinates.Add(new System.Windows.Point(1, 1));
            triangleMesh.TextureCoordinates.Add(new System.Windows.Point(1, 0));

            //define the normal, manually
            Vector3D normal = new Vector3D(0, 1, 0);
            triangleMesh.Normals.Add(normal);

            //Materials

            /*******************************
             * 
             *
             * */

            ImageBrush imgBrush = new ImageBrush();
            //imgBrush.ImageSource = new BitmapImage(new Uri(@"FrontalFace.png", UriKind.Relative));
            imgBrush.ImageSource = new BitmapImage(new Uri(@"temp.jpg", UriKind.Relative));

            imgBrush.Stretch = Stretch.UniformToFill;
            imgBrush.TileMode = TileMode.Tile;

            Material material = new DiffuseMaterial(imgBrush);

            /*******************************
             * 
             *
             * */

            //Create the model
            triangleModel = new GeometryModel3D(triangleMesh, material);

            model.Content ...
0

I'm searching for a forum for my website http://www.game4tress.com
The only free forum I know is https://www.phpbb.com/
The problem is that I've used this forum in the past and I used to receive false posts (like spam).
One other situation is that I also want to integrate the forum with the website. I want it to be inside the bounds of the website itself.
Do you know any other forum that is more secure and flexible?

My thanks in advanced

0

I have the Ajax call listed bellow inside a jquery function, and the ajax call is not working. I've used "alert" to debug and its like the jquery function didn't even had the ajax call. Nothing inside it is processed, with no sucess and no errors.
Isn't it possible to add an ajax function inside a jquery bind method or is it something else I'm doing wrong?

$('#ids').bind('click',function(event){

            var str ="#" + event.target.id;
            var subs=str.substring(2,str.length);
                        selectedWeapon="#E" + subs;
                        var mWeapon=$(selectedWeapon).text();

            if(mWeapon=="Attack!")
            {

                indexInfo=selectedWeapon.indexOf('_');
                            if(indexInfo>0)
                            {
                                var res = "#" + selectedWeapon.substring(1,indexInfo) + "_VALS";
                                var resQT = "#" + selectedWeapon.substring(1,indexInfo) +  "_NumberToSend";

                                selectedWeapon=$(res ).val();
                                selectedQuantity=$(resQT).val();

                                if(EnemyInfo!="")
                                {
                                    $('#txtAttackInfo').val(selectedWeapon);
                                        var tmp="";
                                        var ReturnValue1=40;

                                        // Obtain selected Object ID
                        $.ajax({
                            type: 'POST',
                            url: 'returnObjectID.php',
                            data:  'Name=' + selectedWeapon,
                            cache: false,
                            success: function(result) {
                                ReturnValue1=43;
                                  if(result){
                                    ReturnValue1=22;//result;

                                                  }
                                                  else
                                                  {
                                                    ReturnValue1=-1;
                                                  }
                                            },
                                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                    alert("Status: " + textStatus); 
                                    alert("Error: " + errorThrown);
                                    ReturnValue1=-4;

                                }
                        });

                        tmp="Attacking Player: " + EnemyInfo;
                                        $("#divAtackInfo").html(tmp);
                        alert("Sending " + selectedQuantity + " " + selectedWeapon + " to " + EnemyInfo + " With returned id:" + ReturnValue1); 

                                }
                            }

                                $('#txtAttackInfo').val(selectedWeapon);

            }

        });  

My thanks in advanced

0

I'm creating a chat system and the problem is that when testing with two users, the secound user (entering the system) can see the first user (already loged in), but the first user will never see the next user(s) entering the system.
I know that the problem comes from the jquery, ajax call that I'm listing bellow. That code is responsible for creating a table with the users online. I think that the problem exists because the first time the code is run the table is created, but from there on the table is never recreated, that's why the users that appear online are never updated.
To solve the problem I tried to delete the div tag that holds the table with the users but it doesn't seem to work (I think the table is never recreated, or deleted.
This function is called every second, just like others that are working
Can you please help? Am I doing something wrong when deleting the div tag, or is this idea impossible to be placed into practice?

$.ajax({
    type: 'POST',
    url: 'http://www.game4tress.com/val.php',
    data: 'server=' + serverlocation,
    cache: false,
    success: function(result) {
      if(result){
        resultObj = eval (result);

        $( "#idMR" ).empty();

        var ind;
        var currVal;
        var countCols; 
        var bolEnd=true; 
        var strValueHtml="<div id='idMR'><table id='GetPlayer'><tr>";
        var ColNr=7;
        var idClick=0;

        ind=0;
        countCols=0;
        var myArray = result;        

        $( '#tblOnlinePlayers').html('');
    $.each(result, function(i, item) {
        if((ind>1)&& (ind<result.length-2))
        {

            if(item=="$")
            {

                strValueHtml= strValueHtml + "</td>";

                bolEnd=true;

                if(countCols>=ColNr)
                {                   

                    strValueHtml= strValueHtml + "</tr>";
                }
                countCols++;
            }
            else
            {
                if(countCols>=ColNr)
                {
                    strValueHtml= strValueHtml ...
0

I know that this question is asked a lot but still can't find the correct answer.
I have a database on SQL Server 2012 Express Edition, that I need to protect the information and its structure.
What's the best way to do it?
Is there any way to protect the database with a password that works even if the database is taken to another computer?

My thanks in advanced

0

I have fields in a table that are being constantly updated with the current time (each second). First, the controller calls a function to create the record in the database

public function saveEntry($theuser='')
    {   
        $data = array(
           'theuser' => $theuser ,
           'dateentered' => date('Y-m-d') , //date('d-m-Y H:i:s') ,
           'gname' => date('d-m-Y H:i:s') ,
                   'ldate' => date('Y-m-d'),
                   'ltime' => date('H:i:s'),
                   'ldatetime' => date('Y-m-d H:i:s')
                    );      
        $this->db->insert('onlineusers', $data);        
    }

Then, after the view is called, an ajax function keeps updating the time on the database.
The problem is that when ajax updates the database (with a simple .php update page), the time is less 10 or so minuts than when Codeigniter's function created the record. The difference bettwen CodeIgniter and a simple .php file is, always, more or less 10 minuts
What could I be doing wrong? Is there a way to sincronize the two? Or some other way possible to solve the problem?

My thanks in advanced

0

Thank you for your response!
Well, about the layout I want to use de "Details" layout, if that's what you're asking, but I'm not being able to define that layout. I'm not finding the proper way to define it.

about tang2:

foreach (TipoAngulo tang2 in ListOfAngles)
{
    ListViewItem lvi = new ListViewItem();
    lvi.Text = tang2.Name;
    lvi.SubItems.Add(tang2.Name.ToString());
    lsvUsedAngles.Items.Add(lvi);
}

When I use "Console.WriteLine" to print the value inside "tang2.Name", I see the correct value. The problem comes in the last two lines, when the the listViewItem is added to the ListView. I believe I have the listview improperly configured.

0

I'm creating a chat system and I need to remove every user that did not properly logout (if for instance the computer was shutdown unexpectedly,...), such as some other tasks.
One possibility is for each user's script check for inactivity (3 seconds, for instance) of every other user, but if there are many users online I think I may get in trouble on performance.
Is there an easier way to do this? Is it possible to run a script automatically on the server that performs such task? how?

My thanks in advanced

0

I'm trying to fill a listview with the code shown bellow, but when the listview is populated, each item is shown as:

ListViewItem: {The information to display1}
ListViewItem: {The information to display2}
ListViewItem: {The information to display3}
ListViewItem: {The information to display4}

My question is, how can I display only what is inside braces?
Here is my code:

ListViewItem lvi = new ListViewItem();
lvi.Text = tang2.Name;
lvi.SubItems.Add(tang2.Name.ToString());
lsvUsedAnalysis.Items.Add(lvi);

My thanks in advanced

0

Ok, the problem is solved. Both the jquery section and the 'valueschat.php' were wrong.

$stmt = $conn->prepare('SELECT writtentext from mainchat');

was replaced with

$stmt = $conn->query('SELECT writtentext from mainchat');

and

success: function (data) {
            alert("SUCCESS:");
            for(var key in data) {
                $('#tarChat').append(key);
                $('#tarChat').append('=' + data[key] + '<br />');
            }
        },
        });

was replaced with

$('#tarChat').val(data);
0

Thanks a lot for your answer.
I've been trying to implement this solution in my code but it's not working. I must be doing something wrong. Can you please help?

The jquery section:

<script>
$(document).ready(function () {
function myDate(){  

$.ajax({
        url: "valueschat.php",
        type: "POST",
        data: "key=value",
        dataType: "json",
        success: function (data) {
            alert("SUCCESS:");
            for(var key in data) {
                $('#tarChat').append(key);
                $('#tarChat').append('=' + data[key] + '<br />');
            }
        },
        });

} 

myDate();

setInterval(function(){   myDate();}, 1000);
});
</script>

valueschat.php:

<?php
define('DB_SERVER', 'blablabla');
define('DB_USER', 'blablabla');
define('DB_PASSWORD', 'blablabla');
define('DB_NAME', 'blablabla');

if (isset($_GET['term'])){
    $return_arr = array();

try {
    $conn = new PDO("mysql:host=".DB_SERVER.";port=8889;dbname=".DB_NAME, DB_USER, DB_PASSWORD);
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$stmt = $conn->prepare('SELECT writtentext from mainchat');

$stmt->execute(array('term' => '%'));

while($row = $stmt->fetch()) {
    $return_arr[] =  $row['writtentext'];
}

} catch(PDOException $e) {
    echo 'ERROR: ' . $e->getMessage();
}

echo json_encode($return_arr);
}
0

I'm creating a chat system using Codeigniter and I need to update a textarea with a field in the database each second.
For that I'm trying to use jquery for the timer but I don't know how I can update the textarea with data from the database, with a call from the jquery function.

Can you please help?

My thanks in advanced

0

When I insert data into the database, for instance, a new client, and after that query the clients in the database, the new client is not immediately shown in the list. For it to be listed, I have to clear the cookies and log in, again, into the site.
Why does this happens and how can I solve this situation?

My thanks in advanced

0

I'm creating a morphing module for a certain software and I'm trying to do something that I'm wrestling for quite long.

I've created a mesh divided in 9 parts. So I have a rectangle divided in 9 "sub-rectangles" and I've set a texture for the global rectangle. My idea, doable, or not, is that when I redefine the positions of the "sub-rectangles", the image is changed accordingly.
For instance, imagine a someone's face. When I change some of the coordinates, one of the teeth comes forward, because it's the section in the square corresponding to that tooth, leaving the rest of the face intact (some other squares may need to be set smaller or larger,... but that's another issue).
Although this teory is very interesting, the problem is that I'm not getting the result I wan't and I believe the problem comes from the way I'm applying textures. I'm not accustomed to 3D.

Can you please give me some help?

My thanks in advanced.

Here's the main code:

contentcontrol1.Content = myviewport3d

    myviewport3d.Children.Add(mymodelvisual)
    myviewport3d.Camera = mypccamera
    mymodel3dgroup.Children.Add(New DirectionalLight(Colors.White, New Vector3D(0, 0, 1)))
    mymodelvisual.Content = mymodel3dgroup
    ptn3DRight = New Point3D(7, 0, 0)

      mymesh.Positions.Add(New Point3D(0, 2, 0))
    mymesh.Positions.Add(New Point3D(3, 2, 0))
    mymesh.Positions.Add(New Point3D(3, 0, 0))
    mymesh.Positions.Add(New Point3D(0, 0, 0))

    mymesh.Positions.Add(New Point3D(0, 5, 0))
    mymesh.Positions.Add(New Point3D(3, 5, 0))
    mymesh.Positions.Add(New Point3D(3, 2, 0))
    mymesh.Positions.Add(New Point3D(0, 2, 0))

    mymesh.Positions.Add(New Point3D(0, 9, 0))
    mymesh.Positions.Add(New Point3D(3, 9, 0))
    mymesh.Positions.Add(New Point3D(3, 5, 0))
    mymesh.Positions.Add(New Point3D(0, 5, 0))

    mymesh.Positions.Add(New Point3D(3, 9, 0))
    mymesh.Positions.Add(New Point3D(5, 9, 0))
    mymesh.Positions.Add(New Point3D(5, 5, 0)) ...
0

I'm trying to place a texture in a 3d object, using Visual Basic and WPF, but I'm not being able to do it.
If instead of an image I render a blue square, by replacing the line
mymodel3dgroup.Children.Add(New GeometryModel3D(mymesh, df))
for
mymodel3dgroup.Children.Add(New GeometryModel3D(mymesh, New DiffuseMaterial(Brushes.Blue)))
then I get a blue square. But what I need is to see the image, not just paint the object(s).
Can you please help?
My thanks in advanced

Imports System.Windows.Media.Media3D

Public Class UserControl1
    Dim mymesh As New MeshGeometry3D
    Dim myviewport3d As New Viewport3D
    Dim mymodelvisual As New ModelVisual3D
    Dim mypccamera As New PerspectiveCamera(New Point3D(0, 0, -5), New Vector3D(0, 0, 1), New Vector3D(0, 1, 0), 100)
    Dim mymodel3dgroup As New Model3DGroup
    Dim myMaterial As DiffuseMaterial

    Private Sub UserControl1_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded

        contentcontrol1.Content = myviewport3d

        myviewport3d.Children.Add(mymodelvisual)

        myviewport3d.Camera = mypccamera

        mymodel3dgroup.Children.Add(New DirectionalLight(Colors.White, New Vector3D(0, 0, 1)))

        mymodelvisual.Content = mymodel3dgroup

        mymesh.Positions.Add(New Point3D(0, 7, 0))
        mymesh.Positions.Add(New Point3D(7, 7, 0))
        mymesh.Positions.Add(New Point3D(7, 0, 0))
        mymesh.Positions.Add(New Point3D(7, 0, 0))
        mymesh.Positions.Add(New Point3D(0, 0, 0))
        mymesh.Positions.Add(New Point3D(0, 7, 0))

        Dim m As System.Windows.Media.Media3D.Material
        'Dim m = New System.Windows.Media.Media3D.Material()
        Dim df As System.Windows.Media.Media3D.DiffuseMaterial
        Dim spm As System.Windows.Media.Media3D.SpecularMaterial

        Dim ri As Uri = New Uri("d:\transferir.jpeg", UriKind.Absolute)
        Dim imgSource As ImageSource = New BitmapImage(ri)

        Dim ib = New ImageBrush()
        ib.ImageSource = New BitmapImage(New Uri("d:\cc.png", UriKind.Absolute))
        ib.Stretch = Stretch.Fill
        ib.ViewboxUnits = BrushMappingMode.Absolute
        ib.AlignmentX = AlignmentX.Left
        ib.AlignmentY = AlignmentY.Top

        ib.Opacity = 0.5

        df = New System.Windows.Media.Media3D.DiffuseMaterial(ib)

        spm = New System.Windows.Media.Media3D.SpecularMaterial(ib, 85)

        mymodel3dgroup.Children.Add(New GeometryModel3D(mymesh, df))

    End Sub

End Class
0

It connects to an MS Access database, that can be hosted on the application path.
The application is writen in VB6 and uses several windows and user .dlls
It also uses some external software tools that have to be previously installed (for printing and image handling)

0

I'm working on softwares that were built without taking into account that they could be sold in modules. At the present time, when we (the company I'm working in) sell the software we have to install all features on the client. I know that currently there's a technique using "Prism" that solves this situation, but our softwares are already made and we can't start them all over again.

Does anyone know any technique on how to handle this situation?

My thanks in advanced

0

I'm trying to find a solution to protect all the software developed in the company I work in.
Till now we've been working with hardlocks, but we are trying to cut on expences and wanting to develop our own software protection system.
I know that there some free tools, like for instance activelock, but we aren't interested in using third party tools either, since these tools are frequently open to attacks and we might have migration problems in the future.
I've been googling and I can't find any good techniques for developing this type of solution.
We've seen some ideas like for instance hardware dependet protection, but that is also a problem because it doesn't allow the user to change hardware without contacting us.
We have our own website, what makes possible the comunication with an online database, but we don't know what to do with this functionality. Check IP? It changes often,... Check Hardware? same problem as before, probably,...

Does anyone has any ideas or knows any technique?

My thanks in advanced