Exemple #1
0
        private void MessageReceived(ProximityDevice sender, ProximityMessage message)
        {
            NdefMessage ndefMessage = new NdefMessage();

            ndefMessage.AddRecord(new NdefRecord
            {
                Data       = message.Data.ToArray(),
                RecordType = message.MessageType
            });

            Reading?.Invoke(this, ndefMessage);
        }
Exemple #2
0
        public async Task <bool> ReadInFolderAsync()
        {
            Debug.Assert(IsDeWrapper);
            var folders = (await TmpFolder.GetFoldersAsync()).Where(folder => folder.DisplayName == InkStrokesFolderName).ToList();

            if (folders.Count != 0)
            {
                var folder = folders[0];
                var files  = (await folder.GetFilesAsync()).Where(f => f.FileType.ToLower() == ".isf");
                foreach (var file in files)
                {
                    var ic       = new InkCanvas();
                    var filename = file.Name.Substring(0, file.Name.Length - 4);
                    using (var fs = await file.OpenAsync(FileAccessMode.ReadWrite))
                    {
                        await ic.InkPresenter.StrokeContainer.LoadAsync(fs);
                    }
                    var strokes  = ic.InkPresenter.StrokeContainer.GetStrokes().ToList();
                    var gslength = Enum.GetValues(typeof(GraphicsTypes)).Length;
                    var layer    = new LayerModel();
                    foreach (var stroke in strokes)
                    {
                        var gi = stroke.StrokeDuration.Value.Ticks;
                        if (gi > 0 && gi < gslength)
                        {
                            var gr = (GraphicsRectSizeBase)GraphicsInstCreateManager.CreateGraphics((GraphicsTypes)gi, layer.LocPenModel, layer, layer);
                            Debug.Assert(gr != null);
                            stroke.GetInkPoints().ToList().ForEach(p => gr.Points.Add(p));
                            gr.PenAttribute = PenModel.ToPenModel(stroke.DrawingAttributes);
                            layer.GraphicsRects.Add(gr);
                        }
                    }
                    layer.Name       = filename;
                    layer.CanvasSize = CanvasSize;
                    Debug.Assert(XmlDoc != null);
                    var xmlEle = XmlDoc.SelectSingleNode(filename);
                    if (xmlEle != null)
                    {
                        var layerData = xmlEle.ChildNodes.Where(xmlNode => xmlNode.NodeName == "IsLock" || xmlNode.NodeName == "IsAppear").ToArray();
                        Debug.Assert(layerData.Count() == 2);
                        layer.IsLock   = Convert.ToBoolean(layerData[0].InnerText);
                        layer.IsAppear = Convert.ToBoolean(layerData[1].InnerText);
                    }
                    //TODO:Init Others
                    Reading?.Invoke(XmlDoc);
                    Layers.Add(layer);
                }
                return(true);
            }
            return(false);
        }
        public static void Read()
        {
            if (File.Exists(FILEPATH))
            {
                var json = File.ReadAllBytes(FILEPATH);
                MainWindow.MainViewModel = MessagePackSerializer.Deserialize <MainWindowViewModel>(json);

                if (MainWindow.MainViewModel == null)
                {
                    MainWindow.MainViewModel = defaultViewModel;
                }
            }
            else
            {
                MainWindow.MainViewModel = defaultViewModel;
            }

            if (File.Exists(COLOR_FILEPATH))
            {
                var colorJson = File.ReadAllText(COLOR_FILEPATH);
                JsonConvert.DeserializeObject <SpiritThemeColor>(colorJson);
            }
            else
            {
                ThemeWrite();
            }

            if (File.Exists(KEY_FILEPATH))
            {
                var Key    = File.ReadAllBytes(KEY_FILEPATH);
                var strKey = MessagePackSerializer.Deserialize <string>(Key);
                HttpClient.DefaultRequestHeaders.Add("X-ZUMO-AUTH", strKey);
                Reading += async() =>
                {
                    var(model, IsSuccess) = await GetDataAsync();

                    if (IsSuccess)
                    {
                        MainWindow.MainViewModel.UpdateViewModel(model);
                    }
                };
                IsAuth = true;
            }

            Reading?.Invoke();

            Wrote += async bytes => await PostDataAsync(bytes);

            MainWindow.MainViewModel.Lists.ObserveElementPropertyChanged().Subscribe(_ => Write());
            MainWindow.MainViewModel.Lists.CollectionChanged += (a, e) => Write();
        }
Exemple #4
0
        void NfcAdapter.IReaderCallback.OnTagDiscovered(Tag tag)
        {
            var techList = tag.GetTechList();

            foreach (string tech in techList)
            {
                if (tech == "android.nfc.tech.Ndef")
                {
                    var ndef = Ndef.Get(tag);
                    ndef.Connect();
                    var msg = ndef.NdefMessage;
                    ndef.Dispose();

                    // parse message

                    Reading?.Invoke(this, null);
                    break;
                }
            }
        }
Exemple #5
0
 public void WorkInProgress(long current, long overall)
 {
     Reading?.Invoke(current, overall);
 }
Exemple #6
0
 void IStreamInspector.Reading(byte[] buffer, int offset, int count)
 {
     Reading?.Invoke(buffer, offset, count);
 }
Exemple #7
0
 private void OnReading(int lux)
 {
     Reading?.Invoke(lux, new GY30LightSensorEventArgs(lux));
 }
Exemple #8
0
 protected virtual void OnReading(int e)
 {
     Reading?.Invoke(this, e);
 }