protected override void OnNavigatedTo(NavigationEventArgs args)
        {
            //Handle ExitOnBack=True arg...
            RscUtils.OnNavigatedTo_ExitOnBack(this.NavigationContext.QueryString);

            spItems.Children.Clear();

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

            m_txtTitle.Text = args.Uri.ToString();

            if (parameters.Count > 0)
            {
                List <NavToPar> ap = new List <NavToPar>();

                foreach (string sKey in parameters.Keys)
                {
                    ap.Add(new NavToPar(sKey, ""));
                }

                int iIdx = -1;
                foreach (string sValue in parameters.Values)
                {
                    iIdx++;
                    ap[iIdx].Value = sValue;
                }

                foreach (NavToPar p in ap)
                {
                    AddItem(false, p.Key, p.Value);
                }
            }

            base.OnNavigatedTo(args);
        }
        public string GetStateTitle(bool bDetailed)
        {
            string strSt = "";

            if (!bFile && !bFolder)
            {
                return("message");
            }
            if (!bFolder)
            {
                strSt = "file";
                if (FileSize > -1)
                {
                    strSt += " (local: ";
                    strSt += FileSize.ToString();
                    strSt += " bytes, " + RscUtils.toMBstr(FileSize, false) + ")";
                }
                if (RemoteFileSize > -1)
                {
                    strSt += " (remote: ";
                    strSt += RemoteFileSize.ToString();
                    strSt += " bytes, " + RscUtils.toMBstr(RemoteFileSize, false) + ")";
                }
                if (bDetailed)
                {
                    if (Done)
                    {
                        strSt += " (DONE)";
                    }
                    if (Acked)
                    {
                        strSt += " (ACKED)";
                    }
                }
                return(strSt);
            }

            strSt = "folder";
            if (bDetailed)
            {
                strSt += " (RefCount=" + RefCount.ToString() + ")";
                if (!bWalked)
                {
                    strSt += " (NOT WALKED!!!)";
                }
                if (Created)
                {
                    strSt += " (Created)";
                }
                if (Done)
                {
                    strSt += " (DONE)";
                }
                if (Acked)
                {
                    strSt += " (ACKED)";
                }
            }
            return(strSt);
        }
Example #3
0
        private void btnSendJpg_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            DateTime dNow = DateTime.Now;

            m_bLastFileIsFolder = false;
            string sFile = dNow.Year.ToString() +
                           "_" + RscUtils.pad60(dNow.Month) + "_" +
                           RscUtils.pad60(dNow.Day) + "_" + RscUtils.pad60(dNow.Hour) +
                           "_" + RscUtils.pad60(dNow.Minute) + "_" +
                           RscUtils.pad60(dNow.Second) + NationalChrsToTestFileNames + ".jpg";

            SetLastFile(sFile, false);

            WriteableBitmap wbmp = new WriteableBitmap(ContentPanel,
                                                       new System.Windows.Media.MatrixTransform());

            System.IO.MemoryStream ms = new System.IO.MemoryStream(4096);

            System.Windows.Media.Imaging.
            Extensions.SaveJpeg(wbmp, ms,
                                wbmp.PixelWidth, wbmp.PixelHeight,
                                0, 100);
            ms.Seek(0, System.IO.SeekOrigin.Begin);

            RscFtpClientCommand cmd = RscFtpClientCommand.UploadBin(sFile, ms);

            _SendAutoPASV(cmd);
        }
Example #4
0
        public void TRACE_Stop()
        {
            if (m_txtTRACE == null)
            {
                return;
            }

            string sTrace = "";

            TimeSpan ts = DateTime.Now - m_dtTraceStart;

            sTrace += ts.ToString();
            for (;;)
            {
                if (sTrace.Length == 0)
                {
                    break;
                }
                if (sTrace[sTrace.Length - 1] != '0')
                {
                    break;
                }
                sTrace = sTrace.Substring(0, sTrace.Length - 1);
            }
            for (;;)
            {
                if (sTrace.Length == 0)
                {
                    break;
                }
                if (sTrace[0] != '0' && sTrace[0] != ':')
                {
                    break;
                }
                sTrace = sTrace.Substring(1, sTrace.Length - 1);
            }
            sTrace += " sec\r\n";

            long lMemUsage = Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage - m_lTraceMemUsage;

            {
                //FIX... ...toMBstr fails with negative number...
                if (lMemUsage < 0)
                {
                    sTrace += "-";
                }
                if (lMemUsage < 0)
                {
                    lMemUsage = lMemUsage * -1;
                }

                sTrace += RscUtils.toMBstr(lMemUsage);
            }

            TRACE = sTrace;
        }
Example #5
0
        private void btnHostResolve_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            txIP.Text = "";

            if (RscUtils.IsIpAddress(txHostName.Text))
            {
                txIP.Text = "ERR: IP can not be resolved!";
            }
            else
            {
                var endpoint = new DnsEndPoint(txHostName.Text, 0);
                DeviceNetworkInformation.ResolveHostNameAsync(endpoint, OnHostResolved, null);
            }
        }
Example #6
0
        private string _GetAppMemInfo()
        {
            string strMem = "";

            strMem += "Curr: " + RscUtils.toMBstr(Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage);

            strMem += "\r\n";

            strMem += "Max: " + RscUtils.toMBstr(Microsoft.Phone.Info.DeviceStatus.ApplicationMemoryUsageLimit);

            strMem += "\r\n";

            strMem += "Peek: " + RscUtils.toMBstr(Microsoft.Phone.Info.DeviceStatus.ApplicationPeakMemoryUsage);

            return(strMem);
        }
