예제 #1
0
        private void wizardTunning_BeforeSwitchPages(object sender, CristiPotlog.Controls.Wizard.BeforeSwitchPagesEventArgs e)
        {
            CristiPotlog.Controls.WizardPage oldPage = wizardTunning.Pages[e.OldIndex];
            CristiPotlog.Controls.WizardPage newPage = wizardTunning.Pages[e.NewIndex];

            if (oldPage == wizardPageWelcome && e.OldIndex < e.NewIndex)
            {
                if (startOnNumbering)
                {
                    e.NewIndex = 4;
                }
            }
            else if (oldPage == wizardPageChannelParameters && e.OldIndex < e.NewIndex)
            {
                if (this.radioButtonAddThisChannel.Checked)
                {
                    e.NewIndex++;
                }
            }
            else if (oldPage == wizardPageChannelDestination)
            {
                if (e.OldIndex < e.NewIndex)
                {
                    CopyChannelToDestinationFolder();
                }
                else if (e.OldIndex > e.NewIndex)
                {
                    if (this.radioButtonAddThisChannel.Checked)
                    {
                        e.NewIndex--;
                    }
                }
            }
            else if (oldPage == wizardPageChannelNumbering && e.OldIndex < e.NewIndex)
            {
                UpdateChannelNumbering();
            }
        }
예제 #2
0
        private void projectMigrationWizzard_BeforeSwitchPages(object sender, CristiPotlog.Controls.Wizard.BeforeSwitchPagesEventArgs e)
        {
            // get wizard page already displayed
            WizardPage oldPage = projectMigrationWizzard.Pages[e.OldIndex];

            // check if we're going forward from options page
            if (oldPage == fromStudioVersion && e.NewIndex > e.OldIndex)
            {
                var selectedStudioVersionsGeneric = chkSourceStudioVersions.CheckedObjects;
                if (selectedStudioVersionsGeneric.Count == 0)
                {
                    MessageBox.Show(this,
                                    Resources.MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Please_select_a_Studio_version_,
                                    Resources.MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Select_a_studio_version, MessageBoxButtons.OK);
                    e.Cancel = true;
                    return;
                }
                if (selectedStudioVersionsGeneric.Count > 1)
                {
                    MessageBox.Show(this,
                                    Resources
                                    .MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Please_select_only_one_version,
                                    Resources.MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Only_one_version
                                    , MessageBoxButtons.OK);
                    e.Cancel = true;
                    return;
                }
            }

            if (oldPage == toStudioVersion && e.NewIndex > e.OldIndex)
            {
                var selectedDestinationStudioVersionsGeneric = chkDestinationStudioVersion.CheckedObjects;
                if (selectedDestinationStudioVersionsGeneric.Count == 0)
                {
                    MessageBox.Show(this,
                                    Resources
                                    .MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Please_select_a_Studio_version_,
                                    Resources.MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Select_a_studio_version,
                                    MessageBoxButtons.OK);
                    e.Cancel = true;
                    return;
                }
                if (selectedDestinationStudioVersionsGeneric.Count > 1)
                {
                    MessageBox.Show(this,
                                    Resources
                                    .MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Please_select_only_one_version,
                                    Resources.MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Only_one_version
                                    , MessageBoxButtons.OK);
                    e.Cancel = true;
                    return;
                }
                var selectedSourceStudioVersionsGeneric = chkSourceStudioVersions.CheckedObjects;
                var destinationStudioVersion            = (StudioVersion)selectedDestinationStudioVersionsGeneric[0];
                var sourceStudioVersion = (StudioVersion)selectedSourceStudioVersionsGeneric[0];

                if (destinationStudioVersion.Equals(selectedSourceStudioVersionsGeneric[0]))
                {
                    MessageBox.Show(this,
                                    string.Format("Destination version ({0}) must be different than the source version ({1})",
                                                  destinationStudioVersion.PublicVersion, sourceStudioVersion.PublicVersion),
                                    Resources.MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Same_version
                                    , MessageBoxButtons.OK);
                    e.Cancel = true;
                    return;
                }

                var migrateProjects = new MigrateProjectsService(sourceStudioVersion,
                                                                 destinationStudioVersion);

                var projects = migrateProjects.GetProjectsToBeMigrated();

                projectsToBeMoved.SetObjects(projects);

                foreach (OLVListItem item in from OLVListItem item in projectsToBeMoved.Items let project = (Project)item.RowObject where !Path.IsPathRooted(project.ProjectFilePath) select item)
                {
                    item.Checked = true;
                }
            }
        }
