public TestFunctionModule()
 {
     var myFunction = new MyFunction();
     var customCompiler = new MyFunctionCompiler(myFunction);
     base.Functions.Add(MyFunction.Name, myFunction);
     base.CustomCompilers.Add(typeof(MyFunction), customCompiler);
 }
 public void CreateHandlesCustomFunctionCompiler()
 {
     var functionRepository = FunctionRepository.Create();
     functionRepository.LoadModule(new TestFunctionModule());
     var functionCompilerFactory = new FunctionCompilerFactory(functionRepository);
     var function = new MyFunction();
     var functionCompiler = functionCompilerFactory.Create(function);
     Assert.IsInstanceOfType(functionCompiler, typeof(MyFunctionCompiler));
 }
Beispiel #3
0
    //######################
    // FUNCTIONS
    //######################
    public override object VisitFunction(FaParser.FunctionContext context)
    {
        string id    = context.ID(0).GetText();
        int    nArgs = context.ID().Length - 1;
        LinkedList <string> namesParams = new LinkedList <string>();

        for (int i = 1; i <= nArgs; i++)
        {
            namesParams.AddLast(context.ID(i).GetText());
        }

        MyFunction var = new MyFunction(id, nArgs, namesParams, context.body_return());

        queue.Last().Add(id, var);
        return(null);
    }
Beispiel #4
0
 void UploadImage()
 {
     if (this.IsValid && this.uplImage.HasFile)
     {
         if (MyFunction.validUploadImage(uplImage.FileName.Substring(uplImage.FileName.LastIndexOf('.'))))
         {
             uplImage.SaveAs(Server.MapPath("~/uploads/ads/" + uplImage.FileName));
             txtImage.Text = uplImage.FileName;
             AddData();
         }
         else
         {
             lblMessage.Text = "File không đúng định dạng. Chỉ chấp nhận các dạng file *.jpg, *.jpeg, *.gif, *.png, *.bmp, *.swf";
         }
     }
 }
Beispiel #5
0
        static double MyMaximum(double xmin, double xmax, double ymin, double ymax, MyFunction myFunction)
        {
            double Max = double.MinValue;

            for (double x = xmin; x <= xmax; x = x + 0.01)
            {
                for (double y = ymin; y <= ymax; y = y + 0.01)
                {
                    if (myFunction(x, y) > Max)
                    {
                        Max = myFunction(x, y);
                    }
                }
            }
            return(Max);
        }
Beispiel #6
0
        public bool LoadBool()
        {
            var  testObject = new MyFunction();
            var  o          = new object();
            bool myBool     = false;

            try
            {
                // myBool = (bool)testObject;
                return(myBool);
            }
            catch
            {
                return(true);
            }
        }
Beispiel #7
0
    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();

        MyFunction f;

        MyFunction[] functions = new MyFunction[]{suma, resta, multiplica};
        int random = new Random().Next(3);
        f = functions[random];

        //		if (new Random().Next(2) ==0){
        //			f=suma;
        //		}
        //		else{
        //			f=resta;
        //		}

        Console.WriteLine("f={0}", f(5,3));

        //comboBox
        CellRenderer cellRenderer = new CellRendererText();
        combobox.PackStart(cellRenderer, false);
        combobox.AddAttribute (cellRenderer, "text", 1);

        listStore = new ListStore(typeof(string), typeof(string));
        combobox.Model = listStore;

        listStore.AppendValues("1", "Uno");
        listStore.AppendValues("2", "Dos");
        listStore.AppendValues("3", "Tres");
        listStore.AppendValues("4", "Cuatro");
        listStore.AppendValues("5", "Cinco");

        combobox.Changed += delegate {

            TreeIter treeIter;

            if (combobox.GetActiveIter (out treeIter)) {  //item seleccionado
                object value = listStore.GetValue(treeIter, 0);
                Console.WriteLine ("ComboBox.Changed delegate id={0}", value);
            }

        };

        combobox.Changed += comboBoxChanged;
    }
