update OwnChat Image Size und anzeige Angepasst, funktion zur ermittlung der max upload size erstellt und hinzugefügt
This commit is contained in:
@@ -41,10 +41,11 @@ namespace ChatController.ChatKlassen
|
||||
DokumentVisibility = Visibility.Collapsed;
|
||||
_herunterladen = Visibility.Collapsed;
|
||||
_gifPictureVisibility = Visibility.Collapsed;
|
||||
_picturePlaceHolderVisibility = Visibility.Collapsed;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// IMage Ansicht
|
||||
@@ -77,7 +78,33 @@ namespace ChatController.ChatKlassen
|
||||
HyperlinkVisibility = Visibility.Collapsed;
|
||||
DokumentVisibility = Visibility.Collapsed;
|
||||
_herunterladen = Visibility.Collapsed;
|
||||
_picturePlaceHolderVisibility = Visibility.Collapsed;
|
||||
|
||||
}
|
||||
|
||||
//Konstruktor PlaceHolder
|
||||
public KontaktMessageBuilder(string username, string message, string sendtime, bool isme, DateTime convertedSendTimeString, string originalImage, string imageName)
|
||||
{
|
||||
|
||||
|
||||
Username = username;
|
||||
UserMessage = message;
|
||||
SendTime = sendtime;
|
||||
InternalSendTime = convertedSendTimeString;
|
||||
OriginalImage = originalImage;
|
||||
OriginalImageName = imageName;
|
||||
|
||||
Farbgebung(isme);
|
||||
|
||||
|
||||
_pictureVisibility = Visibility.Collapsed;
|
||||
ChatVisibility = Visibility.Collapsed;
|
||||
SoundVisibility = Visibility.Collapsed;
|
||||
HyperlinkVisibility = Visibility.Collapsed;
|
||||
DokumentVisibility = Visibility.Collapsed;
|
||||
_herunterladen = Visibility.Collapsed;
|
||||
|
||||
_picturePlaceHolderVisibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
//Dokument Ansicht
|
||||
@@ -100,7 +127,8 @@ namespace ChatController.ChatKlassen
|
||||
SoundVisibility = Visibility.Collapsed;
|
||||
_herunterladen = Visibility.Collapsed;
|
||||
HyperlinkVisibility = Visibility.Collapsed;
|
||||
|
||||
_picturePlaceHolderVisibility = Visibility.Collapsed;
|
||||
|
||||
}
|
||||
|
||||
private void Farbgebung(bool isme)
|
||||
@@ -361,6 +389,9 @@ namespace ChatController.ChatKlassen
|
||||
private Visibility _pictureVisibility;
|
||||
public Visibility PictureVisibility { get { return _pictureVisibility; } set { _pictureVisibility = value; OnPropertyChanged("PictureVisibility"); } }
|
||||
|
||||
private Visibility _picturePlaceHolderVisibility;
|
||||
public Visibility PicturePlaceHolderVisibility { get { return _picturePlaceHolderVisibility; } set { _picturePlaceHolderVisibility = value; OnPropertyChanged("PicturePlaceHolderVisibility"); } }
|
||||
|
||||
private Visibility _gifPictureVisibility;
|
||||
public Visibility GifPictureVisibility { get { return _gifPictureVisibility; } set { _gifPictureVisibility = value; OnPropertyChanged("GifPictureVisibility"); } }
|
||||
|
||||
|
||||
@@ -268,15 +268,26 @@
|
||||
</StackPanel>
|
||||
|
||||
|
||||
<!-- Bild bereich-->
|
||||
<!-- Bild bereich MaxHeight="200" MaxWidth="300" Stretch uniform-->
|
||||
<DockPanel DockPanel.Dock="Bottom" Visibility="{Binding PictureVisibility}" >
|
||||
<StackPanel Orientation="Vertical">
|
||||
<Image Stretch="Uniform" MaxHeight="200" MaxWidth="300" Source="{Binding ImageSources}" RenderOptions.BitmapScalingMode="HighQuality" />
|
||||
<Image MaxHeight="200" MaxWidth="300" Source="{Binding ImageSources}" RenderOptions.BitmapScalingMode="HighQuality" />
|
||||
|
||||
<TextBlock Text="{Binding UserMessage}" VerticalAlignment="Center" HorizontalAlignment="Left" />
|
||||
</StackPanel>
|
||||
</DockPanel>
|
||||
|
||||
|
||||
<!-- Image Placeholder -->
|
||||
<DockPanel DockPanel.Dock="Bottom" Visibility="{Binding PicturePlaceHolderVisibility}" >
|
||||
<StackPanel Orientation="Vertical">
|
||||
<Image Source="pack://application:,,,/ChatController;component/Ressourcen/ClipboardDisabled.png" RenderOptions.BitmapScalingMode="HighQuality" />
|
||||
|
||||
<TextBlock Text="{Binding UserMessage}" VerticalAlignment="Center" HorizontalAlignment="Left" />
|
||||
</StackPanel>
|
||||
</DockPanel>
|
||||
|
||||
|
||||
<!-- Gif BEreich ?? <MediaElement Source="" ></MediaElement> villeicht gif erstmal runterladen und dann den pfad ausgeben ? 200
|
||||
<DockPanel DockPanel.Dock="Bottom" Visibility="{Binding GifPictureVisibility}" >
|
||||
<StackPanel Orientation="Vertical">
|
||||
|
||||
@@ -375,14 +375,28 @@ namespace ChatController
|
||||
var medium = _chat.HoleMedium();
|
||||
|
||||
if(medium != null) {
|
||||
_chat.AddeMediumDerNachrichtView(medium);
|
||||
|
||||
CollectionViewSource.GetDefaultView(Chat.ItemsSource).Refresh();
|
||||
Chat.Items.MoveCurrentToLast();
|
||||
Chat.ScrollIntoView(Chat.Items.CurrentItem);
|
||||
|
||||
_chat.SendeMediumAnKontakt(kontakt,medium);
|
||||
|
||||
string convertetMedia = _chat.ScaleImage(medium, Path.GetExtension(medium.ToUpperInvariant()));
|
||||
|
||||
if (!convertetMedia.Equals(""))
|
||||
{
|
||||
_chat.AddeMediumDerNachrichtView(convertetMedia);
|
||||
|
||||
CollectionViewSource.GetDefaultView(Chat.ItemsSource).Refresh();
|
||||
Chat.Items.MoveCurrentToLast();
|
||||
Chat.ScrollIntoView(Chat.Items.CurrentItem);
|
||||
|
||||
_chat.SendeMediumAnKontakt(kontakt, convertetMedia);
|
||||
|
||||
if (!convertetMedia.Equals("") && File.Exists(convertetMedia))
|
||||
{
|
||||
File.Delete(convertetMedia);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Die gewählte Datei ist zu groß!", "Fehler", MessageBoxButton.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -720,6 +734,18 @@ namespace ChatController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//abchecken ob neue Groupid in liste vorhanden , wenn nicht dann adde neuen kontakt der liste hinzu
|
||||
if (!_kontaktlist.Contains(neu))
|
||||
{
|
||||
_kontaktlist.ToList().Add(neu);
|
||||
}
|
||||
}
|
||||
|
||||
//umgekert ist eine kontakt aus der liste nicht mehr in neu muss diese raus
|
||||
if (!alist.Contains(liste))
|
||||
{
|
||||
_kontaktlist.ToList().Remove(liste);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -922,13 +948,13 @@ namespace ChatController
|
||||
|
||||
#endregion
|
||||
|
||||
#region Neue Für Bewoplaner | Nicht integriert
|
||||
#region Neue Für Bewoplaner | Nicht integriert | Wird nicht mehr gebraucht ?? wegnehmen
|
||||
private void DoSynchroForBewoplaner()
|
||||
{
|
||||
try
|
||||
{
|
||||
while (true) {
|
||||
UebergebeMessageInfoDatenFuerDb();
|
||||
// UebergebeMessageInfoDatenFuerDb();
|
||||
|
||||
var aktuelleGruppen = _chat.GruppenAktuallisieren();
|
||||
|
||||
@@ -936,7 +962,7 @@ namespace ChatController
|
||||
|
||||
_kontaktlist = x;
|
||||
|
||||
LeseMessageInfoAusDatei();
|
||||
//ErhalteMessageInfoVonDb();
|
||||
|
||||
Clientlist.Items.Refresh();
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
@@ -47,7 +48,7 @@ namespace ChatController.HauptKlassen
|
||||
public static readonly List<string> DokumentExtension = new List<string> { ".TXT", ".PPT", ".XLS", ".DOC",".PDF" };
|
||||
|
||||
private long lastTimeStamp=0;
|
||||
|
||||
|
||||
public Chat(ChatDatenUebergabe chatDaten)
|
||||
{
|
||||
ChatDaten = chatDaten;
|
||||
@@ -157,8 +158,11 @@ namespace ChatController.HauptKlassen
|
||||
ms.Position = 0;
|
||||
BitmapImage bi = new BitmapImage();
|
||||
bi.BeginInit();
|
||||
bi.CacheOption = BitmapCacheOption.OnLoad;
|
||||
bi.StreamSource = ms;
|
||||
bi.EndInit();
|
||||
ms.Dispose();
|
||||
ms.Close();
|
||||
|
||||
return bi;
|
||||
}
|
||||
@@ -963,14 +967,93 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
if (ImageExtensions.Contains(Path.GetExtension(file).ToUpperInvariant()))
|
||||
{
|
||||
BitmapImage logo = new BitmapImage();
|
||||
logo.BeginInit();
|
||||
logo.UriSource = new Uri(file);
|
||||
logo.EndInit();
|
||||
byte[] mdatei;
|
||||
using (Stream reader = File.OpenRead(file))
|
||||
{
|
||||
mdatei = ReadFully(reader);
|
||||
}
|
||||
|
||||
MemoryStream mss = new MemoryStream(mdatei);
|
||||
System.Drawing.Image Img = System.Drawing.Image.FromStream(mss);
|
||||
|
||||
|
||||
using (System.Drawing.Bitmap dImg = new System.Drawing.Bitmap(Img))
|
||||
{
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
short orient = 0;
|
||||
int orientationId = 0x0112;
|
||||
|
||||
if (Img.PropertyIdList.Contains(orientationId))
|
||||
{
|
||||
PropertyItem item = Img.GetPropertyItem(orientationId);
|
||||
|
||||
|
||||
orient = BitConverter.ToInt16(item.Value, 0);
|
||||
|
||||
dImg.SetPropertyItem(item);
|
||||
}
|
||||
|
||||
|
||||
var x = OrientationToFlipType(orient.ToString());
|
||||
|
||||
dImg.RotateFlip(x);
|
||||
|
||||
dImg.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
|
||||
|
||||
|
||||
System.Windows.Media.Imaging.BitmapImage bImg = new System.Windows.Media.Imaging.BitmapImage();
|
||||
|
||||
bImg.BeginInit();
|
||||
bImg.StreamSource = new MemoryStream(ms.ToArray());
|
||||
bImg.EndInit();
|
||||
|
||||
System.Windows.Controls.Image img = new System.Windows.Controls.Image();
|
||||
img.Source = bImg;
|
||||
|
||||
|
||||
Messages.Add(new KontaktMessageBuilder(ChatMessage.User_Name, Path.GetFileName(file),
|
||||
timeformated.ToString("dd MMM | HH:mm"), true, bImg,
|
||||
timeformated, file, Path.GetFileName(file)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
//var image = new BitmapImage();
|
||||
|
||||
//using (var ms = new System.IO.MemoryStream(mdatei))
|
||||
//{
|
||||
|
||||
// image.BeginInit();
|
||||
// image.CacheOption = BitmapCacheOption.OnLoad; // here
|
||||
// image.StreamSource = ms;
|
||||
// image.EndInit();
|
||||
|
||||
// ms.Dispose();
|
||||
//}
|
||||
|
||||
//int orientationId = 0x0112;
|
||||
|
||||
//if (Img.PropertyIdList.Contains(orientationId))
|
||||
//{
|
||||
// PropertyItem item = Img.GetPropertyItem(orientationId);
|
||||
|
||||
// //image.SetPropertyItem(item);
|
||||
//}
|
||||
|
||||
|
||||
//Messages.Add(new KontaktMessageBuilder(ChatMessage.User_Name, Path.GetFileName(file),
|
||||
// timeformated.ToString("dd MMM | HH:mm"), true, image,
|
||||
// timeformated, file, Path.GetFileName(file)));
|
||||
|
||||
mss.Dispose();
|
||||
mss.Close();
|
||||
|
||||
//Messages.Add(new KontaktMessageBuilder(ChatMessage.User_Name, Path.GetFileName(file),
|
||||
// timeformated.ToString("dd MMM | HH:mm"), true, timeformated, file, Path.GetFileName(file)));
|
||||
|
||||
|
||||
Messages.Add(new KontaktMessageBuilder(ChatMessage.User_Name, Path.GetFileName(file),
|
||||
timeformated.ToString("dd MMM | HH:mm"), true, logo,
|
||||
timeformated, file, Path.GetFileName(file)));
|
||||
}
|
||||
else if (DokumentExtension.Contains(Path.GetExtension(file).ToUpperInvariant()))
|
||||
{
|
||||
@@ -1007,6 +1090,7 @@ namespace ChatController.HauptKlassen
|
||||
biImg.StreamSource = ms;
|
||||
biImg.EndInit();
|
||||
|
||||
ms.Close();
|
||||
ImageSource logo = biImg;
|
||||
|
||||
Messages.Add(new KontaktMessageBuilder(ChatMessage.User_Name, Path.GetFileName(filename),
|
||||
@@ -1041,16 +1125,17 @@ namespace ChatController.HauptKlassen
|
||||
mdatei = ReadFully(reader);
|
||||
}
|
||||
|
||||
string filename = Path.GetFileName(file);
|
||||
string filename = Path.GetFileName(file).ToLower();
|
||||
|
||||
//Medium auflösung auf 80 % vom original setzen
|
||||
//Image x = (Bitmap)((new ImageConverter()).ConvertFrom(mdatei));
|
||||
|
||||
// image wieder in byte[] umwandeln und übergeben
|
||||
if (ImageExtensions.Contains(Path.GetExtension(filename).ToUpperInvariant())){
|
||||
var scaledImage = ScaleImage(mdatei);
|
||||
|
||||
filename = filename.Replace(".bmp", ".jpg");
|
||||
|
||||
SendMediaMessage(filename, kontakt.GroupId, scaledImage);
|
||||
SendMediaMessage(filename, kontakt.GroupId, mdatei);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1059,39 +1144,172 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
}
|
||||
|
||||
private byte[] ScaleImage(byte[] mdatei)
|
||||
public string ScaleImage(string file,string format)
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] mdatei;
|
||||
using (Stream reader = File.OpenRead(file))
|
||||
{
|
||||
mdatei = ReadFully(reader);
|
||||
}
|
||||
|
||||
|
||||
MemoryStream ms = new MemoryStream(mdatei);
|
||||
System.Drawing.Image Image = System.Drawing.Image.FromStream(ms);
|
||||
|
||||
int width = (int) (Image.Width / 100 * 80);
|
||||
int height = (int) (Image.Height / 100 * 80);
|
||||
System.Drawing.Bitmap bmpScaled = new System.Drawing.Bitmap(Image);
|
||||
|
||||
float width = 0;
|
||||
float height = 0;
|
||||
//Querformat
|
||||
if (Image.Height < Image.Width )
|
||||
{
|
||||
|
||||
if (Image.Height > 1080)
|
||||
{
|
||||
float factor = (float)Image.Height / 1080;
|
||||
|
||||
height = 1080;
|
||||
|
||||
width = Image.Width / factor;
|
||||
}
|
||||
else
|
||||
{
|
||||
return file;
|
||||
}
|
||||
}
|
||||
else if(Image.Height < 1080 && Image.Width < 1080 )
|
||||
{
|
||||
return file;
|
||||
}
|
||||
else // Hochformat
|
||||
{
|
||||
if (Image.Width > 1080)
|
||||
{
|
||||
float factor = (float)Image.Width / 1080;
|
||||
|
||||
width = 1080;
|
||||
|
||||
height = Image.Height / factor;
|
||||
}
|
||||
else
|
||||
{
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
System.Drawing.Bitmap bmpScaled = new System.Drawing.Bitmap(Image,new Size((int)width,(int)height));
|
||||
|
||||
int orientationId = 0x0112;
|
||||
|
||||
if (Image.PropertyIdList.Contains(orientationId)) {
|
||||
PropertyItem item = Image.GetPropertyItem(orientationId);
|
||||
|
||||
bmpScaled.SetPropertyItem(item);
|
||||
}
|
||||
|
||||
using (Graphics gr = Graphics.FromImage(Image))
|
||||
{
|
||||
gr.Clear(Color.Transparent);
|
||||
|
||||
// falls jemand mekert, muss die intergedönse erhöht werden
|
||||
gr.InterpolationMode = InterpolationMode.NearestNeighbor; // InterpolationMode.HighQualityBicubic;
|
||||
gr.InterpolationMode = InterpolationMode.Low; // InterpolationMode.HighQualityBicubic;
|
||||
|
||||
gr.DrawImage(bmpScaled, 0, 0, width, height);
|
||||
|
||||
gr.DrawImage(bmpScaled, (int)width, (int)height);
|
||||
//bitMap = gr.GetHdc();
|
||||
}
|
||||
|
||||
ImageConverter converter = new ImageConverter();
|
||||
byte[] imageData = (byte[]) converter.ConvertTo(bmpScaled, typeof(byte[]));
|
||||
|
||||
return imageData;
|
||||
byte[] imageData = (byte[])converter.ConvertTo(bmpScaled, typeof(byte[]));
|
||||
|
||||
|
||||
string filePath = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + format;
|
||||
|
||||
|
||||
//".JPG", ".JPE", ".BMP", ".GIF", ".PNG", ".JPEG"
|
||||
if (format.Equals(".JPG") || format.Equals(".JPE") || format.Equals(".JPEG") || format.Equals(".BMP"))
|
||||
{
|
||||
bmpScaled.Save(filePath, ImageFormat.Jpeg);
|
||||
}else if (format.Equals(".PNG"))
|
||||
{
|
||||
bmpScaled.Save(filePath, ImageFormat.Png);
|
||||
}
|
||||
else if (format.Equals(".GIF"))
|
||||
{
|
||||
bmpScaled.Save(filePath, ImageFormat.Gif);
|
||||
}
|
||||
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
FileInfo f = new FileInfo(filePath);
|
||||
long s1 = f.Length;
|
||||
|
||||
if (ChatDaten.MaxUploadSize < s1)
|
||||
{
|
||||
File.Delete(filePath);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
//byte[] datei;
|
||||
//using (Stream reader = File.OpenRead(filePath))
|
||||
//{
|
||||
// datei = ReadFully(reader);
|
||||
//}
|
||||
ms.Dispose();
|
||||
ms.Close();
|
||||
|
||||
return filePath;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show(e.Message, "Fehler");
|
||||
return mdatei;
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
public static RotateFlipType OrientationToFlipType(string orientation)
|
||||
{
|
||||
switch (int.Parse(orientation))
|
||||
{
|
||||
case 1:
|
||||
return RotateFlipType.RotateNoneFlipNone;
|
||||
break;
|
||||
case 2:
|
||||
return RotateFlipType.RotateNoneFlipX;
|
||||
break;
|
||||
case 3:
|
||||
return RotateFlipType.Rotate180FlipNone;
|
||||
break;
|
||||
case 4:
|
||||
return RotateFlipType.Rotate180FlipX;
|
||||
break;
|
||||
case 5:
|
||||
return RotateFlipType.Rotate90FlipX;
|
||||
break;
|
||||
case 6:
|
||||
return RotateFlipType.Rotate90FlipNone;
|
||||
break;
|
||||
case 7:
|
||||
return RotateFlipType.Rotate270FlipX;
|
||||
break;
|
||||
case 8:
|
||||
return RotateFlipType.Rotate270FlipNone;
|
||||
break;
|
||||
default:
|
||||
return RotateFlipType.RotateNoneFlipNone;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static byte[] ReadFully(Stream stream)
|
||||
{
|
||||
byte[] buffer = new byte[32768];
|
||||
@@ -1469,49 +1687,157 @@ namespace ChatController.HauptKlassen
|
||||
{
|
||||
using (Form form = new Form())
|
||||
{
|
||||
Image imgg = new Image();
|
||||
//Image imgg = new Image();
|
||||
|
||||
BitmapImage bix = new BitmapImage();
|
||||
using (var stream = new MemoryStream(e.Result))
|
||||
//BitmapImage bix = new BitmapImage();
|
||||
//using (var stream = new MemoryStream(e.Result))
|
||||
//{
|
||||
// bix.BeginInit();
|
||||
// bix.CacheOption = BitmapCacheOption.OnLoad;
|
||||
// bix.StreamSource = stream;
|
||||
// bix.EndInit();
|
||||
//}
|
||||
|
||||
//imgg.Source = bix;
|
||||
|
||||
//BmpBitmapEncoder encoder = new BmpBitmapEncoder();
|
||||
//MemoryStream ms = new MemoryStream();
|
||||
//encoder.Frames.Add(BitmapFrame.Create((BitmapSource) imgg.Source));
|
||||
//encoder.Save(ms);
|
||||
//System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
|
||||
|
||||
//##################################################################################
|
||||
MemoryStream ms = new MemoryStream(e.Result);
|
||||
System.Drawing.Image Img = System.Drawing.Image.FromStream(ms);
|
||||
|
||||
|
||||
using (System.Drawing.Bitmap dImg = new System.Drawing.Bitmap(Img))
|
||||
{
|
||||
bix.BeginInit();
|
||||
bix.CacheOption = BitmapCacheOption.OnLoad;
|
||||
bix.StreamSource = stream;
|
||||
bix.EndInit();
|
||||
}
|
||||
using (MemoryStream mss = new MemoryStream())
|
||||
{
|
||||
short orient = 0;
|
||||
int orientationId = 0x0112;
|
||||
|
||||
imgg.Source = bix;
|
||||
if (Img.PropertyIdList.Contains(orientationId))
|
||||
{
|
||||
PropertyItem item = Img.GetPropertyItem(orientationId);
|
||||
|
||||
orient = BitConverter.ToInt16(item.Value, 0);
|
||||
|
||||
BmpBitmapEncoder encoder = new BmpBitmapEncoder();
|
||||
MemoryStream ms = new MemoryStream();
|
||||
encoder.Frames.Add(BitmapFrame.Create((BitmapSource) imgg.Source));
|
||||
encoder.Save(ms);
|
||||
System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
|
||||
dImg.SetPropertyItem(item);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Bitmap imgbit = new Bitmap(img);
|
||||
var x = OrientationToFlipType(orient.ToString());
|
||||
|
||||
form.StartPosition = FormStartPosition.CenterScreen;
|
||||
form.Size = imgbit.Size;
|
||||
form.MinimumSize = new Size(150,150);
|
||||
|
||||
var width = (int)Math.Round(System.Windows.SystemParameters.PrimaryScreenWidth / 1.25);
|
||||
var height = (int)Math.Round(System.Windows.SystemParameters.PrimaryScreenWidth / 2);
|
||||
form.MaximumSize = new Size(width, height);
|
||||
form.FormBorderStyle = FormBorderStyle.Sizable;
|
||||
|
||||
form.MaximizeBox = false;
|
||||
dImg.RotateFlip(x);
|
||||
|
||||
form.Text = "ownChat Bild Voschau";
|
||||
form.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
|
||||
|
||||
form.StartPosition = FormStartPosition.CenterScreen;
|
||||
form.Size = dImg.Size;//imgbit
|
||||
form.MinimumSize = new Size(180,180);
|
||||
|
||||
#region Screen Size-ing
|
||||
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
int targetwidth = (int)Math.Round(System.Windows.SystemParameters.PrimaryScreenWidth / 1.25);
|
||||
|
||||
|
||||
//Querformat
|
||||
if (dImg.Height < dImg.Width)
|
||||
{
|
||||
|
||||
float factor = (float)dImg.Height / targetwidth;
|
||||
|
||||
height =targetwidth;
|
||||
|
||||
width = (int)Math.Round(dImg.Width / factor);
|
||||
|
||||
}
|
||||
else // Hochformat
|
||||
{
|
||||
float factor = (float)dImg.Width / targetwidth;
|
||||
|
||||
width = targetwidth;
|
||||
|
||||
height = (int)Math.Round(dImg.Height / factor);
|
||||
|
||||
}
|
||||
|
||||
if (dImg.Width < targetwidth)
|
||||
{
|
||||
width = dImg.Width;
|
||||
height = dImg.Height;
|
||||
}
|
||||
//#################################
|
||||
|
||||
int targetheight = (int)Math.Round(System.Windows.SystemParameters.PrimaryScreenHeight / 1.25);
|
||||
|
||||
|
||||
//Querformat
|
||||
if (dImg.Height < dImg.Width)
|
||||
{
|
||||
|
||||
float factor = (float)dImg.Width / targetheight;
|
||||
|
||||
width = targetheight;
|
||||
|
||||
height = (int)Math.Round(dImg.Height / factor);
|
||||
|
||||
}
|
||||
else // Hochformat
|
||||
{
|
||||
float factor = (float)dImg.Height / targetheight;
|
||||
|
||||
height = targetheight;
|
||||
|
||||
width = (int)Math.Round(dImg.Width / factor);
|
||||
|
||||
}
|
||||
|
||||
if (dImg.Height < targetheight)
|
||||
{
|
||||
width = dImg.Width;
|
||||
height = dImg.Height;
|
||||
}
|
||||
|
||||
//##########################################
|
||||
if (width < 150 || height < 150)
|
||||
{
|
||||
width = 150;
|
||||
height = 150;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
form.MaximumSize = new Size(width, height);
|
||||
|
||||
|
||||
form.FormBorderStyle = FormBorderStyle.Sizable;
|
||||
|
||||
form.MaximizeBox = false;
|
||||
|
||||
form.Text = "ownChat Bild Voschau";
|
||||
form.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
|
||||
|
||||
PictureBox pb = new PictureBox();
|
||||
pb.Dock = DockStyle.Fill;
|
||||
pb.Image = dImg;//imgbit
|
||||
|
||||
pb.SizeMode = PictureBoxSizeMode.StretchImage;
|
||||
|
||||
form.Controls.Add(pb);
|
||||
form.ShowDialog();
|
||||
} //
|
||||
}//
|
||||
|
||||
|
||||
ms.Dispose();
|
||||
ms.Close();
|
||||
|
||||
PictureBox pb = new PictureBox();
|
||||
pb.Dock = DockStyle.Fill;
|
||||
pb.Image = imgbit;
|
||||
|
||||
pb.SizeMode = PictureBoxSizeMode.StretchImage;
|
||||
|
||||
form.Controls.Add(pb);
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
catch (Exception edf)
|
||||
@@ -1572,6 +1898,44 @@ namespace ChatController.HauptKlassen
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Maximal erlaubte File Größe
|
||||
|
||||
public long GetMaiximumAllowedFileUploadSize(string apikey,string customerid)
|
||||
{
|
||||
try
|
||||
{
|
||||
var endurl = ChatDaten.ServerUrl + "/api/ownchat/uploadmaxsize";// + apikey + "/" + customerid;
|
||||
|
||||
WebRequest request = WebRequest.Create(endurl);
|
||||
requesten.Headers["Token"] = apikey;
|
||||
requesten.Headers["CustomerID"] = customerid;
|
||||
|
||||
request.Credentials = CredentialCache.DefaultCredentials;
|
||||
request.Proxy = null;
|
||||
|
||||
WebResponse response = request.GetResponse();
|
||||
|
||||
// Display the status.
|
||||
var statusResponse = ((HttpWebResponse)response).StatusDescription;
|
||||
|
||||
string responseFromServer = ReadStream(response);
|
||||
|
||||
var definiti = new { file_upload_max_size = "" };
|
||||
|
||||
var jsonDatentyp = JsonConvert.DeserializeAnonymousType(responseFromServer, definiti);
|
||||
|
||||
|
||||
return Convert.ToInt64(jsonDatentyp.file_upload_max_size);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Neue Gruppen Holen für OwnChatDesktop
|
||||
|
||||
@@ -78,8 +78,11 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
|
||||
if (_gruppeholenverbindungsaufbauOK)
|
||||
{
|
||||
ChatDatenUebergabe ubergabe = new ChatDatenUebergabe(_serverconect, _userconect, _groupconect, _serverUrl, _authToken, _userid, _kundennummer,_apikey);
|
||||
{
|
||||
|
||||
long maxUploadSize = GetMaiximumAllowedFileUploadSize(_authToken,_kundennummer);
|
||||
|
||||
ChatDatenUebergabe ubergabe = new ChatDatenUebergabe(_serverconect, _userconect, _groupconect, _serverUrl, _authToken, _userid, _kundennummer,_apikey, maxUploadSize);
|
||||
|
||||
return ubergabe;
|
||||
}
|
||||
@@ -332,5 +335,42 @@ namespace ChatController.HauptKlassen
|
||||
}
|
||||
}
|
||||
|
||||
#region Maximal erlaubte File Größe
|
||||
|
||||
public long GetMaiximumAllowedFileUploadSize(string token, string customerid)
|
||||
{
|
||||
try
|
||||
{
|
||||
var endurl = _serverUrl + "/api/ownchat/uploadmaxsize";// + apikey + "/" + customerid;
|
||||
|
||||
WebRequest request = WebRequest.Create(endurl);
|
||||
request.Headers["Token"] = token;
|
||||
request.Headers["CustomerID"] = customerid;
|
||||
|
||||
request.Credentials = CredentialCache.DefaultCredentials;
|
||||
request.Proxy = null;
|
||||
|
||||
WebResponse response = request.GetResponse();
|
||||
|
||||
// Display the status.
|
||||
var statusResponse = ((HttpWebResponse)response).StatusDescription;
|
||||
|
||||
string responseFromServer = ReadStream(response);
|
||||
|
||||
var definiti = new { file_upload_max_size = "" };
|
||||
|
||||
var jsonDatentyp = JsonConvert.DeserializeAnonymousType(responseFromServer, definiti);
|
||||
|
||||
|
||||
return Convert.ToInt64(jsonDatentyp.file_upload_max_size);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,9 @@ namespace ChatController.Klassen
|
||||
private long? _userid { get; set; }
|
||||
private string _kundennummer { get; set; }
|
||||
private string _apikey { get; set; }
|
||||
private long _maxUploadSize { get; set; }
|
||||
|
||||
public ChatDatenUebergabe(AuthentifizierungsDaten serverConect, UserDaten userConect, ChatGruppenDaten groupConect, string serverUrl, string authToken, long? userid, string kundennummer, string apikey)
|
||||
public ChatDatenUebergabe(AuthentifizierungsDaten serverConect, UserDaten userConect, ChatGruppenDaten groupConect, string serverUrl, string authToken, long? userid, string kundennummer, string apikey,long maxUploadSize)
|
||||
{
|
||||
_serverconect = serverConect;
|
||||
_userconect = userConect;
|
||||
@@ -29,6 +30,7 @@ namespace ChatController.Klassen
|
||||
_userid = userid;
|
||||
_kundennummer = kundennummer;
|
||||
_apikey = apikey;
|
||||
_maxUploadSize = maxUploadSize;
|
||||
}
|
||||
|
||||
public AuthentifizierungsDaten Serverconect
|
||||
@@ -126,5 +128,17 @@ namespace ChatController.Klassen
|
||||
_apikey = value;
|
||||
}
|
||||
}
|
||||
|
||||
public long MaxUploadSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return _maxUploadSize;
|
||||
}
|
||||
private set
|
||||
{
|
||||
_maxUploadSize = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user