示例#1
0
        public ImageForm(string path)
        {
            this.Height = 700;
            this.Width  = 800;
            InitializeComponent();
            path = "\\" + path.Substring(1);

            if (File.Exists(path))
            {
                var uri = new Uri(path);
                //strImagePath 就绝对路径
                try
                {
                    img.Source = new BitmapImage(uri);
                    FormCommon.ShowForm("", this);
                }
                catch (Exception e)
                {
                    if (e is NotSupportedException)
                    {
                        FormCommon.ShowErr("图片格式错误!");
                    }
                    else
                    {
                        FormCommon.ShowErr(e.Message);
                    }
                }
            }
            else
            {
                FormCommon.ShowErr("图片文件不存在!");
            }
        }
示例#2
0
        /// <summary>
        /// 弹出图片查看
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnShowImage_Click(object sender, RoutedEventArgs e)
        {
            var attachment = sender as AttachmentItem;
            var form       = new ImageForm(attachment._FileInfo.FullName);

            FormCommon.ShowForm("", form);
        }
        private void btnCalendar_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            var modelFrom = new MyDatePicker.DateModel();
            var dateFrom  = _Value.ToDateTime();

            dateFrom        = dateFrom.Equals(DateTime.MinValue) ? DateTime.Now : dateFrom;
            modelFrom.Year  = dateFrom.Year;
            modelFrom.Month = dateFrom.Month;
            modelFrom.Day   = dateFrom.Day;

            var modelTo = new MyDatePicker.DateModel();
            var dateTo  = _Value2.ToDateTime();

            dateTo        = dateTo.Equals(DateTime.MinValue) ? DateTime.Now : dateTo;
            modelTo.Year  = dateTo.Year;
            modelTo.Month = dateTo.Month;
            modelTo.Day   = dateTo.Day;

            var model = new DateRangeModel();

            model.DateFrom = modelFrom;
            model.DateTo   = modelTo;

            var form = new MyCalendarDouble();

            form._Mode = _Mode;
            form._Init(model);
            FormCommon.ShowForm("", form, model, AfterCloseCallBack);
        }
示例#4
0
 private void PanelDetail_Click(object sender, EventArgs e)
 {
     if (_panel.Visible)
     {
         FormCommon.Animate(_panel, FormCommon.Effect.Slide, 200, 90);
     }
 }
        /// <summary>
        /// 设置线程,运行copy文件,它与代理CopyFile_Delegate应具有相同的参数和返回类型
        /// </summary>
        private void RunCopyFile()
        {
            if (!File.Exists(_DownloadPath))
            {
                Application.Current.Dispatcher.Invoke((Action)(() =>
                {
                    FormCommon.ShowErr("文件:" + _DownloadPath + "不存在!");
                    this.IsEnabled = true;
                }));
                return;
            }
            var    file   = new FileInfo(_DownloadPath);
            string toFile = this.SavePath + "\\" + file.Name;

            CopyFile(_DownloadPath, toFile, 1024, btnDownload); //复制文件

            Application.Current.Dispatcher.Invoke((Action)(() =>
            {
                var arge = new MyDownloadEventArge(AfterDownloadRoutedEvent, this);
                arge._TargetFileInfo = new FileInfo(toFile);
                RaiseEvent(arge);
            }));

            Thread.Sleep(0);     //避免假死
            ThdCopyFile.Abort(); //关闭线程
        }
示例#6
0
 private void OK_Click(object sender, RoutedEventArgs e)
 {
     if (Button == MessageBoxButton.OK)
     {
         _Model._Result = MessageBoxResult.OK;
     }
     else if (Button == MessageBoxButton.YesNo)
     {
         _Model._Result = MessageBoxResult.Yes;
     }
     FormCommon.CloseForm(this);
 }
示例#7
0
        public MainForm()
        {
            InitializeComponent();
            CheckForIllegalCrossThreadCalls = false;

            GetRadiusEventHandler GR = new GetRadiusEventHandler(FormCommon.GetRadius);

            GR(40);

            FormCommon FC = new FormCommon();

            this.Region = FC.Round(this.Width, this.Height);
        }
