internal static bool LoadNoteProperties(PNote note, DataRow r)
        {
            try
            {
                var sc = new SizeConverter();
                var scd = new System.Drawing.SizeConverter();
                var pc = new PointConverter();

                note.FromDB = true;
                note.ID = (string)r["ID"];
                note.Name = (string)r["NAME"];
                note.GroupID = (int)r["GROUP_ID"];
                note.PrevGroupID = (int)r["PREV_GROUP_ID"];
                note.Opacity = (double)r["OPACITY"];
                note.Visible = (bool)r["VISIBLE"];
                note.Favorite = (bool)r["FAVORITE"];
                note.Protected = (bool)r["PROTECTED"];
                note.Completed = (bool)r["COMPLETED"];
                note.Priority = (bool)r["PRIORITY"];
                note.PasswordString = (string)r["PASSWORD_STRING"];
                note.Pinned = (bool)r["PINNED"];
                note.Topmost = (bool)r["TOPMOST"];
                note.Rolled = (bool)r["ROLLED"];
                note.DockStatus = (DockStatus)r["DOCK_STATUS"];
                note.DockOrder = (int)r["DOCK_ORDER"];
                note.SentReceived = (SendReceiveStatus)r["SEND_RECEIVE_STATUS"];
                note.DateCreated = DateTime.Parse((string)r["DATE_CREATED"], PNStatic.CultureInvariant);
                note.DateSaved = DateTime.Parse((string)r["DATE_SAVED"], PNStatic.CultureInvariant);
                note.DateSent = DateTime.Parse((string)r["DATE_SENT"], PNStatic.CultureInvariant);
                note.DateReceived = DateTime.Parse((string)r["DATE_RECEIVED"], PNStatic.CultureInvariant);
                note.DateDeleted = DateTime.Parse((string)r["DATE_DELETED"], PNStatic.CultureInvariant);
                var convertFromString = sc.ConvertFromString(null, PNStatic.CultureInvariant, (string)r["SIZE"]);
                if (convertFromString != null)
                    note.NoteSize = (Size)convertFromString;
                convertFromString = pc.ConvertFromString(null, PNStatic.CultureInvariant, (string)r["LOCATION"]);
                if (convertFromString != null)
                    note.NoteLocation = (Point)convertFromString;
                convertFromString = scd.ConvertFromString(null, PNStatic.CultureInvariant, (string)r["EDIT_SIZE"]);
                if (convertFromString != null)
                    note.EditSize = (System.Drawing.Size)convertFromString;
                note.XFactor = (double)r["REL_X"];
                note.YFactor = (double)r["REL_Y"];
                note.SentTo = (string)r["SENT_TO"];
                note.ReceivedFrom = (string)r["RECEIVED_FROM"];
                note.ReceivedIp = !PNData.IsDBNull(r["RECEIVED_IP"]) ? (string) r["RECEIVED_IP"] : "";
                note.PinClass = (string)r["PIN_CLASS"];
                note.PinText = (string)r["PIN_TEXT"];
                note.Scrambled = !PNData.IsDBNull(r["SCRAMBLED"]) && (bool)r["SCRAMBLED"];
                note.Thumbnail = !PNData.IsDBNull(r["THUMBNAIL"]) && (bool)r["THUMBNAIL"];

                return loadNoteSchedule(note);
            }
            catch (Exception ex)
            {
                PNStatic.LogException(ex);
                return false;
            }
        }
