Uploading file to Google Drive with C# code

Software, Internet and related

I had to host some files on Google Drive and they needed to be updated on regular basis. Going through the GUI is a tedious task if repeated often, so I ended up coding my own upload code.

The upload login is just using the Google SDK, but the tricky part is the authentication with the Google Services, which is OAuth 2.0 ticket base and needs interaction at least for the first run of the program.

Here is the Google Drive encapsulated logic. It exposes methods for listing the drive contents, downloading and uploading:

And here is the application logic. It’s just a command line utility that accepts the client Id and secret as first parameter and the file to be uploaded as third:

And the rest is the most tricky part. The authentication:


View original post

Showing tooltip on textbox when text exceeds the available size of textbox(Attached Behavior in WPF)

XAML TAG

WPF provides an innovative feature called attached properties, which can be used to add behavior to existing controls. These new properties are not defined on the control being extended, but rather they are defined on a separate object (generally a
DependencyObject). Thus, we end up with a source object that defines the attached properties and a target object on which you attach these properties. The target is the object being extended with new functionality contained in the source. When the attached property is set on the target object, a property change event is fired on the source. The event handler is passed information about the target and the new and old values of the property.
By hooking up property changed handlers, we can add additional behavior by calling methods on the target, changing properties, and listening to events. We look at more detailed examples of using attached properties in Chapter 6, “The Power of Attached Properties.” Keep in mind that…

View original post 392 more words

How to edit WPF Datagrid cell

Chanmingman's Blog

This article will show you the way to change the cell in WPF Datagrid.

I have been reading people asking how to change the cell in WPF Datagrid. A lot of article with a lot of theory somehow the code won’t work.

I give you only 2 pieces of code here.

The first one, MainWindow.xaml. Replace your xaml code with the code below.

<Window x:Class=”WpfAppDataGrid.MainWindow”

        xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”

        xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”

        Title=”MainWindow” Height=”350″ Width=”525″>

    <Grid>

        <DataGrid Name=”dataGrid1″ HorizontalAlignment=”Left” Height=”160″ Margin=”26,23,0,0″ VerticalAlignment=”Top” Width=”419″ AutoGenerateColumns=”True” />

        <Button Content=”Refresh” HorizontalAlignment=”Left” Margin=”26,211,0,0″ VerticalAlignment=”Top” Width=”75″ Click=”Button_Click”/>

        <Button Content=”Modify” HorizontalAlignment=”Left” Margin=”123,211,0,0″ VerticalAlignment=”Top” Width=”75″ Click=”Button_Click_1″/>

        <Label Name=”label1″ Content=”Label” HorizontalAlignment=”Left” Margin=”26,255,0,0″ VerticalAlignment=”Top” Width

View original post 447 more words

Blog at WordPress.com.

Up ↑