public Anniversary()
        {
            InitializeComponent();

            RscStore store = new RscStore();

            store.CreateFolderPath(csDocFolder);

            spFiles = (StackPanel)host.UI.scrl.FindName("filesPanel");
            sEml    = "";

            doRefresh();

            btnSndAll.Click += new System.Windows.RoutedEventHandler(btnSndAll_Click);
            btnSend.Click   += new System.Windows.RoutedEventHandler(btnSend_Click);
            btnNew.Click    += new System.Windows.RoutedEventHandler(btnNew_Click);
            btnSave.Click   += new System.Windows.RoutedEventHandler(btnSave_Click);
            btnDel.Click    += new System.Windows.RoutedEventHandler(btnDel_Click);

            txY.TextChanged += new System.Windows.Controls.TextChangedEventHandler(txtNot_TextChanged);
            txM.TextChanged += new System.Windows.Controls.TextChangedEventHandler(txtNot_TextChanged);
            txD.TextChanged += new System.Windows.Controls.TextChangedEventHandler(txtNot_TextChanged);

            txtTit.TextChanged += new System.Windows.Controls.TextChangedEventHandler(txtTit_TextChanged);
        }
Esempio n. 2
0
 public static void SaveAuthResult(RscGoogleAuthResult auth)
 {
     Deployment.Current.Dispatcher.BeginInvoke(() =>
     {
         RscStore store = new RscStore();
         store.CreateFolderPath(AppLogic.csSecretsFolder);
         store.WriteXmlDataFile(AppLogic.csSecretsFolder + "\\" + "AUTH.xml", auth, true);
     });
 }
Esempio n. 3
0
        private string ImgFolderPath()
        {
            string sPath = "A:\\Internet\\Favicons";

            RscStore store = new RscStore();

            store.CreateFolderPath(sPath);

            return(sPath + "\\");
        }
Esempio n. 4
0
        public static void StoreUserAgentID(string sDomain, string sUaID)
        {
            RscStore store = new RscStore();

            string sFolder = "A:\\Internet\\UserAgents";

            store.CreateFolderPath(sFolder);

            store.WriteTextFile(sFolder + "\\" + sDomain + ".txt", sUaID, true);
        }
        private void m_btnSave_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            RscStore store = new RscStore();

            store.CreateFolderPath(m_sAppFolder);

            SaveImage(true);
            SaveImage(false);

            AddSavedNote();
        }
Esempio n. 6
0
        public static void WriteDWORD(HKEY hk, string sPath, string sName, int iValue)
        {
            string strFullPath = GetFullPath(hk, sPath);

            RscStore store = new RscStore();

            store.CreateFolderPath(strFullPath);

            strFullPath += "\\" + sName + ".DWORD";

            store.WriteTextFile(strFullPath, iValue.ToString(), true);
        }
Esempio n. 7
0
        public static void WriteString(HKEY hk, string sPath, string sName, string sValue)
        {
            string strFullPath = GetFullPath(hk, sPath);

            RscStore store = new RscStore();

            store.CreateFolderPath(strFullPath);

            strFullPath += "\\" + sName + ".String";

            store.WriteTextFile(strFullPath, sValue, true);
        }
Esempio n. 8
0
        private void SaveAuthResult(RscGoogleAuthResult auth)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                //ATT: Logged ON!!!
                m_btnLogOut.Visibility = Rsc.Visible;

                RscStore store = new RscStore();
                store.CreateFolderPath(csSecretsFolder);
                store.WriteXmlDataFile(csSecretsFolder + "\\" + "AUTH.xml", auth, true);
            });
        }
Esempio n. 9
0
        public static RscGoogleAuthResult LoadAuthResult(out bool bNotExists)
        {
            bNotExists = false;

            RscGoogleAuthResult auth;

            RscStore store = new RscStore();

            store.CreateFolderPath(AppLogic.csSecretsFolder);
            auth = store.ReadXmlDataFile <RscGoogleAuthResult>(AppLogic.csSecretsFolder + "\\" + "AUTH.xml", null, out bNotExists);

            return(auth);
        }
Esempio n. 10
0
        private void DoPlay()
        {
            if (m_siInPlayer == null)
            {
                return;
            }

            //m_txtSnd.Text = m_siInPlayer.FileTitle;

            int idx = m_sounds.IndexOf(m_siInPlayer);

            // //
            //

            RscStore store = new RscStore();

            store.CreateFolderPath("A:\\System\\AudioPlaybackAgent");
            store.WriteTextFile("A:\\System\\AudioPlaybackAgent\\CurrentTrack.txt", idx.ToString(), true);

            //
            // //

            bool bErr = true;

            try
            {
                BackgroundAudioPlayer.Instance.Play();
                bErr = false;
            }
            catch (Exception /*e*/)
            {
                //FIX: App closed, Music stoped, App started + last loaded, Play FAILS!!!
                //MessageBox.Show( e.Message );
            }

            if (bErr)
            {
                try
                {
                    //FIX: App closed, Music stoped, App started + last loaded, Play FAILS!!!
                    BackgroundAudioPlayer.Instance.Close();
                }
                catch (Exception /*e*/)
                {
                }
            }
        }
        public NoteEditor()
        {
            InitializeComponent();

            RscStore store = new RscStore();

            store.CreateFolderPath(csDocFolder);

            btnSend.Click          += new System.Windows.RoutedEventHandler(btnSend_Click);
            btnNew.Click           += new System.Windows.RoutedEventHandler(btnNew_Click);
            lbTit.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(lbTit_SelectionChanged);
            btnLoad.Click          += new System.Windows.RoutedEventHandler(btnLoad_Click);
            btnSave.Click          += new System.Windows.RoutedEventHandler(btnSave_Click);
            btnDel.Click           += new System.Windows.RoutedEventHandler(btnDel_Click);
            txtNot.TextChanged     += new System.Windows.Controls.TextChangedEventHandler(txtNot_TextChanged);
            txtTit.TextChanged     += new System.Windows.Controls.TextChangedEventHandler(txtTit_TextChanged);
        }
Esempio n. 12
0
        private RscGoogleAuthResult LoadAuthResult()
        {
            RscGoogleAuthResult auth;

            RscStore store = new RscStore();

            store.CreateFolderPath(csSecretsFolder);
            bool bNotExists;

            auth = store.ReadXmlDataFile <RscGoogleAuthResult>(csSecretsFolder + "\\" + "AUTH.xml", null, out bNotExists);

            if (!bNotExists)
            {
                //ATT: Logged ON!!!
                m_btnLogOut.Visibility = Rsc.Visible;
            }

            return(auth);
        }
