private void AddCommentButton_Click(object sender, RoutedEventArgs e)
 {
     var engine = new CommentEngine();
     try
     {
         List<RadioButton> buttons = new List<RadioButton>
     {
         g1,g2,g3,g4,g5,g6,g7,g8,g9,g10
     };
         var selected = buttons.FirstOrDefault(x => (bool)x.IsChecked);
         if (selected != null)
         {
             string text = "";
             var grade = Convert.ToInt32(selected.Name.Remove(0, 1));
             if (CommentText.Text != "Добавить комментарий..." && CommentText.Text != "")
             {
                 text = CommentText.Text;
             }
             //надо вытащить id работы и юзера
             int workId = 8;
             string userId = "mamaAmaCriminal";
             engine.AddComment(userId, workId, grade, text);
             this.Close();
         }
         else
         {
             MessageBox.Show("Вы не оценили работу!", "Оценка отсутствует");
         }
     }
     catch(Exception exc)
     {
         MessageBox.Show(exc.Message,"Возникла ошибка");
     }
 }
Beispiel #2
0
        public void LoadControlData(List<Mapping> mappingData)
        {
            btnNext.Visibility = System.Windows.Visibility.Hidden;
            if (mappingData != null)
            {
                if (mappingData.FirstOrDefault() != null)
                {
                    if (mappingData.FirstOrDefault().inputFilenames.FirstOrDefault() != null)
                    {
                        txtInputFile.Text = mappingData.FirstOrDefault().inputFilenames.FirstOrDefault();

                        inputfiles.inputFilenames.Add(mappingData.FirstOrDefault().inputFilenames.FirstOrDefault());
                        btnNext.Visibility = System.Windows.Visibility.Visible;
                    }
                }
            }
        }
Beispiel #3
0
        public Messages()
        {
            _messages = CMClient.Instance().LastDisplayContext.Messages;

            Message message = _messages.FirstOrDefault(item => item.Id == CMClient.Instance().LastDisplayContext.InitialMessageId);
            if(message != null)
            {
                _currentMessage = _messages.IndexOf(message);
            }

            DataContext = this;
            InitializeComponent();

            ShowMessage();
        }
        public void Bind(List<Track> musicItems)
        {
            var selectedItem = comboBox.SelectedValue as ComboBoxItem;
            items = musicItems.Select(t => new ComboBoxItem
            {
                NameWithSinger = t.GetNameWithSinger(),
                TimeString = t.GetTimeString(),
                Track = t
            }).ToList();

            comboBox.ItemsSource = items;

            if (selectedItem != null)
                comboBox.SelectedItem = items.FirstOrDefault(i => selectedItem.Track.Equals(i.Track));
        }
Beispiel #5
0
		public DependencyObject[] Generate(HtmlNode node, IHtmlTextBlock textBlock)
		{
			var list = new List<Grid>();
			foreach (var child in node.Children.Where(c => c.Value == "li"))
			{
				var grid = new Grid();
				grid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
				grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });

				var tb = new TextBlock();
				tb.Foreground = textBlock.Foreground;
				tb.FontSize = textBlock.FontSize;
				tb.FontFamily = textBlock.FontFamily;
				tb.Margin = new Thickness();
				tb.Text = "• ";

				grid.Children.Add(tb);
				Grid.SetColumn(tb, 0);

				var panel = new StackPanel();

				child.ToHtmlBlock();
				foreach (var c in child.GetLeaves(textBlock).OfType<UIElement>())
				{
					var frameworkElement = c as FrameworkElement;
					if (frameworkElement != null)
						frameworkElement.HorizontalAlignment = HorizontalAlignment.Stretch;
					panel.Children.Add(c);
				}

				grid.Children.Add(panel);
				Grid.SetColumn(panel, 1);

				list.Add(grid);
			}

			var first = list.FirstOrDefault();
			if (first != null)
				first.Margin = new Thickness(0, textBlock.ParagraphMargin, 0, 0);

			var last = list.LastOrDefault();
			if (last != null)
				last.Margin = new Thickness(0, 0, 0, textBlock.ParagraphMargin);

			return list.OfType<DependencyObject>().ToArray();
		}
        /// <summary>
        /// Populates the layout radio buttons from disk.
        /// </summary>
        private void PopulateLayoutRadioButtonsFromDisk()
        {
            List<RadioButton> radioButtonList = new List<RadioButton>();
            var rockConfig = RockConfig.Load();
            List<string> filenameList = Directory.GetFiles( ".", "*.dplx" ).ToList();
            foreach ( var fileName in filenameList )
            {
                DplxFile dplxFile = new DplxFile( fileName );
                DocumentLayout documentLayout = new DocumentLayout( dplxFile );
                RadioButton radLayout = new RadioButton();
                if ( !string.IsNullOrWhiteSpace( documentLayout.Title ) )
                {
                    radLayout.Content = documentLayout.Title.Trim();
                }
                else
                {
                    radLayout.Content = fileName;
                }

                radLayout.Tag = fileName;
                radLayout.IsChecked = rockConfig.LayoutFile == fileName;
                radioButtonList.Add( radLayout );
            }

            if ( !radioButtonList.Any( a => a.IsChecked ?? false ) )
            {
                if ( radioButtonList.FirstOrDefault() != null )
                {
                    radioButtonList.First().IsChecked = true;
                }
            }

            lstLayouts.Items.Clear();
            foreach ( var item in radioButtonList.OrderBy( a => a.Content ) )
            {
                lstLayouts.Items.Add( item );
            }
        }
 private void submit_Click(object sender, RoutedEventArgs e)
 {
     if((code.Text == string.Empty) && (name.Text == string.Empty) && (brand.Text == string.Empty) && (price.Text == string.Empty) && (vat.Text == string.Empty) && (priceVat.Text == string.Empty) )
         System.Windows.MessageBox.Show("Musí byť vyplnený aspoň jeden údaj ");
     else {
         SearchEventArgs args = new SearchEventArgs();
         List<Interface.IOrder> ords = new List<Interface.IOrder>();
         List<Interface.IOrderItem> ordItems = Settings.Config.getOrderItems();
         if (!String.IsNullOrEmpty(code.Text.ToString()))
           ordItems =  ordItems.Where(x => x.code == code.Text.ToString()).ToList<Interface.IOrderItem>();
         if (!String.IsNullOrEmpty(brand.Text))
             ordItems = ordItems.Where(x => x.brand == brand.Text.ToString()).ToList<Interface.IOrderItem>();
         if (!String.IsNullOrEmpty(price.Text))
             ordItems = ordItems.Where(x => x.price.ToString() == price.Text.ToString()).ToList<Interface.IOrderItem>();
         if (!String.IsNullOrEmpty(vat.Text))
             ordItems = ordItems.Where(x => x.vat.ToString() == vat.Text.ToString()).ToList<Interface.IOrderItem>();
         if (!String.IsNullOrEmpty(priceVat.Text))
             ordItems = ordItems.Where(x => x.priceVat.ToString() == priceVat.Text.ToString()).ToList<Interface.IOrderItem>();
         foreach (var prod in ordItems)
         {
             MessageBox.Show(code.Text.ToString());
             Interface.IOrder ord = Settings.Config.getOrders().FirstOrDefault(x=> x.id == prod.orderId);
             if(ords.FirstOrDefault(x => x.id == ord.id) == null)
                 ords.Add(ord);
         }
         args.ords = ords;
         if (ords.Count == 0)
         {
             MessageBox.Show("Tento filter nenašiel žiadne výsledky.");
         }
         else
         {
             onSearched(args);
         }
     }
    
 }