Beispiel #8
0
        public void ListenOnXMLChanged(MyFunction f)
        {
            FileSystemWatcher watcher = new FileSystemWatcher();
            watcher.Path = LocalFolder.Path;
            /* Watch for changes in LastAccess and LastWrite times, and 
               the renaming of files or directories. */
            watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
               | NotifyFilters.FileName | NotifyFilters.DirectoryName;
            // Only watch text files.
            watcher.Filter = "animations.xml";

            // Add event handlers.
            watcher.Changed += new FileSystemEventHandler(f);

            // Begin watching.
            watcher.EnableRaisingEvents = true;
        }
Beispiel #9
0
 public Reports()
 {
     InitializeComponent();
     try
     {
         centers.Items.Add("all");
         MyFunction.FillComboBox(centers, BAL.addMission.Get_centers(), "id", "centers");
         MyFunction.FillComboBox(volunteers, BAL.Employees.Get_Employees(), "الاسم", "الرمز");
         MyFunction.FillComboBox(CaseType, BAL.addMission.Get_CasesType(), "النوعية", "الرمز");
         MyFunction.FillComboBox(Patient, BAL.PatientInfo.GetPatients(), "اسم", "الرمز");
         centers.SelectedValueChanged += Centers_SelectedValueChanged;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #10
0
 public static void ValidateInput <T>(LstCollection <T> l, MyFunction <T> f) where T : BaseClass, new()
 {
     while (true)
     {
         try
         {
             f(l);
             break;
         }
         catch (Exception e)
         {
             Console.WriteLine(e.Message);
             Console.WriteLine("Try one more time!");
             continue;
         }
     }
 }
Beispiel #11
0
 void GetRandomPrize()
 {
     // isWin 갱신
     int[] A = new int[numCand];
     for (int i = 0; i < numPrize; ++i)
     {
         A[i] = 1;
     }
     MyFunction.Shuffle(ref A);
     for (int i = 0; i < numCand; ++i)
     {
         if (A[i] == 1)
         {
             isWin[i + 1] = true;
         }
     }
 }
Beispiel #12
0
 public static void ValidateInput(LstCollection l, MyFunction f)
 {
     while (true)
     {
         try
         {
             f(l);
             break;
         }
         catch (Exception e)
         {
             Console.WriteLine(e.Message);
             Console.WriteLine("Try one more time!");
             continue;
         }
     }
 }
Beispiel #13
0
        public Block Next()
        {
            Block ret = new Block(nextCand[nIdx]);

            nextCand[nIdx] = group[gIdx];
            for (int i = 0; i < NUMCAND; ++i)
            {
                DrawNext(nextCand[(nIdx + (i + 1) % NUMCAND) % NUMCAND], i);
            }
            nIdx = (nIdx + 1) % NUMCAND;
            gIdx = (gIdx + 1) % NUMTYPE;
            if (gIdx == 0)
            {
                MyFunction.Shuffle(ref group);
            }
            return(ret);
        }
Beispiel #14
0
        ///<summary>从原始数据抽点</summary>
        public void calSamplePoints()
        {
            csDataPoint startdp, enddp;

            //首日
            startdp = orgPoints.OrderBy(p => p.zDate).First();
            foreach (csDataPoint one in orgPoints.Where(p => MyFunction.isSameDay(p.zDate, startdp.zDate)))
            {
                samplePoints.Add(new csDataPoint(one.zDate, one.zValue));
            }
            //尾日, 全时段有数据的最后一天
            enddp = orgPoints.OrderBy(p => p.zDate).Last();
            foreach (csDataPoint one in orgPoints.Where(p => MyFunction.isSameDay(p.zDate, enddp.zDate)))
            {
                samplePoints.Add(new csDataPoint(one.zDate, one.zValue));
            }
            //抽点
            if (orgPoints.GroupBy(p => p.zDate.Date).Count() - 2 <= parent.sampleCount)
            {
                foreach (csDataPoint one in orgPoints.Where(p => !MyFunction.isSameDay(p.zDate, startdp.zDate) && !MyFunction.isSameDay(p.zDate, enddp.zDate)))
                {
                    samplePoints.Add(new csDataPoint(one.zDate, one.zValue));
                }
            }
            else
            {
                int      step = (int)((orgPoints.GroupBy(p => p.zDate.Date).Count() - 2) / parent.sampleCount);//步长天数
                DateTime tmpdate;
                DateTime sdate = startdp.zDate.AddDays(1).Date;
                DateTime edate;
                double   tmpvalue;
                for (int i = 0; i < parent.sampleCount; i++)
                {
                    edate   = sdate.AddDays(step - 1).Date;
                    tmpdate = sdate.AddDays((step - 1) / 2);

                    for (int j = 0; j < 24; j++)
                    {
                        tmpvalue = orgPoints.Where(p => p.zDate.Date >= sdate && p.zDate.Date <= edate && p.zDate.Hour == j).Average(p => p.zValue);
                        samplePoints.Add(new csDataPoint(new DateTime(tmpdate.Year, tmpdate.Month, tmpdate.Day, j, 0, 0), tmpvalue));
                    }
                    sdate = edate.AddDays(1).Date;
                }
            }
        }
Beispiel #15
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     try
     {
         Types obj = new Types();
         obj.TypeID   = GetID();
         obj.TypeName = txtTitle.Text;
         obj.Link     = MyFunction.ConvertUrl(txtTitle.Text);
         obj.Sort     = Convert.ToInt32(txtSort.Text);
         obj.Status   = chkStatus.Checked;
         obj.Update(obj);
         Response.Write("<script>alert('Cập nhật dữ liệu thành công');window.location='type.aspx'</script>");
     }
     catch (Exception ex)
     {
         lblMessage.Text = ex.Message;
     }
 }
Beispiel #16
0
        void Option3()           // 도움말
        {
            Console.Clear();
            Console.SetCursorPosition(2, 1);
            Console.Write("※도움말※");
            Console.SetCursorPosition(2, 3);
            Console.Write("↔: 이동");
            Console.SetCursorPosition(2, 4);
            Console.Write("↑, X: 시계방향 회전");
            Console.SetCursorPosition(2, 5);
            Console.Write("Z: 반시계방향 회전");
            Console.SetCursorPosition(2, 6);
            Console.Write("↓: 한 칸씩 내리기");
            Console.SetCursorPosition(2, 7);
            Console.Write("Spacebar: 한 번에 내리기");

            Console.SetCursorPosition(2, 8);
            Console.Write("C: 홀드");
            Console.SetCursorPosition(2, 9);
            Console.Write("P: 일시 정지/해제");
            Console.SetCursorPosition(2, 10);
            Console.Write("Q: 메뉴로 돌아가기");

            Console.SetCursorPosition(2, 12);
            Console.Write("레벨이 높아질수록 블록이 떨어지는 속도가 빨라집니다");
            Console.SetCursorPosition(2, 13);
            Console.Write("15줄 없앨 때마다 레벨이 1씩 오릅니다");
            Console.SetCursorPosition(2, 14);
            Console.Write("홀드 버튼으로 블록 하나를 킵해두고 불러올 수 있습니다 (연속 사용 불가)");

            Console.SetCursorPosition(2, 16);
            Console.Write("1줄 제거당 기본 점수는 {0}점 입니다", ONELINE);
            Console.SetCursorPosition(2, 17);
            Console.Write("한 번에 줄을 많이 없애면 1줄 제거당 점수가 {0}점씩 추가로 상승합니다", ADDLINE);
            Console.SetCursorPosition(2, 18);
            Console.Write("연속으로 줄을 없애면 점수 배율이 {0}배씩 증가합니다", COMBOBONUS);
            Console.SetCursorPosition(2, 19);
            Console.Write("레벨이 1 상승할 때마다 점수 배율이 {0}배씩 증가합니다", LEVELBONUS);
            Console.SetCursorPosition(2, 20);
            Console.Write("제어판 > 작은아이콘 보기 > 키보드 > 재입력 시간 짧음시 이동이 부드러워집니다");
            Console.SetCursorPosition(50, 23);
            Console.Write("▶ 뒤로가기(Spacebar/Enter)");
            MyFunction.WaitForExit();
        }
        private IEnumerator WaitForLoad(MyFunction functionToRun)
        {
            while (!loaded)
            {
                var resultsViewController = Resources.FindObjectsOfTypeAll <ResultsViewController>().FirstOrDefault();

                if (resultsViewController == null)
                {
                    Plugin.Log("resultsViewController is null!", Plugin.LogLevel.DebugOnly);
                    yield return(new WaitForSeconds(0.01f));
                }
                else
                {
                    Plugin.Log("Loaded the energy bar mover", Plugin.LogLevel.DebugOnly);
                    loaded = true;
                }
            }
            functionToRun();
        }
        public void Init()
        {
            MyFunction fn = StartA;

            fn.BeginInvoke("[B]开始运行", AsyncCallback =>
            {
                for (int i = 0; i < 1000; i++)
                {
                    Console.WriteLine("\t[B]运行了" + i + "%");
                }
                ;
            }, null);
            Console.WriteLine("[A]要开始运行了!");
            for (int i = 1; i <= 1000; i++)
            {
                Console.WriteLine("\t[A]运行了" + i + "%");
            }
            ;
        }
Beispiel #19
0
        public AddPatient(PatientInformation pI)
        {
            InitializeComponent();
            Thread Insurance = new Thread(() => { insurance = BAL.PatientInfo.GetInsurance(); });
            Thread City      = new Thread(() => { city = BAL.PatientInfo.GetCities(); });

            //doctor

            City.Start();
            Insurance.Start();

            City.Join();
            Insurance.Join();

            MyFunction.FillComboBox(Insurancebox, PatientInfo.GetInsurance(), "الجهة_الضامنة", "الرمز");
            MyFunction.FillComboBox(CityBox, BAL.PatientInfo.GetCities(), "المدينة", "رمز");
            CityBox.SelectedValueChanged += CityBox_SelectedValueChanged;
            PI = pI;
        }
Beispiel #20
0
        public static void Question_1()
        {
            Console.WriteLine("Cau 1: ");

            Console.Write("Enter month: ");
            int month = Convert.ToInt32(Console.ReadLine());

            Console.Write("Enter year: ");
            int year = Convert.ToInt32(Console.ReadLine());

            int[] num_day_in_month = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

            if (MyFunction.isLeapYear(year))
            {
                num_day_in_month[2]++;
            }

            Console.WriteLine($"{month}/{year} has {num_day_in_month[month]} days");
        }
        public void TestRamda()
        {
            // 単一ステートメントでは、{ } と return は省略できる
            MyFunction fun1 = (int x) => x * 3;
            int        n1   = fun1(20);

            Console.WriteLine(n1);

            // 引数の型は省略できる (MyFunctionデリゲートは、int型の引数であることが明白)
            MyFunction fun2 = (x) => x * 3;
            int        n2   = fun2(20);

            Console.WriteLine(n2);

            // 引数が1つのときは、( )も省略できる
            MyFunction fun3 = x => x * 3;
            int        n3   = fun3(20);

            Console.WriteLine(n3);
        }
        public async Task TestMyControllerGetResult(int a, int b, int result)
        {
            var request = new HttpRequestMessage
            {
                Method     = HttpMethod.Get,
                RequestUri = new Uri($"https://localhost/myroute?a={a}&b={b}")
            };

            request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration());

            var traceWriter = new TestTraceWriter(TraceLevel.Info);

            var response = MyFunction.Run(request, traceWriter);

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);

            var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

            Assert.Equal(result, int.Parse(responseContent));
        }
    public void E3_Functions_FactorialCalculation_Test()
    {
        OwnR <Func <Func <Func <int, int>, Func <int, int> >, Func <int, int> > > Y = y => f => x => f(y(y)(f))(x);
        var fixedPoint = Y(Y);
        var result     = fixedPoint(MyFunction.CalculateFactorial());

        Assert.AreEqual(1, result(1));
        Assert.AreEqual(2, result(2));
        Assert.AreEqual(6, result(3));
        Assert.AreEqual(24, result(4));
        Assert.AreEqual(120, result(5));
        Assert.AreEqual(720, result(6));
        Assert.AreEqual(5040, result(7));

        // This is Y. See links for more info about S-, K-, I-, and Y-combinator

        // Y combinator is defined as (Wikipedia):
        // g(f) = f(g(f))
        // f is the recursion and g is your function to do the business logic (=stop condition and call f)...
    }
