Esempio n. 1
0
      /// <summary>
      /// Display the PropertyEditor dialog, if the property
      /// was changed fire the PropertyChanged event.
      /// </summary>
      /// <param name="row">PropertyListRow row to display in the PropertyEditor</param>
      private void ShowEditor(GridDataTables.PropertyListRow row)
      {
          DialogResult res = DialogResult.Cancel;

          if (row.PropertyObject is ExtendedPropertyDefinition &&
              (((ExtendedPropertyDefinition)row.PropertyObject).MapiType == MapiPropertyType.Binary))
          {
              res = PropertyEditorDialog.ShowDialog(this.CurrentObject as ServiceObject,
                                                    row.PropertyObject as PropertyDefinitionBase,
                                                    true);
          }
          else if (this.CurrentObject is ServiceObject)
          {
              res = PropertyEditorDialog.ShowDialog(this.CurrentObject as ServiceObject,
                                                    row.PropertyObject as PropertyDefinitionBase,
                                                    false);
          }
          else
          {
              res = PropertyEditorDialog.ShowDialog(
                  row.IsNameNull() ? string.Empty : row.Name,
                  row.IsTypeNull() ? string.Empty : row.Type,
                  row.IsKnownNamesNull() ? string.Empty : row.KnownNames,
                  row.IsValueNull() ? string.Empty : row.Value,
                  row.IsSmartViewNull() ? string.Empty : row.SmartView);
          }

          // Fire the PropertyChanged event
          if (res == DialogResult.OK && PropertyChanged != null)
          {
              PropertyChanged(this, new EventArgs());
          }
      }
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            if (base.DesignedControl != null)
            {
                //set up the editor properties
                this.component    = (GoogleMap)base.DesignedControl;
                this.editorDialog = new PropertyEditorDialog();
                this.editorDialog.TypeContainer    = this.component;
                this.editorDialog.PropertyChanged += new PropertyValueChangedEventHandler(this.EditorDialog_PropertyChanged);
                this.Controls.Add(this.editorDialog);
                this.properties = TypeDescriptor.GetProperties(this.component);

                //bind the zoom drop down
                BindZoomOptions();

                //set the properties of the controls in the designer
                this.GoogleKey.Text = this.component.GoogleKey;
                this.Address.Text   = this.component.Address;
                this.Heading.Text   = this.component.Heading;

                if (this.Width != null)
                {
                    this.Width.Text = this.component.Width.ToString();
                }

                if (this.Height != null)
                {
                    this.Height.Text = this.component.Height.ToString();
                }

                if (this.EnableDirections != null)
                {
                    this.EnableDirections.Checked = this.component.EnableDirections;
                }

                if (this.Zoom != null)
                {
                    ListItem foundZoom = this.Zoom.Items.FindByValue(this.component.Zoom.ToString());
                    if (foundZoom != null)
                    {
                        foundZoom.Selected = true;
                    }
                }

                this.UpdateMapButton.Click += new EventHandler(UpdateMapButton_Click);
            }

            SetMapPreview();
        }
        protected override void CreateChildControls()
        {
            this.Controls.Clear();

            //get the container
            this.cnt = new Container(this);

            //get the template set up
            if ((this.itemTemplate == null) && (this.Page != null))
            {
                string itemTemplatePath = this.ItemTemplatePath;
                if (File.Exists(this.Page.MapPath(itemTemplatePath)))
                {
                    this.itemTemplate = this.Page.LoadTemplate(itemTemplatePath);
                }
                else
                {
                    this.itemTemplate = new DefaultItemTemplate();
                }
            }
            this.itemTemplate.InstantiateIn(this.cnt);
            if (base.DesignedControl != null)
            {
                //set up the editor properties
                this.component    = (GoogleMap)base.DesignedControl;
                this.editorDialog = new PropertyEditorDialog();
                this.editorDialog.TypeContainer    = this.component;
                this.editorDialog.PropertyChanged += new PropertyValueChangedEventHandler(this.EditorDialog_PropertyChanged);
                this.Controls.Add(this.editorDialog);
                this.properties = TypeDescriptor.GetProperties(this.component);

                //bind the zoom drop down
                BindZoomOptions();

                //set the properties of the controls in the designer
                this.cnt.GoogleKey.Text = this.component.GoogleKey;
                this.cnt.Address.Text   = this.component.Address;
                this.cnt.Heading.Text   = this.component.Heading;

                if (this.cnt.Width != null)
                {
                    this.cnt.Width.Text = this.component.Width.ToString();
                }

                if (this.cnt.Height != null)
                {
                    this.cnt.Height.Text = this.component.Height.ToString();
                }

                if (this.cnt.EnableDirections != null)
                {
                    this.cnt.EnableDirections.Checked = this.component.EnableDirections;
                }

                if (this.cnt.Zoom != null)
                {
                    ListItem foundZoom = this.cnt.Zoom.Items.FindByValue(this.component.Zoom.ToString());
                    if (foundZoom != null)
                    {
                        foundZoom.Selected = true;
                    }
                }

                this.cnt.UpdateMapButton.Click += new EventHandler(UpdateMapButton_Click);
            }

            SetMapPreview();
            this.Controls.Add(this.cnt);
        }
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            if (base.DesignedControl != null)
            {
                //set up the editor properties
                this.component = (GoogleMap)base.DesignedControl;
                this.editorDialog = new PropertyEditorDialog();
                this.editorDialog.TypeContainer = this.component;
                this.editorDialog.PropertyChanged += new PropertyValueChangedEventHandler(this.EditorDialog_PropertyChanged);
                this.Controls.Add(this.editorDialog);
                this.properties = TypeDescriptor.GetProperties(this.component);

                //bind the zoom drop down
                BindZoomOptions();

                //set the properties of the controls in the designer
                this.GoogleKey.Text = this.component.GoogleKey;
                this.Address.Text = this.component.Address;
                this.Heading.Text = this.component.Heading;

                if (this.Width != null)
                    this.Width.Text = this.component.Width.ToString();

                if (this.Height != null)
                    this.Height.Text = this.component.Height.ToString();

                if (this.EnableDirections != null)
                    this.EnableDirections.Checked = this.component.EnableDirections;

                if (this.Zoom != null)
                {
                    ListItem foundZoom= this.Zoom.Items.FindByValue(this.component.Zoom.ToString());
                    if (foundZoom != null)
                        foundZoom.Selected = true;
                }

                this.UpdateMapButton.Click += new EventHandler(UpdateMapButton_Click);
            }

            SetMapPreview();
        }