Beispiel #8
0
        private bool AttemptUseItem(List<ACDItem> items)
        {
            var item = items.FirstOrDefault();
            if (item == null) return false;

            ZetaDia.Me.Inventory.UseItem(item.DynamicId);
            return true;
        }
Beispiel #9
0
        /// <summary>
        /// 导入借款单
        /// Creator:安凯航
        /// 日期:2011年5月30日
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void btnImportBorrowData_Click(object sender, RoutedEventArgs e)
        {
            //导入时间
            DateTime createTime = DateTime.Now;
            OpenFileDialog dialog = new OpenFileDialog()
            {
                Multiselect = false,
                Filter = "Excel 2007-2010 File(*.xlsx)|*.xlsx"
            };
            bool? userClickedOK = dialog.ShowDialog();

            // Process input if the user clicked OK.
            if (userClickedOK != true)
            {
                return;
            }
            try
            {

                //待保存数据列表
                List<OrderEntity> orders = new List<OrderEntity>();
                #region 读取Excel文件

                XLSXReader reader = new XLSXReader(dialog.File);
                List<string> subItems = reader.GetListSubItems();
                var maseters = reader.GetData(subItems[0]);
                var listm = maseters.ToDataSource();
                var details = reader.GetData(subItems[1]);
                var listd = details.ToDataSource();
                List<dynamic> masterList = new List<dynamic>();
                foreach (var item in listm)
                {
                    dynamic d = item;
                    masterList.Add(d);
                }
                //排除第一行信息
                masterList.Remove(masterList.First());

                List<dynamic> detailList = new List<dynamic>();
                foreach (var item in listd)
                {
                    dynamic d = item;
                    detailList.Add(d);
                }
                //排除第一行信息
                detailList.Remove(detailList.First());

                #endregion

                #region 添加主表
                List<T_FB_BORROWAPPLYMASTER> import = new List<T_FB_BORROWAPPLYMASTER>();
                foreach (var item in masterList)
                {
                    //构造OrderEntity数据
                    OrderEntity oe = new OrderEntity(typeof(T_FB_BORROWAPPLYMASTER));
                    orders.Add(oe);

                    T_FB_BORROWAPPLYMASTER t = oe.FBEntity.Entity as T_FB_BORROWAPPLYMASTER;
                    t.BORROWAPPLYMASTERID = Guid.NewGuid().ToString();
                    t.BORROWAPPLYMASTERCODE = item.单据号;
                    if (item.借款类型 == "普通借款")
                    {
                        t.REPAYTYPE = 1;
                    }
                    else if (item.借款类型 == "备用金借款")
                    {
                        t.REPAYTYPE = 2;
                    }
                    else if (item.借款类型 == "专项借款")
                    {
                        t.REPAYTYPE = 3;
                    }
                    else
                    {
                        continue;
                    }
                    t.REMARK = item.备注;
                    import.Add(t);
                }

                #endregion

                #region 添加子表

                foreach (var item in detailList)
                {
                    OrderEntity oe = orders.FirstOrDefault(oen =>
                    {
                        T_FB_BORROWAPPLYMASTER bm = oen.FBEntity.Entity as T_FB_BORROWAPPLYMASTER;
                        if (bm.BORROWAPPLYMASTERCODE == item.单据号)
                        {
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    });
                    if (oe == null)
                    {
                        string message = "导入的借款单明细借款单号为\"" + item.单据号 + "\"的明细,没有相应的借款单对应.请检查借款Excel中是否有此借款单的数据";
                        throw new InvalidOperationException(message);
                    }
                    FBEntity fbdetail = oe.CreateFBEntity<T_FB_BORROWAPPLYDETAIL>();
                    T_FB_BORROWAPPLYDETAIL d = fbdetail.Entity as T_FB_BORROWAPPLYDETAIL;
                    d.BORROWAPPLYDETAILID = Guid.NewGuid().ToString();
                    d.REMARK = item.摘要;
                    d.BORROWMONEY = Convert.ToDecimal(item.借款金额);
                    d.UNREPAYMONEY = Convert.ToDecimal(item.未还款金额);
                    d.T_FB_SUBJECT = d.T_FB_SUBJECT ?? new T_FB_SUBJECT();
                    d.T_FB_SUBJECT.SUBJECTID = item.借款科目;
                    d.CREATEDATE = createTime;
                    d.CREATEUSERID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID;
                    d.UPDATEDATE = createTime;
                    d.UPDATEUSERID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID;
                }

                #endregion

                //服务
                OrderEntityService service = new OrderEntityService();

                #region 得到科目信息

                QueryExpression reExp = QueryExpressionHelper.Equal("OWNERID", SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID);
                QueryExpression exp = QueryExpressionHelper.Equal("OWNERPOSTID", SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].PostID);
                exp.QueryType = "T_FB_BORROWAPPLYDETAIL";
                exp.RelatedExpression = reExp;
                exp.IsUnCheckRight = true;

                #endregion

                #region 获取申请人信息

                ObservableCollection<string> numbers = new ObservableCollection<string>();
                masterList.ForEach(item => numbers.Add(item.申请人身份证号));//拿到所有身份证号
                SMT.Saas.Tools.PersonnelWS.PersonnelServiceClient client = new Saas.Tools.PersonnelWS.PersonnelServiceClient();
                client.GetEmployeesByIdnumberAsync(numbers);

                #endregion

                #region 先获取申请人信息,待申请人信息填充完毕之后进行下一步操作

                client.GetEmployeesByIdnumberCompleted += new EventHandler<Saas.Tools.PersonnelWS.GetEmployeesByIdnumberCompletedEventArgs>((oo, ee) =>
                {
                    if (ee.Error == null)
                    {
                        string message = null;
                        try
                        {
                            masterList.ForEach(m =>
                            {
                                //添加owner和creator
                                SMT.Saas.Tools.PersonnelWS.V_EMPLOYEEVIEW userview = null;
                                try
                                {
                                    userview = ee.Result.First(t => t.IDNUMBER == m.申请人身份证号);
                                }
                                catch (InvalidOperationException ex)
                                {
                                    message = ex.Message + "\n" + "在系统中找不到身份证号为\"" + m.申请人身份证号 + "\"的,员工信息.也可能是您没有相应的权限.";
                                    throw new InvalidOperationException(message);
                                }
                                T_FB_BORROWAPPLYMASTER master = null;
                                try
                                {
                                    master = import.First(t => t.BORROWAPPLYMASTERCODE == m.单据号);
                                }
                                catch (InvalidOperationException ex)
                                {
                                    message = ex.Message + "\n" + "导入的借款单明细借款单号为\"" + m.单据号 + "\"的明细,没有相应的借款单对应.请检查借款Excel中是否有此借款单的数据";
                                    throw new InvalidOperationException(message);
                                }
                                master.OWNERCOMPANYID = userview.OWNERCOMPANYID;
                                master.OWNERCOMPANYNAME = userview.OWNERCOMPANYID;
                                master.OWNERDEPARTMENTID = userview.OWNERDEPARTMENTID;
                                master.OWNERID = userview.EMPLOYEEID;
                                master.OWNERPOSTID = userview.OWNERPOSTID;
                                master.CREATECOMPANYID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].CompanyID;
                                master.CREATECOMPANYNAME = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].CompanyName;
                                master.CREATEDEPARTMENTID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].DepartmentID;
                                master.CREATEDEPARTMENTNAME = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].DepartmentName;
                                master.CREATEPOSTID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].PostID;
                                master.CREATEPOSTNAME = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].PostName;
                                master.CREATEUSERID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID;
                                master.CREATEUSERNAME = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeName;
                                master.CREATEDATE = createTime;
                                master.UPDATEUSERID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID;
                                master.UPDATEUSERNAME = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeName;
                                master.UPDATEDATE = createTime;
                            });
                            //填充完申请人信息之后开始填充科目信息
                            service.QueryFBEntities(exp);
                        }
                        catch (Exception ex)
                        {
                            SMT.SaaS.FrameworkUI.ChildWidow.ComfirmWindow.ConfirmationBoxs("导入出错", ex.Message, "确定", MessageIcon.Exclamation);
                        }
                    }
                });

                #endregion

                #region 填充完申请人信息之后开始填充科目信息

                service.QueryFBEntitiesCompleted += new EventHandler<QueryFBEntitiesCompletedEventArgs>((o, args) =>
                {
                    if (args.Error == null)
                    {
                        //构造明细科目及账务信息
                        string message = null;
                        try
                        {
                            import.ForEach(m =>
                            {
                                OrderEntity oe = orders.FirstOrDefault(oen =>
                                {
                                    T_FB_BORROWAPPLYMASTER bm = oen.FBEntity.Entity as T_FB_BORROWAPPLYMASTER;
                                    if (bm.BORROWAPPLYMASTERCODE == m.BORROWAPPLYMASTERCODE)
                                    {
                                        return true;
                                    }
                                    else
                                    {
                                        return false;
                                    }
                                });
                                var dlist = oe.GetRelationFBEntities("T_FB_BORROWAPPLYDETAIL");
                                List<T_FB_BORROWAPPLYDETAIL> detailslist = new List<T_FB_BORROWAPPLYDETAIL>();
                                dlist.ForEach(ddd =>
                                {
                                    detailslist.Add(ddd.Entity as T_FB_BORROWAPPLYDETAIL);
                                });
                                detailslist.ForEach(d =>
                                {
                                    FBEntity en = null;
                                    try
                                    {
                                        en = args.Result.First(a => ((T_FB_BORROWAPPLYDETAIL)a.Entity).T_FB_SUBJECT.SUBJECTCODE == d.T_FB_SUBJECT.SUBJECTID);
                                    }
                                    catch (InvalidOperationException ex)
                                    {
                                        message = ex.Message + "\n" + "导入的借款单明细中,在系统中找不到ID为\"" + d.T_FB_SUBJECT.SUBJECTID + "\"的科目,也可能是您没有相应的权限";
                                        throw new InvalidOperationException(message);
                                    }
                                    T_FB_BORROWAPPLYDETAIL t = en.Entity as T_FB_BORROWAPPLYDETAIL;
                                    if (t != null)
                                    {
                                        t.T_FB_SUBJECT.T_FB_BORROWAPPLYDETAIL.Clear();
                                        d.T_FB_SUBJECT = t.T_FB_SUBJECT;
                                        d.CHARGETYPE = t.CHARGETYPE;
                                        d.USABLEMONEY = t.USABLEMONEY;
                                        #region 清理科目信息中的无用数据

                                        t.T_FB_SUBJECT.T_FB_BORROWAPPLYDETAIL.Clear();
                                        t.T_FB_SUBJECT.T_FB_BUDGETACCOUNT.Clear();
                                        t.T_FB_SUBJECT.T_FB_BUDGETCHECK.Clear();
                                        t.T_FB_SUBJECT.T_FB_CHARGEAPPLYDETAIL.Clear();
                                        t.T_FB_SUBJECT.T_FB_COMPANYBUDGETAPPLYDETAIL.Clear();
                                        t.T_FB_SUBJECT.T_FB_COMPANYBUDGETMODDETAIL.Clear();
                                        t.T_FB_SUBJECT.T_FB_COMPANYBUDGETMODDETAIL.Clear();
                                        t.T_FB_SUBJECT.T_FB_COMPANYTRANSFERDETAIL.Clear();
                                        t.T_FB_SUBJECT.T_FB_DEPTBUDGETADDDETAIL.Clear();
                                        t.T_FB_SUBJECT.T_FB_DEPTBUDGETAPPLYDETAIL.Clear();
                                        t.T_FB_SUBJECT.T_FB_DEPTTRANSFERDETAIL.Clear();
                                        t.T_FB_SUBJECT.T_FB_EXTENSIONORDERDETAIL.Clear();
                                        t.T_FB_SUBJECT.T_FB_PERSONBUDGETADDDETAIL.Clear();
                                        t.T_FB_SUBJECT.T_FB_PERSONBUDGETAPPLYDETAIL.Clear();
                                        t.T_FB_SUBJECT.T_FB_PERSONMONEYASSIGNDETAIL.Clear();
                                        t.T_FB_SUBJECT.T_FB_REPAYAPPLYDETAIL.Clear();
                                        t.T_FB_SUBJECT.T_FB_SUBJECTCOMPANY.Clear();
                                        t.T_FB_SUBJECT.T_FB_SUBJECTDEPTMENT.Clear();
                                        t.T_FB_SUBJECT.T_FB_SUBJECTPOST.Clear();
                                        t.T_FB_SUBJECT.T_FB_TRAVELEXPAPPLYDETAIL.Clear();

                                        #endregion
                                    }
                                });
                            });

                            //保存
                            service.SaveList(orders);
                        }
                        catch (Exception ex)
                        {
                            SMT.SaaS.FrameworkUI.ChildWidow.ComfirmWindow.ConfirmationBoxs("导入出错", ex.Message, "确定", MessageIcon.Exclamation);
                        }
                    }
                });

                #endregion

                #region 所有信息构造完成之后保存数据

                service.SaveListCompleted += new EventHandler<ActionCompletedEventArgs<bool>>((s, evgs) =>
                {
                    if (evgs.Result)
                    {
                        SMT.SaaS.FrameworkUI.ChildWidow.ComfirmWindow.ConfirmationBox("导入成功", "导入成功", "确定");
                    }
                    else
                    {
                        SMT.SaaS.FrameworkUI.ChildWidow.ComfirmWindow.ConfirmationBox("导入失败", "导入失败", "确定");
                    }
                });

                #endregion

            }
            catch (Exception ex)
            {
                SMT.SaaS.FrameworkUI.ChildWidow.ComfirmWindow.ConfirmationBoxs("导入出错", ex.Message, "确定", MessageIcon.Exclamation);
            }
        }
