コード例 #1
0
        public MenuScreen(AABB view_bounds)
        {
            ViewBounds = view_bounds;

            this.guiItemsGrid = new EntityGrid <BaseGuiItem>(ViewBounds);
            // System.Diagnostics.Debug.WriteLine(ViewBounds.dims.X);
        }
コード例 #2
0
        public void Invoke(object Sender, object Element)
        {
            if (Element is CommandParameters)
            {
                CommandParameters cp            = (CommandParameters)Element;
                string[]          elemsToDelete = EntityGrid.GetCheckedCollection(((CommandManager)Sender).Page, cp.CommandArguments["GridId"]);

                int error = 0;
                using (TransactionScope tran = DataContext.Current.BeginTransaction())
                {
                    foreach (string elem in elemsToDelete)
                    {
                        int id = Convert.ToInt32(elem.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries)[0], CultureInfo.InvariantCulture);
                        if (id > 0)
                        {
                            try
                            {
                                ListManager.DeleteList(id);
                            }
                            catch
                            {
                                error++;
                            }
                        }
                    }
                    tran.Commit();
                }
                if (error > 0)
                {
                    ClientScript.RegisterStartupScript(((Control)Sender).Page, ((Control)Sender).Page.GetType(), Guid.NewGuid().ToString("N"),
                                                       String.Format("alert('{0}');", CHelper.GetResFileString("{IbnFramework.ListInfo:RefItemException}")), true);
                }
            }
        }
コード例 #3
0
ファイル: AppForm.xaml.cs プロジェクト: jjg0519/OA
        public virtual void initEntityForm(object obj, bool AddState)
        {
            if (AddState == true)
            {
                btnAdd.Visibility    = Visibility.Visible;
                btnUpdate.Visibility = Visibility.Collapsed;
            }
            else
            {
                btnAdd.Visibility    = Visibility.Collapsed;
                btnUpdate.Visibility = Visibility.Visible;
            }

            Type type = obj.GetType();

            //设置Title
            txtEntityTitle.Text = "详情";
            this.Title          = type.Name;

            EntityGrid.SetValue(Grid.ShowGridLinesProperty, true); //显示网格
            //设置实体属性
            PropertyInfo[] infos = type.GetProperties();
            for (int i = 0; i < infos.Count(); i++)
            {
                RowDefinition row = new RowDefinition();
                EntityGrid.RowDefinitions.Add(row);
                PropertyInfo pinfo = infos[i];
                if (pinfo.Name == "EntityKey")
                {
                    continue;
                }
                Label lable = new Label();
                lable.Content = pinfo.Name + ":";
                lable.Margin  = new Thickness(0, 10, 0, 0);
                EntityGrid.Children.Add(lable);
                lable.SetValue(Grid.ColumnProperty, 0);
                lable.SetValue(Grid.RowProperty, i);

                //EntityGrid.
                //LeftLabelArea.Children.Add(lable);
                //pinfo.Name;
                //pinfo.GetValue(obj, null);
                TextBox txtBox = new TextBox();
                txtBox.Name   = pinfo.Name.Trim();
                txtBox.Margin = new Thickness(0, 10, 0, 0);
                string strPinfoValue = string.Empty;
                if (pinfo.GetValue(obj, null) != null)
                {
                    strPinfoValue = pinfo.GetValue(obj, null).ToString();
                }
                txtBox.Text = strPinfoValue;
                //RightDataArea.Children.Add(txtBox);
                EntityGrid.Children.Add(txtBox);
                txtBox.SetValue(Grid.ColumnProperty, 1);
                txtBox.SetValue(Grid.RowProperty, i);
            }
        }
コード例 #4
0
        private void Grid_DataExport(object sender, DataExportEventArgs e)
        {
            if (EntityGrid.DataContext != null)
            {
                List <object> data = (List <object>) typeof(Enumerable).GetMethod("ToList").MakeGenericMethod(typeof(object)).Invoke(null, new object[] { EntityGrid.DataContext });

                EntityGrid.AppendDataForExport(data, _propertiesUsedByImport);
                EntityGrid.DoExport();
            }
        }
