public static void ElencoFasceOrarie()
 {
     using (ListForm listForm = new ListForm())
     {
         listForm.EditButton.Enabled   = false;
         listForm.AddButton.Enabled    = false;
         listForm.DeleteButton.Enabled = false;
         listForm.DataSource           = Negozio.FasceOrarie.ToList();
         listForm.Text = "Elenco fasce orarie";
         Label label = new Label();
         label.Text      = "Fasce orarie in base a cui avviene la tariffazione";
         label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
         label.Anchor    = AnchorStyles.Top;
         label.AutoSize  = true;
         listForm.SetFilter(label);
         listForm.Size = new Size(568, 355);
         listForm.ShowDialog();
     }
 }
 public static void ElencoCategorie()
 {
     using (ListForm listForm = new ListForm())
     {
         listForm.EditButton.Enabled   = false;
         listForm.AddButton.Enabled    = false;
         listForm.DeleteButton.Enabled = false;
         listForm.DataSource           = Negozio.Categorie;
         listForm.Text = "Elenco categorie";
         Label label = new Label();
         label.Text      = "Categorie di elementi presenti nel sistema";
         label.TextAlign = ContentAlignment.MiddleCenter;
         label.Anchor    = AnchorStyles.Top;
         label.AutoSize  = true;
         listForm.SetFilter(label);
         listForm.Size = new Size(568, 355);
         listForm.ShowDialog();
     }
 }
 public static void ElencoStatiElementi()
 {
     using (ListForm listForm = new ListForm())
     {
         listForm.EditButton.Enabled   = false;
         listForm.AddButton.Enabled    = false;
         listForm.DeleteButton.Enabled = false;
         listForm.DataSource           = Negozio.StatiElemento.ToList();
         listForm.Text = "Elenco stati elementi";
         Label label = new Label();
         label.Text      = "Stati in cui un elmento si può trovare";
         label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
         label.Anchor    = AnchorStyles.Top;
         label.AutoSize  = true;
         listForm.SetFilter(label);
         listForm.Size = new Size(850, 355);
         listForm.ShowDialog();
     }
 }
Exemple #4
0
        public static void AggiungiElementi()
        {
            //  Creare un nuovo elemento (servizio di Negozio)
            //  Invocare il metodo Modifica
            //  In caso di successo, aggiungere l'elemento al negozio (servizio di Document)

            string categoria = null;

            //Faccio scegliere la categoria
            using (ListForm listForm = new ListForm())
            {
                listForm.EditButton.Enabled   = false;
                listForm.AddButton.Enabled    = false;
                listForm.DeleteButton.Enabled = false;
                listForm.DataSource           = Negozio.Categorie;
                listForm.Text = "Scelta categoria elemento";
                Label label = new Label();
                label.Text      = "Scegliere la categoria dell'elemento";
                label.TextAlign = ContentAlignment.MiddleCenter;
                label.Anchor    = AnchorStyles.Top;
                label.AutoSize  = true;
                listForm.SetFilter(label);
                listForm.Size = new Size(568, 355);
                listForm.OkButton.DialogResult = DialogResult.OK;
                if (listForm.ShowDialog() == DialogResult.OK && listForm.DataGridView.CurrentRow != null)
                {
                    categoria = listForm.DataGridView.CurrentRow.DataBoundItem.ToString();
                }
                else
                {
                    return;
                }
            }

            Elemento elemento = Negozio.NuovoElemento(categoria);

            if (NoleggioServices.Modifica(elemento, true))
            {
                Negozio.InserisciNuovoElemento(elemento);
            }
        }
Exemple #5
0
        private static void AggiungiAgevolazioneAlSistema(object sender, EventArgs e)
        {
            string tipologiaAgevolazione = null;

            //Faccio scegliere la categoria
            using (ListForm listForm = new ListForm())
            {
                listForm.EditButton.Enabled   = false;
                listForm.AddButton.Enabled    = false;
                listForm.DeleteButton.Enabled = false;
                //listForm.DataSource = Negozio.TipologieAgevolazioni; >> TO DO: implementare il metodo in Negozio!
                listForm.Text = "Scelta tipologia agevolazione";
                Label label = new Label();
                label.Text      = "Scegliere la tipologia di agevolazione";
                label.TextAlign = ContentAlignment.MiddleCenter;
                label.Anchor    = AnchorStyles.Top;
                label.AutoSize  = true;
                listForm.SetFilter(label);
                listForm.Size = new Size(568, 355);
                listForm.OkButton.DialogResult = DialogResult.OK;
                if (listForm.ShowDialog() == DialogResult.OK && listForm.DataGridView.CurrentRow != null)
                {
                    tipologiaAgevolazione = listForm.DataGridView.CurrentRow.DataBoundItem.ToString();
                }
                else
                {
                    return;
                }
            }

            //Agevolazione agevolazione = Negozio.NuovaAgevolazione(tipologiaAgevolazione); >> TO DO: Da implementare in Negozio
            //if (NoleggioServices.Modifica(agevolazione, true))
            //{
            //Negozio.InserisciNuovaAgevolazione(tipo_agevolazione); >> TO DO: implementare in Negozio
            //}
        }
Exemple #6
0
        public static void AggiungiTipologieElementi()
        {
            string categoria = null;

            //Faccio scegliere la categoria
            using (ListForm listForm = new ListForm())
            {
                listForm.EditButton.Enabled   = false;
                listForm.AddButton.Enabled    = false;
                listForm.DeleteButton.Enabled = false;
                listForm.DataSource           = Negozio.Categorie;
                listForm.Text = "Scelta categoria elemento";
                Label label = new Label();
                label.Text      = "Scegliere la categoria dell'elemento";
                label.TextAlign = ContentAlignment.MiddleCenter;
                label.Anchor    = AnchorStyles.Top;
                label.AutoSize  = true;
                listForm.SetFilter(label);
                listForm.Size = new Size(568, 355);
                listForm.OkButton.DialogResult = DialogResult.OK;
                if (listForm.ShowDialog() == DialogResult.OK && listForm.DataGridView.CurrentRow != null)
                {
                    categoria = listForm.DataGridView.CurrentRow.DataBoundItem.ToString();
                }
                else
                {
                    return;
                }
            }
            TipoElemento tipo_elemento = Negozio.NuovoTipoElemento(categoria);

            if (NoleggioServices.Modifica(tipo_elemento, true))
            {
                Negozio.InserisciNuovoTipoElemento(tipo_elemento);
            }
        }
        protected override bool DoUI()
        {
            Form = new ListForm(this.m_app.ActiveUIDocument);
            PickObjectsMouseHook mouseHook = new PickObjectsMouseHook();
            DialogResult         result    = DialogResult.Retry;

            while ((result = Form.ShowDialog(new RevitHandle(Process.GetCurrentProcess().MainWindowHandle))) == DialogResult.Retry)
            {
                switch (Form.ShowDialogType)
                {
                case ShowDialogType.AddElements_ForDetail:
                case ShowDialogType.DeleleElements_ForDetail:
                    switch (Form.SubFormType)
                    {
                    case SubFormType.Subsidence:
                        try
                        {
                            mouseHook.InstallHook();
                            Form.SubFormForSubsidence.SelectedElementIds = m_uiDoc.Selection.PickObjects(ObjectType.Element, "选择要添加的构件")
                                                                           .Select(p => m_doc.GetElement(p.ElementId).Id).ToList();
                            mouseHook.UninstallHook();
                        }
                        catch
                        {
                            mouseHook.UninstallHook();
                        }
                        Form.SubFormForSubsidence.FinishElementSelection();
                        break;

                    case SubFormType.SkewBack:
                        try
                        {
                            mouseHook.InstallHook();
                            Form.SubFormForSkewBack.SelectedElementIds = m_uiDoc.Selection.PickObjects(ObjectType.Element, "选择要添加的构件")
                                                                         .Select(p => m_doc.GetElement(p.ElementId).Id).ToList();
                            mouseHook.UninstallHook();
                        }
                        catch
                        {
                            mouseHook.UninstallHook();
                        }
                        Form.SubFormForSkewBack.FinishElementSelection();
                        break;
                    }
                    break;

                case ShowDialogType.ViewElementsBySelectedNodes:
                case ShowDialogType.ViewElementsByAllNodes:
                case ShowDialogType.ViewCurrentMaxByRed:
                case ShowDialogType.ViewCurrentMaxByAll:
                case ShowDialogType.ViewTotalMaxByRed:
                case ShowDialogType.ViewTotalMaxByAll:
                case ShowDialogType.ViewCloseWarn:
                case ShowDialogType.ViewOverWarn:
                    mouseHook.InstallHook();
                    m_uiDoc.Selection.PickObjects(ObjectType.Element, "");
                    mouseHook.UninstallHook();
                    break;
                }
            }
            return(true);
        }
