Ejemplo n.º 1
0
 /// <summary>
 /// Replaces this container from the parent with a different container
 /// </summary>
 /// <param name="container">container that replaces this container</param>
 public void ReplaceWith(BaseContainer container)
 {
     if (ParentContainer != null)
     {
         ParentContainer.ReplaceChild(this, container);
     }
 }
        public void AddService(Type serviceType, object serviceInstance, bool promote)
        {
            if (serviceType == null)
            {
                throw new ArgumentNullException("serviceType");
            }
            if (serviceInstance == null)
            {
                throw new ArgumentNullException("serviceInstance");
            }
            if (!(serviceInstance is ServiceCreatorCallback)
                &&
                !serviceType.IsInstanceOfType(serviceInstance))
            {
                throw new ArgumentException(
                          CommonResourceUtil.GetString(Resources.ServiceProvider_InvalidServiceInstance, serviceType.FullName, "serviceInstance"));
            }

            if (promote && ParentContainer != null)
            {
                ParentContainer.AddService(serviceType, serviceInstance, promote);
                return;
            }

            lock (this)
            {
                if (Services.ContainsKey(serviceType))
                {
                    throw new InvalidOperationException(
                              CommonResourceUtil.GetString(Resources.ServiceProvider_ServiceAlreadyExists, serviceType.FullName));
                }
                Services.Add(serviceType, serviceInstance);
            }
        }
Ejemplo n.º 3
0
 public void UpdateParent(DataModel.ParentContainer parent)
 {
     try
     {
         var parents = Context.GetTable <ParentContainer>();
         var record  = parents.Where(x => x.Id.Equals(parent.Id)).FirstOrDefault();
         record = parent;
         Context.SubmitChanges(ConflictMode.FailOnFirstConflict);
     }
     catch (ChangeConflictException e)
     {
         foreach (ObjectChangeConflict occ in Context.ChangeConflicts)
         {
             MetaTable       metaTable        = Context.Mapping.GetTable(occ.Object.GetType());
             ParentContainer entityInConflict = (ParentContainer)occ.Object;
             foreach (var conflict in occ.MemberConflicts)
             {
                 object     currentValue  = conflict.CurrentValue;
                 object     originalValue = conflict.OriginalValue;
                 object     databaseValue = conflict.DatabaseValue;
                 MemberInfo mi            = conflict.Member;
                 Console.WriteLine("Change conflict detected on Member: {0}, Current: {1}, Original: {2}, Database: {3}", mi.Name, currentValue, originalValue, databaseValue);
             }
         }
     }
 }
        private void btnBack_Click(object sender, System.EventArgs e)
        {
            DialogResult result = XtraMessageBox.Show("هل تريد الحفظ قبل الخروج؟", "تنبيه", MessageBoxButtons.YesNoCancel,
                                                      MessageBoxIcon.Question);

            switch (result)
            {
            case DialogResult.Yes:
                btnSave_Click(null, null);
                if (ParentContainer != null)
                {
                    ParentContainer.CollapseLeftPanel(false);
                    ParentContainer.ShowInvoiceContainer(false);
                }
                this.Visible = false;
                break;

            case DialogResult.No:
                if (ParentContainer != null)
                {
                    ParentContainer.CollapseLeftPanel(false);
                    ParentContainer.ShowInvoiceContainer(false);
                }
                this.Visible = false;
                break;

            case DialogResult.Cancel:
                return;
            }
        }
        void UpdateTabstrip()
        {
            var hadSplit = hasSplit;

            var hasMultipleViews = currentContainer != null && currentContainer.GetAllViews().Skip(1).Any();

            tabstrip.Visible = hasMultipleViews && (supportedModes & DocumentViewContainerMode.Tabs) != 0;

            hasSplit = (this.supportedModes & DocumentViewContainerMode.VerticalSplit) != 0 || (this.supportedModes & DocumentViewContainerMode.HorizontalSplit) != 0;
            if (hasSplit && !hadSplit)
            {
                var currentActive = tabstrip.ActiveTab;
                var tab           = new Tab(tabstrip, GettextCatalog.GetString("Split"));
                tabstrip.AddTab(tab);
                tabstrip.ActiveTab = currentActive;
                tab.Activated     += TabActivated;
            }
            else if (!hasSplit && hadSplit)
            {
                tabstrip.RemoveTab(tabstrip.TabCount - 1);
            }

            // If this container is showing tabs and it is inside another container, give the parent the
            // chance to show the tabstrip in its own tab area, to avoid tab stacking
            ParentContainer?.UpdateAttachedTabstrips();

            // This might be a container that has children with tabs. Maybe now it is possible to embed the
            // child tabstrips into this container's tab area. Let's try!
            UpdateAttachedTabstrips();
        }