Beispiel #2
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            var str = value as string;
            if (str != null)
            {
                var note = new PNote();
                var values = str.Split(DEL_NOTE);
                if (values.Length == Enum.GetValues(typeof(Fields)).Length)
                {
                    string[] arr;
                    var dtc = new DateTimeConverter();
                    var szc = new SizeConverter();
                    var scd = new System.Drawing.SizeConverter();
                    var ptc = new PointConverter();
                    var scv = new ScheduleConverter();
                    var skc = new SkinlessConverter();

                    note.Changed = Convert.ToBoolean(values[(int)Fields.Changed]);
                    note.Completed = Convert.ToBoolean(values[(int)Fields.Completed]);
                    note.CustomOpacity = Convert.ToBoolean(values[(int)Fields.CustomOpacity]);
                    var dateFromString = dtc.ConvertFromString(null, PNStatic.CultureInvariant, values[(int)Fields.DateCreated]);
                    if (dateFromString != null)
                        note.DateCreated = (DateTime)dateFromString;
                    dateFromString = dtc.ConvertFromString(null, PNStatic.CultureInvariant, values[(int)Fields.DateDeleted]);
                    if (dateFromString != null)
                        note.DateDeleted = (DateTime)dateFromString;
                    dateFromString = dtc.ConvertFromString(null, PNStatic.CultureInvariant, values[(int)Fields.DateReceived]);
                    if (dateFromString != null)
                        note.DateReceived = (DateTime)dateFromString;
                    dateFromString = dtc.ConvertFromString(null, PNStatic.CultureInvariant, values[(int)Fields.DateSaved]);
                    if (dateFromString != null)
                        note.DateSaved = (DateTime)dateFromString;
                    dateFromString = dtc.ConvertFromString(null, PNStatic.CultureInvariant, values[(int)Fields.DateSent]);
                    if (dateFromString != null)
                        note.DateSent = (DateTime)dateFromString;
                    note.DockStatus = (DockStatus)Convert.ToInt32(values[(int)Fields.DockStatus]);
                    var sizeFromString = scd.ConvertFromString(null, PNStatic.CultureInvariant, values[(int)Fields.EditSize]);
                    if (sizeFromString != null)
                        note.EditSize = (Size)sizeFromString;
                    note.Favorite = Convert.ToBoolean(values[(int)Fields.Favorite]);
                    note.FromDB = Convert.ToBoolean(values[(int)Fields.FromDB]);
                    note.GroupID = Convert.ToInt32(values[(int)Fields.GroupID]);
                    note.ID = values[(int)Fields.ID];
                    var temp = values[(int)Fields.LinkedNotes];
                    if (temp != "")
                    {
                        arr = temp.Split(DEL_INNER);
                        foreach (var s in arr)
                        {
                            note.LinkedNotes.Add(s);
                        }
                    }
                    note.Name = values[(int)Fields.Name];
                    var convertFromString = ptc.ConvertFromString(null, PNStatic.CultureInvariant, values[(int)Fields.NoteLocation]);
                    if (convertFromString != null)
                        note.NoteLocation = (Point)convertFromString;
                    var fromString = szc.ConvertFromString(null, PNStatic.CultureInvariant, values[(int)Fields.NoteSize]);
                    if (fromString != null)
                        note.NoteSize = (System.Windows.Size)fromString;
                    note.Opacity = Convert.ToDouble(values[(int)Fields.Opacity], PNStatic.CultureInvariant);
                    note.PasswordString = values[(int)Fields.PasswordString];
                    note.Pinned = Convert.ToBoolean(values[(int)Fields.Pinned]);
                    note.PrevGroupID = Convert.ToInt32(values[(int)Fields.PrevGroupID]);
                    note.Priority = Convert.ToBoolean(values[(int)Fields.Priority]);
                    note.Protected = Convert.ToBoolean(values[(int)Fields.Protected]);
                    note.ReceivedFrom = values[(int)Fields.ReceivedFrom];
                    note.Rolled = Convert.ToBoolean(values[(int)Fields.Rolled]);
                    note.Schedule = (PNNoteSchedule)scv.ConvertFromString(values[(int)Fields.Schedule]);
                    note.SentReceived = (SendReceiveStatus)Convert.ToInt32(values[(int)Fields.SentReceived]);
                    note.SentTo = values[(int)Fields.SentTo];
                    temp = values[(int)Fields.SkinName];
                    if (temp != PNSkinDetails.NO_SKIN && temp != "")
                    {
                        // TODO - get skin properties
                    }
                    note.Skinless = (PNSkinlessDetails)skc.ConvertFromString(values[(int)Fields.Skinless]);
                    temp = values[(int)Fields.Tags];
                    if (temp != "")
                    {
                        arr = temp.Split(DEL_INNER);
                        foreach (var s in arr)
                        {
                            note.Tags.Add(s);
                        }
                    }
                    note.Topmost = Convert.ToBoolean(values[(int)Fields.Topmost]);
                    note.Visible = Convert.ToBoolean(values[(int)Fields.Visible]);
                    note.XFactor = Convert.ToDouble(values[(int)Fields.XFactor], PNStatic.CultureInvariant);
                    note.YFactor = Convert.ToDouble(values[(int)Fields.YFactor], PNStatic.CultureInvariant);
                    note.PinClass = values[(int)Fields.PinClass];
                    note.PinText = values[(int)Fields.PinText];
                }
                return note;
            }
            return base.ConvertFrom(context, culture, value);
        }