Beispiel #10
0
 public void LoadControlData(List<Mapping> mappingData)
 {
     btnNext.Visibility = System.Windows.Visibility.Hidden;
     if (mappingData != null)
     {
         if (mappingData.FirstOrDefault() != null)
         {
             txtInputFile.Text = mappingData.FirstOrDefault().OutputFolderPath;
             if (mappingData.FirstOrDefault().templateFilenames.FirstOrDefault() != null)
             {
                 if (mode == folderMode.templates)
                 {
                     txtInputFile.Text = mappingData.FirstOrDefault().TemplateFolder;
                     DisplayTemplates(mappingData.FirstOrDefault());
                 }
             }
         }
     }
     if (txtInputFile.Text != string.Empty) btnNext.Visibility = System.Windows.Visibility.Visible;
 }
Beispiel #11
0
        /// <summary>
        /// 下载组件
        /// </summary>
        /// <param name="dllXElements"></param>
        private void DownLoadDll(List<string> dllXElements)
        {

            if (dllXElements.Count < 1)
            {
                if (UpdateDllCompleted != null)
                {
                    UpdateDllCompleted(this, null);
                }      
                return;
            }
            downloadDllName = dllXElements.FirstOrDefault();
            string path = @"http://" + SMT.SAAS.Main.CurrentContext.Common.HostIP + @"/ClientBin/" + downloadDllName + "?dt=" + DateTime.Now.Millisecond;
            DownloadDllClinet.OpenReadAsync(new Uri(path, UriKind.Absolute));
        }
        private void UpdateAll()
        {
            dgrid.Columns.Clear();
            if (!Episodes.Any()) return;


            var episodesSorted = Episodes.OrderBy(e => e, EpisodeComparer); //sort Episodes by season, episode
            var uploadsSorted = episodesSorted.SelectMany(e => e.Downloads.Select(d => d.Upload)).OrderBy(u=>u,UploadComparer).Distinct(); //get a unique collection of the Uploads, sorted by fav/nofav
     
            List<Header> headers = new List<Header>();
            _cells = new List<Cell>();
            int i = 0;

            //Idea: In the following Loop we create 1 Header instance for ALL Uploads (regardless of the season) which have the same String-Representation

            foreach (var upload in uploadsSorted)
            {
                String title = BuildUploadTitle(upload);
                var existingHeader =headers.FirstOrDefault(h => h.Title == title);

                if (existingHeader == null)
                {
                    Header newHeader = new Header();
                    newHeader.Title = BuildUploadTitle(upload);
                    newHeader.ToggleCommand = new SimpleCommand<object,string>( s => ToggleColumn(newHeader,s));
                    newHeader.ToggleAllCommand = new SimpleCommand<object, object>(o => ToggleFullColumn(newHeader));
                    newHeader.Hosters =
                        episodesSorted.SelectMany(e => e.Downloads)
                            .Where(d => d.Upload == upload)
                            .SelectMany(d => d.Links.Keys)
                            .Distinct().ToList();
                    headers.Add(newHeader);

                    DataGridTemplateColumn column = new DataGridTemplateColumn();
                    column.Header = newHeader;
                    column.HeaderTemplate = new DataTemplate();
                    column.HeaderTemplate.VisualTree = new FrameworkElementFactory(typeof (MultiDownloadSelectionHeader));
                    column.HeaderStyle = (Style) FindResource("CenterGridHeaderStyle");
                    column.CellTemplate = new DataTemplate();
                    column.CellTemplate.VisualTree = new FrameworkElementFactory(typeof (MultiDownloadSelectionCell));
                    column.CellTemplate.VisualTree.SetBinding(DataContextProperty, new Binding("Cells[" + i + "]"));

                    dgrid.Columns.Add(column);

                    i++;

                }
                else //there's already an upload existing (maybe in another Season) with the same string represenation
                {
                    existingHeader.Hosters = episodesSorted.SelectMany(e => e.Downloads)
                           .Where(d => d.Upload == upload)
                           .SelectMany(d => d.Links.Keys).Union(existingHeader.Hosters)
                           .Distinct().ToList();
                }
            }

            DataGridTemplateColumn fColumn = new DataGridTemplateColumn();
            fColumn.HeaderStyle = (Style)FindResource("RemovedHeaderContentStyle");
            fColumn.Width = new DataGridLength(1,DataGridLengthUnitType.Star);
            dgrid.Columns.Add(fColumn);

            List<Row> rows = new List<Row>();
            foreach (var episode in episodesSorted)
            {
                Row r = new Row();
                r.Title = "S" + episode.Season.Number + " E" + episode.Number;
                if (episode.EpisodeInformation != null && !String.IsNullOrWhiteSpace(episode.EpisodeInformation.Title))
                {
                    r.Tooltip = episode.EpisodeInformation.Title;
                }
                r.Cells = new List<Cell>();

                bool firstSelected = true;

                foreach (var header in headers)
                {
                    var c = new Cell();
                    c.Header = header;
                    c.Entries = new List<CellEntry>();
                    c.Episode = episode;

                    DownloadData dloads = episode.Downloads.FirstOrDefault(da => BuildUploadTitle(da.Upload) == header.Title);
                    bool selected = dloads!=null && dloads.Upload.Favorized;
                    if (firstSelected && selected)
                    {
                        firstSelected = false;
                    } else if (!firstSelected)
                    {
                        selected = false;
                    }


                    foreach (var hoster in header.Hosters)
                    {
                        if (dloads!=null && dloads.Links.ContainsKey(hoster))
                        {
                            c.Entries.Add(new CellEntry {Visibility = Visibility.Visible,Enabled=true, Link = dloads.Links[hoster], Checked = selected});
                        }
                        else
                        {
                            c.Entries.Add(new CellEntry {Visibility = Visibility.Hidden,Enabled=false,Link = "",Checked = false});
                        }
                    }
                    _cells.Add(c);
                    r.Cells.Add(c);
                }

                rows.Add(r);
            }
            dgrid.ItemsSource = rows;

        }