예제 #3
0
        private void projectMigrationWizzard_BeforeSwitchPages(object sender,
                                                               CristiPotlog.Controls.Wizard.BeforeSwitchPagesEventArgs e)
        {
            // get wizard page already displayed
            WizardPage oldPage = projectMigrationWizzard.Pages[e.OldIndex];

            // check if we're going forward from options page
            if (oldPage == fromStudioVersion && e.NewIndex > e.OldIndex)
            {
                var selectedStudioVersionsGeneric = chkSourceStudioVersions.CheckedObjects;
                if (selectedStudioVersionsGeneric.Count == 0)
                {
                    MessageBox.Show(this,
                                    Resources
                                    .MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Please_select_a_Studio_version_,
                                    Resources.MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Select_a_studio_version,
                                    MessageBoxButtons.OK);
                    e.Cancel = true;
                    return;
                }
                if (selectedStudioVersionsGeneric.Count > 1)
                {
                    MessageBox.Show(this,
                                    Resources
                                    .MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Please_select_only_one_version,
                                    Resources.MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Only_one_version
                                    , MessageBoxButtons.OK);
                    e.Cancel = true;
                    return;
                }
            }

            if (oldPage == toStudioVersion && e.NewIndex > e.OldIndex)
            {
                var selectedDestinationStudioVersionsGeneric = chkDestinationStudioVersion.CheckedObjects;
                if (selectedDestinationStudioVersionsGeneric.Count == 0)
                {
                    MessageBox.Show(this,
                                    Resources
                                    .MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Please_select_a_Studio_version_,
                                    Resources.MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Select_a_studio_version,
                                    MessageBoxButtons.OK);
                    e.Cancel = true;
                    return;
                }
                if (selectedDestinationStudioVersionsGeneric.Count > 1)
                {
                    MessageBox.Show(this,
                                    Resources
                                    .MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Please_select_only_one_version,
                                    Resources.MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Only_one_version
                                    , MessageBoxButtons.OK);
                    e.Cancel = true;
                    return;
                }
                var selectedSourceStudioVersionsGeneric = chkSourceStudioVersions.CheckedObjects;
                var destinationStudioVersion            = (StudioVersion)selectedDestinationStudioVersionsGeneric[0];
                var sourceStudioVersion = (StudioVersion)selectedSourceStudioVersionsGeneric[0];

                if (destinationStudioVersion.Equals(selectedSourceStudioVersionsGeneric[0]))
                {
                    MessageBox.Show(this,
                                    string.Format("Destination version ({0}) must be different than the source version ({1})",
                                                  destinationStudioVersion.PublicVersion, sourceStudioVersion.PublicVersion),
                                    Resources.MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Same_version
                                    , MessageBoxButtons.OK);
                    e.Cancel = true;
                    return;
                }

                var migrateProjects = new MigrateProjectsService(sourceStudioVersion,
                                                                 destinationStudioVersion);

                var selectAllProjects = new Project {
                    Name = "Select all projects"
                };

                var projects = migrateProjects.GetProjectsToBeMigrated();

                if (projects.Count != 0 && projects.Count != 1)
                {
                    projects.Insert(0, selectAllProjects);
                }


                projectsToBeMoved.SetObjects(projects);

                foreach (OLVListItem item in from OLVListItem item in projectsToBeMoved.Items
                         let project = (Project)item.RowObject
                                       where !Path.IsPathRooted(project.ProjectFilePath)
                                       select item)
                {
                    if (item.Text != @"Select all projects")
                    {
                        item.Checked = true;
                    }
                }

                projectsToBeMoved.ItemChecked += ProjectsToBeMoved_ItemChecked;

                if (projectsToBeMoved.Items.Count > 0)
                {
                    if (projectsToBeMoved.Items[0].Text == @"Select all projects")
                    {
                        projectsToBeMoved.Items[0].ForeColor = ColorTranslator.FromHtml("#6887B2");
                        projectsToBeMoved.Items[0].Font      = new Font(projectsToBeMoved.Items[0].Font, FontStyle.Bold);
                    }
                }
            }


            #region Plugins page
            if (oldPage == moveProjects && e.NewIndex > e.OldIndex)
            {
                //call Sdl.Community.PluginInfo.dll in order to get the plugin name
                var currentAssembly = Assembly.GetAssembly(typeof(MigrateProjectsService));
                var path            = Path.GetDirectoryName(currentAssembly.Location);
                if (path != null)
                {
                    var pluginInfoDll = Assembly.LoadFrom(Path.Combine(path, "Sdl.Community.PluginInfo"));
                    var type          = pluginInfoDll.GetType("Sdl.Community.PluginInfo.PluginPackageInfo");

                    var selectedSourceStudioVersionsGeneric = chkSourceStudioVersions.CheckedObjects;
                    var sourceStudioVersion = (StudioVersion)selectedSourceStudioVersionsGeneric[0];

                    var selectedDestinationStudioVersionsGeneric = chkDestinationStudioVersion.CheckedObjects;
                    var destinationStudioVersion = (StudioVersion)selectedDestinationStudioVersionsGeneric[0];

                    //get plugins list for source selected studio  version
                    var sourcePluginsList = GetInstallledPluginsForSpecificStudioVersion(sourceStudioVersion);

                    //get plugins list for destination selected studio  version
                    var destinationPluginsPathList = GetInstallledPluginsForSpecificStudioVersion(destinationStudioVersion);

                    //check if there are any plugins to be migrated for selected verions
                    var pluginsList =
                        sourcePluginsList.Where(p => destinationPluginsPathList.All(d => d.PluginName != p.PluginName));

                    //call "GetPluginName" method in order to get the plugin name
                    var method      = type.GetMethod("GetPluginName");
                    var constructor = type.GetConstructor(
                        BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
                        null, Type.EmptyTypes, null);
                    var instance = constructor.Invoke(new object[] { });

                    foreach (var plugin in pluginsList)
                    {
                        var name            = method.Invoke(instance, new object[] { plugin.Path });
                        var pluginToBeMoved = new Model.PluginInfo
                        {
                            Path       = plugin.Path,
                            PluginName = name as string
                        };

                        if (!_pluginsToBeMigrated.Exists(p => p.PluginName == pluginToBeMoved.PluginName))
                        {
                            _pluginsToBeMigrated.Add(pluginToBeMoved);
                        }
                    }
                }

                var selectAllPlugins = new Model.PluginInfo
                {
                    PluginName = "Select all plugins"
                };

                if (_pluginsToBeMigrated.Count > 1 && !_pluginsToBeMigrated.Exists(p => p.PluginName == selectAllPlugins.PluginName))
                {
                    _pluginsToBeMigrated.Insert(0, selectAllPlugins);
                }

                installedPluginsListView.SetObjects(_pluginsToBeMigrated);


                installedPluginsListView.ItemChecked += InstalledPluginsListView_ItemChecked;

                if (installedPluginsListView.Items.Count > 0)
                {
                    if (installedPluginsListView.Items[0].Text == @"Select all plugins")
                    {
                        installedPluginsListView.Items[0].ForeColor = ColorTranslator.FromHtml("#6887B2");
                        installedPluginsListView.Items[0].Font      = new Font(installedPluginsListView.Items[0].Font, FontStyle.Bold);
                    }
                }
            }
            #endregion
        }