Beispiel #24
0
    // Runs loop to check for valid user input. Checks for passed in valid answers and runs passed in functions if user inputs valid answer
    public static void ValidateInput(string prompt, string option1, MyFunction f1, string option2 = null, MyFunction f2 = null, string option3 = null, MyFunction f3 = null)
    {
        bool invalidInput = true;

        while (invalidInput)
        {
            RollingConsoleWrite(prompt);
            string userChoice = Console.ReadLine();
            if (userChoice == option1)
            {
                invalidInput = false;
                if (option1 == "restart")
                {
                    bread.ClearOrder();
                    pastries.ClearOrder();
                }
                f1();
            }
            else if (userChoice == option2 && option2 != null && f2 != null)
            {
                invalidInput = false;
                f2();
            }
            else if (userChoice == option3 && option3 != null && f3 != null)
            {
                invalidInput = false;
                f3();
            }
            else if (userChoice == "quit")
            {
                RollingConsoleWrite("Goodbye!");
                Environment.Exit(0);
            }
            else
            {
                RollingConsoleWrite("That was not a valid command!");
                Thread.Sleep(1000);
                Console.Clear();
            }
        }
    }
Beispiel #25
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     try
     {
         string   categoryid = Request["ctl00$MainContent$ddlCategory"];
         Products obj        = new Products();
         obj.NewsID      = GetID();
         obj.Title       = txtTitle.Text;
         obj.CategoryID  = Convert.ToInt32(categoryid);
         obj.Link        = MyFunction.ConvertUrl(txtTitle.Text);
         obj.Description = txtDescription.Text;
         obj.Detail      = txtDetail.Value.Replace("'", "’");
         if (this.IsValid && this.uplImage.HasFile)
         {
             Neodynamic.WebControls.ImageDraw.ImageElement uploadedImage;
             uploadedImage = Neodynamic.WebControls.ImageDraw.ImageElement.FromBinary(this.uplImage.FileBytes);
             Neodynamic.WebControls.ImageDraw.Resize actResize = new Neodynamic.WebControls.ImageDraw.Resize();
             actResize.Width  = 150;
             actResize.Height = 150;
             uploadedImage.Actions.Add(actResize);
             Neodynamic.WebControls.ImageDraw.ImageDraw imgDraw = new Neodynamic.WebControls.ImageDraw.ImageDraw();
             imgDraw.Elements.Add(uploadedImage);
             imgDraw.ImageFormat          = Neodynamic.WebControls.ImageDraw.ImageDrawFormat.Jpeg;
             imgDraw.JpegCompressionLevel = 90;
             string filename = GetDate + "_" + uplImage.FileName;
             imgDraw.Save(Server.MapPath("~/uploads/produsts/" + filename));
             obj.Image = filename;
         }
         else
         {
             obj.Image = hdnImage.Value;
         }
         obj.Status = chkStatus.Checked;
         obj.Update(obj);
         Response.Write("<script>alert('Cập nhật dữ liệu thành công');window.location='product.aspx'</script>");
     }
     catch (Exception ex)
     {
         lblMessage.Text = ex.Message;
     }
 }