Beispiel #13
0
        /// <summary>
        /// Sprache wechseln
        /// </summary>
        /// <param name="culture">specific culture</param>
        public void ChangeLanguage(string culture)
        {
            // Alle Woerterbuecher finden
            List<ResourceDictionary> dictionaryList = new List<ResourceDictionary>();
            foreach (ResourceDictionary dictionary in System.Windows.Application.Current.Resources.MergedDictionaries)
            {
                dictionaryList.Add(dictionary);
            }

            // Woerterbuch waehlen
            string requestedCulture = string.Format("Cultures/CultResource.{0}.xaml", culture);
            ResourceDictionary resourceDictionary = dictionaryList.FirstOrDefault(d => d.Source.OriginalString == requestedCulture);
            if (resourceDictionary == null)
            {
                // Wenn das gewuenschte Woerterbuch nicht gefunden wird,
                // lade Standard-Woerterbuch
                requestedCulture = "Cultures/CultResource.xaml";
                resourceDictionary = dictionaryList.FirstOrDefault(d => d.Source.OriginalString == requestedCulture);
            }

            // Altes Woerterbuch loeschen und Neues hinzufuegen
            if (resourceDictionary != null)
            {
                System.Windows.Application.Current.Resources.MergedDictionaries.Remove(resourceDictionary);
                System.Windows.Application.Current.Resources.MergedDictionaries.Add(resourceDictionary);
            }

            // Hauptthread ueber neues Culture informieren
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(culture);
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);
        }
Beispiel #14
0
        private void AdjustMargins(IHtmlView htmlView, List<Grid> controls)
        {
            var firstControl = controls.FirstOrDefault();
            if (firstControl != null)
                firstControl.Margin = new Thickness(0, htmlView.ParagraphMargin, 0, 0);

            var lastControl = controls.LastOrDefault();
            if (lastControl != null)
                lastControl.Margin = new Thickness(0, 0, 0, htmlView.ParagraphMargin);
        }
            private static void AddToHitline(ref int runningSum, List<Tuple<int, List<Point3D>>> sets, int index, Tuple<Point3D, Point3D> hit, double entryRadius, double exitRadius, double maxAxisLength, Random rand)
            {
                Point3D[] points = GetVoronoiCtrlPoints_AroundLine_Cone(hit.Item1, hit.Item2, rand.Next(2, 5), entryRadius, exitRadius, maxAxisLength);

                runningSum += points.Length;

                var existing = sets.FirstOrDefault(o => o.Item1 == index);
                if (existing == null)
                {
                    existing = Tuple.Create(index, new List<Point3D>());
                    sets.Add(existing);
                }

                existing.Item2.AddRange(points);
            }
