public Extension(AppExtension ext, PropertySet properties, BitmapImage logo) { _extension = ext; _properties = properties; _enabled = false; _loaded = false; _offline = false; _logo = logo; _visibility = Visibility.Collapsed; _extwebview = new WebView(); #region Properties _serviceName = null; if (_properties != null) { if (_properties.ContainsKey("Service")) { PropertySet serviceProperty = _properties["Service"] as PropertySet; _serviceName = serviceProperty["#text"].ToString(); } } #endregion //AUMID + Extension ID is the unique identifier for an extension _uniqueId = ext.AppInfo.AppUserModelId + "!" + ext.Id; // webview event when the extension notifies us that something happened _extwebview.ScriptNotify += ExtensionCallback; }
private static PropertySet ExtractExceptionProperties(Exception exception) { PropertySet properties = null; foreach (PropertyInfo propertyInfo in exception.GetType().GetProperties()) { string propertyName = propertyInfo.Name; if (IsBuiltInPropertyName(propertyName)) { continue; } if (IsIgnoredProperty(propertyInfo)) { continue; } if (propertyInfo.GetIndexParameters().Length != 0) { continue; } string propertyValue; try { object obj = propertyInfo.GetValue(exception, null); if (obj == null) { continue; } propertyValue = obj.ToString(); } catch { continue; } if (properties == null) { properties = new PropertySet(); } if (!properties.ContainsKey(propertyName)) { properties.Add(propertyName, propertyValue); } } return(properties ?? NoProperties); }
private void _mediaPlayer_CurrentStateChanged(MediaPlayer sender, object args) { Debug.WriteLine(sender.CurrentState.ToString()); // filter property set is ready after opening on the next paused if (sender.CurrentState == MediaPlayerState.Playing) { if (_referenceProperties.ContainsKey("samplegrabber")) { // Debug.WriteLine(customStruct.Value); //TODO get a ringbuffer interface } } }
public void New(AppExtension ext) { if (UniqueId == ext.AppInfo.AppUserModelId + Consts.ArraySeparator + ext.Id) { AppExtension = ext; #region Properties if (_properties != null) { if (_properties.ContainsKey("Service")) { PropertySet serviceProperty = _properties["Service"] as PropertySet; _serviceName = serviceProperty["#text"].ToString(); } } #endregion } }
public Extension(AppExtension ext, IPropertySet properties) { AppExtension = ext; _properties = properties as PropertySet; #region Properties if (_properties != null) { if (_properties.ContainsKey("Service")) { PropertySet serviceProperty = _properties["Service"] as PropertySet; _serviceName = serviceProperty["#text"].ToString(); } } #endregion //AUMID + Extension ID is the unique identifier for an extension UniqueId = ext.AppInfo.AppUserModelId + Consts.ArraySeparator + ext.Id; }
/// <summary> /// Called when an extension that has already been loaded is updated /// </summary> /// <param name="ext">The updated extension as represented by the system</param> /// <returns></returns> public async Task Update(AppExtension ext) { // ensure this is the same uid string identifier = ext.AppInfo.AppUserModelId + "!" + ext.Id; if (identifier != this.UniqueId) { return; } var properties = await ext.GetExtensionPropertiesAsync() as PropertySet; // get the logo for the extension var filestream = await(ext.AppInfo.DisplayInfo.GetLogo(new Windows.Foundation.Size(1, 1))).OpenReadAsync(); BitmapImage logo = new BitmapImage(); logo.SetSource(filestream); // update the extension this.AppExtension = ext; _properties = properties; Logo = logo; #region Update Properties // update app service information _serviceName = null; if (_properties != null) { if (_properties.ContainsKey("Service")) { PropertySet serviceProperty = _properties["Service"] as PropertySet; this._serviceName = serviceProperty["#text"].ToString(); } } #endregion await MarkAsLoaded(); }
private static PropertySet CollectProperties(object target) { Type targetType = target.GetType(); PropertySet result; if (!Properties.TryGetValue(targetType, out result)) { result = new PropertySet(); foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(target, PropertyFilter)) { if (!result.ContainsKey(descriptor.Name)) { result.Add(descriptor.Name, new PropertyData(descriptor)); CollectAttributes(target, descriptor); } } Properties.Add(targetType, result); } return(result); }
/// <summary> /// Creates an Extension object that represents an extension in the extension manager /// </summary> /// <param name="ext">系统声明的扩展类 The extension as represented by the system</param> /// <param name="properties">有关扩展的属性 Properties about the extension</param> /// <param name="logo">扩展的图标 The logo associated with the package that the extension is defined in</param> public DictionaryExtension(AppExtension ext, PropertySet properties, BitmapImage logo) { AppExtension = ext; _properties = properties; Enabled = false; Loaded = false; Offline = false; Logo = logo; Visible = Visibility.Collapsed; #region Properties _serviceName = null; if (_properties != null) { if (_properties.ContainsKey("Service")) { PropertySet serviceProperty = _properties["Service"] as PropertySet; var service_Name = serviceProperty["#text"].ToString(); _serviceName = service_Name; string[] mm = Regex.Split(service_Name, "\\s+", RegexOptions.IgnoreCase); AddNewDictionary(new ExtensionDictionaryModel(this) { SourceLanguage = Language.EN, TargetLanguage = Language.CN, DictionaryType = DictionaryType.Extension, Name = AppExtension.DisplayName }); //SourceLanguage = mm[0]; //TargetLanguage = mm[1]; } } #endregion UniqueId = ext.AppInfo.AppUserModelId + "!" + ext.Id; // The name that identifies this extension in the extension manager }
private void Canvas_Draw(ICanvasAnimatedControl sender, CanvasAnimatedDrawEventArgs args) { if (!_properties.ContainsKey("chart")) { return; } if (_spectrum == null) { _spectrum = _properties["chart"] as float[]; if (_spectrum == null) { return; } _current = new float[_spectrum.Length / 4]; _prev = new float[_spectrum.Length / 4]; } _part += 0.1f; var length = _spectrum.Length / 4; if (_part > 1) { _prev = _current; _current = new float[length]; for (int i = 0; i < length; i++) { _current[i] = _spectrum.Skip(i * 4).Take(4).Average() * 200; } _part = 0.1f; } _angle = 0; for (int i = 0; i < length; i++) { var lerp = Lerp(_prev[i], _current[i], _part); var abs = Math.Abs(lerp); float Y2 = (float)(Math.Cos(_angle) * (abs + 100) + _canvasSize.Height / 2); float Y1 = (float)(Math.Cos(_angle) * 100 + _canvasSize.Height / 2); float X2 = (float)(Math.Sin(_angle) * (abs + 100) + _canvasSize.Width / 2); float X1 = (float)(Math.Sin(_angle) * 100 + _canvasSize.Width / 2); if (lerp > 0) { args.DrawingSession.DrawLine(X1, Y1, X2, Y2, Color.FromArgb( 255, (byte)(((abs) / 200) * 255), 0, (byte)(((200 - abs) / 200) * 255))); } else { args.DrawingSession.DrawLine(X1, Y1, X2, Y2, Color.FromArgb( 255, 0, (byte)(((abs) / 200) * 255), (byte)(((200 - abs) / 200) * 255))); } _angle += _step; } //args.DrawingSession.FillCircle((float)canvasSize.Height / 2, (float)canvasSize.Width /2, 100, Colors.White); }