예제 #1
0
		public void CanConvertTo ()
		{
			PointConverter r = new PointConverter ();

			Assert.IsTrue (r.CanConvertTo (typeof (string)));
			Assert.IsFalse (r.CanConvertTo (typeof (Point)));
		}
예제 #2
0
		public void ConvertTo ()
		{
			PointConverter r = new PointConverter ();

			Point rect = new Point (1, 2);

			object o = r.ConvertTo (rect, typeof (string));
			
			Assert.AreEqual (typeof (string), o.GetType());
			Assert.AreEqual ("1,2", (string)o);
		}
예제 #3
0
		public void ConvertFrom ()
		{
			PointConverter r = new PointConverter ();

			object or = r.ConvertFrom ("3, 4");
			
			Assert.AreEqual (typeof (Point), or.GetType());
			Assert.AreEqual (new Point (3, 4), or);

			or = r.ConvertFrom ("-1, -4");
			Assert.AreEqual (typeof (Point), or.GetType());
			Assert.AreEqual (new Point (-1, -4), or);
		}
예제 #4
0
 // Initialize known object types
 internal static TypeConverter CreateKnownTypeConverter(Int16 converterId)
 { 
     TypeConverter o = null;
     switch (converterId) 
     { 
         case -42: o = new System.Windows.Media.Converters.BoolIListConverter(); break;
         case -46: o = new System.ComponentModel.BooleanConverter(); break; 
         case -53: o = new System.Windows.Media.BrushConverter(); break;
         case -61: o = new System.ComponentModel.ByteConverter(); break;
         case -70: o = new System.ComponentModel.CharConverter(); break;
         case -71: o = new System.Windows.Media.Converters.CharIListConverter(); break; 
         case -87: o = new System.Windows.Media.ColorConverter(); break;
         case -94: o = new System.Windows.Input.CommandConverter(); break; 
         case -96: o = new System.Windows.Markup.ComponentResourceKeyConverter(); break; 
         case -111: o = new System.Windows.CornerRadiusConverter(); break;
         case -114: o = new System.ComponentModel.CultureInfoConverter(); break; 
         case -115: o = new System.Windows.CultureInfoIetfLanguageTagConverter(); break;
         case -117: o = new System.Windows.Input.CursorConverter(); break;
         case -124: o = new System.ComponentModel.DateTimeConverter(); break;
         case -125: o = new System.Windows.Markup.DateTimeConverter2(); break; 
         case -130: o = new System.ComponentModel.DecimalConverter(); break;
         case -137: o = new System.Windows.Markup.DependencyPropertyConverter(); break; 
         case -138: o = new System.Windows.DialogResultConverter(); break; 
         case -174: o = new System.Windows.Media.DoubleCollectionConverter(); break;
         case -175: o = new System.ComponentModel.DoubleConverter(); break; 
         case -176: o = new System.Windows.Media.Converters.DoubleIListConverter(); break;
         case -188: o = new System.Windows.DurationConverter(); break;
         case -190: o = new System.Windows.DynamicResourceExtensionConverter(); break;
         case -201: o = new System.Windows.ExpressionConverter(); break; 
         case -204: o = new System.Windows.FigureLengthConverter(); break;
         case -215: o = new System.Windows.Media.FontFamilyConverter(); break; 
         case -216: o = new System.Windows.FontSizeConverter(); break; 
         case -218: o = new System.Windows.FontStretchConverter(); break;
         case -220: o = new System.Windows.FontStyleConverter(); break; 
         case -222: o = new System.Windows.FontWeightConverter(); break;
         case -240: o = new System.Windows.Media.GeometryConverter(); break;
         case -256: o = new System.Windows.GridLengthConverter(); break;
         case -267: o = new System.ComponentModel.GuidConverter(); break; 
         case -286: o = new System.Windows.Media.ImageSourceConverter(); break;
         case -299: o = new System.Windows.Input.InputScopeConverter(); break; 
         case -301: o = new System.Windows.Input.InputScopeNameConverter(); break; 
         case -306: o = new System.ComponentModel.Int16Converter(); break;
         case -314: o = new System.Windows.Media.Int32CollectionConverter(); break; 
         case -315: o = new System.ComponentModel.Int32Converter(); break;
         case -319: o = new System.Windows.Int32RectConverter(); break;
         case -324: o = new System.ComponentModel.Int64Converter(); break;
         case -338: o = new System.Windows.Input.KeyConverter(); break; 
         case -340: o = new System.Windows.Input.KeyGestureConverter(); break;
         case -342: o = new System.Windows.KeySplineConverter(); break; 
         case -344: o = new System.Windows.KeyTimeConverter(); break; 
         case -348: o = new System.Windows.LengthConverter(); break;
         case -387: o = new System.Windows.Media.Media3D.Matrix3DConverter(); break; 
         case -392: o = new System.Windows.Media.MatrixConverter(); break;
         case -410: o = new System.Windows.Input.ModifierKeysConverter(); break;
         case -411: o = new System.Windows.Input.MouseActionConverter(); break;
         case -415: o = new System.Windows.Input.MouseGestureConverter(); break; 
         case -423: o = new System.Windows.NullableBoolConverter(); break;
         case -445: o = new System.Windows.Media.PathFigureCollectionConverter(); break; 
         case -453: o = new System.Windows.Media.PixelFormatConverter(); break; 
         case -462: o = new System.Windows.Media.Media3D.Point3DCollectionConverter(); break;
         case -463: o = new System.Windows.Media.Media3D.Point3DConverter(); break; 
         case -467: o = new System.Windows.Media.Media3D.Point4DConverter(); break;
         case -473: o = new System.Windows.Media.PointCollectionConverter(); break;
         case -474: o = new System.Windows.PointConverter(); break;
         case -475: o = new System.Windows.Media.Converters.PointIListConverter(); break; 
         case -492: o = new System.Windows.PropertyPathConverter(); break;
         case -498: o = new System.Windows.Media.Media3D.QuaternionConverter(); break; 
         case -507: o = new System.Windows.Media.Media3D.Rect3DConverter(); break; 
         case -511: o = new System.Windows.RectConverter(); break;
         case -521: o = new System.Windows.Media.Animation.RepeatBehaviorConverter(); break; 
         case -538: o = new System.Windows.Markup.RoutedEventConverter(); break;
         case -545: o = new System.ComponentModel.SByteConverter(); break;
         case -563: o = new System.ComponentModel.SingleConverter(); break;
         case -568: o = new System.Windows.Media.Media3D.Size3DConverter(); break; 
         case -572: o = new System.Windows.SizeConverter(); break;
         case -615: o = new System.ComponentModel.StringConverter(); break; 
         case -619: o = new System.Windows.StrokeCollectionConverter(); break; 
         case -633: o = new System.Windows.TemplateBindingExpressionConverter(); break;
         case -635: o = new System.Windows.TemplateBindingExtensionConverter(); break; 
         case -637: o = new System.Windows.Markup.TemplateKeyConverter(); break;
         case -645: o = new System.Windows.TextDecorationCollectionConverter(); break;
         case -655: o = new System.Windows.ThicknessConverter(); break;
         case -664: o = new System.ComponentModel.TimeSpanConverter(); break; 
         case -681: o = new System.Windows.Media.TransformConverter(); break;
         case -692: o = new System.Windows.Markup.TypeTypeConverter(); break; 
         case -696: o = new System.ComponentModel.UInt16Converter(); break; 
         case -698: o = new System.ComponentModel.UInt32Converter(); break;
         case -700: o = new System.ComponentModel.UInt64Converter(); break; 
         case -701: o = new System.Windows.Media.Converters.UShortIListConverter(); break;
         case -705: o = new System.UriTypeConverter(); break;
         case -714: o = new System.Windows.Media.Media3D.Vector3DCollectionConverter(); break;
         case -715: o = new System.Windows.Media.Media3D.Vector3DConverter(); break; 
         case -722: o = new System.Windows.Media.VectorCollectionConverter(); break;
         case -723: o = new System.Windows.VectorConverter(); break; 
         case -757: o = new System.Windows.Markup.XmlLanguageConverter(); break; 
     }
     return o; 
 }
