Exemplo n.º 1
0
        private void toolStripButtonAdd_Click(object sender, EventArgs e)
        {
            IProjectList list = Application.Selection as IProjectList;

            if (list == null)
            {
                return;
            }
            ProjectDataBase data = list.GenericType.GetConstructor(new Type[] { }).Invoke(new object[] { }) as ProjectDataBase;

            list.Add(data);
            Application_SelectionChanged(this, new Application.SelectionChangedEventArgs(null, Application.Selection));
        }
Exemplo n.º 2
0
        // ツリービュー上で選択オブジェクトが変更されたときに実行する
        private void treeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (RefreshRender_Running)
            {
                return;
            }
            if (Application_SelectionChanged_Running)
            {
                return;
            }
            ProjectDataBase data = e.Node.Tag as ProjectDataBase;

            Application.Selection = data;
        }
Exemplo n.º 3
0
 public CompareScripts(ProjectDataBase db) : this()
 {
     Mouse.OverrideCursor = Cursors.Wait;
     try
     {
         var scripts = db.GetUpdateScripts();
         DataContext             = scripts;
         gcDBObjects.ItemsSource = new ListCollectionView(scripts.Select(t => new ScriptWrapper(t)).ToList());
         DB = db;
     }
     finally
     {
         Mouse.OverrideCursor = null;
     }
 }
Exemplo n.º 4
0
 private void _Delete(ProjectDataBase data)
 {
     if (data is LayerData)
     {
         DeleteLayer(data as LayerData);
     }
     else if (data is GeometricObjectDataBase)
     {
         DeleteGeometricObject(data as GeometricObjectDataBase);
     }
     else
     {
         return;
     }
     ValidateProject(DoesUpdateShapeAuto);
 }
Exemplo n.º 5
0
        Action <DataGridViewCell> MakeValueChangedAction(ProjectDataBase data, PropertyInfo projectDataProperty)
        {
            bool flag = projectDataProperty.DeclaringType == typeof(GlobalRenderingSettingData) ||
                        projectDataProperty.DeclaringType == typeof(ParameterData) ||
                        projectDataProperty.DeclaringType == typeof(FunctionData) ||
                        projectDataProperty.DeclaringType == typeof(LayerRenderSettingData) ||
                        projectDataProperty.DeclaringType.IsSubclassOf(typeof(GeometricObjectDataBase));

            return((DataGridViewCell cell) =>
            {
                if (!projectDataProperty.GetValue(data).Equals(cell.Value))
                {
                    Application.ChangeProperty(data, projectDataProperty, cell.Value);
                    if (!projectDataProperty.GetValue(data).Equals(cell.Value))
                    {
                        cell.Value = projectDataProperty.GetValue(data);
                    }

                    Application.ValidateProject(Application.DoesUpdateShapeAuto);
                }
            });
        }
        private void toolStripButtonAdd_Click(object sender, EventArgs e)
        {
            ListBox         box  = (sender as ToolStripButton).Tag as ListBox;
            ProjectDataBase data = null;

            if (box == listBoxSrc)
            {
                data = new SourceData();
            }
            else if (box == listBoxFlx)
            {
                data = new FluxAnalysisData();
            }
            else if (box == listBoxVis)
            {
                data = new VisualizationOutputData();
            }
            else
            {
                return;
            }
            box.Items.Add(data);
        }
