public InstanceReference(Fragment fragment, string instanceId) { if (fragment == null) throw new ArgumentNullException("fragment"); Instance = fragment; InstanceId = instanceId ?? string.Empty; }
public override void Add(Fragment fragment, IList<Fragment> fragments) { if (fragments.Count > 0) { Fragment prev = fragments[fragments.Count - 1]; if (prev.Name == fragment.Name) { if (prev.Value.Length < fragment.Value.Length) { Add(fragment, prev.ChildFragments); return; } else if (prev.Value.Length > fragment.Value.Length) { for (int i = fragments.Count - 1; i >= 0; i--) { if (fragments[i].Name != fragment.Name) break; if (fragments[i].Value.Length < fragment.Value.Length) { base.Add(fragment, fragments[i].ChildFragments); } } } } } base.Add(fragment, fragments); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(R.Layouts.fragment_menu); // Make sure the two menu fragments are created. FragmentManager fm = GetSupportFragmentManager(); FragmentTransaction ft = fm.BeginTransaction(); mFragment1 = fm.FindFragmentByTag("f1"); if (mFragment1 == null) { mFragment1 = new MenuFragment(); ft.Add(mFragment1, "f1"); } mFragment2 = fm.FindFragmentByTag("f2"); if (mFragment2 == null) { mFragment2 = new Menu2Fragment(); ft.Add(mFragment2, "f2"); } ft.Commit(); // Watch check box clicks. mCheckBox1 = (CheckBox)FindViewById(R.Ids.menu1); mCheckBox1.Click += (o,a) => UpdateFragmentVisibility(); mCheckBox2 = (CheckBox)FindViewById(R.Ids.menu2); mCheckBox2.Click += (o,a) => UpdateFragmentVisibility(); // Make sure fragments start out with correct visibility. UpdateFragmentVisibility(); }
public bool TryCreateFragment(StringCursor text, out Fragment fragment) { ITextSplitter textSplitter = new SeparatorTextSplitter(text, new[] {'\r', '\n'}); fragment = new DelimitedFragment(textSplitter, _fragmentFactory); return true; }
public UINavigationController(Fragment root) { ControllerStack.Add (root); if (root is IViewController) { ((IViewController)root).NavigationController = this; } }
protected override void OnCreate (Bundle bundle) { RequestWindowFeature(WindowFeatures.NoTitle); base.OnCreate (bundle); this.SetContentView(Resource.Layout.Home); String package = PackageName; Glistener = new GestureListener(); Gdetector = new GestureDetector (this, Glistener); var trans = FragmentManager.BeginTransaction (); trans.Add (Resource.Id.frame_home,mHomeFragment3,"HomeFragment3"); trans.Hide (mHomeFragment3); trans.Add (Resource.Id.frame_home,mHomeFragment2,"HomeFragment2"); trans.Hide (mHomeFragment2); trans.Add (Resource.Id.frame_home,mHomeFragment1,"HomeFragment1"); trans.Commit(); currentFragment = mHomeFragment1; Button haz_plif = FindViewById <Button> (Resource.Id.haz_plif); FrameLayout fcontainer = FindViewById<FrameLayout> (Resource.Id.frame_home); haz_plif.Click += (object sender, EventArgs e) => { StartActivity(typeof(login)); Finish (); }; fcontainer.Touch += Fcontainer_Touch; RemoteViews rmv = new RemoteViews(package, Resource.Layout.Home); rmv.SetTextViewText(Resource.Id.haz_plif,"Elias was here"); }
public DrawingImageView(Context context, Fragment fragment): base(context) { mPaint = new Paint(); mPaint.AntiAlias = true; mPaint.Dither = true; mPaint.Color = Color.Yellow; mPaint.SetStyle (Paint.Style.Stroke); mPaint.StrokeJoin = Paint.Join.Round; mPaint.StrokeCap = Paint.Cap.Round; mPaint.StrokeWidth = 10; cPaint = new Paint (); cPaint.Color = Color.Yellow; cPaint.StrokeJoin = Paint.Join.Round; cPaint.StrokeCap = Paint.Cap.Round; cPaint.SetTypeface(Typeface.Default); cPaint.TextSize = 40; mPath = new Android.Graphics.Path(); mBitmapPaint = new Paint(); mBitmapPaint.Color = Color.Yellow; DrawingStatus = DrawingType.None; _fragment = fragment; }
public override View OnCreateView(LayoutInflater Inflater, ViewGroup container, Bundle savedInstanceState) { View v = Inflater.Inflate(R.Layout.fragment_menu, container, false); // Make sure the two menu fragments are created. FragmentManager fm = GetChildFragmentManager(); FragmentTransaction ft = fm.BeginTransaction(); mFragment1 = fm.FindFragmentByTag("f1"); if (mFragment1 == null) { mFragment1 = new FragmentMenuSupport.MenuFragment(); ft.Add(mFragment1, "f1"); } mFragment2 = fm.FindFragmentByTag("f2"); if (mFragment2 == null) { mFragment2 = new FragmentMenuSupport.Menu2Fragment(); ft.Add(mFragment2, "f2"); } ft.Commit(); // Watch check box clicks. mCheckBox1 = (CheckBox)v.FindViewById(R.Id.menu1); mCheckBox1.Click += (o, a) => UpdateFragmentVisibility(); mCheckBox2 = (CheckBox)v.FindViewById(R.Id.menu2); mCheckBox2.Click += (o, a) => UpdateFragmentVisibility(); // Make sure fragments start out with correct visibility. UpdateFragmentVisibility(); return v; }
public static void AddTab(this Activity context, string tabText, int? iconResourceId, int containerId, Fragment view) { var tab = context.ActionBar.NewTab(); tab.SetText(tabText); if (iconResourceId != null) { tab.SetIcon(iconResourceId.Value); } // must set event handler before adding tab tab.TabSelected += delegate (object sender, ActionBar.TabEventArgs e) { var fragment = context.FragmentManager.FindFragmentById(Resource.Id.settingsContainer); if (fragment != null) e.FragmentTransaction.Remove(fragment); e.FragmentTransaction.Add(containerId, view); }; tab.TabUnselected += delegate (object sender, ActionBar.TabEventArgs e) { e.FragmentTransaction.Remove(view); }; context.ActionBar.AddTab(tab); }
// méthode à appeler quand on déponse un fragment sur le musicien public void OnAddingFragment(Fragment fragment) { print("NPC:OnAddingFragment"); SetJustReceivedFragmentComplete(true); // setting de la variable RAIN Material addedMaterial; switch(fragment.family){ // récupération du matérial correspondant au fragment qui vient d'être ajouté au musicien case FragmentType.electricity: addedMaterial = elecMaterial; break; case FragmentType.liquid: addedMaterial = liquidMaterial; break; case FragmentType.metal: addedMaterial = metalMaterial; break; case FragmentType.urban: addedMaterial = urbanMaterial; break; case FragmentType.wood: addedMaterial = woodMaterial; break; default: addedMaterial = defaultMaterial; break; } this.transform.FindChild("mesh").GetChild(1).renderer.material = addedMaterial;// affectation du material }
public BlockParserContext(IProblemPipe problemPipe, Fragment returnFragmentType, List<ReturnCondition> returnConditions, IBlacklistManager blacklistManager, BlockParser.InspectCallback inspect) { _problemPipe = problemPipe; _returnFragmentType = returnFragmentType; _returnConditions = returnConditions; _blacklistManager = blacklistManager; _inspect = inspect; }
public override void OnAttachFragment(Fragment fragment) { base.OnAttachFragment (fragment); if (fragment is HeaderFragment) { headerfragment = fragment; } }
public ProblemMetadata(int sourceExpressionId, SourceContext sourceContext, Fragment expectedFragment, Fragment givenFragment) { ArgumentUtility.CheckNotNull ("givenFragment", givenFragment); _sourceExpressionId = sourceExpressionId; _sourceContext = ArgumentUtility.CheckNotNull ("sourceContext", sourceContext); _expectedFragment = expectedFragment; _givenFragment = givenFragment; }
protected PreConditionBase(string symbol, Fragment fragment) { ArgumentUtility.CheckNotNullOrEmpty ("symbol", symbol); ArgumentUtility.CheckNotNull ("fragment", fragment); _symbol = symbol; _fragment = fragment; _problemMetadata = null; }
public static void RegisterFragment(Fragment p_frag) { if(p_frag != null) { m_currentAmountOfFragmentsInScene++; if(m_currentAmountOfFragmentsInScene > MaxAmountOfFragmentsInScene) UnregisterFragment(p_frag, true); } }
private void SwitchFragment(Fragment newContent) { // todo change this to use an interface var baseActivity = Activity as Activity1; if (baseActivity != null) { baseActivity.SwitchContent(newContent); } }
public override void OnAttachFragment(Fragment fragment) { base.OnAttachFragment (fragment); var demoFragment = fragment as DemoFragment; if(demoFragment != null) { // Can do something with the reference of the fragment in here. Tabs/Fragments are created on demand as they are getting displayed. } }
public override Dialog OnCreateDialog(Bundle savedInstanceState) { mParent = ParentFragment; return new AlertDialog.Builder(Activity) .SetMessage(Resource.String.request_permission) .SetPositiveButton(Android.Resource.String.Ok, new PositiveListener()) .SetNegativeButton(Android.Resource.String.Cancel, new NegativeListener()) .Create(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it fragment1 = new Fragment(); fragment2 = new Fragment(); ActionBar.NavigationMode = ActionBarNavigationMode.Tabs; var tab = ActionBar.NewTab(); tab.SetText("Tab1"); tab.SetIcon(Resource.Drawable.Icon); var tab2 = ActionBar.NewTab(); tab2.SetText("Tab2"); tab2.SetIcon(Resource.Drawable.Icon); //ActionBar.AddTab(tab); //ActionBar.AddTab(tab2); tab.TabSelected += (s, e) => { // if (!fragment1.IsAdded) // { // e.FragmentTransaction.Add(Resource.Id.frameLayout1, fragment1); // } // if (fragment2.IsAdded && !fragment2.IsHidden) // { // e.FragmentTransaction.Hide(fragment2); // } e.FragmentTransaction.Show(fragment1); }; tab2.TabSelected += (s, e) => { //if (!fragment2.IsAdded) //{ // e.FragmentTransaction.Add(Resource.Id.frameLayout1, fragment2); //} //if (fragment1.IsAdded && !fragment1.IsHidden) //{ // e.FragmentTransaction.Hide(fragment1); //} e.FragmentTransaction.Show(fragment2); }; ActionBar.AddTab(tab); ActionBar.AddTab(tab2); ActionBar.SelectTab(tab); }
public virtual void Add(Fragment fragment, IList<Fragment> fragments) { if (fragments.Count > 0) { Fragment previousFragment = fragments[fragments.Count - 1]; fragment.Previous = previousFragment; previousFragment.Next = fragment; } fragments.Add(fragment); }
private void CheckParameter(Expression operand, Fragment expectedFragment) { Fragment operandFragmentType = _symbolTable.InferFragmentType (operand); if (!FragmentUtility.FragmentTypesAssignable (operandFragmentType, expectedFragment)) { ProblemMetadata problemMetadata = new ProblemMetadata (operand.UniqueKey, operand.SourceContext, expectedFragment, operandFragmentType); PassProblem (operand, problemMetadata); } }
protected void SwitchContent(Fragment fragment) { var ftx = FragmentManager.BeginTransaction(); ftx.Replace(_fragmentContainerId, fragment); // Do animation ftx.Commit(); }
public bool TryCreateFragment(StringCursor text, out Fragment fragment) { if (text.Count == 0) { fragment = default(Fragment); return false; } return _fragmentFactory.TryCreateFragment(text, out fragment); }
public static void UnregisterFragment(Fragment p_frag, bool p_forceDestroy = false) { if(p_frag != null) { m_currentAmountOfFragmentsInScene--; m_currentAmountOfFragmentsInScene = Mathf.Max(0, m_currentAmountOfFragmentsInScene); if(p_forceDestroy) KiltUtils.DestroyImmediate(p_frag.gameObject); } }
private void ChangeFragment(Fragment targetFragment) { resideMenu.ClearIgnoredViewList(); FragmentManager .BeginTransaction () .Replace (Resource.Id.main_fragment, targetFragment, "fragment") .SetTransitionStyle ((int)FragmentTransit.FragmentFade) .Commit (); }
public void removeFragment(Fragment frg) { int k = 0; Fragment[] tmp = new Fragment [fragments.Length - 1]; for (int i=0; i<fragments.Length-1; i++) { if(frg == fragments[i]) k = 1; tmp[i] = fragments[i+k]; } fragments = tmp; }
private void ViewModelOnMainNavigationRequested(Fragment fragment) { _lastPage = fragment as MalFragmentBase; var trans = FragmentManager.BeginTransaction(); trans.SetCustomAnimations(Resource.Animator.animation_slide_btm, Resource.Animator.animation_fade_out, Resource.Animator.animation_slide_btm, Resource.Animator.animation_fade_out); trans.Replace(Resource.Id.MainContentFrame, fragment); trans.Commit(); }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); ActionBar.NavigationMode = ActionBarNavigationMode.Tabs; var tab = ActionBar.NewTab ().SetText ("View"); tab.TabSelected += (_, e) => { if (viewFragment == null) { viewFragment = Fragment.Instantiate (this, Class.FromType (typeof (ViewAnimationFragment)).Name); e.FragmentTransaction.Add (Android.Resource.Id.Content, viewFragment, "view-tab"); } else { e.FragmentTransaction.Attach (viewFragment); } }; tab.TabUnselected += (_, e) => { if (viewFragment != null) e.FragmentTransaction.Detach (viewFragment); }; ActionBar.AddTab (tab); tab = ActionBar.NewTab ().SetText ("Property"); tab.TabSelected += (_, e) => { if (propertyFragment == null) { propertyFragment = Fragment.Instantiate (this, Class.FromType (typeof (PropertyAnimationFragment)).Name); e.FragmentTransaction.Add (Android.Resource.Id.Content, propertyFragment, "property-tab"); } else { e.FragmentTransaction.Attach (propertyFragment); } }; tab.TabUnselected += (_, e) => { if (propertyFragment != null) e.FragmentTransaction.Detach (propertyFragment); }; ActionBar.AddTab (tab); tab = ActionBar.NewTab ().SetText ("Layout"); tab.TabSelected += (_, e) => { if (layoutFragment == null) { layoutFragment = Fragment.Instantiate (this, Class.FromType (typeof (LayoutAnimationFragment)).Name); e.FragmentTransaction.Add (Android.Resource.Id.Content, layoutFragment, "layout-tab"); } else { e.FragmentTransaction.Attach (layoutFragment); } }; tab.TabUnselected += (_, e) => { if (layoutFragment != null) e.FragmentTransaction.Detach (layoutFragment); }; ActionBar.AddTab (tab); }
public bool TryGetFragment(int index, out Fragment fragment) { StringCursor text; if (_parser.TryGetText(index, out text)) { return _fragmentFactory.TryCreateFragment(text, out fragment); } fragment = default(Fragment); return false; }
public void AddFragmentToStack(Fragment fragment, string title = null) { FragmentManager.BeginTransaction() .Replace(Resource.Id.frameLayout, fragment) .AddToBackStack(title) .CommitAllowingStateLoss(); ActionBar.Title = title; // DrawerToggle.SetHomeAsUpIndicator(Resource.Drawable.back); // DrawerToggle.DrawerIndicatorEnabled = false; }
private void ShowOrderDialogFragment(string ledgerOrderItemString, bool isEditOrderItem, int itemPos, bool inEditMode) { try { FragmentTransaction fragmentTransaction = FragmentManager.BeginTransaction(); //remove fragment from backstack if any exists Fragment fragmentPrev = FragmentManager.FindFragmentByTag("dialog"); if (fragmentPrev != null) { fragmentTransaction.Remove(fragmentPrev); } fragmentTransaction.AddToBackStack(null); //create and show the dialog OrderAddDialogFrag dialogFragment = OrderAddDialogFrag.NewInstance(this, ledgerOrderItemString, isEditOrderItem, itemPos, inEditMode); dialogFragment.Show(fragmentTransaction, "dialog"); } catch (Exception ex) { } }
public void CollectFragment(Fragment f) { /* * if (_collectedCoins.Contains(coin.CoinId)) * { * Debug.LogError("You've already collected " + coin.CoinId); * } * else * { * _collectedCoins.Add(coin.CoinId); * } * GameObject.Destroy(coin.gameObject); */ if (collectedFragments.Contains(f.fragmentID)) { Debug.LogError("Already collected fragment " + f.fragmentID); } else { collectedFragments.Add(f.fragmentID); Destroy(f.gameObject); } }
private void AddTab(string tabText, int iconResourceId, Fragment view) { var tab = this.ActionBar.NewTab(); tab.SetText(tabText); tab.SetIcon(iconResourceId); tab.TabSelected += delegate(object sender, ActionBar.TabEventArgs e) { var fragment = this.FragmentManager.FindFragmentById(Resource.Id.fragmentContainer); if (fragment != null) { e.FragmentTransaction.Remove(fragment); } e.FragmentTransaction.Add(Resource.Id.fragmentContainer, view); }; tab.TabUnselected += delegate(object sender, ActionBar.TabEventArgs e) { e.FragmentTransaction.Remove(view); }; this.ActionBar.AddTab(tab); }
private void ProcessHighDetail(RgbDevice device, Fragment fragment, EffectDetailLevel quality, float time) { time *= 2f; for (int i = 0; i < fragment.Count; i++) { Vector2 canvasPositionOfIndex = fragment.GetCanvasPositionOfIndex(i); Vector4 backgroundColor = _backgroundColor; float num = time * 0.5f + canvasPositionOfIndex.X + canvasPositionOfIndex.Y; float value = (float)Math.Cos(num) * 2f + 2f; value = MathHelper.Clamp(value, 0f, 1f); num = (num + (float)Math.PI) % ((float)Math.PI * 6f); Vector4 value2; if (num < (float)Math.PI * 2f) { float staticNoise = NoiseHelper.GetStaticNoise(canvasPositionOfIndex * 0.3f + new Vector2(12.5f, time * 0.2f)); staticNoise = Math.Max(0f, 1f - staticNoise * staticNoise * 4f * staticNoise); staticNoise = MathHelper.Clamp(staticNoise, 0f, 1f); value2 = Vector4.Lerp(_fireDarkColor, _fireBrightColor, staticNoise); } else if (num < (float)Math.PI * 4f) { float dynamicNoise = NoiseHelper.GetDynamicNoise(new Vector2((canvasPositionOfIndex.X + canvasPositionOfIndex.Y) * 0.2f, 0f), time / 5f); dynamicNoise = Math.Max(0f, 1f - dynamicNoise * 1.5f); value2 = Vector4.Lerp(_iceDarkColor, _iceBrightColor, dynamicNoise); } else { float dynamicNoise2 = NoiseHelper.GetDynamicNoise(canvasPositionOfIndex * 0.15f, time * 0.05f); dynamicNoise2 = (float)Math.Sin(dynamicNoise2 * 15f) * 0.5f + 0.5f; dynamicNoise2 = Math.Max(0f, 1f - 5f * dynamicNoise2); value2 = Vector4.Lerp(_lightningDarkColor, _lightningBrightColor, dynamicNoise2); } backgroundColor = Vector4.Lerp(backgroundColor, value2, value); fragment.SetColor(i, backgroundColor); } }
private void LoadNavigation(int id) { Fragment fragment = null; switch (id) { case Resource.Id.navigation_movies: fragment = MoviesListFragment.NewInstance(); currentSelected = 0; break; case Resource.Id.navigation_else: fragment = ElseFragment.NewInstance(); currentSelected = 1; break; } if (fragment == null) { return; } LoadFragment(fragment); }
private void AddTab(string text, int iconId, Fragment view) { var tab = ActionBar.NewTab(); tab.SetText(text); //tab.SetIcon(iconId); tab.TabSelected += (sender, e) => { var fragment = FragmentManager.FindFragmentById(Resource.Id.fragmentContainer); if (fragment != null) { e.FragmentTransaction.Remove(fragment); } e.FragmentTransaction.Add(Resource.Id.fragmentContainer, view); }; tab.TabUnselected += (sender, e) => { e.FragmentTransaction.Remove(view); }; ActionBar.AddTab(tab); }
private bool CalculateSampleCoverage(ref Fragment fragment) { int multiSampleCount = MultiSampleCount; bool anyCoveredSamples = false; if (multiSampleCount > 0) { anyCoveredSamples = CalculateSampleCoverage(ref fragment, 0, out fragment.Samples.Sample0); } if (multiSampleCount > 1) { anyCoveredSamples = anyCoveredSamples || CalculateSampleCoverage(ref fragment, 1, out fragment.Samples.Sample1); } if (multiSampleCount > 2) { anyCoveredSamples = anyCoveredSamples || CalculateSampleCoverage(ref fragment, 2, out fragment.Samples.Sample2); } if (multiSampleCount > 3) { anyCoveredSamples = anyCoveredSamples || CalculateSampleCoverage(ref fragment, 3, out fragment.Samples.Sample3); } fragment.Samples.AnyCovered = anyCoveredSamples; return(anyCoveredSamples); }
protected internal void WriteEscapedOriginalTo(ref Fragment fragment, ITextSink sink) { var run = fragment.head; if (run != fragment.tail) { var runOffset = fragment.headOffset; do { var runEntry = runList[run]; if (runEntry.Type == RunType.Normal || runEntry.Type == RunType.Literal) { EscapeAndWriteBuffer( buffer, runOffset, runEntry.Length, sink); } runOffset += runEntry.Length; }while (++run != fragment.tail && !sink.IsEnough); } }
public SimpleSlice(string sliceType, string sliceLabel, Fragment value) { this.sliceType = sliceType; this.sliceLabel = sliceLabel; this.value = value; }
private void NavigateInternal(Fragment fragment, IViewModelBase viewModel) { _backStack.Add(fragment); CurrentStore.Add(ToKey(fragment), viewModel); ReplaceFragmentIfPossible(fragment); }
// This function runs on the ORK on every authentication request // epIP is the end-point IP/port address of the requester // Function returns the amount of minutes that requester is blocked from now - if the request failed. 0 is if the request is approved. private (bool success, string result, int minutes) ProcessRequest(AuthenticationModel model, Fragment fragment) { // initialize local variables string returnedValue = null; // check for current epoch time var epoch = (DateTime.UtcNow - _epoch).TotalSeconds; CleanDictionary(epoch); // check if record exists for that end-point if (!Records.ContainsKey(model.Ip)) { Records.Add(model.Ip, new Tuple <int, double>(1, epoch - 1)); } var(item1, item2) = Records[model.Ip]; ValidationResult validationResult = null; var success = false; // execute the authentication check only if ban expired or if still in the first 3 bans if (item1 < 4 || epoch > item2) { validationResult = ValidationManager.ValidatePass(model.PasswordHash, AesCrypto.Decrypt(fragment.PasswordHash, _settings.Password), AesCrypto.Decrypt(fragment.CvkFragment, _settings.Password), _settings.Key).Result; returnedValue = validationResult.Result; success = validationResult.Success; } var result = 0; if (validationResult != null && validationResult.Success) { // if authentication confirmed, reset record Records[model.Ip] = new Tuple <int, double>(1, epoch - 1); } else { // increase ban exponentially result = (int)Math.Pow(2, item1 - 3); // if authentication failed: // increase Attempts counter for that record var additionalTime = epoch + 60 * result; Records[model.Ip] = new Tuple <int, double>(item1 + 1, additionalTime); } // return result return(success, returnedValue, result); }
public override void GoToApplication() { _mainActivity.NavigateToFragment(_appFragment ?? (_appFragment = new ApplicationFragment())); }
private static IViewModelBase ExtractViewModel(Fragment fragment) { return((IViewModelBase)((IBindable)fragment).DataContext); }
public override void OnAttachFragment(Fragment fragment) { base.OnAttachFragment(fragment); _fragList.Add(new WeakReference <Fragment>(fragment)); }
private bool TryAddImpl(ScaleoutMapping mapping, out ulong newMessageId) { ulong nextFreeMessageId = (ulong)Volatile.Read(ref _nextFreeMessageId); // locate the fragment containing the next free id, which is where we should write ulong fragmentNum; int idxIntoFragmentsArray, idxIntoFragment; GetFragmentOffsets(nextFreeMessageId, out fragmentNum, out idxIntoFragmentsArray, out idxIntoFragment); Fragment fragment = _fragments[idxIntoFragmentsArray]; if (fragment == null || fragment.FragmentNum < fragmentNum) { // the fragment is outdated (or non-existent) and must be replaced bool overwrite = fragment != null && fragment.FragmentNum < fragmentNum; if (idxIntoFragment == 0) { // this thread is responsible for creating the fragment Fragment newFragment = new Fragment(fragmentNum, _fragmentSize); newFragment.Data[0] = mapping; Fragment existingFragment = Interlocked.CompareExchange(ref _fragments[idxIntoFragmentsArray], newFragment, fragment); if (existingFragment == fragment) { newMessageId = GetMessageId(fragmentNum, offset: 0); newFragment.MinId = newMessageId; newFragment.Length = 1; newFragment.MaxId = GetMessageId(fragmentNum, offset: _fragmentSize - 1); _maxMapping = mapping; // Move the minimum id when we overwrite if (overwrite) { _minMessageId = (long)(existingFragment.MaxId + 1); _minMappingId = existingFragment.MaxId; } else if (idxIntoFragmentsArray == 0) { _minMappingId = mapping.Id; } return(true); } } // another thread is responsible for updating the fragment, so fall to bottom of method } else if (fragment.FragmentNum == fragmentNum) { // the fragment is valid, and we can just try writing into it until we reach the end of the fragment ScaleoutMapping[] fragmentData = fragment.Data; for (int i = idxIntoFragment; i < fragmentData.Length; i++) { ScaleoutMapping originalMapping = Interlocked.CompareExchange(ref fragmentData[i], mapping, null); if (originalMapping == null) { newMessageId = GetMessageId(fragmentNum, offset: (uint)i); fragment.Length++; _maxMapping = fragmentData[i]; return(true); } } // another thread used the last open space in this fragment, so fall to bottom of method } // failure; caller will retry operation newMessageId = 0; return(false); }
public void FragmentChemicalFormulaCIon() { Fragment fragment = _mockPeptideEveryAminoAcid.Fragment(FragmentTypes.c, 1).ToArray()[0]; Assert.AreEqual(88.063662885719992, fragment.MonoisotopicMass); }
public void FragmentChemicalFormulaXIon() { Fragment fragment = _mockPeptideEveryAminoAcid.Fragment(FragmentTypes.x, 1).ToArray()[0]; Assert.AreEqual(207.05315777167004, fragment.MonoisotopicMass); }
public void FragmentChemicalFormulaAIon() { Fragment fragment = _mockPeptideEveryAminoAcid.Fragment(FragmentTypes.a, 1).ToArray()[0]; Assert.IsTrue(fragment.MassEquals(43.04219916514)); }
public void FragmentChemicalFormulaBIon() { Fragment fragment = _mockPeptideEveryAminoAcid.Fragment(FragmentTypes.b, 1).ToArray()[0]; Assert.AreEqual(71.037113784709987, fragment.MonoisotopicMass); }
public void FragmentName() { Fragment fragment = _mockPeptideEveryAminoAcid.Fragment(FragmentTypes.a, 1).ToArray()[0]; Assert.AreEqual("a1", fragment.ToString()); }
public void FragmentChemicalFormulaZIon() { Fragment fragment = _mockPeptideEveryAminoAcid.Fragment(FragmentTypes.z, 1).ToArray()[0]; Assert.AreEqual(164.04734411524004, fragment.MonoisotopicMass); }
internal static void NavigateToFragment(this Activity mainActivity, Fragment fragment, bool addToBackStack = true, bool animate = true) { mainActivity.SetFragmentOnContainer(fragment, Resource.Id.ContentArea, addToBackStack, animate); }
// Module defining this command // Optional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of System.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (ApplicationName.Expression != null) { targetCommand.AddParameter("ApplicationName", ApplicationName.Get(context)); } if (BasePropertiesOnly.Expression != null) { targetCommand.AddParameter("BasePropertiesOnly", BasePropertiesOnly.Get(context)); } if ((ComputerName.Expression != null) && (PSRemotingBehavior.Get(context) != RemotingBehavior.Custom)) { targetCommand.AddParameter("ComputerName", ComputerName.Get(context)); } if (ConnectionURI.Expression != null) { targetCommand.AddParameter("ConnectionURI", ConnectionURI.Get(context)); } if (Dialect.Expression != null) { targetCommand.AddParameter("Dialect", Dialect.Get(context)); } if (Enumerate.Expression != null) { targetCommand.AddParameter("Enumerate", Enumerate.Get(context)); } if (Filter.Expression != null) { targetCommand.AddParameter("Filter", Filter.Get(context)); } if (Fragment.Expression != null) { targetCommand.AddParameter("Fragment", Fragment.Get(context)); } if (OptionSet.Expression != null) { targetCommand.AddParameter("OptionSet", OptionSet.Get(context)); } if (Port.Expression != null) { targetCommand.AddParameter("Port", Port.Get(context)); } if (Associations.Expression != null) { targetCommand.AddParameter("Associations", Associations.Get(context)); } if (ResourceURI.Expression != null) { targetCommand.AddParameter("ResourceURI", ResourceURI.Get(context)); } if (ReturnType.Expression != null) { targetCommand.AddParameter("ReturnType", ReturnType.Get(context)); } if (SelectorSet.Expression != null) { targetCommand.AddParameter("SelectorSet", SelectorSet.Get(context)); } if (SessionOption.Expression != null) { targetCommand.AddParameter("SessionOption", SessionOption.Get(context)); } if (Shallow.Expression != null) { targetCommand.AddParameter("Shallow", Shallow.Get(context)); } if (UseSSL.Expression != null) { targetCommand.AddParameter("UseSSL", UseSSL.Get(context)); } if (Credential.Expression != null) { targetCommand.AddParameter("Credential", Credential.Get(context)); } if (Authentication.Expression != null) { targetCommand.AddParameter("Authentication", Authentication.Get(context)); } if (CertificateThumbprint.Expression != null) { targetCommand.AddParameter("CertificateThumbprint", CertificateThumbprint.Get(context)); } if (GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom)) { targetCommand.AddParameter("ComputerName", PSComputerName.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
public void FragmentChemicalFormulaYIon() { Fragment fragment = _mockPeptideEveryAminoAcid.Fragment(FragmentTypes.y, 1).ToArray()[0]; Assert.AreEqual(181.07389321625004, fragment.MonoisotopicMass); }
/// <summary> /// Show Fragment with a specific tag at a specific placeholder /// </summary> /// <param name="tag">The tag for the fragment to lookup</param> /// <param name="contentId">Where you want to show the Fragment</param> /// <param name="bundle">Bundle which usually contains a Serialized MvxViewModelRequest</param> /// <param name="forceAddToBackStack">If you want to force add the fragment to the backstack so on backbutton it will go back to it. Note: This will override IMvxCachedFragmentInfo.AddToBackStack configuration.</param> /// <param name="forceReplaceFragment">If you want the fragment to be re-created</param> protected virtual void ShowFragment(string tag, int contentId, Bundle bundle, bool forceAddToBackStack = false, bool forceReplaceFragment = false) { IMvxCachedFragmentInfo fragInfo; FragmentCacheConfiguration.TryGetValue(tag, out fragInfo); IMvxCachedFragmentInfo currentFragInfo = null; var currentFragment = FragmentManager.FindFragmentById(contentId); if (currentFragment != null) { FragmentCacheConfiguration.TryGetValue(currentFragment.Tag, out currentFragInfo); } if (fragInfo == null) { throw new MvxException("Could not find tag: {0} in cache, you need to register it first.", tag); } // We shouldn't replace the current fragment unless we really need to. FragmentReplaceMode fragmentReplaceMode = FragmentReplaceMode.ReplaceFragmentAndViewModel; if (!forceReplaceFragment) { fragmentReplaceMode = ShouldReplaceCurrentFragment(fragInfo, currentFragInfo, bundle); } if (fragmentReplaceMode == FragmentReplaceMode.NoReplace) { return; } var ft = FragmentManager.BeginTransaction(); OnBeforeFragmentChanging(fragInfo, ft); fragInfo.ContentId = contentId; //If we already have a previously created fragment, we only need to send the new parameters if (fragInfo.CachedFragment != null && fragmentReplaceMode == FragmentReplaceMode.ReplaceFragment) { (fragInfo.CachedFragment as Fragment).Arguments.Clear(); (fragInfo.CachedFragment as Fragment).Arguments.PutAll(bundle); } else { //Otherwise, create one and cache it fragInfo.CachedFragment = Fragment.Instantiate(this, FragmentJavaName(fragInfo.FragmentType), bundle) as IMvxFragmentView; OnFragmentCreated(fragInfo, ft); } currentFragment = fragInfo.CachedFragment as Fragment; ft.Replace(fragInfo.ContentId, fragInfo.CachedFragment as Fragment, fragInfo.Tag); //if replacing ViewModel then clear the cache after the fragment //has been added to the transaction so that the Tag property is not null //and the UniqueImmutableCacheTag property (if not overridden) has the correct value if (fragmentReplaceMode == FragmentReplaceMode.ReplaceFragmentAndViewModel) { var cache = Mvx.GetSingleton <IMvxMultipleViewModelCache>(); cache.GetAndClear(fragInfo.ViewModelType, GetTagFromFragment(fragInfo.CachedFragment as Fragment)); } if ((currentFragment != null && fragInfo.AddToBackStack) || forceAddToBackStack) { ft.AddToBackStack(fragInfo.Tag); } OnFragmentChanging(fragInfo, ft); ft.Commit(); FragmentManager.ExecutePendingTransactions(); OnFragmentChanged(fragInfo); }
/// <summary> /// This function calculates the accuracy of the labeling. /// Note: For the sake of a good running time we assume that the dataCheck and /// dataFiles contain corresponding files i.e. dataCheck[i] corresponds to /// dataFiles[i]. /// </summary> public void calcAccuracy(string logFile) { //string dummyFile = "foo.txt"; StreamWriter swr = null;//new StreamWriter(dummyFile); printData printAcc; if (logFile.Length != 0) { swr = new StreamWriter(logFile); printAcc = new printData(swr.WriteLine); } else { printAcc = new printData(Console.WriteLine); } /* at index 0 -> data for wires * at index 1 -> data for gates * at index 2 -> data for labels */ double[] numCorrectOverall = new double[3]; double[] numTotalOverall = new double[3]; double totalLabels = 0.0; double mislabeledAsOther = 0.0; double mislabeledAsWire = 0.0; double mislabeledAsGate = 0.0; double correctLabels = 0.0; double totalSubstrokes = 0.0; double missedSubstrokes = 0.0; double unknownLabels = 0.0; List <float?> probCorWires = new List <float?>(); List <float?> probWrongWires = new List <float?>(); List <float?> probCorGates = new List <float?>(); List <float?> probWrongGates = new List <float?>(); List <float?> probCorLabels = new List <float?>(); List <float?> probWrongLabels = new List <float?>(); //Check whether we are comparing the same substrokes. //Check for the sizes. for (int index = 0; index < dataLabeled.Count; ++index) { string fileLabeled = (string)dataLabeled[index]; string fileCheck = (string)dataCheck[index]; //printAcc("fileLabeled: {0}", fileLabeled); //printAcc("fileCheck: {0}", fileCheck); Sketch.Sketch sketchLabeled = (new ReadXML(fileLabeled)).Sketch; Sketch.Sketch sketchCheck = (new ReadXML(fileCheck)).Sketch; Fragment.fragmentSketch(sketchLabeled); Fragment.fragmentSketch(sketchCheck); /* at index 0 -> data for wires * at index 1 -> data for gates * at index 2 -> data for labels */ double[] numCorrect = new double[3]; double[] numTotal = new double[3]; totalSubstrokes += sketchLabeled.Substrokes.Length; //Check whether we are comparing the same substrokes. //Check for the sizes. for (int i = 0; i < sketchLabeled.Substrokes.Length; ++i) { Sketch.Substroke subStr = sketchLabeled.Substrokes[i]; string labelCorrect = subStr.GetFirstLabel(); // //if (labelCorrect.Equals("Wire") || labelCorrect.Equals("Label")) // labelCorrect = "Nongate"; string labelCorrectId = subStr.XmlAttrs.Id.ToString(); float xCorrect = subStr.XmlAttrs.X.Value; float yCorrect = subStr.XmlAttrs.Y.Value; //string labelCorrect = subStr.ParentStroke.XmlAttrs.Type.ToString(); //string labelCorrectId = subStr.ParentStroke.XmlAttrs.Id.ToString(); if (labelCorrect.Length == 0 || labelCorrect.Equals("BUBBLE")) { printAcc("*** Skipping the following id: {0}***", labelCorrectId); continue; } string labelCheck = ""; string labelCheckId = ""; float xCheck = -1; float yCheck = -1; float?prob = 0; foreach (Sketch.Substroke sub in sketchCheck.Substrokes) { string tmp = sub.XmlAttrs.Id.ToString(); float xTmp = sub.XmlAttrs.X.Value; float yTmp = sub.XmlAttrs.Y.Value; //if (tmp.Equals(labelCorrectId)) if (xTmp == xCorrect && yTmp == yCorrect) { labelCheck = sub.GetFirstLabel(); labelCheckId = sub.XmlAttrs.Id.ToString(); xCheck = sub.XmlAttrs.X.Value; yCheck = sub.XmlAttrs.Y.Value; //prob = sub.ParentShapes[0].XmlAttrs.Probability.Value; break; } } if (xCheck == -1 || yCheck == -1) { printAcc("*** A stroke is not found in sketchCheck ***"); continue; } /* * if (labelCheck.Length == 0) * { * * printAcc("*** LabelCheck has length 0 => could not find a sustroke in sketchCheck ***"); * printAcc("Correct label: {0} labelCorrectId: {1}", labelCorrect, labelCorrectId); ++missedSubstrokes; * continue; * } */ //printAcc(""); //printAcc("LabelCorrectId is: {0}", labelCorrectId); //printAcc("LabelCheckId is : {0}", labelCheckId); //printAcc("Type of label is : {0}", labelCheck); //printAcc("Probability for this label is: {0}", prob); switch (labelCorrect) { case "Wire": ++totalLabels; ++(numTotal[0]); ++(numTotalOverall[0]); if (labelCheck.Equals("Wire")) { ++correctLabels; ++(numCorrect[0]); ++(numCorrectOverall[0]); probCorWires.Add(prob); } else { probWrongWires.Add(prob); } break; case "Gate": ++totalLabels; ++(numTotal[1]); ++(numTotalOverall[1]); if (labelCheck.Equals("Gate")) { ++correctLabels; ++(numCorrect[1]); ++(numCorrectOverall[1]); probCorGates.Add(prob); } else { probWrongGates.Add(prob); } break; case "Label": ++totalLabels; ++(numTotal[2]); ++(numTotalOverall[2]); if (labelCheck.Equals("Wire")) { ++mislabeledAsWire; ++mislabeledAsOther; } if (labelCheck.Equals("Gate")) { ++mislabeledAsGate; ++mislabeledAsOther; } if (labelCheck.Equals("Label")) { ++correctLabels; ++(numCorrect[2]); ++(numCorrectOverall[2]); probCorLabels.Add(prob); } else { probWrongLabels.Add(prob); } break; /*//---Start new part. * case "Gate": ++(numTotal[0]); ++(numTotalOverall[0]); * if (labelCheck.Equals("Gate")) * { ++(numCorrect[0]); ++(numCorrectOverall[0]); * } * break; * * case "Nongate": ++(numTotal[1]); ++(numTotalOverall[1]); * if (labelCheck.Equals("Nongate")) * { ++(numCorrect[1]); ++(numCorrectOverall[1]); * } * break; */ //---End default: printAcc("*** UNKNOWN LABEL: Correct label: {0}, Examined label: {1}", labelCorrect, labelCheck); printAcc("*** Correct id: {0}", labelCorrectId); ++unknownLabels; break; } } printAcc(""); printAcc("Comparing files {0} and {1}.", fileCheck, fileLabeled); printAcc("Percentage of correctly labeled Wires: {0:##.000%}", numCorrect[0] / numTotal[0]); printAcc("Percentage of correctly labeled Gates: {0:##.000%}", numCorrect[1] / numTotal[1]); printAcc("Percentage of correctly labeled Labels: {0:##.000%}", numCorrect[2] / numTotal[2]); /*//---Start new part. * printAcc(""); * printAcc("Comparing files {0} and {1}.", fileCheck, fileLabeled); * printAcc("Percentage of correctly labeled Gate: {0:##.000%}", * numCorrect[0] / numTotal[0]); * printAcc("Percentage of correctly labeled Nongate: {0:##.000%}", * numCorrect[1] / numTotal[1]); * //---End of new part.*/ } printAcc(""); printAcc("Results based on whole set of data:"); printAcc("Labels missed: {0} out of {1} => {2:##.000%}", missedSubstrokes, totalSubstrokes, missedSubstrokes / totalSubstrokes); printAcc("Unlabeled strokes: {0} out of {1} => {2:##.000%}", unknownLabels, totalLabels, unknownLabels / totalLabels); printAcc("Overall accuracy: {0:##.000%}", correctLabels / totalLabels); printAcc("Percentage of correctly labeled Wires: {0:##.000%}", numCorrectOverall[0] / numTotalOverall[0]); printAcc("Percentage of correctly labeled Gates: {0:##.000%}", numCorrectOverall[1] / numTotalOverall[1]); printAcc("Percentage of correctly labeled Labels: {0:##.000%}", numCorrectOverall[2] / numTotalOverall[2]); printAcc("Percentage of labels mislabeled as Wires: {0:##.000%}", mislabeledAsWire / mislabeledAsOther); printAcc("Percentage of labels mislabeled as Gates: {0:##.000%}", mislabeledAsGate / mislabeledAsOther); /*//---Start new part. * printAcc(""); * printAcc("Results based on whole set of data:"); * printAcc("Percentage of correctly labeled Gates: {0:##.000%}", * numCorrectOverall[0] / numTotalOverall[0]); * printAcc("Percentage of correctly labeled Nongates: {0:##.000%}", * numCorrectOverall[1] / numTotalOverall[1]); * //---End new part.*/ if (logFile.Length != 0) { swr.Close(); } /* * swr1.Close(); swr2.Close(); swr3.Close(); * swr4.Close(); swr5.Close(); swr6.Close(); */ }
protected void MatchFragments(Method baseMethod, Method overridingMethod) { foreach (var parameter in baseMethod.Parameters) { var fragmentType = FragmentUtility.GetFragmentType(parameter.Attributes); if (fragmentType != Fragment.CreateEmpty()) { var overriddenParameter = overridingMethod.Parameters[parameter.ParameterListIndex]; var overriddenFragmentType = FragmentUtility.GetFragmentType(overriddenParameter.Attributes); if (overriddenFragmentType != fragmentType && overriddenFragmentType != Fragment.CreateEmpty()) { AddProblem(new ProblemMetadata(overridingMethod.UniqueKey, overridingMethod.SourceContext, fragmentType, overriddenFragmentType)); } } } }
protected virtual string ToKey(Fragment fragment) { return(fragment.GetType().Name); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); uiHelper = new UiLifecycleHelper(this, callback); uiHelper.OnCreate(savedInstanceState); if (savedInstanceState != null) { string name = savedInstanceState.GetString(PENDING_ACTION_BUNDLE_KEY); pendingAction = (PendingAction)Enum.Parse(typeof(PendingAction), name); } SetContentView(Resource.Layout.main); loginButton = (LoginButton)FindViewById(Resource.Id.login_button); loginButton.UserInfoChangedCallback = new MyUserInfoChangedCallback(this); profilePictureView = FindViewById <ProfilePictureView> (Resource.Id.profilePicture); greeting = FindViewById <TextView> (Resource.Id.greeting); postStatusUpdateButton = FindViewById <Button> (Resource.Id.postStatusUpdateButton); postStatusUpdateButton.Click += delegate { OnClickPostStatusUpdate(); }; postPhotoButton = (Button)FindViewById(Resource.Id.postPhotoButton); postPhotoButton.Click += delegate { OnClickPostPhoto(); }; pickFriendsButton = (Button)FindViewById(Resource.Id.pickFriendsButton); pickFriendsButton.Click += delegate { OnClickPickFriends(); }; pickPlaceButton = (Button)FindViewById(Resource.Id.pickPlaceButton); pickPlaceButton.Click += delegate { OnClickPickPlace(); }; controlsContainer = (ViewGroup)FindViewById(Resource.Id.main_ui_container); FragmentManager fm = SupportFragmentManager; Fragment fragment = fm.FindFragmentById(Resource.Id.fragment_container); if (fragment != null) { // If we're being re-created and have a fragment, we need to a) hide the main UI controls and // b) hook up its listeners again. controlsContainer.Visibility = ViewStates.Gone; if (fragment is FriendPickerFragment) { SetFriendPickerListeners((FriendPickerFragment)fragment); } else if (fragment is PlacePickerFragment) { SetPlacePickerListeners((PlacePickerFragment)fragment); } } fm.BackStackChanged += delegate { if (fm.BackStackEntryCount == 0) { // We need to re-show our UI. controlsContainer.Visibility = ViewStates.Visible; } }; }
public override void GoToReportDetails() { _mainActivity.NavigateToFragment(_reportFragment ?? (_reportFragment = new ReportFragment())); }