コード例 #5
0
        protected void lbAdd_Click(object sender, EventArgs e)
        {
            DataTable dt = ((DataTable)ViewState["Resources"]).Copy();

            if (!String.IsNullOrEmpty(txtEMail.Text.Trim()))
            {
                DataRow[] rows = dt.Select(String.Format("Id='{0}'", String.Format("{0}::0", txtEMail.Text.Trim())));
                if (rows.Length == 0)
                {
                    DataRow dr = dt.NewRow();
                    dr["Id"]   = String.Format("{0}::0", txtEMail.Text.Trim());
                    dr["Name"] = txtEMail.Text.Trim();
                    dt.Rows.Add(dr);
                }
                txtEMail.Text = String.Empty;
            }
            else
            {
                string[] mas = EntityGrid.GetCheckedCollection(this.Page, grdMain.ID);
                if (mas.Length == 0)
                {
                    mas = hdnValue.Value.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                }
                foreach (string s in mas)
                {
                    DataRow[] rows = dt.Select(String.Format("Id='{0}'", s));
                    if (rows.Length > 0)
                    {
                        continue;
                    }
                    DataRow dr = dt.NewRow();
                    if (ddFilter.SelectedValue == ContactEntity.GetAssignedMetaClassName())
                    {
                        dr["Id"]   = s;
                        dr["Name"] = CHelper.GetEntityTitle(ContactEntity.GetAssignedMetaClassName(), PrimaryKeyId.Parse(s.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries)[0]));
                    }
                    else if (ddFilter.SelectedValue == OrganizationEntity.GetAssignedMetaClassName())
                    {
                        dr["Id"]   = s;
                        dr["Name"] = CHelper.GetEntityTitle(OrganizationEntity.GetAssignedMetaClassName(), PrimaryKeyId.Parse(s.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries)[0]));
                    }
                    else if (ddFilter.SelectedValue == Principal.GetAssignedMetaClass().Name)
                    {
                        dr["Id"]   = s;
                        dr["Name"] = CHelper.GetEntityTitle(Principal.GetAssignedMetaClass().Name, PrimaryKeyId.Parse(s.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries)[0]));
                    }
                    dt.Rows.Add(dr);
                }
            }
            ViewState["Resources"] = dt;

            grdMainSelectedPanel.Update();
            CommonEventPart();
            hdnValue.Value = String.Empty;
        }
コード例 #6
0
        public void Invoke(object Sender, object Element)
        {
            if (Element is CommandParameters)
            {
                CommandParameters cp = (CommandParameters)Element;
                string[]          selectedElements = EntityGrid.GetCheckedCollection(((CommandManager)Sender).Page, cp.CommandArguments["GridId"]);

                if (selectedElements != null && selectedElements.Length > 0)
                {
                    int          errorCount      = 0;
                    string       bridgeClassName = CHelper.GetFromContext("ReferenceNN_BridgeClassName").ToString();
                    string       field1Name      = CHelper.GetFromContext("ReferenceNN_Field1Name").ToString();
                    string       field2Name      = CHelper.GetFromContext("ReferenceNN_Field2Name").ToString();
                    PrimaryKeyId field1Value     = PrimaryKeyId.Parse(CHelper.GetFromContext("ReferenceNN_Field1Value").ToString());
                    using (TransactionScope tran = DataContext.Current.BeginTransaction())
                    {
                        foreach (string elem in selectedElements)
                        {
                            string[]     parts     = elem.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries);
                            string       id        = parts[0];
                            PrimaryKeyId key       = PrimaryKeyId.Parse(id);
                            string       className = parts[1];

                            FilterElementCollection fec = new FilterElementCollection();
                            fec.Add(FilterElement.EqualElement(field1Name, field1Value));
                            fec.Add(FilterElement.EqualElement(field2Name, key));
                            EntityObject[] list = BusinessManager.List(bridgeClassName, fec.ToArray());
                            if (list.Length > 0)
                            {
                                foreach (EntityObject eo in list)
                                {
                                    try
                                    {
                                        BusinessManager.Delete(bridgeClassName, eo.PrimaryKeyId.Value);
                                    }
                                    catch (Exception ex)
                                    {
                                        CHelper.GenerateErrorReport(ex);
                                        errorCount++;
                                    }
                                }
                            }
                        }

                        tran.Commit();
                    }

                    if (errorCount > 0)
                    {
                        ((CommandManager)Sender).InfoMessage = CHelper.GetResFileString("{IbnFramework.Common:NotAllSelectedItemsWereProcessed}");
                    }
                }
            }
            CHelper.RequireDataBind();
        }
