internal SampleSelectionService(IDesignerHost host) { this.host = host; this.container = host.Container; this.selectionsByComponent = new Hashtable(); this.selectionChanged = false; // We initialize this to true to catch anything that would cause // an update during load. this.batchMode = true; // And configure the events we want to listen to. IComponentChangeService cs = (IComponentChangeService)host.GetService(typeof(IComponentChangeService)); Debug.Assert(cs != null, "IComponentChangeService not found"); if (cs != null) { cs.ComponentAdded += new ComponentEventHandler(this.DesignerHost_ComponentAdd); cs.ComponentRemoved += new ComponentEventHandler(this.DesignerHost_ComponentRemove); cs.ComponentChanged += new ComponentChangedEventHandler(this.DesignerHost_ComponentChanged); } host.TransactionOpened += new EventHandler(this.DesignerHost_TransactionOpened); host.TransactionClosed += new DesignerTransactionCloseEventHandler(this.DesignerHost_TransactionClosed); // If our host is already in a transaction, we handle it. if (host.InTransaction) { DesignerHost_TransactionOpened(host, EventArgs.Empty); } host.LoadComplete += new EventHandler(this.DesignerHost_LoadComplete); }
/// <summary> /// <para> /// Gets the delarative type for the /// specified type. /// </para> /// </summary> /// <param name='type'> /// The type of the declarator. /// </param> /// <param name='host'> /// The services interface exposed by the webforms designer. /// </param> private static string GetDeclarativeType(Type type, IDesignerHost host) { Debug.Assert(host != null, "Need an IDesignerHost to create declarative type names"); string declarativeType = null; if (host != null) { IWebFormReferenceManager refMgr = (IWebFormReferenceManager)host.GetService(typeof(IWebFormReferenceManager)); Debug.Assert(refMgr != null, "Did not get back IWebFormReferenceManager service from host."); if (refMgr != null) { string tagPrefix = refMgr.GetTagPrefix(type); if ((tagPrefix != null) && (tagPrefix.Length != 0)) { declarativeType = tagPrefix + ":" + type.Name; } } } if (declarativeType == null) { /* Begin AUI 7201 */ /* Original declarativeType = type.FullName; */ if (type == typeof(System.Web.UI.MobileControls.Style)) { declarativeType = type.Name; } else { declarativeType = type.FullName; } /* End AUI 7201 */ } return declarativeType; }
// protected override IComponent[] CreateComponentsCore(IDesignerHost host) { Type typeOfComponent = GetType(host, AssemblyName, TypeName, true); if (typeOfComponent == null && host != null) typeOfComponent = host.GetType(TypeName); if (typeOfComponent == null) { ITypeProviderCreator tpc = null; if (host != null) tpc = (ITypeProviderCreator)host.GetService(typeof(ITypeProviderCreator)); if (tpc != null) { System.Reflection.Assembly assembly = tpc.GetTransientAssembly(this.AssemblyName); if (assembly != null) typeOfComponent = assembly.GetType(this.TypeName); } if (typeOfComponent == null) typeOfComponent = GetType(host, AssemblyName, TypeName, true); } ArrayList comps = new ArrayList(); if (typeOfComponent != null) { if (typeof(IComponent).IsAssignableFrom(typeOfComponent)) comps.Add(TypeDescriptor.CreateInstance(null, typeOfComponent, null, null)); } IComponent[] temp = new IComponent[comps.Count]; comps.CopyTo(temp, 0); return temp; }
public WorkflowViewWrapper() { this.loader = new Loader(); // Create a Workflow Design Surface this.surface = new DesignSurface(); this.surface.BeginLoad(this.loader); // Get the Workflow Designer Host this.Host = this.surface.GetService(typeof(IDesignerHost)) as IDesignerHost; if (this.Host == null) return; // Create a Sequential Workflow by using the Workflow Designer Host SequentialWorkflow = (SequentialWorkflowActivity)Host.CreateComponent(typeof(SequentialWorkflowActivity)); SequentialWorkflow.Name = "CustomOutlookWorkflow"; // Create a Workflow View on the Workflow Design Surface this.workflowView = new WorkflowView(this.surface as IServiceProvider); // Add a message filter to the workflow view, to support panning MessageFilter filter = new MessageFilter(this.surface as IServiceProvider, this.workflowView); this.workflowView.AddDesignerMessageFilter(filter); // Activate the Workflow View this.Host.Activate(); this.workflowView.Dock = DockStyle.Fill; this.Controls.Add(workflowView); this.Dock = DockStyle.Fill; }
internal ChangeToolStripParentVerb(string text, ToolStripDesigner designer) { this._designer = designer; this._provider = designer.Component.Site; this._host = (IDesignerHost) this._provider.GetService(typeof(IDesignerHost)); this.componentChangeSvc = (IComponentChangeService) this._provider.GetService(typeof(IComponentChangeService)); }
// We don't really deserialize a tool box item, we fabricate // it is the drag source is a node that has a type. Otherwise // we just return null indicating this is not from the toolbox public ToolboxItem DeserializeToolboxItem(Object obj, IDesignerHost host) { //Console.WriteLine("TBS:DeserializeToolBoxItem " + obj); if (!(obj is IDataObject)) return null; IDataObject data = (IDataObject)obj; bool found = false; IDragDropItem sourceNode = null; // Look for a node that represents a type, this is either // a constructor or a type node foreach (Type t in BrowserTree.DragSourceTypes) { sourceNode = (IDragDropItem)data.GetData(t); if (sourceNode != null && sourceNode is ITargetType) { found = true; break; } } if (!found) return null; Type type = ((ITargetType)sourceNode).Type; if (!(typeof(Control).IsAssignableFrom(type))) return null; IDesignSurfaceNode dNode = (IDesignSurfaceNode)sourceNode; if (!dNode.OnDesignSurface) return null; ToolboxItem ti = new ToolboxItem(type); ti.ComponentsCreated += new ToolboxComponentsCreatedEventHandler(ComponentsCreated); return ti; }
public ToolStripTemplateNode(IComponent component, string text, Image image) { this.component = component; this.activeItem = component as ToolStripItem; this._designerHost = (IDesignerHost) component.Site.GetService(typeof(IDesignerHost)); this._designer = this._designerHost.GetDesigner(component); this._designSurface = (DesignSurface) component.Site.GetService(typeof(DesignSurface)); if (this._designSurface != null) { this._designSurface.Flushed += new EventHandler(this.OnLoaderFlushed); } if (!isScalingInitialized) { if (System.Windows.Forms.DpiHelper.IsScalingRequired) { TOOLSTRIP_TEMPLATE_HEIGHT = System.Windows.Forms.DpiHelper.LogicalToDeviceUnitsY(0x16); TEMPLATE_HEIGHT = System.Windows.Forms.DpiHelper.LogicalToDeviceUnitsY(0x13); TOOLSTRIP_TEMPLATE_WIDTH = System.Windows.Forms.DpiHelper.LogicalToDeviceUnitsX(0x5c); TEMPLATE_WIDTH = System.Windows.Forms.DpiHelper.LogicalToDeviceUnitsX(0x1f); TEMPLATE_HOTREGION_WIDTH = System.Windows.Forms.DpiHelper.LogicalToDeviceUnitsX(9); MINITOOLSTRIP_DROPDOWN_BUTTON_WIDTH = System.Windows.Forms.DpiHelper.LogicalToDeviceUnitsX(11); MINITOOLSTRIP_TEXTBOX_WIDTH = System.Windows.Forms.DpiHelper.LogicalToDeviceUnitsX(90); } isScalingInitialized = true; } this.SetupNewEditNode(this, text, image, component); this.commands = new MenuCommand[] { new MenuCommand(new EventHandler(this.OnMenuCut), MenuCommands.KeyMoveUp), new MenuCommand(new EventHandler(this.OnMenuCut), MenuCommands.KeyMoveDown), new MenuCommand(new EventHandler(this.OnMenuCut), MenuCommands.KeyMoveLeft), new MenuCommand(new EventHandler(this.OnMenuCut), MenuCommands.KeyMoveRight), new MenuCommand(new EventHandler(this.OnMenuCut), StandardCommands.Delete), new MenuCommand(new EventHandler(this.OnMenuCut), StandardCommands.Cut), new MenuCommand(new EventHandler(this.OnMenuCut), StandardCommands.Copy), new MenuCommand(new EventHandler(this.OnMenuCut), MenuCommands.KeyNudgeUp), new MenuCommand(new EventHandler(this.OnMenuCut), MenuCommands.KeyNudgeDown), new MenuCommand(new EventHandler(this.OnMenuCut), MenuCommands.KeyNudgeLeft), new MenuCommand(new EventHandler(this.OnMenuCut), MenuCommands.KeyNudgeRight), new MenuCommand(new EventHandler(this.OnMenuCut), MenuCommands.KeySizeWidthIncrease), new MenuCommand(new EventHandler(this.OnMenuCut), MenuCommands.KeySizeHeightIncrease), new MenuCommand(new EventHandler(this.OnMenuCut), MenuCommands.KeySizeWidthDecrease), new MenuCommand(new EventHandler(this.OnMenuCut), MenuCommands.KeySizeHeightDecrease), new MenuCommand(new EventHandler(this.OnMenuCut), MenuCommands.KeyNudgeWidthIncrease), new MenuCommand(new EventHandler(this.OnMenuCut), MenuCommands.KeyNudgeHeightIncrease), new MenuCommand(new EventHandler(this.OnMenuCut), MenuCommands.KeyNudgeWidthDecrease), new MenuCommand(new EventHandler(this.OnMenuCut), MenuCommands.KeyNudgeHeightDecrease) }; this.addCommands = new MenuCommand[] { new MenuCommand(new EventHandler(this.OnMenuCut), StandardCommands.Undo), new MenuCommand(new EventHandler(this.OnMenuCut), StandardCommands.Redo) }; }
protected override IComponent[] CreateComponentsCore(IDesignerHost designerHost) { CompositeActivity activity = new IfElseActivity { Activities = { new IfElseBranchActivity(), new IfElseBranchActivity() } }; return new IComponent[] { activity }; }
public void GenButtons(object sender, EventArgs e) { if (schedule == null) { schedule = this.Component as AjaxSchedule; } if (schedule.ScheduleButtons.Count == 0) { if (host == null) { host = (IDesignerHost)this.GetService(typeof(IDesignerHost)); } if (svcCompChange == null) { svcCompChange = (IComponentChangeService)this.GetService(typeof(IComponentChangeService)); } DesignerTransaction trans = host.CreateTransaction("Generate buttons"); this.addButton(AjaxScheduleButtonType.PreviousYear, "<<"); this.addButton(AjaxScheduleButtonType.Previous, "<"); this.addButton(AjaxScheduleButtonType.NextYear, ">>"); this.addButton(AjaxScheduleButtonType.Next, ">"); this.addButton(AjaxScheduleButtonType.Today, "today"); this.addButton(AjaxScheduleButtonType.Month, "month"); this.addButton(AjaxScheduleButtonType.Week, "week"); this.addButton(AjaxScheduleButtonType.Day, "day"); trans.Commit(); MessageBox.Show("generate buttons successful!"); } }
private string[] GetControls(IDesignerHost host, object instance) { IContainer container = host.Container; IComponent component = instance as IComponent; if ((component != null) && (component.Site != null)) { container = component.Site.Container; } if (container == null) { return null; } ComponentCollection components = container.Components; ArrayList list = new ArrayList(); foreach (IComponent component2 in components) { Control control = component2 as Control; if ((((control != null) && (control != instance)) && ((control != host.RootComponent) && (control.ID != null))) && ((control.ID.Length > 0) && this.FilterControl(control))) { list.Add(control.ID); } } list.Sort(Comparer.Default); return (string[]) list.ToArray(typeof(string)); }
public static object DoInTransaction(IDesignerHost theHost, string theTransactionName, TransactionAwareParammedMethod theMethod, object theParam) { DesignerTransaction transaction = null; object obj2 = null; try { transaction = theHost.CreateTransaction(theTransactionName); obj2 = theMethod(theHost, theParam); } catch (CheckoutException exception) { if (exception != CheckoutException.Canceled) { throw exception; } } catch { if (transaction != null) { transaction.Cancel(); transaction = null; } throw; } finally { if (transaction != null) { transaction.Commit(); } } return obj2; }
protected override IComponent[] CreateComponentsCore(IDesignerHost designerHost) { CompositeActivity activity = new ListenActivity { Activities = { new EventDrivenActivity(), new EventDrivenActivity() } }; return new IComponent[] { activity }; }
public SelectionUIService(IDesignerHost host) { base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.StandardClick | ControlStyles.Opaque, true); this.host = host; this.dragHandler = null; this.dragComponents = null; this.selectionItems = new Hashtable(); this.selectionHandlers = new Hashtable(); this.AllowDrop = true; this.Text = "SelectionUIOverlay"; this.selSvc = (ISelectionService) host.GetService(typeof(ISelectionService)); if (this.selSvc != null) { this.selSvc.SelectionChanged += new EventHandler(this.OnSelectionChanged); } host.TransactionOpened += new EventHandler(this.OnTransactionOpened); host.TransactionClosed += new DesignerTransactionCloseEventHandler(this.OnTransactionClosed); if (host.InTransaction) { this.OnTransactionOpened(host, EventArgs.Empty); } IComponentChangeService service = (IComponentChangeService) host.GetService(typeof(IComponentChangeService)); if (service != null) { service.ComponentRemoved += new ComponentEventHandler(this.OnComponentRemove); service.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged); } SystemEvents.DisplaySettingsChanged += new EventHandler(this.OnSystemSettingChanged); SystemEvents.InstalledFontsChanged += new EventHandler(this.OnSystemSettingChanged); SystemEvents.UserPreferenceChanged += new UserPreferenceChangedEventHandler(this.OnUserPreferenceChanged); }
public CodeDomHostLoader(IDesignerHost host, string formFile, string unitFile) { _trs = host.GetService(typeof(ITypeResolutionService)) as TypeResolutionService; this.formFile = formFile; this.unitFile = unitFile; this.host = host; }
public InfoTransactionEditorDialog(InfoTransaction trans, IDesignerHost host) { transaction = trans; DesignerHost = host; InitializeComponent(); }
protected override IComponent[] CreateComponentsCore(IDesignerHost designerHost) { CompositeActivity conditionalActivity = new IfElseActivity(); conditionalActivity.Activities.Add(new IfElseBranchActivity()); conditionalActivity.Activities.Add(new IfElseBranchActivity()); return (IComponent[])new IComponent[] { conditionalActivity }; }
public JQSecurityForm(JQSecurity jqs, IDesignerHost host) { InitializeComponent(); DesignerHost = host; ict = host.Container; jqSecurity = jqs; }
public static RootDesignerView GetInstance (IDesignerHost host) { if (instance == null) instance = new RootDesignerView (host); instance.active = false; return instance; }
public ThemeProvider(IDesignerHost host, string name, string themeDefinition, string[] cssFiles, string themePath) { this._themeName = name; this._themePath = themePath; this._cssFiles = cssFiles; this._host = host; ControlBuilder builder = DesignTimeTemplateParser.ParseTheme(host, themeDefinition, themePath); this._contentHashCode = themeDefinition.GetHashCode(); ArrayList subBuilders = builder.SubBuilders; this._skinBuilders = new Hashtable(); for (int i = 0; i < subBuilders.Count; i++) { ControlBuilder builder2 = subBuilders[i] as ControlBuilder; if (builder2 != null) { IDictionary dictionary = this._skinBuilders[builder2.ControlType] as IDictionary; if (dictionary == null) { dictionary = new SortedList(StringComparer.OrdinalIgnoreCase); this._skinBuilders[builder2.ControlType] = dictionary; } Control control = builder2.BuildObject() as Control; if (control != null) { dictionary[control.SkinID] = builder2; } } } }
public TemplateEditingService (IDesignerHost designerHost) { if (designerHost == null) throw new ArgumentNullException ("designerHost"); _designerHost = designerHost; }
protected override IComponent[] CreateComponentsCore(IDesignerHost designerHost) { CompositeActivity parallelActivity = new ParallelActivity(); parallelActivity.Activities.Add(new SequenceActivity()); parallelActivity.Activities.Add(new SequenceActivity()); return (IComponent[])new IComponent[] { parallelActivity }; }
public static string GetUniqueSiteName(IDesignerHost host, string name) { if (string.IsNullOrEmpty(name)) { return null; } INameCreationService service = (INameCreationService)host.GetService(typeof(INameCreationService)); if (service == null) { return null; } if (host.Container.Components[name] == null) { if (!service.IsValidName(name)) { return null; } return name; } string str = name; for (int i = 1; !service.IsValidName(str); i++) { str = name + i.ToString(CultureInfo.InvariantCulture); } return str; }
protected override IComponent[] CreateComponentsCore(IDesignerHost designerHost) { CompositeActivity activity = new ParallelActivity { Activities = { new SequenceActivity(), new SequenceActivity() } }; return new IComponent[] { activity }; }
private static void SelectWizard(IComponent wizardControl, IDesignerHost host) { if (wizardControl == null) { return; } if (host == null) { return; } while (true) { WizardDesigner designer = (WizardDesigner) host.GetDesigner(wizardControl); if (designer == null) { return; } ISelectionService service = (ISelectionService) host.GetService(typeof (ISelectionService)); if (service == null) { return; } object[] components = new object[] {wizardControl}; service.SetSelectedComponents(components, SelectionTypes.Replace); return; } }
/// <devdoc> /// Returns a list of all control IDs in the container. /// </devdoc> private string[] GetControls(IDesignerHost host, object instance) { IContainer container = host.Container; // Locate nearest container IComponent component = instance as IComponent; if (component != null && component.Site != null) { container = component.Site.Container; } if (container == null) { return null; } ComponentCollection allComponents = container.Components; ArrayList array = new ArrayList(); // For each control in the container foreach (IComponent comp in (IEnumerable)allComponents) { Control control = comp as Control; // Ignore DesignerHost.RootComponent (Page or UserControl), controls that don't have ID's, // and the Control itself if (control != null && control != instance && control != host.RootComponent && control.ID != null && control.ID.Length > 0 && FilterControl(control)) { array.Add(control.ID); } } array.Sort(Comparer.Default); return (string[])array.ToArray(typeof(string)); }
/// <summary> /// Event handler for the "Add Page" verb. /// </summary> /// <param name="dh"></param> /// <param name="panel"></param> private static void AddPage(IDesignerHost dh, MultiPanel panel) { DesignerTransaction dt = dh.CreateTransaction("Added new page"); // Gets a free name int i = 1; while (panel.Controls.Cast<Control>().Any(x => x.Name == "Page" + i)) { i++; } string name = "Page" + i; // Creates the page MultiPanelPage newPage = dh.CreateComponent(typeof(MultiPanelPage), name) as MultiPanelPage; if (newPage != null) { newPage.Text = name; panel.Controls.Add(newPage); // Update selection panel.SelectedPage = newPage; } dt.Commit(); }
internal DropSourceBehavior(ICollection dragComponents, Control source, Point initialMouseLocation) { this.serviceProviderSource = source.Site; if (this.serviceProviderSource != null) { this.behaviorServiceSource = (BehaviorService) this.serviceProviderSource.GetService(typeof(BehaviorService)); if ((this.behaviorServiceSource != null) && ((dragComponents != null) && (dragComponents.Count > 0))) { this.srcHost = (IDesignerHost) this.serviceProviderSource.GetService(typeof(IDesignerHost)); if (this.srcHost != null) { this.data = new BehaviorDataObject(dragComponents, source, this); this.allowedEffects = DragDropEffects.Move | DragDropEffects.Copy; this.dragComponents = new DragComponent[dragComponents.Count]; this.parentGridSize = Size.Empty; this.lastEffect = DragDropEffects.None; this.lastFeedbackLocation = new Point(-1, -1); this.lastSnapOffset = Point.Empty; this.dragImageRect = Rectangle.Empty; this.clearDragImageRect = Rectangle.Empty; this.InitiateDrag(initialMouseLocation, dragComponents); } } } }
public SampleToolboxService(IDesignerHost host) { this.host = host; // Our MainForm adds our ToolboxPane to the host's services. toolbox = host.GetService(typeof(SampleDesignerApplication.ToolBoxPane)) as SampleDesignerApplication.ToolBoxPane; }
protected override IComponent[] CreateComponentsCore(IDesignerHost designerHost) { CompositeActivity listenActivity = new ListenActivity(); listenActivity.Activities.Add(new EventDrivenActivity()); listenActivity.Activities.Add(new EventDrivenActivity()); return (IComponent[])new IComponent[] { listenActivity }; }
public override void DataBindControl(IDesignerHost designerHost, Control control) { DataBinding runtimeDataBinding = ((IDataBindingsAccessor) control).DataBindings["Text"]; if (runtimeDataBinding != null) { PropertyInfo property = control.GetType().GetProperty("Text"); if ((property != null) && (property.PropertyType == typeof(string))) { DesignTimeDataBinding binding2 = new DesignTimeDataBinding(runtimeDataBinding); string str = string.Empty; if (!binding2.IsCustom) { try { str = DataBinder.Eval(((IDataItemContainer) control.NamingContainer).DataItem, binding2.Field, binding2.Format); } catch { } } if ((str == null) || (str.Length == 0)) { str = System.Design.SR.GetString("Sample_Databound_Text"); } property.SetValue(control, str, null); } } }
public bool IsSupported(object serializedObject, IDesignerHost host) { return(true); }
public ToolboxItemCollection GetToolboxItems(string category, IDesignerHost host) { throw new NotImplementedException(); }
public ToolboxItem GetSelectedToolboxItem(IDesignerHost host) { return(this.selectedItem); }
public ToolboxItem DeserializeToolboxItem(object serializedObject, IDesignerHost host) { ToolboxItem item = (ToolboxItem)((System.Windows.Forms.IDataObject)serializedObject).GetData(typeof(ToolboxItem)); return(item); }
public static void Check(MeasureGroup mg, IDesignerHost designer) { if (mg.Measures.Count == 0) { throw new Exception(mg.Name + " has no measures."); } if (mg.IsLinked) { throw new Exception(mg.Name + " is a linked measure group. Run this Measure Group Health Check on the source measure group."); } DataSource oDataSource = mg.Parent.DataSource; DsvTableBinding oTblBinding = new DsvTableBinding(mg.Parent.DataSourceView.ID, GetTableIdForDataItem(mg.Measures[0].Source)); DataTable dtTable = mg.ParentDatabase.DataSourceViews[oTblBinding.DataSourceViewID].Schema.Tables[oTblBinding.TableID]; //check whether this fact table uses an alternate datasource if (dtTable.ExtendedProperties.ContainsKey("DataSourceID")) { oDataSource = mg.ParentDatabase.DataSources[dtTable.ExtendedProperties["DataSourceID"].ToString()]; } Microsoft.DataWarehouse.Design.DataSourceConnection openedDataSourceConnection = Microsoft.DataWarehouse.DataWarehouseUtilities.GetOpenedDataSourceConnection((object)null, oDataSource.ID, oDataSource.Name, oDataSource.ManagedProvider, oDataSource.ConnectionString, oDataSource.Site, false); try { if (openedDataSourceConnection != null) { openedDataSourceConnection.QueryTimeOut = (int)oDataSource.Timeout.TotalSeconds; } } catch { } if (openedDataSourceConnection == null) { MessageBox.Show("Unable to connect to data source [" + oDataSource.Name + "]"); return; } sq = openedDataSourceConnection.Cartridge.IdentStartQuote; fq = openedDataSourceConnection.Cartridge.IdentEndQuote; string sBitSqlDatatype = "bit"; string sCountBig = "count_big("; string sCountBigEnd = ")"; string sFloorFunctionBegin = "floor("; string sFloorFunctionEnd = ")"; if (openedDataSourceConnection.DBServerName == "Oracle") { sBitSqlDatatype = "number(1,0)"; sCountBig = "count("; } else if (openedDataSourceConnection.DBServerName == "Teradata") { sBitSqlDatatype = "numeric(1,0)"; sCountBig = "cast(count("; sCountBigEnd = ") as bigint)"; sFloorFunctionBegin = "cast("; sFloorFunctionEnd = " as bigint)"; } string sFactQuery = GetQueryDefinition(mg.ParentDatabase, mg, oTblBinding, null); StringBuilder sOuterQuery = new StringBuilder(); foreach (Measure m in mg.Measures) { //TODO: measure expressions if ((m.AggregateFunction == AggregationFunction.Sum && !(m.Source.Source is RowBinding)) || m.AggregateFunction == AggregationFunction.AverageOfChildren || m.AggregateFunction == AggregationFunction.ByAccount || m.AggregateFunction == AggregationFunction.FirstChild || m.AggregateFunction == AggregationFunction.FirstNonEmpty || m.AggregateFunction == AggregationFunction.LastChild || m.AggregateFunction == AggregationFunction.LastNonEmpty || m.AggregateFunction == AggregationFunction.Min || m.AggregateFunction == AggregationFunction.Max || m.AggregateFunction == AggregationFunction.None) { ColumnBinding cb = GetColumnBindingForDataItem(m.Source); DataColumn col = mg.Parent.DataSourceView.Schema.Tables[cb.TableID].Columns[cb.ColumnID]; if (col.DataType == typeof(DateTime)) { continue; //DateTime not supported by BIDS Helper except for count and distinct count aggregates } if (sOuterQuery.Length > 0) { sOuterQuery.Append(","); } else { sOuterQuery.Append("select "); } string sNegativeSign = string.Empty; if (col.DataType == typeof(bool)) { sNegativeSign = "-"; //true in sql is 1, but SSAS treats true as -1 } if (m.AggregateFunction == AggregationFunction.Min || m.AggregateFunction == AggregationFunction.Max || m.AggregateFunction == AggregationFunction.None) { sOuterQuery.Append("max(").Append(sNegativeSign).Append("cast(").Append(sq).Append(cb.ColumnID).Append(fq).Append(" as float))").AppendLine(); } else { sOuterQuery.Append("sum(").Append(sNegativeSign).Append("cast(").Append(sq).Append(cb.ColumnID).Append(fq).Append(" as float))").AppendLine(); } sOuterQuery.Append(",min(").Append(sNegativeSign).Append("cast(").Append(sq).Append(cb.ColumnID).Append(fq).Append(" as float))").AppendLine(); sOuterQuery.Append(",max(").Append(sNegativeSign).Append("cast(").Append(sq).Append(cb.ColumnID).Append(fq).Append(" as float))").AppendLine(); sOuterQuery.Append(",cast(max(case when ").Append(sFloorFunctionBegin).Append(sq).Append(cb.ColumnID).Append(fq).Append(sFloorFunctionEnd).Append(" <> ").Append(sq).Append(cb.ColumnID).Append(fq).Append(" then 1 else 0 end) as ").Append(sBitSqlDatatype).Append(")").AppendLine(); sOuterQuery.Append(",cast(max(case when ").Append(sFloorFunctionBegin).Append(sq).Append(cb.ColumnID).Append(fq).Append("*10000.0").Append(sFloorFunctionEnd).Append(" <> cast(").Append(sq).Append(cb.ColumnID).Append(fq).Append("*10000.0 as float) then 1 else 0 end) as ").Append(sBitSqlDatatype).Append(")").AppendLine(); } else if (m.AggregateFunction == AggregationFunction.Count || m.AggregateFunction == AggregationFunction.DistinctCount || (m.AggregateFunction == AggregationFunction.Sum && m.Source.Source is RowBinding)) { if (sOuterQuery.Length > 0) { sOuterQuery.Append(","); } else { sOuterQuery.Append("select "); } if (m.Source.Source is RowBinding) { if (m.AggregateFunction == AggregationFunction.DistinctCount) { throw new Exception("RowBinding on a distinct count not allowed by Analysis Services"); } else { sOuterQuery.Append(sCountBig).Append("*").Append(sCountBigEnd).AppendLine(); } sOuterQuery.Append(",0").AppendLine(); sOuterQuery.Append(",1").AppendLine(); sOuterQuery.Append(",cast(0 as ").Append(sBitSqlDatatype).Append(")").AppendLine(); sOuterQuery.Append(",cast(0 as ").Append(sBitSqlDatatype).Append(")").AppendLine(); } else { ColumnBinding cb = GetColumnBindingForDataItem(m.Source); DataColumn col = mg.Parent.DataSourceView.Schema.Tables[cb.TableID].Columns[cb.ColumnID]; if (m.AggregateFunction == AggregationFunction.DistinctCount) { sOuterQuery.Append(sCountBig).Append("distinct ").Append(sq).Append(cb.ColumnID).Append(fq).Append(sCountBigEnd).AppendLine(); } else if (col.DataType == typeof(Byte[])) { sOuterQuery.Append("sum(cast(case when ").Append(sq).Append(cb.ColumnID).Append(fq).Append(" is not null then 1 else 0 end as float))").AppendLine(); } else { sOuterQuery.Append(sCountBig).Append(sq).Append(cb.ColumnID).Append(fq).Append(sCountBigEnd).AppendLine(); } sOuterQuery.Append(",0").AppendLine(); sOuterQuery.Append(",1").AppendLine(); sOuterQuery.Append(",cast(0 as ").Append(sBitSqlDatatype).Append(")").AppendLine(); sOuterQuery.Append(",cast(0 as ").Append(sBitSqlDatatype).Append(")").AppendLine(); } } else { throw new Exception("Aggregation function " + m.AggregateFunction.ToString() + " not supported!"); } } if (sOuterQuery.Length == 0) { return; } sOuterQuery.AppendLine("from (").Append(sFactQuery).AppendLine(") fact"); DataSet ds = new DataSet(); //openedDataSourceConnection.QueryTimeOut = 0; //just inherit from the datasource openedDataSourceConnection.Fill(ds, sOuterQuery.ToString()); DataRow row = ds.Tables[0].Rows[0]; openedDataSourceConnection.Close(); List <MeasureHealthCheckResult> measureResults = new List <MeasureHealthCheckResult>(); int i = 0; foreach (Measure m in mg.Measures) { if (m.AggregateFunction == AggregationFunction.Sum || m.AggregateFunction == AggregationFunction.AverageOfChildren || m.AggregateFunction == AggregationFunction.ByAccount || m.AggregateFunction == AggregationFunction.FirstChild || m.AggregateFunction == AggregationFunction.FirstNonEmpty || m.AggregateFunction == AggregationFunction.LastChild || m.AggregateFunction == AggregationFunction.LastNonEmpty || m.AggregateFunction == AggregationFunction.Count || m.AggregateFunction == AggregationFunction.DistinctCount || m.AggregateFunction == AggregationFunction.Min || m.AggregateFunction == AggregationFunction.Max || m.AggregateFunction == AggregationFunction.None) { double dsvColMaxValue = 0; bool dsvColAllowsDecimals = false; if (m.Source.Source is ColumnBinding && m.AggregateFunction != AggregationFunction.Count && m.AggregateFunction != AggregationFunction.DistinctCount) { ColumnBinding cb = GetColumnBindingForDataItem(m.Source); DataColumn col = mg.Parent.DataSourceView.Schema.Tables[cb.TableID].Columns[cb.ColumnID]; if (col.DataType == typeof(DateTime)) { continue; //DateTime not supported by BIDS Helper except for count and distinct count aggregates } MeasureDataTypeOption dsvOption = GetMeasureDataTypeOptionForType(col.DataType); if (dsvOption != null) { dsvColMaxValue = dsvOption.max; dsvColAllowsDecimals = dsvOption.allowsDecimals; } } double?total = (!Convert.IsDBNull(row[i * 5]) ? Convert.ToDouble(row[i * 5]) : (double?)null); double?min = (!Convert.IsDBNull(row[i * 5 + 1]) ? Convert.ToDouble(row[i * 5 + 1]) : (double?)null); double?max = (!Convert.IsDBNull(row[i * 5 + 2]) ? Convert.ToDouble(row[i * 5 + 2]) : (double?)null); bool hasDecimals = (!Convert.IsDBNull(row[i * 5 + 3]) ? Convert.ToBoolean(row[i * 5 + 3]) : false); bool hasMoreThan4Decimals = (!Convert.IsDBNull(row[i * 5 + 4]) ? Convert.ToBoolean(row[i * 5 + 4]) : false); MeasureDataTypeOption oldDataTypeOption = GetMeasureDataTypeOptionForMeasure(m); double recommendedMaxValue = double.MaxValue; List <MeasureDataTypeOption> possible = new List <MeasureDataTypeOption>(); foreach (MeasureDataTypeOption option in dataTypeOptions) { if ( (total == null || (option.max >= total && option.min <= total)) && (max == null || option.max >= max) && (min == null || option.min <= min) && (!hasDecimals || option.allowsDecimals) && (!hasMoreThan4Decimals || option.allowsMoreThan4Decimals) ) { possible.Add(option); if ( (total == null || (total * FreeSpaceFactor < option.max && total * FreeSpaceFactor > option.min)) && option.max < recommendedMaxValue && option.max >= dsvColMaxValue && (dsvColAllowsDecimals == option.allowsDecimals) && (option.oleDbType != OleDbType.Single) //never recommend Single ) { recommendedMaxValue = option.max; } } } foreach (MeasureDataTypeOption option in dataTypeOptions) { if (option.max == recommendedMaxValue) { Type dsvDataType = null; //don't bother getting the DSV datatype for count or DistinctCount measures if (m.Source.Source is ColumnBinding && m.AggregateFunction != AggregationFunction.Count && m.AggregateFunction != AggregationFunction.DistinctCount) { ColumnBinding cb = GetColumnBindingForDataItem(m.Source); DataColumn col = mg.Parent.DataSourceView.Schema.Tables[cb.TableID].Columns[cb.ColumnID]; dsvDataType = col.DataType; } MeasureHealthCheckResult result = new MeasureHealthCheckResult(m, FormatDouble(total), FormatDouble(min), FormatDouble(max), hasDecimals, hasMoreThan4Decimals, possible.ToArray(), option, oldDataTypeOption, dsvDataType); measureResults.Add(result); break; } } i++; } else { throw new Exception("Aggregation function " + m.AggregateFunction.ToString() + " not supported"); } } BIDSHelper.SSAS.MeasureGroupHealthCheckForm form = new BIDSHelper.SSAS.MeasureGroupHealthCheckForm(); form.measureDataTypeOptionBindingSource.DataSource = dataTypeOptions; form.measureHealthCheckResultBindingSource.DataSource = measureResults; form.Text = "Measure Group Health Check: " + mg.Name; DialogResult dialogResult = form.ShowDialog(); if (dialogResult == DialogResult.OK) { foreach (MeasureHealthCheckResult r in measureResults) { if (r.CurrentDataType != r.DataType) { //save change if (r.Measure.AggregateFunction == AggregationFunction.Count || r.Measure.AggregateFunction == AggregationFunction.DistinctCount) { r.Measure.DataType = r.DataType.dataType; } else { r.Measure.Source.DataType = r.DataType.oleDbType; r.Measure.DataType = MeasureDataType.Inherited; } //mark cube object as dirty IComponentChangeService changesvc = (IComponentChangeService)designer.GetService(typeof(IComponentChangeService)); changesvc.OnComponentChanging(mg.Parent, null); changesvc.OnComponentChanged(mg.Parent, null, null, null); //marks the cube designer as dirty } } } }
public void AddCreator(ToolboxItemCreatorCallback creator, string format, IDesignerHost host) { // System.Console.WriteLine(" AddCreator for"); // System.Console.WriteLine("\t {0} / {1} / {2}",creator.ToString(),format,host.ToString()); }
/// <include file='doc\ControlCommandSet.uex' path='docs/doc[@for="ControlCommandSet.OnMenuZOrderSelection"]/*' /> /// <devdoc> /// Called when the zorder->send to back menu item is selected. /// </devdoc> private void OnMenuZOrderSelection(object sender, EventArgs e) { MenuCommand cmd = (MenuCommand)sender; CommandID cmdID = cmd.CommandID; Debug.Assert(SelectionService != null, "Need SelectionService for sizing command"); if (SelectionService == null) { return; } Cursor oldCursor = Cursor.Current; try { Cursor.Current = Cursors.WaitCursor; IComponentChangeService ccs = (IComponentChangeService)GetService(typeof(IComponentChangeService)); IDesignerHost designerHost = (IDesignerHost)GetService(typeof(IDesignerHost)); DesignerTransaction trans = null; try { string batchString; // NOTE: this only works on Control types ICollection sel = SelectionService.GetSelectedComponents(); object[] selectedComponents = new object[sel.Count]; sel.CopyTo(selectedComponents, 0); if (cmdID == MenuCommands.BringToFront) { batchString = SR.GetString(SR.CommandSetBringToFront, selectedComponents.Length); } else { batchString = SR.GetString(SR.CommandSetSendToBack, selectedComponents.Length); } // sort the components by their current zOrder Array.Sort(selectedComponents, new ControlComparer()); trans = designerHost.CreateTransaction(batchString); int len = selectedComponents.Length; for (int i = len - 1; i >= 0; i--) { if (selectedComponents[i] is Control) { Control parent = ((Control)selectedComponents[i]).Parent; PropertyDescriptor controlsProp = null; if (ccs != null && parent != null) { try { controlsProp = TypeDescriptor.GetProperties(parent)["Controls"]; if (controlsProp != null) { ccs.OnComponentChanging(parent, controlsProp); } } catch (CheckoutException ex) { if (ex == CheckoutException.Canceled) { return; } throw ex; } } if (cmdID == MenuCommands.BringToFront) { // we do this backwards to maintain zorder Control otherControl = selectedComponents[len - i - 1] as Control; if (otherControl != null) { otherControl.BringToFront(); } } else if (cmdID == MenuCommands.SendToBack) { ((Control)selectedComponents[i]).SendToBack(); } if (ccs != null) { if (controlsProp != null && parent != null) { ccs.OnComponentChanged(parent, controlsProp, null, null); } } } } } finally { // now we need to regenerate so the ordering is right. if (trans != null) { trans.Commit(); } } } finally { Cursor.Current = oldCursor; } }
/// <include file='doc\ControlCommandSet.uex' path='docs/doc[@for="ControlCommandSet.OnKeySize"]/*' /> /// <devdoc> /// Called for the various sizing commands we support. /// </devdoc> protected void OnKeySize(object sender, EventArgs e) { // Arrow keys. Begin a drag if the selection isn't locked. // ISelectionService selSvc = SelectionService; ISelectionUIService uiSvc = SelectionUIService; if (uiSvc != null && selSvc != null) { //added to remove the selection rectangle: bug(54692) // uiSvc.Visible = false; object comp = selSvc.PrimarySelection; if (comp != null && comp is IComponent) { PropertyDescriptor lockedProp = TypeDescriptor.GetProperties(comp)["Locked"]; if (lockedProp == null || (lockedProp.PropertyType == typeof(bool) && ((bool)lockedProp.GetValue(comp))) == false) { SelectionRules rules = SelectionRules.Visible; CommandID cmd = ((MenuCommand)sender).CommandID; bool invertSnap = false; int moveOffsetX = 0; int moveOffsetY = 0; if (cmd.Equals(MenuCommands.KeySizeHeightDecrease)) { moveOffsetY = -1; rules |= SelectionRules.BottomSizeable; } else if (cmd.Equals(MenuCommands.KeySizeHeightIncrease)) { moveOffsetY = 1; rules |= SelectionRules.BottomSizeable; } else if (cmd.Equals(MenuCommands.KeySizeWidthDecrease)) { moveOffsetX = -1; rules |= SelectionRules.RightSizeable; } else if (cmd.Equals(MenuCommands.KeySizeWidthIncrease)) { moveOffsetX = 1; rules |= SelectionRules.RightSizeable; } else if (cmd.Equals(MenuCommands.KeyNudgeHeightDecrease)) { moveOffsetY = -1; invertSnap = true; rules |= SelectionRules.BottomSizeable; } else if (cmd.Equals(MenuCommands.KeyNudgeHeightIncrease)) { moveOffsetY = 1; invertSnap = true; rules |= SelectionRules.BottomSizeable; } else if (cmd.Equals(MenuCommands.KeyNudgeWidthDecrease)) { moveOffsetX = -1; invertSnap = true; rules |= SelectionRules.RightSizeable; } else if (cmd.Equals(MenuCommands.KeyNudgeWidthIncrease)) { moveOffsetX = 1; invertSnap = true; rules |= SelectionRules.RightSizeable; } else { Debug.Fail("Unknown command mapped to OnKeySize: " + cmd.ToString()); } if (uiSvc.BeginDrag(rules, 0, 0)) { bool snapOn = false; Size snapSize = Size.Empty; IComponent snapComponent = null; PropertyDescriptor snapProperty = null; // Gets the needed snap information // IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); DesignerTransaction trans = null; try { if (host != null) { GetSnapInformation(host, (IComponent)comp, out snapSize, out snapComponent, out snapProperty); if (selSvc.SelectionCount > 1) { trans = host.CreateTransaction(SR.GetString(SR.DragDropSizeComponents, selSvc.SelectionCount)); } else { trans = host.CreateTransaction(SR.GetString(SR.DragDropSizeComponent, ((IComponent)comp).Site.Name)); } if (snapProperty != null) { snapOn = (bool)snapProperty.GetValue(snapComponent); if (invertSnap) { snapOn = !snapOn; snapProperty.SetValue(snapComponent, snapOn); } } } if (snapOn && !snapSize.IsEmpty) { moveOffsetX *= snapSize.Width; moveOffsetY *= snapSize.Height; } // Now move the controls the correct # of pixels. // uiSvc.DragMoved(new Rectangle(0, 0, moveOffsetX, moveOffsetY)); uiSvc.EndDrag(false); if (host != null) { if (invertSnap && snapProperty != null) { snapOn = !snapOn; snapProperty.SetValue(snapComponent, snapOn); } } } finally { if (trans != null) { trans.Commit(); uiSvc.Visible = true; } } } } } uiSvc.Visible = true; } }
/// <include file='doc\ControlCommandSet.uex' path='docs/doc[@for="ControlCommandSet.ControlCommandSet"]/*' /> /// <devdoc> /// Creates a new CommandSet object. This object implements the set /// of commands that the UI.Win32 form designer offers. /// </devdoc> public ControlCommandSet(ISite site) : base(site) { // Establish our set of commands // commandSet = new CommandSetItem[] { // Allignment commands new CommandSetItem( this, new EventHandler(OnStatusMultiSelectPrimary), new EventHandler(OnMenuAlignByPrimary), MenuCommands.AlignLeft), new CommandSetItem( this, new EventHandler(OnStatusMultiSelectPrimary), new EventHandler(OnMenuAlignByPrimary), MenuCommands.AlignTop), new CommandSetItem( this, new EventHandler(OnStatusControlsOnlySelection), new EventHandler(OnMenuAlignToGrid), MenuCommands.AlignToGrid), new CommandSetItem( this, new EventHandler(OnStatusMultiSelectPrimary), new EventHandler(OnMenuAlignByPrimary), MenuCommands.AlignBottom), new CommandSetItem( this, new EventHandler(OnStatusMultiSelectPrimary), new EventHandler(OnMenuAlignByPrimary), MenuCommands.AlignHorizontalCenters), new CommandSetItem( this, new EventHandler(OnStatusMultiSelectPrimary), new EventHandler(OnMenuAlignByPrimary), MenuCommands.AlignRight), new CommandSetItem( this, new EventHandler(OnStatusMultiSelectPrimary), new EventHandler(OnMenuAlignByPrimary), MenuCommands.AlignVerticalCenters), // Centering commands new CommandSetItem( this, new EventHandler(OnStatusControlsOnlySelection), new EventHandler(OnMenuCenterSelection), MenuCommands.CenterHorizontally), new CommandSetItem( this, new EventHandler(OnStatusControlsOnlySelection), new EventHandler(OnMenuCenterSelection), MenuCommands.CenterVertically), // Spacing commands new CommandSetItem( this, new EventHandler(OnStatusMultiSelect), new EventHandler(OnMenuSpacingCommand), MenuCommands.HorizSpaceConcatenate), new CommandSetItem( this, new EventHandler(OnStatusMultiSelect), new EventHandler(OnMenuSpacingCommand), MenuCommands.HorizSpaceDecrease), new CommandSetItem( this, new EventHandler(OnStatusMultiSelect), new EventHandler(OnMenuSpacingCommand), MenuCommands.HorizSpaceIncrease), new CommandSetItem( this, new EventHandler(OnStatusMultiSelect), new EventHandler(OnMenuSpacingCommand), MenuCommands.HorizSpaceMakeEqual), new CommandSetItem( this, new EventHandler(OnStatusMultiSelect), new EventHandler(OnMenuSpacingCommand), MenuCommands.VertSpaceConcatenate), new CommandSetItem( this, new EventHandler(OnStatusMultiSelect), new EventHandler(OnMenuSpacingCommand), MenuCommands.VertSpaceDecrease), new CommandSetItem( this, new EventHandler(OnStatusMultiSelect), new EventHandler(OnMenuSpacingCommand), MenuCommands.VertSpaceIncrease), new CommandSetItem( this, new EventHandler(OnStatusMultiSelect), new EventHandler(OnMenuSpacingCommand), MenuCommands.VertSpaceMakeEqual), // Sizing commands new CommandSetItem( this, new EventHandler(OnStatusMultiSelectPrimary), new EventHandler(OnMenuSizingCommand), MenuCommands.SizeToControl), new CommandSetItem( this, new EventHandler(OnStatusMultiSelectPrimary), new EventHandler(OnMenuSizingCommand), MenuCommands.SizeToControlWidth), new CommandSetItem( this, new EventHandler(OnStatusMultiSelectPrimary), new EventHandler(OnMenuSizingCommand), MenuCommands.SizeToControlHeight), new CommandSetItem( this, new EventHandler(OnStatusControlsOnlySelection), new EventHandler(OnMenuSizeToGrid), MenuCommands.SizeToGrid), // Z-Order commands new CommandSetItem( this, new EventHandler(OnStatusZOrder), new EventHandler(OnMenuZOrderSelection), MenuCommands.BringToFront), new CommandSetItem( this, new EventHandler(OnStatusZOrder), new EventHandler(OnMenuZOrderSelection), MenuCommands.SendToBack), // Miscellaneous commands new CommandSetItem( this, new EventHandler(OnStatusShowGrid), new EventHandler(OnMenuShowGrid), MenuCommands.ShowGrid), new CommandSetItem( this, new EventHandler(OnStatusSnapToGrid), new EventHandler(OnMenuSnapToGrid), MenuCommands.SnapToGrid), new CommandSetItem( this, new EventHandler(OnStatusAnyControls), new EventHandler(OnMenuTabOrder), MenuCommands.TabOrder), new CommandSetItem( this, new EventHandler(OnStatusLockControls), new EventHandler(OnMenuLockControls), MenuCommands.LockControls), // Keyboard commands new CommandSetItem( this, new EventHandler(OnStatusAlways), new EventHandler(OnKeySize), MenuCommands.KeySizeWidthIncrease), new CommandSetItem( this, new EventHandler(OnStatusAlways), new EventHandler(OnKeySize), MenuCommands.KeySizeHeightIncrease), new CommandSetItem( this, new EventHandler(OnStatusAlways), new EventHandler(OnKeySize), MenuCommands.KeySizeWidthDecrease), new CommandSetItem( this, new EventHandler(OnStatusAlways), new EventHandler(OnKeySize), MenuCommands.KeySizeHeightDecrease), new CommandSetItem( this, new EventHandler(OnStatusAlways), new EventHandler(OnKeySize), MenuCommands.KeyNudgeWidthIncrease), new CommandSetItem( this, new EventHandler(OnStatusAlways), new EventHandler(OnKeySize), MenuCommands.KeyNudgeHeightIncrease), new CommandSetItem( this, new EventHandler(OnStatusAlways), new EventHandler(OnKeySize), MenuCommands.KeyNudgeWidthDecrease), new CommandSetItem( this, new EventHandler(OnStatusAlways), new EventHandler(OnKeySize), MenuCommands.KeyNudgeHeightDecrease), new CommandSetItem( this, new EventHandler(OnStatusAlways), new EventHandler(OnKeySelect), MenuCommands.KeySelectNext), new CommandSetItem( this, new EventHandler(OnStatusAlways), new EventHandler(OnKeySelect), MenuCommands.KeySelectPrevious), }; if (MenuService != null) { for (int i = 0; i < commandSet.Length; i++) { MenuService.AddCommand(commandSet[i]); } } // Get the base control object. // IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); if (host != null) { IComponent comp = host.RootComponent; if (comp is Control) { baseControl = (Control)comp; } } }
/// <include file='doc\ControlCommandSet.uex' path='docs/doc[@for="ControlCommandSet.GetSnapInformation"]/*' /> /// <devdoc> /// Retrieves the snap information for the given component. /// </devdoc> protected override void GetSnapInformation(IDesignerHost host, IComponent component, out Size snapSize, out IComponent snapComponent, out PropertyDescriptor snapProperty) { IComponent currentSnapComponent = null; IContainer container = component.Site.Container; PropertyDescriptor gridSizeProp = null; PropertyDescriptor currentSnapProp = null; PropertyDescriptorCollection props; // This implementation is specific to controls. It looks in the parent hierarchy for an object with a // snap property. If it fails to find one, it just gets the base component. // if (component is Control) { Control c = ((Control)component).Parent; while (c != null && currentSnapComponent == null) { props = TypeDescriptor.GetProperties(c); currentSnapProp = props["SnapToGrid"]; if (currentSnapProp != null) { if (currentSnapProp.PropertyType == typeof(bool) && c.Site != null && c.Site.Container == container) { currentSnapComponent = c; } else { currentSnapProp = null; } } c = c.Parent; } } if (currentSnapComponent == null) { currentSnapComponent = host.RootComponent; } props = TypeDescriptor.GetProperties(currentSnapComponent); if (currentSnapProp == null) { currentSnapProp = props["SnapToGrid"]; if (currentSnapProp != null && currentSnapProp.PropertyType != typeof(bool)) { currentSnapProp = null; } } if (gridSizeProp == null) { gridSizeProp = props["GridSize"]; if (gridSizeProp != null && gridSizeProp.PropertyType != typeof(Size)) { gridSizeProp = null; } } // Finally, now that we've got the various properties and components, dole out the // values. // snapComponent = currentSnapComponent; snapProperty = currentSnapProp; if (gridSizeProp != null) { snapSize = (Size)gridSizeProp.GetValue(snapComponent); } else { snapSize = Size.Empty; } }
/// <include file='doc\ControlCommandSet.uex' path='docs/doc[@for="ControlCommandSet.RotateTabSelection"]/*' /> /// <devdoc> /// Rotates the selection to the element next in the tab index. If backwards /// is set, this will rotate to the previous tab index. /// </devdoc> private void RotateTabSelection(bool backwards) { Control ctl; Control baseCtl; object targetSelection = null; object currentSelection; ISelectionService selSvc = SelectionService; IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); if (selSvc == null || host == null || !(host.RootComponent is Control)) { return; } IContainer container = host.Container; baseCtl = (Control)host.RootComponent; // We must handle two cases of logic here. We are responsible for handling // selection within ourself, and also for components on the tray. For our // own tabbing around, we want to go by tab-order. When we get to the end // of the form, however, we go by selection order into the tray. And, // when we're at the end of the tray we start back at the form. We must // reverse this logic to go backwards. currentSelection = selSvc.PrimarySelection; if (currentSelection is Control) { // Our current selection is a control. Select the next control in // the z-order. // ctl = (Control)currentSelection; while (null != (ctl = baseCtl.GetNextControl(ctl, !backwards))) { if (ctl.Site != null && ctl.Site.Container == container) { break; } } targetSelection = ctl; } if (targetSelection == null) { ComponentTray tray = (ComponentTray)GetService(typeof(ComponentTray)); if (tray != null) { targetSelection = tray.GetNextComponent((IComponent)currentSelection, !backwards); } if (targetSelection == null) { targetSelection = baseCtl; } } selSvc.SetSelectedComponents(new object[] { targetSelection }, SelectionTypes.Replace); }
public ToolboxComponentsCreatingEventArgs(IDesignerHost host) { this.host = host; }
public void RemoveCreator(string format, IDesignerHost host) { System.Console.WriteLine("Toolbox:removeCreator"); throw new NotImplementedException(); }
public void AddLinkedToolboxItem(ToolboxItem toolboxItem, string category, IDesignerHost host) { AddItemToToolbox(toolboxItem, category, host); }
public ToolboxEventArgs(ToolboxItem item, string category, IDesignerHost host) { this.item = item; this.category = category; this.host = host; }
internal SingleSelectRootGridEntry(PropertyGridView gridEntryHost, object value, GridEntry parent, IServiceProvider baseProvider, IDesignerHost host, PropertyTab tab, PropertySort sortType) : base(gridEntryHost.OwnerGrid, parent) { Debug.Assert(value != null, "Can't browse a null object!"); this.host = host; this.gridEntryHost = gridEntryHost; this.baseProvider = baseProvider; this.tab = tab; this.objValue = value; this.objValueClassName = TypeDescriptor.GetClassName(this.objValue); this.IsExpandable = true; // default to categories this.PropertySort = sortType; this.InternalExpanded = true; }
public void AddLinkedToolboxItem(ToolboxItem toolboxItem, IDesignerHost host) { AddItemToToolbox(toolboxItem, null, host); }
internal SingleSelectRootGridEntry(PropertyGridView view, object value, IServiceProvider baseProvider, IDesignerHost host, PropertyTab tab, PropertySort sortType) : this(view, value, null, baseProvider, host, tab, sortType) { }
/// <include file='doc\ToolboxItem.uex' path='docs/doc[@for="ToolboxItem.GetType1"]/*' /> /// <devdoc> /// Allows access to the type associated with the toolbox item. /// The designer host is used to access an implementation of ITypeResolutionService. /// However, the loaded type is not added to the list of references in the designer host. /// </devdoc> public Type GetType(IDesignerHost host) { return(GetType(host, AssemblyName, TypeName, false)); }
protected virtual Type GetType(IDesignerHost host, AssemblyName assemblyName, string typeName, bool reference) { ITypeResolutionService ts = null; Type type = null; if (typeName == null) { throw new ArgumentNullException("typeName"); } if (host != null) { ts = (ITypeResolutionService)host.GetService(typeof(ITypeResolutionService)); } if (ts != null) { if (reference) { if (assemblyName != null) { ts.ReferenceAssembly(assemblyName); type = ts.GetType(typeName); } else { // Just try loading the type. If we succeed, then use this as the // reference. type = ts.GetType(typeName); if (type == null) { type = Type.GetType(typeName); } if (type != null) { ts.ReferenceAssembly(type.Assembly.GetName()); } } } else { if (assemblyName != null) { Assembly a = ts.GetAssembly(assemblyName); if (a != null) { type = a.GetType(typeName); } } if (type == null) { type = ts.GetType(typeName); } } } else { if (!String.IsNullOrEmpty(typeName)) { if (assemblyName != null) { Assembly a = null; try { a = Assembly.Load(assemblyName); } catch (FileNotFoundException) { } catch (BadImageFormatException) { } catch (IOException) { } if (a == null && assemblyName.CodeBase != null && assemblyName.CodeBase.Length > 0) { try { a = Assembly.LoadFrom(assemblyName.CodeBase); } catch (FileNotFoundException) { } catch (BadImageFormatException) { } catch (IOException) { } } if (a != null) { type = a.GetType(typeName); } } if (type == null) { type = Type.GetType(typeName, false); } } } return(type); }
public override void OnWindowActivated(Window GotFocus, Window LostFocus) { try { if (GotFocus == null) { return; } IDesignerHost designer = GotFocus.Object as IDesignerHost; if (designer == null) { return; } ProjectItem pi = GotFocus.ProjectItem; if ((pi == null) || (!(pi.Object is Cube))) { return; } EditorWindow win = (EditorWindow)designer.GetService(typeof(IComponentNavigator)); VsStyleToolBar toolbar = (VsStyleToolBar)win.SelectedView.GetType().InvokeMember("ToolBar", getflags, null, win.SelectedView, null); IntPtr ptr = win.Handle; string sHandle = ptr.ToInt64().ToString(); if (!windowHandlesFixedForM2M.ContainsKey(sHandle)) { windowHandlesFixedForM2M.Add(sHandle, win); win.ActiveViewChanged += new EventHandler(win_ActiveViewChanged); } if (win.SelectedView.MenuItemCommandID.ID == 12898) //language neutral way of saying win.SelectedView.Caption == "Dimension Usage" { if (!toolbar.Buttons.ContainsKey(this.FullName + ".M2M")) { newSeparatorButton = new ToolBarButton(); newSeparatorButton.Name = this.FullName + ".Separator"; newSeparatorButton.Style = ToolBarButtonStyle.Separator; toolbar.ImageList.Images.Add(BIDSHelper.Resources.Common.M2MIcon); newM2MButton = new ToolBarButton(); newM2MButton.ToolTipText = this.FeatureName + " (BIDS Helper)"; newM2MButton.Name = this.FullName + ".M2M"; newM2MButton.Tag = newM2MButton.Name; newM2MButton.ImageIndex = toolbar.ImageList.Images.Count - 1; newM2MButton.Enabled = true; newM2MButton.Style = ToolBarButtonStyle.PushButton; if (BIDSHelperPackage.Plugins[BaseName + typeof(PrinterFriendlyDimensionUsagePlugin).Name].Enabled) { toolbar.ImageList.Images.Add(BIDSHelper.Resources.Common.PrinterFriendlyDimensionUsageIcon); newPrintFriendlyButton = new ToolBarButton(); newPrintFriendlyButton.ToolTipText = "Printer Friendly Dimension Usage (BIDS Helper)"; newPrintFriendlyButton.Name = this.FullName + ".PrintFriendly"; newPrintFriendlyButton.Tag = newPrintFriendlyButton.Name; newPrintFriendlyButton.ImageIndex = toolbar.ImageList.Images.Count - 1; newPrintFriendlyButton.Enabled = true; newPrintFriendlyButton.Style = ToolBarButtonStyle.PushButton; } //catch the button clicks of the new buttons we just added toolbar.ButtonClick += new ToolBarButtonClickEventHandler(toolbar_ButtonClick); } if (newM2MButton != null && !toolbar.Buttons.Contains(newM2MButton)) { toolbar.Buttons.Add(newSeparatorButton); toolbar.Buttons.Add(newM2MButton); } if (newPrintFriendlyButton != null && !toolbar.Buttons.Contains(newPrintFriendlyButton)) { toolbar.Buttons.Add(newPrintFriendlyButton); } } } catch { } }
internal MultiSelectRootGridEntry(PropertyGridView view, object obj, IServiceProvider baseProvider, IDesignerHost host, PropertyTab tab, PropertySort sortType) : base(view, obj, baseProvider, host, tab, sortType) { }
protected virtual IComponent[] CreateComponentsCore(IDesignerHost host) { // TODO return(null); }
protected virtual Type GetType(IDesignerHost host, AssemblyName assemblyName, String typeName, bool reference) { // TODO return(null); }
/// <summary> /// Used to create copies of the objects that we are dragging in a drag operation /// </summary> public static ICollection CopyDragObjects(ICollection objects, IServiceProvider svcProvider) { if (objects == null || svcProvider == null) { Debug.Fail("Invalid parameter passed to DesignerUtils.CopyObjects."); return(null); } Cursor oldCursor = Cursor.Current; try { Cursor.Current = Cursors.WaitCursor; ComponentSerializationService css = svcProvider.GetService(typeof(ComponentSerializationService)) as ComponentSerializationService; IDesignerHost host = svcProvider.GetService(typeof(IDesignerHost)) as IDesignerHost; Debug.Assert(css != null, "No component serialization service -- we cannot copy the objects"); Debug.Assert(host != null, "No host -- we cannot copy the objects"); if (css != null && host != null) { SerializationStore store = null; store = css.CreateStore(); // Get all the objects, meaning we want the children too ICollection copyObjects = GetCopySelection(objects, host); // The serialization service does not (yet) handle serializing collections foreach (IComponent comp in copyObjects) { css.Serialize(store, comp); } store.Close(); copyObjects = css.Deserialize(store); // Now, copyObjects contains a flattened list of all the controls contained in the original drag objects, that's not what we want to return. // We only want to return the root drag objects, so that the caller gets an identical copy - identical in terms of objects.Count ArrayList newObjects = new ArrayList(objects.Count); foreach (IComponent comp in copyObjects) { Control c = comp as Control; if (c != null && c.Parent == null) { newObjects.Add(comp); } else if (c == null) { // this happens when we are dragging a toolstripitem // TODO: Can we remove the ToolStrip specific code? if (comp is ToolStripItem item && item.GetCurrentParent() == null) { newObjects.Add(comp); } } } Debug.Assert(newObjects.Count == objects.Count, "Why is the count of the copied objects not the same?"); return(newObjects); } } finally { Cursor.Current = oldCursor; } return(null); }
public IComponent[] CreateComponents(IDesignerHost host) { // TODO return(null); }
//构造函数 public UnboundColumnExpressionEditorFormEx(object contextInstance, IDesignerHost designerHost) : base(contextInstance, designerHost) { }
void AddItemToToolbox(ToolboxItem toolboxItem, string category, IDesignerHost host) { toolboxItems.Add(toolboxItem); System.Console.WriteLine("{0}", toolboxItems.Count); FireToolboxItemAdded(toolboxItem, category, host); }
protected override IComponent[] CreateComponentsCore(IDesignerHost host, IDictionary defaultValues) { return(RunWizard(host, base.CreateComponentsCore(host, defaultValues))); }
// This method is called when a user double-clicks (the representation of) a component. // Tries to bind the default event to a method or creates a new one. // public virtual void DoDefaultAction() { IDesignerHost host = (IDesignerHost)this.GetService(typeof(IDesignerHost)); DesignerTransaction transaction = null; if (host != null) { transaction = host.CreateTransaction("ComponentDesigner_AddEvent"); } IEventBindingService eventBindingService = GetService(typeof(IEventBindingService)) as IEventBindingService; EventDescriptor defaultEventDescriptor = null; if (eventBindingService != null) { ISelectionService selectionService = this.GetService(typeof(ISelectionService)) as ISelectionService; try { if (selectionService != null) { ICollection selectedComponents = selectionService.GetSelectedComponents(); foreach (IComponent component in selectedComponents) { EventDescriptor eventDescriptor = TypeDescriptor.GetDefaultEvent(component); if (eventDescriptor != null) { PropertyDescriptor eventProperty = eventBindingService.GetEventProperty(eventDescriptor); if (eventProperty != null && !eventProperty.IsReadOnly) { string methodName = eventProperty.GetValue(component) as string; bool newMethod = true; if (methodName != null || methodName != String.Empty) { ICollection compatibleMethods = eventBindingService.GetCompatibleMethods(eventDescriptor); foreach (string signature in compatibleMethods) { if (signature == methodName) { newMethod = false; break; } } } if (newMethod) { if (methodName == null) { methodName = eventBindingService.CreateUniqueMethodName(component, eventDescriptor); } eventProperty.SetValue(component, methodName); } if (component == _component) { defaultEventDescriptor = eventDescriptor; } } } } } } catch { if (transaction != null) { transaction.Cancel(); transaction = null; } } finally { if (transaction != null) { transaction.Commit(); } } if (defaultEventDescriptor != null) { eventBindingService.ShowCode(_component, defaultEventDescriptor); } } }