示例#1
0
        // 생성자
        public MainPage()
        {
            InitializeComponent ();

            cameraTask.Completed += ( object sender, PhotoResult e ) =>
            {
                if ( e.TaskResult == TaskResult.Cancel ) return;

                BitmapImage bitmapImage = new BitmapImage ();
                bitmapImage.SetSource ( e.ChosenPhoto );
                DateTime dateTime = DateTime.Now;
                byte [] photoBuffer = new byte [ e.ChosenPhoto.Length ];

                e.ChosenPhoto.Position = 0;
                e.ChosenPhoto.Read ( photoBuffer, 0, ( int ) e.ChosenPhoto.Length );

                Memo memo = new Memo ( MemoType.Photo, photoBuffer, dateTime );
                memoStorage.MemoList.Add ( memo );
                AddItemToStackBottom ( new PhotoThread ( bitmapImage, dateTime ), memo.MemoID );
            };

            mic.BufferDuration = TimeSpan.FromSeconds ( 1 );
            mic.BufferReady += ( object sender, EventArgs e ) =>
            {
                byte [] buffer = new byte [ mic.GetSampleSizeInBytes ( mic.BufferDuration ) ];
                mic.GetData ( buffer, 0, buffer.Length );
                recordStream.Write ( buffer, 0, buffer.Length );
            };

            if ( new LicenseInformation ().IsTrial () )
            {
                //abbRecord.IsEnabled = false;
                ( ApplicationBar.Buttons [ 2 ] as ApplicationBarIconButton ).IsEnabled = false;
            }
        }
示例#2
0
        public MemoStorage(Action<Memo> loadedOne)
        {
            LoadedOne = loadedOne;

            try
            {
                using ( IsolatedStorageFileStream fs = new IsolatedStorageFileStream ( "memo.mem", FileMode.Open,
                    IsolatedStorageFile.GetUserStoreForApplication () ) )
                {
                    BinaryReader br = new BinaryReader ( fs );
                    int count = br.ReadInt32 ();
                    Memo.memoIdGenerator = br.ReadInt64 ();
                    for ( int i = 0; i < count; i++ )
                    {
                        Memo memo = new Memo ();
                        memo.MemoID = br.ReadInt64 ();
                        memo.MemoType = ( MemoType ) br.ReadByte ();
                        switch ( memo.MemoType )
                        {
                            case MemoType.Text:
                                memo.MemoObject = br.ReadString ();
                                break;
                            case MemoType.Photo:
                            case MemoType.Voice:
                                int len = br.ReadInt32 ();
                                memo.MemoObject = br.ReadBytes ( len );
                                break;
                        }
                        memo.MemoDate = DateTime.Parse ( br.ReadString () );

                        memoList.Add ( memo );
                        if ( loadedOne != null )
                            loadedOne ( memo );
                    }
                    memoList.Reverse ();
                }
            }
            catch ( Exception e ) { Debug.WriteLine ( e.StackTrace ); }
        }
示例#3
0
        private void abbRecord_Click( object sender, EventArgs e )
        {
            switch ( isRecordStarted )
            {
                case false:
                    {
                        isRecordStarted = true;
                        SystemTray.ProgressIndicator.IsVisible = true;
                        recordStream = new MemoryStream ();
                        mic.Start ();

                        phoneAppService.UserIdleDetectionMode = IdleDetectionMode.Disabled;
                    }
                    break;
                case true:
                    {
                        isRecordStarted = false;
                        SystemTray.ProgressIndicator.IsVisible = false;
                        mic.Stop ();

                        SoundEffectInstance soundEffect = new SoundEffect ( recordStream.ToArray (),
                            mic.SampleRate, AudioChannels.Mono ).CreateInstance ();

                        DateTime dateTime = DateTime.Now;
                        Memo memo = new Memo ( MemoType.Voice, recordStream.ToArray (), dateTime );
                        memoStorage.MemoList.Add ( memo );
                        AddItemToStackBottom ( new VoiceThread ( soundEffect, dateTime ), memo.MemoID );

                        soundEffect = null;

                        recordStream.Dispose ();
                        recordStream = null;

                        phoneAppService.UserIdleDetectionMode = IdleDetectionMode.Enabled;
                    }
                    break;
            }
        }
示例#4
0
        private void abbSave_Click( object sender, EventArgs e )
        {
            if ( txtMemo.Text.Trim () == "" )
            {
                MessageBox.Show ( "텍스트가 비어 있습니다!", "메모스레드", MessageBoxButton.OK );
                return;
            }

            DateTime dateTime = DateTime.Now;
            Memo memo = new Memo ( MemoType.Text, txtMemo.Text, dateTime );
            memoStorage.MemoList.Add ( memo );
            AddItemToStackBottom ( new TextThread ( txtMemo.Text, dateTime ), memo.MemoID );

            this.Focus ();
            txtMemo.Text = "";
            txtMemo.Focus ();
        }