Exemple #8
0
        /// <summary>
        /// 执行命令
        /// </summary>
        /// <param name="o">命令参数</param>
        /// <returns>是否执行成功</returns>
        public override bool Execute(object o)
        {
            bool success = false;
            List<string> mapList = o as List<string>;
            TreeNode currentNode = tree.SelectedNode;
            TreeNode newNode;
            DialogResult result;
            string inputText;

            if (currentNode.Level > 0) // 在当前选中树结点下新建分类
            {
                InputForm iForm = new InputForm("请输入新建分类的名称", "新建分类");
                result = iForm.ShowDialog();
                inputText = iForm.InputText;
            }
            else // 在根结点下新建分类
            {
                ListForm lForm = new ListForm("请选择新建分类的地图名", mapList);
                result = lForm.ShowDialog();
                inputText = lForm.InputText;
            }

            if (result == DialogResult.OK)
            {
                if (CheckPathValid(currentNode, inputText)) // 当前无重复路径
                {
                    // 保存命令执行前的状态
                    description = ("新建分类 " + inputText);                    

                    if (currentNode != null) 
                    {
                        newNode = currentNode.Nodes.Add(inputText);
                    }
                    else 
                    {
                        newNode = tree.Nodes.Add(inputText);
                    }

                    newNode.Name = inputText;
                    newNode.ImageIndex = 0;
                    newNode.SelectedImageIndex = 0;
                    tree.SelectedNode = newNode;
                    documentManager.CurrentTreeMode = EditMode.Normal;

                    // 对数据库进行操作
                    DataBaseManager dataBaseManager = DataBaseManager.GetDataBaseManager();
                    string path = documentManager.GetNodePath(newNode);
                    string id = dataBaseManager.CreateNewDiagram(path, true, documentManager.CurrentChartMode);
                    newNode.Tag = id;

                    // 保存命令执行后的状态                    
                    success = true;
                }
                else
                {
                    MessageBox.Show("该路径已经存在!", "路径有效性检查", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }

            return success;
        }
        protected override bool DoUI()
        {
            Form = new ListForm(this.m_app.ActiveUIDocument);
            PickObjectsMouseHook mouseHook = new PickObjectsMouseHook();
            DialogResult         result    = DialogResult.Retry;

            while ((result = Form.ShowDialog(new RevitHandle(Process.GetCurrentProcess().MainWindowHandle))) == DialogResult.Retry)
            {
                switch (Form.ShowDialogType)
                {
                case ShowDialogType.AddElements:
                case ShowDialogType.DeleleElements:
                    switch (Form.SubFormType)
                    {
                    case SubFormType.Subsidence:
                        MouseHook.VLHooker.Hooker.DelegateCompletingAction(() =>
                        {
                            Form.SubFormForSubsidence.SelectedElementIds = new List <ElementId>()
                            {
                                m_uiDoc.Selection.PickObject(ObjectType.Element, "选择要添加的构件").ElementId
                            };
                        });
                        //try
                        //{
                        //    mouseHook.InstallHook();
                        //    Form.SubFormForSubsidence.SelectedElementIds = new List<ElementId>() { m_uiDoc.Selection.PickObject(ObjectType.Element, "选择要添加的构件").ElementId };
                        //    mouseHook.UninstallHook();
                        //}
                        //catch
                        //{
                        //    mouseHook.UninstallHook();
                        //}
                        Form.SubFormForSubsidence.FinishElementSelection();
                        break;

                    case SubFormType.SkewBack:
                        MouseHook.VLHooker.Hooker.DelegateCompletingAction(() =>
                        {
                            Form.SubFormForSkewBack.SelectedElementIds = new List <ElementId>()
                            {
                                m_uiDoc.Selection.PickObject(ObjectType.Element, "选择要添加的构件").ElementId
                            };
                        });
                        //try
                        //{
                        //    mouseHook.InstallHook();
                        //    Form.SubFormForSkewBack.SelectedElementIds = new List<ElementId>() { m_uiDoc.Selection.PickObject(ObjectType.Element, "选择要添加的构件").ElementId };
                        //    mouseHook.UninstallHook();
                        //}
                        //catch
                        //{
                        //    mouseHook.UninstallHook();
                        //}
                        Form.SubFormForSkewBack.FinishElementSelection();
                        break;
                    }
                    break;

                case ShowDialogType.ViewElementsBySelectedNodes:
                case ShowDialogType.ViewElementsByAllNodes:
                case ShowDialogType.ViewCurrentMaxByRed:
                case ShowDialogType.ViewCurrentMaxByAll:
                case ShowDialogType.ViewTotalMaxByRed:
                case ShowDialogType.ViewTotalMaxByAll:
                case ShowDialogType.ViewCloseWarn:
                case ShowDialogType.ViewOverWarn:
                    MouseHook.VLHooker.Hooker.DelegateCompletingAction(() =>
                    {
                        m_uiDoc.Selection.PickObjects(ObjectType.Element, "");
                    });
                    //try
                    //{
                    //    mouseHook.InstallHook();
                    //    m_uiDoc.Selection.PickObjects(ObjectType.Element, "");
                    //    mouseHook.UninstallHook();
                    //}
                    //catch
                    //{
                    //    mouseHook.UninstallHook();
                    //}
                    break;
                }
            }
            return(true);
        }
        /// <summary>
        /// 执行命令
        /// </summary>
        /// <param name="o">命令参数</param>
        /// <returns>是否执行成功</returns>
        public override bool Execute(object o)
        {
            bool          success     = false;
            List <string> mapList     = o as List <string>;
            TreeNode      currentNode = tree.SelectedNode;
            TreeNode      newNode;
            DialogResult  result;
            string        inputText;

            if (currentNode.Level > 0) // 在当前选中树结点下新建分类
            {
                InputForm iForm = new InputForm("请输入新建分类的名称", "新建分类");
                result    = iForm.ShowDialog();
                inputText = iForm.InputText;
            }
            else // 在根结点下新建分类
            {
                ListForm lForm = new ListForm("请选择新建分类的地图名", mapList);
                result    = lForm.ShowDialog();
                inputText = lForm.InputText;
            }

            if (result == DialogResult.OK)
            {
                if (CheckPathValid(currentNode, inputText)) // 当前无重复路径
                {
                    // 保存命令执行前的状态
                    description = ("新建分类 " + inputText);

                    if (currentNode != null)
                    {
                        newNode = currentNode.Nodes.Add(inputText);
                    }
                    else
                    {
                        newNode = tree.Nodes.Add(inputText);
                    }

                    newNode.Name                    = inputText;
                    newNode.ImageIndex              = 0;
                    newNode.SelectedImageIndex      = 0;
                    tree.SelectedNode               = newNode;
                    documentManager.CurrentTreeMode = EditMode.Normal;

                    // 对数据库进行操作
                    DataBaseManager dataBaseManager = DataBaseManager.GetDataBaseManager();
                    string          path            = documentManager.GetNodePath(newNode);
                    string          id = dataBaseManager.CreateNewDiagram(path, true, documentManager.CurrentChartMode);
                    newNode.Tag = id;

                    // 保存命令执行后的状态
                    success = true;
                }
                else
                {
                    MessageBox.Show("该路径已经存在!", "路径有效性检查", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }

            return(success);
        }