Ejemplo n.º 6
0
        protected virtual bool OnCursorIsInArea()
        {
            //control rectangle
            if (!(new Rectangle(Vector2.Zero, new Vector2(1, 1))).Contains(MousePosition))
            {
                return(false);
            }

            if (ParentContainer != null && ParentContainer.IsControlCursorCoveredByOther(this))
            {
                return(false);
            }

            //!!!!было
            ////click mask
            //if( !string.IsNullOrEmpty( clickMask ) )
            //{
            //if( needUpdateClickTextureMask )
            //{
            //	clickTextureMask = TextureMaskManager.GetMask( clickMask );
            //	needUpdateClickTextureMask = false;
            //}

            //if( clickTextureMask != null )
            //{
            //	Vec2 pos = clickMaskTextureCoord.LeftTop + clickMaskTextureCoord.GetSize() * MousePosition;
            //	if( !clickTextureMask.GetValue( pos ) )
            //		return false;
            //}
            //}

            return(true);
        }
 public void SetTitle(string label, Xwt.Drawing.Image icon, string accessibilityDescription)
 {
     Title = label;
     Icon  = icon;
     AccessibilityDescription = accessibilityDescription;
     ParentContainer?.SetViewTitle(this, label, icon, accessibilityDescription);
 }
        public void AddService(Type serviceType, ServiceCreatorCallback callback, bool promote)
        {
            if (serviceType == null)
            {
                throw new ArgumentNullException("serviceType");
            }
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            if (promote && ParentContainer != null)
            {
                ParentContainer.AddService(serviceType, callback, promote);
                return;
            }

            lock (this)
            {
                if (Services.ContainsKey(serviceType))
                {
                    throw new InvalidOperationException(
                              CommonResourceUtil.GetString(Resources.ServiceProvider_ServiceAlreadyExists, serviceType.FullName));
                }
                Services.Add(serviceType, callback);
            }
        }
Ejemplo n.º 9
0
        private (TItem, bool) ItemCanBeDropped()
        {
            if (!TransactionInProgress)
            {
                return(default(TItem), false);
            }

            var item = ParentContainer.GetTransactionItem();

            if (item == null)
            {
                return(default(TItem), false);
            }

            var canBeDropped = true;

            if (DropAllowed != null)
            {
                canBeDropped = DropAllowed(item);
            }
            else if (ParentContainer.DropAllowed != null)
            {
                canBeDropped = ParentContainer.DropAllowed(item, Name);
            }

            return(item, canBeDropped);
        }
Ejemplo n.º 10
0
        public void SetUpNestedContainer()
        {
            NestedContainer = ParentContainer.GetNestedContainer();
            var url = Config.Environment.Equals("DEV", StringComparison.InvariantCultureIgnoreCase) ? Config.WebSiteUrlLocal: Config.WebSiteUrl;

            WebSite = new ForecastingWebSite(url, Config.Browser);
        }
Ejemplo n.º 11
0
 public void PrepareNewGraph()
 {
     graphObjects.Clear();
     if (ParentContainer != null)
     {
         ParentContainer.PrepareNewGraph();
     }
 }