Beispiel #16
0
    private uiItem GetVisual(double x, double y) {
      int gs=LogramView.CellSize;

      List<uiItem> objs=new List<uiItem>();
      GeometryHitTestParameters parameters=new GeometryHitTestParameters(new RectangleGeometry(new Rect(x-gs/4, y-gs/4, gs/2, gs/2)));
      VisualTreeHelper.HitTest(this, null, new HitTestResultCallback((hr) => {
        var rez=(GeometryHitTestResult)hr;
        var vis=hr.VisualHit as uiItem;
        if(vis!=null) {
          objs.Add(vis);
        }
        return HitTestResultBehavior.Continue;
      }), parameters);
      uiItem ret=null;
      if(objs.Count>0) {
        ret=objs.FirstOrDefault(z => z is uiPin);
        if(ret==null) {
          ret=objs.FirstOrDefault(z => z is uiWire);
          if(ret==null) {
            ret=objs.FirstOrDefault(z => z is SchemaElement);
          }
        }
      }
      return ret;
    }
 private void DrawImplementationPlan(string filepath)
 {
     var converter = Manufactory.CreateImplementationPlanConverter(ConverterTypes.JSON);
     converter.ParseDocument(filepath);
     var blocks = converter.GetBlocks();
     var links = converter.GetLinks();
     var graph = new Graph(blocks, links);
     ulong startX = 30;
     ulong startY = 30;
     var countBlocksInLevel = new Dictionary<ulong, ulong>();
     for (ulong i = 0; i <= graph.GetMaxLevel(); i++)
     {
         countBlocksInLevel.Add(i, 0);
     }
     var grids = new List<EllipseIP>();
     foreach (var block in blocks)
     {
         var currentX = startX + (2*startX*countBlocksInLevel[block.Level] + 20);
         var currentY = (block.Level*startY + startY + 40*block.Level);
         var grid = CreateGrid(currentY, currentX, block.Id);
         if (block.Level > 0)
         {
             var currentLinks = links.Where(x => x.To == block.Id);
             var currentGrids = currentLinks.Select(l => grids.FirstOrDefault(x => ulong.Parse(x.Tag.ToString()) == l.From)).ToList();
             double x1 = 0;
             double y1 = 0;
             foreach (var g in currentGrids)
             {
                 x1 += Canvas.GetLeft(g);
                 y1 = Canvas.GetTop(g);
             }
             x1 /= currentGrids.Count;
             y1 += currentGrids[0].Height;
             foreach (var g in currentGrids)
             {
                 var line = CreateAPolyline(Canvas.GetLeft(g) + g.GetWidth()/2, Canvas.GetTop(g) + g.GetHeight(),
                     x1 + g.GetWidth()/2, currentY);
                 ImageCanvas.Children.Add(line);
             }
             grid = CreateGrid(currentY, x1, block.Id, block.Level);
         }
         countBlocksInLevel[block.Level]++;
         grid.SetContent(block.Content);
         grids.Add(grid);
     }
     foreach (var g in grids)
     {
         ImageCanvas.Children.Add(g);
     }
     ImageCanvas.Width = 2*startX + (2 * startX * countBlocksInLevel[0] + 20);
     ImageCanvas.Height = (graph.GetMaxLevel() * startY + 4*startY + 40 * graph.GetMaxLevel());
 }
Beispiel #18
0
 private void BindData(List<T_OA_MEETINGROOM> obj)
 {
     if (obj == null || obj.Count < 1)
     {
         DaGr.ItemsSource = null;
         return;
     }
     DaGr.ItemsSource = obj;
     currentItem = obj.FirstOrDefault();
     SelectedMeetingRoom = obj.FirstOrDefault();
 }
Beispiel #19
0
        /// <summary>
        /// 下载组件
        /// </summary>
        /// <param name="dllXElements"></param>
        private void DownLoadDll(List<string> dllXElements)
        {

            if (dllXElements.Count < 1)
            {
                if (UpdateDllCompleted != null)
                {
                    UpdateDllCompleted(this, null);
                }      
                return;
            }
            downloadDllName = dllXElements.FirstOrDefault();
            string path = @"http://" + SMT.SAAS.Main.CurrentContext.Common.HostIP + @"/ClientBin/" +FilePath+@"/"+ downloadDllName + "?dt=" + DateTime.Now.Millisecond;

            //SMT.SAAS.Main.CurrentContext.AppContext.logAndShow("正在下载更新:" + path);
            DownloadDllClinet = new WebClient();
            DownloadDllClinet.OpenReadCompleted += new OpenReadCompletedEventHandler(webcDownloadDll_OpenReadCompleted);
            DownloadDllClinet.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadDllClinet_DownloadProgressChanged);
            DownloadDllClinet.OpenReadAsync(new Uri(path, UriKind.Absolute));
        }