Example #7
0
        private void cam_CaptureImageAvailable(object sender, Microsoft.Devices.ContentReadyEventArgs e)
        {
            if (m_sFnDtNext.Length == 0)
            {
                DateTime dNow = DateTime.Now;
                m_sFnDtNext = dNow.Year.ToString() + RscUtils.pad60(dNow.Month)
                              + RscUtils.pad60(dNow.Day) + "_" + RscUtils.pad60(dNow.Hour) + RscUtils.pad60(dNow.Minute)
                              + RscUtils.pad60(dNow.Second);
            }

            if (m_bSaveToMediaLibrary)
            {
                MediaLibrary media = new MediaLibrary();
                media.SavePicture(m_sFnDtNext, e.ImageStream);

                e.ImageStream.Seek(0, System.IO.SeekOrigin.Begin);
            }
            else
            {
                RscStore store = new RscStore();

                string fName = RscKnownFolders.GetMediaPath("DCIM") + "\\" + m_sFnDtNext + ".jpg";
                int    iCnt  = 0;
                for (;;)
                {
                    if (!store.FileExists(fName))
                    {
                        break;
                    }
                    iCnt++;
                    fName = RscKnownFolders.GetMediaPath("DCIM") + "\\" + m_sFnDtNext + "_" + iCnt.ToString() + ".jpg";
                }

                System.IO.Stream stream = store.CreateFile(fName);
                // Initialize the buffer for 4KB disk pages.
                byte[] readBuffer = new byte[4096];
                int    bytesRead  = -1;
                // Copy the thumbnail to the local folder.
                while ((bytesRead = e.ImageStream.Read(readBuffer, 0, readBuffer.Length)) > 0)
                {
                    stream.Write(readBuffer, 0, bytesRead);
                }
                stream.Close();
            }
        }
        // Set recording state: start recording.
        private void StartVideoRecording()
        {
            try
            {
                // Connect fileSink to captureSource.
                if (captureSource.VideoCaptureDevice != null &&
                    captureSource.State == CaptureState.Started)
                {
                    captureSource.Stop();

                    DateTime dNow = DateTime.Now;

                    string sVidName = dNow.Year.ToString() + RscUtils.pad60(dNow.Month)
                                      + RscUtils.pad60(dNow.Day) + "_" + RscUtils.pad60(dNow.Hour) + RscUtils.pad60(dNow.Minute)
                                      + RscUtils.pad60(dNow.Second);

                    // Connect the input and output of fileSink.
                    fileSink.CaptureSource           = captureSource;
                    fileSink.IsolatedStorageFileName = (RscKnownFolders.GetMediaPath("DCVID") + "\\" + sVidName + ".mp4").Substring(3);
                }

                // Begin recording.
                if (captureSource.VideoCaptureDevice != null &&
                    captureSource.State == CaptureState.Stopped)
                {
                    captureSource.Start();
                }

                // Set the button states and the message.
                UpdateUI(ButtonState.Recording, "Recording...");

                BtnBk.Fill = new SolidColorBrush(Colors.Green);
            }

            // If recording fails, display an error.
            catch (Exception /*e*/)
            {
                this.Dispatcher.BeginInvoke(delegate()
                {
                    //txtDebug.Text = "ERROR: " + e.Message.ToString();

                    BtnBk.Fill = new SolidColorBrush(Colors.Red);
                });
            }
        }
Example #9
0
        private void btnMkD_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            DateTime dNow = DateTime.Now;

            m_bLastFileIsFolder = true;
            string sFile = dNow.Year.ToString() +
                           "_" + RscUtils.pad60(dNow.Month) + "_" +
                           RscUtils.pad60(dNow.Day) + "_" + RscUtils.pad60(dNow.Hour) +
                           "_" + RscUtils.pad60(dNow.Minute) + "_" +
                           RscUtils.pad60(dNow.Second) + NationalChrsToTestFileNames;

            SetLastFile(sFile, true);

            RscFtpClientCommand cmd = RscFtpClientCommand.CreateFolder(sFile);

            _Log("21", cmd.ToString());

            m_ftpc.SendCommandToServer(cmd);
        }
        override public void Expand()
        {
            if (Expanded)
            {
                return;
            }

            if (sID.Length == 0 || sHistoryID.Length == 0)
            {
                base.Expand();
                return;
            }

            PreInserts();

            foreach (MyThread2 thSub in m_a)
            {
                TreeLbItem tiSub = new TreeLbItem(Holder, this);
                //
                tiSub.sID        = thSub.ID;
                tiSub.sHistoryID = thSub.HistoryID;
                //
                tiSub.DetailsFontSize  = DetailsFontSize;
                tiSub.DetailsBackColor = Holder.Theme.ThemeColors.TextDarkBack;
                tiSub.DetailsForeColor = Holder.Theme.ThemeColors.TextDarkFore;
                if (!thSub.Acknowledged)
                {
                    tiSub.CustomBackColor = Colors.Orange;

                    tiSub.BtnCustom1Visibility = Rsc.Visible;
                }
                tiSub.BtnCustom1Image = BtnCustom1Image;
                //
                tiSub.Title          = RscUtils.toDateDiff(thSub.DateSaved);
                tiSub.DetailsOfTitle = TreeLbItemThread.DecorateSnippet(thSub);
                tiSub.IsLeaf         = true;

                Insert(tiSub);
            }

            base.Expand();
        }
Example #11
0
        private void btnSendTxt_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            DateTime dNow = DateTime.Now;

            m_bLastFileIsFolder = false;
            string sFile = dNow.Year.ToString() +
                           "_" + RscUtils.pad60(dNow.Month) + "_" +
                           RscUtils.pad60(dNow.Day) + "_" + RscUtils.pad60(dNow.Hour) +
                           "_" + RscUtils.pad60(dNow.Minute) + "_" +
                           RscUtils.pad60(dNow.Second) + NationalChrsToTestFileNames + ".txt";

            SetLastFile(sFile, false);

            string sTxt = dNow.ToLongDateString( ) +
                          "\r\n" + dNow.ToLongTimeString( ) +
                          "\r\n" + "Áá Éé Íí Óó Öö Őő Úú Üü Űű";

            RscFtpClientCommand cmd = RscFtpClientCommand.UploadTxt(sFile, sTxt);

            _SendAutoPASV(cmd);
        }
