private void ComputeVennDiagram() { Intersection = new HashSet <T>(); Set1Only = new HashSet <T>(); Set2Only = new HashSet <T>(); foreach (var element in Set1) { if (Set2.Contains(element)) { Intersection.Add(element); } else { Set1Only.Add(element); } } foreach (var element in Set2) { if (!Intersection.Contains(element)) { Set2Only.Add(element); } } }
/** * */ internal StyleTable CreateProtoChainRoot(bool registerClone = true) { StyleTable root = new StyleTable(); // If there's a defaultFactory for this style sheet, // then add the object it produces to the root. if (null != Set1) { root = root.CloneAndOverrideWith(Set1.Produce()); } // If there's a factory for this style sheet, // then add the object it produces to the root. if (null != Set2) { root = root.CloneAndOverrideWith(Set2.Produce()); } if (registerClone) { _clones.Add(root); } return(root); }
public void Challenge09() { Set2 set = new Set2(); string pkcs7PaddedString = set.PKCS7Padding("YELLOW SUBMARINE", 20); Assert.AreEqual("YELLOW SUBMARINE04040404", pkcs7PaddedString); }
void Start() { var totallength = Set1.Length + Set2.Length + Set3.Length + Set4.Length; allSets = new Sprite[totallength]; Set1.CopyTo(allSets, 0); Set2.CopyTo(allSets, Set1.Length); Set3.CopyTo(allSets, Set1.Length + Set2.Length); Set4.CopyTo(allSets, Set1.Length + Set2.Length + Set3.Length); }
/// <summary> /// Determines if the two sets are equivalent /// </summary> /// <param name="Set1">Set 1</param> /// <param name="Set2">Set 2</param> /// <returns>True if they are, false otherwise</returns> public static bool operator ==(Set <T> Set1, Set <T> Set2) { if (((object)Set1) == null && ((object)Set2) == null) { return(true); } if (((object)Set1) == null || ((object)Set2) == null) { return(false); } return(Set1.Contains(Set2) && Set2.Contains(Set1)); }
/// <summary> /// Gets the style /// </summary> /// <param name="styleProp"></param> /// <returns></returns> // ReSharper disable MemberCanBePrivate.Global public object GetStyle(string styleProp) // ReSharper restore MemberCanBePrivate.Global { // First look in the overrides, in case setStyle() // has been called on this StyleDeclaration. if (null != _overrides) { // If the property exists in our overrides, but // has 'undefined' as its value, it has been // cleared from this stylesheet so return // undefined. /*if (_overrides.ContainsKey(styleProp) && UNDEFINED.Equals(_overrides[styleProp])) * { * return UNDEFINED; * }*/ if (_overrides.ContainsKey(styleProp)) { var v = _overrides[styleProp]; if (!UNDEFINED.Equals(v)) // must use !== { return(v); } } } // not found in overrides if (null != Set2) { StyleTable o = Set2.Produce(); object v = o.GetValue(styleProp); if (!UNDEFINED.Equals(v)) { return(v); } } // not found in stylesheet if (null != Set1) { StyleTable o = Set1.Produce(); object v = o.GetValue(styleProp); if (!UNDEFINED.Equals(v)) { return(v); } } // not faund in default values // so return null return(UNDEFINED); }
protected override void OnPostExecute(Bitmap bitmap) { if (bitmap != null) { MemoryStream stream = new MemoryStream(); bitmap.Compress(Bitmap.CompressFormat.Jpeg, 50, stream); byte[] bitmapData = stream.ToArray(); Set2 set2 = new Set2(); set2.Galleryimage(bitmapData); bitmap.Recycle(); GC.Collect(); } }
/// <summary> /// Removes items from set 2 from set 1 /// </summary> /// <param name="Set1">Set 1</param> /// <param name="Set2">Set 2</param> /// <returns>The resulting set</returns> public static Set <T> operator -(Set <T> Set1, Set <T> Set2) { Contract.Requires <ArgumentNullException>(Set1 != null, "Set1"); Contract.Requires <ArgumentNullException>(Set2 != null, "Set2"); var ReturnValue = new Set <T>(); for (int x = 0; x < Set1.Count; ++x) { if (!Set2.Contains(Set1[x])) { ReturnValue.Add(Set1[x]); } } return(ReturnValue); }
/// <summary> /// Removes items from set 2 from set 1 /// </summary> /// <param name="Set1">Set 1</param> /// <param name="Set2">Set 2</param> /// <returns>The resulting set</returns> public static Set <T> operator -(Set <T> Set1, Set <T> Set2) { if (Set1 == null || Set2 == null) { throw new ArgumentNullException(); } Set <T> ReturnValue = new Set <T>(); for (int x = 0; x < Set1.NumberItems; ++x) { if (!Set2.Contains(Set1.Items[x])) { ReturnValue.Add(Set1.Items[x]); } } return(ReturnValue); }
public void GalleryMedia() { var imagePicker = new UIImagePickerController { SourceType = UIImagePickerControllerSourceType.PhotoLibrary, MediaTypes = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.PhotoLibrary) }; imagePicker.AllowsEditing = true; var window = UIApplication.SharedApplication.KeyWindow; var vc = window.RootViewController; while (vc.PresentedViewController != null) { vc = vc.PresentedViewController; } vc.PresentViewController(imagePicker, true, null); imagePicker.FinishedPickingMedia += (sender, e) => { UIImage originalImage = e.Info[UIImagePickerController.EditedImage] as UIImage; if (originalImage != null) { var pngImage = originalImage.AsPNG(); byte[] myByteArray = new byte[pngImage.Length]; System.Runtime.InteropServices.Marshal.Copy(pngImage.Bytes, myByteArray, 0, Convert.ToInt32(pngImage.Length)); set2 = new Set2(); set2.Galleryimage(myByteArray); } Device.BeginInvokeOnMainThread(() => { vc.DismissViewController(true, null); }); }; imagePicker.Canceled += (sender, e) => vc.DismissViewController(true, null); }
// ReSharper restore UnassignedField.Global #endif ///<summary> ///</summary> ///<param name="chain">Replikativni Dictionary</param> ///<param name="target"></param> ///<returns></returns> internal virtual StyleTable AddStyleToProtoChain(StyleTable chain, object target /*, object filterMap*/) { //Debug.Log("AddStyleToProtoChain: chain: " + chain + "; target: " + target); bool nodeAddedToChain = false; //var originalChain = chain; //if (filterMap) //{ // chain = {}; //} #if DEBUG if (!string.IsNullOrEmpty(DebugId)) { Debug.Log(DebugId + " 0. " + chain); } #endif // If there's a defaultFactory for this style sheet, // then add the object it produces to the chain. if (null != Set1) { chain = chain.CloneAndOverrideWith(Set1.Produce()); nodeAddedToChain = true; } #if DEBUG if (!string.IsNullOrEmpty(DebugId)) { Debug.Log(DebugId + " 1. " + chain); } #endif // If there's a factory for this style sheet, // then add the object it produces to the chain. if (null != Set2) { chain = chain.CloneAndOverrideWith(Set2.Produce()); nodeAddedToChain = true; } #if DEBUG if (!string.IsNullOrEmpty(DebugId)) { Debug.Log(DebugId + " 2. " + chain); } #endif //Debug.Log("-- chain: " + chain); // If someone has called setStyle() on this StyleDeclaration, // then some of the values returned from the factory are // out-of-date. Overwrite them with the up-to-date values. if (null != _overrides) { // Before we add our overrides to the object at the head of // the chain, make sure that we added an object at the head // of the chain. if (null == Set1 && null == Set2) { chain = (StyleTable)chain.Clone(); nodeAddedToChain = true; } foreach (string p in _overrides.Keys) { if (!UNDEFINED.Equals(_overrides[p])) { chain[p] = _overrides[p]; } /*if (UNDEFINED.Equals(_overrides[p])) * chain.Remove(p); * else * chain[p] = _overrides[p];*/ } } #if DEBUG if (!string.IsNullOrEmpty(DebugId)) { Debug.Log(DebugId + " 3. " + chain); } #endif #region _complex ////if (filterMap) ////{ // if (nodeAddedToChain) // { // //Debug.Log("nodeAddedToChain"); // //var filteredChain = new Dictionary<string, object>(); // //for (string i in chain) // //{ // // if (filterMap[i] != null) // // { // // filteredChain[filterMap[i]] = chain[i]; // // } // //} // //var f = new StyleTableValuesFactory(originalChain); // chain = (StyleTable) originalChain.Clone(); // //chain = originalChain; // //chain = filteredChain; // //chain = f.Produce(); // //chain[FILTERMAP_PROP] = filterMap; // } // else // { // chain = originalChain; // } ////} #endregion if (nodeAddedToChain) { _clones.Add(chain); } return(chain); }
/// <summary> /// Private /// </summary> /// <param name="styleProp"></param> /// <param name="value"></param> internal void SetLocalStyle(string styleProp, object value) { //object oldValue = GetStyle(styleProp); if (UNDEFINED.Equals(value)) { ClearStyleAttr(styleProp); return; } StyleTable o; if (null != Set1) { o = Set1.Produce(); if (!o.ContainsKey(styleProp) || o[styleProp] != value) // Defaultni factory nema taj stil ili ga ima ali s različitom vrijednošću { /** * Defaultni factory ima različitu vrijednost ovog stila, znači radi se o overrideu * Kreirajmo overrides tablicu i u njoj setirajmo stil * */ if (null == _overrides) { _overrides = new StyleTable(); } _overrides[styleProp] = value; } else if (null != _overrides && _overrides.ContainsKey(styleProp)) // Defaultni factory ima taj stil i to sa istom vrijednošću { /** * Obrišimo ga u overrides tabeli * */ _overrides.Remove(styleProp); } } if (null != Set2) { o = Set2.Produce(); if (!o.ContainsKey(styleProp) || o[styleProp] != value) { if (null == _overrides) { _overrides = new StyleTable(); } _overrides[styleProp] = value; } else if (null != _overrides && _overrides.ContainsKey(styleProp)) { _overrides.Remove(styleProp); } } if (null == Set1 && null == Set2) // Ne postoji niti jedan factory (ni metadata, ni stylesheet) { if (null == _overrides) { _overrides = new StyleTable(); } _overrides[styleProp] = value; } UpdateClones(styleProp, value); }