コード例 #7
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        EntityGrid grid = (EntityGrid)target;

        if (GUILayout.Button("Generate Grid"))
        {
            grid.UpdateGrid();
        }
    }
コード例 #8
0
        public BaseGuiItem(GameState parent, AABB bounds) : base()
        {
            this.parent       = parent;
            this.Bounds       = bounds;
            this.OnClickFunc  = null;
            this.Active       = true;
            this.renderStates = new RenderStates(BlendMode.Alpha);

            this.GridPosition = EntityGrid <BaseGuiItem> .calcGridPos(this.Bounds.center);

            this.Reset();
        }
コード例 #9
0
        public void Invoke(object Sender, object Element)
        {
            if (Element is CommandParameters)
            {
                CommandParameters cp = (CommandParameters)Element;
                string[]          selectedElements = EntityGrid.GetCheckedCollection(((CommandManager)Sender).Page, cp.CommandArguments["GridId"]);

                if (selectedElements != null && selectedElements.Length > 0)
                {
                    int errorCount = 0;
                    using (TransactionScope tran = DataContext.Current.BeginTransaction())
                    {
                        foreach (string elem in selectedElements)
                        {
                            string[]     parts     = elem.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries);
                            string       id        = parts[0];
                            PrimaryKeyId key       = PrimaryKeyId.Parse(id);
                            string       className = parts[1];

                            if ((int)key == -1)                                 // we mustn't delete default profile
                            {
                                errorCount++;
                                continue;
                            }

                            try
                            {
                                BusinessManager.Delete(className, key);
                            }
                            catch (Exception ex)
                            {
                                CHelper.GenerateErrorReport(ex);
                                errorCount++;
                            }
                        }

                        tran.Commit();
                    }

                    if (errorCount > 0)
                    {
                        ((CommandManager)Sender).InfoMessage = CHelper.GetResFileString("{IbnFramework.Common:NotAllSelectedItemsWereProcessed}");
                    }
                }
            }
            CHelper.RequireDataBind();
        }
コード例 #10
0
        public void Invoke(object Sender, object Element)
        {
            if (Element is CommandParameters)
            {
                CommandParameters cp = (CommandParameters)Element;
                string[]          selectedElements = EntityGrid.GetCheckedCollection(((CommandManager)Sender).Page, cp.CommandArguments["GridId"]);

                if (selectedElements != null)
                {
                    string className  = ContactEntity.GetAssignedMetaClassName();
                    int    errorCount = 0;

                    foreach (string elem in selectedElements)
                    {
                        string       id  = elem.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries)[0];
                        PrimaryKeyId key = PrimaryKeyId.Parse(id);

                        using (TransactionScope tran = DataContext.Current.BeginTransaction())
                        {
                            bool wasError = false;
                            try
                            {
                                BusinessManager.Delete(className, key);
                            }
                            catch (Exception ex)
                            {
                                wasError = true;
                                CHelper.GenerateErrorReport(ex);
                                errorCount++;
                            }

                            if (!wasError)
                            {
                                tran.Commit();
                            }
                        }
                    }

                    if (errorCount > 0)
                    {
                        ((CommandManager)Sender).InfoMessage = CHelper.GetResFileString("{IbnFramework.Common:NotAllSelectedItemsWereProcessed}");
                    }

                    CHelper.RequireBindGrid();
                }
            }
        }