Ejemplo n.º 12
0
 public void SetCryptedString(string key, string value)
 {
     if (key == null)
     {
         throw new ArgumentNullException(nameof(key));
     }
     ParentContainer.SetCryptedString(KeyPrefix + key, value);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Move this container to a new parent
 /// </summary>
 /// <param name="newParent">new parent</param>
 public void MoveTo(BaseContainer newParent)
 {
     if (ParentContainer != null)
     {
         ParentContainer.RemoveChild(this);
     }
     newParent.AddChild(this);
 }
Ejemplo n.º 14
0
 public string GetDecryptedStringOrDefault(string key, string defaultValue = null)
 {
     if (key == null)
     {
         throw new ArgumentNullException(nameof(key));
     }
     return(ParentContainer.Get(KeyPrefix + key, defaultValue));
 }
Ejemplo n.º 15
0
 public T Get <T>(string key, T defaultValue = default(T))
 {
     if (key == null)
     {
         throw new ArgumentNullException(nameof(key));
     }
     return(ParentContainer.Get(KeyPrefix + key, defaultValue));
 }
Ejemplo n.º 16
0
 public bool Exists(string key)
 {
     if (key == null)
     {
         throw new ArgumentNullException(nameof(key));
     }
     return(ParentContainer.Exists(KeyPrefix + key));
 }
Ejemplo n.º 17
0
        void Ex01()
        {
            Fixture = TestFixtures.CreateFixture <TestFixtures.SimpleFixture>("FixtureMethod");
            Container.Add(Fixture);

            ParentContainer.EnsureParent();

            Expect("the parent of the added fixture is set to the parent fixture container", () => Fixture.ParentFixture == ParentContainer);
        }
Ejemplo n.º 18
0
        public void Clear()
        {
            var keysToRemove = Keys.ToArray();

            foreach (var key in keysToRemove)
            {
                ParentContainer.Remove(key);
            }
        }
Ejemplo n.º 19
0
        void Ex02()
        {
            Fixture = new FixtureContainer(typeof(TestFixtures.SimpleFixture));
            Container.Add(Fixture);

            ParentContainer.EnsureParent();

            Expect("the parent of the added fixture container is set to the fixture container", () => Fixture.ParentFixture == Container);
        }
Ejemplo n.º 20
0
 public virtual void AddFlowElementToMap(FlowElement element)
 {
     if (element != null && !string.IsNullOrWhiteSpace(element.Id))
     {
         flowElementMap[element.Id] = element;
         if (ParentContainer != null)
         {
             ParentContainer.AddFlowElementToMap(element);
         }
     }
 }
Ejemplo n.º 21
0
        private IEnumerable <TItem> GetItems()
        {
            Func <TItem, bool> predicate = (item) => ParentContainer.ItemsFilter(item, Name);

            if (ItemsFilter != null)
            {
                predicate = ItemsFilter;
            }

            return((ParentContainer?.Items ?? Enumerable.Empty <TItem>()).Where(predicate).ToArray());
        }
Ejemplo n.º 22
0
 public override void Initialize()
 {
     command = new RemindMeCommand()
     {
         ParentModule = this
     };
     ParentContainer.GetModule <CommandRootModule>().AddCommands(command);
     this.GetClock().OnMinutePassed += Update;
     ParentShard.ReactionAdded      += ReactionAdded;
     ParentShard.ReactionRemoved    += ReactionRemoved;
 }
Ejemplo n.º 23
0
 public void AddFlowElementToMap(FlowElement element)
 {
     if (element != null && (!string.IsNullOrEmpty(element.Id)))
     {
         flowElementMap.Add(element.Id, element);
         if (ParentContainer != null)
         {
             ParentContainer.AddFlowElementToMap(element);
         }
     }
 }
Ejemplo n.º 24
0
        private async Task OnDragStartHandler()
        {
            if (ParentContainer == null)
            {
                return;
            }

            dragging = true;

            ParentContainer.StartTransaction(Item, ZoneName, OnDroppedSucceeded, OnDroppedCanceled);

            await DragStarted.InvokeAsync();
        }
Ejemplo n.º 25
0
        public bool HasAncestorWith(Func <IContainer, bool> criteria)
        {
            if (ParentContainer == null)
            {
                return(false);
            }
            if (criteria(ParentContainer))
            {
                return(true);
            }

            return(ParentContainer.HasAncestorWith(criteria));
        }
Ejemplo n.º 26
0
 public void AddFlowElement(FlowElement element)
 {
     flowElementList.Add(element);
     element.ParentContainer = this;
     if (!string.IsNullOrEmpty(element.Id))
     {
         flowElementMap.Add(element.Id, element);
         if (ParentContainer != null)
         {
             ParentContainer.AddFlowElementToMap(element);
         }
     }
 }
Ejemplo n.º 27
0
        private async Task OnDragEndHandler(DragEventArgs e)
        {
            if (dragging)
            {
                dragging = false;

                await ParentContainer?.CancelTransaction();
            }
            else
            {
                await DragEnded.InvokeAsync(Item);
            }
        }
Ejemplo n.º 28
0
        void Ex03()
        {
            var fixtures = new[] {
                TestFixtures.CreateFixture <TestFixtures.SimpleFixture>("FixtureMethod"),
                TestFixtures.CreateFixture <TestFixtures.SimpleFixture>("FixtureMethod"),
                TestFixtures.CreateFixture <TestFixtures.SimpleFixture>("FixtureMethod")
            };

            Container.AddRange(fixtures);

            ParentContainer.EnsureParent();

            Expect("the parent of each added fixture is set to the parent fixture container.", () => fixtures.All(f => f.ParentFixture == ParentContainer));
        }
Ejemplo n.º 29
0
        void Ex04()
        {
            var fixtureContainers = new IFixture[] {
                new FixtureContainer(typeof(TestFixtures.SimpleFixture)),
                new FixtureContainer(typeof(TestFixtures.SimpleFixture)),
                new FixtureContainer(typeof(TestFixtures.SimpleFixture))
            };

            Container.AddRange(fixtureContainers);

            ParentContainer.EnsureParent();

            Expect("the parent of each added fixture container is set to the fixture container.", () => fixtureContainers.All(f => f.ParentFixture == Container));
        }
Ejemplo n.º 30
0
 public void AddServicePromotedWithCallback()
 {
     using (ParentContainer parentContainer = new ParentContainer())
     {
         using (TestContainer testContainer = new TestContainer(parentContainer))
         {
             testContainer.AddService(typeof(SayHelloService), new ServiceCreatorCallback(SayHelloServiceCreatorCallback), true);
             SayHelloService sayHello = testContainer.GetService(typeof(SayHelloService)) as SayHelloService;
             Assert.AreEqual(1, testContainer.services.Count);
             Assert.AreEqual(1, parentContainer.services.Count);
             Assert.IsNotNull(sayHello);
             Assert.IsTrue(serviceCallbackExecuted);
         }
     }
 }
Ejemplo n.º 31
0
 public void AddServicePromotedWithCallback()
 {
     using (ParentContainer parentContainer = new ParentContainer())
     {
         using (TestContainer testContainer = new TestContainer(parentContainer))
         {
             testContainer.AddService(typeof(SayHelloService), new ServiceCreatorCallback(SayHelloServiceCreatorCallback), true);
             SayHelloService sayHello = testContainer.GetService(typeof(SayHelloService)) as SayHelloService;
             Assert.AreEqual(1, testContainer.services.Count);
             Assert.AreEqual(1, parentContainer.services.Count);
             Assert.IsNotNull(sayHello);
             Assert.IsTrue(serviceCallbackExecuted);
         }
     }
 }