Beispiel #20
0
        /*
        public void DoDynamicAnimation(object sender, MouseButtonEventArgs args)
        {
            for (var i = 0; i < 36; ++i)
            {
                // var e = new Button { Width = 50, Height = 16, Content="Test" };

                //var e = new Ellipse { Width = 16, Height = 16, Fill = SystemColors.HighlightBrush };
                //var e = new Ellipse { Width = 6, Height = 6, Fill=Brushes.HotPink };

                var e = new SliderNode(this) {Left = Mouse.GetPosition(this).X, Top = Mouse.GetPosition(this).Y};

                // var e = new TextBlock { Text = "Test" };
                // var e = new Slider { Width = 100 };

                // var e = new ProgressBar { Width = 100 , Height =10, Value=i };

                // var e = =new DataGrid{Width=100, Height=100};
                // var e = new TextBox { Text = "Hallo" };
                // var e = new Label { Content = "Halllo" };
                // var e = new RadioButton { Content="dfsdf" };

                //Canvas.SetLeft(e, Mouse.GetPosition(this).X);
                //Canvas.SetTop(e, Mouse.GetPosition(this).Y);

                var tg = new TransformGroup();
                var translation = new TranslateTransform(30, 0);
                var translationName = "myTranslation" + translation.GetHashCode();
                RegisterName(translationName, translation);
                tg.Children.Add(translation);
                tg.Children.Add(new RotateTransform(i*10));
                e.RenderTransform = tg;

                NodeCollection.Add(e);
                Children.Add(e);

                var anim = new DoubleAnimation(3, 250, new Duration(new TimeSpan(0, 0, 0, 2, 0)))
                {
                    EasingFunction = new PowerEase {EasingMode = EasingMode.EaseOut}
                };

                var s = new Storyboard();
                Storyboard.SetTargetName(s, translationName);
                Storyboard.SetTargetProperty(s, new PropertyPath(TranslateTransform.YProperty));
                var storyboardName = "s" + s.GetHashCode();
                Resources.Add(storyboardName, s);

                s.Children.Add(anim);

                s.Completed +=
                    (sndr, evtArgs) =>
                    {
                        //panel.Children.Remove(e);
                        Resources.Remove(storyboardName);
                        UnregisterName(translationName);
                    };
                s.Begin();
            }
        }
        */


        public void VplControl_KeyUp(object sender, KeyEventArgs e)
        {
            switch (e.Key)
            {
                case Key.Delete:

                    foreach (var node in SelectedNodes)
                        node.Delete();

                    foreach (var conn in SelectedConnectors)
                    {
                        conn.Delete();
                    }

                    SelectedNodes.Clear();
                    SelectedConnectors.Clear();
                    break;
                case Key.C:
                {
                    if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                    {
                        tempCollection = new TrulyObservableCollection<Node>();


                        foreach (var node in SelectedNodes)
                            tempCollection.Add(node);
                    }
                }
                    break;
                case Key.V:
                {
                    if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                    {
                        if (tempCollection == null) return;
                        if (tempCollection.Count == 0) return;

                        var bBox = Node.GetBoundingBoxOfNodes(tempCollection.ToList());

                        var copyPoint = new Point(bBox.Left + bBox.Size.Width/2, bBox.Top + bBox.Size.Height/2);
                        var pastePoint = Mouse.GetPosition(this);

                        var delta = Point.Subtract(pastePoint, copyPoint);

                        UnselectAllElements();

                        var alreadyClonedConnectors = new List<Connector>();
                        var copyConnections = new List<CopyConnection>();

                        // copy nodes from clipboard to canvas
                        foreach (var node in tempCollection)
                        {
                            var newNode = node.Clone();

                            newNode.Left += delta.X;
                            newNode.Top += delta.Y;

                            newNode.Left = Convert.ToInt32(newNode.Left);
                            newNode.Top = Convert.ToInt32(newNode.Top);

                            newNode.Show();

                            copyConnections.Add(new CopyConnection {NewNode = newNode, OldNode = node});

                        }

                        foreach (var cc in copyConnections)
                        {
                            var counter = 0;

                            foreach (var conn in cc.OldNode.InputPorts)
                            {
                                foreach (var connector in conn.ConnectedConnectors)
                                {
                                    if (!alreadyClonedConnectors.Contains(connector))
                                    {
                                        Connector newConnector = null;

                                        // start and end node are contained in selection
                                        if (tempCollection.Contains(connector.StartPort.ParentNode))
                                        {
                                            var cc2 =
                                                copyConnections.FirstOrDefault(
                                                    i => Equals(i.OldNode, connector.StartPort.ParentNode));

                                            if (cc2 != null)
                                            {
                                                newConnector = new Connector(this, cc2.NewNode.OutputPorts[0],
                                                    cc.NewNode.InputPorts[counter]);
                                            }
                                        }
                                        // only end node is contained in selection
                                        else
                                        {
                                            newConnector = new Connector(this, connector.StartPort,
                                                cc.NewNode.InputPorts[counter]);
                                        }

                                        if (newConnector != null)
                                        {
                                            alreadyClonedConnectors.Add(connector);
                                            ConnectorCollection.Add(newConnector);
                                        }
                                    }
                                }
                                counter++;
                            }
                        }
                    }
                }
                    break;
                case Key.G:
                {
                    if (Keyboard.Modifiers == ModifierKeys.Control)
                        GroupNodes();
                }
                    break;

                case Key.S:
                {
                    if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                        SaveFile();
                }
                    break;
                case Key.T:
                {
                    Console.WriteLine("T");
                    foreach (var node in NodeCollection)
                    {
                        Console.WriteLine(node.ActualWidth);
                        Console.WriteLine(node.ActualHeight);
                    }
                }
                    break;
                case Key.O:
                {
                    if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                        OpenFile();
                }
                    break;
                case Key.A:
                {
                    if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                    {
                        SelectedNodes.Clear();

                        foreach (var node in NodeCollection)
                        {
                            node.IsSelected = true;
                            SelectedNodes.Add(node);
                        }
                    }
                }
                    break;
                case Key.Escape:
                {
                    UnselectAllElements();
                    mouseMode = MouseMode.Nothing;
                }
                    break;
                case Key.LeftCtrl:
                    if (!Keyboard.IsKeyDown(Key.RightCtrl)) ShowElementsAfterTransformation();
                    break;
                case Key.RightCtrl:
                    if (!Keyboard.IsKeyDown(Key.LeftCtrl)) ShowElementsAfterTransformation();
                    break;
            }
        }
            public static Point3D[] GetVoronoiCtrlPoints(ShotHit[] hits, ITriangle[] convexHull, int maxCount = 33)
            {
                const int MIN = 5;

                Random rand = StaticRandom.GetRandomForThread();

                #region examine hits

                Tuple<int, double>[] hitsByLength = hits.
                    Select((o, i) => Tuple.Create(i, (o.Hit.Item2 - o.Hit.Item1).Length)).
                    OrderByDescending(o => o.Item2).
                    ToArray();

                double totalLength = hitsByLength.Sum(o => o.Item2);

                Tuple<int, double>[] hitsByPercentLength = hitsByLength.
                    Select(o => Tuple.Create(o.Item1, o.Item2 / totalLength)).
                    ToArray();

                #endregion

                #region define control point cones

                var aabb = Math3D.GetAABB(convexHull);
                double aabbLen = (aabb.Item2 - aabb.Item1).Length;

                double entryRadius = aabbLen * .05;
                double exitRadius = aabbLen * .35;
                double maxAxisLength = aabbLen * .75;

                int count = hits.Length * 2;
                count += (totalLength / (aabbLen * .1)).ToInt_Round();

                if (count > maxCount)
                {
                    count = maxCount;
                }

                #endregion

                #region randomly pick control points

                // Keep adding rings around shots until the count is exceeded

                var sets = new List<Tuple<int, List<Point3D>>>();
                int runningSum = 0;

                // Make sure each hit line gets some points
                for (int cntr = 0; cntr < hits.Length; cntr++)
                {
                    AddToHitline(ref runningSum, sets, cntr, hits[cntr].Hit, entryRadius, exitRadius, maxAxisLength, rand);
                }

                // Now that all hit lines have points, randomly choose lines until count is exceeded
                while (runningSum < count)
                {
                    var pointsPerLength = hitsByLength.
                        Select(o =>
                        {
                            var pointsForIndex = sets.FirstOrDefault(p => p.Item1 == o.Item1);
                            int countForIndex = pointsForIndex == null ? 0 : pointsForIndex.Item2.Count;
                            return Tuple.Create(o.Item1, countForIndex / o.Item2);
                        }).
                        OrderBy(o => o.Item2).
                        ToArray();

                    double sumRatio = pointsPerLength.Sum(o => o.Item2);

                    var pointsPerLengthNormalized = pointsPerLength.
                        Select(o => Tuple.Create(o.Item1, o.Item2 / sumRatio)).
                        ToArray();

                    int index = UtilityCore.GetIndexIntoList(rand.NextPow(3), pointsPerLengthNormalized);

                    AddToHitline(ref runningSum, sets, index, hits[index].Hit, entryRadius, exitRadius, maxAxisLength, rand);
                }

                #endregion

                #region remove excessive points

                while (runningSum > count)
                {
                    Tuple<int, double>[] fractions = sets.
                        Select((o, i) => Tuple.Create(i, o.Item2.Count.ToDouble() / runningSum.ToDouble())).
                        OrderByDescending(o => o.Item2).
                        ToArray();

                    int fractionIndex = UtilityCore.GetIndexIntoList(rand.NextPow(1.5), fractions);     //nextPow will favor the front of the list, which is where the rings with the most points are
                    int setIndex = fractions[fractionIndex].Item1;

                    sets[setIndex].Item2.RemoveAt(UtilityCore.GetIndexIntoList(rand.NextDouble(), sets[setIndex].Item2.Count));

                    runningSum--;
                }

                #endregion

                #region ensure enough for voronoi algorithm

                List<Point3D> retVal = new List<Point3D>();
                retVal.AddRange(sets.SelectMany(o => o.Item2));

                // The voronoi algrorithm fails if there aren't at least 5 points (really should fix that).  So add points that are
                // way away from the hull.  This will make the voronoi algorithm happy, and won't affect the local results
                if (count < MIN)
                {
                    retVal.AddRange(
                        Enumerable.Range(0, MIN - count).
                        Select(o => Math3D.GetRandomVector_Spherical_Shell(aabbLen * 20).ToPoint())
                        );
                }

                #endregion

                return retVal.ToArray();
            }
        private void btnFolder_Click(object sender, RoutedEventArgs e)
        {
            FolderBrowserDialog dlg = new FolderBrowserDialog();
            fileList = new List<string>();
            DialogResult result = dlg.ShowDialog();
            int skip = 0;

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                string foldername = dlg.SelectedPath;
                txtConditionFile.Text = foldername;

                foreach (string f in Directory.GetFiles(foldername))
                {
                    fileList.Add(f);
                }

                if (txtHdrNumber.Text != string.Empty)
                {
                    int.TryParse(txtHdrNumber.Text, out skip);
                }

                if (fileList != null && fileList.Count > 0)
                {
                    string filename = fileList.FirstOrDefault();
                    if (filename != null)
                    {
                        List<string> InspColumns = GetColumnNamesFromInput(fileList.FirstOrDefault(), skip);
                        BindInspectionColumns(InspColumns);
                    }
                }
            }
        }