Esempio n. 5
0
        public void OnExecute(CommandEventArgs e)
        {
            ISvnLogItem selectedLog = EnumTools.GetSingle(e.Selection.GetSelection <ISvnLogItem>());

            if (selectedLog == null)
            {
                return;
            }

            using (PropertyEditorDialog dialog = new PropertyEditorDialog(selectedLog.RepositoryRoot, selectedLog.Revision, true))
            {
                SvnRevisionPropertyListArgs args = new SvnRevisionPropertyListArgs();
                args.ThrowOnError = false;
                SvnPropertyCollection properties = null;

                if (!e.GetService <IProgressRunner>().RunModal(LogStrings.RetrievingRevisionProperties,
                                                               delegate(object sender, ProgressWorkerArgs wa)
                {
                    if (!wa.Client.GetRevisionPropertyList(selectedLog.RepositoryRoot, selectedLog.Revision, args, out properties))
                    {
                        properties = null;
                    }
                }).Succeeded)
                {
                    return;
                }
                else if (properties != null)
                {
                    List <PropertyEditItem> propItems = new List <PropertyEditItem>();
                    foreach (SvnPropertyValue prop in properties)
                    {
                        PropertyEditItem pi = new PropertyEditItem(dialog.ListView, prop.Key);
                        pi.OriginalValue = pi.Value = pi.BaseValue = prop;

                        propItems.Add(pi);
                    }
                    dialog.PropertyValues = propItems.ToArray();
                }

                if (dialog.ShowDialog(e.Context) != DialogResult.OK)
                {
                    return;
                }

                PropertyEditItem[] finalItems = dialog.PropertyValues;

                bool hasChanges = false;

                foreach (PropertyEditItem ei in finalItems)
                {
                    if (ei.ShouldPersist)
                    {
                        hasChanges = true;
                        break;
                    }
                }
                if (!hasChanges)
                {
                    return;
                }

                IProgressRunner progressRunner = e.GetService <IProgressRunner>();

                ProgressRunnerResult result = progressRunner.RunModal(LogStrings.UpdatingRevisionProperties,
                                                                      delegate(object sender, ProgressWorkerArgs ee)
                {
                    foreach (PropertyEditItem ei in finalItems)
                    {
                        if (!ei.ShouldPersist)
                        {
                            continue;
                        }

                        if (ei.IsDeleted)
                        {
                            ee.Client.DeleteRevisionProperty(selectedLog.RepositoryRoot, selectedLog.Revision, ei.PropertyName);
                        }
                        else if (ei.Value.StringValue != null)
                        {
                            ee.Client.SetRevisionProperty(selectedLog.RepositoryRoot, selectedLog.Revision, ei.PropertyName, ei.Value.StringValue);
                        }
                        else
                        {
                            ee.Client.SetRevisionProperty(selectedLog.RepositoryRoot, selectedLog.Revision, ei.PropertyName, ei.Value.RawValue);
                        }
                    }
                });

                if (result.Succeeded)
                {
                    ILogControl logWindow = e.Selection.GetActiveControl <ILogControl>();

                    if (logWindow != null)
                    {
                        logWindow.Restart();
                    }
                }
            } // using
        }