Esempio n. 13
0
        private void PlayNext(BackgroundAudioPlayer player)
        {
            ReadPlaylist();
            m_iCurrentTrack++;
            if (m_iCurrentTrack >= m_aTracks.Count)
            {
                m_iCurrentTrack = 0;
            }
            if (m_iCurrentTrack >= m_aTracks.Count)
            {
                return;
            }

            RscStore store = new RscStore();

            store.CreateFolderPath("A:\\System\\AudioPlaybackAgent");
            store.WriteTextFile("A:\\System\\AudioPlaybackAgent\\CurrentTrack.txt", m_iCurrentTrack.ToString(), true);

            Play(player);
        }
Esempio n. 14
0
        public static void MarkOpenExternal(string sDomain, bool bMark)
        {
            RscStore store = new RscStore();

            string sFolder = "A:\\Internet\\UserAgents";

            store.CreateFolderPath(sFolder);

            if (bMark)
            {
                store.WriteTextFile(sFolder + "\\" + sDomain + "_OpenExternal" + ".txt", "", true);
            }
            else
            {
                if (store.FileExists(sFolder + "\\" + sDomain + "_OpenExternal" + ".txt"))
                {
                    store.DeleteFile(sFolder + "\\" + sDomain + "_OpenExternal" + ".txt");
                }
            }
        }
Esempio n. 15
0
        private void ReadPlaylist()
        {
            m_iCurrentTrack = 0;
            m_aTracks.Clear();

            RscStore store = new RscStore();

            store.CreateFolderPath("A:\\System\\AudioPlaybackAgent");

            bool   bPlNotExist;
            string sPl = store.ReadTextFile("A:\\System\\AudioPlaybackAgent\\Playlist.txt", "", out bPlNotExist);

            if (bPlNotExist)
            {
                return;
            }

            string [] astr = sPl.Split(new String [] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string str in astr)
            {
                string [] astrTi = str.Split('|');
                if (astrTi.Length == 3)
                {
                    MyTrack t = new MyTrack();

                    t.Album = astrTi[0];
                    t.Title = astrTi[1];
                    t.Path  = astrTi[2];

                    m_aTracks.Add(t);
                }
            }

            string sCt = store.ReadTextFile("A:\\System\\AudioPlaybackAgent\\CurrentTrack.txt", "0", out bPlNotExist);

            if (!Int32.TryParse(sCt, out m_iCurrentTrack))
            {
                m_iCurrentTrack = 0;
            }
        }
Esempio n. 16
0
        private void ClearAllSound( )
        {
            //MUST NOT!!!

            /*
             * Ressive.MediaEx.RscMediaEx.StopMusic();
             */
            BackgroundAudioPlayer.Instance.Close();

            m_sounds.Clear();

            // //
            //

            RscStore store = new RscStore();

            store.CreateFolderPath("A:\\System\\AudioPlaybackAgent");
            store.DeleteFile("A:\\System\\AudioPlaybackAgent\\Playlist.txt");
            store.DeleteFile("A:\\System\\AudioPlaybackAgent\\CurrentTrack.txt");

            //
            // //
        }
