Ejemplo n.º 1
0
        void ToolMenu_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem menu  = (ToolStripMenuItem)sender;
            ToolWindow        panel = (ToolWindow)menu.Tag;

            if (IsPanelOpen(panel))
            {
                panel.Hide();
            }
            else
            {
                panel.Show(mDockPanel);
            }
        }
Ejemplo n.º 2
0
        private void OnRowSelected(object sender, ListEditorEventArgs e)
        {
            TableEditor   tab  = (TableEditor)sender;
            List <DBItem> rows = tab.SelectedRows;

            foreach (DBItem row in rows)
            {
                DBItem dr = Table.NewItem();
                dr[baseColumn]     = baseRow.PrimaryId;
                dr[tab.baseColumn] = row.PrimaryId;
                Table.Add(dr);
            }
            _currentControl.Hide();
            _currentControl = null;
        }
Ejemplo n.º 3
0
        protected override void OnToolRemoveClick(object sender, EventArgs e)
        {
            if (Selected == null)
            {
                return;
            }
            // var deletWindow = new RowDeleting { Row = Selected };
            var rowsText = new StringBuilder();
            var temp     = DBList.Selection.GetItems <DBItem>();

            foreach (DBItem refRow in temp)
            {
                rowsText.AppendLine(refRow.ToString());
            }

            var text = new RichTextView();

            text.LoadText(rowsText.ToString(), Xwt.Formats.TextFormat.Plain);

            var window = new ToolWindow
            {
                Target = text,
                Mode   = ToolShowMode.Dialog
            };

            if (mode == TableEditorMode.Referencing || mode == TableEditorMode.Item)
            {
                window.AddButton("Exclude", async(object se, EventArgs arg) =>
                {
                    foreach (DBItem refRow in temp)
                    {
                        refRow[OwnerColumn] = null;
                    }

                    await Table.Save();
                    window.Hide();
                });
                //tw.ButtonAccept.Location = new Point (b.Location.X - 60, 3);
                //tw.ButtonClose.Location = new Point (b.Location.X - 120, 3);
            }
            window.Label.Text         = Common.Locale.Get("TableEditor", "Deleting!");
            window.ButtonAcceptText   = Common.Locale.Get("TableEditor", "Delete");
            window.ButtonAcceptClick += async(p1, p2) =>
            {
                question.SecondaryText = Common.Locale.Get("TableEditor", "Check Reference?");
                bool flag = MessageDialog.AskQuestion(ParentWindow, question) == Command.Yes;
                list.ListSensetive = false;
                foreach (DBItem selectedRow in temp)
                {
                    RowDeleting?.Invoke(this, new ListEditorEventArgs()
                    {
                        Item = selectedRow
                    });

                    if (flag)
                    {
                        foreach (var relation in selectedRow.Table.GetChildRelations())
                        {
                            var childs = selectedRow.GetReferencing(relation, DBLoadParam.Load | DBLoadParam.Synchronize).ToList();
                            if (childs.Count == 0)
                            {
                                continue;
                            }
                            rowsText.Clear();
                            foreach (DBItem refRow in childs)
                            {
                                rowsText.AppendLine(refRow.ToString());
                            }
                            question.SecondaryText = string.Format(Common.Locale.Get("TableEditor", "Found reference on {0}. Delete?\n{1}"), relation.Table, rowsText);
                            if (MessageDialog.AskQuestion(ParentWindow, question) == Command.Yes)
                            {
                                for (int j = 0; j < childs.Count; j++)
                                {
                                    ((DBItem)childs[j]).Delete();
                                }
                            }
                            else
                            {
                                question.SecondaryText = string.Format(Common.Locale.Get("TableEditor", "Found reference on {0}. Remove Refence?\n{1}"), relation.Table, rowsText);
                                if (MessageDialog.AskQuestion(ParentWindow, question) == Command.Yes)
                                {
                                    for (int j = 0; j < childs.Count; j++)
                                    {
                                        ((DBItem)childs[j])[relation.Column] = null;
                                    }
                                }
                            }
                            await relation.Table.Save();
                        }
                    }
                    selectedRow.Delete();
                }

                await Table.Save();

                list.ListSensetive = true;
                // list.QueueDraw(true, true);
                window.Hide();
            };
            window.Show(this, Point.Zero);
        }