Example #12
0
        private void _RefreshStatusText()
        {
            string sPlus = "";

            sPlus += "\r\n" + "UP ->"
                     + " sys: " + RscUtils.toMBstr(m_ftpc.StatUpCmd.ByteCount)
                     + " (" + m_ftpc.StatUpCmd.Seconds.ToString() + ")"
                     + " |"
                     + " usr: "******" (" + m_ftpc.StatUpDat.Seconds.ToString() + ")";

            sPlus += "\r\n" + "DN <-"
                     + " sys: " + RscUtils.toMBstr(m_ftpc.StatDnCmd.ByteCount)
                     + " (" + m_ftpc.StatDnCmd.Seconds.ToString() + ")"
                     + " |"
                     + " usr: "******" (" + m_ftpc.StatDnDat.Seconds.ToString() + ")";

            long lUp = m_ftpc.BytesPerSecUp;
            long lDn = m_ftpc.BytesPerSecDn;

            if (lUp > 0 || lDn > 0)
            {
                sPlus += "\r\nSpeed ";
                if (lUp > 0)
                {
                    sPlus += "UP: " + RscUtils.toMBstr(lUp) + "/s";
                }
                if (lDn > 0)
                {
                    if (lUp > 0)
                    {
                        sPlus += " | ";
                    }
                    sPlus += "DN: " + RscUtils.toMBstr(lDn) + "/s";
                }
            }

            m_AppFrame.SetStatusText(sSAVE_Status + sPlus, scSAVE);
        }
        private void OnOK()
        {
            bool bGoBack = true;

            if (!DeviceNetworkInformation.IsNetworkAvailable)
            {
                ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
                connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.WiFi;
                connectionSettingsTask.Show();

                return;
            }

            if (m_AppInput != null)
            {
                string strRes = txSvrIP.Text;

                //NoEmpty...
                if (m_AppInput.GetFlag(1).Length > 0)
                {
                    strRes = strRes.Trim();

                    if (strRes.Length == 0)
                    {
                        MessageBox.Show("Value must not be empty!");
                        return;
                    }
                }

                /*
                 * //FileName...
                 * if( m_AppInput.GetFlag(1).Length > 0 )
                 * {
                 *      strRes = strRes.Trim();
                 *
                 *      string strChk = "\\/:*?\"<>|";
                 *      foreach( char cChk in strChk )
                 *      {
                 *              if( strRes.IndexOf( cChk ) >= 0 )
                 *              {
                 *                      MessageBox.Show("Value must not contain characters of '" + strChk + "'!");
                 *                      return;
                 *              }
                 *      }
                 * }
                 */

                bGoBack = false;

                if (RscUtils.IsIpAddress(strRes))
                {
                    /*
                     * MessageBox.Show("IP Address is not allowed here!");
                     * return;
                     */

                    DoOk();
                }
                else
                {
                    prsBar.Visibility = Rsc.Visible;

                    var endpoint = new DnsEndPoint(strRes, 0);
                    DeviceNetworkInformation.ResolveHostNameAsync(endpoint, OnHostResolved, null);
                }
            }

            if (bGoBack)
            {
                this.NavigationService.GoBack();
            }
        }
        private void _ShowDump()
        {
            if (m_lPos == 0)
            {
                m_btnPrev.Visibility = Rsc.Collapsed;
            }
            else
            {
                m_btnPrev.Visibility = Rsc.Visible;
            }

            long lLen = 0;

            if (m_stream != null)
            {
                lLen = m_stream.Length;
            }

            if ((m_lPos + (clLn * clCb)) >= (lLen - 1))
            {
                m_btnNext.Visibility = Rsc.Collapsed;
            }
            else
            {
                m_btnNext.Visibility = Rsc.Visible;
            }

            /*
             * m_btnShare.Visibility = Rsc.ConditionalVisibility( m_lPos > 0 );
             */

            if (m_stream == null)
            {
                m_AppFrame.StatusText = "0 to 0";
                m_txtPath.Text        = "";
                m_txtContent.Text     = "";

                return;
            }

            m_AppFrame.StatusText = m_lPos.ToString() + " to "
                                    + (Math.Min(m_stream.Length - 1, (m_lPos + (clLn * clCb)) - 1)).ToString() + "\n"
                                    + "of " + (m_stream.Length - 1).ToString() + " (" + RscUtils.toMBstr(m_stream.Length - 1, false) + ")";

            m_txtPath.Text = m_sPath;

            string sContent = "";

            try
            {
                m_stream.Seek(m_lPos, System.IO.SeekOrigin.Begin);

                long lChk = m_lPos - 1;
                for (long li = 0; li < clLn; li++)
                {
                    sContent += "\n  ";

                    string sAsc = "";

                    bool bBreak = false;
                    for (long lj = 0; lj < clCb; lj++)
                    {
                        lChk++;
                        if (lChk >= m_stream.Length)
                        {
                            for (long lj2 = lj; lj2 < clCb; lj2++)
                            {
                                sContent += " __";
                            }
                            bBreak = true;
                            break;
                        }

                        if (lj == 4)
                        {
                            sContent += " ";
                        }

                        int y = m_stream.ReadByte();
                        sContent += " " + RscEncode.IntToHexaString(y, 2);

                        if ((y < 32) || (y >= 128))
                        {
                            sAsc += ".";
                        }
                        else
                        {
                            sAsc += ((char)y);
                        }
                    }

                    sContent += "   " + sAsc;

                    if (bBreak)
                    {
                        break;
                    }
                }

                m_txtContent.Text = sContent;
            }
            catch (Exception e)
            {
                m_txtContent.Text = "ERROR: " + e.Message;
            }
        }
            override public void Expand()
            {
                if (ContainerID.Length == 0)
                {
                    return;
                }

                // ???

                /*
                 * if( tiCurrent.Children.Count > 0 )
                 * {
                 *      //TODO...
                 *      return;
                 * }
                 */

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

                PreInserts();

                switch (ContainerID)
                {
                default:
                {
                    Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceList nil
                        = new Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceList();
                    foreach (Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceInfo nii in nil)
                    {
                        if (ContainerID == nii.InterfaceName)
                        {
                            TreeLbItem ti;

                            ti = new TreeLbItem(Holder, this, "",
                                                "Interface Name",
                                                nii.InterfaceName);
                            Insert(ti);

                            ti = new TreeLbItem(Holder, this, "",
                                                "Description",
                                                nii.Description + " ");
                            Insert(ti);

                            ti = new TreeLbItem(Holder, this, "",
                                                "Interface State",
                                                nii.InterfaceState.ToString());
                            Insert(ti);

                            ti = new TreeLbItem(Holder, this, "",
                                                "Interface Type",
                                                nii.InterfaceType.ToString());
                            Insert(ti);

                            ti = new TreeLbItem(Holder, this, "",
                                                "Characteristics",
                                                nii.Characteristics.ToString());
                            Insert(ti);

                            ti = new TreeLbItem(Holder, this, "",
                                                "Bandwidth",
                                                nii.Bandwidth.ToString());
                            Insert(ti);

                            break;
                        }
                    }

                    break;
                }

                case "Network Interface List":
                {
                    Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceList nil
                        = new Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceList();
                    foreach (Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceInfo nii in nil)
                    {
                        TreeLbItem ti = new TreeLbItem(Holder, this, nii.InterfaceName, nii.InterfaceName);
                        Insert(ti);
                    }

                    break;
                }

                case "Device Network Information":
                {
                    string     sValue;
                    TreeLbItem ti;

                    ti = new TreeLbItem(Holder, this, "",
                                        "Cellular Mobile Operator",
                                        Microsoft.Phone.Net.NetworkInformation.DeviceNetworkInformation.CellularMobileOperator + " ");
                    Insert(ti);

                    sValue = "No";
                    if (Microsoft.Phone.Net.NetworkInformation.DeviceNetworkInformation.IsCellularDataEnabled)
                    {
                        sValue = "Yes";
                    }
                    ti = new TreeLbItem(Holder, this, "",
                                        "Is Cellular Data Enabled",
                                        sValue);
                    Insert(ti);

                    sValue = "No";
                    if (Microsoft.Phone.Net.NetworkInformation.DeviceNetworkInformation.IsCellularDataRoamingEnabled)
                    {
                        sValue = "Yes";
                    }
                    ti = new TreeLbItem(Holder, this, "",
                                        "Is Cellular Data Roaming Enabled",
                                        sValue);
                    Insert(ti);

                    sValue = "No";
                    if (Microsoft.Phone.Net.NetworkInformation.DeviceNetworkInformation.IsNetworkAvailable)
                    {
                        sValue = "Yes";
                    }
                    ti = new TreeLbItem(Holder, this, "",
                                        "Is Network Available",
                                        sValue);
                    Insert(ti);

                    sValue = "No";
                    if (Microsoft.Phone.Net.NetworkInformation.DeviceNetworkInformation.IsWiFiEnabled)
                    {
                        sValue = "Yes";
                    }
                    ti = new TreeLbItem(Holder, this, "",
                                        "Is WiFi Enabled",
                                        sValue);
                    Insert(ti);

                    break;
                }

                case "Network":
                {
                    TreeLbItem ti;

                    ti = new TreeLbItem(Holder, this, "Device Network Information", "Device Network Information");
                    Insert(ti);

                    ti = new TreeLbItem(Holder, this, "Network Interface List", "Network Interface List");
                    Insert(ti);

                    break;
                }

                case "Device.Rsc":
                {
                    TreeLbItem ti;

                    ti = new TreeLbItem(Holder, this, "",
                                        "RscUtils.GetDeviceName",
                                        "\"" + RscUtils.GetDeviceName() + "\"" + "\n\n"
                                        + "Networking.Proximity.PeerFinder.DisplayName =\n"
                                        + Windows.Networking.Proximity.PeerFinder.DisplayName);
                    Insert(ti);

                    break;
                }

                case "Device.DeviceStatus":
                {
                    string     sValue;
                    TreeLbItem ti;

                    ti = new TreeLbItem(Holder, this, "",
                                        "Device Name",
                                        Microsoft.Phone.Info.DeviceStatus.DeviceName);
                    Insert(ti);

                    ti = new TreeLbItem(Holder, this, "",
                                        "Device Manufacturer",
                                        Microsoft.Phone.Info.DeviceStatus.DeviceManufacturer);
                    Insert(ti);

                    ti = new TreeLbItem(Holder, this, "",
                                        "Device Total Memory",
                                        RscUtils.toMBstr(Microsoft.Phone.Info.DeviceStatus.DeviceTotalMemory, false));
                    Insert(ti);

                    sValue = "No";
                    if (Microsoft.Phone.Info.DeviceStatus.IsKeyboardDeployed)
                    {
                        sValue = "Yes";
                    }
                    ti = new TreeLbItem(Holder, this, "",
                                        "Is Keyboard Deployed",
                                        sValue);
                    Insert(ti);

                    ti = new TreeLbItem(Holder, this, "",
                                        "Power Source",
                                        Microsoft.Phone.Info.DeviceStatus.PowerSource.ToString());
                    Insert(ti);

                    break;
                }

                case "Device.Environment":
                {
                    TreeLbItem ti;

                    ti = new TreeLbItem(Holder, this, "",
                                        "Device Type",
                                        Microsoft.Devices.Environment.DeviceType.ToString());
                    Insert(ti);

                    break;
                }

                case "Device.ExtendedProperties":
                {
                    TreeLbItem ti;

                    ti = new TreeLbItem(Holder, this, "",
                                        "Device Name",
                                        Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceName").ToString());
                    Insert(ti);

                    ti = new TreeLbItem(Holder, this, "",
                                        "Device Manufacturer",
                                        Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceManufacturer").ToString());
                    Insert(ti);

                    ti = new TreeLbItem(Holder, this, "",
                                        "Device Firmware Version",
                                        Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceFirmwareVersion").ToString());
                    Insert(ti);

                    ti = new TreeLbItem(Holder, this, "",
                                        "Device Hardware Version",
                                        Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceHardwareVersion").ToString());
                    Insert(ti);

                    break;
                }

                case "Device":
                {
                    TreeLbItem ti;

                    ti = new TreeLbItem(Holder, this, "Device.Rsc", "Rsc");
                    Insert(ti);

                    ti = new TreeLbItem(Holder, this, "Device.DeviceStatus", "Device Status");
                    Insert(ti);

                    ti = new TreeLbItem(Holder, this, "Device.Environment", "Device Environment");
                    Insert(ti);

                    ti = new TreeLbItem(Holder, this, "Device.ExtendedProperties", "Device Extended Properties");
                    Insert(ti);

                    break;
                }
                }

                base.Expand();
            }
Example #16
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 csTileID:
                {
                    int iCount_NEW       = 0;
                    int iCount_NonAckAll = 0;
                    int iCountAll        = 0;

                    RscStore store = new RscStore();

                    string sUserIDlast = store.ReadTextFile(AppLogic.csSecretsFolder + "\\" + "UserIDlast.txt", "");

                    if (sUserIDlast.Length > 0)
                    {
                        string sPath = AppLogic.csSecretsFolder + "\\" + sUserIDlast;

                        sPath += "\\Threads";
                        if (store.FolderExists(sPath))
                        {
                            iCount_NEW       = store.ReadXmlDataFile(sPath + "\\" + "Count_NEW" + ".xml", iCount_NEW);
                            iCount_NonAckAll = store.ReadXmlDataFile(sPath + "\\" + "Count_NonAck" + ".xml", iCount_NonAckAll);
                            iCountAll        = store.ReadXmlDataFile(sPath + "\\" + "Count" + ".xml", iCountAll);
                        }
                    }

                    int iNewNow = 0;
                    if (bForSysTile)
                    {
                        /*
                         * try
                         * {
                         *      AppLogic al = new AppLogic();
                         *      iNew = al.ReadThreadData( );
                         * }
                         * catch( Exception )
                         * {
                         *      iNew = -1;
                         * }
                         */

                        if (bCalledByAgent)
                        {
                            iNewNow = 0;
                            if (!Int32.TryParse(oAgentParam.ToString(), out iNewNow))
                            {
                                iNewNow = -400;
                            }
                        }
                    }
                    else
                    {
                    }

                    string sTile;
                    if (iNewNow < 0)
                    {
                        if (iNewNow == AppLogic.ciAuthFail)
                        {
                            sTile = "NO CONN!";
                        }
                        else
                        {
                            sTile = "ERR: " + iNewNow.ToString();                                     //"ERROR!";
                        }
                    }
                    else
                    {
                        sTile = "new: " + iCount_NEW.ToString();
                    }
                    sCnt += sTile;

                    string sCont = "non-ack: " + iCount_NonAckAll.ToString() + " / " + iCountAll.ToString();

                    sCnt += "\n" + "non-ack: " + iCount_NonAckAll.ToString();
                    sCnt += "\n" + "all: " + iCountAll.ToString();

                    sInfoToChngChk = sCnt;

                    DateTime dNow = DateTime.Now;
                    sCnt += "\n\n" + "at: " + RscUtils.pad60(dNow.Hour) +
                            ":" + RscUtils.pad60(dNow.Minute);

                    if (iNewNow < 0 || iNewNow > 0 || iCount_NEW > 0)
                    {
                        brBk = new SolidColorBrush(Colors.Red);

                        sNotiTitle   = sTile;
                        sNotiContent = sCont;

                        //sNotiSound = /*"/Lib_Rsc;component/" +*/ "Media/BociBociTarka.wav";
                        sNotiSound = /*"/Lib_Rsc;component/" +*/ "Media/Ding.wav";
                    }
                    else
                    {
                        if (iCount_NonAckAll > 0)
                        {
                            brBk = new SolidColorBrush(Colors.Orange);
                        }
                        else
                        {
                            brBk = new SolidColorBrush(Colors.Green);
                        }
                    }
                    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 #17
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);
        }
Example #18
0
        protected override void OnNavigatedTo(NavigationEventArgs args)
        {
            //Handle ExitOnBack=True arg...
            RscUtils.OnNavigatedTo_ExitOnBack(this.NavigationContext.QueryString);

            spItems.Children.Clear();

            List <NavToPar> ap = new List <NavToPar>();

            NavToPar np;
            string   sBool;

            np = new NavToPar("RscUtils.GetDeviceName",
                              "\"" + RscUtils.GetDeviceName() + "\"");
            ap.Add(np);

            np = new NavToPar("(Networking.Proximity.PeerFinder) Display Name",
                              Windows.Networking.Proximity.PeerFinder.DisplayName);
            ap.Add(np);

            /*
             * var deviceInformation = new Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation();
             * console.log(deviceInformation.systemSku);
             * np = new NavToPar( "(ExchangeActiveSyncProvisioning) systemSku",
             *      deviceInformation.systemSku );
             * ap.Add( np );
             */

            np = new NavToPar("(DeviceStatus) Device Name",
                              Microsoft.Phone.Info.DeviceStatus.DeviceName);
            ap.Add(np);

            np = new NavToPar("(Extended Properties) Device Name",
                              Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceName").ToString());
            ap.Add(np);

            np = new NavToPar("(DeviceStatus) Device Manufacturer",
                              Microsoft.Phone.Info.DeviceStatus.DeviceManufacturer);
            ap.Add(np);

            np = new NavToPar("(DeviceStatus) Device Hardware Version",
                              Microsoft.Phone.Info.DeviceStatus.DeviceHardwareVersion);
            ap.Add(np);

            np = new NavToPar("(DeviceStatus) Device Total Memory",
                              RscUtils.toMBstr(Microsoft.Phone.Info.DeviceStatus.DeviceTotalMemory, false));
            ap.Add(np);

            sBool = "No";
            if (Microsoft.Phone.Info.DeviceStatus.IsKeyboardDeployed)
            {
                sBool = "Yes";
            }
            np = new NavToPar("(DeviceStatus) Is Keyboard Deployed",
                              sBool);
            ap.Add(np);

            np = new NavToPar("(DeviceStatus) Power Source",
                              Microsoft.Phone.Info.DeviceStatus.PowerSource.ToString());
            ap.Add(np);

            np = new NavToPar("(Environment) Device Type",
                              Microsoft.Devices.Environment.DeviceType.ToString());
            ap.Add(np);

            np = new NavToPar("(Extended Properties)Device Firmware Version",
                              Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceFirmwareVersion").ToString());
            ap.Add(np);

            np = new NavToPar("(Extended Properties)Device Hardware Version",
                              Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceHardwareVersion").ToString());
            ap.Add(np);

            np = new NavToPar("(Extended Properties)Device Manufacturer",
                              Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceManufacturer").ToString());
            ap.Add(np);

            foreach (NavToPar p in ap)
            {
                AddItem(false, p.Key, p.Value);
            }

            base.OnNavigatedTo(args);
        }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            //Handle ExitOnBack=True arg...
            RscUtils.OnNavigatedTo_ExitOnBack(this.NavigationContext.QueryString);

            if (m_media != null)
            {
                return;
            }

            m_media = new MediaLibrary();
            m_pic   = null;

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

            if (parameters.ContainsKey("token"))
            {
                m_sGUID = parameters["token"];
            }
            else if (parameters.ContainsKey("FileId"))
            {
                m_sGUID = parameters["FileId"];
            }
            else
            {
                return;
            }

            m_pic = m_media.GetPictureFromToken(m_sGUID);

            if (m_pic != null)
            {
                string sFName = m_pic.Name;
                string sFExt  = "";
                int    iPos   = sFName.LastIndexOf('.');
                if (iPos >= 0)
                {
                    sFExt  = sFName.Substring(iPos);
                    sFName = sFName.Substring(0, iPos);
                }

                m_sPicFileName = m_sGUID + sFExt;

                m_sPhoneFolder = "";
                PictureAlbum pa = m_pic.Album;
                for (;;)
                {
                    if (pa.Name.ToString().Length == 0)
                    {
                        break;
                    }

                    if (m_sPhoneFolder.Length > 0)
                    {
                        m_sPhoneFolder = "\\" + m_sPhoneFolder;
                    }
                    m_sPhoneFolder = pa.Name + m_sPhoneFolder;

                    pa = pa.Parent;
                    if (pa == null)
                    {
                        break;
                    }
                }

                m_sAppFolder = RscKnownFolders.GetMediaPath("Zune");
                if (m_sPhoneFolder.Length > 0)
                {
                    m_sAppFolder += "\\" + m_sPhoneFolder;
                }

                m_sAppPath = m_sAppFolder + "\\" + m_sPicFileName;

                string sNames = "";
                sNames        += "Name";
                sNames        += "\r\n";
                sNames        += "Time";
                sNames        += "\r\n";
                sNames        += "Size";
                sNames        += "\r\n";
                sNames        += "Folder";
                m_txtName.Text = sNames;

                string sInf = "";
                sInf          += m_pic.Name;
                sInf          += "\r\n";
                sInf          += m_pic.Date.ToShortDateString() + " " + m_pic.Date.ToShortTimeString();
                sInf          += "\r\n";
                sInf          += m_pic.Width.ToString() + " x " + m_pic.Height.ToString();
                sInf          += "\r\n";
                sInf          += m_sPhoneFolder;
                m_txtInfo.Text = sInf;

                m_sInf  = "";
                m_sInf += m_pic.Name;
                m_sInf += "\r\n";
                m_sInf += m_sGUID;
                m_sInf += "\r\n";
                m_sInf += m_pic.Date.ToShortDateString() + " | " + m_pic.Date.ToShortTimeString();
                m_sInf += "\r\n";
                m_sInf += m_pic.Width.ToString() + " x " + m_pic.Height.ToString();
                m_sInf += "\r\n";
                m_sInf += m_sPhoneFolder;

                AddSavedNote();

                /*
                 * if( bThumbnail )
                 * {
                 *      System.Windows.Media.Imaging.WriteableBitmap wbmp =
                 *              Microsoft.Phone.PictureDecoder.DecodeJpeg(pic.GetThumbnail(), iCX, iCY );
                 *
                 *      return wbmp;
                 * }
                 * else
                 * {
                 */
                BitmapImage bmp = new BitmapImage();
                bmp.SetSource(m_pic.GetImage());

                /*
                 *      return bmp;
                 * }
                 */

                imgFull.Source = bmp;
            }

            /*
             * else
             * {
             *
             *      imgFull.Source = m_isDummy;
             *
             * }
             */
        }
        private void _ShowVideo(string sPath)
        {
            txPrevCnt.Text = m_iIndex.ToString();
            txNextCnt.Text = Math.Max(0, ((m_aVideos.Count - 1) - m_iIndex)).ToString();

            string strDet = (m_iIndex + 1).ToString() + " / " + m_aVideos.Count.ToString() + "\r\n";

            string strFn = sPath;
            int    iPos  = sPath.LastIndexOf('\\');

            if (iPos >= 0)
            {
                strFn = sPath.Substring(iPos + 1);
            }
            strDet += "\r\n" + strFn;

            string strFldr = "\\";

            if (iPos >= 0)
            {
                strFldr = sPath.Substring(0, iPos + 1);
            }

            strDet += "\r\n" + "\r\n" + strFldr;

            m_sVidInf         = strDet;
            txImgDetails.Text = strDet;

            long lFs = 0;

            try
            {
                if (RscStore.IsIsoStorePath(sPath))
                {
                    RscStore store = new RscStore();

                    System.IO.Stream stream = store.GetReaderStream(sPath, false);
                    lFs = stream.Length;

                    vidFull.SetSource(stream);

                    stream.Close();
                }
                else
                {
                    RscStore store = new RscStore();
                    lFs = store.GetFileLength(sPath);

                    vidFull.Source = new Uri("file:///" + sPath, UriKind.Absolute);
                }
            }
            catch (Exception e)
            {
                strDet += "\r\n" + "\r\nERROR: " + e.Message;
            }

            if (lFs > 0)
            {
                strDet += "\r\n" + lFs.ToString() + " B" + " ( " + RscUtils.toMBstr(lFs) + " ) ";
            }

            if (m_strInitErr.Length > 0)
            {
                strDet += "\r\n" + "\r\nApp Init ERROR: " + m_strInitErr;
            }

            m_sVidInf         = strDet;
            txImgDetails.Text = strDet;
        }
Example #21
0
        /*
         * private void ContentPanel_SizeChanged(object sender, System.Windows.SizeChangedEventArgs e)
         * {
         *      bool bNoChng = (m_sContentPanel.Width == e.NewSize.Width && m_sContentPanel.Height == e.NewSize.Height);
         *      m_sContentPanel = e.NewSize;
         *
         *      if( !bNoChng )
         *      {
         *              if( e.NewSize.Width < e.NewSize.Height )
         *                      imgBk.Source = m_AppFrame.Theme.GetImage("Images/Bk001_portrait.jpg");
         *              else
         *                      imgBk.Source = m_AppFrame.Theme.GetImage("Images/Bk001_landscape.jpg");
         *      }
         * }
         */

        private void Instance_PlayStateChanged(object sender, EventArgs e)
        {
            switch (BackgroundAudioPlayer.Instance.PlayerState)
            {
            case PlayState.Playing:
            {
                m_AppFrame.StatusText = "Playing...";

                m_currentPosition.Stop();

                m_txtSnd.Text  = BackgroundAudioPlayer.Instance.Track.Title;
                m_txtSnd.Text += " (" + BackgroundAudioPlayer.Instance.PlayerState.ToString() + ")";

                m_btnPlayPause.Image.Source = m_isPause;
                m_btnPlayPause.Visibility   = Rsc.Visible;

                m_btnExtOpen.Visibility = Rsc.Visible;
                m_btnStop.Visibility    = Rsc.Visible;

                string sTag = BackgroundAudioPlayer.Instance.Track.Tag;
                if (sTag.Length > 0)
                {
                    int iTag = 0;
                    if (Int32.TryParse(sTag, out iTag))
                    {
                        //ATT: Can happen...
                        if ((iTag >= 0) && (iTag < m_sounds.Count))
                        {
                            try
                            {
                                //m_txtSnd.Text += " " + iTag.ToString();

                                m_siInPlayer = m_sounds[iTag];

                                m_btnPrev.Visibility = Rsc.ConditionalVisibility(iTag > 0);
                                m_btnNext.Visibility = Rsc.Visible;                                         //Allowe to restart list... //Rsc.ConditionalVisibility( idx < (m_sounds.Count - 1) );

                                prsBarLen.Minimum = 0;
                                prsBarLen.Maximum = (int)BackgroundAudioPlayer.Instance.Track.Duration.TotalMilliseconds;

                                m_siInPlayer.sLen = RscUtils.toDurationStr(BackgroundAudioPlayer.Instance.Track.Duration);

                                //Refresh...
                                lbSounds.ItemsSource = null;
                                lbSounds.ItemsSource = m_sounds;

                                m_currentPosition.Start();
                            }
                            catch (Exception)
                            {
                                //NOP...
                            }
                        }
                    }
                }

                break;
            }

            case PlayState.Paused:
            {
                m_AppFrame.StatusText = "Paused...";

                m_currentPosition.Stop();

                m_txtSnd.Text  = BackgroundAudioPlayer.Instance.Track.Title;
                m_txtSnd.Text += " (" + BackgroundAudioPlayer.Instance.PlayerState.ToString() + ")";

                m_btnPlayPause.Image.Source = m_isPlay;
                m_btnPlayPause.Visibility   = Rsc.Visible;

                m_btnExtOpen.Visibility = Rsc.Visible;
                m_btnStop.Visibility    = Rsc.Visible;

                break;
            }

            case PlayState.Stopped:
            {
                m_AppFrame.StatusText = "Stopped...";

                m_currentPosition.Stop();

                m_txtSnd.Text  = BackgroundAudioPlayer.Instance.Track.Title;
                m_txtSnd.Text += " (" + BackgroundAudioPlayer.Instance.PlayerState.ToString() + ")";

                m_btnPlayPause.Image.Source = m_isPlay;
                m_btnPlayPause.Visibility   = Rsc.Visible;

                m_btnExtOpen.Visibility = Rsc.Collapsed;
                m_btnStop.Visibility    = Rsc.Collapsed;

                prsBarLen.Value = 0;

                break;
            }

            default:
            {
                m_txtSnd.Text = "Loading...";                         //BackgroundAudioPlayer.Instance.PlayerState.ToString();
                break;
            }
            }
        }
Example #22
0
        private void ShowSavedThreadData(string sPath, int iStartIndex, TreeLbItem tiHead = null)
        {
            RscStore store = new RscStore();

            sPath += "\\Threads";
            if (!store.FolderExists(sPath))
            {
                return;
            }

            int iCountAll = 0;

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

            int iCount_NonAckAll = 0;

            iCount_NonAckAll = store.ReadXmlDataFile(sPath + "\\" + "Count_NonAck" + ".xml", iCount_NonAckAll);

            if (iStartIndex == 0)
            {
                m_tiSum = new TreeLbItem(m_aTI, null);
                m_tiSum.DetailsFontSize = cdFontSize;
                UpdateSumItem(iCount_NonAckAll, iCountAll);
                m_aTI.Add(m_tiSum);

                tiHead = new TreeLbItem(m_aTI, null);
                //tiHead.DetailsFontSize = cdFontSize;
                tiHead.DetailsOnly = "...";
                m_aTI.Add(tiHead);
            }

            string sThreadIdOrder = "";

            sThreadIdOrder = store.ReadTextFile(sPath + "\\" + "IdOrder" + ".txt", sThreadIdOrder);
            string [] asThreadIdOrders = sThreadIdOrder.Split('|');

            bool bMoreItems = false;
            int  iThCnt     = asThreadIdOrders.Length;

            for (int iTh = iStartIndex; iTh < iThCnt; iTh++)
            {
                //NOT all...
                if ((iTh - iStartIndex) >= ciMaxAtOnce)
                {
                    bMoreItems = true;
                    break;
                }

                string sID = asThreadIdOrders[iTh];

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

                if (!store.FolderExists(sPath + "\\" + sID))
                {
                    continue;
                }

                string sIdOrder = "";
                sIdOrder = store.ReadTextFile(sPath + "\\" + sID + "\\" + "IdOrder" + ".txt", sIdOrder);
                string [] asIdOrders = sIdOrder.Split('|');

                string sHistoryID = asIdOrders[0];

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

                if (!store.FileExists(sPath + "\\" + sID + "\\" + sHistoryID + ".xml"))
                {
                    continue;
                }

                MyThread2 th = new MyThread2();
                th = store.ReadXmlDataFile(sPath + "\\" + sID + "\\" + sHistoryID + ".xml", th);
                if (th.ID.Length == 0)
                {
                    continue;
                }

                TreeLbItem ti = new TreeLbItem(m_aTI, null);
                //
                ti.DetailsFontSize  = cdFontSize;
                ti.DetailsBackColor = m_AppFrame.Theme.ThemeColors.TextDarkBack;
                ti.DetailsForeColor = m_AppFrame.Theme.ThemeColors.TextDarkFore;
                if (!th.Acknowledged)
                {
                    ti.CustomBackColor = Colors.Orange;

                    ti.BtnCustom1Visibility = Rsc.Visible;
                }
                ti.BtnCustom1Image = m_isCheckOn;                 //Off;
                //
                string sTitle = "";
                sTitle += RscUtils.toDateDiff(th.DateSaved);
                if (asIdOrders.Length > 1)
                {
                    sTitle += " ( +" + (asIdOrders.Length - 1).ToString() + " )";
                }
                ti.Title          = sTitle;
                ti.DetailsOfTitle = TreeLbItemThread.DecorateSnippet(th);
                ti.IsLeaf         = (asIdOrders.Length <= 1);
                m_aTI.Add(ti);

                ti.sID        = sID;
                ti.sHistoryID = sHistoryID;

                foreach (string sId in asIdOrders)
                {
                    if (sId.Length == 0)
                    {
                        continue;
                    }
                    if (sId == sHistoryID)
                    {
                        continue;
                    }

                    MyThread2 thSub = new MyThread2();
                    thSub = store.ReadXmlDataFile(sPath + "\\" + sID + "\\" + sId + ".xml", thSub);
                    if (thSub.ID.Length == 0)
                    {
                        continue;
                    }

                    //DO NOT!!!

                    /*
                     * TreeLbItem tiSub = new TreeLbItem( m_aTI, ti );
                     * tiSub.Title = RscUtils.toDateDiff( thSub.DateSaved ) + "retrived...";
                     * tiSub.DetailsOfTitle = thSub.Snippet;
                     * tiSub.IsLeaf = true;
                     * m_aTI.Add( tiSub );
                     */

                    ti.m_a.Add(thSub);
                }
            }

            if (tiHead != null)
            {
                string sTit = "Threads " + (iStartIndex + 1).ToString() + " - ";
                if (bMoreItems)
                {
                    sTit += (iStartIndex + ciMaxAtOnce).ToString();
                }
                else
                {
                    sTit += iThCnt.ToString();
                }

                //tiHead.DetailsFontSize = cdFontSize;
                tiHead.DetailsOnly = sTit;
            }

            if (bMoreItems)
            {
                TreeLbItem ti = new TreeLbItem(m_aTI, null);
                ti.Title           = "Threads " + (iStartIndex + ciMaxAtOnce + 1).ToString() + " - ... (press to list)";
                ti.sID             = csMoreItems;
                ti.sHistoryID      = (iStartIndex + ciMaxAtOnce).ToString();
                ti.CustomBackColor = m_AppFrame.Theme.ThemeColors.TreeDescBack;
                ti.CustomForeColor = m_AppFrame.Theme.ThemeColors.TreeDescFore;
                m_aTI.Add(ti);
            }
        }
        private void _ShowImage(string sPath, Size sz)
        {
            //NOT WORKING!!!
            //m_tmrGif.Stop();

            txPrevCnt.Text = m_iIndex.ToString();
            txNextCnt.Text = Math.Max(0, ((m_aImages.Count - 1) - m_iIndex)).ToString();

            string strDet = (m_iIndex + 1).ToString() + " / " + m_aImages.Count.ToString() + "\r\n";

            string strFn = sPath;
            int    iPos  = sPath.LastIndexOf('\\');

            if (iPos >= 0)
            {
                strFn = sPath.Substring(iPos + 1);
            }
            strDet += "\r\n" + strFn;

            string strExt = "";
            int    iPos2  = strFn.LastIndexOf('.');

            if (iPos2 >= 0)
            {
                strExt = strFn.Substring(iPos2 + 1);
            }

            //NOT WORKING!!!

            /*
             * bool bGif = false;
             * if( strExt.ToLower() == "gif" )
             *      bGif = true;
             */

            string strFldr = "\\";

            if (iPos >= 0)
            {
                strFldr = sPath.Substring(0, iPos + 1);
            }

            strDet           += "\r\n" + "\r\n" + strFldr;
            txImgDetails.Text = strDet;

            long lFs = 0;

            m_iImgWidth  = 0;
            m_iImgHeight = 0;
            try
            {
                RscStore store = new RscStore();

                //if( !store.FileExists(sPath) ) return;

                Stream stream = store.GetReaderStream(sPath, false);
                lFs = stream.Length;

                //TODO... ImageTools, strExt

                BitmapImage bmp = new BitmapImage();
                bmp.SetSource(stream);
                stream.Close();

                m_iImgWidth  = bmp.PixelWidth;
                m_iImgHeight = bmp.PixelHeight;

                //NOT WORKING!!!

                /*
                 * if( bGif )
                 * {
                 *      imgFull.Visibility = Rsc.Collapsed;
                 *
                 *      //imgGif.Source = bmp;
                 *      imgGif.Source = new Uri( "", UriKind.Absolute );
                 *
                 *      canvGif.Visibility = Rsc.Visible;
                 *
                 *      m_iFrameGif = 0;
                 *      m_tmrGif.Start();
                 * }
                 * else
                 * {
                 *      canvGif.Visibility = Rsc.Collapsed;
                 */

                //strDet += "\r\n" + "bmp( " + bmp.PixelWidth.ToString() + " ; " + bmp.PixelHeight.ToString() + " )";
                //strDet += "\r\n" + "sz( " + sz.Width.ToString() + " ; " + sz.Height.ToString() + " )";
                if ((bmp.PixelWidth <= sz.Width) && (bmp.PixelHeight <= sz.Height))
                {
                    imgFull.Stretch = Stretch.None;
                }
                else
                {
                    imgFull.Stretch = Stretch.Uniform;
                }

                imgFull.Source = bmp;

                //NOT WORKING!!!

                /*
                 *      imgFull.Visibility = Rsc.Visible;
                 * }
                 */
            }
            catch (Exception e)
            {
                strDet += "\r\n" + "\r\nERROR: " + e.Message;

                imgFull.Stretch = Stretch.None;
                imgFull.Source  = m_isDummy;
            }

            if (lFs > 0)
            {
                strDet += "\n\n" + lFs.ToString() + " B" + " ( " + RscUtils.toMBstr(lFs) + " ) ";
            }

            string sDim = "";

            if (m_iImgWidth > 0)
            {
                sDim += m_iImgWidth.ToString();
            }
            else
            {
                sDim += "-";
            }
            sDim += " x ";
            if (m_iImgHeight > 0)
            {
                sDim += m_iImgHeight.ToString();
            }
            else
            {
                sDim += "-";
            }
            strDet += "\n\n" + sDim;

            if (m_strInitErr.Length > 0)
            {
                strDet += "\n\n" + "\r\nApp Init ERROR: " + m_strInitErr;
            }

            txImgDetails.Text = strDet;
        }
Example #24
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>";
            }
        }
Example #25
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);
        }
        private void UpdateContents(double dCY, bool bIgnoreSec = false)
        {
            if (m_tbClk != null)
            {
                if (m_iSecTime >= 1 || bIgnoreSec)
                {
                    m_iSecTime = 0;

                    DateTime dNow = DateTime.Now;
                    m_tbClk.Text = RscUtils.pad60(dNow.Hour) +
                                   ":" + RscUtils.pad60(dNow.Minute) + ":" +
                                   RscUtils.pad60(dNow.Second);
                }
            }

            if (m_tbDt != null)
            {
                if (m_iSecDate >= 1 || bIgnoreSec)
                {
                    m_iSecDate = 0;

                    DateTime dNow = DateTime.Now;
                    string   sCnt = "";

                    sCnt = dNow.Year.ToString() +
                           ". " + RscUtils.pad60(dNow.Month) + ". " +
                           RscUtils.pad60(dNow.Day) + ".";

                    sCnt += " ";
                    switch (dNow.DayOfWeek)
                    {
                    case DayOfWeek.Monday: sCnt += "Hétfő"; break;

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

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

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

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

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

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

                    int iWeek;
                    iWeek = dNow.DayOfYear / 7;
                    if (dNow.DayOfYear % 7 > 0)
                    {
                        iWeek++;
                    }
                    sCnt += ", " + RscUtils.pad60(iWeek) + ". hét";

                    sCnt += ", ";
                    switch (dNow.Month)
                    {
                    case 1: sCnt += "Január"; break;

                    case 2: sCnt += "Február"; break;

                    case 3: sCnt += "Március"; break;

                    case 4: sCnt += "Április"; break;

                    case 5: sCnt += "Május"; break;

                    case 6: sCnt += "Június"; break;

                    case 7: sCnt += "Július"; break;

                    case 8: sCnt += "Augusztus"; break;

                    case 9: sCnt += "Szeptember"; break;

                    case 10: sCnt += "Október"; break;

                    case 11: sCnt += "November"; break;

                    case 12: sCnt += "December"; break;
                    }

                    m_tbDt.Text = sCnt;
                }
            }

            if (m_tbFs != null)
            {
                if (m_iSecFree >= 10 || bIgnoreSec)
                {
                    m_iSecFree = 0;

                    string sCnt = "";

                    string sIsoStoreDrive = "";
                    if (sCnt.Length > 0)
                    {
                        sCnt += " | ";
                    }
                    sCnt = RscUtils.toMBstr(RscStore.AvailableFreeSpace(out sIsoStoreDrive));
                    if (sIsoStoreDrive.Length > 0)
                    {
                        // WRONG AvailableFreeSpace VALUE!!!
                        //sCnt = sIsoStoreDrive + " " + sCnt;

                        sCnt = sIsoStoreDrive;
                    }

                    if (Windows.System.Power.PowerManager.BatteryStatus == Windows.System.Power.BatteryStatus.NotPresent)
                    {
                        if (sCnt.Length > 0)
                        {
                            sCnt += " | ";
                        }
                        sCnt += "AC POWER";
                    }
                    else
                    {
                        if (sCnt.Length > 0)
                        {
                            sCnt += " | ";
                        }
                        sCnt += Windows.System.Power.PowerManager.RemainingChargePercent.ToString() + " %";
                        if (Windows.System.Power.PowerManager.PowerSupplyStatus != Windows.System.Power.PowerSupplyStatus.Adequate)
                        {
                            sCnt += "";                             //" (batt)";
                        }
                        else
                        {
                            sCnt += " (chrg)";
                        }
                    }

                    //TODO...

                    /*
                     * if (DeviceNetworkInformation.IsWiFiEnabled)
                     * {
                     *      if (sCnt.Length > 0) sCnt += " | ";
                     *      sCnt += "WiFi (";
                     *
                     *      //TODO...
                     *      /*
                     *      NetworkInterfaceList nil;
                     *      nil = new NetworkInterfaceList();
                     *      foreach (NetworkInterfaceInfo ni in nil)
                     *      {
                     *              if (ni.InterfaceState == ConnectState.Connected)
                     *              {
                     *                      if (ni.InterfaceSubtype == NetworkInterfaceSubType.WiFi)
                     *                      {
                     *                              sCnt += ni.Description;
                     *                              break;
                     *                      }
                     *              }
                     *      }
                     *
                     *
                     *      sCnt += ")";
                     * }
                     */

                    m_tbFs.Text = sCnt;
                }
            }

            if (m_iSecMove >= 5 || bIgnoreSec)
            {
                m_iSecMove = 0;

                Random rnd;
                rnd = new Random();

                int iTop;
                iTop = rnd.Next(((int)dCY) - iBandHeight);

                m_grid.Margin = new Thickness(0, iTop, 0, 0);
            }
        }
        private void Touch_FrameReported(object sender, System.Windows.Input.TouchFrameEventArgs e)
        {
            string sLog;

            DateTime dNow = DateTime.Now;

            sLog = RscUtils.pad60(dNow.Minute) + ":" + RscUtils.pad60(dNow.Second) + " - ";

            TouchPoint primaryTouchPoint = e.GetPrimaryTouchPoint(null);

            if (primaryTouchPoint == null)
            {
                sLog += "null";
                lstLog.Items.Insert(0, sLog);
            }
            else
            {
                if (primaryTouchPoint.TouchDevice.DirectlyOver != imgTestArea)
                {
                    return;
                }
                else
                {
                    if (primaryTouchPoint.Action == TouchAction.Down)
                    {
                        ptStart = primaryTouchPoint.Position;
                    }

                    sLog += primaryTouchPoint.Action.ToString();
                    lstLog.Items.Insert(0, sLog);

                    sLog  = "      ";
                    sLog += primaryTouchPoint.Position.ToString();
                    lstLog.Items.Insert(1, sLog);

                    sLog  = "      ";
                    sLog += primaryTouchPoint.Size.ToString();
                    lstLog.Items.Insert(2, sLog);

                    sLog = "      ";
                    if (ptStart.X <= primaryTouchPoint.Position.X)
                    {
                        sLog += "Right";
                    }
                    else
                    {
                        sLog += "Left";
                    }
                    lstLog.Items.Insert(3, sLog);

                    sLog = "      ";
                    if (ptStart.Y <= primaryTouchPoint.Position.Y)
                    {
                        sLog += "Down";
                    }
                    else
                    {
                        sLog += "Top";
                    }
                    lstLog.Items.Insert(4, sLog);

                    /*
                     * sLog = "      ";
                     * sLog += (primaryTouchPoint.Position.X - ptStart.X).ToString();
                     * sLog += ":";
                     * sLog += (primaryTouchPoint.Position.Y - ptStart.Y).ToString();
                     * lstLog.Items.Insert(5, sLog);
                     *
                     * sLog = "      ";
                     * sLog += ptStart.ToString();
                     * lstLog.Items.Insert(6, sLog);
                     */
                }
            }
        }