void button_Click(object sender, RoutedEventArgs e) { Button btn = (Button)sender; BufferPositions bufferPopup = new BufferPositions(btn.Content.ToString()); bufferPopup.ShowDialog(); btn.Content = bufferPopup.BufferPositionValue; var Selection = designerCanvas.SelectionService.CurrentSelection; ViewModelDesignerItem Ditem = new ViewModelDesignerItem(); foreach (var slc in Selection) { Ditem = (ViewModelDesignerItem)slc; } DockPanel Sourcepnl = (DockPanel)Ditem.Content; PropertyGrid SelectedPgrid = designerCanvas.TransactionList.FindAll(x => x.TransactionName == designerCanvas.CurrentTransactionName).Find(x => x.Id == Sourcepnl.Uid).PropertyGrid; string SelectedProperty = btn.Name.ToString(); string newValue = btn.Content.ToString(); StateY statey = (StateY)SelectedPgrid.SelectedObject; Type ClassType = statey.GetType(); PropertyInfo property = ClassType.GetProperty(SelectedProperty); property.SetValue(statey, newValue, null); designerCanvas.TransactionList.FindAll(x => x.TransactionName == designerCanvas.CurrentTransactionName).Find(x => x.Id == Sourcepnl.Uid).PropertyGrid.SelectedObject = statey; }
void button_Click(object sender, RoutedEventArgs e) { Button btn = (Button)sender; FDKPriorityApp fdkpopup = new FDKPriorityApp(btn.Content.ToString()); fdkpopup.ShowDialog(); btn.Content = fdkpopup.FDKValue; var Selection = designerCanvas.SelectionService.CurrentSelection; ViewModelDesignerItem Ditem = new ViewModelDesignerItem(); foreach (var slc in Selection) { Ditem = (ViewModelDesignerItem)slc; } DockPanel Sourcepnl = (DockPanel)Ditem.Content; PropertyGrid SelectedPgrid = designerCanvas.TransactionList.Find(x => x.Id == Sourcepnl.Uid).PropertyGrid; string SelectedProperty = btn.Name.ToString(); string newValue = btn.Content.ToString(); Statee001 state = (Statee001)SelectedPgrid.SelectedObject; Type ClassType = state.GetType(); PropertyInfo property = ClassType.GetProperty(SelectedProperty); property.SetValue(state, newValue, null); designerCanvas.TransactionList.Find(x => x.Id == Sourcepnl.Uid).PropertyGrid.SelectedObject = state; }
void button_Click(object sender, RoutedEventArgs e) { Button btn = (Button)sender; ScreenSelection scrnSelec = new ScreenSelection(btn.Content.ToString()); scrnSelec.ShowDialog(); btn.Content = scrnSelec.ScreenNumber; var Selection = designerCanvas.SelectionService.CurrentSelection; ViewModelDesignerItem Ditem = new ViewModelDesignerItem(); foreach (var slc in Selection) { Ditem = (ViewModelDesignerItem)slc; } DockPanel Sourcepnl = (DockPanel)Ditem.Content; PropertyGrid SelectedPgrid = designerCanvas.TransactionList.FindAll(x => x.TransactionName == designerCanvas.CurrentTransactionName).Find(x => x.Id == Sourcepnl.Uid).PropertyGrid; string SelectedProperty = btn.Name.ToString(); string newValue = btn.Content.ToString(); Object stateobj = (Object)SelectedPgrid.SelectedObject; Type ClassType = stateobj.GetType(); PropertyInfo property = ClassType.GetProperty(SelectedProperty); property.SetValue(stateobj, newValue, null); designerCanvas.TransactionList.FindAll(x => x.TransactionName == designerCanvas.CurrentTransactionName).Find(x => x.Id == Sourcepnl.Uid).PropertyGrid.SelectedObject = stateobj; }
void ccb_ItemSelectionChanged(object sender, Xceed.Wpf.Toolkit.Primitives.ItemSelectionChangedEventArgs e) { Xceed.Wpf.Toolkit.CheckComboBox ccb = (Xceed.Wpf.Toolkit.CheckComboBox)sender; int mask = 0; foreach (var item in ccb.SelectedItems) { double index = Convert.ToDouble(item.ToString().Substring(6)); mask = mask + (int)Math.Pow(2, index); } ccb.Text = mask.ToString("000"); var Selection = designerCanvas.SelectionService.CurrentSelection; ViewModelDesignerItem Ditem = new ViewModelDesignerItem(); foreach (var slc in Selection) { Ditem = (ViewModelDesignerItem)slc; } DockPanel Sourcepnl = (DockPanel)Ditem.Content; PropertyGrid SelectedPgrid = designerCanvas.TransactionList.Find(x => x.Id == Sourcepnl.Uid).PropertyGrid; string SelectedProperty = property.DisplayName; string newValue = ccb.Text; StateY stated = (StateY)SelectedPgrid.SelectedObject; Type ClassType = stated.GetType(); PropertyInfo propertyName = ClassType.GetProperty(SelectedProperty); propertyName.SetValue(stated, newValue, null); designerCanvas.TransactionList.Find(x => x.Id == Sourcepnl.Uid).PropertyGrid.SelectedObject = stated; }
//ViewProperties on mouseupclick private void TransactionDiagram_PreviewMouseUp(object sender, MouseButtonEventArgs e) { var Selection = TransactionDiagram.SelectionService.CurrentSelection; if (Selection.Count != 1) { propertyGrid.SelectedObject = null; propertyGrid.SelectedObjectName = ""; return; } ViewModelDesignerItem Ditem = new ViewModelDesignerItem(); foreach (var slc in Selection) { if (slc.GetType().Name.ToString() != "ViewModelDesignerItem") { return; } Ditem = (ViewModelDesignerItem)slc; } DockPanel Sourcepnl = (DockPanel)Ditem.Content; if (this.TransactionDiagram.TransactionList.Exists(x => x.Id == Sourcepnl.Uid)) { propertyGrid.SelectedObject = this.TransactionDiagram.TransactionList.FindAll(x => x.Id == Sourcepnl.Uid).Find (x => x.TransactionName == this.TransactionDiagram.CurrentTransactionName).PropertyGrid.SelectedObject; propertyGrid.SelectedObjectName = Sourcepnl.Uid; } else { MessageBox.Show("Bir Hata Oluştu."); } }
public void ViewPropertyGrid(List <IModelSelectable> CurrentSelection) { var Selection = CurrentSelection; ViewModelDesignerItem Ditem = new ViewModelDesignerItem(); foreach (var slc in Selection) { Ditem = (ViewModelDesignerItem)slc; } DockPanel Sourcepnl = (DockPanel)Ditem.Content; string frmName = "State" + Sourcepnl.Tag.ToString(); Type CAType = Type.GetType("ATMDesigner.UI.States." + frmName); Object myObj = Activator.CreateInstance(CAType); PropertyInfo StateNo = CAType.GetProperty("StateNumber"); StateNo.SetValue(myObj, Sourcepnl.Uid, null); PropertyInfo stateType = CAType.GetProperty("StateType"); stateType.SetValue(myObj, Sourcepnl.Tag.ToString(), null); PropertyInfo Desc = CAType.GetProperty("StateDescription"); Desc.SetValue(myObj, frmName, null); StateObj = myObj; }
//ViewProperties on Drop to canvas private void TransactionDiagram_PreviewDrop(object sender, DragEventArgs e) { ViewModelDesignerCanvas dcanvas = new ViewModelDesignerCanvas(); dcanvas = (ViewModelDesignerCanvas)sender; SelectedPgrid = new PropertyGrid(); TreeViewItem ChildNode = new TreeViewItem(); ChildNode = TreeFlow.SelectedItem as TreeViewItem; ItemsControl parent = ItemsControl.ItemsControlFromItemContainer(ChildNode); TreeViewItem parentNode = parent as TreeViewItem; if (parentNode != null && !String.IsNullOrEmpty(parentNode.Header.ToString())) { dcanvas.ProjectName = parentNode.Header.ToString(); dcanvas.CurrentTransactionName = TransDiagramName.Header.ToString(); ModelDragObject dragObject = e.Data.GetData(typeof(ModelDragObject)) as ModelDragObject; ModelCanvasStateObject state = new ModelCanvasStateObject(); if (dragObject != null && !String.IsNullOrEmpty(dragObject.Xaml)) { ViewModelDesignerItem newItem = null; Object content = XamlReader.Load(XmlReader.Create(new StringReader(dragObject.Xaml))); if (content != null) { newItem = new ViewModelDesignerItem(); DockPanel pnl = (DockPanel)content; string StateBrandName = pnl.ToolTip.ToString(); if (StateBrandName != "P" && StateBrandName != "GENERIC") { string StateBrandId = ConfigurationManager.AppSettings[StateBrandName]; if (dcanvas.CurrentBrandId != StateBrandId) { MessageBox.Show("Kullanmak istediğiniz State " + StateBrandName + " için sadece kullanılabilir, lütfen Mevcut Brande uygun State kullanınız"); return; } } string frmName = "State" + pnl.Tag.ToString(); string Id = dcanvas.avaliableStateNumberList[0].ToString(); Type ClassType = Type.GetType("ATMDesigner.UI.States." + frmName); Object ClassInstance = Activator.CreateInstance(ClassType); PropertyInfo StateNo = ClassType.GetProperty("StateNumber"); StateNo.SetValue(ClassInstance, Id, null); propertyGrid.SelectedObject = ClassInstance; propertyGrid.SelectedObjectName = Id; SelectedPgrid.SelectedObject = ClassInstance; SelectedPgrid.SelectedObjectName = Id; PropertyGridList.Add(SelectedPgrid); } } } }
private void DragTop(double scale, ViewModelDesignerItem item, ViewModelSelectionService selectionService) { IEnumerable <ViewModelDesignerItem> groupItems = selectionService.GetGroupMembers(item).Cast <ViewModelDesignerItem>(); double groupBottom = Canvas.GetTop(item) + item.Height; foreach (ViewModelDesignerItem groupItem in groupItems) { double groupItemTop = Canvas.GetTop(groupItem); double delta = (groupBottom - groupItemTop) * (scale - 1); Canvas.SetTop(groupItem, groupItemTop - delta); groupItem.Height = groupItem.ActualHeight * scale; } }
private void DragLeft(double scale, ViewModelDesignerItem item, ViewModelSelectionService selectionService) { IEnumerable <ViewModelDesignerItem> groupItems = selectionService.GetGroupMembers(item).Cast <ViewModelDesignerItem>(); double groupLeft = Canvas.GetLeft(item) + item.Width; foreach (ViewModelDesignerItem groupItem in groupItems) { double groupItemLeft = Canvas.GetLeft(groupItem); double delta = (groupLeft - groupItemLeft) * (scale - 1); Canvas.SetLeft(groupItem, groupItemLeft - delta); groupItem.Width = groupItem.ActualWidth * scale; } }
void button_Click(object sender, RoutedEventArgs e) { Button btn = (Button)sender; NextStateSelection StateSelectionPopup = new NextStateSelection(designerCanvas.TransactionList, btn.Content.ToString(), designerCanvas.CurrentBrandId, designerCanvas.CurrentTransactionName); StateSelectionPopup.ShowDialog(); var Selection = designerCanvas.SelectionService.CurrentSelection; ViewModelDesignerItem Ditem = new ViewModelDesignerItem(); foreach (var slc in Selection) { Ditem = (ViewModelDesignerItem)slc; } DockPanel pointerpnl = (DockPanel)Ditem.Content; string PointerTransactionName = designerCanvas.TransactionList.Find(x => x.Id == pointerpnl.Uid).TransactionName; StateP statepointer = (StateP)designerCanvas.TransactionList.Find(x => x.Id == pointerpnl.Uid).PropertyGrid.SelectedObject; if (statepointer.SourceStatesList.Count > 0) { btn.Content = StateSelectionPopup.NextStateNumber; string SelectedProperty = btn.Name.ToString(); string SelectedPropertyValue = btn.Content.ToString(); //Pointer state güncellemesi Type ClassType = statepointer.GetType(); PropertyInfo property = ClassType.GetProperty(SelectedProperty); property.SetValue(statepointer, SelectedPropertyValue, null); designerCanvas.TransactionList.Find(x => x.Id == pointerpnl.Uid).PropertyGrid.SelectedObject = statepointer; List <PointerStateElements> elementlist = new List <PointerStateElements>(); for (int i = 0; i < statepointer.SourceStatesList.Count; i++) { //Source State Güncellemesi Object SourceStateobj = designerCanvas.TransactionList.FindAll(x => x.Id == statepointer.SourceStatesList[i].SourceStateNumber). Find(x => x.TransactionName == PointerTransactionName).PropertyGrid.SelectedObject; Type SourceClassType = SourceStateobj.GetType(); PropertyInfo SourcePropertyName = SourceClassType.GetProperty(statepointer.SourceStatesList[i].SourcePropertyName); SourcePropertyName.SetValue(SourceStateobj, statepointer.NextStateNumber); designerCanvas.TransactionList.Find(x => x.Id == statepointer.SourceStatesList[i].SourceStateNumber).PropertyGrid.SelectedObject = SourceStateobj; } } else { MessageBox.Show("Lütfen Öncellikle Pointer State bir bağlantı oluşturun..!"); } }
void DragThumb_DragDelta(object sender, DragDeltaEventArgs e) { ViewModelDesignerItem designerItem = this.DataContext as ViewModelDesignerItem; ViewModelDesignerCanvas designer = VisualTreeHelper.GetParent(designerItem) as ViewModelDesignerCanvas; if (designerItem != null && designer != null && designerItem.IsSelected) { double minLeft = double.MaxValue; double minTop = double.MaxValue; // we only move DesignerItems var designerItems = designer.SelectionService.CurrentSelection.OfType <ViewModelDesignerItem>(); foreach (ViewModelDesignerItem item in designerItems) { double left = Canvas.GetLeft(item); double top = Canvas.GetTop(item); minLeft = double.IsNaN(left) ? 0 : Math.Min(left, minLeft); minTop = double.IsNaN(top) ? 0 : Math.Min(top, minTop); } double deltaHorizontal = Math.Max(-minLeft, e.HorizontalChange); double deltaVertical = Math.Max(-minTop, e.VerticalChange); foreach (ViewModelDesignerItem item in designerItems) { double left = Canvas.GetLeft(item); double top = Canvas.GetTop(item); if (double.IsNaN(left)) { left = 0; } if (double.IsNaN(top)) { top = 0; } Canvas.SetLeft(item, left + deltaHorizontal); Canvas.SetTop(item, top + deltaVertical); } designer.InvalidateMeasure(); e.Handled = true; } }
//on Drag Drop event private void ViewPropertyGrid(object param) { DragEventArgs e = param as DragEventArgs; ViewModelDesignerCanvas dcanvas = new ViewModelDesignerCanvas(); //dcanvas = (ViewModelDesignerCanvas)sender; //SelectedPgrid = new PropertyGrid(); ModelDragObject dragObject = e.Data.GetData(typeof(ModelDragObject)) as ModelDragObject; ModelCanvasStateObject state = new ModelCanvasStateObject(); if (dragObject != null && !String.IsNullOrEmpty(dragObject.Xaml)) { ViewModelDesignerItem newItem = null; Object content = XamlReader.Load(XmlReader.Create(new StringReader(dragObject.Xaml))); if (content != null) { newItem = new ViewModelDesignerItem(); DockPanel pnl = (DockPanel)content; string frmName = "State" + pnl.Tag.ToString(); string Id = (dcanvas.avaliableStateNumberList[dcanvas.TransactionList.Count]).ToString(); state.Type = pnl.Tag.ToString(); Type CAType = Type.GetType("ATMDesigner.UI.States." + frmName); Object myObj = Activator.CreateInstance(CAType); PropertyInfo StateNo = CAType.GetProperty("StateNumber"); StateNo.SetValue(myObj, Id, null); PropertyInfo stateType = CAType.GetProperty("StateType"); stateType.SetValue(myObj, pnl.Tag.ToString(), null); PropertyInfo Desc = CAType.GetProperty("StateDescription"); Desc.SetValue(myObj, frmName, null); StateObj = myObj; } } }
void ResizeThumb_DragDelta(object sender, DragDeltaEventArgs e) { return; ViewModelDesignerItem designerItem = this.DataContext as ViewModelDesignerItem; ViewModelDesignerCanvas designer = VisualTreeHelper.GetParent(designerItem) as ViewModelDesignerCanvas; if (designerItem != null && designer != null && designerItem.IsSelected) { double minLeft, minTop, minDeltaHorizontal, minDeltaVertical; double dragDeltaVertical, dragDeltaHorizontal, scale; IEnumerable <ViewModelDesignerItem> selectedDesignerItems = designer.SelectionService.CurrentSelection.OfType <ViewModelDesignerItem>(); CalculateDragLimits(selectedDesignerItems, out minLeft, out minTop, out minDeltaHorizontal, out minDeltaVertical); foreach (ViewModelDesignerItem item in selectedDesignerItems) { if (item != null && item.ParentID == Guid.Empty) { switch (base.VerticalAlignment) { case VerticalAlignment.Bottom: dragDeltaVertical = Math.Min(-e.VerticalChange, minDeltaVertical); scale = (item.ActualHeight - dragDeltaVertical) / item.ActualHeight; DragBottom(scale, item, designer.SelectionService); break; case VerticalAlignment.Top: double top = Canvas.GetTop(item); dragDeltaVertical = Math.Min(Math.Max(-minTop, e.VerticalChange), minDeltaVertical); scale = (item.ActualHeight - dragDeltaVertical) / item.ActualHeight; DragTop(scale, item, designer.SelectionService); break; default: break; } switch (base.HorizontalAlignment) { case HorizontalAlignment.Left: double left = Canvas.GetLeft(item); dragDeltaHorizontal = Math.Min(Math.Max(-minLeft, e.HorizontalChange), minDeltaHorizontal); scale = (item.ActualWidth - dragDeltaHorizontal) / item.ActualWidth; DragLeft(scale, item, designer.SelectionService); break; case HorizontalAlignment.Right: dragDeltaHorizontal = Math.Min(-e.HorizontalChange, minDeltaHorizontal); scale = (item.ActualWidth - dragDeltaHorizontal) / item.ActualWidth; DragRight(scale, item, designer.SelectionService); break; default: break; } } } e.Handled = true; } }
void button_Click(object sender, RoutedEventArgs e) { Button btn = (Button)sender; StateNumberSelection StateSelectionPopup = new StateNumberSelection(designerCanvas.avaliableStateNumberList, btn.Content.ToString(), designerCanvas.CurrentBrandId , designerCanvas.TransactionList); StateSelectionPopup.ShowDialog(); var Selection = designerCanvas.SelectionService.CurrentSelection; ViewModelDesignerItem Ditem = new ViewModelDesignerItem(); foreach (var slc in Selection) { Ditem = (ViewModelDesignerItem)slc; } DockPanel Sourcepnl = (DockPanel)Ditem.Content; //StateNumber deðiþmememiþ if (btn.Content.ToString() == StateSelectionPopup.StateNumber) { return; } //State number ve baðlantýlý yerlerde gerekli güncellemeler string ExStateId = btn.Content.ToString(); string NewStateId = StateSelectionPopup.StateNumber; PropertyGrid SelectedPgrid = designerCanvas.TransactionList.FindAll(x => x.TransactionName == designerCanvas.CurrentTransactionName).Find(x => x.Id == ExStateId).PropertyGrid; Object state = (Object)SelectedPgrid.SelectedObject; if (state != null) { btn.Content = NewStateId; string SelectedProperty = btn.Name.ToString(); string SelectedPropertyValue = NewStateId; //state güncellemesi SelectedPgrid.SelectedObject.GetType().GetProperty("StateNumber").SetValue(SelectedPgrid.SelectedObject, SelectedPropertyValue); SelectedPgrid.SelectedObjectName = SelectedPropertyValue; designerCanvas.TransactionList.FindAll(x => x.TransactionName == designerCanvas.CurrentTransactionName) .Find(x => x.Id == ExStateId).PropertyGrid = SelectedPgrid; designerCanvas.TransactionList.FindAll(x => x.TransactionName == designerCanvas.CurrentTransactionName) .Find(x => x.Id == ExStateId).Id = SelectedPropertyValue; Sourcepnl.Uid = SelectedPropertyValue; Ditem.Content = Sourcepnl; designerCanvas.avaliableStateNumberList.Remove(SelectedPropertyValue); //parent State Güncellemesi List <ModelParentStateObject> PStateList = new List <ModelParentStateObject>(); PStateList = designerCanvas.TransactionList.FindAll(x => x.TransactionName == designerCanvas.CurrentTransactionName).Find(x => x.Id == SelectedPropertyValue).ParentStateList; if (PStateList.Count != 0) { for (int i = 0; i < PStateList.Count; i++) { SelectedPgrid = designerCanvas.TransactionList.Find(x => x.Id == PStateList[i].ParentId).PropertyGrid; SelectedPgrid.SelectedObject.GetType().GetProperty(PStateList[i].PropertyName).SetValue(SelectedPgrid.SelectedObject, SelectedPropertyValue); designerCanvas.TransactionList.Find(x => x.Id == PStateList[i].ParentId).PropertyGrid.SelectedObject = SelectedPgrid.SelectedObject; } } } else { } }
public void GoTo_NextState_Trans(object sender, ExecutedRoutedEventArgs e) { try { log.Info("GoTo_NextState_Trans() Start.!"); var Selection = TransactionDiagram.SelectionService.CurrentSelection; if (Selection.Count != 1) { propertyGrid.SelectedObject = null; propertyGrid.SelectedObjectName = ""; return; } ViewModelDesignerItem Ditem = new ViewModelDesignerItem(); foreach (var slc in Selection) { if (slc.GetType().Name.ToString() != "ViewModelDesignerItem") { return; } Ditem = (ViewModelDesignerItem)slc; } DockPanel Dpnl = (DockPanel)Ditem.Content; if (Dpnl.Tag.ToString() != "P") { log.Warn("GoTo_NextState_Trans(), Sadece Pointer state Go To özelliğne Sahiptir. State:" + Dpnl.Tag.ToString()); return; } StateP pState = new StateP(); pState = (StateP)this.TransactionDiagram.TransactionList.FindAll(x => x.TransactionName == this.TransactionDiagram.CurrentTransactionName) .Find(x => x.Id == Dpnl.Uid).PropertyGrid.SelectedObject; if (pState.NextStateNumber == "255") { log.Warn("GoTo_NextState_Trans(), NextStateNumber 255'ten farklı olmalı pState.NextStateNumber:" + pState.NextStateNumber); return; } PointerStateTransaction PointerTrans = new PointerStateTransaction(this.TransactionDiagram.TransactionList, pState.NextStateNumber); if (PointerTrans.ShowDialog() == true) { string TransactionName = PointerTrans.TransactionName; string BrandId = PointerTrans.BrandId; string ExTransactionName = this.TransactionDiagram.CurrentTransactionName; this.TransactionDiagram.CurrentTransactionName = TransactionName; if (!string.IsNullOrEmpty(ExTransactionName)) { this.TransactionDiagram.Open_Executed(false, ExTransactionName); } this.TransactionDiagram.CurrentBrandId = BrandId; propertyGrid.SelectedObject = null; propertyGrid.SelectedObjectName = ""; TransDiagramName.Header = TransactionName; ExpanderDItem.IsExpanded = IsTransactionSelected(); } } catch (Exception ex) { log.Error("GoTo_NextState_Trans() Error ! " + ex.Message); MessageBox.Show("Beklenmedik bir Hata Oluştu.!, Tekrar Deneyiniz."); } }