示例#8
0
        public LoginForm()
        {
            InitializeComponent();

            // 通过委托传递圆角弧度
            GetRadiusEventHandler getRadiusEventHandler = new GetRadiusEventHandler(FormCommon.GetRadius);

            getRadiusEventHandler(40);
            //base.Refresh();
            FormCommon formCommon = new FormCommon();

            this.Region = formCommon.Round(this.Width, this.Height);
        }
示例#9
0
 private void TxtALONTOP_KeyDown(object sender, KeyEventArgs e)
 {
     if ((e.KeyCode >= Keys.PageUp && e.KeyCode <= Keys.Home) ||
         (e.KeyCode >= Keys.Insert && e.KeyCode <= Keys.Z) ||
         (e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.F12) ||
         (e.KeyCode >= Keys.OemSemicolon && e.KeyCode <= Keys.OemQuotes))
     {
         e.SuppressKeyPress   = true;
         this.TxtALONTOP.Tag  = e.KeyValue;
         this.TxtALONTOP.Text = FormCommon.ConvertKeyToString(e.KeyCode);
     }
     else
     {
         e.Handled = true;
     }
 }
示例#10
0
        /// <summary>
        /// 设置线程,运行copy文件,它与代理CopyFile_Delegate应具有相同的参数和返回类型
        /// </summary>
        private void RunCopyFile()
        {
            Application.Current.Dispatcher.Invoke((Action)(() =>
            {
                if (_FileInfo == null)
                {
                    _SetErr();
                    FormCommon.ShowErr("请选择要上传的文件!");
                    return;
                }
                if (!File.Exists(_FileInfo.FullName))
                {
                    _SetErr();
                    FormCommon.ShowErr("源文件不存在!");
                    return;
                }
            }));

            var path = _DefaultDirectory;

            try
            {
                UploadFile(_FileInfo.FullName, path + _FileInfo.Name, 1024); //复制文件
            }
            catch (Exception ex)
            {
                Application.Current.Dispatcher.Invoke((Action)(() =>
                {
                    if (_AfterUpload != null)
                    {
                        _AfterUpload(false, ex.Message);
                    }
                }));
            }
            Thread.Sleep(0); //避免假死

            Application.Current.Dispatcher.Invoke((Action)(() =>
            {
                if (_AfterUpload != null)
                {
                    _AfterUpload(true, null);
                }
            }));
            ThdCopyFile.Abort();  //关闭线程
        }
示例#11
0
        /// <summary>
        /// login button click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Login_btn_Click(object sender, EventArgs e)
        {
            messageData = new MessageData("llce00001", Properties.Resources.llce00001.ToString(), new string[] { "Login Click. Start : " + DateTime.Now.ToString() });
            Logger.Info(messageData);

            if (!CheckMandatory())
            {
                return;
            }

            try
            {
                if (!IsAuthentificated())
                {
                    return;
                }

                //get the instance of form to be open after logged in
                FormCommon frmMenu = GetMenuInstance();
                if (frmMenu == null)
                {
                    return;
                }

                this.Hide();
                frmMenu.ShowDialog(frmMenu);
                this.Show();
                Password_txt.Text = string.Empty;
            }
            catch (ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                return;
            }
            catch (SystemException exception)
            {
                popUpMessage.SystemError(exception.GetMessageData(), Text);
                this.Close();
            }
            finally
            {
                messageData = new MessageData("llce00001", Properties.Resources.llce00001.ToString(), new string[] { "Login Click. End : " + DateTime.Now.ToString() });
                Logger.Info(messageData);
            }
        }
示例#12
0
        private void btnCalendar_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            var model = new DateModel();
            var date  = _Value.ToDateTime();

            date        = date.Equals(DateTime.MinValue) ? DateTime.Now : date;
            model.Year  = date.Year;
            model.Month = date.Month;
            model.Day   = date.Day;
            var form = new MyCalendar();

            form._Mode = this._Mode;
            form._Init(model);
            form._CalendarMonthSelect += MonthSelect;
            form._CalendarDateSelect  += DaySelect;
            form._CalendarYearSelect  += YearSelect;
            FormCommon.ShowForm("", form);
        }