Esempio n. 17
0
        public int ReadThreadData()
        {
            RscStore store = new RscStore();

            store.CreateFolderPath(AppLogic.csSecretsFolder);

            string sPath      = AppLogic.csSecretsFolder + "\\" + "client_secret.json";
            bool   bNotExists = false;
            string sJSon      = store.ReadTextFile(sPath, "", out bNotExists);

            if (bNotExists)
            {
                return(-2);
            }

            string      sErr = "";
            RscJSonItem json = RscJSon.FromResponseContetn(sJSon, out sErr);

            if (sErr.Length > 0)
            {
                //Try to get values needed...
                //return -3;
            }

            m_sUserIDlast = store.ReadTextFile(AppLogic.csSecretsFolder + "\\" + "UserIDlast.txt", "");
            if (m_sUserIDlast.Length == 0)
            {
                return(-3);
            }

            // //
            //

            //if( gAuth == null )
            //{
            RscGoogleAuth gAuth = new RscGoogleAuth(json,
                                                    RscGoogleScopes.UserinfoEmail
                                                    + " " + RscGoogleScopes.UserinfoProfile
                                                    + " " + RscGoogleScopes.Gmail,
                                                    null); //webBrowser1 );

            gAuth.Authenticated        += new EventHandler(m_gAuth_Authenticated);
            gAuth.AuthenticationFailed += new EventHandler(m_gAuth_AuthenticationFailed);
            gAuth.ShowAuthPage         += new EventHandler(m_gAuth_ShowAuthPage);
            gAuth.ResponseReceived     += new Ressive.GoogleApi.RscGoogleAuth.ResponseReceived_EventHandler(m_gAuth_ResponseReceived);

            //bool bNotExists;
            gAuth.AuthResult = LoadAuthResult(out bNotExists);
            if (bNotExists)
            {
                return(-4);
            }
            //}

            //
            // //

            string sUriResource = "";
            string sBaseUrl     = GoogleUtils.GoogleRequestBaseUrl(GoogleRequest.GMail_Threads, out sUriResource, "me", "");

            if (sBaseUrl.Length == 0)
            {
                return(-5);
            }

            /*
             * Object oRes = null;
             * var taskHlp = Task.Run(async () => { oRes = await m_gAuth.SendRequestTask( sBaseUrl, sUriResource ); });
             * taskHlp.Wait();
             *
             * if( oRes == null )
             *      return -6;
             * else
             *      return oRes.ToString().Length;
             */

            //Task<Object> tsk = gAuth.SendRequestTask( sBaseUrl, sUriResource );
            //tsk.Wait();

            /*
             * int iRet = 0;
             * var taskHlp = Task.Run(async () => { iRet = await SendRequestTask( gAuth, sBaseUrl, sUriResource ); });
             * taskHlp.Wait();
             */

            /*
             * Task<Object> tsk = gAuth.SendRequestTask( sBaseUrl, sUriResource );
             * for(;;)
             * {
             *      if( tsk.IsCompleted )
             *              break;
             *
             *      //System.Threading.Tasks.Task.Delay(100).Wait();
             *
             *      MessageBox.Show( "Not complete..." );
             * }
             */

            try
            {
                gAuth.SendRequest(sBaseUrl, sUriResource);
            }
            catch (Exception)
            {
                return(-6);
            }

            return(0);
        }
        public void DoUpdate(bool bCalledByAgent, object oAgentParam)
        {
            RscStore.AddSysEvent(DateTime.Now.ToString(), false, "ShellTiles_DoUpdate");

            var tiles = ShellTile.ActiveTiles;

            string sDbg = "";

            string sStCntFldr = RscKnownFolders.GetTempPath("ShellTiles", "Content");

            foreach (ShellTile tile in tiles)
            {
                if (sDbg.Length > 0)
                {
                    sDbg += "\r\n";
                }
                sDbg += tile.NavigationUri.OriginalString;

                try
                {
                    StandardTileData updatedData = new StandardTileData();

                    int iPos = tile.NavigationUri.OriginalString.IndexOf("IcoId=");
                    if (iPos < 0)
                    {
                        continue;
                    }
                    iPos += 6;
                    string sIcoId = tile.NavigationUri.OriginalString.Substring(iPos);

                    iPos = tile.NavigationUri.OriginalString.IndexOf("IcoGd=");
                    if (iPos < 0)
                    {
                        continue;
                    }
                    iPos += 6;
                    int iPos2 = tile.NavigationUri.OriginalString.IndexOf('&', iPos);
                    if (iPos2 < 0)
                    {
                        continue;
                    }
                    iPos2--;
                    string sIcoGd = tile.NavigationUri.OriginalString.Substring(iPos, (iPos2 - iPos) + 1);

                    /*
                     * DateTime dNow = DateTime.Now;
                     * string sTm =     RscUtils.pad60(dNow.Hour) +
                     *                              ":" + RscUtils.pad60(dNow.Minute); // + ":" + RscUtils.pad60(dNow.Second);
                     *
                     * updatedData.Title = RscUtils.pad60(dNow.Day) + ". " + sTm;
                     */

                    Brush  brBk           = null;
                    Brush  brFore         = null;
                    double dFontSize      = 0;
                    string sErr           = "";
                    string sNotiTitle     = "";
                    string sNotiContent   = "";
                    string sNotiSound     = "";
                    string sInfoToChngChk = "";

                    string sInfo = GetInfo(true, sIcoId, out brBk, out brFore, out dFontSize,
                                           out sErr, out sNotiTitle, out sNotiContent, out sNotiSound,
                                           bCalledByAgent, oAgentParam, out sInfoToChngChk);

                    if (sInfo == "")
                    {
                        sInfo = "\n\n(N/A)";
                    }
                    if (brBk == null)
                    {
                        brBk = new SolidColorBrush(Color.FromArgb(255, 32, 32, 32));                                        //Colors.Black );
                    }
                    if (brFore == null)
                    {
                        brFore = new SolidColorBrush(Colors.White);
                    }
                    if (dFontSize > 0)
                    {
                        dFontSize = cdFontSize - cdFontSize_SmDiff;
                    }
                    else
                    {
                        dFontSize = cdFontSize;
                    }
                    if (sInfoToChngChk.Length == 0)
                    {
                        sInfoToChngChk = sInfo;
                    }
                    if (sErr.Length > 0)
                    {
                        sDbg += "\r\nERROR: " + sErr;
                    }

                    RscStore store = new RscStore();

                    // //
                    //

                    string sInfoToChngChk_Old = store.ReadTextFile(sStCntFldr + "\\" + sIcoGd + ".txt", "");
                    if (sInfoToChngChk_Old.CompareTo(sInfoToChngChk) != 0)
                    {
                        if (sNotiTitle.Length > 0 && sNotiContent.Length > 0)
                        {
                            string sUriSnd = sNotiSound;
                            if (sUriSnd.Length == 0)
                            {
                                sUriSnd = /*"/Lib_Rsc;component/" +*/ "Media/empty.mp3";
                            }

                            ShellToast_Wp80U3.ShowToast(sNotiTitle, sNotiContent,
                                                        new Uri(sUriSnd, UriKind.Relative));
                        }

                        store.WriteTextFile(sStCntFldr + "\\" + sIcoGd + ".txt", sInfoToChngChk, true);
                    }

                    //
                    // //
                    //

                    string sInfo_Old = store.ReadTextFile(sStCntFldr + "\\" + sIcoGd + "(full).txt", "");
                    if (sInfo_Old.CompareTo(sInfo) == 0)
                    {
                        sDbg += " " + sIcoId + "|" + sIcoGd + " (NO UPDATE, NO CHANGE)";
                        continue;                         //No change!!!
                    }

                    string sTileImgPath = "A:\\Shared\\ShellContent";
                    store.CreateFolderPath(sTileImgPath);
                    sTileImgPath += "\\" + sIcoGd + ".jpg";
                    store.DeleteFile(sTileImgPath);
                    RenderText(sInfo, sTileImgPath, brBk, brFore, dFontSize);

                    string sImgUriFinal = "isostore:/" + sTileImgPath.Substring(3).Replace('\\', '/');
                    updatedData.BackgroundImage = new Uri(sImgUriFinal, UriKind.Absolute);

                    tile.Update(updatedData);

                    sDbg += " " + sIcoId + "|" + sIcoGd + " (Updated)";

                    store.WriteTextFile(sStCntFldr + "\\" + sIcoGd + "(full).txt", sInfo, true);

                    //
                    // //
                }
                catch (Exception e)
                {
                    sDbg += "\r\nERROR: " + e.Message + "\r\n" + e.StackTrace;
                }
            }

            RscStore.AddSysEvent(sDbg, false, "ShellTiles_DoUpdate_List");
        }
