Daily Archives

Articles indexed Tuesday August 19 2014

Page 4/20 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Synaptics drivers are not loading on Kubuntu 13.10 on Dell Vostro 2420

    - by Alok Singh Mahor
    I freshly installed Kubuntu 13.10, 32 bit version on newly purchased Dell Vostro 2420. everything is working fine except scrolling and multitouch features through touchpad. I am able to change position of cursor using touchpad and able to tap (single click and double click) but scrolling is not working I tried to find out solution by searching on google but could not find proper solution to load synaptics drivers. i am listing some details: Laptop: Dell Vostro 2420 Linux Kernel version and distribution: 3.11.0-12-generic, Kubuntu 13.10 output of xinput list is ? Virtual core pointer id=2 [master pointer (3)] ? ? Virtual core XTEST pointer id=4 [slave pointer (2)] ? ? PS/2 Generic Mouse id=12 [slave pointer (2)] ? Virtual core keyboard id=3 [master keyboard (2)] ? Virtual core XTEST keyboard id=5 [slave keyboard (3)] ? Power Button id=6 [slave keyboard (3)] ? Video Bus id=7 [slave keyboard (3)] ? Power Button id=8 [slave keyboard (3)] ? Sleep Button id=9 [slave keyboard (3)] ? Laptop_Integrated_Webcam_HD id=10 [slave keyboard (3)] ? AT Translated Set 2 keyboard id=11 [slave keyboard (3)] ? Dell WMI hotkeys id=13 [slave keyboard (3)] Output of synclient -l is Couldn't find synaptics properties. No synaptics driver loaded? output of lshw is at http://paste.ubuntu.com/6645687/ xserver log and dmesg dont have trace of synaptics kindly tell me how to troubleshoot this problem.

    Read the article

  • Problem with Mono and .exe file

    - by Vere Nicolson
    I have purchased a piece of software to configure programable radio control transmitters. It says it will run on Linux, see below: Digital Radio runs on: Microsoft Windows 2000/2003/XP Microsoft Windows Vista/Seven/2008, Linux Ubuntu or a distribution with Mono, 32 or 64 bit, also in a virtual machine. Linux requires the Mono package installed, with also the Visual Basic 2005 runtime library. The Linux version is the same executable file of the Windows platform, and can be execute using Mono. You don't need Wine. All the tests have been done on Ubuntu Desktop 10.10 I have tried for weeks to get the drivers for the cable to work in XP or Win7 and I admit defeat. It looks like Ubuntu can run the cable effortlessly but now I can't get the software going. Tried to run in Ubuntu 10.04 with mono, GUI failed and I got the following message in terminal. $ mono ~/Desktop/GigRadioLinux/DigitalRadio/DigitalRadio.exe The entry point method could not be loaded Windows installation requires using a 30 odd character Passkey and a 4.24k text file as a "license" to be entered during running of the exe file. Can someone tell me how I enter the passkey and license into terminal, or is that not my primary problem? I don't understand "entry point method". Tried Wine and that didn't work either. The developer responded to my earlier emails re the cable drivers, but hasn't replied to questions regarding this. If I have left out anything important let me know and I will try to supply more information.

    Read the article

  • Stateless layout switching in Ubuntu 14.04

    - by ulidtko
    I use extensively two keyboard layouts (latin for English, and cyrillic for Ukrainian and Russian), and it bothers me to experience my mode errors because of the additional bit of UI state: the current layout. I used to eliminate them completely by using stateless layout switching, whereby one has no next layout action (as such an action is based on the current state, which is easy to forget for the user, and so leads to errors), rather only two actions: enable latin layout; enable cyrillic layout. This was trivially accomplishable in pre-Saucy releases. As illustrated on the screenshot above. However, that settings window was destroyed in Saucy. How do I get my stateless switching now?

    Read the article

  • Simple collision detection in Unity 2D

    - by N1ghtshade3
    I realise other posts exist with this topic yet none have gone into enough detail for me. I am attempting to create a 2D game in Unity using C# as my scripting language. Basically I have two objects, player and bomb. Both were created simply by dragging the respective PNG to the stage. I have set up touch controls to move player left and right; gravity of any kind is not needed as I only require it to move x units when I tap either the left or right side of the screen. This movement is stored in a script called playerController.cs and works just fine. I also have a variable health = 3 for player, which is stored in healthScript.cs. I am now at a point where I am stuck. I would like it so that when player collides with bomb, health decreases by one and the bomb object is destroyed. So what I tried doing is using a new script called playerPhysics.cs, I added the following: void OnCollisionEnter2D(Collision2D coll){ if(coll.gameObject.name=="bomb") GameObject.Destroy("bomb"); healthScript.health -= 1; } While I'm fairly sure I don't know the proper way to reference a variable in another script and that's why the health didn't decrease when I collided, bomb never disappeared from the stage so I'm thinking there's also a problem with my collision. Initially, I had simply attached playerPhysics.cs to player. After searching around though, it appeared as though player also needed a rigidBody attached to it, so I did that. Still no luck. I tried using a circleCollider (player is a circle), using a rigidBody2D, and using all manner of colliders on one and/or both of the objects. If you could please explain what colliders (if any) should be attached to which objects and whether I need to change my script(s), that would be much more helpful than pointing me to one of the generic documentation examples I've already read. Also, if it would be simple to fix the health thing not working that would be an added bonus but not exactly the focus of this question. Bear in mind that this game is 2D; I'm not sure if that changes anything. Thanks!

    Read the article

  • What resources do I need to start developing games? [on hold]

    - by Matt
    I'm in a unique situation here. I'm only just now a sophomore in high school and I've had a passion for gaming and technology since I was a child. I picked up python at age 9 and have learned 3 other languages since then. I never was good at art or such things, but I can imagine amazing logic devices to carry out game elements I would like to try. I've been researching and finding very vague advice on what needs to be present in order for me to develop. I've attempted at many things, but they never become more than a text-based mess. What education in specific would I need to advance in the game industry? Workflows are never clear to me. I've watched videos on Valve, Zenimax, and many others on how to get from an idea to a product. I've never gotten a finished product, but I've always had the idea clearly in my head.

    Read the article

  • speed up the update of glutidle()

    - by CroCo
    I have a client that sends data at 1KHz (i.e. 0.001 sec) to a master over Internet using UDP protocol. In Master, I need to draw an object, but the problem is that the update of GLUT is slower than the client's update. I have tried to use glutTimerFunc(0,glutIdle, 0); but still slow. Is there a way to speed up the update rate of drawing? I need to update Display() every 0.001 sec. Any suggestions? I'm using windows 7.

    Read the article

  • How could I implement 3D player collision with rotation in LWJGL?

    - by Tinfoilboy
    I have a problem with my current collision implementation. Currently for player collision, I just use an AABB where I check if another AABB is in the way of the player, as shown in this code. (The code below is a sample of checking for collisions in the Z axis) for (int z = (int) (this.position.getZ()); z > this.position.getZ() - moveSpeed - boundingBoxDepth; z--) { // The maximum Z you can get. int maxZ = (int) (this.position.getZ() - moveSpeed - boundingBoxDepth) + 1; AxisAlignedBoundingBox aabb = WarmupWeekend.getInstance().currentLevel.getAxisAlignedBoundingBoxAt(new Vector3f(this.position.getX(), this.position.getY(), z)); AxisAlignedBoundingBox potentialCameraBB = new AxisAlignedBoundingBox(this, "collider", new Vector3f(this.position.getX(), this.position.getY(), z), boundingBoxWidth, boundingBoxHeight, boundingBoxDepth); if (aabb != null) { if (potentialCameraBB.colliding(aabb) && aabb.COLLIDER_TYPE.equalsIgnoreCase("collider")) { break; } else if (!potentialCameraBB.colliding(aabb) && z == maxZ) { if (this.grounded) { playFootstep(); } this.position.z -= moveSpeed; break; } } else if (z == maxZ) { if (this.grounded) { playFootstep(); } this.position.z -= moveSpeed; break; } } Now, when I tried to implement rotation to this method, everything broke. I'm wondering how I could implement rotation to this block (and as all other checks in each axis are the same) and others. Thanks in advance.

    Read the article

  • Problem with sprite direction and rotation

    - by user2236165
    I have a sprite called Tool that moves with a speed represented as a float and in a direction represented as a Vector2. When I click the mouse on the screen the sprite change its direction and starts to move towards the mouseclick. In addition to that I rotate the sprite so that it is facing in the direction it is heading. However, when I add a camera that is suppose to follow the sprite so that the sprite is always centered on the screen, the sprite won't move in the given direction and the rotation isn't accurate anymore. This only happens when I add the Camera.View in the spriteBatch.Begin(). I was hoping anyone could maybe shed a light on what I am missing in my code, that would be highly appreciated. Here is the camera class i use: public class Camera { private const float zoomUpperLimit = 1.5f; private const float zoomLowerLimit = 0.1f; private float _zoom; private Vector2 _pos; private int ViewportWidth, ViewportHeight; #region Properties public float Zoom { get { return _zoom; } set { _zoom = value; if (_zoom < zoomLowerLimit) _zoom = zoomLowerLimit; if (_zoom > zoomUpperLimit) _zoom = zoomUpperLimit; } } public Rectangle Viewport { get { int width = (int)((ViewportWidth / _zoom)); int height = (int)((ViewportHeight / _zoom)); return new Rectangle((int)(_pos.X - width / 2), (int)(_pos.Y - height / 2), width, height); } } public void Move(Vector2 amount) { _pos += amount; } public Vector2 Position { get { return _pos; } set { _pos = value; } } public Matrix View { get { return Matrix.CreateTranslation(new Vector3(-_pos.X, -_pos.Y, 0)) * Matrix.CreateScale(new Vector3(Zoom, Zoom, 1)) * Matrix.CreateTranslation(new Vector3(ViewportWidth * 0.5f, ViewportHeight * 0.5f, 0)); } } #endregion public Camera(Viewport viewport, float initialZoom) { _zoom = initialZoom; _pos = Vector2.Zero; ViewportWidth = viewport.Width; ViewportHeight = viewport.Height; } } And here is my Update and Draw-method: protected override void Update (GameTime gameTime) { float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds; TouchCollection touchCollection = TouchPanel.GetState (); foreach (TouchLocation tl in touchCollection) { if (tl.State == TouchLocationState.Pressed || tl.State == TouchLocationState.Moved) { //direction the tool shall move towards direction = touchCollection [0].Position - toolPos; if (direction != Vector2.Zero) { direction.Normalize (); } //change the direction the tool is moving and find the rotationangle the texture must rotate to point in given direction toolPos += (direction * speed * elapsed); RotationAngle = (float)Math.Atan2 (direction.Y, direction.X); } } if (direction != Vector2.Zero) { direction.Normalize (); } //move tool in given direction toolPos += (direction * speed * elapsed); //change cameracentre to the tools position Camera.Position = toolPos; base.Update (gameTime); } protected override void Draw (GameTime gameTime) { graphics.GraphicsDevice.Clear (Color.Blue); spriteBatch.Begin (SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, Camera.View); spriteBatch.Draw (tool, new Vector2 (toolPos.X, toolPos.Y), null, Color.White, RotationAngle, originOfToolTexture, 1, SpriteEffects.None, 1); spriteBatch.End (); base.Draw (gameTime); }

    Read the article

  • Unity mouse input not working in webplayer build

    - by Califer
    I have a button script with the following code void OnMouseDown() { animation.Play("button-squish"); enlarged = true; audio.PlayOneShot(buttonSound); } void OnMouseUpAsButton() { if (enlarged) { SelectThisButton(); enlarged = false; animation.Play("button-return"); } } void OnMouseExit() { if (enlarged) { enlarged = false; animation.Play("button-return"); } } It works great in the editor, but when I made a build and tested it in Chrome none of the buttons had any response. Further testing revealed that it did work in Firefox. Rather than telling people to change their browser if they want to play, I want to make the button code work. How else can I get the buttons to know when they're being pressed if the built-in stuff isn't working?

    Read the article

  • Unity3d and Windows 8 run game in frame

    - by floAr
    How do I set Unity3D to run my game on Windows 8 in a fixed size frame (with a border around it) and not in fullscreen? I tried setting this in the Unity script and in the final C# project, but nothings seems to work. I have set the players resolution to 1366x786 (the desired size) and while this works fine with the webplayer the windows 8 solution seems really unimpressed by it. I also tinkered with the 'Default Is Full Screen' option

    Read the article

  • problem adding bumpmap to textured gluSphere in JOGL

    - by ChocoMan
    I currently have one texture on a gluSphere that represents the Earth being displayed perfectly, but having trouble figuring out how to implement a bumpmap as well. The bumpmap resides in "res/planet/earth/earthbump1k.jpg".Here is the code I have for the regular texture: gl.glTranslatef(xPath, 0, yPath + zPos); gl.glColor3f(1.0f, 1.0f, 1.0f); // base color for earth earthGluSphere = glu.gluNewQuadric(); colorTexture.enable(); // enable texture colorTexture.bind(); // bind texture // draw sphere... glu.gluDeleteQuadric(earthGluSphere); colorTexture.disable(); // texturing public void loadPlanetTexture(GL2 gl) { InputStream colorMap = null; try { colorMap = new FileInputStream("res/planet/earth/earthmap1k.jpg"); TextureData data = TextureIO.newTextureData(colorMap, false, null); colorTexture = TextureIO.newTexture(data); colorTexture.getImageTexCoords(); colorTexture.setTexParameteri(GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR); colorTexture.setTexParameteri(GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST); colorMap.close(); } catch(IOException e) { e.printStackTrace(); System.exit(1); } // Set material properties gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR); gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST); colorTexture.setTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S); colorTexture.setTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T); } How would I add the bumpmap as well to the same gluSphere?

    Read the article

  • Windows Azure Mobil Services first connection in Android

    - by egente
    my application based windows azure mobil services. Application connecting time is well normally but when login to application first time azure mobile services connection is very slow like 10 second, after connection speed is normally. how can i solve this problem? my codes; private MobileServiceClient mClient; private MobileServiceTable<products> mProductsTable; mClient = new MobileServiceClient( "https://example.azure-mobile.net/", "aaaaaaaaaaaaaaaaaaaaaaaa", this).withFilter(new ProgressFilter());; mProductsTable = mClient.getTable(products.class); mProductsTable.where() .execute(new TableQueryCallback<products>() { public void onCompleted(List<products> result, int count, Exception exception, ServiceFilterResponse response) { if (exception == null) { } else{ Toast.makeText(Product.this, "Ops!!! Error.", 1000).show(); }} });

    Read the article

  • 301 redirects in .htaccess on apache

    - by WhitechapelTom
    I guess this should be straightforward but my host got me to switch server from zeus to apache following which the .htaccess file with existing individual 301 redirects failed to work causing an internal server error, so have commented them out for the time being. Could someone explain how to set these up to work in their new apache context? Have no apache experience Example redirect: Redirect 301 /pages/exhibitions/thegreatindoors.html http://www.klassnik.com/pages/thegreatindoors.html Read a lot about mod rewrites etc but not sure what to write. Thanks

    Read the article

  • Installation error: INSTALL_FAILED_OLDER_SDK in eclipse

    - by user3014909
    I have an unexpe`ted problem with my Android project. I have a real android device with ice_cream sandwich installed. My app was working fine during the development but after I added a class to the project, I got an error: Installation error: INSTALL_FAILED_OLDER_SDK The problem is that everything is good in the manifest file. The minSdkversion is 8. Here is my manifest file: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="zabolotnii.pavel.timer" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18 " /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="zabolotnii.pavel.timer.TimerActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> I don't know, if there is any need to attach the new class ,but I didn't any changes to other code that should led to this error: package zabolotnii.pavel.timer; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.graphics.Paint; import android.graphics.Point; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Environment; import android.util.DisplayMetrics; import android.util.TypedValue; import android.view.*; import android.widget.*; import java.io.File; import java.io.FilenameFilter; import java.util.*; public class OpenFileDialog extends AlertDialog.Builder { private String currentPath = Environment.getExternalStorageDirectory().getPath(); private List<File> files = new ArrayList<File>(); private TextView title; private ListView listView; private FilenameFilter filenameFilter; private int selectedIndex = -1; private OpenDialogListener listener; private Drawable folderIcon; private Drawable fileIcon; private String accessDeniedMessage; public interface OpenDialogListener { public void OnSelectedFile(String fileName); } private class FileAdapter extends ArrayAdapter<File> { public FileAdapter(Context context, List<File> files) { super(context, android.R.layout.simple_list_item_1, files); } @Override public View getView(int position, View convertView, ViewGroup parent) { TextView view = (TextView) super.getView(position, convertView, parent); File file = getItem(position); if (view != null) { view.setText(file.getName()); if (file.isDirectory()) { setDrawable(view, folderIcon); } else { setDrawable(view, fileIcon); if (selectedIndex == position) view.setBackgroundColor(getContext().getResources().getColor(android.R.color.holo_blue_dark)); else view.setBackgroundColor(getContext().getResources().getColor(android.R.color.transparent)); } } return view; } private void setDrawable(TextView view, Drawable drawable) { if (view != null) { if (drawable != null) { drawable.setBounds(0, 0, 60, 60); view.setCompoundDrawables(drawable, null, null, null); } else { view.setCompoundDrawables(null, null, null, null); } } } } public OpenFileDialog(Context context) { super(context); title = createTitle(context); changeTitle(); LinearLayout linearLayout = createMainLayout(context); linearLayout.addView(createBackItem(context)); listView = createListView(context); linearLayout.addView(listView); setCustomTitle(title) .setView(linearLayout) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (selectedIndex > -1 && listener != null) { listener.OnSelectedFile(listView.getItemAtPosition(selectedIndex).toString()); } } }) .setNegativeButton(android.R.string.cancel, null); } @Override public AlertDialog show() { files.addAll(getFiles(currentPath)); listView.setAdapter(new FileAdapter(getContext(), files)); return super.show(); } public OpenFileDialog setFilter(final String filter) { filenameFilter = new FilenameFilter() { @Override public boolean accept(File file, String fileName) { File tempFile = new File(String.format("%s/%s", file.getPath(), fileName)); if (tempFile.isFile()) return tempFile.getName().matches(filter); return true; } }; return this; } public OpenFileDialog setOpenDialogListener(OpenDialogListener listener) { this.listener = listener; return this; } public OpenFileDialog setFolderIcon(Drawable drawable) { this.folderIcon = drawable; return this; } public OpenFileDialog setFileIcon(Drawable drawable) { this.fileIcon = drawable; return this; } public OpenFileDialog setAccessDeniedMessage(String message) { this.accessDeniedMessage = message; return this; } private static Display getDefaultDisplay(Context context) { return ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); } private static Point getScreenSize(Context context) { Point screeSize = new Point(); getDefaultDisplay(context).getSize(screeSize); return screeSize; } private static int getLinearLayoutMinHeight(Context context) { return getScreenSize(context).y; } private LinearLayout createMainLayout(Context context) { LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setMinimumHeight(getLinearLayoutMinHeight(context)); return linearLayout; } private int getItemHeight(Context context) { TypedValue value = new TypedValue(); DisplayMetrics metrics = new DisplayMetrics(); context.getTheme().resolveAttribute(android.R.attr.listPreferredItemHeightSmall, value, true); getDefaultDisplay(context).getMetrics(metrics); return (int) TypedValue.complexToDimension(value.data, metrics); } private TextView createTextView(Context context, int style) { TextView textView = new TextView(context); textView.setTextAppearance(context, style); int itemHeight = getItemHeight(context); textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, itemHeight)); textView.setMinHeight(itemHeight); textView.setGravity(Gravity.CENTER_VERTICAL); textView.setPadding(15, 0, 0, 0); return textView; } private TextView createTitle(Context context) { TextView textView = createTextView(context, android.R.style.TextAppearance_DeviceDefault_DialogWindowTitle); return textView; } private TextView createBackItem(Context context) { TextView textView = createTextView(context, android.R.style.TextAppearance_DeviceDefault_Small); Drawable drawable = getContext().getResources().getDrawable(android.R.drawable.ic_menu_directions); drawable.setBounds(0, 0, 60, 60); textView.setCompoundDrawables(drawable, null, null, null); textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { File file = new File(currentPath); File parentDirectory = file.getParentFile(); if (parentDirectory != null) { currentPath = parentDirectory.getPath(); RebuildFiles(((FileAdapter) listView.getAdapter())); } } }); return textView; } public int getTextWidth(String text, Paint paint) { Rect bounds = new Rect(); paint.getTextBounds(text, 0, text.length(), bounds); return bounds.left + bounds.width() + 80; } private void changeTitle() { String titleText = currentPath; int screenWidth = getScreenSize(getContext()).x; int maxWidth = (int) (screenWidth * 0.99); if (getTextWidth(titleText, title.getPaint()) > maxWidth) { while (getTextWidth("..." + titleText, title.getPaint()) > maxWidth) { int start = titleText.indexOf("/", 2); if (start > 0) titleText = titleText.substring(start); else titleText = titleText.substring(2); } title.setText("..." + titleText); } else { title.setText(titleText); } } private List<File> getFiles(String directoryPath) { File directory = new File(directoryPath); List<File> fileList = Arrays.asList(directory.listFiles(filenameFilter)); Collections.sort(fileList, new Comparator<File>() { @Override public int compare(File file, File file2) { if (file.isDirectory() && file2.isFile()) return -1; else if (file.isFile() && file2.isDirectory()) return 1; else return file.getPath().compareTo(file2.getPath()); } }); return fileList; } private void RebuildFiles(ArrayAdapter<File> adapter) { try { List<File> fileList = getFiles(currentPath); files.clear(); selectedIndex = -1; files.addAll(fileList); adapter.notifyDataSetChanged(); changeTitle(); } catch (NullPointerException e) { String message = getContext().getResources().getString(android.R.string.unknownName); if (!accessDeniedMessage.equals("")) message = accessDeniedMessage; Toast.makeText(getContext(), message, Toast.LENGTH_SHORT).show(); } } private ListView createListView(Context context) { ListView listView = new ListView(context); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int index, long l) { final ArrayAdapter<File> adapter = (FileAdapter) adapterView.getAdapter(); File file = adapter.getItem(index); if (file.isDirectory()) { currentPath = file.getPath(); RebuildFiles(adapter); } else { if (index != selectedIndex) selectedIndex = index; else selectedIndex = -1; adapter.notifyDataSetChanged(); } } }); return listView; } }

    Read the article

  • WPF MVVM TreeView item source losing context after command

    - by user3955716
    I have a treeview which contains files, every view model holds an item source which is an ObservableCollection with files items: public ObservableCollection<CMItemFileNode> SubItemNode On each item i have context menu options (Delete, Execute..). If i move from one viewModel to another the ObservableCollection of files updated correctly and presented correctly but, when i perform a context menu command like delete file item, the command execute good but when i move to another view model (which holds SubItemNode ObservableCollection of is own) after the command executed the WPF still thinks i'm in the last view model i was in and not the one i'm really on. Very important to mention is that when i update to .net 4.5 (which unfortunantly i can't do) everything is ok and the ObservableCollection addresses the correct view model. Here is the treeView: <TreeView x:Name="Files" Margin="0,5,5,0" Grid.Row="6" Grid.Column="2" ItemsSource="{Binding SubItemNode}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalAlignment="Stretch" Height="300" Grid.RowSpan="6" Width="300" dd:DragDrop.IsDragSource="True" dd:DragDrop.IsDropTarget="True" dd:DragDrop.DropHandler="{Binding}" dd:DragDrop.UseDefaultDragAdorner="True"> <TreeView.Resources> <Style TargetType="{x:Type TreeView}"> <Setter Property="local:CMTreeViewFilesBehavior.IsTreeViewFilesBehavior" Value="True"/> </Style> <Style TargetType="{x:Type TreeViewItem}"> <Setter Property="IsSelected" Value="{Binding IsSelected}" /> <Setter Property="local:CMTreeViewFilesItemBehavior.IsTreeViewFilesItemBehavior" Value="True"/> </Style> <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" /> <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" /> </TreeView.Resources> <TreeView.ContextMenu> <ContextMenu> <MenuItem Header="View File" Command="{Binding ExecuteFileCommand}" /> <Separator /> <MenuItem Header="Delete all" Command="{Binding DeleteAllFilesCommand}" /> <MenuItem Header="Delete selected" Command="{Binding DeleteSelectedFilesCommand}" /> </ContextMenu> </TreeView.ContextMenu> <TreeView.ItemTemplate> <HierarchicalDataTemplate ItemsSource="{Binding SubItemNode}" > <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Image Grid.Column="0" Margin="2" Width="32" Height="18" Source="{Binding Path=Icon}" HorizontalAlignment="Left" VerticalAlignment="Center" /> <TextBlock Text="{Binding Path=Name}" Grid.Column="1" Margin="2" VerticalAlignment="Center" Foreground="{Binding Path=Status, Converter={StaticResource ItemFileStatusToColor}}" FontWeight="{Binding Path=IsSelected, Converter={StaticResource BoolToFontWidth}}"/> </Grid> </HierarchicalDataTemplate> </TreeView.ItemTemplate> </TreeView> Am I doing somthing wrong? and why in .net 4.5 it works well ?

    Read the article

  • Python breaks for a certain amount

    - by Brian Cox
    All, I am not very good at explaining so i will let my comments do it! #this script is to calculate some of the times table up to 24X24 and also miss some out #Range of numbers to be calculated numbers=range(1,25) for i in numbers: for w in numbers: print(str(i)+"X"+str(w)+"="+str(i*w)) #here i want to break randomly (skip some out) e.g. i could be doing the 12X1,12X2 and then 12X5 i have no limit of skips. Update Sorry if this is not clear i want it to break from the inner loop for a random amount of times

    Read the article

  • Incrementing through mysql PHP

    - by Rawdon
    I am looking at try to increment and decrement by three records through a table and present those records. Say if the id '4' is currently active. I want the to be display the ID's and category of 3.2.1 and 5.6.7 from an increment and decrement So far I have: $stmt = $db->query("SELECT id, category FROM test"); $stmt->execute(); while ($results = $stmt->fetch(PDO::FETCH_ASSOC)) { $current = $results['id']; $category = $results['category']; $next = array(array('slide_no' => $current, 'category' => $category)); } print_r($next); Now with this, I am getting back every row in the table. I'm now getting confused on how I could increment and decrement the records by 3 and make sure that the category will also increment correctly. Thank you very much.

    Read the article

  • Creating array from two arrays

    - by binoculars
    I'm having troubles trying to create a certain array. Basicly, I have an array like this: [0] => Array ( [id] => 12341241 [type] => "Blue" ) [1] => Array ( [id] => 52454235 [type] => "Blue" ) [2] => Array ( [id] => 848437437 [type] => "Blue" ) [3] => Array ( [id] => 387372723 [type] => "Blue" ) [4] => Array ( [id] => 73732623 [type] => "Blue" ) ... Next, I have an array like this: [0] => Array ( [id] => 34141 [type] => "Red" ) [1] => Array ( [id] => 253532 [type] => "Red" ) [2] => Array ( [id] => 94274 [type] => "Red" ) I want to construct an array, which is a combination of the two above, using this rule: after 3 Blues, there must be a Red: Blue1 Blue2 Blue3 Red1 Blue4 Blue5 Blue6 Red2 Blue7 Blue8 Blue9 Red3 Note that the their can be more Red's than Blue's, but also more Blue's than Red's. If the Red's run out, it should begin with the first one again. Example: let's say there are only two Red's: Blue1 Blue2 Blue3 Red1 Blue4 Blue5 Blue6 Red2 Blue7 Blue8 Blue9 Red1 ... ... If the Blue's run out, the Red's should append until they run out too. Example: let's say there are 5 Blue's, and 5 Red's: Blue1 Blue2 Blue3 Red1 Blue4 Blue5 Red2 Red3 Red4 Red5 Note: the arrays come from mysql-fetches. Maybe it's better to fetch them while building the new array? Anyway, the while-loops got to me, I can't figure it out... Any help is much appreciated!

    Read the article

  • No class def find error

    - by John Smith
    I have the following piece of code which helps me to read the paths of all the files in a directory and its subdirectories : File dir = new File("directory path"); try { System.out.println("Getting all files in " + dir.getCanonicalPath() + " including those in subdirectories"); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } List<File> files = (List<File>) FileUtils.listFiles(dir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE); for (File file : files) { try { System.out.println("file: " + file.getCanonicalPath()); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } The problem is that I get a java.lang.NoClassDefFoundError: org/apache/commons/io/filefilter/TrueFileFilter error. I've imported the necessary libraries. I mention that I work on a plugin project. This code runs in a class with main function. I don't understand why it gave me this error. Thank you !

    Read the article

  • How to change class name of a button

    - by stackOver Flow
    I have four buttons like this <div class="btn-group"> <button id="btn-men" class="btn btn-default active" i18n:translate="men">Men</button> <button id="btn-women" class="btn btn-default" i18n:translate="women">Women</button> <button id="btn-kids" class="btn btn-default" i18n:translate="kids">Kids</button> </div> And I have different css styles for the class "btn btn-default active" and "btn btn-default". what I want to know is if there is any way of changing the class name of the clicked button as btn btn-default active from btn btn-default and also change the unclicked button as btn btn-default during run time. I also use i18n for mulitilingual purpose.

    Read the article

  • Java JPA Hibernate Spring @EntityListeners throws org.springframework.dao.DataIntegrityViolationException

    - by user
    I am using Spring 3 with Hibernate 3. I would like to update the last modification date automatically when an entity is updated. Below is the sample code: HibernateConfig: @Configuration public class HibernateConfig { @Bean public DataSource dataSource() throws Exception { DriverManagerDataSource dataSource = new DriverManagerDataSource(); Properties properties = new Properties(); properties.load(ClassLoader.getSystemResourceAsStream(new String("hibernate.properties"))); dataSource.setUrl(properties.getProperty(new String("jdbc.url"))); dataSource.setUsername(properties.getProperty(new String("jdbc.username"))); dataSource.setPassword(properties.getProperty(new String("jdbc.password"))); dataSource.setDriverClassName(properties.getProperty(new String("jdbc.driverClassName"))); return dataSource; } @Bean public AnnotationSessionFactoryBean sessionFactory() throws Exception { AnnotationSessionFactoryBean sessionFactory = new AnnotationSessionFactoryBean(); Properties hibernateProperties = new Properties(); Properties properties = new Properties(); properties.load(ClassLoader.getSystemResourceAsStream(new String("hibernate.properties"))); // set the Hibernate Properties hibernateProperties.setProperty(new String("hibernate.dialect"), properties.getProperty(new String("hibernate.dialect"))); hibernateProperties.setProperty(new String("hibernate.show_sql"), properties.getProperty(new String("hibernate.show_sql"))); hibernateProperties.setProperty(new String("hibernate.hbm2ddl.auto"), properties.getProperty(new String("hibernate.hbm2ddl.auto"))); sessionFactory.setDataSource(dataSource()); sessionFactory.setHibernateProperties(hibernateProperties); sessionFactory.setAnnotatedClasses(new Class[]{Message.class}) return sessionFactory; } @Bean public HibernateTemplate hibernateTemplate() throws Exception { HibernateTemplate hibernateTemplate = new HibernateTemplate(); hibernateTemplate.setSessionFactory(sessionFactory().getObject()); return hibernateTemplate; } } DAOConfig: @Configuration public class DAOConfig { @Autowired private HibernateConfig hibernateConfig; @Bean public MessageDAO messageDAO() throws Exception { MessageDAO messageDAO = new MessageHibernateDAO(hibernateConfig.hibernateTemplate()); return messageDAO; } } Message: import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.EntityListeners; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; import java.io.Serializable; import javax.persistence.Column; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; @Entity @Table @EntityListeners(value = MessageListener.class) public class Message implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column private int id; @Column(nullable = false) @Temporal(TemporalType.TIMESTAMP) private Date lastMod; public Message() { } public int getId() { return id; } public void setId(int id) { this.id = id; } public Date getLastMod() { return lastMod; } public void setLastMod(Date lastMod) { this.lastMod = lastMod; } } MessageListener: import java.util.Date; import javax.persistence.PrePersist; import javax.persistence.PreUpdate; import org.springframework.stereotype.Component; @Component public class MessageListener { @PrePersist @PreUpdate public void setLastMod(Message message) { message.setLastMod(new Date()); } } When running this the MessageListener is not being invoked. I use a DAO design pattern and when calling dao.update(Message) it throws the following Exception: org.springframework.dao.DataIntegrityViolationException: not-null property references a null or transient value: com.persistence.entities.MessageStatus.lastMod; nested exception is org.hibernate.PropertyValueException: not-null property references a null or transient value: com.persistence.entities.Message.lastMod at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:665) at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412) at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411) at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374) at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:683) at com.persistence.dao.hibernate.GenericHibernateDAO.save(GenericHibernateDAO.java:38) Having looked at a number of websites there seems not to be a solution.

    Read the article

  • MySQL query - if not exists - insert into - else - update

    - by user3180931
    I made a simple document generator by the form, this form saves everything to mysql database, It works great, but when someone type a the same 'nrumowy' it creates a new row in mysql, 'nrumowy' is unique, so when someone adds a form with the same 'nrumowy' I want to just update existing data in mysql, I have that code: $con=mysqli_connect("localhost","login","pass","database"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // escape variables for security $numerklienta = mysqli_real_escape_string($con, $_POST['numerklienta']); $name = mysqli_real_escape_string($con, $_POST['name']); $hours = mysqli_real_escape_string($con, $_POST['hours']); $date = mysqli_real_escape_string($con, $_POST['date']); $beginDate = mysqli_real_escape_string($con, $_POST['beginDate']); $nrdomu = mysqli_real_escape_string($con, $_POST['nrdomu']); $telefon = mysqli_real_escape_string($con, $_POST['telefon']); $fax = mysqli_real_escape_string($con, $_POST['fax']); $nip = mysqli_real_escape_string($con, $_POST['nip']); $email = mysqli_real_escape_string($con, $_POST['email']); $stronawww = mysqli_real_escape_string($con, $_POST['stronawww']); $branza = mysqli_real_escape_string($con, $_POST['branza']); $vatkodpocztowy = mysqli_real_escape_string($con, $_POST['vatkodpocztowy']); $vatmiejscowosc = mysqli_real_escape_string($con, $_POST['vatmiejscowosc']); $vatulica = mysqli_real_escape_string($con, $_POST['vatulica']); $vatnrdomu = mysqli_real_escape_string($con, $_POST['vatnrdomu']); $vatemail = mysqli_real_escape_string($con, $_POST['vatemail']); $vatosoba = mysqli_real_escape_string($con, $_POST['vatosoba']); $datapublikacji = mysqli_real_escape_string($con, $_POST['datapublikacji']); $rabat = mysqli_real_escape_string($con, $_POST['rabat']); $wartoscnetto = mysqli_real_escape_string($con, $_POST['wartoscnetto']); $typreklamy = mysqli_real_escape_string($con, $_POST['typreklamy']); $inne = mysqli_real_escape_string($con, $_POST['inne']); $inne2 = mysqli_real_escape_string($con, $_POST['inne2']); $inne3 = mysqli_real_escape_string($con, $_POST['inne3']); $zaliczka = mysqli_real_escape_string($con, $_POST['zaliczka']); $liczbarat1 = mysqli_real_escape_string($con, $_POST['liczbarat1']); $zaakceptowaneprzez = mysqli_real_escape_string($con, $_POST['zaakceptowaneprzez']); $telzam = mysqli_real_escape_string($con, $_POST['telzam']); $datapodpis = mysqli_real_escape_string($con, $_POST['datapodpis']); $nrumowy = mysqli_real_escape_string($con, $_POST['nrumowy']); $sql="IF NOT EXISTS ( SELECT * FROM zam WHERE nrumowy = '$nrumowy' ) THEN INSERT INTO zam (numerklienta, name, hours, date, beginDate, nrdomu, telefon, fax, nip, email, stronawww, branza, vatkodpocztowy, vatmiejscowosc, vatulica, vatnrdomu, vatemail, vatosoba, datapublikacji, rabat, wartoscnetto, typreklamy, inne, inne2, inne3, zaliczka, liczbarat1, zaakceptowaneprzez, telzam, datapodpis, nrumowy) VALUES ('$numerklienta', '$name', '$hours', '$date', '$beginDate', '$nrdomu', '$telefon', '$fax', '$nip', '$email', '$stronawww', '$branza', '$vatkodpocztowy', '$vatmiejscowosc', '$vatulica', '$vatnrdomu', '$vatemail', '$vatosoba', '$datapublikacji', '$rabat', '$wartoscnetto', '$typreklamy', '$inne', '$inne2', '$inne3', '$zaliczka', '$liczbarat1', '$zaakceptowaneprzez', '$telzam', '$datapodpis', '$nrumowy' ) ELSE UPDATE zam SET name = '$name', numerklienta = '$numerklienta', hours = '$hours', date = '$date', beginDate = '$beginDate', nrdomu = '$nrdomu', telefon = '$telefon', fax = '$fax', nip = '$nip', email = '$email', stronawww = '$stronawww', branza = '$branza', vatkodpocztowy = '$vatkodpocztowy', vatmiejscowosc = '$vatmiejscowosc', vatulica = '$vatulica', vatnrdomu = '$vatnrdomu', vatemail = '$vatemail', vatosoba = '$vatosoba', datapublikacji = '$datapublikacji', rabat = '$rabat', wartoscnetto = '$wartoscnetto', typreklamy = '$typreklamy', inne = '$inne', inne2 = '$inne2', inne3 = '$inne3', zaliczka = '$zaliczka', liczbarat1 = '$liczbarat1', zaakceptowaneprzez = '$zaakceptowaneprzez', telzam = '$telzam', datapodpis = '$datapodpis' WHERE nrumowy ='$nrumowy' END IF"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } mysqli_close($con); This query without " select..... " and "else update" just a 'insert into' works great, also when I change this 'insert into' to 'update' but I don't know how to make this variable if not exists - insert into - else update

    Read the article

  • OSX launchctl programmatically as root

    - by Lukas1
    I'm trying to start samba service using launchctl from OSX app as root, but I get error status -60031. I can run without problems the command in Terminal: sudo launchctl load -F /System/Library/LaunchDaemons/com.apple.AppleFileServer.plist` In the objective-c code, I'm using (I know it's deprecated, but that really shouldn't be the issue here) AuthorizationExecuteWithPrivileges method. Here's the code: NSString *command = @"launchctl"; // Conversion of NSArray args to char** args here (not relevant part of the code) OSStatus authStatus = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &_authRef); if (authStatus != errAuthorizationSuccess) { NSLog(@"Failed to create application authorization: %d", (int)authStatus); return; } FILE* pipe = NULL; AuthorizationFlags flags = kAuthorizationFlagDefaults; AuthorizationItem right = {kAuthorizationRightExecute, 0, NULL, 0}; AuthorizationRights rights = {1, &right}; // Call AuthorizationCopyRights to determine or extend the allowable rights. OSStatus stat = AuthorizationCopyRights(_authRef, &rights, NULL, flags, NULL); if (stat != errAuthorizationSuccess) { NSLog(@"Copy Rights Unsuccessful: %d", (int)stat); return; } OSStatus status = AuthorizationExecuteWithPrivileges(_authRef, command.UTF8String, flags, args, &pipe); if (status != errAuthorizationSuccess) { NSLog(@"Error executing command %@ with status %d", command, status); } else { // some other stuff } I have also tried using different flags then kAuthorizationFlagDefaults, but that led to either the same problem or error code -60011 - invalid flags. What am I doing wrong here, please?

    Read the article

  • Python - How to wake up a sleeping process- multiprocessing?

    - by user1162512
    I need to wake up a sleeping process ? The time (t) for which it sleeps is calculated as t = D/S . Now since s is varying, can increase or decrease, I need to increase/decrease the sleeping time as well. The speed is received over a UDP procotol. So, how do I change the sleeping time of a process, keeping in mind the following:- If as per the previous speed `S1`, the time to sleep is `(D/S1)` . Now the speed is changed, it should now sleep for the new time,ie (D/S2). Since, it has already slept for D/S1 time, now it should sleep for D/S2 - D/S1. How would I do it? As of right now, I'm just assuming that the speed will remain constant all throughout the program, hence not notifying the process. But how would I do that according to the above condition? def process2(): p = multiprocessing.current_process() time.sleep(secs1) # send some packet1 via UDP time.sleep(secs2) # send some packet2 via UDP time.sleep(secs3) # send some packet3 via UDP Also, as in threads, 1) threading.activeCount(): Returns the number of thread objects that are active. 2) threading.currentThread(): Returns the number of thread objects in the caller's thread control. 3) threading.enumerate(): Returns a list of all thread objects that are currently active. What are the similar functions for getting activecount, enumerate in multiprocessing?

    Read the article

  • angular, try to display object in ng-repeat fails

    - by Simone M
    i'm writing an mobile application in javascript with angularJS and ionicframework (last beta v.11), i create dinamically an object and want to display all objects inside in a ng-repeat. Why nr-repeat don't display anything? This is screen from my object: I use this code for put values in scope: $scope.distanceSuppliers = myCar; And this is the code in html: <ion-item ng-repeat="(id, supplier) in distanceSuppliers"> <div class="items item-button-right" ng-click="openDetails(id)"> {{supplier.name}}<br /> {{supplier.address}}<br /> </div> </ion-item> This is my complete code for JS: .controller('suppliers', function($scope, cw_db, $ionicPopup, $ionicActionSheet, appdelegate, $rootScope, $firebase, $location, $ionicLoading, cw_position) { $ionicLoading.show({ template: 'Updating data..' }); var geocoder; var tot = 0; var done = 0; geocoder = new google.maps.Geocoder(); cw_db.getData(cw_db.getSuppliers(), "", function(suppliers) { cw_position.getPosition(function (error, position) { suppliers.on('value', function(supp) { $scope.distanceSuppliers = {}; tot = 0; done = 0; supp.forEach(function(childSnapshot) { tot++; var childData = childSnapshot.val(); if (childData.address) { calculateDistance(childData, position.coords.latitude, position.coords.longitude); } }); }); $ionicLoading.hide(); }); }); function calculateDistance(childData, usrLat, usrLon) { var service = new google.maps.DistanceMatrixService(); service.getDistanceMatrix( { origins: [new google.maps.LatLng(usrLat, usrLon)], destinations: [childData.address], travelMode: google.maps.TravelMode.DRIVING, unitSystem: google.maps.UnitSystem.METRIC, avoidHighways: false, avoidTolls: false }, function(response, status) { if (status != google.maps.DistanceMatrixStatus.OK) { alert('Error was: ' + status); } else { done++; var results = response.rows[0].elements; childData.distance = results[0].distance.value; $scope.distanceSuppliers.push(childData); if (done == tot) { console.log($scope.distanceSuppliers); } } }); } $scope.openDetails = function(index) { //appdelegate.setCallId(index); //$location.path("/app/supplierDetails"); } }) what's wrong?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >