void listKeys()
        {
            var coll = host.createCollection();

            RscStore store = new RscStore();

            string[] fles = RscSort.OrderBy(store.GetFileNames(csDocFolder, "*.txt"));
            foreach (string sFle in fles)
            {
                /*
                 * string strFileGroup = RscRegFs.GetFileGroup( RscFs.ExtensionOfPath(sFle) );
                 * switch( strFileGroup )
                 * {
                 *      case "Text" :
                 *      {
                 */
                var item = host.createBindableObject();

                item.ObjectA = RscStore.FileNameOfPath(sFle);
                item.ObjectB = csDocFolder + "\\" + sFle;

                coll.Add(item);

                /*
                 *              break;
                 *      }
                 * }
                 */
            }

            host.UI.lbTit.ItemsSource       = coll;
            host.UI.lbTit.DisplayMemberPath = "ObjectA";
        }
        public static void CleanUpShellTileData( )
        {
            string sStFldr    = RscKnownFolders.GetTempPath("ShellTiles", "");
            string sStCntFldr = RscKnownFolders.GetTempPath("ShellTiles", "Content");
            string sScFldr    = "A:\\Shared\\ShellContent";

            RscStore store = new RscStore();

            string[] fles = store.GetFileNames(sStFldr, "*.txt");

            foreach (string fle in fles)
            {
                string sGd = RscStore.FileNameOfPath(fle);

                ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("IcoGd=" + sGd));
                if (TileToFind != null)
                {
                    continue;
                }

                store.DeleteFile(sStFldr + "\\" + sGd + ".txt");
                store.DeleteFile(sStCntFldr + "\\" + sGd + ".txt");

                if (store.FolderExists(sScFldr))
                {
                    store.DeleteFile(sScFldr + "\\" + sGd + ".jpg");
                    store.DeleteFile(sScFldr + "\\" + sGd + ".png");
                }
            }
        }
        private void doRefresh()
        {
            spFiles.Children.Clear();
            sEml = "";

            RscStore store = new RscStore();

            string[] fles = RscSort.OrderBy(store.GetFileNames(csDocFolder, "*.txt"));
            foreach (string sFle in fles)
            {
                bool   bTmp;
                string sTx = store.ReadTextFile(csDocFolder + "\\" + sFle, "", out bTmp);
                if (sTx.Length > 0)
                {
                    addDate(csDocFolder + "\\" + sFle, sTx, RscStore.FileNameOfPath(sFle));
                }
            }
        }
        private void listKeys()
        {
            var coll = host.createCollection();

            RscStore store = new RscStore();

            string[] fles = RscSort.OrderBy(store.GetFileNames(csDocFolder, "*.txt"));
            foreach (string sFle in fles)
            {
                NoteEditor_coll_item item = host.createBindableObject();

                item.ObjectA = RscStore.FileNameOfPath(sFle);
                item.ObjectB = csDocFolder + "\\" + sFle;

                coll.Add(item);
            }

            host.UI.lbTit.ItemsSource       = coll;
            host.UI.lbTit.DisplayMemberPath = "ObjectA";
        }
        public override void Parse(string sFileGroupPre, bool bListFoldersToo, bool bReverseOrder)
        {
            Clear();

            RscStore store = new RscStore();

            if (bListFoldersToo)
            {
                string[]           fldrsAll = RscSort.OrderBy(store.GetFolderNames(FullPath, "*.*"), bReverseOrder);
                RscStoreItemFolder oFolder;
                foreach (string fldr in fldrsAll)
                {
                    oFolder = new RscStoreItemFolder(fldr);
                    AddItem(oFolder);
                }
            }

            string[] flesAll = RscSort.OrderBy(store.GetFileNames(FullPath, "*.*"), bReverseOrder);

            int              iPos;
            string           sExt;
            string           sFileGroup;
            RscStoreItemFile oFile;

            foreach (string fle in flesAll)
            {
                iPos = fle.LastIndexOf('.');
                if (iPos >= 0)
                {
                    sExt       = fle.Substring(iPos);
                    sFileGroup = RscRegFs.GetFileGroupEx(sExt);
                    if (sFileGroupPre.Length == 0 || sFileGroup.IndexOf(sFileGroupPre) == 0)
                    {
                        oFile = new RscStoreItemFile(fle.Substring(0, iPos), sExt, sFileGroup);
                        AddItem(oFile);
                    }
                }
            }
        }