Esempio n. 19
0
        private void m_btnInit_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            if (m_gAuth == null)
            {
                RscStore store = new RscStore();
                store.CreateFolderPath(csSecretsFolder);

                string sPath      = csSecretsFolder + "\\" + "client_secret.json";
                bool   bNotExists = false;
                string sJSon      = store.ReadTextFile(sPath, "", out bNotExists);
                if (bNotExists)
                {
                    MessageBox.Show("File " + sPath + " does not exists!"
                                    + "\n\n(NOTE: Drive A: reffers to Isolated Storage.)"
                                    + "\n\n(NOTE: You can download missing file from FTP Cloud. Press Tools button in Caption Bar.)");
                    return;
                }

                string      sErr = "";
                RscJSonItem json = RscJSon.FromResponseContetn(sJSon, out sErr);
                if (sErr.Length > 0)
                {
                    LogError(sErr);

                    //Try to get values needed...
                    //return;
                }

                //To see content of json...
                TreeLbItem tiJSon;
                tiJSon       = new TreeLbItem(m_aTI, null);
                tiJSon.Title = "client_secret.json";
                m_aTI.Add(tiJSon);
                tiJSon.SetResponse(json, false);

                bool bTmp;
                m_sUserIDlast = store.ReadTextFile(csSecretsFolder + "\\" + "UserIDlast.txt", "", out bTmp);


                // //
                //

                m_gAuth = new RscGoogleAuth(json,
                                            RscGoogleScopes.UserinfoEmail
                                            + " " + RscGoogleScopes.UserinfoProfile
                                            + " " + RscGoogleScopes.Gmail,
                                            webBrowser1);

                m_gAuth.Authenticated        += new EventHandler(m_gAuth_Authenticated);
                m_gAuth.AuthenticationFailed += new EventHandler(m_gAuth_AuthenticationFailed);
                m_gAuth.ShowAuthPage         += new EventHandler(m_gAuth_ShowAuthPage);
                m_gAuth.ResponseReceived     += new Ressive.GoogleApi.RscGoogleAuth.ResponseReceived_EventHandler(m_gAuth_ResponseReceived);

                m_gAuth.AuthResult = LoadAuthResult();

                //
                // //


                m_btnInit.Visibility = Rsc.Collapsed;

                m_btnExpandAll.Visibility   = Rsc.Visible;
                m_btnCollapseAll.Visibility = Rsc.Visible;

                //DO NOT!!!
                //m_btnLogOut.Visibility = Rsc.Visible;

                m_AppFrame.StatusText = "Initialized...";

                // //
                //

                TreeLbItem ti;

                ti    = new TreeLbItem(m_aTI, null);
                ti.gr = GoogleRequest.UserInfo;
                m_aTI.Add(ti);

                if (m_sUserIDlast.Length > 0)
                {
                    AddRootContainers();
                }

                //
                // //
            }
        }
        public void Create(string sPageNavTo, string sPageArgs, string sImage, string sStatus, string sIcoId = "")
        {
            RscStore store = new RscStore();

            Guid   gd       = Guid.NewGuid();
            string gdStr    = gd.ToString();
            string sPageUri = "/MainPage.xaml" + "?IcoGd=" + gdStr;

            if (sIcoId.Length > 0)
            {
                sPageUri += "&IcoId=" + sIcoId;
            }

            if (sIcoId.Length == 0)
            {
                string sStFldr = RscKnownFolders.GetTempPath("ShellTiles", "");
                store.WriteTextFile(sStFldr + "\\" + gdStr + ".txt", sPageNavTo + "\r\n" + sPageArgs, true);
            }
            else
            {
                //To make it enumerable...
                string sStFldr = RscKnownFolders.GetTempPath("ShellTiles", "");
                store.WriteTextFile(sStFldr + "\\" + gdStr + ".txt", sIcoId, true);
            }

            string sImageUri    = sImage;
            string sImgUriFinal = sImageUri;

            if (sImageUri.Length > 0)
            {
                string sTileImg = gdStr;
                if (sImageUri.IndexOf("isostore:\\") >= 0)
                {
                    sImageUri = sImageUri.Substring(10);
                    sTileImg += RscStore.ExtensionOfPath(sImageUri);
                }
                else
                {
                    sImageUri = sImageUri.Replace("Images/", "A:\\System\\Theme\\Current\\");
                    sImageUri = sImageUri.Replace(".jpg", ".png");
                    if (!store.FileExists(sImageUri))
                    {
                        sImageUri = sImageUri.Replace(".png", ".jpg");
                        sTileImg += ".jpg";
                    }
                    else
                    {
                        sTileImg += ".png";
                    }
                }

                string sTileImgPath = "A:\\Shared\\ShellContent";
                store.CreateFolderPath(sTileImgPath);
                sTileImgPath += "\\" + sTileImg;
                store.CopyFileForce(sImageUri, sTileImgPath);

                sImgUriFinal = "isostore:/" + sTileImgPath.Substring(3).Replace('\\', '/');
            }

            string sTitle = sStatus;

            if (sIcoId.Length > 0)
            {
                sTitle = "";

                Brush  brBk           = null;
                Brush  brFore         = null;
                double dFontSize      = 0;
                string sErr           = "";
                string sNotiTitle     = "";
                string sNotiContent   = "";
                string sNotiSound     = "";
                string sInfoToChngChk = "";

                string sInfo = GetInfo(true, sIcoId, out brBk, out brFore, out dFontSize,
                                       out sErr, out sNotiTitle, out sNotiContent, out sNotiSound,
                                       false, null, out sInfoToChngChk);

                if (sInfo == "")
                {
                    sInfo = "\n\n(N/A)";
                }
                if (brBk == null)
                {
                    brBk = new SolidColorBrush(Color.FromArgb(255, 32, 32, 32));                                    //Colors.Black );
                }
                if (brFore == null)
                {
                    brFore = new SolidColorBrush(Colors.White);
                }
                if (dFontSize > 0)
                {
                    dFontSize = cdFontSize - cdFontSize_SmDiff;
                }
                else
                {
                    dFontSize = cdFontSize;
                }
                if (sInfoToChngChk.Length == 0)
                {
                    sInfoToChngChk = sInfo;
                }

                //To update only if info has changed...
                string sStCntFldr = RscKnownFolders.GetTempPath("ShellTiles", "Content");
                store.WriteTextFile(sStCntFldr + "\\" + gdStr + ".txt", sInfo, true);

                string sTileImgPath = "A:\\Shared\\ShellContent";
                store.CreateFolderPath(sTileImgPath);
                sTileImgPath += "\\" + gdStr + ".jpg";
                store.DeleteFile(sTileImgPath);
                RenderText(sInfo, sTileImgPath, brBk, brFore, dFontSize);

                sImgUriFinal = "isostore:/" + sTileImgPath.Substring(3).Replace('\\', '/');
            }

            //MessageBox.Show( "Title: " + sTitle + "\r\n" + "NavTo: " + sPageUri + "\r\n" + "Image: " + sImageUri );

            StandardTileData initialData = new StandardTileData();

            {
                if (sImgUriFinal.Length > 0)
                {
                    initialData.BackgroundImage = new Uri(sImgUriFinal, UriKind.Absolute);
                }
                if (sTitle.Length > 0)
                {
                    initialData.Title = sTitle;
                }
            }
            ShellTile.Create(new Uri(sPageUri, UriKind.Relative), initialData);
        }
Esempio n. 21
0
        public FaviconViewer()
        {
            InitializeComponent();

            //MemUsage Optimization...
            Button GlobalDILholder = Application.Current.Resources["GlobalDIL"] as Button;

            m_Theme = (RscTheme)GlobalDILholder.Tag;
            //m_dil = new RscDefaultedImageList( "Theme", "Current", "Default" );

            RscStore store = new RscStore();

            store.CreateFolderPath(csDocFolder);

            //Building Palette...
            for (int y = 0; y < 16; y++)
            {
                for (int x = 0; x < 16; x++)
                {
                    System.Windows.Shapes.Rectangle rc = new System.Windows.Shapes.Rectangle();
                    rc.Name   = "clr" + toHexa(y, 1) + toHexa(x, 1);
                    rc.Width  = 4;
                    rc.Height = 4;
                    rc.Margin = new System.Windows.Thickness(4 * x, 4 * y, 0, 0);
                    rc.Fill   = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.White);

                    host.UI.imgPalette.Children.Add(rc);
                }
            }

            //Building Icon...
            for (int y = 0; y < 16; y++)
            {
                for (int x = 0; x < 16; x++)
                {
                    System.Windows.Shapes.Rectangle rc = new System.Windows.Shapes.Rectangle();
                    rc.Name   = "pix" + toHexa(x, 1) + toHexa(15 - y, 1);
                    rc.Width  = 4;
                    rc.Height = 4;
                    rc.Margin = new System.Windows.Thickness(4 * x, 4 * y, 0, 0);
                    rc.Fill   = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.White);

                    host.UI.imgIcon.Children.Add(rc);
                }
            }

            //Building Icon Sm...
            host.UI.imgIconSm.Background = new SolidColorBrush(m_Theme.ThemeColors.ThemeBack);
            int iCX = 16;
            int iCY = 16;

            for (int y = 0; y < 16; y++)
            {
                for (int x = 0; x < 16; x++)
                {
                    System.Windows.Shapes.Rectangle rc = new System.Windows.Shapes.Rectangle();
                    rc.Name   = "pixSm" + toHexa(x, 1) + toHexa(15 - y, 1);
                    rc.Width  = 2;
                    rc.Height = 2;
                    rc.Margin = new System.Windows.Thickness(iCX + (2 * x), iCY + (2 * y), 0, 0);
                    rc.Fill   = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.White);

                    host.UI.imgIconSm.Children.Add(rc);
                }
            }

            btnWebDog.Click += new System.Windows.RoutedEventHandler(btnWebDog_Click);
            btnSave.Click   += new System.Windows.RoutedEventHandler(btnSave_Click);
            btnGet.Click    += new System.Windows.RoutedEventHandler(btnGet_Click);
        }
