/// <summary> /// Lance le calcul de génération d'une grille de planète. /// </summary> /// <param name="planetPosition"></param> /// <param name="planetRadius"></param> /// <param name="gridSize"></param> /// <param name="noiseLow"></param> /// <param name="noiseHigh"></param> /// <param name="repartitionNoise"></param> /// <param name="world"></param> /// <param name="initialGridPos"></param> /// <param name="gridLevelScale"></param> public void RunCalculation(Vector3 planetPosition, float planetRadius, int gridSize, Noise.NoiseMapGenerator.NoiseParameters noiseLow, Noise.NoiseMapGenerator.NoiseParameters noiseHigh, Noise.NoiseMapGenerator.NoiseParameters repartitionNoise, Matrix world, Vector2 initialGridPos, float gridLevelScale) { if (m_isComputing) { throw new NotImplementedException(); } m_planetPosition = planetPosition; m_planetRadius = planetRadius; m_gridSize = gridSize; IsRessourceReady = false; System.Threading.Thread.CurrentThread.Priority = ThreadPriority.Highest; Thread thread = new Thread(() => { m_isComputing = true; System.Threading.Thread.CurrentThread.Priority = ThreadPriority.Normal; var low = noiseLow.CreateNoise(); var high = noiseHigh.CreateNoise(); var rep = repartitionNoise.CreateNoise(); BoundingBox aabb; Generation.ChunkAltitude altitude; Buffer vertexBuffer; Generation.ModelGenerator.GeneratePlanet(planetPosition, planetRadius, gridSize, initialGridPos, gridLevelScale, low, high, rep, // bruits out vertexBuffer, out aabb, out altitude); // Si on abort la tâche. Ressource = new Rsc() { VertexBuffer = vertexBuffer, Box = aabb, Altitude = altitude }; IsRessourceReady = true; m_isComputing = false; m_currentThread = null; if (m_isAborted) { Ressource.Dispose(); IsRessourceReady = false; } }); m_currentThread = thread; Scene.Instance.ThreadPool.AddThread(thread); }
private void _ReadTextFile() { if (m_iIndex == 0) { m_btnPrev.Visibility = Rsc.Collapsed; } else { m_btnPrev.Visibility = Rsc.Visible; } if (m_iIndex >= (m_aPathes.Count - 1)) { m_btnNext.Visibility = Rsc.Collapsed; } else { m_btnNext.Visibility = Rsc.Visible; } m_btnShare.Visibility = Rsc.ConditionalVisibility(m_aPathes.Count > 0); if (m_aPathes.Count == 0) { m_AppFrame.StatusText = "0 of 0"; m_txtPath.Text = ""; m_aLines.Clear(); return; } m_AppFrame.StatusText = (m_iIndex + 1).ToString() + " of " + m_aPathes.Count.ToString(); m_sPath_TEMP = m_aPathes[m_iIndex]; m_txtPath.Text = m_sPath_TEMP; RscStore store = new RscStore(); bool bNotExist = false; m_sContent_TEMP = store.ReadTextFile(m_sPath_TEMP, "", out bNotExist); if (m_sContent_TEMP.Length == 0) { return; } m_aLines.Clear(); m_AppFrame.StartTimer("load", LayoutRoot, 1, 0, false); }
// Code to execute when the application is launching (eg, from Start) // This code will not execute when the application is reactivated private void Application_Launching(object sender, LaunchingEventArgs e) { MDeviceUniqueId = BitConverter.ToString(Convert.FromBase64String(Windows.Phone.System.Analytics.HostInformation.PublisherHostId)).Replace("-", string.Empty); // Rayzit API Client & Push Notification Service Rsc = new Rsc("WP8APP_AVC3PAFGO054FLP3AGEL0L", MDeviceUniqueId); LocFinder.Update(); FlurryWP8SDK.Api.StartSession("H66V7XHYX85YKD7RMH7G"); FlurryWP8SDK.Api.LogEvent("Application_Launching"); CheckDatabase(); // Network Interface Event Callbacks NetworkInformation.NetworkStatusChanged += NetworkInformation_NetworkStatusChanged; }
/// <summary> /// Agent that runs a scheduled task /// </summary> /// <param name="task"> /// The invoked task /// </param> /// <remarks> /// This method is called when a periodic or resource intensive task is invoked /// </remarks> protected override async void OnInvoke(ScheduledTask task) { // Nothing to be done without Internet Connectivity if (!NetworkInterface.GetIsNetworkAvailable()) { NotifyComplete(); return; } var appSettings = IsolatedStorageSettings.ApplicationSettings; var enabled = appSettings.Contains("LocationToggleSwitchSetting") && (bool)appSettings["LocationToggleSwitchSetting"]; if (!enabled) { NotifyComplete(); return; } var rsc = new Rsc("<API ID>", MDeviceUniqueId); Geolocation = await new LocationFinderBG().GetLocation(); // Problem occured with Geolocation if (Geolocation == null) { NotifyComplete(); return; } // Update User's Position await rsc.UpdatePosition(Geolocation.Latitude, Geolocation.Longitude, Geolocation.Accuracy); // Request User's LiveFeed with one random (latest) rayz var reply = await rsc.GetLiveFeedRandom(); await ParseLiveFeed(reply); //ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(60)); NotifyComplete(); }
// // // // private void SetLastFile(string sLastFile, bool bIsFolder, long lSize = -1) { m_sLastFile = sLastFile; m_bLastFileIsFolder = bIsFolder; m_lLastFileSize = lSize; bool bHas = m_sLastFile.Length > 0; lastFilePanel.Visibility = Rsc.ConditionalVisibility(bHas); m_btnRemoteEnter.Visibility = Rsc.ConditionalVisibility(bHas && bIsFolder); m_btnDownloadMem.Visibility = Rsc.ConditionalVisibility(bHas && !bIsFolder && lSize >= 0); m_btnDownloadFile.Visibility = Rsc.ConditionalVisibility(bHas && !bIsFolder && lSize >= 0); m_btnRemoteDateTime.Visibility = Rsc.ConditionalVisibility(bHas); m_btnRemoteList.Visibility = Rsc.ConditionalVisibility(bHas && bIsFolder); m_txtLastFile.Text = m_sLastFile; }
public RscDlg_TxtInputV10() { InitializeComponent(); m_AppFrame = new RscAppFrame("Ressive.Hu", "Text Input 1.0", "Images/Ico001_Ressive.jpg" , this, AppTitleBar, AppStatusBar); // /////////////// m_AppFrame.OnNext += new Ressive.FrameWork.RscAppFrame.OnNext_EventHandler(m_AppFrame_OnNext); m_AppFrame.OnExit += new Ressive.FrameWork.RscAppFrame.OnExit_EventHandler(m_AppFrame_OnExit); RscPageArgsRetManager appArgsMgr = new RscPageArgsRetManager(); m_AppInput = appArgsMgr.GetInput(csClsName); if (m_AppInput != null) { m_AppFrame.AppTitle = m_AppInput.CallerAppTitle; m_AppFrame.AppIconRes = m_AppInput.CallerAppIconRes; lbStr.Text = m_AppInput.GetFlag(0); txStr.Text = m_AppInput.GetData(0); m_bUseHistory = (m_AppInput.GetFlag(3).Length == 0); lbHis.Visibility = Rsc.ConditionalVisibility(m_bUseHistory); scrl.Visibility = Rsc.ConditionalVisibility(m_bUseHistory); if (txStr.Text.Length == 0 && m_bUseHistory) { string sPath = "Software\\Ressive.Hu\\" + csClsName + "\\History"; sPath += "\\" + m_AppInput.CallerAppTitle; sPath += "\\" + m_AppInput.ID; txStr.Text = RscRegistry.ReadString(HKEY.HKEY_CURRENT_USER, sPath, "LastOk", ""); } _LoadHistory(); } }
private async static Task <bool> ParseLiveFeed(IJSonObject e) { var imageUrl = String.Empty; var counter = 0; var rayzMessage = String.Empty; foreach (var objItem in e.ObjectItems) { switch (objItem.Key) { case "counter": counter = Convert.ToInt16(objItem.Value.ToString()); break; case "liveFeed": var x = objItem.Value.ArrayItems.FirstOrDefault(); if (x != null) { // Extract Rayz details foreach (var oi in x.ObjectItems) { switch (oi.Key) { case "rayz_message": rayzMessage = oi.Value.ToString(); break; case "attachments": foreach (var attachmentObject in oi.Value.ObjectItems) { var stop = false; switch (attachmentObject.Key) { case "images": var img = attachmentObject.Value.ArrayItems.FirstOrDefault(); if (img != null) { imageUrl = img["url"].StringValue; } stop = true; break; } if (stop) { break; } } break; } } } break; } } if (!String.IsNullOrEmpty(imageUrl)) { var rsc = new Rsc("<API ID>", MDeviceUniqueId); var image = await rsc.RequestAttachment(imageUrl); if (image != null) { Deployment.Current.Dispatcher.BeginInvoke(() => { const string fileName = "/Shared/ShellContent/tile.jpg"; using ( var myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication() ) { if (myIsolatedStorage.FileExists(fileName)) { myIsolatedStorage.DeleteFile(fileName); } var fileStream = myIsolatedStorage.CreateFile(fileName); fileStream.Write(image, 0, image.Length); fileStream.Close(); } }); } } //if (!String.IsNullOrEmpty(rayzMessage)) // ShowToast(rayzMessage); if (String.IsNullOrEmpty(rayzMessage)) { ResetLiveTile(); } else { UpdateLiveTile(rayzMessage, counter, !String.IsNullOrEmpty(imageUrl)); } return(true); }
private void m_AppFrame_OnTimer(object sender, RscAppFrameTimerEventArgs e) { switch (e.Reason) { case "list files_Cancel": { m_folders.Clear(); m_files.Clear(); m_AppFrame.SetStatusText("User canceled operation!", StatusColoring.Error); break; } case "list files": { string sFileFilter = txFilter.Text; if (sFileFilter.Length == 0) { sFileFilter = "*.*"; } sFileFilter = sFileFilter.Replace("\\", ""); sFileFilter = sFileFilter.Replace("/", ""); sFileFilter = sFileFilter.Replace(":", ""); sFileFilter = sFileFilter.Replace(('"').ToString(), ""); sFileFilter = sFileFilter.Replace("<", ""); sFileFilter = sFileFilter.Replace(">", ""); sFileFilter = sFileFilter.Replace("|", ""); RscFileItemDesc itCurrent; RscFileItemDesc it; RscStore store = new RscStore(); itCurrent = m_folders[e.Pos]; if (!itCurrent.bWalked) { if (chbRecurse.IsChecked.Value) { string[] fldrs = RscSort.OrderBy(store.GetFolderNames(itCurrent.Path, "*.*", chbShowHidden.IsChecked.Value)); foreach (string node in fldrs) { it = new RscFileItemDesc(m_AppFrame.Theme); it.bFolder = true; it.bWalked = false; it.strParent = itCurrent.Path; it.strFileName = node; e.Max++; it.Parent = m_folders; m_folders.Add(it); } } itCurrent.bWalked = true; if (e.Pos == e.Max) { e.Pos = 0; } } else { if (itCurrent.LastError.Length == 0) //Otherwise Not Exist!!! { string[] fles = RscSort.OrderBy(store.GetFileNames(itCurrent.Path, sFileFilter, chbShowHidden.IsChecked.Value)); foreach (string node in fles) { it = new RscFileItemDesc(m_AppFrame.Theme); it.bFolder = false; it.bWalked = false; it.strParent = itCurrent.Path; it.strFileName = node; it.Parent = m_files; m_files.Add(it); } } if (e.Pos == e.Max) { //ReQuery... lbFiles.ItemsSource = null; lbFiles.ItemsSource = m_files; btnRename.Visibility = Rsc.ConditionalVisibility(m_files.Count == 1 && m_folders.Count == 1); imgRename.Visibility = btnRename.Visibility; // ActionPanel.Visibility = Rsc.ConditionalVisibility( (m_files.Count > 0 || m_txtRootFldr.Text.Length > 0) && m_folders[0].LastError.Length == 0); m_btnDelete.Visibility = Rsc.ConditionalVisibility( (m_files.Count > 0 || m_folders.Count > 0 /*|| m_txtRootFldr.Text.Length > 0*/) && m_folders[0].LastError.Length == 0); // btnCopy.Visibility = Rsc.ConditionalVisibility( (m_files.Count > 0 /*|| m_txtRootFldr.Text.Length > 0*/) && m_folders[0].LastError.Length == 0); imgCopy.Visibility = btnCopy.Visibility; // btnMove.Visibility = Rsc.ConditionalVisibility( (m_files.Count > 0 /*|| m_txtRootFldr.Text.Length > 0*/) && m_folders[0].LastError.Length == 0); imgMove.Visibility = btnMove.Visibility; m_AppFrame.SetStatusText(m_files.Count.ToString() + " file(s) in " + m_folders.Count.ToString() + " folder(s) listed"); // // // if (m_sAutoOperation.Length > 0) { ActionPanel.Visibility = Rsc.Collapsed; switch (m_sAutoOperation) { case "AutoDelete": m_AppFrame.AutoClick(m_btnDelete, new System.Windows.RoutedEventHandler(m_btnDelete_Click)); break; } } // // // } } break; } default: m_AppFrame_OnTimer_Sub1(sender, e); break; } }
/* * 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; } } }
private void LoadContent( ) { string sPath = m_sPath_TEMP; m_sPath_TEMP = ""; string sContent = m_sContent_TEMP; m_sContent_TEMP = ""; // // // string sExt = RscStore.ExtensionOfPath(sPath); sExt = sExt.ToUpper(); switch (sExt) { case ".VCF": RscTextTags_VCF tags = new RscTextTags_VCF(); m_tags = tags; tags.Parse(sContent, "\r\n", ":", ";"); if (tags.PhotoPresent && tags.PhotoIsBase64 && tags.PhotoIs("JPEG")) { string sBase64 = tags.PhotoData; //RscFs.WriteTextFile( "vcf.photo.txt", sBase64, true ); byte [] ayImage = Convert.FromBase64String(sBase64); if (ayImage != null) { if (ayImage.Length > 0) { /* * RscStore store = new RscStore(); * if( store.FileExists("vcf.photo.jpg") ) store.DeleteFile("vcf.photo.jpg"); * System.IO.Stream stream = store.CreateFile("vcf.photo.jpg"); * stream.Write( ayImage, 0, ayImage.Length ); * stream.Close(); */ System.IO.MemoryStream ms = new System.IO.MemoryStream(ayImage.Length); ms.Write(ayImage, 0, ayImage.Length); ms.Seek(0, System.IO.SeekOrigin.Begin); BitmapImage bmp = new BitmapImage(); bmp.SetSource(ms); ms.Close(); Img.Source = bmp; Img.Visibility = Rsc.Visible; } else { Img.Visibility = Rsc.Collapsed; } } else { Img.Visibility = Rsc.Collapsed; } } else { //MessageBox.Show( "No photo present!" ); Img.Visibility = Rsc.Collapsed; } btnCall.Content = "Call " + tags.PhoneNumber(0); BtnGrid.Visibility = Rsc.ConditionalVisibility(tags.PhoneNumber(0).Length > 0); RscStore store = new RscStore(); bool bExists = false; if (store.FolderExists("A:\\Desktop")) { if (store.FolderExists("A:\\Desktop\\Contacts")) { bExists = store.FileExists("A:\\Desktop\\Contacts\\" + tags.Name + ".txt"); } } if (bExists) { btnEx.Content = "Remove from Desktop"; BtnGridEx.Background = new SolidColorBrush(Colors.Red); } else { btnEx.Content = "Add to Desktop"; BtnGridEx.Background = new SolidColorBrush(Colors.Green); } BtnGridEx.Visibility = Rsc.ConditionalVisibility(tags.PhoneNumber(0).Length > 0); break; default: Img.Visibility = Rsc.Collapsed; BtnGrid.Visibility = Rsc.Collapsed; m_tags = null; break; } // // // if (m_tags == null) { m_aLines.FontSize = 18; m_aLines.Text = sContent; } else { m_aLines.FontSize = 22; m_aLines.Text = m_tags.ToString(); } }
/// <summary> /// Lance le calcul de génération d'une grille de planète. /// </summary> /// <param name="planetPosition"></param> /// <param name="planetRadius"></param> /// <param name="gridSize"></param> /// <param name="noiseLow"></param> /// <param name="noiseHigh"></param> /// <param name="repartitionNoise"></param> /// <param name="world"></param> /// <param name="initialGridPos"></param> /// <param name="gridLevelScale"></param> public void RunCalculation(Vector3 planetPosition, float planetRadius, int gridSize, Noise.NoiseMapGenerator.NoiseParameters noiseLow, Noise.NoiseMapGenerator.NoiseParameters noiseHigh, Noise.NoiseMapGenerator.NoiseParameters repartitionNoise, Matrix world, Vector2 initialGridPos, float gridLevelScale) { if (m_isComputing) throw new NotImplementedException(); m_planetPosition = planetPosition; m_planetRadius = planetRadius; m_gridSize = gridSize; IsRessourceReady = false; System.Threading.Thread.CurrentThread.Priority = ThreadPriority.Highest; Thread thread = new Thread(() => { m_isComputing = true; System.Threading.Thread.CurrentThread.Priority = ThreadPriority.Normal; var low = noiseLow.CreateNoise(); var high = noiseHigh.CreateNoise(); var rep = repartitionNoise.CreateNoise(); BoundingBox aabb; Generation.ChunkAltitude altitude; Buffer vertexBuffer; Generation.ModelGenerator.GeneratePlanet(planetPosition, planetRadius, gridSize, initialGridPos, gridLevelScale, low, high, rep, // bruits out vertexBuffer, out aabb, out altitude); // Si on abort la tâche. Ressource = new Rsc() { VertexBuffer = vertexBuffer, Box = aabb, Altitude = altitude }; IsRessourceReady = true; m_isComputing = false; m_currentThread = null; if(m_isAborted) { Ressource.Dispose(); IsRessourceReady = false; } }); m_currentThread = thread; Scene.Instance.ThreadPool.AddThread(thread); }