Esempio n. 6
0
        public override void OnExecute(CommandEventArgs e)
        {
            SvnItem         firstVersioned = null;
            ISvnStatusCache cache          = e.GetService <ISvnStatusCache>();

            switch (e.Command)
            {
            case AnkhCommand.ItemEditProperties:
            case AnkhCommand.ItemShowPropertyChanges:
                foreach (SvnItem i in e.Selection.GetSelectedSvnItems(false))
                {
                    if (i.IsVersioned)
                    {
                        firstVersioned = i;
                        break;
                    }
                }
                break;

            case AnkhCommand.ProjectEditProperties:     // use project folder
                foreach (SccProject p in e.Selection.GetSelectedProjects(false))
                {
                    IProjectFileMapper pfm = e.GetService <IProjectFileMapper>();
                    if (pfm != null)
                    {
                        ISccProjectInfo info = pfm.GetProjectInfo(p);
                        if (info != null && info.ProjectDirectory != null)
                        {
                            firstVersioned = cache[info.ProjectDirectory];
                        }
                        if (firstVersioned != null)
                        {
                            break;
                        }
                    }
                }
                break;

            case AnkhCommand.SolutionEditProperties:     // use solution folder
                IAnkhSolutionSettings solutionSettings = e.GetService <IAnkhSolutionSettings>();
                if (solutionSettings != null)
                {
                    firstVersioned = cache[solutionSettings.ProjectRoot];
                }
                break;
            }
            if (firstVersioned == null)
            {
                return; // exceptional case
            }
            //using (SvnClient client = e.GetService<ISvnClientPool>().GetNoUIClient())
            using (PropertyEditorDialog dialog = new PropertyEditorDialog(firstVersioned))
            {
                dialog.Context = e.Context;

                SortedList <string, PropertyEditItem> editItems = new SortedList <string, PropertyEditItem>();
                if (!e.GetService <IProgressRunner>().RunModal(CommandStrings.ReadingProperties,
                                                               delegate(object Sender, ProgressWorkerArgs wa)
                {
                    // Retrieve base properties
                    wa.Client.PropertyList(new SvnPathTarget(firstVersioned.FullPath, SvnRevision.Base),
                                           delegate(object s, SvnPropertyListEventArgs la)
                    {
                        foreach (SvnPropertyValue pv in la.Properties)
                        {
                            PropertyEditItem ei;
                            if (!editItems.TryGetValue(pv.Key, out ei))
                            {
                                editItems.Add(pv.Key, ei = new PropertyEditItem(dialog.ListView, pv.Key));
                            }

                            ei.BaseValue = pv;
                        }
                    });
                    //

                    wa.Client.PropertyList(firstVersioned.FullPath,
                                           delegate(object s, SvnPropertyListEventArgs la)
                    {
                        foreach (SvnPropertyValue pv in la.Properties)
                        {
                            PropertyEditItem ei;
                            if (!editItems.TryGetValue(pv.Key, out ei))
                            {
                                editItems.Add(pv.Key, ei = new PropertyEditItem(dialog.ListView, pv.Key));
                            }

                            ei.OriginalValue = ei.Value = pv;
                        }
                    });
                }).Succeeded)
                {
                    return; // Canceled
                }

                PropertyEditItem[] items = new PropertyEditItem[editItems.Count];
                editItems.Values.CopyTo(items, 0);
                dialog.PropertyValues = items;

                if (dialog.ShowDialog(e.Context) == DialogResult.OK)
                {
                    // Hack: Currently we save all properties, not only the in memory changed ones

                    items = dialog.PropertyValues;

                    bool hasChanges = false;
                    foreach (PropertyEditItem i in items)
                    {
                        if (i.ShouldPersist)
                        {
                            hasChanges = true;
                            break;
                        }
                    }

                    if (!hasChanges)
                    {
                        return;
                    }

                    e.GetService <IProgressRunner>().RunModal(CommandStrings.StoringPropertyValues,
                                                              delegate(object sender, ProgressWorkerArgs wa)
                    {
                        foreach (PropertyEditItem ei in items)
                        {
                            if (!ei.ShouldPersist)
                            {
                                continue;
                            }

                            if (ei.Value == null)
                            {
                                if (ei.OriginalValue != null)
                                {
                                    wa.Client.DeleteProperty(firstVersioned.FullPath, ei.PropertyName);
                                }
                            }
                            else if (!ei.Value.ValueEquals(ei.OriginalValue))
                            {
                                if (ei.Value.StringValue != null)
                                {
                                    wa.Client.SetProperty(firstVersioned.FullPath, ei.PropertyName, ei.Value.StringValue);
                                }
                                else
                                {
                                    wa.Client.SetProperty(firstVersioned.FullPath, ei.PropertyName, ei.Value.RawValue);
                                }
                            }
                        }
                    });
                } // if
            }
        }