Beispiel #26
0
        public Task Run(MyFunction f)
        {
            source1 = new CancellationTokenSource();
            token1  = source1.Token;

            token1.Register(() =>
            {
                Console.WriteLine("Cancelled.");
            });

            m_t = new Task(() =>
            {
                f(token1);
            }, token1);

            m_t.Start();

            ProcessServer.Register(m_key, this);

            return(m_t);
        }
Beispiel #27
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     try
     {
         Users obj = new Users();
         obj.Username = Session["UserLogin"].ToString();
         obj.Password = MyFunction.EncodePassword(txtPassword.Text);
         if (obj.DoiMatKhau(obj, MyFunction.EncodePassword(txtNewPassword.Text)))
         {
             Response.Redirect("ChangePasswordSuccess.aspx");
         }
         else
         {
             lblMessage.Text = "Mật khẩu cũ không chính xác.";
         }
     }
     catch (Exception ex)
     {
         lblMessage.Text = ex.Message;
     }
 }
Beispiel #28
0
        public static void Question_2()
        {
            Console.WriteLine("\nCau 2 ");
            Console.Write("Enter array length: ");
            int n = Convert.ToInt32(Console.ReadLine());

            int[] myArray = new int[n];

            int sum = 0;
            int num_of_prime_number = 0;
            int min_square_number   = Int32.MaxValue;

            for (int i = 0; i < n; i++)
            {
                Console.Write($"element {i}: ");
                myArray[i] = Convert.ToInt32(Console.ReadLine());
            }

            foreach (int element in myArray)
            {
                sum += element;
                if (MyFunction.isPrimeNumber(element))
                {
                    num_of_prime_number++;
                }
                if (MyFunction.isSquareNumber(element) && element < min_square_number)
                {
                    min_square_number = element;
                }
            }

            if (min_square_number == Int32.MaxValue)
            {
                min_square_number = -1;
            }

            Console.WriteLine("Sum: " + sum);
            Console.WriteLine("Number of Prime Number: " + num_of_prime_number);
            Console.WriteLine("Min Square Number: " + min_square_number);
        }