Esempio n. 22
0
        public static bool VersionUpgrade(string sUserIDlast, bool bChkOnly)
        {
            RscStore store = new RscStore();

            string sFolder = AppLogic.csSecretsFolder + "\\" + sUserIDlast + "\\" + "Threads";

            int iOldVer = 0;

            if (!store.FolderExists(sFolder))
            {
                if (bChkOnly)
                {
                    return(true);                           //NOTHING stored yet...
                }
                store.CreateFolderPath(sFolder);
            }

            string sVersion = store.ReadTextFile(sFolder + "\\" + "Version.txt", "0");

            if (sVersion == ciCurrentVersion.ToString())
            {
                return(true);
            }

            if (bChkOnly)
            {
                return(false);
            }

            if (!Int32.TryParse(sVersion, out iOldVer))
            {
                iOldVer = 0;
            }

            // //
            //

            int iVer = iOldVer;

            for (;;)
            {
                if (iVer >= ciCurrentVersion)
                {
                    break;
                }

                switch (iVer)
                {
                case 0:
                case 100:
                case 101:
                {
                    string [] asIDs = store.GetFolderNames(sFolder, "*.*");

                    int iSubCntr = 0;

                    for (int i = 0; i < asIDs.Length; i++)
                    {
                        string sIdOrder = "";
                        sIdOrder = store.ReadTextFile(sFolder + "\\" + asIDs[i] + "\\" + "IdOrder" + ".txt", sIdOrder);
                        string [] asIdOrders = sIdOrder.Split('|');

                        iSubCntr += asIdOrders.Length;

                        string sId = asIdOrders[asIdOrders.Length - 1];

                        MyThread2 th = new MyThread2();
                        th = store.ReadXmlDataFile(sFolder + "\\" + asIDs[i] + "\\" + sId + ".xml", th);
                        if (th.ID.Length == 0)
                        {
                            return(false);                                    //FAIL!!!
                        }
                        string sTmp = "";

                        sTmp += th.DateSaved.Year.ToString();
                        sTmp += RscUtils.pad60(th.DateSaved.Month);
                        sTmp += RscUtils.pad60(th.DateSaved.Day);
                        sTmp += "_";
                        sTmp += RscUtils.pad60(th.DateSaved.Hour);
                        sTmp += RscUtils.pad60(th.DateSaved.Minute);
                        sTmp += RscUtils.pad60(th.DateSaved.Second);
                        sTmp += "_";
                        int iMs = th.DateSaved.Millisecond;
                        if (iMs < 10)
                        {
                            sTmp += "00";
                        }
                        else
                        {
                            if (iMs < 100)
                            {
                                sTmp += "0";
                            }
                        }
                        sTmp += iMs.ToString();

                        asIDs[i] = sTmp + "|" + asIDs[i];
                    }

                    asIDs = RscSort.OrderBy(asIDs, true);

                    /*
                     * StringBuilder sb = new StringBuilder();
                     */

                    string sRes = "";

                    foreach (string sID in asIDs)
                    {
                        /*
                         * sb.AppendLine( sID );
                         */

                        if (sRes.Length > 0)
                        {
                            sRes += "|";
                        }
                        sRes += sID.Substring(20);
                    }

                    /*
                     * sb.Append( "\r\n" );
                     * sb.Append( "Cntr: " + asIDs.Length.ToString() + "\r\n" );
                     * sb.Append( "Sub-Cntr: " + iSubCntr.ToString() + "\r\n" );
                     * store.WriteTextFile( "A:\\GMail.txt", sb.ToString(), true );
                     */

                    store.WriteTextFile(sFolder + "\\" + "IdOrder" + ".txt", sRes, true);

                    iVer = 102;

                    break;
                }

                //Denie endless loop...
                default:
                    iVer = ciCurrentVersion;
                    break;
                }

                store.WriteTextFile(sFolder + "\\" + "Version.txt", iVer.ToString(), true);
            }

            //
            // //

            return(true);
        }
Esempio n. 23
0
        private void DoExpCol(object sender)
        {
            Button     btn = (Button)sender;
            TreeLbItem ti  = (TreeLbItem)btn.Tag;

            if (ti.gr == GoogleRequest.None && (!ti.HasResponse))
            {
                return;                 //Nothing to load...
            }
            if (ti.Expanded)
            {
                ti.Collapse();
            }
            else
            {
                if (ti.HasResponse)
                {
                    ti.Expand();
                }
                else
                {
                    if (m_tiLoading != null)
                    {
                        MessageBox.Show("Load in progress!\n\nPlease wait...");
                        return;
                    }

                    string id = "";
                    if (ti.Parameters != null)
                    {
                        id = ti.Parameters.GetPropertyValue("id");
                    }
                    string sUriResource = "";
                    string sBaseUrl     = GoogleUtils.GoogleRequestBaseUrl(ti.gr, out sUriResource, "me", id);
                    if (sBaseUrl.Length == 0)
                    {
                        MessageBox.Show("No Request Url found!");
                        return;
                    }

                    bool bLoadedFromFile = false;
                    if (m_sUserIDlast.Length > 0)
                    {
                        string sPath = csSecretsFolder + "\\" + m_sUserIDlast;

                        RscStore store = new RscStore();
                        store.CreateFolderPath(sPath);

                        string sFn = Uri2FileName(sBaseUrl + sUriResource);
                        bool   bTmp;
                        string sJSon = store.ReadTextFile(sPath + "\\" + sFn + ".json", "", out bTmp);
                        if (sJSon.Length > 0)
                        {
                            DoLoad(ti, sJSon,
                                   sBaseUrl + sUriResource, "", false);

                            m_btnCleanUp.Visibility = Rsc.Visible;

                            bLoadedFromFile = true;
                        }
                    }

                    if (!bLoadedFromFile)
                    {
                        m_tiLoading         = ti;
                        m_tiLoading.Loading = true;

                        //VERY SLOW!!!
                        //m_aTI.Refresh();

                        m_gAuth.SendRequest(sBaseUrl, sUriResource);
                    }
                }
            }
        }