示例#13
0
        /// <summary>
        /// 下载文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDownloadFile_Click(object sender, RoutedEventArgs e)
        {
            var attachment = sender as AttachmentItem;

            if (!File.Exists(attachment._FileInfo.FullName))
            {
                FormCommon.ShowErr("文件:" + attachment._FileInfo.FullName + "不存在!");
                return;
            }

            var op     = new System.Windows.Forms.FolderBrowserDialog();
            var result = op.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                File.Copy(attachment._FileInfo.FullName, op.SelectedPath + "\\" + attachment._FileInfo.Name, true);
            }
        }
        /// <summary>
        /// 确认
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OK_Click(object sender, RoutedEventArgs e)
        {
            var dateFrom = this.DateFrom.ToDateTime();

            if (!dateFrom.Equals(DateTime.MinValue))
            {
                DateRange.DateFrom.Year  = dateFrom.Year;
                DateRange.DateFrom.Month = dateFrom.Month;
                DateRange.DateFrom.Day   = dateFrom.Day;
            }

            var dateTo = this.DateTo.ToDateTime();

            DateRange.DateTo.Year  = dateTo.Year;
            DateRange.DateTo.Month = dateTo.Month;
            DateRange.DateTo.Day   = dateTo.Day;

            FormCommon.CloseForm(this);
        }
示例#15
0
        /// <summary>
        /// 选中日期
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDay_Click(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            var cell = sender as CalendarCell;

            this.Date.Year  = cell.Year;
            this.Date.Month = cell.Month;
            this.Date.Day   = cell.Day;
            foreach (var row in pnlDate.Children)
            {
                var pnl = row as StackPanel;
                foreach (var cel in pnl.Children)
                {
                    var lbl = cel as CalendarCell;
                    lbl.Background = CommonUtil.ToBrush("#FFFFFF");
                    if (lbl.Year == this.Year && lbl.Month == this.Month)
                    {
                        lbl.Foreground = CommonUtil.ToBrush("#3b3b3b");
                    }
                    else
                    {
                        lbl.Foreground = CommonUtil.ToBrush("#CCC");
                    }
                }
            }

            var col = sender as Label;

            col.Background = CommonUtil.ToBrush("#FF4169E1");
            col.Foreground = CommonUtil.ToBrush("#FFFFFF");

            var arge = new CalendarDateSelectEventArge(CalendarDateSelectRoutedEvent, this);

            arge._Year  = this.Date.Year;
            arge._Month = this.Date.Month;
            arge._Day   = this.Date.Day;
            RaiseEvent(arge);

            if (this.SelectDateClose)
            {
                FormCommon.CloseForm(this);
            }
        }
示例#16
0
        /// <summary>
        /// 选中月份
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnMonth_Click(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            var cell = sender as CalendarCell;

            this.Year       = cell.Year;
            this.Month      = cell.Month;
            this.Year_Month = cell.Year;
            this.Year_Year  = cell.Year;
            foreach (var row in pnlMonth.Children)
            {
                var pnl = row as StackPanel;
                foreach (var cel in pnl.Children)
                {
                    var lbl = cel as Label;
                    lbl.Background = CommonUtil.ToBrush("#FFFFFF");
                    lbl.Foreground = CommonUtil.ToBrush("#3b3b3b");
                }
            }

            var col = sender as Label;

            col.Background = CommonUtil.ToBrush("#FF4169E1");
            col.Foreground = CommonUtil.ToBrush("#FFFFFF");

            var arge = new CalendarDateSelectEventArge(CalendarMonthSelectRoutedEvent, this);

            arge._Year  = cell.Year;
            arge._Month = cell.Month;
            arge._Day   = 0;
            RaiseEvent(arge);

            if (_Mode == DateMode.Month)
            {
                if (this.SelectDateClose)
                {
                    FormCommon.CloseForm(this);
                }
                return;
            }
            this.Mode = 1;
            SetByMode();
        }