예제 #5
0
        // This method performs the Point operations
        public void PerformOperation(object sender, RoutedEventArgs e)
        {
            RadioButton li = (sender as RadioButton);

            // Strings used to display the results
            String syntaxString, resultType, operationString;

            // The local variables point1, point2, vector2, etc are defined in each
            // case block for readability reasons. Each variable is contained within
            // the scope of each case statement.
              switch (li.Name)
            {   //begin switch

                case "rb1":
                    {
                        // Converts a String to a Point using a PointConverter
                        // Returns a Point.

                        PointConverter pConverter = new PointConverter();
                        Point pointResult = new Point();
                        string string1 = "10,20";

                        pointResult = (Point)pConverter.ConvertFromString(string1);
                        // pointResult is equal to (10, 20)

                        // Displaying Results
                        syntaxString = "pointResult = (Point)pConverter1.ConvertFromString(string1);";
                        resultType = "Point";
                        operationString = "Converting a String to a Point";
                        ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb2":
                    {
                        // Converts a String to a Vector using a VectorConverter
                        // Returns a Vector.

                        VectorConverter vConverter = new VectorConverter();
                        Vector vectorResult = new Vector();
                        string string1 = "10,20";

                        vectorResult = (Vector)vConverter.ConvertFromString(string1);
                        // vectorResult is equal to (10, 20)

                        // Displaying Results
                        syntaxString = "vectorResult = (Vector)vConverter.ConvertFromString(string1);";
                        resultType = "Vector";
                        operationString = "Converting a String into a Vector";
                        ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb3":
                    {
                        // Converts a String to a Matrix using a MatrixConverter
                        // Returns a Matrix.

                        MatrixConverter mConverter = new MatrixConverter();
                        Matrix matrixResult = new Matrix();
                        string string2 = "10,20,30,40,50,60";

                        matrixResult = (Matrix)mConverter.ConvertFromString(string2);
                        // matrixResult is equal to (10, 20, 30, 40, 50, 60)

                        // Displaying Results
                        syntaxString = "matrixResult = (Vector)mConverter.ConvertFromString(string2);";
                        resultType = "Matrix";
                        operationString = "Converting a String into a Matrix";
                        ShowResults(matrixResult.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb4":
                    {
                        // Converts a String to a Point3D using a Point3DConverter
                        // Returns a Point3D.

                        Point3DConverter p3DConverter = new Point3DConverter();
                        Point3D point3DResult = new Point3D();
                        string string3 = "10,20,30";

                        point3DResult = (Point3D)p3DConverter.ConvertFromString(string3);
                        // point3DResult is equal to (10, 20, 30)

                        // Displaying Results
                        syntaxString = "point3DResult = (Point3D)p3DConverter.ConvertFromString(string3);";
                        resultType = "Point3D";
                        operationString = "Converting a String into a Point3D";
                        ShowResults(point3DResult.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb5":
                    {
                        // Converts a String to a Vector3D using a Vector3DConverter
                        // Returns a Vector3D.

                        Vector3DConverter v3DConverter = new Vector3DConverter();
                        Vector3D vector3DResult = new Vector3D();
                        string string3 = "10,20,30";

                        vector3DResult = (Vector3D)v3DConverter.ConvertFromString(string3);
                        // vector3DResult is equal to (10, 20, 30)

                        // Displaying Results
                        syntaxString = "vector3DResult = (Vector3D)v3DConverter.ConvertFromString(string3);";
                        resultType = "Vector3D";
                        operationString = "Converting a String into a Vector3D";
                        ShowResults(vector3DResult.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb6":
                    {
                        // Converts a String to a Size3D using a Size3DConverter
                        // Returns a Size3D.

                        Size3DConverter s3DConverter = new Size3DConverter();
                        Size3D size3DResult = new Size3D();
                        string string3 = "10,20,30";

                        size3DResult = (Size3D)s3DConverter.ConvertFromString(string3);
                        // size3DResult is equal to (10, 20, 30)

                        // Displaying Results
                        syntaxString = "size3DResult = (Size3D)v3DConverter.ConvertFromString(string3);";
                        resultType = "Size3D";
                        operationString = "Converting a String into a Size3D";
                        ShowResults(size3DResult.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb7":
                    {
                        // Converts a String to a Point4D using a Point4DConverter
                        // Returns a Point4D.

                        Point4DConverter p4DConverter = new Point4DConverter();
                        Point4D point4DResult = new Point4D();
                        string string4 = "10,20,30,40";

                        point4DResult = (Point4D)p4DConverter.ConvertFromString(string4);
                        // point4DResult is equal to (10, 20, 30)

                        // Displaying Results
                        syntaxString = "point4DResult = (Point4D)v3DConverter.ConvertFromString(string3);";
                        resultType = "Point4D";
                        operationString = "Converting a String into a Point4D";
                        ShowResults(point4DResult.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                    default:
                    break;

            } //end switch
        }
예제 #6
0
        internal static void SaveNoteLocation(PNote note, Point location)
        {
            try
            {
                note.NoteLocation = location;
                var factors = getRelationalFactors(note);
                note.XFactor = factors[0];
                note.YFactor = factors[1];

                if (note.FromDB)
                {
                    var pc = new PointConverter();
                    var sb = new StringBuilder();
                    sb.Append("UPDATE NOTES SET LOCATION = '");
                    sb.Append(pc.ConvertToString(null, PNStatic.CultureInvariant, note.NoteLocation));
                    sb.Append("', REL_X = ");
                    sb.Append(factors[0].ToString(PNStatic.CultureInvariant));
                    sb.Append(", REL_Y = ");
                    sb.Append(factors[1].ToString(PNStatic.CultureInvariant));
                    sb.Append(" WHERE ID = '");
                    sb.Append(note.ID);
                    sb.Append("'");
                    using (var oData = new SQLiteDataObject(PNData.ConnectionString))
                    {
                        oData.Execute(sb.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                PNStatic.LogException(ex);
            }
        }
예제 #7
0
        internal static bool SaveNewNote(PNote note)
        {
            try
            {
                var sb = new StringBuilder();
                note.DateSaved = DateTime.Now;

                sb.Append("INSERT INTO NOTES (ID, NAME, GROUP_ID, PREV_GROUP_ID, OPACITY, VISIBLE, FAVORITE, PROTECTED, COMPLETED, PRIORITY, PASSWORD_STRING, PINNED, TOPMOST, ROLLED, DOCK_STATUS, DOCK_ORDER, SEND_RECEIVE_STATUS, DATE_CREATED, DATE_SAVED, DATE_SENT, DATE_RECEIVED, DATE_DELETED, SIZE, LOCATION, EDIT_SIZE, REL_X, REL_Y, SENT_TO, RECEIVED_FROM, PIN_CLASS, PIN_TEXT, SCRAMBLED, RECEIVED_IP) VALUES('");
                sb.Append(note.ID);
                sb.Append("', '");
                sb.Append(note.Name.Replace("'", "''"));
                sb.Append("', ");
                sb.Append(note.GroupID);
                sb.Append(", ");
                sb.Append(note.GroupID);   //as prev png
                sb.Append(", ");
                sb.Append(note.Opacity.ToString(PNStatic.CultureInvariant));
                sb.Append(", ");
                sb.Append(Convert.ToInt32(note.Visible));
                sb.Append(", ");
                sb.Append(Convert.ToInt32(note.Favorite));
                sb.Append(", ");
                sb.Append(Convert.ToInt32(note.Protected));
                sb.Append(", ");
                sb.Append(Convert.ToInt32(note.Completed));
                sb.Append(", ");
                sb.Append(Convert.ToInt32(note.Priority));
                sb.Append(", '");
                sb.Append(note.PasswordString.Replace("'", "''"));
                sb.Append("', ");
                sb.Append(Convert.ToInt32(note.Pinned));
                sb.Append(", ");
                sb.Append(Convert.ToInt32(note.Topmost));
                sb.Append(", ");
                sb.Append(Convert.ToInt32(note.Rolled));
                sb.Append(", ");
                sb.Append(Convert.ToInt32(note.DockStatus));
                sb.Append(", ");
                sb.Append(Convert.ToInt32(note.DockOrder));
                sb.Append(", ");
                sb.Append(Convert.ToInt32(note.SentReceived));
                sb.Append(", '");
                sb.Append(note.DateCreated.ToString(PNStrings.DATE_TIME_FORMAT, PNStatic.CultureInvariant).Replace("'", "''"));
                sb.Append("', '");
                sb.Append(note.DateSaved.ToString(PNStrings.DATE_TIME_FORMAT, PNStatic.CultureInvariant).Replace("'", "''"));
                sb.Append("', '");
                sb.Append(note.DateSent.ToString(PNStrings.DATE_TIME_FORMAT, PNStatic.CultureInvariant).Replace("'", "''"));
                sb.Append("', '");
                sb.Append(note.DateReceived.ToString(PNStrings.DATE_TIME_FORMAT, PNStatic.CultureInvariant).Replace("'", "''"));
                sb.Append("', '");
                sb.Append(note.DateDeleted.ToString(PNStrings.DATE_TIME_FORMAT, PNStatic.CultureInvariant).Replace("'", "''"));
                sb.Append("', '");
                var sc = new SizeConverter();
                sb.Append(sc.ConvertToString(null, PNStatic.CultureInvariant, note.NoteSize));
                sb.Append("', '");
                var pc = new PointConverter();
                sb.Append(pc.ConvertToString(null, PNStatic.CultureInvariant, note.NoteLocation));
                sb.Append("', '");
                var scd = new System.Drawing.SizeConverter();
                sb.Append(scd.ConvertToString(null, PNStatic.CultureInvariant, note.EditSize));
                sb.Append("', ");
                var factors = getRelationalFactors(note);
                sb.Append(factors[0].ToString(PNStatic.CultureInvariant));
                sb.Append(", ");
                sb.Append(factors[1].ToString(PNStatic.CultureInvariant));
                sb.Append(", '");
                sb.Append(note.SentTo.Replace("'", "''"));
                sb.Append("', '");
                sb.Append(note.ReceivedFrom.Replace("'", "''"));
                sb.Append("', '");
                sb.Append(note.PinClass);
                sb.Append("', '");
                sb.Append(note.PinText);
                sb.Append("', ");
                sb.Append(Convert.ToInt32(note.Scrambled));
                sb.Append(", '");
                sb.Append(note.ReceivedIp);
                sb.Append("'");
                sb.Append(")");
                using (var oData = new SQLiteDataObject(PNData.ConnectionString))
                {
                    oData.Execute(sb.ToString());
                }
                note.FromDB = true;
                if (note.Skinless != null)
                {
                    SaveNoteSkinless(note);
                }
                return true;
            }
            catch (Exception ex)
            {
                PNStatic.LogException(ex);
                return false;
            }
        }
예제 #8
0
        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;
            }
        }
예제 #9
0
        internal static void SaveCPProperties()
        {
            try
            {
                var crc = new ColorConverter();
                var sb = new StringBuilder();
                var sc = new SizeConverter();
                var pc = new PointConverter();

                var pcf = PNStatic.Settings.Config;
                sb.Append("UPDATE CONFIG SET CP_LAST_GROUP = ");
                sb.Append(pcf.CPLastGroup);
                sb.Append(",CP_PVW_COLOR = '");
                sb.Append(crc.ConvertToString(null, PNStatic.CultureInvariant, pcf.CPPvwColor));
                sb.Append("',CP_USE_CUST_PVW_COLOR = ");
                sb.Append(Convert.ToInt32(pcf.CPUseCustPvwColor));
                sb.Append(",CP_SIZE = '");
                sb.Append(sc.ConvertToString(null, PNStatic.CultureInvariant, pcf.CPSize));
                sb.Append("',CP_LOCATION = '");
                sb.Append(pc.ConvertToString(null, PNStatic.CultureInvariant, pcf.CPLocation));
                sb.Append("',CP_PVW_RIGHT = ");
                sb.Append(Convert.ToInt32(pcf.CPPvwRight));
                sb.Append(",CP_PVW_SHOW = ");
                sb.Append(Convert.ToInt32(pcf.CPPvwShow));
                sb.Append(",CP_GROUPS_SHOW = ");
                sb.Append(Convert.ToInt32(pcf.CPGroupsShow));
                ExecuteTransactionForStringBuilder(sb, SettingsConnectionString);
            }
            catch (Exception ex)
            {
                PNStatic.LogException(ex);
            }
        }
예제 #10
0
        internal static void LoadDBSettings()
        {
            try
            {
                var mediaConverter = new ColorConverter();
                var drawingConverter = new System.Drawing.ColorConverter();
                var sc = new SizeConverter();
                var pc = new PointConverter();
                var wpfc = new WPFFontConverter();
                //var fc = new FontConverter();
                var v = Assembly.GetExecutingAssembly().GetName().Version;
                PNStatic.Settings = new PNSettings();
                SettingsConnectionString = SQLiteDataObject.CheckAndCreateDatabase(PNPaths.Instance.SettingsDBPath);
                using (var oData = new SQLiteDataObject(SettingsConnectionString))
                {
                    string sqlQuery;
                    //config
                    var pnc = PNStatic.Settings.Config;
                    if (!oData.TableExists("CONFIG"))
                    {
                        sqlQuery = "CREATE TABLE [CONFIG] ([LAST_PAGE] TEXT, [EXIT_FLAG] INT, [CP_LAST_GROUP] INT, [SKINNABLE] BOOLEAN, [CP_PVW_COLOR] TEXT, [CP_USE_CUST_PVW_COLOR] BOOLEAN, [CP_SIZE] TEXT, [CP_LOCATION] TEXT, [CONTROLS_STYLE] TEXT, [CP_PVW_RIGHT] BOOLEAN, [UI_FONT] TEXT, [PROGRAM_VERSION] TEXT, [CP_PVW_SHOW] BOOLEAN, [CP_GROUPS_SHOW] BOOLEAN, [NOTES_WITH_SHORTCUTS] TEXT, [SEARCH_NOTES_SETT] TEXT)";
                        oData.Execute(sqlQuery);
                        sqlQuery =
                            "INSERT INTO CONFIG VALUES(NULL, -1, NULL, NULL, NULL, NULL, '1000,600', NULL, NULL, NULL, NULL, '" +
                            v.ToString(3) + "', NULL, NULL, NULL, NULL)";
                        oData.Execute(sqlQuery);
                        PNSingleton.Instance.FontUser = new PNFont();
                        pnc.CPSize = new Size(1000, 600);
                    }
                    else
                    {
                        using (var t = oData.GetSchema("Columns"))
                        {
                            var rows = t.Select("COLUMN_NAME = 'PROGRAM_VERSION' AND TABLE_NAME = 'CONFIG'");
                            if (rows.Length == 0)
                            {
                                PNSingleton.Instance.PlatformChanged = true;
                                sqlQuery = "ALTER TABLE CONFIG ADD COLUMN [PROGRAM_VERSION] TEXT";
                                oData.Execute(sqlQuery);
                                //save previous edition files
                                PNStatic.SpTextProvider.SplashText = PNLang.Instance.GetMessageText("back_prev",
                                    "Backing up files from previous edition...");
                                savePreviousFiles();
                            }
                            rows = t.Select("COLUMN_NAME = 'CP_PVW_RIGHT' AND TABLE_NAME = 'CONFIG'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE CONFIG ADD COLUMN [CP_PVW_RIGHT] BOOLEAN";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'CP_PVW_SHOW' AND TABLE_NAME = 'CONFIG'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE CONFIG ADD COLUMN [CP_PVW_SHOW] BOOLEAN";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'CP_GROUPS_SHOW' AND TABLE_NAME = 'CONFIG'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE CONFIG ADD COLUMN [CP_GROUPS_SHOW] BOOLEAN";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'UI_FONT' AND TABLE_NAME = 'CONFIG'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE CONFIG ADD COLUMN [UI_FONT] TEXT";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'NOTES_WITH_SHORTCUTS' AND TABLE_NAME = 'CONFIG'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE CONFIG ADD COLUMN [NOTES_WITH_SHORTCUTS] TEXT";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'SEARCH_NOTES_SETT' AND TABLE_NAME = 'CONFIG'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE CONFIG ADD COLUMN [SEARCH_NOTES_SETT] TEXT";
                                oData.Execute(sqlQuery);
                            }
                        }
                        //store version
                        sqlQuery = "UPDATE CONFIG SET PROGRAM_VERSION = '" + v.ToString(3) + "'";
                        oData.Execute(sqlQuery);
                        //upgrade colors an fonts
                        if (PNSingleton.Instance.PlatformChanged)
                        {
                            var obj = oData.GetScalar("SELECT CP_PVW_COLOR FROM CONFIG");
                            if (obj != null && !IsDBNull(obj))
                            {
                                obj = drawingConverter.ConvertFromString(null, PNStatic.CultureInvariant, (string)obj);
                                if (obj != null)
                                {
                                    var clrD = (System.Drawing.Color)obj;
                                    var clrM = Color.FromArgb(clrD.A, clrD.R, clrD.G, clrD.B);
                                    var clrText = mediaConverter.ConvertToString(clrM);
                                    oData.Execute("UPDATE CONFIG SET CP_PVW_COLOR = '" + clrText + "'");
                                }
                            }
                            obj = oData.GetScalar("SELECT UI_FONT FROM CONFIG");
                            if (obj != null && !IsDBNull(obj))
                            {
                                var pnFonf = PNStatic.FromDrawingFont((string)obj);
                                var fontText = wpfc.ConvertToString(pnFonf);
                                oData.Execute("UPDATE CONFIG SET UI_FONT = '" + fontText + "'");
                            }
                        }
                        sqlQuery = "SELECT * FROM CONFIG";
                        using (var t = oData.FillDataTable(sqlQuery))
                        {
                            if (t.Rows.Count > 0)
                            {
                                var r = t.Rows[0];
                                if (!IsDBNull(r["LAST_PAGE"]))
                                {
                                    pnc.LastPage = Convert.ToInt32(r["LAST_PAGE"]);
                                }

                                if (!IsDBNull(r["EXIT_FLAG"]))
                                {
                                    pnc.ExitFlag = (int)r["EXIT_FLAG"];
                                }
                                if (!IsDBNull(r["CP_LAST_GROUP"]))
                                {
                                    pnc.CPLastGroup = (int)r["CP_LAST_GROUP"];
                                }
                                if (!IsDBNull(r["SKINNABLE"]))
                                {
                                    pnc.Skinnable = Convert.ToBoolean(r["SKINNABLE"]);
                                }
                                if (!IsDBNull(r["CP_PVW_COLOR"]))
                                {
                                    var convertFromString = mediaConverter.ConvertFromString(null, PNStatic.CultureInvariant, (string)r["CP_PVW_COLOR"]);
                                    if (
                                        convertFromString != null)
                                        pnc.CPPvwColor = (Color)convertFromString;
                                }
                                if (!IsDBNull(r["CP_USE_CUST_PVW_COLOR"]))
                                {
                                    pnc.CPUseCustPvwColor = Convert.ToBoolean(r["CP_USE_CUST_PVW_COLOR"]);
                                }
                                if (!IsDBNull(r["CP_SIZE"]))
                                {
                                    var str = Convert.ToString(r["CP_LOCATION"]);
                                    if (!str.Contains('-'))
                                    {
                                        str = Convert.ToString(r["CP_SIZE"]);
                                        var convertFromString = sc.ConvertFromString(null, PNStatic.CultureInvariant,
                                            str);
                                        if (convertFromString != null)
                                            pnc.CPSize = (Size)convertFromString;
                                    }
                                }
                                if (!IsDBNull(r["CP_LOCATION"]))
                                {
                                    var convertFromString = pc.ConvertFromString(null, PNStatic.CultureInvariant, (string)r["CP_LOCATION"]);
                                    if (
                                        convertFromString != null)
                                        pnc.CPLocation = (Point)convertFromString;
                                }
                                if (!IsDBNull(r["CONTROLS_STYLE"]))
                                {
                                    pnc.ControlsStyle = (string)r["CONTROLS_STYLE"];
                                }
                                if (!IsDBNull(r["CP_PVW_RIGHT"]))
                                {
                                    pnc.CPPvwRight = Convert.ToBoolean(r["CP_PVW_RIGHT"]);
                                }
                                if (!IsDBNull(r["CP_PVW_SHOW"]))
                                {
                                    pnc.CPPvwShow = Convert.ToBoolean(r["CP_PVW_SHOW"]);
                                }
                                if (!IsDBNull(r["CP_GROUPS_SHOW"]))
                                {
                                    pnc.CPGroupsShow = Convert.ToBoolean(r["CP_GROUPS_SHOW"]);
                                }
                                if (!IsDBNull(r["UI_FONT"]))
                                {
                                    var temp = (string)(r["UI_FONT"]);
                                    if (temp != "")
                                    {
                                        PNSingleton.Instance.FontUser = (PNFont)wpfc.ConvertFromString(temp);
                                    }
                                    else
                                    {
                                        PNSingleton.Instance.FontUser = new PNFont();
                                    }
                                }
                                else
                                {
                                    PNSingleton.Instance.FontUser = new PNFont();
                                }
                                if (!IsDBNull(r["SEARCH_NOTES_SETT"]))
                                {
                                    var arr = Convert.ToString(r["SEARCH_NOTES_SETT"]).Split('|');
                                    pnc.SearchNotesSettings.WholewWord = Convert.ToBoolean(arr[0]);
                                    pnc.SearchNotesSettings.MatchCase = Convert.ToBoolean(arr[1]);
                                    pnc.SearchNotesSettings.IncludeHidden = Convert.ToBoolean(arr[2]);
                                    pnc.SearchNotesSettings.Criteria = Convert.ToInt32(arr[3]);
                                    pnc.SearchNotesSettings.Scope = Convert.ToInt32(arr[4]);
                                }
                                SaveExitFlag(-1);
                            }
                            else
                            {
                                sqlQuery =
                                    "INSERT INTO CONFIG VALUES(NULL, -1, NULL, NULL, NULL, NULL, '1000,600', NULL, NULL, NULL, NULL, '" +
                                    v.ToString(3) + "', NULL, NULL, NULL, NULL)";
                                oData.Execute(sqlQuery);
                                PNSingleton.Instance.FontUser = new PNFont();
                                pnc.CPSize = new Size(1000, 600);
                            }
                        }
                    }

                    //general setting
                    var pngeneral = PNStatic.Settings.GeneralSettings;
                    if (!oData.TableExists("GENERAL_SETTINGS"))
                    {
                        sqlQuery = "CREATE TABLE [GENERAL_SETTINGS] ([LANGUAGE] TEXT, [RUN_ON_START] BOOLEAN, [SHOW_CP_ON_START] BOOLEAN, [CHECK_NEW_VERSION_ON_START] BOOLEAN, [HIDE_TOOLBAR] BOOLEAN, [USE_CUSTOM_FONTS] BOOLEAN, [SHOW_SCROLLBAR] BOOLEAN, [HIDE_DELETE_BUTTON] BOOLEAN, [CHANGE_HIDE_TO_DELETE] BOOLEAN, [HIDE_HIDE_BUTTON] BOOLEAN, [BULLETS_INDENT] INT, [MARGIN_WIDTH] INT, [SAVE_ON_EXIT] BOOLEAN, [CONFIRM_SAVING] BOOLEAN, [CONFIRM_BEFORE_DELETION] BOOLEAN, [SAVE_WITHOUT_CONFIRM_ON_HIDE] BOOLEAN, [WARN_ON_AUTOMATICAL_DELETE] BOOLEAN, [AUTO_SAVE] BOOLEAN, [AUTO_SAVE_PERIOD] INT, [REMOVE_FROM_BIN_PERIOD] INT, [DATE_FORMAT] TEXT, [TIME_FORMAT] TEXT, [SKINLESS_WIDTH] INT, [SKINLESS_HEIGHT] INT, [SPELL_COLOR] TEXT, [USE_SKINS] BOOLEAN, [SPELL_MODE] INT, [SPELL_DICT] TEXT, [DOCK_WIDTH] INT, [DOCK_HEIGHT] INT, [SHOW_PRIORITY_ON_START] BOOLEAN, [BUTTONS_SIZE] INT, [AUTOMATIC_SMILIES] BOOLEAN, [SPACE_POINTS] INT, [RESTORE_AUTO] BOOLEAN, [PARAGRAPH_INDENT] INT, [AUTO_HEIGHT] BOOLEAN, [CRITICAL_ON_START] BOOLEAN, [CRITICAL_PERIODICALLY] BOOLEAN, [DELETE_SHORTCUTS_ON_EXIT] BOOLEAN, [RESTORE_SHORTCUTS_ON_START] BOOLEAN, [CLOSE_ON_SHORTCUT] BOOLEAN)";
                        oData.Execute(sqlQuery);
                        sqlQuery = "INSERT INTO GENERAL_SETTINGS VALUES(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)";
                        oData.Execute(sqlQuery);
                        //store default english language
                        var langPath = Path.Combine(PNPaths.Instance.LangDir, pngeneral.Language);
                        PNLang.Instance.LoadLanguage(langPath);
                    }
                    else
                    {
                        using (var t = oData.GetSchema("Columns"))
                        {
                            var rows = t.Select("COLUMN_NAME = 'BUTTONS_SIZE' AND TABLE_NAME = 'GENERAL_SETTINGS'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE GENERAL_SETTINGS ADD COLUMN [BUTTONS_SIZE] INT";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'AUTOMATIC_SMILIES' AND TABLE_NAME = 'GENERAL_SETTINGS'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE GENERAL_SETTINGS ADD COLUMN [AUTOMATIC_SMILIES] BOOLEAN";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'SPACE_POINTS' AND TABLE_NAME = 'GENERAL_SETTINGS'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE GENERAL_SETTINGS ADD COLUMN [SPACE_POINTS] INT";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'RESTORE_AUTO' AND TABLE_NAME = 'GENERAL_SETTINGS'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE GENERAL_SETTINGS ADD COLUMN [RESTORE_AUTO] BOOLEAN";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'PARAGRAPH_INDENT' AND TABLE_NAME = 'GENERAL_SETTINGS'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE GENERAL_SETTINGS ADD COLUMN [PARAGRAPH_INDENT] INT";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'AUTO_HEIGHT' AND TABLE_NAME = 'GENERAL_SETTINGS'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE GENERAL_SETTINGS ADD COLUMN [AUTO_HEIGHT] BOOLEAN";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'CRITICAL_ON_START' AND TABLE_NAME = 'GENERAL_SETTINGS'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE GENERAL_SETTINGS ADD COLUMN [CRITICAL_ON_START] BOOLEAN";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'CRITICAL_PERIODICALLY' AND TABLE_NAME = 'GENERAL_SETTINGS'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE GENERAL_SETTINGS ADD COLUMN [CRITICAL_PERIODICALLY] BOOLEAN";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'DELETE_SHORTCUTS_ON_EXIT' AND TABLE_NAME = 'GENERAL_SETTINGS'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE GENERAL_SETTINGS ADD COLUMN [DELETE_SHORTCUTS_ON_EXIT] BOOLEAN";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'RESTORE_SHORTCUTS_ON_START' AND TABLE_NAME = 'GENERAL_SETTINGS'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE GENERAL_SETTINGS ADD COLUMN [RESTORE_SHORTCUTS_ON_START] BOOLEAN";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'CLOSE_ON_SHORTCUT' AND TABLE_NAME = 'GENERAL_SETTINGS'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE GENERAL_SETTINGS ADD COLUMN [CLOSE_ON_SHORTCUT] BOOLEAN";
                                oData.Execute(sqlQuery);
                            }
                        }
                        sqlQuery = "SELECT * FROM GENERAL_SETTINGS";
                        using (var t = oData.FillDataTable(sqlQuery))
                        {
                            if (t.Rows.Count > 0)
                            {
                                var r = t.Rows[0];
                                if (!IsDBNull(r["LANGUAGE"]))
                                {
                                    pngeneral.Language = (string) r["LANGUAGE"];
                                }
                                var langPath = Path.Combine(PNPaths.Instance.LangDir, pngeneral.Language);
                                PNLang.Instance.LoadLanguage(langPath);
                                if (!IsDBNull(r["RUN_ON_START"]))
                                {
                                    pngeneral.RunOnStart = (bool)r["RUN_ON_START"];
                                }
                                if (!IsDBNull(r["HIDE_TOOLBAR"]))
                                {
                                    pngeneral.HideToolbar = (bool)r["HIDE_TOOLBAR"];
                                }
                                if (!IsDBNull(r["SHOW_CP_ON_START"]))
                                {
                                    pngeneral.ShowCPOnStart = (bool)r["SHOW_CP_ON_START"];
                                }
                                if (!IsDBNull(r["CHECK_NEW_VERSION_ON_START"]))
                                {
                                    pngeneral.CheckNewVersionOnStart = (bool)r["CHECK_NEW_VERSION_ON_START"];
                                }
                                if (!IsDBNull(r["USE_CUSTOM_FONTS"]))
                                {
                                    pngeneral.UseCustomFonts = (bool)r["USE_CUSTOM_FONTS"];
                                }
                                if (!IsDBNull(r["SHOW_SCROLLBAR"]))
                                {
                                        pngeneral.ShowScrollbar =
                                            (System.Windows.Forms.RichTextBoxScrollBars)
                                                Convert.ToInt32(r["SHOW_SCROLLBAR"]);
                                }
                                if (!IsDBNull(r["HIDE_DELETE_BUTTON"]))
                                {
                                    pngeneral.HideDeleteButton = (bool)r["HIDE_DELETE_BUTTON"];
                                }
                                if (!IsDBNull(r["CHANGE_HIDE_TO_DELETE"]))
                                {
                                    pngeneral.ChangeHideToDelete = (bool)r["CHANGE_HIDE_TO_DELETE"];
                                }
                                if (!IsDBNull(r["HIDE_HIDE_BUTTON"]))
                                {
                                    pngeneral.HideHideButton = (bool)r["HIDE_HIDE_BUTTON"];
                                }
                                if (!IsDBNull(r["BULLETS_INDENT"]))
                                {
                                    pngeneral.BulletsIndent = (short)(int)r["BULLETS_INDENT"];
                                }
                                if (!IsDBNull(r["MARGIN_WIDTH"]))
                                {
                                    pngeneral.MarginWidth = (short)(int)r["MARGIN_WIDTH"];
                                }
                                if (!IsDBNull(r["DATE_FORMAT"]))
                                {
                                    pngeneral.DateFormat =
                                        ((string)r["DATE_FORMAT"]).Replace("H", "")
                                            .Replace("h", "")
                                            .Replace("m", "")
                                            .Replace(":", "")
                                            .Trim();
                                    Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern = pngeneral.DateFormat;
                                }
                                if (!IsDBNull(r["TIME_FORMAT"]))
                                {
                                    pngeneral.TimeFormat = (string)r["TIME_FORMAT"];
                                    Thread.CurrentThread.CurrentCulture.DateTimeFormat.LongTimePattern = pngeneral.TimeFormat;
                                }
                                if (!IsDBNull(r["SAVE_ON_EXIT"]))
                                {
                                    pngeneral.SaveOnExit = (bool)r["SAVE_ON_EXIT"];
                                }
                                if (!IsDBNull(r["CONFIRM_SAVING"]))
                                {
                                    pngeneral.ConfirmSaving = (bool)r["CONFIRM_SAVING"];
                                }
                                if (!IsDBNull(r["CONFIRM_BEFORE_DELETION"]))
                                {
                                    pngeneral.ConfirmBeforeDeletion = (bool)r["CONFIRM_BEFORE_DELETION"];
                                }
                                if (!IsDBNull(r["SAVE_WITHOUT_CONFIRM_ON_HIDE"]))
                                {
                                    pngeneral.SaveWithoutConfirmOnHide = (bool)r["SAVE_WITHOUT_CONFIRM_ON_HIDE"];
                                }
                                if (!IsDBNull(r["WARN_ON_AUTOMATICAL_DELETE"]))
                                {
                                    pngeneral.WarnOnAutomaticalDelete = (bool)r["WARN_ON_AUTOMATICAL_DELETE"];
                                }
                                if (!IsDBNull(r["REMOVE_FROM_BIN_PERIOD"]))
                                {
                                    pngeneral.RemoveFromBinPeriod = (int)r["REMOVE_FROM_BIN_PERIOD"];
                                }
                                if (!IsDBNull(r["AUTO_SAVE"]))
                                {
                                    pngeneral.Autosave = (bool)r["AUTO_SAVE"];
                                }
                                if (!IsDBNull(r["AUTO_SAVE_PERIOD"]))
                                {
                                    pngeneral.AutosavePeriod = (int)r["AUTO_SAVE_PERIOD"];
                                }
                                if (!IsDBNull(r["SKINLESS_WIDTH"]))
                                {
                                    pngeneral.Width = (int)r["SKINLESS_WIDTH"];
                                }
                                if (!IsDBNull(r["SKINLESS_HEIGHT"]))
                                {
                                    pngeneral.Height = (int)r["SKINLESS_HEIGHT"];
                                }
                                if (!IsDBNull(r["SPELL_COLOR"]))
                                {
                                    pngeneral.SpellColor = (System.Drawing.Color)
                                            drawingConverter.ConvertFromString(null, PNStatic.CultureInvariant,
                                                (string)r["SPELL_COLOR"]);
                                }
                                if (!IsDBNull(r["USE_SKINS"]))
                                {
                                    pngeneral.UseSkins = (bool)r["USE_SKINS"];
                                }
                                if (!IsDBNull(r["SPELL_MODE"]))
                                {
                                    pngeneral.SpellMode = (int)r["SPELL_MODE"];
                                }
                                if (!IsDBNull(r["SPELL_DICT"]))
                                {
                                    pngeneral.SpellDict = (string)r["SPELL_DICT"];
                                }
                                if (!IsDBNull(r["DOCK_WIDTH"]))
                                {
                                    pngeneral.DockWidth = (int)r["DOCK_WIDTH"];
                                }
                                if (!IsDBNull(r["DOCK_HEIGHT"]))
                                {
                                    pngeneral.DockHeight = (int)r["DOCK_HEIGHT"];
                                }
                                if (!IsDBNull(r["SHOW_PRIORITY_ON_START"]))
                                {
                                    pngeneral.ShowPriorityOnStart = (bool)r["SHOW_PRIORITY_ON_START"];
                                }
                                if (!IsDBNull(r["BUTTONS_SIZE"]))
                                {
                                    pngeneral.ButtonsSize = (ToolStripButtonSize)((int)r["BUTTONS_SIZE"]);
                                }
                                if (!IsDBNull(r["AUTOMATIC_SMILIES"]))
                                {
                                    pngeneral.AutomaticSmilies = (bool)r["AUTOMATIC_SMILIES"];
                                }
                                if (!IsDBNull(r["SPACE_POINTS"]))
                                {
                                    pngeneral.SpacePoints = (int)r["SPACE_POINTS"];
                                }
                                if (!IsDBNull(r["RESTORE_AUTO"]))
                                {
                                    pngeneral.RestoreAuto = (bool)r["RESTORE_AUTO"];
                                }
                                if (!IsDBNull(r["PARAGRAPH_INDENT"]))
                                {
                                    pngeneral.ParagraphIndent = (int)r["PARAGRAPH_INDENT"];
                                }
                                if (!IsDBNull(r["AUTO_HEIGHT"]))
                                {
                                    pngeneral.AutoHeight = (bool)r["AUTO_HEIGHT"];
                                }
                                if (!IsDBNull(r["CRITICAL_ON_START"]))
                                {
                                    pngeneral.CheckCriticalOnStart = (bool)r["CRITICAL_ON_START"];
                                }
                                if (!IsDBNull(r["CRITICAL_PERIODICALLY"]))
                                {
                                    pngeneral.CheckCriticalPeriodically = (bool)r["CRITICAL_PERIODICALLY"];
                                }
                                if (!IsDBNull(r["DELETE_SHORTCUTS_ON_EXIT"]))
                                {
                                    pngeneral.DeleteShortcutsOnExit = (bool)r["DELETE_SHORTCUTS_ON_EXIT"];
                                }
                                if (!IsDBNull(r["RESTORE_SHORTCUTS_ON_START"]))
                                {
                                    pngeneral.RestoreShortcutsOnStart = (bool)r["RESTORE_SHORTCUTS_ON_START"];
                                }
                                if (!IsDBNull(r["CLOSE_ON_SHORTCUT"]))
                                {
                                    pngeneral.CloseOnShortcut = (bool)r["CLOSE_ON_SHORTCUT"];
                                }
                            }
                            else
                            {
                                sqlQuery = "INSERT INTO GENERAL_SETTINGS VALUES(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)";
                                oData.Execute(sqlQuery);
                            }
                        }
                    }

                    PNStatic.SpTextProvider.SplashText = PNLang.Instance.GetMessageText("load_program_settings", "Loading program settings");

                    //schedule
                    if (!oData.TableExists("SCHEDULE"))
                    {
                        sqlQuery = "CREATE TABLE [SCHEDULE] ([SOUND] TEXT, [DATE_FORMAT] TEXT, [TIME_FORMAT] TEXT, [VOICE] TEXT, [ALLOW_SOUND] BOOLEAN, [TRACK_OVERDUE] BOOLEAN, [VISUAL_NOTIFY] BOOLEAN, [CENTER_SCREEN] BOOLEAN, [VOICE_VOLUME] INT, [VOICE_SPEED] INT, [VOICE_PITCH] INT)";
                        oData.Execute(sqlQuery);
                        sqlQuery = "INSERT INTO SCHEDULE VALUES(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)";
                        oData.Execute(sqlQuery);
                    }
                    else
                    {
                        sqlQuery = "SELECT * FROM SCHEDULE";
                        using (var t = oData.FillDataTable(sqlQuery))
                        {
                            if (t.Rows.Count > 0)
                            {
                                var r = t.Rows[0];
                                var pnsc = PNStatic.Settings.Schedule;
                                if (!IsDBNull(r["SOUND"]))
                                {
                                    pnsc.Sound = (string)r["SOUND"];
                                }
                                if (!IsDBNull(r["VOICE"]))
                                {
                                    pnsc.Voice = (string)r["VOICE"];
                                }
                                if (!IsDBNull(r["ALLOW_SOUND"]))
                                {
                                    pnsc.AllowSoundAlert = (bool)r["ALLOW_SOUND"];
                                }
                                if (!IsDBNull(r["TRACK_OVERDUE"]))
                                {
                                    pnsc.TrackOverdue = (bool)r["TRACK_OVERDUE"];
                                }
                                if (!IsDBNull(r["VISUAL_NOTIFY"]))
                                {
                                    pnsc.VisualNotification = (bool)r["VISUAL_NOTIFY"];
                                }
                                if (!IsDBNull(r["CENTER_SCREEN"]))
                                {
                                    pnsc.CenterScreen = (bool)r["CENTER_SCREEN"];
                                }
                                if (!IsDBNull(r["VOICE_VOLUME"]))
                                {
                                    pnsc.VoiceVolume = (int)r["VOICE_VOLUME"];
                                }
                                if (!IsDBNull(r["VOICE_SPEED"]))
                                {
                                    pnsc.VoiceSpeed = (int)r["VOICE_SPEED"];
                                }
                                if (!IsDBNull(r["VOICE_PITCH"]))
                                {
                                    pnsc.VoicePitch = (int)r["VOICE_PITCH"];
                                }
                            }
                            else
                            {
                                sqlQuery = "INSERT INTO SCHEDULE VALUES(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)";
                                oData.Execute(sqlQuery);
                            }
                        }
                    }
                    //behavior
                    if (!oData.TableExists("BEHAVIOR"))
                    {
                        sqlQuery = "CREATE TABLE [BEHAVIOR] ([NEW_ALWAYS_ON_TOP] BOOLEAN, [RELATIONAL_POSITION] BOOLEAN, [HIDE_COMPLETED] BOOLEAN, [BIG_ICONS_ON_CP] BOOLEAN, [DO_NOT_SHOW_IN_LIST] BOOLEAN, [KEEP_VISIBLE_ON_SHOW_DESKTOP] BOOLEAN, [DBL_CLICK_ACTION] INT, [SINGLE_CLICK_ACTION] INT, [DEFAULT_NAMING] INT, [DEFAULT_NAME_LENGHT] INT, [CONTENT_COLUMN_LENGTH] INT, [HIDE_FLUENTLY] BOOLEAN, [PLAY_SOUND_ON_HIDE] BOOLEAN, [OPACITY] REAL, [RANDOM_COLOR] BOOLEAN, [INVERT_TEXT_COLOR] BOOLEAN, [ROLL_ON_DBLCLICK] BOOLEAN, [FIT_WHEN_ROLLED] BOOLEAN, [SHOW_SEPARATE_NOTES] BOOLEAN, [PIN_CLICK_ACTION] INT, [NOTE_START_POSITION] INT, [HIDE_MAIN_WINDOW] BOOLEAN, [THEME] TEXT, [PREVENT_RESIZING] BOOLEAN, [SHOW_PANEL] BOOLEAN, [PANEL_DOCK] INT, [PANEL_AUTO_HIDE] BOOLEAN, [PANEL_REMOVE_MODE] INT, [PANEL_SWITCH_OFF_ANIMATION] BOOLEAN, [PANEL_ENTER_DELAY] INT)";
                        oData.Execute(sqlQuery);
                        sqlQuery = "INSERT INTO BEHAVIOR VALUES(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)";
                        oData.Execute(sqlQuery);
                    }
                    else
                    {
                        using (var t = oData.GetSchema("Columns"))
                        {
                            var rows = t.Select("COLUMN_NAME = 'NOTE_START_POSITION' AND TABLE_NAME = 'BEHAVIOR'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE BEHAVIOR ADD COLUMN [NOTE_START_POSITION] INT";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'HIDE_MAIN_WINDOW' AND TABLE_NAME = 'BEHAVIOR'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE BEHAVIOR ADD COLUMN [HIDE_MAIN_WINDOW] BOOLEAN";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'THEME' AND TABLE_NAME = 'BEHAVIOR'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE BEHAVIOR ADD COLUMN [THEME] TEXT";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'PREVENT_RESIZING' AND TABLE_NAME = 'BEHAVIOR'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE BEHAVIOR ADD COLUMN [PREVENT_RESIZING] BOOLEAN";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'SHOW_PANEL' AND TABLE_NAME = 'BEHAVIOR'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE BEHAVIOR ADD COLUMN [SHOW_PANEL] BOOLEAN";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'PANEL_DOCK' AND TABLE_NAME = 'BEHAVIOR'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE BEHAVIOR ADD COLUMN [PANEL_DOCK] INT";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'PANEL_AUTO_HIDE' AND TABLE_NAME = 'BEHAVIOR'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE BEHAVIOR ADD COLUMN [PANEL_AUTO_HIDE] BOOLEAN";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'PANEL_REMOVE_MODE' AND TABLE_NAME = 'BEHAVIOR'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE BEHAVIOR ADD COLUMN [PANEL_REMOVE_MODE] INT";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'PANEL_SWITCH_OFF_ANIMATION' AND TABLE_NAME = 'BEHAVIOR'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE BEHAVIOR ADD COLUMN [PANEL_SWITCH_OFF_ANIMATION] BOOLEAN";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'PANEL_ENTER_DELAY' AND TABLE_NAME = 'BEHAVIOR'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE BEHAVIOR ADD COLUMN [PANEL_ENTER_DELAY] INT";
                                oData.Execute(sqlQuery);
                            }
                        }
                        sqlQuery = "SELECT * FROM BEHAVIOR";
                        using (var t = oData.FillDataTable(sqlQuery))
                        {
                            if (t.Rows.Count > 0)
                            {
                                var r = t.Rows[0];
                                var pnb = PNStatic.Settings.Behavior;
                                if (!IsDBNull(r["NEW_ALWAYS_ON_TOP"]))
                                {
                                    pnb.NewNoteAlwaysOnTop = (bool)r["NEW_ALWAYS_ON_TOP"];
                                }
                                if (!IsDBNull(r["RELATIONAL_POSITION"]))
                                {
                                    pnb.RelationalPositioning = (bool)r["RELATIONAL_POSITION"];
                                }
                                if (!IsDBNull(r["HIDE_COMPLETED"]))
                                {
                                    pnb.HideCompleted = (bool)r["HIDE_COMPLETED"];
                                }
                                if (!IsDBNull(r["BIG_ICONS_ON_CP"]))
                                {
                                    pnb.BigIconsOnCP = (bool)r["BIG_ICONS_ON_CP"];
                                }
                                if (!IsDBNull(r["DO_NOT_SHOW_IN_LIST"]))
                                {
                                    pnb.DoNotShowNotesInList = (bool)r["DO_NOT_SHOW_IN_LIST"];
                                }
                                if (!IsDBNull(r["KEEP_VISIBLE_ON_SHOW_DESKTOP"]))
                                {
                                    pnb.KeepVisibleOnShowDesktop = (bool)r["KEEP_VISIBLE_ON_SHOW_DESKTOP"];
                                }
                                if (!IsDBNull(r["DBL_CLICK_ACTION"]))
                                {
                                    var index = (int) r["DBL_CLICK_ACTION"];
                                    if (index < Enum.GetValues(typeof (TrayMouseAction)).Length)
                                        pnb.DoubleClickAction = (TrayMouseAction) index;
                                }
                                if (!IsDBNull(r["SINGLE_CLICK_ACTION"]))
                                {
                                    var index = (int)r["SINGLE_CLICK_ACTION"];
                                    if (index < Enum.GetValues(typeof (TrayMouseAction)).Length)
                                        pnb.SingleClickAction = (TrayMouseAction) index;
                                }
                                if (!IsDBNull(r["DEFAULT_NAMING"]))
                                {
                                    var index = (int)r["DEFAULT_NAMING"];
                                    if (index < Enum.GetValues(typeof(DefaultNaming)).Length)
                                        pnb.DefaultNaming = (DefaultNaming)index;
                                }
                                if (!IsDBNull(r["DEFAULT_NAME_LENGHT"]))
                                {
                                    pnb.DefaultNameLength = (int)r["DEFAULT_NAME_LENGHT"];
                                }
                                if (!IsDBNull(r["CONTENT_COLUMN_LENGTH"]))
                                {
                                    pnb.ContentColumnLength = (int)r["CONTENT_COLUMN_LENGTH"];
                                }
                                if (!IsDBNull(r["HIDE_FLUENTLY"]))
                                {
                                    pnb.HideFluently = (bool)r["HIDE_FLUENTLY"];
                                }
                                if (!IsDBNull(r["PLAY_SOUND_ON_HIDE"]))
                                {
                                    pnb.PlaySoundOnHide = (bool)r["PLAY_SOUND_ON_HIDE"];
                                }
                                if (!IsDBNull(r["OPACITY"]))
                                {
                                    pnb.Opacity = (double)r["OPACITY"];
                                }
                                if (!IsDBNull(r["RANDOM_COLOR"]))
                                {
                                    pnb.RandomBackColor = (bool)r["RANDOM_COLOR"];
                                }
                                if (!IsDBNull(r["INVERT_TEXT_COLOR"]))
                                {
                                    pnb.InvertTextColor = (bool)r["INVERT_TEXT_COLOR"];
                                }
                                if (!IsDBNull(r["ROLL_ON_DBLCLICK"]))
                                {
                                    pnb.RollOnDblClick = (bool)r["ROLL_ON_DBLCLICK"];
                                }
                                if (!IsDBNull(r["FIT_WHEN_ROLLED"]))
                                {
                                    pnb.FitWhenRolled = (bool)r["FIT_WHEN_ROLLED"];
                                }
                                if (!IsDBNull(r["SHOW_SEPARATE_NOTES"]))
                                {
                                    pnb.ShowSeparateNotes = (bool)r["SHOW_SEPARATE_NOTES"];
                                }
                                if (!IsDBNull(r["PIN_CLICK_ACTION"]))
                                {
                                    var index = (int)r["PIN_CLICK_ACTION"];
                                    if (index < Enum.GetValues(typeof(PinClickAction)).Length)
                                        pnb.PinClickAction = (PinClickAction)index;
                                }
                                if (!IsDBNull(r["NOTE_START_POSITION"]))
                                {
                                    var index = (int)r["NOTE_START_POSITION"];
                                    if (index < Enum.GetValues(typeof(NoteStartPosition)).Length)
                                        pnb.StartPosition = (NoteStartPosition)index;
                                }
                                if (!IsDBNull(r["HIDE_MAIN_WINDOW"]))
                                {
                                    pnb.HideMainWindow = (bool)r["HIDE_MAIN_WINDOW"];
                                }
                                if (!IsDBNull(r["THEME"]))
                                {
                                    pnb.Theme = (string) r["THEME"];
                                }
                                else
                                {
                                    pnb.Theme = PNStrings.DEF_THEME;
                                }
                                if (!IsDBNull(r["PREVENT_RESIZING"]))
                                {
                                    pnb.PreventAutomaticResizing = (bool)r["PREVENT_RESIZING"];
                                }
                                if (!IsDBNull(r["SHOW_PANEL"]))
                                {
                                    pnb.ShowNotesPanel = (bool)r["SHOW_PANEL"];
                                }
                                if (!IsDBNull(r["PANEL_DOCK"]))
                                {
                                    pnb.NotesPanelOrientation = (NotesPanelOrientation)r["PANEL_DOCK"];
                                }
                                if (!IsDBNull(r["PANEL_AUTO_HIDE"]))
                                {
                                    pnb.PanelAutoHide = (bool)r["PANEL_AUTO_HIDE"];
                                }
                                if (!IsDBNull(r["PANEL_REMOVE_MODE"]))
                                {
                                    pnb.PanelRemoveMode = (PanelRemoveMode)r["PANEL_REMOVE_MODE"];
                                }
                                if (!IsDBNull(r["PANEL_SWITCH_OFF_ANIMATION"]))
                                {
                                    pnb.PanelSwitchOffAnimation = (bool)r["PANEL_SWITCH_OFF_ANIMATION"];
                                }
                                if (!IsDBNull(r["PANEL_ENTER_DELAY"]))
                                {
                                    pnb.PanelEnterDelay = (int)r["PANEL_ENTER_DELAY"];
                                }
                            }
                            else
                            {
                                sqlQuery = "INSERT INTO BEHAVIOR VALUES(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)";
                                oData.Execute(sqlQuery);
                            }
                        }
                    }
                    //protection
                    if (!oData.TableExists("PROTECTION"))
                    {
                        sqlQuery = "CREATE TABLE [PROTECTION] ([STORE_AS_ENCRYPTED] BOOLEAN, [HIDE_TRAY_ICON] BOOLEAN, [BACKUP_BEFORE_SAVING] BOOLEAN, [SILENT_FULL_BACKUP] BOOLEAN, [BACKUP_DEEPNESS] INT, [DO_NOT_SHOW_CONTENT] BOOLEAN, [INCLUDE_BIN_IN_SYNC] BOOLEAN, [PASSWORD_STRING] TEXT, [FULL_BACKUP_DAYS] TEXT, [FULL_BACKUP_TIME] TEXT, [FULL_BACKUP_DATE] TEXT, [PROMPT_PASSWORD] BOOLEAN)";
                        oData.Execute(sqlQuery);
                        sqlQuery = "INSERT INTO PROTECTION VALUES(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)";
                        oData.Execute(sqlQuery);
                    }
                    else
                    {
                        using (var t = oData.GetSchema("Columns"))
                        {
                            var rows = t.Select("COLUMN_NAME = 'FULL_BACKUP_DAYS' AND TABLE_NAME = 'PROTECTION'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE PROTECTION ADD COLUMN [FULL_BACKUP_DAYS] TEXT";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'FULL_BACKUP_TIME' AND TABLE_NAME = 'PROTECTION'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE PROTECTION ADD COLUMN [FULL_BACKUP_TIME] TEXT";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'FULL_BACKUP_DATE' AND TABLE_NAME = 'PROTECTION'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE PROTECTION ADD COLUMN [FULL_BACKUP_DATE] TEXT";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'PROMPT_PASSWORD' AND TABLE_NAME = 'PROTECTION'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE PROTECTION ADD COLUMN [PROMPT_PASSWORD] BOOLEAN";
                                oData.Execute(sqlQuery);
                            }
                        }
                        sqlQuery = "SELECT * FROM PROTECTION";
                        using (var t = oData.FillDataTable(sqlQuery))
                        {
                            if (t.Rows.Count > 0)
                            {
                                var r = t.Rows[0];
                                var pnp = PNStatic.Settings.Protection;
                                if (!IsDBNull(r["STORE_AS_ENCRYPTED"]))
                                {
                                    pnp.StoreAsEncrypted = (bool)r["STORE_AS_ENCRYPTED"];
                                }
                                if (!IsDBNull(r["HIDE_TRAY_ICON"]))
                                {
                                    pnp.HideTrayIcon = (bool)r["HIDE_TRAY_ICON"];
                                }
                                if (!IsDBNull(r["BACKUP_BEFORE_SAVING"]))
                                {
                                    pnp.BackupBeforeSaving = (bool)r["BACKUP_BEFORE_SAVING"];
                                }
                                if (!IsDBNull(r["SILENT_FULL_BACKUP"]))
                                {
                                    pnp.SilentFullBackup = (bool)r["SILENT_FULL_BACKUP"];
                                }
                                if (!IsDBNull(r["BACKUP_DEEPNESS"]))
                                {
                                    pnp.BackupDeepness = (int)r["BACKUP_DEEPNESS"];
                                }
                                if (!IsDBNull(r["DO_NOT_SHOW_CONTENT"]))
                                {
                                    pnp.DontShowContent = (bool)r["DO_NOT_SHOW_CONTENT"];
                                }
                                if (!IsDBNull(r["INCLUDE_BIN_IN_SYNC"]))
                                {
                                    pnp.IncludeBinInSync = (bool)r["INCLUDE_BIN_IN_SYNC"];
                                }
                                if (!IsDBNull(r["PASSWORD_STRING"]))
                                {
                                    pnp.PasswordString = (string)r["PASSWORD_STRING"];
                                }
                                if (!IsDBNull(r["FULL_BACKUP_DAYS"]))
                                {
                                    var temp = Convert.ToString(r["FULL_BACKUP_DAYS"]);
                                    if (!string.IsNullOrEmpty(temp))
                                    {
                                        var days = temp.Split(',');
                                        foreach (var d in days)
                                        {
                                            pnp.FullBackupDays.Add((DayOfWeek)Convert.ToInt32(d));
                                        }
                                    }
                                }
                                if (!IsDBNull(r["FULL_BACKUP_TIME"]))
                                {
                                    pnp.FullBackupTime = DateTime.Parse((string)r["FULL_BACKUP_TIME"], PNStatic.CultureInvariant);
                                }
                                if (!IsDBNull(r["FULL_BACKUP_DATE"]))
                                {
                                    pnp.FullBackupDate = DateTime.Parse((string)r["FULL_BACKUP_DATE"], PNStatic.CultureInvariant);
                                }
                                if (!IsDBNull(r["PROMPT_PASSWORD"]))
                                {
                                    pnp.PromptForPassword = (bool)r["PROMPT_PASSWORD"];
                                }
                            }
                            else
                            {
                                sqlQuery = "INSERT INTO PROTECTION VALUES(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)";
                                oData.Execute(sqlQuery);
                            }
                        }
                    }
                    //diary
                    if (!oData.TableExists("DIARY"))
                    {
                        sqlQuery = "CREATE TABLE [DIARY] ([CUSTOM_SETTINGS] BOOLEAN, [ADD_WEEKDAY] BOOLEAN, [FULL_WEEKDAY_NAME] BOOLEAN, [WEEKDAY_AT_THE_END] BOOLEAN, [DO_NOT_SHOW_PREVIOUS] BOOLEAN, [ASC_ORDER] BOOLEAN, [NUMBER_OF_PAGES] INT, [DATE_FORMAT] TEXT)";
                        oData.Execute(sqlQuery);
                        sqlQuery = "INSERT INTO DIARY VALUES(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)";
                        oData.Execute(sqlQuery);
                    }
                    else
                    {
                        sqlQuery = "SELECT * FROM DIARY";
                        using (var t = oData.FillDataTable(sqlQuery))
                        {
                            if (t.Rows.Count > 0)
                            {
                                var r = t.Rows[0];
                                var pndr = PNStatic.Settings.Diary;
                                if (!IsDBNull(r["CUSTOM_SETTINGS"]))
                                {
                                    pndr.CustomSettings = (bool)r["CUSTOM_SETTINGS"];
                                }
                                if (!IsDBNull(r["ADD_WEEKDAY"]))
                                {
                                    pndr.AddWeekday = (bool)r["ADD_WEEKDAY"];
                                }
                                if (!IsDBNull(r["FULL_WEEKDAY_NAME"]))
                                {
                                    pndr.FullWeekdayName = (bool)r["FULL_WEEKDAY_NAME"];
                                }
                                if (!IsDBNull(r["WEEKDAY_AT_THE_END"]))
                                {
                                    pndr.WeekdayAtTheEnd = (bool)r["WEEKDAY_AT_THE_END"];
                                }
                                if (!IsDBNull(r["DO_NOT_SHOW_PREVIOUS"]))
                                {
                                    pndr.DoNotShowPrevious = (bool)r["DO_NOT_SHOW_PREVIOUS"];
                                }
                                if (!IsDBNull(r["ASC_ORDER"]))
                                {
                                    pndr.AscendingOrder = (bool)r["ASC_ORDER"];
                                }
                                if (!IsDBNull(r["NUMBER_OF_PAGES"]))
                                {
                                    pndr.NumberOfPages = (int)r["NUMBER_OF_PAGES"];
                                }
                                if (!IsDBNull(r["DATE_FORMAT"]))
                                {
                                    pndr.DateFormat = (string)r["DATE_FORMAT"];
                                }
                            }
                            else
                            {
                                sqlQuery = "INSERT INTO DIARY VALUES(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)";
                                oData.Execute(sqlQuery);
                            }
                        }
                    }
                    //network
                    if (!oData.TableExists("NETWORK"))
                    {
                        sqlQuery = "CREATE TABLE [NETWORK] ([INCLUDE_BIN_IN_SYNC] BOOLEAN, [SYNC_ON_START] BOOLEAN, [SAVE_BEFORE_SYNC] BOOLEAN, [ENABLE_EXCHANGE] BOOLEAN, [SAVE_BEFORE_SEND] BOOLEAN, [NO_NOTIFY_ON_ARRIVE] BOOLEAN, [SHOW_RECEIVED_ON_CLICK] BOOLEAN, [SHOW_INCOMING_ON_CLICK] BOOLEAN, [NO_SOUND_ON_ARRIVE] BOOLEAN, [NO_NOTIFY_ON_SEND] BOOLEAN, [SHOW_AFTER_ARRIVE] BOOLEAN, [HIDE_AFTER_SEND] BOOLEAN, [NO_CONTACTS_IN_CONTEXT_MENU] BOOLEAN, [EXCHANGE_PORT] INT, [POST_COUNT] INT, [ALLOW_PING] BOOLEAN, [RECEIVED_ON_TOP] BOOLEAN)";
                        oData.Execute(sqlQuery);
                        sqlQuery = "INSERT INTO NETWORK VALUES(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)";
                        oData.Execute(sqlQuery);
                    }
                    else
                    {
                        using (var t = oData.GetSchema("Columns"))
                        {
                            var rows = t.Select("COLUMN_NAME = 'POST_COUNT' AND TABLE_NAME = 'NETWORK'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE NETWORK ADD COLUMN [POST_COUNT] INT";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'ALLOW_PING' AND TABLE_NAME = 'NETWORK'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE NETWORK ADD COLUMN [ALLOW_PING] BOOLEAN";
                                oData.Execute(sqlQuery);
                            }
                            rows = t.Select("COLUMN_NAME = 'RECEIVED_ON_TOP' AND TABLE_NAME = 'NETWORK'");
                            if (rows.Length == 0)
                            {
                                sqlQuery = "ALTER TABLE NETWORK ADD COLUMN [RECEIVED_ON_TOP] BOOLEAN";
                                oData.Execute(sqlQuery);
                            }
                        }
                        sqlQuery = "SELECT * FROM NETWORK";
                        using (var t = oData.FillDataTable(sqlQuery))
                        {
                            if (t.Rows.Count > 0)
                            {
                                var r = t.Rows[0];
                                var pnw = PNStatic.Settings.Network;
                                if (!IsDBNull(r["INCLUDE_BIN_IN_SYNC"]))
                                {
                                    pnw.IncludeBinInSync = (bool)r["INCLUDE_BIN_IN_SYNC"];
                                }
                                if (!IsDBNull(r["SYNC_ON_START"]))
                                {
                                    pnw.SyncOnStart = (bool)r["SYNC_ON_START"];
                                }
                                if (!IsDBNull(r["SAVE_BEFORE_SYNC"]))
                                {
                                    pnw.SaveBeforeSync = (bool)r["SAVE_BEFORE_SYNC"];
                                }
                                if (!IsDBNull(r["ENABLE_EXCHANGE"]))
                                {
                                    pnw.EnableExchange = (bool)r["ENABLE_EXCHANGE"];
                                }
                                if (!IsDBNull(r["SAVE_BEFORE_SEND"]))
                                {
                                    pnw.SaveBeforeSending = (bool)r["SAVE_BEFORE_SEND"];
                                }
                                if (!IsDBNull(r["NO_NOTIFY_ON_ARRIVE"]))
                                {
                                    pnw.NoNotificationOnArrive = (bool)r["NO_NOTIFY_ON_ARRIVE"];
                                }
                                if (!IsDBNull(r["SHOW_RECEIVED_ON_CLICK"]))
                                {
                                    pnw.ShowReceivedOnClick = (bool)r["SHOW_RECEIVED_ON_CLICK"];
                                }
                                if (!IsDBNull(r["SHOW_INCOMING_ON_CLICK"]))
                                {
                                    pnw.ShowIncomingOnClick = (bool)r["SHOW_INCOMING_ON_CLICK"];
                                }
                                if (!IsDBNull(r["NO_SOUND_ON_ARRIVE"]))
                                {
                                    pnw.NoSoundOnArrive = (bool)r["NO_SOUND_ON_ARRIVE"];
                                }
                                if (!IsDBNull(r["NO_NOTIFY_ON_SEND"]))
                                {
                                    pnw.NoNotificationOnSend = (bool)r["NO_NOTIFY_ON_SEND"];
                                }
                                if (!IsDBNull(r["SHOW_AFTER_ARRIVE"]))
                                {
                                    pnw.ShowAfterArrive = (bool)r["SHOW_AFTER_ARRIVE"];
                                }
                                if (!IsDBNull(r["HIDE_AFTER_SEND"]))
                                {
                                    pnw.HideAfterSending = (bool)r["HIDE_AFTER_SEND"];
                                }
                                if (!IsDBNull(r["NO_CONTACTS_IN_CONTEXT_MENU"]))
                                {
                                    pnw.NoContactsInContextMenu = (bool)r["NO_CONTACTS_IN_CONTEXT_MENU"];
                                }
                                if (!IsDBNull(r["EXCHANGE_PORT"]))
                                {
                                    pnw.ExchangePort = (int)r["EXCHANGE_PORT"];
                                }
                                if (!IsDBNull(r["POST_COUNT"]))
                                {
                                    pnw.PostCount = (int)r["POST_COUNT"];
                                }
                                if (!IsDBNull(r["ALLOW_PING"]))
                                {
                                    pnw.AllowPing = (bool)r["ALLOW_PING"];
                                }
                                if (!IsDBNull(r["RECEIVED_ON_TOP"]))
                                {
                                    pnw.ReceivedOnTop = (bool)r["RECEIVED_ON_TOP"];
                                }
                            }
                            else
                            {
                                sqlQuery = "INSERT INTO NETWORK VALUES(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)";
                                oData.Execute(sqlQuery);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                PNStatic.LogException(ex);
            }
        }
예제 #11
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);
        }
예제 #12
0
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType != typeof (string)) return base.ConvertTo(context, culture, value, destinationType);
            var note = value as PNote;
            if (note == null) return "";
            var bt = new StringBuilder();
            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();
            var sb = new StringBuilder();

            sb.Append(note.Changed);
            sb.Append(DEL_NOTE);
            sb.Append(note.Completed);
            sb.Append(DEL_NOTE);
            sb.Append(note.CustomOpacity);
            sb.Append(DEL_NOTE);
            sb.Append(dtc.ConvertToString(null, PNStatic.CultureInvariant, note.DateCreated));
            sb.Append(DEL_NOTE);
            sb.Append(dtc.ConvertToString(null, PNStatic.CultureInvariant, note.DateDeleted));
            sb.Append(DEL_NOTE);
            sb.Append(dtc.ConvertToString(null, PNStatic.CultureInvariant, note.DateReceived));
            sb.Append(DEL_NOTE);
            sb.Append(dtc.ConvertToString(null, PNStatic.CultureInvariant, note.DateSaved));
            sb.Append(DEL_NOTE);
            sb.Append(dtc.ConvertToString(null, PNStatic.CultureInvariant, note.DateSent));
            sb.Append(DEL_NOTE);
            sb.Append((int)note.DockStatus);
            sb.Append(DEL_NOTE);
            sb.Append(scd.ConvertToString(null, PNStatic.CultureInvariant, note.EditSize));
            sb.Append(DEL_NOTE);
            sb.Append(note.Favorite);
            sb.Append(DEL_NOTE);
            sb.Append(note.FromDB);
            sb.Append(DEL_NOTE);
            sb.Append(note.GroupID);
            sb.Append(DEL_NOTE);
            sb.Append(note.ID);
            sb.Append(DEL_NOTE);
            foreach (var s in note.LinkedNotes)
            {
                bt.Append(s);
                bt.Append(DEL_INNER);
            }
            if (bt.Length > 0)
                bt.Length -= 1;
            sb.Append(bt);
            sb.Append(DEL_NOTE);
            sb.Append(note.Name);
            sb.Append(DEL_NOTE);
            sb.Append(ptc.ConvertToString(null, PNStatic.CultureInvariant, note.NoteLocation));
            sb.Append(DEL_NOTE);
            sb.Append(szc.ConvertToString(null, PNStatic.CultureInvariant, note.NoteSize));
            sb.Append(DEL_NOTE);
            sb.Append(note.Opacity.ToString(PNStatic.CultureInvariant));
            sb.Append(DEL_NOTE);
            sb.Append(note.PasswordString);
            sb.Append(DEL_NOTE);
            sb.Append(note.Pinned);
            sb.Append(DEL_NOTE);
            sb.Append(note.PrevGroupID);
            sb.Append(DEL_NOTE);
            sb.Append(note.Priority);
            sb.Append(DEL_NOTE);
            sb.Append(note.Protected);
            sb.Append(DEL_NOTE);
            sb.Append(note.ReceivedFrom);
            sb.Append(DEL_NOTE);
            sb.Append(note.Rolled);
            sb.Append(DEL_NOTE);
            sb.Append(scv.ConvertToString(note.Schedule));
            sb.Append(DEL_NOTE);
            sb.Append((int)note.SentReceived);
            sb.Append(DEL_NOTE);
            sb.Append(note.SentTo);
            sb.Append(DEL_NOTE);
            sb.Append(note.Skin != null ? note.Skin.SkinName : "");
            sb.Append(DEL_NOTE);
            sb.Append(note.Skinless != null ? skc.ConvertToString(note.Skinless) : "");
            sb.Append(DEL_NOTE);
            bt = new StringBuilder();
            foreach (var s in note.Tags)
            {
                bt.Append(s);
                bt.Append(DEL_INNER);
            }
            if (bt.Length > 0)
                bt.Length -= 1;
            sb.Append(bt);
            sb.Append(DEL_NOTE);
            sb.Append(note.Topmost);
            sb.Append(DEL_NOTE);
            sb.Append(note.Visible);
            sb.Append(DEL_NOTE);
            sb.Append(note.XFactor.ToString(PNStatic.CultureInvariant));
            sb.Append(DEL_NOTE);
            sb.Append(note.YFactor.ToString(PNStatic.CultureInvariant));
            sb.Append(DEL_NOTE);
            sb.Append(note.PinClass);
            sb.Append(DEL_NOTE);
            sb.Append(note.PinText);
            return sb.ToString();
        }
예제 #13
0
		public void ConvertFrom_size ()
		{
			PointConverter r = new PointConverter ();

			r.ConvertFrom (new Point (10, 20));
		}
예제 #14
0
        private bool addNewNote(string id, NOTE_DATA data, SCHEDULE_TYPE schedule, NOTE_REL_POSITION relPos,
            ADDITIONAL_NAPP addApp, SYSTEMTIME creation, SYSTEMTIME deletion, NOTE_APPEARANCE appearance, NOTE_PIN pin,
            SEND_REC_STATUS sendrec, StringBuilder tags, StringBuilder links, Dictionary<int, int> groupIds, bool hide)
        {
            try
            {
                var sqlList = new List<string>();
                var sb = new StringBuilder();
                var afv = new AlarmAfterValues();
                var md = new MonthDay();
                var dw = new List<DayOfWeek>();
                var sc = new SizeConverter();
                var pc = new PointConverter();
                var ac = new AlarmAfterValuesConverter();
                var mdc = new MonthDayConverter();
                var dwc = new DaysOfWeekConverter();
                var lfc = new LogFontConverter();

                if (PNStatic.Notes.Any(n => n.ID == id))
                {
                    string message = PNLang.Instance.GetMessageText("id_exists",
                        "The note with the same ID already exists.");
                    message += '\n';
                    message += PNLang.Instance.GetMessageText("continue_anyway", "Continue anyway?");
                    if (
                        PNMessageBox.Show(message, PNStrings.PROG_NAME, MessageBoxButton.YesNo, MessageBoxImage.Question) ==
                        MessageBoxResult.No)
                    {
                        return false;
                    }
                }
                sqlList.Add("DELETE FROM NOTES WHERE ID = '" + id + "'");
                sb.Append(
                    "INSERT INTO NOTES (ID, NAME, GROUP_ID, PREV_GROUP_ID, OPACITY, VISIBLE, FAVORITE, PROTECTED, COMPLETED, PRIORITY, PASSWORD_STRING, PINNED, TOPMOST, ROLLED, DOCK_STATUS, DOCK_ORDER, SEND_RECEIVE_STATUS, DATE_CREATED, DATE_SAVED, DATE_SENT, DATE_RECEIVED, DATE_DELETED, SIZE, LOCATION, EDIT_SIZE, REL_X, REL_Y, SENT_TO, RECEIVED_FROM, PIN_CLASS, PIN_TEXT, RECEIVED_IP) VALUES(");
                // ID
                sb.Append("'");
                sb.Append(id);
                sb.Append("', ");
                // NAME
                sb.Append("'");
                sb.Append(data.szName.Replace("'", "''"));
                sb.Append("', ");
                // GROUP_ID
                if (groupIds.Keys.Contains(data.idGroup))
                {
                    sb.Append(groupIds[data.idGroup]);
                }
                else
                {
                    if (PNStatic.Groups.Any(g => g.ID == data.idGroup))
                    {
                        if (data.idGroup == GROUP_INCOMING)
                            sb.Append((int)SpecialGroups.Incoming);
                        else
                            sb.Append(data.idGroup);
                    }
                    else
                    {
                        sb.Append("0");
                    }
                }
                sb.Append(", ");
                // PREV_GROUP_ID
                sb.Append("0");
                sb.Append(", ");
                // OPACITY
                sb.Append(addApp.transValue != 0 ? (addApp.transValue / 255.0).ToString(PNStatic.CultureInvariant) : "1.0");
                sb.Append(", ");
                // VISIBLE
                sb.Append(!hide ? Convert.ToInt32(data.visible) : 0);
                sb.Append(", ");
                // FAVORITE
                sb.Append("0, ");
                // PROTECTED
                sb.Append(Convert.ToInt32(PNStatic.IsBitSet(data.res1, NB_PROTECTED)));
                sb.Append(", ");
                // COMPLETED
                sb.Append(Convert.ToInt32(PNStatic.IsBitSet(data.res1, NB_COMPLETED)));
                sb.Append(", ");
                // PRIORITY
                sb.Append(Convert.ToInt32(PNStatic.IsBitSet(data.res1, NB_HIGH_PRIORITY)));
                sb.Append(", ");
                // PASSWORD_STRING
                sb.Append("'',");
                // PINNED
                sb.Append(
                    Convert.ToInt32((pin.className != null && pin.text != null && pin.className != "" && pin.text != "")));
                sb.Append(", ");
                // TOPMOST
                sb.Append(Convert.ToInt32(data.onTop));
                sb.Append(", ");
                // ROLLED
                sb.Append(Convert.ToInt32(data.rolled));
                sb.Append(", ");
                // DOCK_STATUS
                int ddata = loWord(data.dockData);
                if (ddata < (int)DockStatus.None || ddata > (int)DockStatus.Bottom)
                    sb.Append((int)DockStatus.None);
                else
                    sb.Append(ddata);
                sb.Append(", ");
                // DOCK_ORDER
                var dorder = -1;
                switch ((DockStatus)ddata)
                {
                    case DockStatus.Left:
                    case DockStatus.Top:
                    case DockStatus.Right:
                    case DockStatus.Bottom:
                        if (PNStatic.DockedNotes[(DockStatus)ddata].Count > 0)
                        {
                            dorder = PNStatic.DockedNotes[(DockStatus)ddata].Max(n => n.DockOrder) + 1;
                            dorder += m_DockedNotes[(DockStatus)ddata];
                            m_DockedNotes[(DockStatus)ddata]++;
                        }
                        else
                            dorder = 0;
                        break;
                }
                sb.Append(dorder);
                sb.Append(", ");
                // SEND_RECEIVE_STATUS
                if (sendrec.sentTo != null && sendrec.recFrom != null && sendrec.sentTo != "" && sendrec.recFrom != "")
                    sb.Append((int)(SendReceiveStatus.Both));
                else if (!string.IsNullOrEmpty(sendrec.sentTo))
                    sb.Append((int)SendReceiveStatus.Sent);
                else if (!string.IsNullOrEmpty(sendrec.recFrom))
                    sb.Append((int)SendReceiveStatus.Received);
                else
                    sb.Append("0");
                sb.Append(", ");
                // DATE_CREATED
                DateTime date = new DateTime(creation.wYear != 0 ? creation.wYear : 1,
                    creation.wMonth != 0 ? creation.wMonth : 1, creation.wDay != 0 ? creation.wDay : 1, creation.wHour,
                    creation.wMinute, creation.wSecond);
                sb.Append("'");
                sb.Append(date.ToString(PNStrings.DATE_TIME_FORMAT, PNStatic.CultureInvariant).Replace("'", "''"));
                sb.Append("', ");
                // DATE_SAVED
                date = new DateTime(data.stChanged.wYear != 0 ? data.stChanged.wYear : 1,
                    data.stChanged.wMonth != 0 ? data.stChanged.wMonth : 1,
                    data.stChanged.wDay != 0 ? data.stChanged.wDay : 1, data.stChanged.wHour, data.stChanged.wMinute,
                    data.stChanged.wSecond);
                sb.Append("'");
                sb.Append(date.ToString(PNStrings.DATE_TIME_FORMAT, PNStatic.CultureInvariant).Replace("'", "''"));
                sb.Append("', ");
                // DATE_SENT
                date = new DateTime(sendrec.lastSent.wYear != 0 ? sendrec.lastSent.wYear : 1,
                    sendrec.lastSent.wMonth != 0 ? sendrec.lastSent.wMonth : 1,
                    sendrec.lastSent.wDay != 0 ? sendrec.lastSent.wDay : 1, sendrec.lastSent.wHour,
                    sendrec.lastSent.wMinute, sendrec.lastSent.wSecond);
                sb.Append("'");
                sb.Append(date.ToString(PNStrings.DATE_TIME_FORMAT, PNStatic.CultureInvariant).Replace("'", "''"));
                sb.Append("', ");
                // DATE_RECEIVED
                date = new DateTime(sendrec.lastRec.wYear != 0 ? sendrec.lastRec.wYear : 1,
                    sendrec.lastRec.wMonth != 0 ? sendrec.lastRec.wMonth : 1,
                    sendrec.lastRec.wDay != 0 ? sendrec.lastRec.wDay : 1, sendrec.lastRec.wHour, sendrec.lastRec.wMinute,
                    sendrec.lastRec.wSecond);
                sb.Append("'");
                sb.Append(date.ToString(PNStrings.DATE_TIME_FORMAT, PNStatic.CultureInvariant).Replace("'", "''"));
                sb.Append("', ");
                // DATE_DELETED
                date = new DateTime(deletion.wYear != 0 ? deletion.wYear : 1, deletion.wMonth != 0 ? deletion.wMonth : 1,
                    deletion.wDay != 0 ? deletion.wDay : 1, deletion.wHour, deletion.wMinute, deletion.wSecond);
                sb.Append("'");
                sb.Append(date.ToString(PNStrings.DATE_TIME_FORMAT, PNStatic.CultureInvariant).Replace("'", "''"));
                sb.Append("', ");
                // SIZE
                Size size = new Size(data.rcp.right - data.rcp.left, data.rcp.bottom - data.rcp.top);
                sb.Append("'");
                sb.Append(sc.ConvertToString(null, PNStatic.CultureInvariant, size));
                sb.Append("', ");
                // LOCATION
                Point location = new Point(data.rcp.left, data.rcp.top);
                sb.Append("'");
                sb.Append(pc.ConvertToString(null, PNStatic.CultureInvariant, location));
                sb.Append("', ");
                // EDIT_SIZE - just copy note size, there is no way to get the edit size of note
                sb.Append("'");
                sb.Append(sc.ConvertToString(null, PNStatic.CultureInvariant, size));
                sb.Append("', ");
                // REL_X
                sb.Append(Math.Abs(relPos.left - 0) > double.Epsilon
                    ? relPos.left.ToString(PNStatic.CultureInvariant)
                    : "1.0");
                sb.Append(", ");
                // REL_Y
                sb.Append(Math.Abs(relPos.top - 0) > double.Epsilon
                    ? relPos.top.ToString(PNStatic.CultureInvariant)
                    : "1.0");
                sb.Append(", ");
                // SENT_TO
                sb.Append("'");
                sb.Append(!string.IsNullOrEmpty(sendrec.sentTo) ? sendrec.sentTo.Replace("'", "''") : "");
                sb.Append("', ");
                // RECEIVED_FROM
                sb.Append("'");
                sb.Append(!string.IsNullOrEmpty(sendrec.recFrom) ? sendrec.recFrom.Replace("'", "''") : "");
                sb.Append("', ");
                // PIN_CLASS
                sb.Append("'");
                sb.Append(!string.IsNullOrEmpty(pin.className) ? pin.className.Replace("'", "''") : "");
                sb.Append("', ");
                // PIN_TEXT
                sb.Append("'");
                sb.Append(!string.IsNullOrEmpty(pin.text) ? pin.text.Replace("'", "''") : "");
                //RECEIVED_IP
                sb.Append("', ''");
                
                sb.Append(")");
                sqlList.Add(sb.ToString());

                // schedule
                // SCHEDULE_TYPE
                if (schedule.scType > 0)
                {
                    ScheduleType sctype;
                    if (schedule.scType > START_PROG)
                    {
                        sctype = (ScheduleType)(schedule.scType - START_PROG);
                    }
                    else
                    {
                        sctype = (ScheduleType)schedule.scType;
                    }
                    var doInsert = true;
                    if (sctype == ScheduleType.RepeatEvery || sctype == ScheduleType.After)
                    {
                        if (schedule.scDate.wYear == 0 &&
                            schedule.scDate.wMonth == 0 &&
                            schedule.scDate.wDayOfWeek == 0 &&
                            schedule.scDate.wDay == 0 &&
                            schedule.scDate.wHour == 0 &&
                            schedule.scDate.wMinute == 0 &&
                            schedule.scDate.wSecond == 0)
                        {
                            doInsert = false;
                        }
                    }
                    if (doInsert)
                    {
                        sb = new StringBuilder();
                        sb.Append(
                            "INSERT INTO NOTES_SCHEDULE (NOTE_ID, SCHEDULE_TYPE, ALARM_DATE, START_DATE, LAST_RUN, SOUND, STOP_AFTER, TRACK, REPEAT_COUNT, SOUND_IN_LOOP, USE_TTS, START_FROM, MONTH_DAY, ALARM_AFTER, WEEKDAYS, PROG_TO_RUN, CLOSE_ON_NOTIFICATION, MULTI_ALERTS, TIME_ZONE) VALUES(");
                        // NOTE_ID
                        sb.Append("'");
                        sb.Append(id);
                        sb.Append("', ");
                        sb.Append((int)sctype);
                        sb.Append(", ");
                        // ALARM_DATE
                        date = new DateTime(schedule.scDate.wYear != 0 ? schedule.scDate.wYear : 1,
                            schedule.scDate.wMonth != 0 ? schedule.scDate.wMonth : 1,
                            schedule.scDate.wDay != 0 ? schedule.scDate.wDay : 1, schedule.scDate.wHour,
                            schedule.scDate.wMinute, schedule.scDate.wSecond);
                        sb.Append("'");
                        sb.Append(date.ToString(PNStrings.DATE_TIME_FORMAT, PNStatic.CultureInvariant)
                            .Replace("'", "''"));
                        sb.Append("', ");
                        // START_DATE
                        date = new DateTime(schedule.scStart.wYear != 0 ? schedule.scStart.wYear : 1,
                            schedule.scStart.wMonth != 0 ? schedule.scStart.wMonth : 1,
                            schedule.scStart.wDay != 0 ? schedule.scStart.wDay : 1, schedule.scStart.wHour,
                            schedule.scStart.wMinute, schedule.scStart.wSecond);
                        sb.Append("'");
                        sb.Append(date.ToString(PNStrings.DATE_TIME_FORMAT, PNStatic.CultureInvariant)
                            .Replace("'", "''"));
                        sb.Append("', ");
                        // LAST_RUN
                        date = new DateTime(schedule.scLastRun.wYear != 0 ? schedule.scLastRun.wYear : 1,
                            schedule.scLastRun.wMonth != 0 ? schedule.scLastRun.wMonth : 1,
                            schedule.scLastRun.wDay != 0 ? schedule.scLastRun.wDay : 1, schedule.scLastRun.wHour,
                            schedule.scLastRun.wMinute, schedule.scLastRun.wSecond);
                        sb.Append("'");
                        sb.Append(date.ToString(PNStrings.DATE_TIME_FORMAT, PNStatic.CultureInvariant)
                            .Replace("'", "''"));
                        sb.Append("', ");
                        // SOUND
                        sb.Append("'");
                        sb.Append(schedule.szSound != null && schedule.szSound.Trim().Length > 0
                            ? schedule.szSound.Replace("'", "''")
                            : PNSchedule.DEF_SOUND);
                        sb.Append("', ");
                        // STOP_AFTER
                        sb.Append(schedule.stopLoop);
                        sb.Append(", ");
                        // TRACK
                        sb.Append(Convert.ToInt32(!PNStatic.IsBitSet(data.res1, NB_NOT_TRACK)));
                        sb.Append(", ");
                        // REPEAT_COUNT - no way to get repeat count
                        sb.Append(0);
                        sb.Append(", ");
                        // SOUND_IN_LOOP
                        sb.Append(Convert.ToInt32(PNStatic.IsBitSet(schedule.parameters, SP_SOUND_IN_LOOP)));
                        sb.Append(", ");
                        // USE_TTS
                        sb.Append(Convert.ToInt32(PNStatic.IsBitSet(schedule.parameters, SP_USE_TTS)));
                        sb.Append(", ");
                        // START_FROM
                        if (schedule.scType > START_PROG)
                            sb.Append((int)ScheduleStart.ProgramStart);
                        else
                            sb.Append((int)ScheduleStart.ExactTime);
                        sb.Append(", ");
                        // MONTH_DAY
                        if (sctype == ScheduleType.MonthlyDayOfWeek)
                        {
                            md.WeekDay = (DayOfWeek)schedule.scDate.wDayOfWeek;
                            md.OrdinalNumber = (DayOrdinal)schedule.scDate.wMilliseconds;
                        }
                        sb.Append("'");
                        var convertToString = mdc.ConvertToString(md);
                        if (convertToString != null) sb.Append(convertToString.Replace("'", "''"));
                        sb.Append("', ");
                        // ALARM_AFTER
                        if (sctype == ScheduleType.RepeatEvery || sctype == ScheduleType.After)
                        {
                            afv.Years = schedule.scDate.wYear;
                            afv.Months = schedule.scDate.wMonth;
                            afv.Weeks = schedule.scDate.wDayOfWeek;
                            afv.Days = schedule.scDate.wDay;
                            afv.Hours = schedule.scDate.wHour;
                            afv.Minutes = schedule.scDate.wMinute;
                            afv.Seconds = schedule.scDate.wSecond;
                        }
                        sb.Append("'");
                        sb.Append(ac.ConvertToString(afv).Replace("'", "''"));
                        sb.Append("', ");
                        // WEEKDAYS
                        if (sctype == ScheduleType.Weekly)
                        {
                            if (PNStatic.IsBitSet(schedule.scDate.wDayOfWeek, 1))
                                dw.Add(DayOfWeek.Sunday);
                            if (PNStatic.IsBitSet(schedule.scDate.wDayOfWeek, 2))
                                dw.Add(DayOfWeek.Monday);
                            if (PNStatic.IsBitSet(schedule.scDate.wDayOfWeek, 3))
                                dw.Add(DayOfWeek.Tuesday);
                            if (PNStatic.IsBitSet(schedule.scDate.wDayOfWeek, 4))
                                dw.Add(DayOfWeek.Wednesday);
                            if (PNStatic.IsBitSet(schedule.scDate.wDayOfWeek, 5))
                                dw.Add(DayOfWeek.Thursday);
                            if (PNStatic.IsBitSet(schedule.scDate.wDayOfWeek, 6))
                                dw.Add(DayOfWeek.Friday);
                            if (PNStatic.IsBitSet(schedule.scDate.wDayOfWeek, 7))
                                dw.Add(DayOfWeek.Saturday);
                        }
                        sb.Append("'");
                        sb.Append(dwc.ConvertToString(dw));
                        sb.Append("','");
                        //PROG_TO_RUN
                        sb.Append("',");
                        //CLOSE_ON_NOTIFICATION
                        sb.Append(0);
                        //MULTI_ALERTS
                        sb.Append(", NULL");
                        //TIME_ZONE
                        sb.Append(", NULL");
                        sb.Append(")");
                        sqlList.Add(sb.ToString());
                    }
                }
                // custom note settings
                sb = new StringBuilder();
                sb.Append(
                    "INSERT INTO CUSTOM_NOTES_SETTINGS (NOTE_ID, BACK_COLOR, CAPTION_FONT_COLOR, CAPTION_FONT, SKIN_NAME, CUSTOM_OPACITY) VALUES(");
                // NOTE_ID
                sb.Append("'");
                sb.Append(id);
                sb.Append("', ");
                // BACK_COLOR
                if (appearance.crWindow != 0 && (appearance.nPrivate & F_B_COLOR) == F_B_COLOR)
                {
                    sb.Append("'");
                    var colorString = PNStatic.FromIntToColorString(appearance.crWindow);
                    sb.Append(colorString);
                    sb.Append("', ");
                }
                else
                {
                    sb.Append("NULL, ");
                }
                // CAPTION_FONT_COLOR
                if (appearance.crCaption != 0 && (appearance.nPrivate & F_C_COLOR) == F_C_COLOR)
                {
                    sb.Append("'");
                    var colorString = PNStatic.FromIntToColorString(appearance.crCaption);
                    sb.Append(colorString);
                    sb.Append("', ");
                }
                else
                {
                    sb.Append("NULL, ");
                }
                // CAPTION_FONT
                if (appearance.lfCaption.lfFaceName != null && appearance.lfCaption.lfFaceName.Trim().Length > 0 &&
                    (appearance.nPrivate & F_C_FONT) == F_C_FONT)
                {
                    var lf = new LOGFONT
                    {
                        lfCharSet = appearance.lfCaption.lfCharSet,
                        lfClipPrecision = appearance.lfCaption.lfClipPrecision,
                        lfEscapement = appearance.lfCaption.lfEscapement,
                        lfFaceName = appearance.lfCaption.lfFaceName.Trim(),
                        lfHeight = appearance.lfCaption.lfHeight,
                        lfItalic = appearance.lfCaption.lfItalic,
                        lfOrientation = appearance.lfCaption.lfOrientation,
                        lfOutPrecision = appearance.lfCaption.lfOutPrecision,
                        lfPitchAndFamily = appearance.lfCaption.lfPitchAndFamily,
                        lfQuality = appearance.lfCaption.lfQuality,
                        lfStrikeOut = appearance.lfCaption.lfStrikeOut,
                        lfUnderline = appearance.lfCaption.lfUnderline,
                        lfWeight = appearance.lfCaption.lfWeight,
                        lfWidth = appearance.lfCaption.lfWidth
                    };
                    sb.Append("'");
                    sb.Append(lfc.ConvertToString(lf));
                    sb.Append("', ");
                }
                else
                {
                    sb.Append("NULL, ");
                }
                // SKIN_NAME
                if (appearance.szSkin != null && appearance.szSkin.Trim().Length > 0 &&
                    (appearance.nPrivate & F_SKIN) == F_SKIN)
                {
                    sb.Append("'");
                    sb.Append(appearance.szSkin.Trim().Replace("'", "''"));
                    sb.Append("', ");
                }
                else
                {
                    sb.Append("NULL, ");
                }
                // CUSTOM_OPACITY
                sb.Append(addApp.transValue != 0 ? 1 : 0);
                sb.Append(")");
                sqlList.Add(sb.ToString());

                // linked notes
                if (links.Length > 0)
                {
                    var arr = links.ToString().Split('|');
                    foreach (var s in arr)
                    {
                        if (s.Trim().Length > 0)
                        {
                            sb = new StringBuilder();
                            sb.Append("INSERT INTO LINKED_NOTES (NOTE_ID, LINK_ID) VALUES(");
                            // NOTE_ID
                            sb.Append("'");
                            sb.Append(id);
                            sb.Append("', ");
                            // LINK_ID
                            sb.Append("'");
                            sb.Append(s);
                            sb.Append("'");
                            sb.Append(")");
                            sqlList.Add(sb.ToString());
                        }
                    }
                }

                // tags
                if (tags.Length > 0)
                {
                    var arr = tags.ToString().Split(',');
                    foreach (var s in arr)
                    {
                        if (s.Trim().Length > 0)
                        {
                            sb = new StringBuilder();
                            sb.Append("INSERT INTO NOTES_TAGS (NOTE_ID, TAG) VALUES(");
                            // NOTE_ID
                            sb.Append("'");
                            sb.Append(id);
                            sb.Append("', ");
                            // TAG
                            sb.Append("'");
                            sb.Append(s.Replace("'", "''"));
                            sb.Append("'");
                            sb.Append(") ");
                            sqlList.Add(sb.ToString());
                        }
                    }
                }

                if (!removeNote(id))
                    return false;
                if (!PNData.ExecuteTransactionForList(sqlList, PNData.ConnectionString))
                    return false;
                return true;
            }
            catch (Exception ex)
            {
                PNStatic.LogException(ex);
                return false;
            }
        }