Beispiel #29
0
        public void WalkDirectoryTree(System.IO.DirectoryInfo root, MyFunction func)
        {
            System.IO.FileInfo[]      files   = null;
            System.IO.DirectoryInfo[] subDirs = null;

            files = root.GetFiles("*.*");

            if (files != null)
            {
                foreach (System.IO.FileInfo fi in files)
                {
                    func(fi);
                }

                subDirs = root.GetDirectories();

                foreach (System.IO.DirectoryInfo dirInfo in subDirs)
                {
                    WalkDirectoryTree(dirInfo, func);
                }
            }
        }
        private static double FindRootViaHalving(MyFunction func, double left, double right, decimal eps)
        {
            if (func(left) * func(right) > 0)
            {
                throw new ArgumentException("Func value has the same sign in 'left' and 'right'");
            }
            var x = (left + right) / 2;

            while ((decimal)Math.Abs(left - right) > 2 * eps)
            {
                if (func(left) * func(x) < 0)
                {
                    right = x;
                }
                else if (func(x) * func(right) < 0)
                {
                    left = x;
                }
                x = (left + right) / 2;
            }
            return(x);
        }
Beispiel #31
0
        private void ToHos_CheckChange(object sender, EventArgs e)
        {
            if (!ToHos.Check)
            {
                ToHospital.Enabled = false;
            }
            else
            {
                ToHospital.Enabled = true;



                if (ToHome.Check)
                {
                    tableLayoutPanel15.Enabled = false;
                    tableLayoutPanel20.Enabled = false;
                    ToHome.Check = false;

                    ToBuilding.Text       = "";
                    ToRegion.SelectedItem = null;
                    ToCity.SelectedItem   = null;

                    ToFloor.Text    = "";
                    ToStreet.Text   = "";
                    MoreToInfo.Text = "";
                }
                try
                {
                    ToCity.SelectedValueChanged -= Name_ToHospital_SelectedValueChanged;
                }
                catch { }
                if (Name_ToHospital.DataSource == null)
                {
                    MyFunction.FillComboBox(Name_ToHospital, BAL.PatientInfo.GetHospitals(), "اسم_المستشفى", "رمز_المستشفى");
                }
                ID_ToHospital.Text = "";
                Name_ToHospital.SelectedValueChanged += Name_ToHospital_SelectedValueChanged;
            }
        }
Beispiel #32
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     try
     {
         News obj = new News();
         obj.Title       = txtTitle.Text;
         obj.Link        = MyFunction.ConvertUrl(txtTitle.Text);
         obj.Description = txtDescription.Text;
         obj.Detail      = txtDetail.Value.Replace("'", "’");
         if (this.IsValid && this.uplImage.HasFile)
         {
             Neodynamic.WebControls.ImageDraw.ImageElement uploadedImage;
             uploadedImage = Neodynamic.WebControls.ImageDraw.ImageElement.FromBinary(this.uplImage.FileBytes);
             Neodynamic.WebControls.ImageDraw.Resize actResize = new Neodynamic.WebControls.ImageDraw.Resize();
             actResize.Width  = 150;
             actResize.Height = 130;
             uploadedImage.Actions.Add(actResize);
             Neodynamic.WebControls.ImageDraw.ImageDraw imgDraw = new Neodynamic.WebControls.ImageDraw.ImageDraw();
             imgDraw.Elements.Add(uploadedImage);
             imgDraw.ImageFormat          = Neodynamic.WebControls.ImageDraw.ImageDrawFormat.Jpeg;
             imgDraw.JpegCompressionLevel = 90;
             string filename = GetDate + "_" + uplImage.FileName;
             imgDraw.Save(Server.MapPath("~/uploads/news/" + filename));
             obj.Image = filename;
         }
         else
         {
             obj.Image = "";
         }
         obj.Date = DateTime.Now;
         obj.Add(obj);
         Response.Write("<script>alert('Cập nhật dữ liệu thành công');window.location='new.aspx'</script>");
     }
     catch (Exception ex)
     {
         lblMessage.Text = ex.Message;
     }
 }