コード例 #11
0
 public void Invoke(object Sender, object Element)
 {
     if (Element is CommandParameters)
     {
         CommandParameters cp        = (CommandParameters)Element;
         string            type      = cp.CommandArguments["Type"];
         string            variant   = cp.CommandArguments["Variant"];
         string            className = cp.CommandArguments["ClassName"];
         string            ids       = String.Empty;
         if (String.Compare(variant, "3", true) == 0)                    //SelectedItems
         {
             string[] selectedElements = EntityGrid.GetCheckedCollection(((CommandManager)Sender).Page, cp.CommandArguments["GridId"]);
             ids = String.Join(";", selectedElements);
         }
         ((System.Web.UI.Control)(Sender)).Page.Response.Redirect(((System.Web.UI.Control)(Sender)).Page.ResolveUrl("~/Apps/MetaUIEntity/Pages/EntityList.aspx") + "?ClassName=" + className + "&Export=" + type + "&variant=" + variant + "&ids=" + ids);
     }
 }
コード例 #12
0
        public void Invoke(object Sender, object Element)
        {
            if (Element is CommandParameters)
            {
                CommandParameters cp = (CommandParameters)Element;
                string[]          selectedElements = EntityGrid.GetCheckedCollection(((CommandManager)Sender).Page, cp.CommandArguments["GridId"]);

                if (selectedElements != null && selectedElements.Length > 0)
                {
                    int errorCount = 0;
                    using (TransactionScope tran = DataContext.Current.BeginTransaction())
                    {
                        foreach (string elem in selectedElements)
                        {
                            string[]     parts     = elem.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries);
                            string       id        = parts[0];
                            PrimaryKeyId key       = PrimaryKeyId.Parse(id);
                            string       className = parts[1];

                            try
                            {
                                EntityObject obj = BusinessManager.Load(className, key);

                                string fieldName = (string)CHelper.GetFromContext(_httpContextFilterFieldNameKey);
                                obj.Properties[fieldName].Value = null;
                                BusinessManager.Update(obj);
                            }
                            catch (Exception ex)
                            {
                                CHelper.GenerateErrorReport(ex);
                                errorCount++;
                            }
                        }

                        tran.Commit();
                    }

                    if (errorCount > 0)
                    {
                        ((CommandManager)Sender).InfoMessage = CHelper.GetResFileString("{IbnFramework.Common:NotAllSelectedItemsWereProcessed}");
                    }
                }
            }
            CHelper.RequireDataBind();
        }
コード例 #13
0
        public override void HandleMouseMoved(MouseMoveEventArgs e)
        {
            Vector2f mousePos                         = new Vector2f(e.X, e.Y);
            EntityGrid <BaseGuiItem> grid             = null;
            List <BaseGuiItem>       possibleHandlers = null;

            try
            {
                grid             = currentMenu.ItemGrid;
                possibleHandlers = grid.getEntitiesInRadius(mousePos, 10.0f);

                foreach (var guiItem in possibleHandlers)
                {
                    if (cCollision.IsPointInsideBox(mousePos, guiItem.Bounds))
                    {
                        guiItem.OnMouseMove(e);
                        break;
                    }
                    else
                    {
                        guiItem.OnMouseLeave(e);
                    }
                }
            }
            catch (Exception ex)
            {
            #if DEBUG
                System.Diagnostics.Debug.WriteLine(this.menus != null ? "menus OK" : "menus NULL");
                System.Diagnostics.Debug.WriteLine(currentMenu != null ? "currentMenu OK" : "currentMenu NULL");
                System.Diagnostics.Debug.WriteLine(grid != null ? "grid OK" : "grid NULL");
                System.Diagnostics.Debug.WriteLine(ex.Message);
            #endif

                while (true)
                {
                }


                // throw ex;
            }

            // grid?.getEntitiesNearby(mousePos);
        }
