- Apple Watch
- Samsung Galaxy S23 Ultra - non plus ultra
- Apple iPhone Air - almacsutka
- Apple iPhone 17 Pro Max – fennsík
- iPhone topik
- Huawei Watch GT 6 és GT 6 Pro duplateszt
- Merész dizájn és új teleobjektív az iPhone 17 Pro mobilokban
- Yettel topik
- Samsung Galaxy Z Fold6 - ugyanaz, sarkosan fogalmazva
- Kézbe fogható paradoxon lett az iPhone Air
Új hozzászólás Aktív témák
-
DrojDtroll
veterán
válasz
DrojDtroll #8292 üzenetére
Ezt a problémát megoldottam úgy hogy csináltam egy osztály ami egyetlen color field-et tartalmaz.
Most a serializációval küszködök.
A Class amit el kellene menteni.
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
namespace raw_data
{
[Serializable]
public class ColorPalette : Data.ISeriazable
{
private List<Imaging.RefColor> _colorList;
public string SerializedName { get; set; }
public ColorPalette()
{
ColorList = new List<Imaging.RefColor>();
ColorList.Add(new Imaging.RefColor(Settings.ColorPalette.Default.DefaultMin));
ColorList.Add(new Imaging.RefColor(Settings.ColorPalette.Default.DefaultMax));
SerializedName = Settings.Folder.Default.ColorPalette + Path.AltDirectorySeparatorChar + System.IO.Directory.GetFiles(Settings.Folder.Default.ColorPalette).Length;
}
public List<Imaging.RefColor> ColorList { get => _colorList; set => _colorList = value; }
public Lut lut { get; set; }
public string GetSerializedName()
{
return SerializedName;
}
}
}A serializálást végző függvény:
public static void SerializeObject(Data.ISeriazable obj)
{
IFormatter formatter = new BinaryFormatter();
Stream stream = new FileStream(obj.GetSerializedName(),
FileMode.Create,
FileAccess.Write, FileShare.None);
formatter.Serialize(stream, obj);
stream.Close();
}A visszatöltés metódusa
internal static void LoadSerializedPalettes(GroupBox colorPaletteGroupBox)
{
string[] serializedfilenames=Directory.GetFiles(Settings.Folder.Default.ColorPalette);
foreach (var item in serializedfilenames)
{
IFormatter formatter = new BinaryFormatter();
Stream stream = new FileStream(item,
FileMode.Open,
FileAccess.Read,
FileShare.Read);
ColorPalette cp = (ColorPalette)formatter.Deserialize(stream);
stream.Close();
ColorPaletteSettings.ColorPaletteList.Add(cp);
AddNewPalatte(colorPaletteGroupBox, cp);
}
}Nem töltődnek rendesen vissza az objektumok. A stream még rendesen megvan. Debugban látom, hogy a hossza olyan mint amilyennek lennie kell.
Mitől lehet, hogy mégis null-t kapok?
Új hozzászólás Aktív témák
● ha kódot szúrsz be, használd a PROGRAMKÓD formázási funkciót!
- Apple iPhone 13 Pro 256GB, Akku: 85%Normál, Kártyafüggetlen, Töltővel, Dobozzal, 1 Év Garanciával!
- Apple iPhone 13 128GB, Akku: 100%, Normál, Kártyafüggetlen, Töltővel, Dobozzal, 1 Év Garanciával!
- Xiaomi Redmi 15 6/128GB, Megkímélt, Kártyafüggetlen, Töltővel, Dobozzal, 1 Év Garanciával!
- Apple iPhone 13 128GB, Akku: 100%, Normál, Kártyafüggetlen, Töltővel, Dobozzal, 1 Év Garanciával!
- Be Quiet Pure Rock FX Black BK033 + Garancia 2027.02.08-ig
- DELL PowerEdge R740 rack szerver - 2xGold 6130 (16c/32t, 2.1/3.7GHz), 64GB RAM, 10Gbit HBA330, áfás
- ÁRGARANCIA!Épített KomPhone Ryzen 5 7600X 32/64GB RAM RTX 5070 12GB GAMER PC termékbeszámítással
- GYÖNYÖRŰ iPhone 12 64GB Black -1 ÉV GARANCIA - Kártyafüggetlen, MS2113, 100% Akkumulátor
- GYÖNYÖRŰ iPhone 13 mini 128GB Green -1 ÉV GARANCIA - Kártyafüggetlen, MS3340
- ÁRCSÖKKENTÉS AlzaPower M7503CA Fast Charge 100W
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest