コード例 #1
0
        //----------------------------------------------------------------------------+
        //                                TabItem_Drop                                |
        //----------------------------------------------------------------------------+
        private void TabItem_Drop(object sender, DragEventArgs e)
        {
            if (_ReadOnly)
            {
                return;
            }
            var tabItemTarget = e.Source as TabItem;

            if (tabItemTarget.Header.ToString() == App.NewTabHeaderText)
            {
                return;
            }
            var tabItemSource = e.Data.GetData(typeof(TabItem)) as TabItem;

            if (!tabItemTarget.Equals(tabItemSource))
            {
                string    sourceHeader  = tabItemSource.Header.ToString();
                ucTabella sourceContent = tabItemSource.Content as ucTabella;
                tabItemSource.Content = null;
                sourceContent.ChangeAlias(sourceHeader);
                string    targetHeader  = tabItemTarget.Header.ToString();
                ucTabella targetContent = tabItemTarget.Content as ucTabella;
                tabItemTarget.Content = null;
                targetContent.ChangeAlias(targetHeader);
                tabItemSource.Header  = targetHeader;
                tabItemSource.Content = targetContent;
                tabItemTarget.Header  = sourceHeader;
                tabItemTarget.Content = sourceContent;
            }
        }
コード例 #2
0
        //----------------------------------------------------------------------------+
        //                                    Load                                    |
        //----------------------------------------------------------------------------+
        public void Load(string ID, string tab, string IDTree, string IDCliente, string IDSessione)
        {
            id = int.Parse(ID.ToString());
            cBusinessObjects.idcliente  = int.Parse(IDCliente.ToString());
            cBusinessObjects.idsessione = int.Parse(IDSessione.ToString());

            _ID = ID;


            _IDTree = IDTree;
            TabItem   ti;
            ArrayList Tabs = new ArrayList();

            dati = cBusinessObjects.GetData(id, typeof(Tabella));
            if (dati.Rows.Count == 0)
            {
                ucTabella t = new ucTabella();
                t.ReadOnly = _ReadOnly;
                t.Load(ID, "", _IDTree, "", IDCliente, IDSessione);
                if (tab == "")
                {
                    tab = "Tabella Principale";
                }
                else if (_NewTabModifiedNames.ContainsKey(IDTree + "_" + ID))
                {
                    tab = String.Format(_NewTabModifiedNames[IDTree + "_" + ID], 1);//in questo caso è sempre la prima
                }
                ti        = new TabItem();
                ti.Header = tab;
                t.ChangeAlias(tab);
                ti.Content = t;
                //tabControl.Items.Add(ti); // E.B. comment
                Tabs.Add(tab); // E.B.
            }
            else
            {
                bool trovata = false;
                foreach (DataRow dtrow in dati.Rows)
                {
                    try
                    {
                        string tabtmp = dtrow["Tab"].ToString();
                        if (tabtmp != "")
                        {
                            trovata = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        string log = ex.Message;
                    }
                }
                if (!trovata)
                {
                    foreach (DataRow dtrow in dati.Rows)
                    {
                        dtrow["Tab"] = "Tabella Principale";
                    }
                    cBusinessObjects.SaveData(id, dati, typeof(Tabella));
                }
            }

            foreach (DataRow dtrow in dati.Rows)
            {
                try
                {
                    string tabtmp = dtrow["Tab"].ToString();
                    if (!Tabs.Contains(tabtmp))
                    {
                        Tabs.Add(tabtmp);
                    }
                }
                catch (Exception ex)
                {
                    string log = ex.Message;
                }
            }


            for (int i = 0; i < Tabs.Count; i++)
            {
                ti        = new TabItem();
                ti.Header = Tabs[i];
                ucTabella t_int = new ucTabella();
                t_int.ReadOnly = _ReadOnly;
                t_int.Load(ID, (string)(Tabs[i]), _IDTree, "", IDCliente, IDSessione);
                t_int.ChangeAlias(Tabs[i].ToString());
                ti.Content = t_int;

                tabControl.Items.Add(ti);
            }
            ti        = new TabItem();
            ti.Header = App.NewTabHeaderText;
            tabControl.Items.Add(ti);
        }