|
|
It could also be that you need to copy the files themselves (images) from the source solution, and put them in the exact same folder (the resource manager holds a reference to the file added to the .resx).
I never finish anyth
|
|
|
|
|
hi
i have DataSet that contain Image.
i need to save this Image to File.
i try this:
SQL = ItemCode,PIC from ROW;
dsView = new DataSet();
adp = new SqlCeDataAdapter(SQL, Conn);
adp.Fill(dsView, "ROW");
adp.Dispose();
foreach (DataRow R in dsROW.Tables[0].Rows)
{
ItemCode = R["ItemCode"].ToString().Trim() ;
TEMP = R["PIC"].ToString().Trim();
Image image = R["PIC"] as Image;
if(image != null)
{
MemoryStream ms = new MemoryStream();
image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] imagedata = ms.ToArray();
}
but image Always is null
and in TEMP i see System.Byte[]
need some help, thanks
|
|
|
|
|
|
thank for the help !
i try this and i got: InvalidCastException
i work on C# Windows-Mobile
thanks
|
|
|
|
|
That means the field is not a blob (thus, it can't be converted to a byte array). Please check the data type of your "pic"
Best,
John
-- LogWizard Meet the Log Viewer that makes monitoring log files a joy!
|
|
|
|
|
How to get data(json) to listview by MVVM?
Inside View:
<Grid>
<ListView x:Name="lsvItems" VerticalAlignment="Top" HorizontalAlignment="Stretch">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsWrapGrid Orientation="Horizontal"></ItemsWrapGrid>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel>
<Grid>
<Ellipse Stroke="Black" Width="180" Height="180" StrokeThickness="0.9" Margin="0,5">
<Ellipse.Fill>
<ImageBrush ImageSource="/Asets/nologo.jpg"></ImageBrush>
</Ellipse.Fill>
</Ellipse>
<Ellipse Stroke="Black" Width="180" Height="180" StrokeThickness="0.9" Margin="0,5">
<Ellipse.Fill>
<ImageBrush ImageSource="{Binding thumbail}"></ImageBrush>
</Ellipse.Fill>
</Ellipse>
</Grid>
<StackPanel Margin="0,5">
<TextBlock Text="{Binding title}" Foreground="White" FontWeight="SemiBold" OpticalMarginAlignment="TrimSideBearings" TextTrimming="CharacterEllipsis" FontSize="15" Margin="2" ></TextBlock>
<TextBlock Text="{Binding user.full_name}" Foreground="White" FontSize="12" Margin="2"></TextBlock>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
Inside Model:(tracksModel.cs)
...........
public class Track
{
public string urn { get; set; }
public string uri { get; set; }
public string permalink { get; set; }
public string permalink_url { get; set; }
public string title { get; set; }
public string description { get; set; }
public string track_type { get; set; }
public string genre { get; set; }
public string tag_list { get; set; }
................
}
public class RootObject
{
public List<Track> tracks { get; set; }
public string tag { get; set; }
public string next_href { get; set; }
}
Inside ViewModel:
StaticMethod:
public class StaticMethod
{
public static async Task<string> GetJsonStringTask(string link)
{
HttpClient client = new HttpClient();
HttpResponseMessage message = await client.GetAsync(link+ "&client_id=9ac2b...");
string result = await message.Content.ReadAsStringAsync();
return result;
}
}
TrackViewModel:
public ObservableCollection<TracksModel> TrackCollection = new ObservableCollection<TracksModel>();
public async Task GetTrackAsyncTask(string link)
{
var result = await StaticMethod.GetJsonStringTask(link);
if(result!=null)
{
**var getItem = JsonConvert.DeserializeObject<TracksSoundCloud.RootObject>(result);
if(Do not get a error)
{ give data to listview}
else
return a error and show up on listview or show messagebox.
}**
}
Please help me to fix it? I'm new on MVVM.
var getItem = JsonConvert.DeserializeObject<TracksSoundCloud.RootObject>(result);
if(Do not get a error)
{ give data to listview}
else
return a error and show up on listview or show messagebox.
}
|
|
|
|
|
What exactly is the problem?
|
|
|
|
|
I did not get data.
binding trackcollection but no have data.
|
|
|
|
|
If it not mvvm then
lsvitem.itemsource=getitem.track;
but this is mvvm so I don't know .
|
|
|
|
|
I can't seem to find any way to get a GUI in Cosmos OS. I have went on Youtube, Stacks, and more. I did not find any methods that work. If anyone can please help me that would be awesome! Thanks in advanced!
|
|
|
|
|
What does this have to do with C#?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Believe it or not, Cosmos has something to do with C#; but, yes, this question here is way-off this forum's scope.
"Cosmos is an operating system "construction kit", built from the ground up around the IL2CPU compiler in C# and our home-brewed language called X#." [^]
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
|
|
|
|
|
Thank you. I learn from CP every day!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Enjoy[^]
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Cool ! I should never underestimate the content on CodeProject
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
|
|
|
|
|
It has quite a few unexpected articles, yes
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
so here I'm trying to use proxies from a listView in my project. But I have no clue and have had no experiences in using proxies in C# before nore in any other form of anything haha.
So what I've got so far is a button to import a .txt file of "proxies" and it adds the items to a listView.
From there I'm wanting a loop in my proxy state so it runs through the listView of proxies.
I have no clue on what I'm doing here so would need some extended support here. In need of this for a college project.
Here is my post data.
CookieContainer cookieCon = new CookieContainer();
public string postRequest(string url, String postData, String Username, String Password)
{
try
{
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
request.Method = "POST";
request.CookieContainer = cookieCon;
request.ContentType = "application/json; charset=utf-8";
request.Headers.Add("Cookie", "devicecookie=146.200.41.147.1446567416483.346;");
request.UserAgent = "FireFox User Agent";
request.Headers.Add("Accept-Language", "en-GB,en-US;q=0.8");
request.Host = "www.collegename.co.uk";
request.Headers.Add("Accept-Encoding", "gzip");
request.KeepAlive = true;
byte[] byteArr = Encoding.Default.GetBytes(postData);
request.ContentLength = byteArr.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArr, 0, byteArr.Length);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
string source = reader.ReadToEnd();
return source;
}
catch (Exception ex)
{
if (ex.Message.Contains("401"))
{
}
}
return null;
}
Would appreciate it if you could give me some help here, thanks guys. I'm not looking to change a mass amount of my code but would appreciate some help.
|
|
|
|
|
Member 11367553 wrote: I have no clue on what I'm doing here Exactly what are you trying to do with these proxies? And more importantly, are you sure this is a good choice of college project?
|
|
|
|
|
It's to login and yes it's a good choice of college project because it's what we have been asked to do.
|
|
|
|
|
Member 11367553 wrote: It's to login What exactly is that supposed to mean?
|
|
|
|
|
It's posting to the student login page, our project is to utilize proxies in a project so this is what I'm doing.
|
|
|
|
|
Can you show us the code where you load data into the listview? That is assuming you already have that code
What kind of listview are we talking about? The one from WinForms? If yes, then you can "foreach" the Items property.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
yeah i have this already coded where the proxies from the .txt file are listed in the listView.
Here is the code for that.
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "TXT files|*.txt";
ofd.Title = "Load Proxies";
var dialogResult = ofd.ShowDialog();
if (dialogResult == DialogResult.OK)
{
foreach (var line in System.IO.File.ReadLines(ofd.FileName))
{
if (line.Contains(":"))
proxies.Add(line);
proxyView.Items.Add(line);
}
}
|
|
|
|
|
You already 'run' through the items right there
Add a button to your form, and create a similar loop for the items in the listview;
foreach (var item in proxyView.Items)
{
System.Diagnostics.Debug.WriteLine(Convert.ToString(item));
} You can then reference any item in the listview and access its properties. Looks like each item is a single item, a text-string. I assume you want to call the other method and pass that then?
Where do the other arguments come from, like the name and password? Does the user have to enter those?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|