コード例 #14
0
        public void Invoke(object Sender, object Element)
        {
            CommandParameters cp = (CommandParameters)Element;

            string[] selectedElements = EntityGrid.GetCheckedCollection(((CommandManager)Sender).Page, cp.CommandArguments["GridId"]);

            if (selectedElements != null && selectedElements.Length > 0)
            {
                int errorCount = 0;
                using (TransactionScope tran = DataContext.Current.BeginTransaction())
                {
                    foreach (string elem in selectedElements)
                    {
                        string[]     parts = elem.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries);
                        string       id    = parts[0];
                        PrimaryKeyId key   = PrimaryKeyId.Parse(id);

                        try
                        {
                            DocumentContentVersionEntity dcve = (DocumentContentVersionEntity)BusinessManager.Load(DocumentContentVersionEntity.GetAssignedMetaClassName(), key);
                            dcve.State = (int)DocumentContentVersionState.Draft;
                            UpdateStateRequest usr = new UpdateStateRequest(dcve);
                            BusinessManager.Execute(usr);
                        }
                        catch (Exception ex)
                        {
                            CHelper.GenerateErrorReport(ex);
                            errorCount++;
                        }
                    }

                    tran.Commit();
                }

                if (errorCount > 0)
                {
                    ((CommandManager)Sender).InfoMessage = CHelper.GetResFileString("{IbnFramework.Common:NotAllSelectedItemsWereProcessed}");
                }

                CHelper.RequireBindGrid();
            }
        }
コード例 #15
0
 public EntityGrid EntityGridCreate(EntityPositionPlacerProperties properties)
 {
     float startX = properties.BoundaryCenterCoordinate.x - (properties.BoundaryScale.x / 2) + properties.EntityDistance.x / 2;
     float startY = properties.BoundaryCenterCoordinate.y + (properties.BoundaryScale.y / 2) - properties.EntityDistance.y / 2;
     var startPosition = new Vector2(startX, startY);
     //Рассчитываем количество возможных объектов по x
     var numberForX =(int)(properties.BoundaryScale.x / (properties.EntityDistance.x + properties.EntityScale.x));
     var numberForY =(int)(properties.BoundaryScale.y / (properties.EntityDistance.y + properties.EntityScale.y));
     var grid = new EntityGrid(numberForX,numberForY);
     for (int i = 0; i < numberForY; i++)
     {
         for (int j = 0; j < numberForX; j++)
         {
             var entityPosition = new Vector3(
                 startX + (properties.EntityDistance.x + properties.EntityScale.x)*j,
                 startY - (properties.EntityDistance.y + properties.EntityScale.y)*i, 0);
             grid.SetGridItem(j,i,new GridItem(position:entityPosition));
         }
     }
     return grid;
 }
コード例 #16
0
        public void Invoke(object Sender, object Element)
        {
            if (Element is CommandParameters)
            {
                CommandParameters cp = (CommandParameters)Element;
                string[]          selectedElements = EntityGrid.GetCheckedCollection(((CommandManager)Sender).Page, cp.CommandArguments["GridId"]);
                string            deleteType       = cp.CommandArguments["DeleteType"]; // 0: org only; 1: org & contacts

                if (selectedElements != null)
                {
                    string className  = OrganizationEntity.GetAssignedMetaClassName();
                    int    errorCount = 0;

                    foreach (string elem in selectedElements)
                    {
                        string       id  = elem.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries)[0];
                        PrimaryKeyId key = PrimaryKeyId.Parse(id);

                        try
                        {
                            DeleteRequest request = new DeleteRequest(className, key);
                            request.Parameters.Add(OrganizationRequestParameters.Delete_RelatedContactAction, (deleteType == "0") ? RelatedContactAction.Detach : RelatedContactAction.Delete);
                            BusinessManager.Execute(request);
                        }
                        catch (Exception ex)
                        {
                            CHelper.GenerateErrorReport(ex);
                            errorCount++;
                        }
                    }


                    if (errorCount > 0)
                    {
                        ((CommandManager)Sender).InfoMessage = CHelper.GetResFileString("{IbnFramework.Common:NotAllSelectedItemsWereProcessed}");
                    }
                }
            }
        }