Esempio n. 24
0
        private void DoLoad(TreeLbItem ti, string sContent, string sID, string sDetails, bool bSaveJSon)
        {
            string      sErr     = "";
            RscJSonItem jsonRoot = null;

            /*
             * jsonRoot = new RscJSonItem();
             * jsonRoot.ID = response.ResponseUri.ToString();
             * jsonRoot.Name = "IRestResponse<Object>";
             * jsonRoot.AddProperty( "Response Status", response.ResponseStatus.ToString() );
             * jsonRoot.AddProperty( "Response Uri", response.ResponseUri.ToString() );
             * jsonRoot.AddProperty( "Content Length", response.ContentLength.ToString() );
             */
            jsonRoot = RscJSon.FromResponseContetn(jsonRoot, sContent, out sErr, sID, sDetails);
            if (sErr.Length > 0)
            {
                LogError(sErr);
            }

            if (jsonRoot != null)
            {
                // //
                //

                string sErrorCode = "";
                if (jsonRoot.ChildCount > 0)
                {
                    if (jsonRoot.GetChild(0).Name == "error")
                    {
                        //For example: Required Scope not specified while LogOn!!!

                        sErrorCode = jsonRoot.GetChildPropertyValue(0, "code");
                        string sErrorMessage = jsonRoot.GetChildPropertyValue(0, "message");

                        LogError("Error response:\ncode: " + sErrorCode + "\nmessage: " + sErrorMessage);
                    }
                }

                //
                // //

                //Show Error JSon!!!
                //if( sErrorCode.Length == 0 )
                {
                    //Try to load result as is...
                    GoogleRequest gr = GoogleUtils.GoogleRequestFromUrl(jsonRoot.ID);

                    switch (gr)
                    {
                    case GoogleRequest.UserInfo:
                    case GoogleRequest.GMail_Messages:
                    case GoogleRequest.GMail_Message_Details:
                    case GoogleRequest.GMail_Labels:
                    case GoogleRequest.GMail_Threads:
                    case GoogleRequest.GMail_History:
                    case GoogleRequest.GMail_Drafts:
                    {
                        ti.SetResponse(jsonRoot);

                        RscStore store = new RscStore();

                        if (gr == GoogleRequest.UserInfo)
                        {
                            string sUserID = jsonRoot.GetPropertyValue("id");

                            if (m_sUserIDlast.Length == 0 || m_sUserIDlast != sUserID)
                            {
                                if (sUserID.Length > 0)
                                {
                                    m_sUserIDlast = sUserID;
                                    store.WriteTextFile(csSecretsFolder + "\\" + "UserIDlast.txt", m_sUserIDlast, true);

                                    AddRootContainers();
                                }
                            }
                        }

                        string sPath = "";
                        string sFn   = "";
                        if (m_sUserIDlast.Length > 0)
                        {
                            sPath = csSecretsFolder + "\\" + m_sUserIDlast;
                            sFn   = Uri2FileName(jsonRoot.ID);
                        }
                        if (bSaveJSon)
                        {
                            if (m_sUserIDlast.Length > 0)
                            {
                                store.CreateFolderPath(sPath);

                                store.WriteTextFile(sPath + "\\" + sFn + ".json", sContent, true);

                                m_btnCleanUp.Visibility = Rsc.Visible;
                            }
                        }

                        if (sErr.Length == 0)
                        {
                            if (sFn.Length > 0)
                            {
                                if (bSaveJSon)
                                {
                                    m_AppFrame.StatusText = "Downloaded to " + sPath + "\\" + sFn + ".json";
                                }
                                else
                                {
                                    m_AppFrame.StatusText = "Loaded from " + sPath + "\\" + sFn + ".json";
                                }
                            }
                            else
                            {
                                if (bSaveJSon)
                                {
                                    m_AppFrame.StatusText = "Downloaded...";
                                }
                                else
                                {
                                    m_AppFrame.StatusText = "Loaded...";
                                }
                            }
                        }

                        break;
                    }

                    default:
                    {
                        //Unexpected...
                        LogError(jsonRoot.ToDecoratedString());
                        break;
                    }
                    }
                }
            }
        }
Esempio n. 25
0
        private void m_btnLogOut_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            if (MessageBoxResult.OK != MessageBox.Show("Do you really want to log out\nand to delete all saved response files (.json)\nand browser chache?\n\n(Press Back to Cancel...)"))
            {
                return;
            }

            // //
            //

            logGrid.Visibility = Rsc.Collapsed;

            m_aTI.CollapseAll(true);

            //
            // //
            //

            m_gAuth.Logout();

            RscStore store = new RscStore();

            store.CreateFolderPath(csSecretsFolder);
            //Otherwise able to logon on next run...
            store.DeleteFile(csSecretsFolder + "\\" + "AUTH.xml");

            //
            // //
            //

            //NOTE: Deleting all IE folders WILL NOT force the user to reenter eMail + Pw!!!

            string sIeCacheFolders = ";" + RscStore_IsoStore.Get_IE_Cache_FolderList(';');

            sIeCacheFolders = sIeCacheFolders.Replace(";", ";A:\\");

            //
            // //
            //

            if (m_sUserIDlast.Length > 0)
            {
                RscPageArgsRet appInput = new RscPageArgsRet(m_AppArgs,
                                                             m_AppFrame.AppTitle, m_AppFrame.AppIconRes, "LogOut");

                appInput.SetData(0, csSecretsFolder + "\\" + m_sUserIDlast + sIeCacheFolders);
                appInput.SetData(1, "*.*");
                appInput.SetData(2, "recurse");
                //appInput.SetData( 2, "" );

                appInput.SetData(3, "showHidden");
                //appInput.SetData( 3, "" );

                appInput.SetData(4, "AutoDelete");

                appInput.SetInput("RscViewer_FindFilesV12");

                this.NavigationService.Navigate(appInput.GetNavigateUri(csViewersAssy));
            }

            //
            // //
        }