示例#17
0
        /// <summary>
        /// instance of the form to be load after login
        /// </summary>
        /// <returns></returns>
        private FormCommon GetMenuInstance()
        {
            //Get empty userdatas
            UserData userData = BindLoggedInUserData();

            if (userData == null)
            {
                return(null);
            }

            FormCommon menuform = null;

            if (UserData.GetUserData().FactoryCodeList.Count == 1)
            {
                userData.FactoryCode = UserData.GetUserData().FactoryCodeList[0].ToString();

                Assembly assembly = Assembly.LoadFile(AppDomain.CurrentDomain.BaseDirectory + applicationAssemblyName); // dll name
                Type     type     = assembly.GetType(applicationTypeName);                                              //form name

                if (type != null)
                {
                    menuform = Activator.CreateInstance(type) as FormCommon;

                    return(menuform);
                }
                else
                {
                    messageData = new MessageData("llce00006", Properties.Resources.llce00006.ToString());
                    popUpMessage.ApplicationError(messageData, Text);
                    Logger.Info(messageData);

                    return(null);
                }
            }
            else
            {
                menuform = new FactorySelectionForm(applicationAssemblyName, applicationTypeName);

                return(menuform);
            }
        }
示例#18
0
        private void btnAdd_Click(object sender, MouseButtonEventArgs e)
        {
            if (_ViewFullName.IsNullOrEmpty())
            {
                FormCommon.ShowErr("必须将属性“_ViewFullName”设置为当前画面的全称!");
                return;
            }

            if (this._DefaultDirectory.IsNullOrEmpty())
            {
                FormCommon.ShowErr("必须设置属性“_DefaultDirectory”!");
                return;
            }

            var op = new System.Windows.Forms.OpenFileDialog();

            op.RestoreDirectory = true;
            var result = op.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                SourceFile = op.FileName;

                //this._Text = this._Content;
                this.IsEnabled = true;

                var arge = new MyUploadEventArge(BeforeAttarchUploadRoutedEvent, this);
                arge._SourceFileInfo = new FileInfo(op.FileName);
                RaiseEvent(arge);


                ThdCopyFile = new Thread(new ThreadStart(RunCopyFile));
                // 将子线程管理起来,便宜在画面关闭后将子线程停止
                ThreadManager._AddThread(_ViewFullName, ThdCopyFile);
                // 开始下载
                this.IsEnabled = false;
                ThdCopyFile.Start();
            }
        }
        private void btnDownload_Click(object sender, RoutedEventArgs e)
        {
            if (_ViewFullName.IsNullOrEmpty())
            {
                FormCommon.ShowErr("必须将属性“_ViewFullName”设置为当前画面的全称!");
                return;
            }

            var op     = new System.Windows.Forms.FolderBrowserDialog();
            var result = op.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                this.SavePath = op.SelectedPath;

                ThdCopyFile = new Thread(new ThreadStart(RunCopyFile));
                // 将子线程管理起来,便宜在画面关闭后将子线程停止
                ThreadManager._AddThread(_ViewFullName, ThdCopyFile);
                // 开始下载
                this.IsEnabled = false;
                ThdCopyFile.Start();
            }
        }