コード例 #17
0
        /// <summary>
        /// 로딩된 엔티티를 UI Control에 바인딩합니다.
        /// </summary>
        protected virtual void BindEntity()
        {
            if (IsDebugEnabled)
            {
                log.Debug(@"EntityGrid에 로딩된 Entity[{0}] 컬렉션을 Binding합니다...", ConcreteType.Name);
            }

            EntityGrid.DataSource = Entities;
            EntityGrid.DataBind();

            if (GridPager != null)
            {
                GridPager.PageCount = Entities.TotalPageCount;
                GridPager.Visible   = Entities.TotalPageCount > 1;
            }

            if (GridLegend != null)
            {
                GridLegend.Count = Entities.TotalItemCount;
            }

            ResetPageIndex(Math.Max(0, Math.Min(Entities.PageIndex, Entities.TotalPageCount - 1)));
        }
コード例 #18
0
        public void PresentData(object data, IDictionary <string, List <string> > propertiesUsedByImport = null)
        {
            _propertiesUsedByImport = propertiesUsedByImport;

            bool isList = false;

            if (data == null)
            {
                return;
            }

            Type dataType;

            if (data.GetType().Name == typeof(List <object>).Name)
            {
                if (((System.Collections.ICollection)data).Count == 0)
                {
                    return;
                }

                dataType = data.GetType().GetGenericArguments()[0];

                isList = true;
            }
            else
            {
                dataType = data.GetType();
            }

            foreach (PropertyInfo pi in dataType.GetProperties())
            {
                if (pi.GetGetMethod().GetCustomAttributes(typeof(CompilerGeneratedAttribute), true).Count() == 0)
                {
                    string headerText;
                    string bindingName;

                    headerText  = pi.Name;
                    bindingName = pi.Name;

                    if (pi.GetCustomAttributes(typeof(DisplayNameAttribute), false).Count() > 0)
                    {
                        headerText += "\n\r[" + ((DisplayNameAttribute)pi.GetCustomAttributes(typeof(DisplayNameAttribute), false)[0]).DisplayName + "]";
                    }

                    Column newColumn = new Column();
                    newColumn.Title     = headerText;
                    newColumn.FieldName = bindingName;

                    EntityGrid.Columns.Add(newColumn);
                }
            }

            if (!isList)
            {
                data = new List <object>()
                {
                    data
                };
            }

            EntityGrid.DataContext = data;

            Dispatcher.BeginInvoke(new Action(() =>
            {
                ICollectionView collectionView = CollectionViewSource.GetDefaultView(data);

                if (collectionView != null && collectionView.CurrentItem != null)
                {
                    object item = Presenter.WorkItem.Items.FindByType(collectionView.CurrentItem.GetType()).LastOrDefault();
                    int index   = EntityGrid.Items.IndexOf(item);

                    if (index > -1)
                    {
                        EntityGrid.SelectedCellRanges.Add(new SelectionCellRange(index, 0));
                        EntityGrid.CurrentItem = item;
                    }
                }

                EntityGrid.Focus();
            }));

            base.ShowDialog();

            WorkItem.SmartParts.Remove(this);
        }
コード例 #19
0
ファイル: Analytics.xaml.cs プロジェクト: SharpNesla/Laundry
 public void ExportToExcel()
 {
     EntityGrid.ExportToExcel();
 }