Esempio n. 26
0
        private void DoExpColItem(TreeLbItem ti)
        {
            if (ti.gr == GoogleRequest.None && (!ti.HasResponse))
            {
                if (ti.Expanded)
                {
                    ti.Collapse();
                }
                else if (!ti.IsLeaf && !ti.IsDetailsOnly)
                {
                    if (ti.sID == csVerUp)
                    {
                        if (m_tiLoading != null)
                        {
                            MessageBox.Show("Load in progress!\n\nPlease wait...");
                            return;
                        }

                        m_tiLoading         = ti;
                        m_tiLoading.Loading = true;

                        m_AppFrame.StartTimer(csVerUp, LayoutRoot, 1, 0, false);
                    }
                    else if (ti.sID == csMoreItems)
                    {
                        int iStartIndex = Int32.Parse(ti.sHistoryID);

                        string sPath = AppLogic.csSecretsFolder + "\\" + m_sUserIDlast;
                        ShowSavedThreadData(sPath, iStartIndex, ti);
                    }
                    else
                    {
                        ti.Expand();
                    }
                }

                return;                 //Nothing to load...
            }

            if (ti.Expanded)
            {
                ti.Collapse();
            }
            else
            {
                if (ti.HasResponse)
                {
                    ti.Expand();
                }
                else
                {
                    if (m_tiLoading != null)
                    {
                        MessageBox.Show("Load in progress!\n\nPlease wait...");
                        return;
                    }

                    string id = "";
                    if (ti.Parameters != null)
                    {
                        id = ti.Parameters.GetPropertyValue("id");
                    }
                    string sUriResource = "";
                    string sBaseUrl     = GoogleUtils.GoogleRequestBaseUrl(ti.gr, out sUriResource, "me", id);
                    if (sBaseUrl.Length == 0)
                    {
                        MessageBox.Show("No Request Url found!");
                        return;
                    }

                    bool bLoadedFromFile = false;
                    if (m_sUserIDlast.Length > 0)
                    {
                        if (ti.gr != GoogleRequest.GMail_Threads)
                        {
                            string sPath = AppLogic.csSecretsFolder + "\\" + m_sUserIDlast;

                            RscStore store = new RscStore();
                            store.CreateFolderPath(sPath);

                            string sFn = Uri2FileName(sBaseUrl + sUriResource);
                            bool   bTmp;
                            string sJSon = store.ReadTextFile(sPath + "\\" + sFn + ".json", "", out bTmp);
                            if (sJSon.Length > 0)
                            {
                                bool bTmp2;
                                DoLoad(ti, sJSon,
                                       sBaseUrl + sUriResource, "", false, out bTmp2);

                                m_btnCleanUp.Visibility = Rsc.Visible;

                                bLoadedFromFile = true;
                            }
                        }
                    }

                    if (!bLoadedFromFile)
                    {
                        if (ti.gr == GoogleRequest.GMail_Threads)
                        {
                            m_tiSum = null;
                            m_aTI.RemoveAll(ti);
                        }

                        m_tiLoading         = ti;
                        m_tiLoading.Loading = true;

                        //VERY SLOW!!!
                        //m_aTI.Refresh();

                        m_gAuth.SendRequest(sBaseUrl, sUriResource);
                    }
                }
            }
        }
Esempio n. 27
0
        private void Calc()
        {
            cntout.Text  = "...";
            cntout2.Text = "...";
            cntout3.Text = "...";

            try
            {
                int iY = Int32.Parse(dtin_y.Text);
                int iM = Int32.Parse(dtin_m.Text);
                int iD = Int32.Parse(dtin_d.Text);

                DateTime dtNow = DateTime.Now;

                DateTime d1 = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day);
                DateTime d2 = new DateTime(iY, iM, iD);

                TimeSpan ts    = d2 - d1;
                int      iDays = Math.Max(1, (int)Math.Round(ts.TotalDays, 0));

                double dAmo = 0;
                if (amo.Text.Length > 0)
                {
                    dAmo = double.Parse(amo.Text);
                }

                string   sPath = "A:\\Documents\\PerDay";
                RscStore store = new RscStore();
                store.CreateFolderPath(sPath);

                if (dAmo != 0)
                {
                    int iRes = (int)Math.Round(dAmo / iDays, 0);

                    cntout.Text = iRes.ToString();
                    if (unt.Text.Length > 0)
                    {
                        cntout.Text += " " + unt.Text;
                    }

                    cntout2.Text = Math.Max(0, (int)Math.Round(ts.TotalDays, 0)).ToString();

                    ////
                    //

                    string sInf = "";
                    switch (d2.DayOfWeek)
                    {
                    case DayOfWeek.Monday: sInf += "Hétfő"; break;

                    case DayOfWeek.Tuesday: sInf += "Kedd"; break;

                    case DayOfWeek.Wednesday: sInf += "Szerda"; break;

                    case DayOfWeek.Thursday: sInf += "Csütörtök"; break;

                    case DayOfWeek.Friday: sInf += "Péntek"; break;

                    case DayOfWeek.Saturday: sInf += "Szombat"; break;

                    case DayOfWeek.Sunday: sInf += "Vasárnap"; break;
                    }

                    sInf += ", " + RscUtils.pad60(RscUtils.WeekOfYearHU(d2)) + ". hét";

                    cntout3.Text = sInf;

                    //
                    ////

                    string sCnt = iY.ToString() + "|"
                                  + iM.ToString() + "|"
                                  + iD.ToString() + "|"
                                  + dAmo.ToString() + "|"
                                  + unt.Text;

                    store.WriteTextFile(sPath + "\\" + "Default.txt", sCnt, true);
                }
                else
                {
                    cntout.Text = "";

                    store.DeleteFile(sPath + "\\" + "Default.txt");
                }
            }
            catch (Exception)
            {
                cntout.Text = "<error>";
            }
        }
Esempio n. 28
0
        private SoundInfo AddSound(string sPath)
        {
            string sExt    = "N/A";
            string sTitle  = "N/A";
            string sFolder = "";

            int iPosDot = sPath.LastIndexOf('.');

            if (iPosDot >= 0)
            {
                sExt = sPath.Substring(iPosDot + 1);
            }
            else
            {
                iPosDot = sPath.Length;
                sExt    = "<NONE>";
            }

            int iPosBs = sPath.LastIndexOf('\\');

            if (iPosBs >= 0)
            {
                if (iPosBs < 0)
                {
                    iPosBs = -1;
                }
                sTitle = sPath.Substring(iPosBs + 1, (iPosDot - iPosBs) - 1);

                if (iPosBs > 0)
                {
                    sFolder = sPath.Substring(0, iPosBs);
                }
            }

            SoundInfo snd = new SoundInfo();

            snd.Path = sPath;

            snd.FileType  = "\r\n" + sExt.ToUpper();
            snd.FileTitle = sTitle;
            snd.sFolder   = sFolder;

            snd.SoundState = MediaElementState.Closed;

            snd.Parent = m_sounds;
            m_sounds.Add(snd);

            // //
            //

            RscStore store = new RscStore();

            store.CreateFolderPath("A:\\System\\AudioPlaybackAgent");

            bool   bPlNotExist;
            string sPl = store.ReadTextFile("A:\\System\\AudioPlaybackAgent\\Playlist.txt", "", out bPlNotExist);

            if (sPl.Length > 0)
            {
                sPl += "\r\n";
            }
            sPl += sFolder + "|" + sTitle + "|" + sPath;
            store.WriteTextFile("A:\\System\\AudioPlaybackAgent\\Playlist.txt", sPl, true);

            if (bPlNotExist)
            {
                store.WriteTextFile("A:\\System\\AudioPlaybackAgent\\CurrentTrack.txt", "0", true);
            }

            //
            // //

            return(snd);
        }