Beispiel #23
0
 private void BindData(List<T_OA_HOUSEINFO> houseobj)
 {
     if (houseobj.Count() > 0)
     {
         InfoObj = houseobj.FirstOrDefault();
     }
     
 }
        void p_Exited(object sender, EventArgs e)
        {
            // get pids of files in output folder
            var downloaded_pids = new List<DownloadedFile>();
            foreach (var file in new DirectoryInfo(OUTPUT_FOLDER).GetFiles())
            {
                if (file.Name.Contains('_'))
                {
                    downloaded_pids.Add(new DownloadedFile()
                    {
                        pid = file.Name.Substring(0, file.Name.IndexOf('_')),
                        Filename = file.FullName
                    });
                }
            }

            Dispatcher.Invoke((Action)delegate
            {
                // remove blank lines from end of textBox1.Text
                textBox1.Text = textBox1.Text.TrimEnd(Environment.NewLine.ToCharArray());

                if (txtCmdLine.Text.Contains("--type="))
                {
                    // parse search results
                    matches.Clear();
                    foreach (var line in textBox1.Text.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
                    {
                        if (line.Length > 0 && char.IsDigit(line[0]) && line.Contains(':'))
                        {
                            string[] parts = line.Split('|');
                            var downloaded = downloaded_pids.FirstOrDefault(z => z.pid == parts[4]);
                            // e.g.
                            // -[0]-|-- [1] --|--------------- [2] ----------------|--------------------- [3] ------------------ |-- [4] --
                            // 13348|Zane Lowe|Zane Lowe. Kanye West. The Interview|http://www.bbc.co.uk/programmes/b03cnqpl.html|b03cnqpl
                            matches.Add(new Match()
                            {
                                Index = parts[0],
                                Name = parts[1] + " - " + parts[2],
                                Web = parts[3],
                                pid = parts[4],
                                Downloaded = downloaded != null,
                                DownloadedFilename = downloaded == null ? null : downloaded.Filename,
                                EnableGet = true
                            });
                        }
                    }
                }
                else if (txtCmdLine.Text.Contains("--get"))
                {
                    // refresh the list after downloading
                    btnSearch_Click(null, null);
                }

                EnableDisableControls(true);
            });
        }
Beispiel #25
0
        private void submitCFButton_Click(object sender, RoutedEventArgs e)
        {
            TextBox firstNameTB = (TextBox) this.FindName("nameCFTextBox");
            TextBox lastNameTB = (TextBox) this.FindName("lastNameCFTextBox");
            TextBox descriptionTB = (TextBox) this.FindName("descriptionCFTextBox");

            string resultString = resultTextBox.Text;
            
            Grid parent = (Grid)this.FindName("summaryCFGrid");
            Grid oddGrid = (Grid)parent.Children.OfType<Grid>().ElementAt(0);
            Grid evenGrid = (Grid)parent.Children.OfType<Grid>().ElementAt(1);
            RadioButton even = (RadioButton)evenGrid.Children.OfType<RadioButton>().FirstOrDefault(r => r.IsChecked.Value);
            RadioButton odd = (RadioButton)oddGrid.Children.OfType<RadioButton>().FirstOrDefault(r => r.IsChecked.Value);
            int evenSummand = Int32.Parse(even.Content.ToString());
            int oddSummand = Int32.Parse(odd.Content.ToString());
            int sum = evenSummand + oddSummand;

            string goodNameString = firstNameTB.Text;
            string goodLastNameString = lastNameTB.Text;
            string goodDescriptionString = descriptionTB.Text;
            string goodSumString = "Summary: " + sum;

            List<string> listFromBox = new List<string>(resultString.Split(new string[] {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries));


            string badSumString = listFromBox.FirstOrDefault(r => r.IndexOf("Summary") == 0);
            if (badSumString != null)
            {
                listFromBox[listFromBox.IndexOf(badSumString)] = goodSumString;
            }
            else
            {
                listFromBox.Add(goodSumString);
            }

            if (goodNameString != "")
            {
                string badNameString = listFromBox.FirstOrDefault(r => r.IndexOf("Name") == 0);
                if (badNameString != null)
                {
                    listFromBox[listFromBox.IndexOf(badNameString)] = "Name: " + goodNameString;
                }
                else
                {
                    listFromBox.Add("Name: "+ goodNameString);
                }
            }

            if (goodLastNameString != "")
            {
                string badLastNameString = listFromBox.FirstOrDefault(r => r.IndexOf("Last Name") == 0);
                if (badLastNameString != null)
                {
                    listFromBox[listFromBox.IndexOf(badLastNameString)] = "Last Name: " + goodLastNameString;
                }
                else
                {
                    listFromBox.Add("Last Name: " + goodLastNameString);
                }
            }

            if (goodDescriptionString!= "")
            {
                string badDescriptionString = listFromBox.FirstOrDefault(r => r.IndexOf("Description") == 0);
                if (badDescriptionString!= null)
                {
                    listFromBox[listFromBox.IndexOf(badDescriptionString)] = "Description: " + goodDescriptionString;
                }
                else
                {
                    listFromBox.Add("Description: " + goodDescriptionString);
                }
            }

            resultTextBox.Text = String.Join(Environment.NewLine, listFromBox);
            
        }
Beispiel #26
0
        private List<ServerViewModel> DiscoverServers(bool search)
        {
            var list = new List<ServerViewModel>();

            var profiles = Config.GetGlobal<List<ConnectionProfile>>("connection.profiles", new List<ConnectionProfile>());
            foreach (ConnectionProfile profile in profiles) {
                var existing = list.FirstOrDefault((sv) => {
                    return sv.Name.Equals(profile.Server, StringComparison.CurrentCultureIgnoreCase);
                });
                if (existing == null) {
                    list.Add(CreateServerViewModel(profile.Server));
                }
            }

            LegacySettings.TraverseSubKeys("Client", "UserProfiles", (key) => {
                ConnectionProfile profile = new ConnectionProfile();
                var server = key.GetValue("DatabaseServer") as string;

                var existing = list.FirstOrDefault((sv) => {
                    return sv.Name.Equals(server, StringComparison.CurrentCultureIgnoreCase);
                });

                if (server != null && existing == null) {
                    list.Add(CreateServerViewModel(server));
                }
            });

            if (search) {
                DataTable dt = SmoApplication.EnumAvailableSqlServers(false);
                if (dt.Rows.Count > 0) {
                    foreach (DataRow dr in dt.Rows) {
                        var server = dr["Name"] as string;
                        var existing = list.FirstOrDefault((sv) => {
                            return sv.Name.Equals(server, StringComparison.CurrentCultureIgnoreCase);
                        });

                        if (!string.IsNullOrEmpty(server) && existing == null) {
                            list.Add(CreateServerViewModel(server));
                        }
                    }
                }
            }

            return list;
        }
Beispiel #27
0
        void GetModelNameInfosComboxCompleted(object sender, GetModelNameInfosComboxCompletedEventArgs e)//获取模块代码
        {
            if (e.Result != null)
            {
                ModelDefineList = e.Result.ToList();
                MODELDEFINE = ModelDefineList.FirstOrDefault();

                InitModelCode(sender, null);
            }
        }
        private static List<PropertyInfo> ParseProperties(string sql, string dbName)
        {
            var properties = new List<PropertyInfo>();

            using (var dba = DbAccesserFactory.Create(dbName))
            {
                var table = dba.QueryDataTable(sql);
                var columns = table.Columns;
                foreach (DataColumn column in columns)
                {
                    if (!column.ColumnName.EqualsIgnoreCase(Entity.IdProperty.Name))
                    {
                        var property = new PropertyInfo
                        {
                            Name = column.ColumnName,
                            Type = column.DataType
                        };
                        properties.Add(property);
                    }
                }
            }

            var matches = Regex.Matches(sql, @"(?<name>[\w_]+)\s*,?\s*--(?<comment>.+)$", RegexOptions.Multiline);
            foreach (Match match in matches)
            {
                var name = match.Groups["name"].Value;
                var comment = match.Groups["comment"].Value;
                var property = properties.FirstOrDefault(p => p.Name.EqualsIgnoreCase(name));
                if (property != null)
                {
                    property.Comment = comment.Trim();
                }
            }

            return properties;
        }
Beispiel #29
0
        private void GetOrgInfoByChecked(ref string sType, ref string sValue, ref string strMsg)
        {
            List<ExtOrgObj> selObjs = new List<ExtOrgObj>();
            foreach (TreeViewItem item in orgTree.treeOrganization.Items)
            {

                TreeViewItem myItem =
                    (TreeViewItem)(orgTree.treeOrganization.ItemContainerGenerator.ContainerFromItem(item));
                myItem.Style = Application.Current.Resources["TreeViewItemStyle"] as Style;

                CheckBox cbx = Helper.UIHelper.FindChildControl<CheckBox>(myItem);
                if (cbx != null && cbx.IsChecked.GetValueOrDefault(false))
                {
                    OrgTreeItemTypes type = (OrgTreeItemTypes)(item.Tag);

                    selObjs.Add(item.DataContext as ExtOrgObj);
                }

                GetChildSelectedOrgObj(item, ref selObjs);
            }

            if (selObjs.Count() == 0)
            {
                strMsg = "请选择员工所在的公司再进行查询";
                return;
            }

            if (selObjs.Count() > 1)
            {
                strMsg = "查询员工,只能选择单个机构做为范围查询";
                return;
            }

            ExtOrgObj selobj = selObjs.FirstOrDefault();
            sType = selobj.ObjectType.ToString();
            sValue = selobj.ObjectID;
        }
 private void submit_Click(object sender, RoutedEventArgs e)
 {
     if ((customId.Text == string.Empty) && (titlePrefix.Text == string.Empty) && 
         (firstName.Text == string.Empty) && (lastName.Text == string.Empty) && 
         (titleSuffix.Text == string.Empty) && (street.Text == string.Empty) && 
         (city.Text == string.Empty) && (zip.Text == string.Empty) && (email.Text == string.Empty)
         && (mobile.Text == string.Empty) && (name.Text == string.Empty) && (ico.Text == string.Empty)
         && (dic.Text == string.Empty) && (icDph.Text == string.Empty) && this.oznacene && 
         (country.SelectedValue == null))
         System.Windows.MessageBox.Show("Musí byť vyplnený aspoň jeden údaj ");
     else
     {
         SearchEventArgs args = new SearchEventArgs();
         List<Interface.IOrder> ords = new List<Interface.IOrder>();
         List<Interface.IOrder> orders = Settings.Config.getOrders();
         if (!String.IsNullOrEmpty(customId.Text.ToString()))
             orders = orders.Where(x => x.company.custom_id == customId.Text.ToString()).ToList<Interface.IOrder>();
         if (!String.IsNullOrEmpty(titlePrefix.Text))
             orders = orders.Where(x => x.company.person.titlePrefix == titlePrefix.Text.ToString()).ToList<Interface.IOrder>();
         if (!String.IsNullOrEmpty(firstName.Text))
             orders = orders.Where(x => x.company.person.firstName == firstName.Text.ToString()).ToList<Interface.IOrder>();
         if (!String.IsNullOrEmpty(lastName.Text))
             orders = orders.Where(x => x.company.person.lastName == lastName.Text.ToString()).ToList<Interface.IOrder>();
         if (!String.IsNullOrEmpty(titleSuffix.Text))
             orders = orders.Where(x => x.company.person.titleSuffix == titleSuffix.Text.ToString()).ToList<Interface.IOrder>();
         if (!String.IsNullOrEmpty(street.Text))
             orders = orders.Where(x => x.company.address.street == street.Text.ToString()).ToList<Interface.IOrder>();
         if (!String.IsNullOrEmpty(city.Text))
             orders = orders.Where(x => x.company.address.city == city.Text.ToString()).ToList<Interface.IOrder>();
         if (!String.IsNullOrEmpty(zip.Text))
             orders = orders.Where(x => x.company.address.zip == zip.Text.ToString()).ToList<Interface.IOrder>();
         if (!String.IsNullOrEmpty(email.Text))
             orders = orders.Where(x => x.company.contact.email == email.Text.ToString()).ToList<Interface.IOrder>();
         if (!String.IsNullOrEmpty(mobile.Text))
             orders = orders.Where(x => x.company.contact.mobile == mobile.Text.ToString()).ToList<Interface.IOrder>();
         if (!String.IsNullOrEmpty(name.Text))
             orders = orders.Where(x => x.company.name == name.Text.ToString()).ToList<Interface.IOrder>();
         if (!String.IsNullOrEmpty(ico.Text))
             orders = orders.Where(x => x.company.ico == ico.Text.ToString()).ToList<Interface.IOrder>();
         if (!String.IsNullOrEmpty(dic.Text))
             orders = orders.Where(x => x.company.dic == dic.Text.ToString()).ToList<Interface.IOrder>();
         if (!String.IsNullOrEmpty(icDph.Text))
             orders = orders.Where(x => x.company.icDph == icDph.Text.ToString()).ToList<Interface.IOrder>();
         if (country.SelectedValue != null)
             orders = orders.Where(x => x.company.address.country == country.SelectedValue.ToString()).ToList<Interface.IOrder>();
         if (!oznacene)
             orders = orders.Where(x => x.company.corporatePerson.ToString() == this.c).ToList<Interface.IOrder>();
         foreach (var _ord in orders)
         {
             
             Interface.IOrder ord = Settings.Config.getOrders().FirstOrDefault(x => x.id == _ord.id);
             if (ords.FirstOrDefault(x => x.id == ord.id) == null)
                 ords.Add(ord);
         }
         args.ords = ords;
         if (ords.Count == 0)
         {
             MessageBox.Show("Tento filter nenašiel žiadne výsledky.");
         }
         else
         {
             onSearched(args);
         }
     }  
 }