示例#20
0
        public override void LoadSettings()
        {
            try
            {
                string[] settings = Properties.Settings.Default.ALONTOPShortcut.Split('&');
                this.ChkALONTOPCtrl.Checked  = settings[0].Trim().Equals("1");
                this.ChkALONTOPShift.Checked = settings[1].Trim().Equals("1");
                this.ChkALONTOPAlt.Checked   = settings[2].Trim().Equals("1");
                this.TxtALONTOP.Text         = FormCommon.ConvertKeyToString((Keys)Int32.Parse(settings[3]));
                //this.ChkALONTOP.Checked = Properties.Settings.Default.ALONTOEnable;
                //this.ChkRunAtStatup.Checked = Properties.Settings.Default.RunAtStatupEnable;

                _registryKey = Registry.CurrentUser.OpenSubKey
                                   ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

                SetStatupSetting();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                MessageBox.Show(Resources.Error001, Resources.TitleError, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                DefaultSettings();
            }
        }
示例#21
0
        //static string Config;

        //public static void GetConfig(string config)
        //{
        //    Config = config;
        //}

        //private void TimerMenu_Tick(object sender, EventArgs e)
        //{
        //    if (Cursor.Position.Y - this.Top < 50)
        //    {
        //        this.PanelMenuShow.Show();
        //        //timer1.Start();
        //        //PanelShow();
        //        //this.PanelMenuShow.Visible = true;

        //        //FormCommon formCommon = new FormCommon();
        //        //formCommon.TimerCreate();
        //    }
        //    else
        //    {
        //        this.PanelMenuShow.Hide();
        //    }
        //}

        //private void timer1_Tick(object sender, EventArgs e)
        //{
        //    int i = 2;
        //    int y = this.PanelMenuShow.Height;
        //    this.PanelMenuShow.Height = y / i;
        //    i = i + 1;
        //}

        private void PanelShow()
        {
            FormCommon formCommon = new FormCommon();

            formCommon.TimerCreate();
        }
示例#22
0
 private void Cancel_Click(object sender, RoutedEventArgs e)
 {
     _Model._Result = MessageBoxResult.No;
     FormCommon.CloseForm(this);
 }
示例#23
0
        /// <summary>
        /// 复制文件
        /// </summary>
        /// <param name="sourceFile">源文件路径</param>
        /// <param name="ToFile">目的文件路径</param>
        /// <param name="TranSize">传输大小</param>
        /// <param name="progressBar1">ProgressBar控件</param>
        private void CopyFile(string sourceFile, string ToFile, int TranSize)
        {
            if (sourceFile.IsNullOrEmpty())
            {
                FormCommon.ShowErr("未指定源文件!");
                return;
            }

            // 实例化源文件FileStream类
            FileStream FormerOpenStream;
            // 实例化目标文件FileStream类
            FileStream ToFileOpenStream;

            try
            {
                FormerOpenStream = new FileStream(sourceFile, FileMode.Open, FileAccess.Read);//以只读方式打开源文件
            }
            catch (IOException ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            try
            {
                FileStream fileToCreate = new FileStream(ToFile, FileMode.Create); //创建目的文件,如果已存在将被覆盖
                fileToCreate.Close();                                              //关闭所有fileToCreate的资源
                fileToCreate.Dispose();                                            //释放所有fileToCreate的资源
            }
            catch (IOException ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            ToFileOpenStream = new FileStream(ToFile, FileMode.Append, FileAccess.Write);//以写方式打开目的文件

            //根据一次传输的大小,计算最大传输个数. Math.Ceiling 方法 (Double),返回大于或等于指定的双精度浮点数的最小整数值。
            int max        = Convert.ToInt32(Math.Ceiling((Double)FormerOpenStream.Length / (Double)TranSize));
            int currentVal = 0;
            //progressBar1.Maximum = max;//设置进度条的最大值
            int FileSize;                           //每次要拷贝的文件的大小

            if (TranSize < FormerOpenStream.Length) //如果分段拷贝,即每次拷贝内容小于文件总长度
            {
                byte[] buffer = new byte[TranSize]; //根据传输的大小,定义一个字节数组,用来存储传输的字节
                int    copied = 0;                  //记录传输的大小
                int    tem_n  = 1;                  //设置进度栏中进度的增加个数
                while (copied <= ((int)FormerOpenStream.Length - TranSize))
                {
                    FileSize = FormerOpenStream.Read(buffer, 0, TranSize); //从0开始读到buffer字节数组中,每次最大读TranSize
                    FormerOpenStream.Flush();                              //清空缓存
                    ToFileOpenStream.Write(buffer, 0, TranSize);           //向目的文件写入字节
                    ToFileOpenStream.Flush();                              //清空缓存
                    ToFileOpenStream.Position = FormerOpenStream.Position; //是源文件的目的文件流的位置相同
                    copied     += FileSize;                                //记录已经拷贝的大小
                    currentVal += tem_n;                                   //增加进度栏的进度块

                    Application.Current.Dispatcher.Invoke((Action)(() =>
                    {
                        lblPercent.Content = (currentVal * 100 / max).ToString() + "%";
                    }));
                }
                int leftSize = (int)FormerOpenStream.Length - copied;  //获取剩余文件的大小
                FileSize = FormerOpenStream.Read(buffer, 0, leftSize); //读取剩余的字节
                FormerOpenStream.Flush();
                ToFileOpenStream.Write(buffer, 0, leftSize);           //写入剩余的部分
                ToFileOpenStream.Flush();
            }
            else //如果整体拷贝,即每次拷贝内容大于文件总长度
            {
                byte[] buffer = new byte[FormerOpenStream.Length];
                FormerOpenStream.Read(buffer, 0, (int)FormerOpenStream.Length);
                FormerOpenStream.Flush();
                ToFileOpenStream.Write(buffer, 0, (int)FormerOpenStream.Length);
                ToFileOpenStream.Flush();
            }
            FormerOpenStream.Close();
            ToFileOpenStream.Close();
            Application.Current.Dispatcher.Invoke((Action)(() =>
            {
                lblPercent.Content = "100%";
                var fileInfo = new FileInfo(ToFile);
                _AttachmentList.Add(fileInfo);
                MyTimer.SetTimeout(1000, () =>
                {
                    lblPercent.Content = "";
                    CreateSmallImg(fileInfo, _AttachmentList.Count - 1);
                });

                this.IsEnabled = true;

                var arge = new MyUploadEventArge(AftervUploadRoutedEvent, this);
                arge._SourceFileInfo = new FileInfo(sourceFile);
                arge._TargetFileInfo = new FileInfo(ToFile);
                RaiseEvent(arge);
            }));
        }
示例#24
0
 private void HelperButton_Click(object sender, EventArgs e)
 {
     FormCommon.Animate(_panel, FormCommon.Effect.Slide, 200, 90);
 }
示例#25
0
        /// <summary>
        /// 复制文件
        /// </summary>
        /// <param name="sourceFile">源文件路径</param>
        /// <param name="ToFile">目的文件路径</param>
        /// <param name="TranSize">传输大小</param>
        /// <param name="progressBar1">ProgressBar控件</param>
        private void UploadFile(string sourceFile, string ToFile, int TranSize)
        {
            if (sourceFile.IsNullOrEmpty())
            {
                FormCommon.ShowErr("未指定源文件!");
                return;
            }

            // 实例化源文件FileStream类
            FileStream FormerOpenStream;
            // 实例化目标文件FileStream类
            FileStream ToFileOpenStream;

            try
            {
                FormerOpenStream = new FileStream(sourceFile, FileMode.Open, FileAccess.Read);//以只读方式打开源文件
            }
            catch (IOException ex)
            {
                if (_AfterUpload != null)
                {
                    _AfterUpload(false, ex.Message);
                }
                return;
            }

            try
            {
                FileStream fileToCreate = new FileStream(ToFile, FileMode.Create); //创建目的文件,如果已存在将被覆盖
                fileToCreate.Close();                                              //关闭所有fileToCreate的资源
                fileToCreate.Dispose();                                            //释放所有fileToCreate的资源
            }
            catch (IOException ex)
            {
                if (_AfterUpload != null)
                {
                    _AfterUpload(false, ex.Message);
                }
                return;
            }

            ToFileOpenStream = new FileStream(ToFile, FileMode.Append, FileAccess.Write);//以写方式打开目的文件

            //根据一次传输的大小,计算最大传输个数. Math.Ceiling 方法 (Double),返回大于或等于指定的双精度浮点数的最小整数值。
            int max        = Convert.ToInt32(Math.Ceiling((Double)FormerOpenStream.Length / (Double)TranSize));
            int currentVal = 0;
            //progressBar1.Maximum = max;//设置进度条的最大值
            int FileSize;                           //每次要拷贝的文件的大小

            if (TranSize < FormerOpenStream.Length) //如果分段拷贝,即每次拷贝内容小于文件总长度
            {
                byte[] buffer = new byte[TranSize]; //根据传输的大小,定义一个字节数组,用来存储传输的字节
                int    copied = 0;                  //记录传输的大小
                int    tem_n  = 1;                  //设置进度栏中进度的增加个数
                while (copied <= ((int)FormerOpenStream.Length - TranSize))
                {
                    FileSize = FormerOpenStream.Read(buffer, 0, TranSize); //从0开始读到buffer字节数组中,每次最大读TranSize
                    FormerOpenStream.Flush();                              //清空缓存
                    ToFileOpenStream.Write(buffer, 0, TranSize);           //向目的文件写入字节
                    ToFileOpenStream.Flush();                              //清空缓存
                    ToFileOpenStream.Position = FormerOpenStream.Position; //是源文件的目的文件流的位置相同
                    copied     += FileSize;                                //记录已经拷贝的大小
                    currentVal += tem_n;                                   //增加进度栏的进度块

                    Application.Current.Dispatcher.Invoke((Action)(() =>
                    {
                        this._Text = _Caption + (currentVal * 100 / max).ToString() + "%";
                    }));
                }
                int leftSize = (int)FormerOpenStream.Length - copied;  //获取剩余文件的大小
                FileSize = FormerOpenStream.Read(buffer, 0, leftSize); //读取剩余的字节
                FormerOpenStream.Flush();
                ToFileOpenStream.Write(buffer, 0, leftSize);           //写入剩余的部分
                ToFileOpenStream.Flush();
                Application.Current.Dispatcher.Invoke((Action)(() =>
                {
                    this._Text = _Caption + "100%";
                    Thread.Sleep(1000);
                }));
            }
            else //如果整体拷贝,即每次拷贝内容大于文件总长度
            {
                byte[] buffer = new byte[FormerOpenStream.Length];
                FormerOpenStream.Read(buffer, 0, (int)FormerOpenStream.Length);
                FormerOpenStream.Flush();
                ToFileOpenStream.Write(buffer, 0, (int)FormerOpenStream.Length);
                ToFileOpenStream.Flush();
            }
            FormerOpenStream.Close();
            ToFileOpenStream.Close();
            Application.Current.Dispatcher.Invoke((Action)(() =>
            {
                this._Text = this._Caption;
                this.IsEnabled = true;
            }));
        }
示例#26
0
    {/* Docs: https://html.spec.whatwg.org/multipage/custom-elements.html#cereactions */
     /* Docs: https://html.spec.whatwg.org/multipage/custom-elements.html#custom-element-reaction-queue */



#if ENABLE_HTML
        public static void Upgrade_Element(Element element, ref CustomElementDefinition definition)
        {/* Docs: https://html.spec.whatwg.org/multipage/custom-elements.html#upgrades */
            if (element.isCustom)
            {
                return;
            }

            if (element.CustomElementState == ECustomElement.Failed)
            {
                return;
            }

            element.Definition = new WeakReference <CustomElementDefinition>(definition);
            /* 4) For each attribute in element's attribute list, in order, enqueue a custom element callback reaction with element, callback name "attributeChangedCallback", and an argument list containing attribute's local name, null, attribute's value, and attribute's namespace. */
            foreach (Attr attr in element.AttributeList)
            {
                Enqueue_Reaction(element, EReactionName.AttributeChanged, attr.localName, null, attr.Value, attr.namespaceURI);
            }

            if (element.isConnected)
            {
                Enqueue_Reaction(element, EReactionName.Connected);
            }

            definition.constructionStack.Push(new WeakReference <Element>(element));

            var C = definition.constructor;

            /* 8) Run the following substeps while catching any exceptions: */
            try
            {
                if (definition.bDisableShadow && element.shadowRoot != null)
                {
                    throw new NotSupportedException($"Cannot upgrade a custom element which has a shadow root and whose definition has ShadowDOM disabled");
                }

                /* Notes:
                 * Okay so the specifications intended this system to be used by javascript, and because of this it relies on being able to sort of tack on prototype functions and stuff to an element object.
                 * We are implementing this (and using it) with C#, as such we cannot simply "tack-on" things to this element instance to upgrade it to this class.
                 * So we need to actually completely replace the element within the document with an instance of the class it should be which also contains all of its data & children...
                 * Fortunately creating a clone of this element and "stealing" its children will do exactly that!
                 */

                /* UPDATE:
                 *      We cannot just replace the element because we cannot update any instances of it being referenced in memory,
                 *      so we need to figure out a way we can do the equivalent of this upgrade to the actual live element instance in memory */

                throw new NotImplementedException($"Custom element upgrading is not yet supported");

                /* Clone this node to get an upgraded version of it *//*
                 * Element upgradeResult = (Element)Node._clone_node(element, null);
                 *
                 *//* Steal all of the old nodes children *//*
                 * Node lastNode = null;
                 * foreach (Node child in element.childNodes)
                 * {
                 *  Node._insert_node_into_parent_before(child, upgradeResult, lastNode, true);
                 *  lastNode = child;
                 * }
                 */
            }
            catch (Exception ex)
            {
                element.CustomElementState = ECustomElement.Failed;
                element.Definition         = null;
                element.Custom_Element_Reaction_Queue.Clear();

                throw ex;
            }
            finally
            {
                definition.constructionStack.Pop();
            }

            /* 9) If element is a form-associated custom element, then: */
            if (element is FormAssociatedElement formElement)
            {
                /* 1) Reset the form owner of element. If element is associated with a form element, then enqueue a custom element callback reaction with element, callback name "formAssociatedCallback", and « the associated form ». */
                FormCommon.Reset_Form_Owner(element);
                if (formElement.form != null)
                {
                    Enqueue_Reaction(element, EReactionName.FormAssociated, formElement.form);
                }

                /* 2) If element is disabled, then enqueue a custom element callback reaction with element, callback name "formDisabledCallback" and « true ». */
                if (element is HTMLElement htmlElement && htmlElement.disabled)
                {
                    Enqueue_Reaction(element, EReactionName.FormDisabled, true);
                }
            }

            element.CustomElementState = ECustomElement.Custom;
        }
示例#27
0
 private void PanelBody_MouseDown(object sender, MouseEventArgs e)
 {
     FormCommon.ReleaseCapture();
     FormCommon.SendMessage(this.Handle, 0x0112, 0xF012, 0);
 }
示例#28
0
        /// <summary>
        /// 验证条件
        /// 遍历该容器下所有继承IInputControl接口的控件的_Value属性,当被遍历的控件的_MustInput属性为true,
        /// 并且没有输入时会返回这些控件的_Caption,用逗号分隔
        /// </summary>
        /// <returns></returns>
        public string _CheckCondition()
        {
            var listMustInput = new List <IInputControl>();

            GetMustInputCondition(this, listMustInput);


            var list = new List <string>();
            var msg  = new StringBuilder();

            foreach (var contr in listMustInput)
            {
                // 对日期范围控件特殊处理
                if (contr is MyDatePickerRange)
                {
                    var    datePickerRange = contr as MyDatePickerRange;
                    string from            = datePickerRange._Value.ToStr();
                    string to = datePickerRange._Value2.ToStr();
                    if (!from.IsNullOrEmpty() && !from.IsNullOrEmpty())
                    {
                        if (from.CompareTo(to) > 0)
                        {
                            list.Add(contr._Caption);
                            contr._SetErr();
                            msg.AppendLine(contr._Caption + "的大小关系不正确!");
                        }
                    }

                    if (from.IsNullOrEmpty() && to.IsNullOrEmpty())
                    {
                        list.Add(contr._Caption);
                        contr._SetErr();
                    }
                    else
                    {
                        contr._CleanErr();
                    }
                }
                else
                {
                    if (contr._Value.ToStr().IsNullOrEmpty())
                    {
                        list.Add(contr._Caption);
                        contr._SetErr();
                    }
                    else
                    {
                        contr._CleanErr();
                    }
                }
            }
            string errControls = string.Join(",", list);

            if (!errControls.IsNullOrEmpty())
            {
                msg.AppendLine(errControls + "必须输入!");
            }

            if (!msg.ToString().IsNullOrEmpty())
            {
                FormCommon.ShowErr(msg.ToString());
            }
            return(errControls);
        }