Esempio n. 29
0
        public static int SaveThreadData(bool bCalledByAgent, string sPath, RscJSonItem jsonThreads)
        {
            RscJSonItem json = jsonThreads.GetChildByName("threads");

            if (json == null)
            {
                return(-200);
            }

            RscStore store = new RscStore();

            bool bFirstRun = false;

            sPath += "\\Threads";
            if (!store.FolderExists(sPath))
            {
                bFirstRun = true;

                store.CreateFolderPath(sPath);
                store.WriteTextFile(sPath + "\\" + "Version.txt", ciCurrentVersion.ToString(), true);
            }

            string sThreadIdOrder_OLD = "";

            sThreadIdOrder_OLD  = store.ReadTextFile(sPath + "\\" + "IdOrder" + ".txt", sThreadIdOrder_OLD);
            sThreadIdOrder_OLD += "|";             //ATTENTION!!! 1 of 2
            string sThreadIdOrder_NEW = "";

            int iJustAdded = 0;

            int iThCnt = json.ChildCount;

            for (int iTh = 0; iTh < iThCnt; iTh++)
            {
                RscJSonItem jsonTh = json.GetChild(iTh);

                string sID        = jsonTh.GetPropertyValue("id");
                string sHistoryID = jsonTh.GetPropertyValue("historyId");
                string sSnippet   = jsonTh.GetPropertyValue("snippet");                 //, true );

                if (sID.Length == 0 || sHistoryID.Length == 0 || sSnippet.Length == 0)
                {
                    continue;
                }

                store.CreateFolderPath(sPath + "\\" + sID);

                if (store.FileExists(sPath + "\\" + sID + "\\" + sHistoryID + ".xml"))
                {
                    //Threads arrives in reverse order, so...
                    break;
                }
                else
                {
                    sThreadIdOrder_OLD = sThreadIdOrder_OLD.Replace(sID + "|", "");                       //Removing ID
                    if (sThreadIdOrder_NEW.Length > 0)
                    {
                        sThreadIdOrder_NEW += "|";
                    }
                    sThreadIdOrder_NEW += sID;                     //Adding ID

                    string sIdOrder = "";
                    sIdOrder = store.ReadTextFile(sPath + "\\" + sID + "\\" + "IdOrder" + ".txt", "");

                    iJustAdded++;

                    MyThread2 th = new MyThread2();
                    th.ID        = sID;
                    th.HistoryID = sHistoryID;
                    th.Snippet   = sSnippet;

                    if (bFirstRun)
                    {
                        th.DateAcked = DateTime.Now;
                    }

                    store.WriteXmlDataFile(sPath + "\\" + sID + "\\" + sHistoryID + ".xml", th, true);

                    if (sIdOrder.Length > 0)
                    {
                        sIdOrder = "|" + sIdOrder;
                    }
                    sIdOrder = sHistoryID + sIdOrder;
                    store.WriteTextFile(sPath + "\\" + sID + "\\" + "IdOrder" + ".txt", sIdOrder, true);
                }
            }

            if (sThreadIdOrder_OLD.Length > 0)
            {
                //ATTENTION!!! 2 of 2
                sThreadIdOrder_OLD = sThreadIdOrder_OLD.Substring(0, sThreadIdOrder_OLD.Length - 1);
            }
            if (sThreadIdOrder_NEW.Length > 0 && sThreadIdOrder_OLD.Length > 0)
            {
                sThreadIdOrder_NEW += "|";
            }
            sThreadIdOrder_NEW += sThreadIdOrder_OLD;
            store.WriteTextFile(sPath + "\\" + "IdOrder" + ".txt", sThreadIdOrder_NEW, true);

            int iCountAll = 0;

            iCountAll  = store.ReadXmlDataFile(sPath + "\\" + "Count" + ".xml", iCountAll);
            iCountAll += iJustAdded;
            store.WriteXmlDataFile(sPath + "\\" + "Count" + ".xml", iCountAll, true);

            int iCount_NonAckAll = 0;

            iCount_NonAckAll = store.ReadXmlDataFile(sPath + "\\" + "Count_NonAck" + ".xml", iCount_NonAckAll);
            if (!bFirstRun)
            {
                iCount_NonAckAll += iJustAdded;
            }
            store.WriteXmlDataFile(sPath + "\\" + "Count_NonAck" + ".xml", iCount_NonAckAll, true);

            int iCount_NEW = 0;

            iCount_NEW = store.ReadXmlDataFile(sPath + "\\" + "Count_NEW" + ".xml", iCount_NEW);
            if (bCalledByAgent)
            {
                iCount_NEW += iJustAdded;
            }
            else if (bFirstRun)
            {
                iCount_NEW = 0;
            }
            else
            {
                iCount_NEW = 0;
            }
            store.WriteXmlDataFile(sPath + "\\" + "Count_NEW" + ".xml", iCount_NEW, true);

            return(iJustAdded);
        }
        private void btnEx_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            if (m_tags == null)
            {
                return;
            }
            switch (m_tags.GetType().ToString())
            {
            case "Ressive.Formats.RscTextTags_VCF":
            {
                RscStore store = new RscStore();

                store.CreateFolderPath("A:\\Desktop\\Contacts\\tn");

                string sPath   = "A:\\Desktop\\Contacts\\" + ((RscTextTags_VCF)m_tags).Name + ".txt";
                string sPathTn = "A:\\Desktop\\Contacts\\tn\\" + ((RscTextTags_VCF)m_tags).Name + ".txt.jpg";

                if (store.FileExists(sPath))
                {
                    store.DeleteFile(sPath);
                    store.DeleteFile(sPathTn);

                    btnEx.Content        = "Add to Desktop";
                    BtnGridEx.Background = new SolidColorBrush(Colors.Green);
                }
                else
                {
                    try
                    {
                        store.WriteTextFile(sPath, m_aPathes[m_iIndex], true);

                        if (((RscTextTags_VCF)m_tags).PhotoPresent &&
                            ((RscTextTags_VCF)m_tags).PhotoIsBase64 &&
                            ((RscTextTags_VCF)m_tags).PhotoIs("JPEG"))
                        {
                            string sBase64 = ((RscTextTags_VCF)m_tags).PhotoData;

                            //RscFs.WriteTextFile( "vcf.photo.txt", sBase64, true );

                            byte [] ayImage = Convert.FromBase64String(sBase64);

                            if (store.FileExists(sPathTn))
                            {
                                store.DeleteFile(sPathTn);
                            }

                            if (ayImage != null)
                            {
                                if (ayImage.Length > 0)
                                {
                                    System.IO.Stream stream = store.CreateFile(sPathTn);
                                    stream.Write(ayImage, 0, ayImage.Length);
                                    stream.Close();
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("ERROR: Unable to create Desktop icon for Contact!");
                        return;
                    }

                    btnEx.Content        = "Remove from Desktop";
                    BtnGridEx.Background = new SolidColorBrush(Colors.Red);
                }

                MessageBox.Show("NOTE: To take into effect, restart application!");

                break;
            }

            default:
                MessageBox.Show("No action defined!");
                break;
            }
        }