Example #6
0
        private void BuildList()
        {
            // //
            //

            m_strThemeFolder = RscKnownFolders.GetSystemPath("Theme");

            RscStore store = new RscStore();

            string[] fldrs  = RscSort.OrderBy(store.GetFolderNames(m_strThemeFolder, "*.*"));
            string   sFldrs = "Default";

            foreach (string fldr in fldrs)
            {
                switch (fldr)
                {
                case "Current":
                case "Default":
                    //Special folders...
                    break;

                default:
                {
                    string sPathPre   = m_strThemeFolder + "\\" + fldr + "\\" + "Theme";
                    bool   bFullTheme = false;

                    //There are WallPaper only folders!!!
                    if (store.FileExists(sPathPre + ".png"))
                    {
                        bFullTheme = true;
                    }
                    if (store.FileExists(sPathPre + ".jpg"))
                    {
                        bFullTheme = true;
                    }

                    if (bFullTheme)
                    {
                        sFldrs += "|" + fldr;
                    }

                    break;
                }
                }
            }
            fldrs = sFldrs.Split('|');

            //
            // //
            //

            var listOfImageResources = new StringBuilder();

            //var asm = Assembly.GetExecutingAssembly();
            //MessageBox.Show( asm.FullName );
            //
            // NOT WORKS: //var asm = Assembly.LoadFrom("RscLib.dll");
            //var asm = Assembly.Load("Microsoft.Phone.Media.Extended, Version=7.0.0.0, Culture=neutral, PublicKeyToken=24eec0d8c86cda1e");
            var asm = Assembly.Load("Lib_Rsc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");

            var mrn = asm.GetManifestResourceNames();

            foreach (var resource in mrn)
            {
                var rm = new ResourceManager(resource.Replace(".resources", ""), asm);

                try
                {
                    var NOT_USED = rm.GetStream("app.xaml");                     // without getting a stream, next statement doesn't work - bug?

                    var rs = rm.GetResourceSet(Thread.CurrentThread.CurrentUICulture, false, true);

                    var enumerator = rs.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        if (enumerator.Key.ToString().StartsWith("images/"))
                        {
                            listOfImageResources.AppendLine(
                                RscEncode.UrlEncodingToString(enumerator.Key.ToString())
                                );
                        }
                    }
                }
                catch (MissingManifestResourceException)
                {
                    // Ignore any other embedded resources (they won't contain app.xaml)
                }
            }

            string str = listOfImageResources.ToString();

            string [] astrDelims = new String [1];
            astrDelims[0] = "\r\n";
            string [] astrKeys = RscSort.OrderBy(str.Split(astrDelims, StringSplitOptions.RemoveEmptyEntries));

            //
            // //
            //

            int iCount = astrKeys.Length;

            for (int i = -1; i < iCount; i++)
            {
                string sImage;

                if (i == -1)
                {
                    sImage = "Theme";
                }
                else
                {
                    string sTmp  = astrKeys[i];
                    int    iPos1 = sTmp.LastIndexOf('/');
                    if (iPos1 < 0)
                    {
                        iPos1 = -1;
                    }
                    int iPos2 = sTmp.LastIndexOf('.');
                    if (iPos2 < 0)
                    {
                        iPos2 = sTmp.Length;
                    }
                    sImage = sTmp.Substring(iPos1 + 1, iPos2 - (iPos1 + 1));
                }

                string [] astrFldrLst;
                string    sName;
                int       iPos;

                Theme thm = new Theme();
                m_a.Add(thm);
                foreach (string fldr in fldrs)
                {
                    ThemeImg thmimg = new ThemeImg(fldr, sImage);
                    thm.m_a.Add(thmimg);

                    string sPath;
                    sPath = m_strThemeFolder + "\\" + thmimg.Name + "\\" + thmimg.Image + ".png";
                    if (store.FileExists(sPath))
                    {
                        astrFldrLst = store.GetFileNames(m_strThemeFolder + "\\" + thmimg.Name, thmimg.Image + ".png");
                        sName       = "";
                        if (astrFldrLst.Length == 1)
                        {
                            sName = astrFldrLst[0];
                        }
                        if (sName.Length > 0)
                        {
                            iPos = sName.LastIndexOf('.');
                            if (iPos >= 0)
                            {
                                //FIX: Orig value of thmimg.Image (Key) is LOWERCASE!!!
                                thmimg.Image = sName.Substring(0, iPos);
                                sPath        = m_strThemeFolder + "\\" + thmimg.Name + "\\" + sName;
                            }
                        }

                        thmimg.FullPath = sPath;
                    }
                    else
                    {
                        sPath = m_strThemeFolder + "\\" + thmimg.Name + "\\" + thmimg.Image + ".jpg";
                        if (store.FileExists(sPath))
                        {
                            astrFldrLst = store.GetFileNames(m_strThemeFolder + "\\" + thmimg.Name, thmimg.Image + ".jpg");
                            sName       = "";
                            if (astrFldrLst.Length == 1)
                            {
                                sName = astrFldrLst[0];
                            }
                            if (sName.Length > 0)
                            {
                                iPos = sName.LastIndexOf('.');
                                if (iPos >= 0)
                                {
                                    //FIX: Orig value of thmimg.Image (Key) is LOWERCASE!!!
                                    thmimg.Image = sName.Substring(0, iPos);
                                    sPath        = m_strThemeFolder + "\\" + thmimg.Name + "\\" + sName;
                                }
                            }

                            thmimg.FullPath = sPath;
                        }
                        else
                        {
                            thmimg.FullPath = "";                             //Not found...
                        }
                    }
                }
            }

            //
            // //
            //

            if (m_a.Count == 0)
            {
                m_iCX = 0;
            }
            else
            {
                m_iCX = m_a[0].m_a.Count;
            }

            //
            // //
        }
        private void m_AppFrame_OnTimer(object sender, RscAppFrameTimerEventArgs e)
        {
            switch (e.Reason)
            {
            case "list files_Cancel":
            {
                m_folders.Clear();
                m_files.Clear();
                m_AppFrame.SetStatusText("User canceled operation!", StatusColoring.Error);
                break;
            }

            case "list files":
            {
                string sFileFilter = txFilter.Text;
                if (sFileFilter.Length == 0)
                {
                    sFileFilter = "*.*";
                }
                sFileFilter = sFileFilter.Replace("\\", "");
                sFileFilter = sFileFilter.Replace("/", "");
                sFileFilter = sFileFilter.Replace(":", "");
                sFileFilter = sFileFilter.Replace(('"').ToString(), "");
                sFileFilter = sFileFilter.Replace("<", "");
                sFileFilter = sFileFilter.Replace(">", "");
                sFileFilter = sFileFilter.Replace("|", "");

                RscFileItemDesc itCurrent;
                RscFileItemDesc it;

                RscStore store = new RscStore();

                itCurrent = m_folders[e.Pos];

                if (!itCurrent.bWalked)
                {
                    if (chbRecurse.IsChecked.Value)
                    {
                        string[] fldrs = RscSort.OrderBy(store.GetFolderNames(itCurrent.Path, "*.*", chbShowHidden.IsChecked.Value));
                        foreach (string node in fldrs)
                        {
                            it = new RscFileItemDesc(m_AppFrame.Theme);

                            it.bFolder = true;
                            it.bWalked = false;

                            it.strParent   = itCurrent.Path;
                            it.strFileName = node;

                            e.Max++;
                            it.Parent = m_folders;
                            m_folders.Add(it);
                        }
                    }

                    itCurrent.bWalked = true;

                    if (e.Pos == e.Max)
                    {
                        e.Pos = 0;
                    }
                }
                else
                {
                    if (itCurrent.LastError.Length == 0)                              //Otherwise Not Exist!!!
                    {
                        string[] fles = RscSort.OrderBy(store.GetFileNames(itCurrent.Path, sFileFilter, chbShowHidden.IsChecked.Value));
                        foreach (string node in fles)
                        {
                            it = new RscFileItemDesc(m_AppFrame.Theme);

                            it.bFolder = false;
                            it.bWalked = false;

                            it.strParent   = itCurrent.Path;
                            it.strFileName = node;

                            it.Parent = m_files;
                            m_files.Add(it);
                        }
                    }

                    if (e.Pos == e.Max)
                    {
                        //ReQuery...
                        lbFiles.ItemsSource = null;
                        lbFiles.ItemsSource = m_files;

                        btnRename.Visibility = Rsc.ConditionalVisibility(m_files.Count == 1 && m_folders.Count == 1);
                        imgRename.Visibility = btnRename.Visibility;
                        //
                        ActionPanel.Visibility = Rsc.ConditionalVisibility(
                            (m_files.Count > 0 || m_txtRootFldr.Text.Length > 0) && m_folders[0].LastError.Length == 0);
                        m_btnDelete.Visibility = Rsc.ConditionalVisibility(
                            (m_files.Count > 0 || m_folders.Count > 0 /*|| m_txtRootFldr.Text.Length > 0*/) && m_folders[0].LastError.Length == 0);
                        //
                        btnCopy.Visibility = Rsc.ConditionalVisibility(
                            (m_files.Count > 0 /*|| m_txtRootFldr.Text.Length > 0*/) && m_folders[0].LastError.Length == 0);
                        imgCopy.Visibility = btnCopy.Visibility;
                        //
                        btnMove.Visibility = Rsc.ConditionalVisibility(
                            (m_files.Count > 0 /*|| m_txtRootFldr.Text.Length > 0*/) && m_folders[0].LastError.Length == 0);
                        imgMove.Visibility = btnMove.Visibility;

                        m_AppFrame.SetStatusText(m_files.Count.ToString() + " file(s) in "
                                                 + m_folders.Count.ToString() + " folder(s) listed");

                        // //
                        //

                        if (m_sAutoOperation.Length > 0)
                        {
                            ActionPanel.Visibility = Rsc.Collapsed;

                            switch (m_sAutoOperation)
                            {
                            case "AutoDelete":
                                m_AppFrame.AutoClick(m_btnDelete, new System.Windows.RoutedEventHandler(m_btnDelete_Click));
                                break;
                            }
                        }

                        //
                        // //
                    }
                }

                break;
            }

            default:
                m_AppFrame_OnTimer_Sub1(sender, e);
                break;
            }
        }