Beispiel #33
0
        private void FromHos_CheckChange(object sender, EventArgs e)
        {
            if (!FromHos.Check)
            {
                FromHospital.Enabled = false;
            }
            else
            {
                FromHospital.Enabled = true;



                if (FromHome.Check)
                {
                    FromHomeInfo.Enabled = false;
                    FromHome.Check       = false;

                    FromBuilding.Text       = "";
                    FromRegion.SelectedItem = null;
                    FromCity.SelectedItem   = null;

                    FromFloor.Text    = "";
                    FromStreet.Text   = "";
                    MoreFromInfo.Text = "";
                }
                try
                {
                    FromCity.SelectedValueChanged -= Name_FromHospital_SelectedValueChanged;
                }
                catch { }
                if (Name_FromHospital.DataSource == null)
                {
                    MyFunction.FillComboBox(Name_FromHospital, BAL.PatientInfo.GetHospitals(), "اسم_المستشفى", "رمز_المستشفى");
                }
                ID_FromHospital.Text = "";
                Name_FromHospital.SelectedValueChanged += Name_FromHospital_SelectedValueChanged;
            }
        }
Beispiel #34
0
	public bool buttons(int rows, int cols,Rect r, Texture[] textures,MyFunction func, bool requireParField)
	{
		float rx = r.x;
		int n = 0;
		bool badTextures = false;
		//r.width = 1f / (float)bx;
		//r.height = 0.4f / (float)by; 
		
		//	Debug.Log("buttons" + r);
		float rh = r.height;
		for(int i=0;i<rows; i++)
		{
			for(int j=0; j<cols; j++)
			{
				if(textures!=null)
				{
					float r0 = r.height;
					if(requireParField)
					{
						r.height = rh - 0.05f;
					}
					if(GUI.Button(GUIHelper.screenRect(r),textures[n]))
					{
						func(textures,n);
					}
					
					if(requireParField)
					{
						Rect r1 = r;
						r1.y += r.height;
						r1.width *= 0.5f;
						GUI.Label(GUIHelper.screenRect(r1),"Hole: " + (n+1) + " Par");
						r1.x += r1.width;
						r1.height = 0.05f; 
					//	m_par[n] = EditorGUI.IntField(GUIHelper.screenRect(r1),m_par[n]);
					}
					
					
				}else{
					
					badTextures=true;
					
				}
				n++;
				r.x+=r.width;
			}
			r.x = rx;
			float offset = 0f;
			if(requireParField)offset=0.05f;
			
			r.y+= r.height+offset;
		}
		return badTextures;
	}
 public MyFunctionCompiler(MyFunction function)
     : base(function)
 {
 }