예제 #4
0
        /// <summary>
        /// 当向导页要切换到下一页前可以做的该页检查工作,决定是否可以切换到下一页。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void wizardLogistcCA_BeforeSwitchPages(object sender, CristiPotlog.Controls.Wizard.BeforeSwitchPagesEventArgs e)
        {
            //从介绍页切换前,如果使用默认,则直接切换到摘要页
            if (e.OldIndex == 1 && e.NewIndex == 2)
            {
                if (isUsingDefault)
                {
                    e.NewIndex         = 8;
                    textBoxSummay.Text = WriteSummay();
                }
            }
            //训练数据设置页切换前的检查
            else if (e.OldIndex == 2 && e.NewIndex == 3)
            {
                StringBuilder sb = new StringBuilder();
                if (comboBoxTrainingStartImage.SelectedIndex == -1)
                {
                    sb.AppendLine(resourceManager.GetString("String3"));
                    sb.AppendLine();
                    e.Cancel = true;
                }
                if (comboBoxTrainingEndImage.SelectedIndex == -1)
                {
                    sb.AppendLine(resourceManager.GetString("String4"));
                    sb.AppendLine();
                    e.Cancel = true;
                }
                if (this.dataGridViewVariableDatas.Rows.Count == 0)
                {
                    sb.AppendLine(resourceManager.GetString("String5"));
                    e.Cancel = true;
                }
                else
                {
                    //还需要判断每行里是否有空值
                    if (dataGridViewVariableDatas.Rows[0].Cells[0].Value == null)
                    {
                        sb.AppendLine(resourceManager.GetString("String5"));
                        e.Cancel = true;
                    }
                }
                if (sb.Length > 0)
                {
                    MessageBox.Show(sb.ToString(), resourceManager.GetString("String2"), MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
            //土地利用类型设置页切换前的检查
            else if (e.OldIndex == 3 && e.NewIndex == 4)
            {
                for (int i = 0; i < dataGridViewLandUse.Rows.Count; i++)
                {
                    if (dataGridViewLandUse.Rows[i].Cells[2].Value == null)
                    {
                        MessageBox.Show(resourceManager.GetString("String10"),
                                        resourceManager.GetString("String2"), MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        e.Cancel = true;
                        break;
                    }
                }
            }
            //模拟数据设置页可以继续的条件
            else if (e.OldIndex == 6 && e.NewIndex == 7)
            {
                StringBuilder sb = new StringBuilder();
                if (this.comboBoxSimStartImage.Text == "")
                {
                    sb.AppendLine(resourceManager.GetString("String16"));
                    sb.AppendLine();
                    e.Cancel = true;
                }
                if (sb.Length > 0)
                {
                    MessageBox.Show(sb.ToString(), resourceManager.GetString("String2"), MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
            //如果欢迎页选择使用默认
            else if (e.OldIndex == 0)
            {
                isUsingDefault = checkBoxUseDefault.Checked;
                if (isUsingDefault)
                {
                    if (!application.Caption.Contains("LandUseChange_DongGuan"))
                    {
                        MessageBox.Show(resourceManager.GetString("String17"), resourceManager.GetString("String2"), MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        e.Cancel = true;
                    }
                    else
                    {
                        //如果不是第一次打开窗体,则再次读取地图数据
                        application             = ArcMap.Application;
                        document                = application.Document as IMxDocument;
                        map                     = document.FocusMap;
                        ArcGISOperator.FoucsMap = document.FocusMap;
                        //如果图层选择框为空
                        if (comboBoxTrainingStartImage.Items.Count == 0)
                        {
                            for (int i = 0; i < map.LayerCount; i++)
                            {
                                string layerName = map.get_Layer(i).Name;
                                comboBoxTrainingStartImage.Items.Add(layerName);
                                comboBoxTrainingEndImage.Items.Add(layerName);
                                comboBoxSimStartImage.Items.Add(layerName);
                                comboBoxSimEndImage.Items.Add(layerName);
                            }
                        }
                        for (int i = 0; i < comboBoxTrainingStartImage.Items.Count; i++)
                        {
                            if (comboBoxTrainingStartImage.Items[i].ToString() == "landuse2000")
                            {
                                comboBoxTrainingStartImage.SelectedIndex = i;
                                break;
                            }
                        }
                        for (int i = 0; i < comboBoxTrainingEndImage.Items.Count; i++)
                        {
                            if (comboBoxTrainingEndImage.Items[i].ToString() == "landuse2005")
                            {
                                comboBoxTrainingEndImage.SelectedIndex = i;
                                break;
                            }
                        }
                        for (int i = 0; i < comboBoxSimStartImage.Items.Count; i++)
                        {
                            if (comboBoxSimStartImage.Items[i].ToString() == "landuse2005")
                            {
                                comboBoxSimStartImage.SelectedIndex = i;
                                break;
                            }
                        }
                        for (int i = 0; i < comboBoxSimEndImage.Items.Count; i++)
                        {
                            if (comboBoxSimEndImage.Items[i].ToString() == "landuse2006")
                            {
                                comboBoxSimEndImage.SelectedIndex = i;
                                break;
                            }
                        }
                        //使用默认配置时未读取变量数据,需要在模拟前读取
                        listVariableLayersName.Clear();
                        listVariableLayersName.Add("dtroad");
                        listVariableLayersName.Add("dtrailway");
                        listVariableLayersName.Add("dtfreeway");
                        listVariableLayersName.Add("dtcity");

                        System.IO.StreamReader streamReader = new System.IO.StreamReader(GetMxdDocumentFolder() + @"\Config Files\DefaultLanduseInfo.xml");
                        System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(LandUseClassificationInfo));
                        landUseClassificationInfo = (LandUseClassificationInfo)xmlSerializer.Deserialize(streamReader);
                        streamReader.Close();

                        coef    = new double[5];
                        coef[0] = 0.061f;
                        coef[1] = 0.662f;
                        coef[2] = -1.329f;
                        coef[3] = -1.107f;
                        coef[4] = 1.729f;

                        outputFolder         = GetOutputFolder();
                        convertCount         = 19260;
                        simulationIterations = 100;
                        refreshInterval      = 10;
                        outputImageInterval  = 10;
                        delta = 3;
                        numericUpDownConvertCount.Value = 19260;
                        numericUpDownIterations.Value   = 100;
                        numericUpDownDelta.Value        = 3;
                        numericUpDownRefresh.Value      = 10;
                        numericUpDownOutputImage.Value  = 10;
                        isOutput = false;
                    }
                }
            }
            //如果欢迎页选择使用默认,则“上一步”直接回到介绍页。
            else if (e.NewIndex == 7 && e.OldIndex == 8)
            {
                if (isUsingDefault)
                {
                    e.NewIndex = 1;
                }
            }
        }