Exemplo n.º 7
0
        public void FinalWindow(ProjectBase userData, WindowTabControlBase userWindow)
        {
            ProjectDataBase          incomeBase   = (ProjectDataBase)userData;
            WindowTabControlDataBase incomeWindow = (WindowTabControlDataBase)userWindow;
            bool chDisc   = incomeBase.DataBase.Discs.GetChanges() != null ? true : false,
                 chCycles = incomeBase.DataBase.Cycles.GetChanges() != null ? true : false;

            if ((chDisc || chCycles) && MessageBox.Show("При выходе из вкладки внесенные изменения будут потеряны. Сохранить изменения?", "Изменения", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                if (chDisc)
                {
                    incomeWindow.DiscSave.PerformClick();
                }
                if (chCycles)
                {
                    incomeWindow.CyclesSave.PerformClick();
                }
            }
            else
            {
                incomeBase.DataBase.Discs.RejectChanges();
                incomeBase.DataBase.Cycles.RejectChanges();
            }
        }
Exemplo n.º 8
0
 /// <summary>データをデリートする。レイヤまたは構造オブジェクトにのみ適用。</summary>
 /// <param name="data"></param>
 public void Delete(ProjectDataBase data)
 {
     LogMethodStart();
     _Delete(data);
     LogMethodEnd();
 }
Exemplo n.º 9
0
 public SelectionChangedEventArgs(ProjectDataBase oldItem, ProjectDataBase newItem)
 {
     OldItem = oldItem;
     NewItem = newItem;
 }
Exemplo n.º 10
0
 public abstract Task <IFile> Create(ProjectDataBase projectData, IFolder projectFolder);
Exemplo n.º 11
0
 public DependenciesSettings(ProjectDataBase dB) : this()
 {
     DataContext = dB;
     dB.UpdateDBObjects();
 }
Exemplo n.º 12
0
 public AddScript(ProjectDataBase dB) : this()
 {
     this.dB = dB;
 }
Exemplo n.º 13
0
        public DBObjectsFiltering(ProjectDataBase dB)
        {
            timer.Tick    += ApplyTextFilter;
            timer.Interval = new TimeSpan(0, 0, 0, 0, 400);

            DataContext = dB;

            Mouse.OverrideCursor = Cursors.Wait;
            try
            {
                dB.UpdateFilterDataFromConfig();

                InitializeComponent();

                SqlConnection conn = new SqlConnection(dB.GetConnectionString());

                Server server = new Server(new ServerConnection(conn));

                if (!HasConnection(dB.GetConnectionString()))
                {
                    throw new Exception($@"Не удалось подключиться к серверу: {dB.Project.Server}");
                }

                Database dataBase = server.Databases.Cast <Database>().ToList().SingleOrDefault(d => d.Name == dB.Name);

                if (dataBase == null)
                {
                    MessageBox.Show($@"На сервере {dB.Project.Server} не найдена база данных: {dB.Name}");
                    return;
                }

                dataBase.Schemas.Cast <Schema>().ToList()
                .Where(s => !s.IsSystemObject || s.Name == "dbo").ToList()
                .ForEach(s =>
                {
                    string sName = $@"{s.Name}";
                    Sch sch      = dB.Schemas.SingleOrDefault(sh => sh.ToString() == sName);

                    if (sch == null)
                    {
                        var NewSchema = new Sch(sName);
                        dB.Schemas.Add(NewSchema);
                    }
                }
                         );

                dataBase.StoredProcedures.Cast <StoredProcedure>().ToList()
                .Where(sp => sp.Schema != "sys").ToList()
                .ForEach(sp =>
                {
                    string spName  = $@"{sp.Schema}.{sp.Name}";
                    Procedure proc = dB.Procedures.SingleOrDefault(s => s.ToString() == spName);

                    if (proc == null)
                    {
                        var NewProc = new Procedure(spName);
                        dB.Procedures.Add(NewProc);
                    }
                }
                         );

                dataBase.UserDefinedFunctions.Cast <UserDefinedFunction>().ToList()
                .Where(f => f.Schema != "sys").ToList()
                .ForEach(f =>
                {
                    string fnName = $@"{f.Schema}.{f.Name}";
                    Function fn   = dB.Functions.SingleOrDefault(fun => fun.ToString() == fnName);

                    if (fn == null)
                    {
                        var NewFn = new Function(fnName);
                        dB.Functions.Add(NewFn);
                    }
                }
                         );

                dataBase.Tables.Cast <Table>().ToList()
                .Where(t => t.Schema != "sys").ToList()
                .ForEach(t =>
                {
                    string tblName = $@"{t.Schema}.{t.Name}";
                    Tbl tbl        = dB.Tables.SingleOrDefault(tab => tab.ToString() == tblName);

                    if (tbl == null)
                    {
                        var NewTable = new Tbl(tblName);
                        dB.Tables.Add(NewTable);
                    }
                }
                         );

                Filtering();
            }
            finally
            {
                Mouse.OverrideCursor = null;
            }
        }
Exemplo n.º 14
0
        void SetDataGridViewWithProjectDataBase(ProjectDataBase data)
        {
            // 特別な注意が必要なProjectData以外はリフレクションを利用してdataGridViewを設定する
            // toolStripは隠す
            toolStrip.Visible = false;

            PropertyInfo[]             properties     = data.GetType().GetProperties();
            List <ProjectDataProperty> projProperties = new List <ProjectDataProperty>();
            PropertyEditorAttribute    attr;

            foreach (PropertyInfo p in properties)
            {
                attr = Attribute.GetCustomAttribute(p, typeof(PropertyEditorAttribute)) as PropertyEditorAttribute;
                if (attr != null)
                {
                    projProperties.Add(new ProjectDataProperty(attr, p));
                }
            }

            projProperties.Sort();
            PropertyInfo descriptionStringProperty;
            Dictionary <string, object> tags;
            Action <DataGridViewCell>   selected, changed;
            DataGridViewRow             row;
            DataGridViewTextBoxCell     nCell, vCell;

            dataGridView.Columns.Add("Name", "Name");
            dataGridView.Columns.Add("Value", "Value");
            dataGridView.Columns[0].SortMode     = DataGridViewColumnSortMode.NotSortable;
            dataGridView.Columns[1].SortMode     = DataGridViewColumnSortMode.NotSortable;
            dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            foreach (ProjectDataProperty p in projProperties)
            {
                row = new DataGridViewRow();
                descriptionStringProperty = typeof(LanguagePack.ProjectDataPropertyDescriptionText).GetProperty(data.GetType().Name + "_" + p.P.Name);
                if (descriptionStringProperty == null)
                {
                    descriptionStringProperty = typeof(LanguagePack.ProjectDataPropertyDescriptionText).GetProperty(p.P.DeclaringType.Name + "_" + p.P.Name);
                }
                selected = MakeSelectedAction(p.P, descriptionStringProperty);

                nCell       = new DataGridViewTextBoxCell();
                nCell.Value = p.P.Name;
                tags        = new Dictionary <string, object>();
                tags.Add("Selected", selected);
                nCell.Tag = tags;
                row.Cells.Add(nCell);
                nCell.ReadOnly = true;

                vCell           = new DataGridViewTextBoxCell();
                changed         = MakeValueChangedAction(data, p.P);
                vCell.ValueType = p.P.PropertyType;
                vCell.Value     = p.P.GetValue(data);
                tags            = new Dictionary <string, object>();
                tags.Add("ValueChanged", changed);
                vCell.Tag = tags;
                row.Cells.Add(vCell);
                vCell.ReadOnly = !p.Attr.EditableAsString;

                dataGridView.Rows.Add(row);
            }
        }