Example #8
0
        public override string GetInfo(bool bForSysTile, string sIcoId, out Brush brBk, out Brush brFore,
                                       out double dFontSize, out string sErr,
                                       out string sNotiTitle, out string sNotiContent, out string sNotiSound,
                                       bool bCalledByAgent, object oAgentParam, out string sInfoToChngChk)
        {
            brBk      = null;
            brFore    = null;
            dFontSize = 0;
            sErr      = "";

            sNotiTitle   = "";
            sNotiContent = "";
            sNotiSound   = "";

            sInfoToChngChk = "";

            string sCnt = "";

            try
            {
                switch (sIcoId)
                {
                case "sysTm":
                {
                    DateTime dNow = DateTime.Now;
                    sCnt += RscUtils.pad60(dNow.Hour) +
                            ":" + RscUtils.pad60(dNow.Minute);

                    if (bForSysTile)
                    {
                        sCnt += "\n\n(as of)";
                    }
                    else
                    {
                        sCnt += "\n:" + RscUtils.pad60(dNow.Second);
                    }

                    break;
                }

                case "sysDtFull":
                {
                    DateTime dNow = DateTime.Now;
                    sCnt += dNow.Year.ToString() +
                            ".\n" + RscUtils.pad60(dNow.Month) + "." +
                            RscUtils.pad60(dNow.Day) + ".";
                    break;
                }

                case "sysDtDay":
                {
                    DateTime dNow = DateTime.Now;
                    sCnt += RscUtils.pad60(dNow.Day) + ". ";
                    switch (dNow.DayOfWeek)
                    {
                    case DayOfWeek.Monday: sCnt += "H"; break;

                    case DayOfWeek.Tuesday: sCnt += "K"; break;

                    case DayOfWeek.Wednesday: sCnt += "Sze"; break;

                    case DayOfWeek.Thursday: sCnt += "Cs"; break;

                    case DayOfWeek.Friday: sCnt += "P"; break;

                    case DayOfWeek.Saturday: sCnt += "Szo"; break;

                    case DayOfWeek.Sunday: sCnt += "V"; break;
                    }

                    sCnt += "\n" + RscUtils.pad60(RscUtils.WeekOfYearHU(dNow)) + ". hét";
                    break;
                }

                case "sysFsFree":
                {
                    string sIsoStoreDrive = "";
                    long   lFree          = RscStore.AvailableFreeSpace(out sIsoStoreDrive);

                    sCnt += RscUtils.toMBstr(lFree, true);

                    if (sIsoStoreDrive.Length > 0)
                    {
                        sCnt = sIsoStoreDrive + "\n" + sCnt;
                    }

                    sNotiTitle   = "Free Space";
                    sNotiContent = sCnt.Replace('\n', ' ');

                    sInfoToChngChk = RscUtils.toMBstr(lFree, true, false, 1);

                    break;
                }

                case "sysBatPow":
                {
                    sCnt += Windows.Phone.Devices.Power.Battery.GetDefault().RemainingChargePercent.ToString() + " %";

                    if (Microsoft.Phone.Info.DeviceStatus.PowerSource == Microsoft.Phone.Info.PowerSource.Battery)
                    {
                        sCnt += "";                                 //"\n\nBATT";
                    }
                    else
                    {
                        sCnt += "\n\nCHRG";
                    }

                    if (Windows.Phone.Devices.Power.Battery.GetDefault().RemainingChargePercent >= 100 &&
                        Microsoft.Phone.Info.DeviceStatus.PowerSource != Microsoft.Phone.Info.PowerSource.Battery)
                    {
                        brBk   = new SolidColorBrush(Colors.Red);
                        brFore = new SolidColorBrush(Colors.White);

                        sNotiTitle   = "Battery Charge";
                        sNotiContent = sCnt.Replace('\n', ' ');

                        //sNotiSound = /*"/Lib_Rsc;component/" +*/ "Media/BociBociTarka.wav";
                        sNotiSound = /*"/Lib_Rsc;component/" +*/ "Media/DingDing.wav";
                    }

                    break;
                }

                case "sysCellNet":
                {
                    dFontSize = 11;

                    string sCmo = DeviceNetworkInformation.CellularMobileOperator;
                    for (int i = 0; i < 1; i++)
                    {
                        int iPos = sCmo.IndexOf(' ');
                        if (iPos < 0)
                        {
                            sCmo += "\n";
                            //if( i == 0 ) sCmo += "\n";
                            break;
                        }

                        sCmo = sCmo.Substring(0, iPos) + "\n" + sCmo.Substring(iPos + 1);
                    }

                    sCnt += sCmo + "\n";

                    if (DeviceNetworkInformation.IsCellularDataEnabled)
                    {
                        sCnt += "d(ata) ON";
                    }
                    else
                    {
                        sCnt += "d(ata) OFF";
                    }
                    sCnt += "\n";

                    if (DeviceNetworkInformation.IsCellularDataRoamingEnabled)
                    {
                        sCnt += "d roam ON";
                    }
                    else
                    {
                        sCnt += "d roam OFF";
                    }

                    break;
                }

                case "sysCnt_Note":
                {
                    int iCount = 0;

                    RscStore store = new RscStore();

                    if (store.FolderExists("A:\\Documents\\Notes"))
                    {
                        string[] fles = store.GetFileNames("A:\\Documents\\Notes", "*.txt");
                        iCount = fles.Length;
                    }

                    brBk   = new SolidColorBrush(Color.FromArgb(255, 252, 244, 178));
                    brFore = new SolidColorBrush(Colors.Black);
                    sCnt  += iCount.ToString() + "\n\nnotes";

                    break;
                }

                case "sysCnt_Anni":
                {
                    int iCntRed    = 0;
                    int iCntOrange = 0;
                    int iCntGreen  = 0;
                    int iCntBlue   = 0;
                    int iCntGray   = 0;

                    RscStore store = new RscStore();

                    if (store.FolderExists("A:\\Documents\\Dates"))
                    {
                        string[] fles = RscSort.OrderBy(store.GetFileNames("A:\\Documents\\Dates", "*.txt"));
                        foreach (string sFle in fles)
                        {
                            bool   bTmp;
                            string sDate = store.ReadTextFile("A:\\Documents\\Dates" + "\\" + sFle, "", out bTmp);

                            if (sDate.Length == 0)
                            {
                                continue;
                            }

                            DateTime dtNow = DateTime.Now;
                            string   sYnow = dtNow.Year.ToString();
                            string   sMnow = dtNow.Month.ToString();

                            int iCyc = 0;
                            for (iCyc = 0; iCyc < 2; iCyc++)
                            {
                                string sY;
                                string sM;
                                string sD;

                                bool bAnniver = (sDate.Substring(2, 1) == ".");
                                if (bAnniver)
                                {
                                    if (sDate.Length == 3)
                                    {
                                        sY = sYnow;
                                        sM = sMnow;
                                        sD = sDate.Substring(0, 2);

                                        //FIX...
                                        //sMnow = (dtNow.Month + 1).ToString();
                                        if (dtNow.Month >= 12)
                                        {
                                            sMnow = "1";
                                            sYnow = (dtNow.Year + 1).ToString();
                                        }
                                        else
                                        {
                                            sMnow = (dtNow.Month + 1).ToString();
                                        }
                                    }
                                    else
                                    {
                                        sY = sYnow;
                                        sM = sDate.Substring(0, 2);
                                        sD = sDate.Substring(3, 2);

                                        sYnow = (dtNow.Year + 1).ToString();
                                    }
                                }
                                else
                                {
                                    sY = sDate.Substring(0, 4);
                                    sM = sDate.Substring(5, 2);
                                    sD = sDate.Substring(8, 2);
                                }

                                int iY = 1901; Int32.TryParse(sY, out iY);                                        //parseInt(sY);
                                int iM = 1; Int32.TryParse(sM, out iM);                                           //parseInt(sM);
                                int iD = 1; Int32.TryParse(sD, out iD);                                           //parseInt(sD);

                                dtNow = DateTime.Now;
                                DateTime dt1 = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day);
                                DateTime dt2 = new DateTime(iY, iM, iD);

                                //var dDiff = dt1.getTime() - dt2.getTime();
                                TimeSpan tsDiff = dt1 - dt2;
                                double   dDiff  = tsDiff.TotalMilliseconds;

                                double dDiffD = Math.Floor(dDiff / (1000 * 3600 * 24));

                                /*
                                 * double dDiffW;
                                 * if( dDiffD < 0 )
                                 * {
                                 *      dDiffW = Math.Round((dDiffD * -1) / 7, 0) * -1;
                                 * }
                                 * else
                                 * {
                                 *      dDiffW = Math.Round(dDiffD / 7, 0);
                                 * }
                                 */

                                if (bAnniver && (dDiffD > 7))
                                {
                                    continue;
                                }

                                /*
                                 * var sWtit = dDiffW.ToString() +
                                 *      "w " + (dDiffD - (dDiffW * 7)).ToString() + "d";
                                 */

                                if (bAnniver)
                                {
                                    if ((dDiffD * dDiffD) < 10)
                                    {
                                        iCntRed++;
                                    }
                                    else
                                    {
                                        if ((dDiffD * dDiffD) < 50)
                                        {
                                            iCntOrange++;
                                        }
                                        else
                                        {
                                            if ((dDiffD * dDiffD) < 197)
                                            {
                                                iCntGreen++;
                                            }
                                            else
                                            {
                                                iCntBlue++;
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    iCntGray++;
                                }
                            }
                        }
                    }

                    int    iCnt = 0;
                    string sMsg = "";
                    if (iCntRed > 0)
                    {
                        sMsg   = "+/- 3d";
                        iCnt   = iCntRed;
                        brBk   = new SolidColorBrush(Colors.Red);
                        brFore = new SolidColorBrush(Colors.White);
                    }
                    else if (iCntOrange > 0)
                    {
                        sMsg   = "+/- 1w";
                        iCnt   = iCntOrange;
                        brBk   = new SolidColorBrush(Colors.Orange);
                        brFore = new SolidColorBrush(Colors.White);
                    }
                    else if (iCntGreen > 0)
                    {
                        sMsg   = "2w";
                        iCnt   = iCntGreen;
                        brBk   = new SolidColorBrush(Colors.Green);
                        brFore = new SolidColorBrush(Colors.White);
                    }
                    else if (iCntBlue > 0)
                    {
                        sMsg = "> 2w";
                        iCnt = iCntBlue;
                        brBk = new SolidColorBrush(Colors.Blue);
                    }
                    else                             //if( iCntGray > 0 )
                    {
                        sMsg = "dates";
                        iCnt = /*iCntBlue +*/ iCntGray;

                        //Use default...
                        //brBk = new SolidColorBrush(Colors.Black);
                        //brFore = new SolidColorBrush( Colors.White );
                    }

                    sCnt += iCnt.ToString() + "\n\n" + sMsg;

                    sNotiTitle   = "Anniversary";
                    sNotiContent = sCnt.Replace('\n', ' ');

                    break;
                }

                case "sysCnt_WebDog":
                {
                    RscStore store = new RscStore();

                    if (store.FileExists("A:\\Documents\\WebDogUri.txt"))
                    {
                        DateTimeOffset dtf    = store.GetFileLastWriteTime("A:\\Documents\\WebDogUri.txt");
                        DateTime       dt     = dtf.DateTime;
                        DateTime       dtNow  = DateTime.Now;
                        TimeSpan       tsDiff = dtNow - dt;

                        bool   bTmp;
                        string sUri = store.ReadTextFile("A:\\Documents\\WebDogUri.txt", "", out bTmp);
                        if (sUri.Length > 0)
                        {
                            try
                            {
                                Uri    uri  = new Uri(sUri, UriKind.Absolute);
                                string sDns = uri.DnsSafeHost;

                                if (sDns.Length > 5)
                                {
                                    sDns  = sDns.Substring(0, 5);
                                    sDns += "...";
                                }

                                sCnt += sDns;
                            }
                            catch (Exception)
                            {
                            }
                        }
                        sCnt += "\n";

                        //sCnt = RscUtils.toDurationStr( tsDiff.Duration() );
                        if (Math.Floor(tsDiff.TotalDays) > 0)
                        {
                            brBk   = new SolidColorBrush(Colors.Red);
                            brFore = new SolidColorBrush(Colors.White);

                            sCnt += Math.Floor(tsDiff.TotalDays).ToString() + "\nday(s)";
                        }
                        else if (Math.Floor(tsDiff.TotalHours) > 0)
                        {
                            //Use Default...
                            //brBk = new SolidColorBrush( Colors.Black );
                            //brFore = new SolidColorBrush( Colors.White );

                            sCnt += Math.Floor(tsDiff.TotalHours).ToString() + "\nhour(s)";
                        }
                        else                                 //if( Math.Floor( tsDiff.TotalMinutes ) > 0 )
                        {
                            //Use Default...
                            //brBk = new SolidColorBrush( Colors.Black );
                            //brFore = new SolidColorBrush( Colors.White );

                            sCnt += Math.Floor(tsDiff.TotalMinutes).ToString() + "\nmin(s)";
                        }

                        /*
                         * else //if( Math.Floor( tsDiff.TotalSeconds ) > 0 )
                         * {
                         *      //Use Default...
                         *      //brBk = new SolidColorBrush( Colors.Black );
                         *      //brFore = new SolidColorBrush( Colors.White );
                         *
                         *      sCnt += Math.Floor( tsDiff.TotalSeconds ).ToString() + "\n\nsec(s)";
                         * }
                         */
                    }
                    else
                    {
                        if (bForSysTile)
                        {
                            //Use Default...
                            //brBk = new SolidColorBrush( Colors.Black );
                            //brFore = new SolidColorBrush( Colors.White );
                        }
                        else
                        {
                            brBk   = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
                            brFore = new SolidColorBrush(Colors.Black);
                        }
                    }

                    break;
                }

                case "sysCnt_Event":
                {
                    int iCountErr = 0;
                    int iCountInf = 0;

                    RscStore store = new RscStore();

                    if (store.FolderExists("A:\\System\\Events"))
                    {
                        string[] fles = store.GetFileNames("A:\\System\\Events", "*.error");
                        iCountErr = fles.Length;

                        fles      = store.GetFileNames("A:\\System\\Events", "*.info");
                        iCountInf = fles.Length;

                        if (iCountErr > 0)
                        {
                            brBk   = new SolidColorBrush(Colors.Red);
                            brFore = new SolidColorBrush(Colors.White);
                        }
                        else if (iCountInf > 0)
                        {
                            brBk   = new SolidColorBrush(Colors.Blue);
                            brFore = new SolidColorBrush(Colors.White);
                        }
                        else
                        {
                            //Use Default...
                            //brBk = new SolidColorBrush( Colors.Black );
                            //brFore = new SolidColorBrush( Colors.White );
                        }
                    }

                    sCnt += iCountErr.ToString() + " err\n"
                            /*+ "\n"*/
                            + iCountInf.ToString() + " inf";

                    break;
                }

                case "sysCnt_PerDay":
                {
                    sCnt += "";

                    if (bForSysTile)
                    {
                        //Use Default...
                        //brBk = new SolidColorBrush( Colors.Black );
                        //brFore = new SolidColorBrush( Colors.White );
                    }
                    else
                    {
                        brBk   = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
                        brFore = new SolidColorBrush(Colors.Black);
                    }

                    RscStore store = new RscStore();

                    if (store.FolderExists("A:\\Documents\\PerDay"))
                    {
                        bool   bTmp;
                        string sTx = store.ReadTextFile("A:\\Documents\\PerDay\\Default.txt", "", out bTmp);
                        if (sTx.Length > 0)
                        {
                            string [] aTx = sTx.Split('|');
                            if (aTx.Length == 5)
                            {
                                int iY = Int32.Parse(aTx[0]);
                                int iM = Int32.Parse(aTx[1]);
                                int iD = Int32.Parse(aTx[2]);

                                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 = double.Parse(aTx[3]);
                                if (dAmo != 0)
                                {
                                    int iRes = (int)Math.Round(dAmo / iDays, 0);

                                    string sUnit = "";
                                    if (aTx[4].Length > 0)
                                    {
                                        sUnit = " " + aTx[4];
                                    }

                                    sCnt += aTx[3] + sUnit + "\n"
                                            + /*(iY % 1000).ToString()*/ aTx[0] + "." + RscUtils.pad60(iM) + "." + RscUtils.pad60(iD) + "." + "\n"
                                            + "----------" + "\n"
                                            + iRes.ToString() + sUnit + "\n"
                                            + "/ day" + " (" + Math.Max(0, (int)Math.Round(ts.TotalDays, 0)).ToString() + ")";

                                    brBk   = new SolidColorBrush(Colors.Gray);
                                    brFore = new SolidColorBrush(Colors.White);

                                    dFontSize = 11;
                                }
                            }
                        }
                    }

                    break;
                }

                default:
                {
                    sCnt = "???";
                    break;
                }
                }
            }
            catch (Exception e)
            {
                //Do not generate too many err files...
                RscStore.AddSysEvent(e, "Tile_Info_Title_Createion_Error");

                sErr = e.Message + "\r\n" + e.StackTrace;
                sCnt = "ERR!";
            }

            return(sCnt);
        }
Example #9
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            if (m_AppArgs.Waiting)
            {
                RscPageArgsRet appOutput = m_AppArgs.GetOutput();
                if (appOutput != null)
                {
                    switch (appOutput.ID)
                    {
                    case "SndFldrPath":
                        if (appOutput.GetFlag(0) == "Ok")
                        {
                            string sFolderIn = appOutput.GetData(0);

                            m_siInPlayer = null;
                            ClearAllSound();

                            RscStore store = new RscStore();

                            string[] fles = RscSort.OrderBy(store.GetFileNames(sFolderIn, "*.*"));
                            foreach (string sFle in fles)
                            {
                                string sExt = RscStore.ExtensionOfPath(sFle);

                                // FIX: To support Tube(HD)'s own local storage Video folder
                                //      where files are listed without extension!!!
                                bool bInclude = (sExt == "");

                                string strFileGroup = RscRegFs.GetFileGroupEx(sExt);
                                switch (strFileGroup)
                                {
                                case "Sound.Native":
                                case "Video.Native":
                                {
                                    bInclude = true;
                                    break;
                                }
                                }

                                if (bInclude)
                                {
                                    SoundInfo si = AddSound(sFolderIn + "\\" + sFle);
                                    if (m_siInPlayer == null)
                                    {
                                        m_siInPlayer = si;
                                    }
                                }
                            }

                            if (m_siInPlayer != null)
                            {
                                DoPlay();
                            }

                            RscRegistry.WriteString(HKEY.HKEY_CURRENT_USER, "Software\\Ressive.Hu\\RscViewer_SoundV11"
                                                    , "LastOk", sFolderIn);
                        }
                        else
                        {
                            //NOP...
                        }
                        break;
                    }
                }

                m_AppArgs.Clear();
            }
        }
Example #10
0
        private void RscViewer_SoundV10_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            m_AppFrame.SetNoSleep(true);

            if (m_bLoaded)
            {
                return;
            }
            m_bLoaded = true;

            m_currentPosition.Tick += new System.EventHandler(m_currentPosition_Tick);

            RscPageArgsRetManager appArgsMgr = new RscPageArgsRetManager();

            appInput = appArgsMgr.GetInput(csPageName);

            if (appInput != null)
            {
                m_AppFrame.AppTitle   = appInput.CallerAppTitle;
                m_AppFrame.AppIconRes = appInput.CallerAppIconRes;

                int iIndex = 0;
                if (!Int32.TryParse(appInput.GetFlag(0), out iIndex))
                {
                    return;
                }

                //NOT NEEDED...

                /*
                 * if( !double.TryParse( appInput.GetFlag(1), out dWidth ) ) return;
                 * if( !double.TryParse( appInput.GetFlag(2), out dHeight ) ) return;
                 */

                m_siInPlayer = null;
                ClearAllSound();

                for (int i = 0; i < appInput.DataCount; i++)
                {
                    SoundInfo si = AddSound(appInput.GetData(i));
                    if (i == iIndex)
                    {
                        m_siInPlayer = si;
                    }
                }

                if (m_siInPlayer != null)
                {
                    DoPlay();
                }

                //Denie to auto-reload on next start...
                appArgsMgr.Vipe();
            }
            else
            {
                string sLastOk = RscRegistry.ReadString(HKEY.HKEY_CURRENT_USER, "Software\\Ressive.Hu\\RscViewer_SoundV11"
                                                        , "LastOk", "");
                if (sLastOk.Length > 0)
                {
                    try
                    {
                        m_siInPlayer = null;

                        //DO NOT!!!
                        //ClearAllSound();

                        RscStore store = new RscStore();

                        string[] fles = RscSort.OrderBy(store.GetFileNames(sLastOk, "*.*"));
                        foreach (string sFle in fles)
                        {
                            string sExt = RscStore.ExtensionOfPath(sFle);

                            // FIX: To support Tube(HD)'s own local storage Video folder
                            //      where files are listed without extension!!!
                            bool bInclude = (sExt == "");

                            string strFileGroup = RscRegFs.GetFileGroupEx(sExt);
                            switch (strFileGroup)
                            {
                            case "Sound.Native":
                            case "Video.Native":
                            {
                                bInclude = true;
                                break;
                            }
                            }

                            if (bInclude)
                            {
                                SoundInfo si = AddSound(sLastOk + "\\" + sFle);
                                if (m_siInPlayer == null)
                                {
                                    m_siInPlayer = si;
                                }
                            }
                        }

                        //DO NOT!!!

                        /*
                         * if( m_siInPlayer != null )
                         * {
                         *      DoPlay();
                         * }
                         */
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            m_bInThisApp = true;

            if (!m_bFirstLoad)
            {
                return;
            }
            m_bFirstLoad = false;

            IDictionary <string, string> parameters = this.NavigationContext.QueryString;

            if (parameters.ContainsKey("folder"))
            {
                RscStore store = new RscStore();

                string sFolder;
                sFolder = parameters["folder"];

                switch (sFolder)
                {
                case "A:\\Contacts":
                {
                    m_AppFrame.AppTitle   = "Contacts";
                    m_AppFrame.AppIconRes = "Images/IcoSm001_Contacts.jpg";

                    store.CreateFolderPath(sFolder);

                    string [] asFns = RscSort.OrderBy(store.GetFileNames(sFolder, "*.vcf"));

                    foreach (string sFn in asFns)
                    {
                        string sPath = sFolder + "\\" + sFn;

                        m_aPathes.Add(sPath);
                    }

                    break;
                }

                case "A:\\System\\Events":
                {
                    m_AppFrame.AppTitle   = "Events";
                    m_AppFrame.AppIconRes = "Images/IcoSm001_EventViewer.jpg";

                    store.CreateFolderPath(sFolder);

                    //INFs
                    string [] asFns = RscSort.OrderBy(store.GetFileNames(sFolder, "*.info"));
                    foreach (string sFn in asFns)
                    {
                        string sPath = sFolder + "\\" + sFn;

                        m_aPathes.Add(sPath);
                    }

                    //ERRORs
                    asFns = RscSort.OrderBy(store.GetFileNames(sFolder, "*.error"));
                    foreach (string sFn in asFns)
                    {
                        string sPath = sFolder + "\\" + sFn;

                        m_aPathes.Add(sPath);
                    }

                    break;
                }

                default:
                {
                    store.CreateFolderPath(sFolder);

                    string [] asFns = RscSort.OrderBy(store.GetFileNames(sFolder, "*.txt"));

                    foreach (string sFn in asFns)
                    {
                        string sPath = sFolder + "\\" + sFn;

                        m_aPathes.Add(sPath);
                    }

                    break;
                }
                }

                if (m_aPathes.Count > 0)
                {
                    m_iIndex = 0;
                    _ReadTextFile();
                }
            }
            else if (parameters.ContainsKey("file"))
            {
                m_AppFrame.AppTitle   = "Contact";
                m_AppFrame.AppIconRes = "Images/IcoSm001_Contacts.jpg";

                string sPath = parameters["file"];
                if (sPath.Length > 0)
                {
                    m_aPathes.Add(sPath);

                    m_iIndex = 0;
                    _ReadTextFile();
                }
            }
            else
            {
                RscPageArgsRetManager appArgsMgr = new RscPageArgsRetManager();
                m_AppInput = appArgsMgr.GetInput("RscViewer_TextV10");
                if (m_AppInput != null)
                {
                    m_AppFrame.AppTitle   = m_AppInput.CallerAppTitle;
                    m_AppFrame.AppIconRes = m_AppInput.CallerAppIconRes;

                    m_iIndex = 0;
                    if (!Int32.TryParse(m_AppInput.GetFlag(0), out m_iIndex))
                    {
                        return;
                    }

                    m_aPathes.Clear();
                    for (int i = 0; i < m_AppInput.DataCount; i++)
                    {
                        string sPath = m_AppInput.GetData(i);

                        m_aPathes.Add(sPath);
                    }
                    if (m_aPathes.Count == 0)
                    {
                        return;
                    }

                    m_iIndex = Math.Min(m_iIndex, m_AppInput.DataCount - 1);
                    m_iIndex = Math.Max(m_iIndex, 0);

                    //appArgsMgr.Vipe();

                    _ReadTextFile();
                }
            }
        }