public PeriodVisual(Period period, GlobalLine line, MainWindow wnd) { this.wnd = wnd; Source = period; this.Line = line; Can = new Canvas { Background=Brushes.Black, Height=Settings.LineHeight, Visibility=Visibility.Collapsed, HorizontalAlignment=HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top}; brd.Stroke = Brushes.Red; brd.StrokeThickness = 0; brd.HorizontalAlignment = HorizontalAlignment.Stretch; brd.VerticalAlignment = VerticalAlignment.Stretch; brd.Width = Can.ActualWidth; brd.Height = Can.ActualHeight; Can.Children.Add(brd); Canvas.SetZIndex(brd, 100); Can.MouseEnter+=Can_MouseEnter; Can.MouseLeave += Can_MouseLeave; Can.MouseLeftButtonDown += Can_MouseLeftButtonDown; Can.MouseLeftButtonUp += Can_MouseLeftButtonUp; Can.MouseMove += Can_MouseMove; Can.Opacity = 1.0; MenuItem CMIDelete = new MenuItem { Header = "Удалить" }; CMIDelete.Click += CMIDelete_Click; CMPeriod.Items.Add(CMIDelete); MenuItem CMIProps = new MenuItem { Header="Свойства"}; CMIProps.Click += CMIProps_Click; CMPeriod.Items.Add(CMIProps); Can.ContextMenu = CMPeriod; wnd.GSVSignals.Children.Add(Can); Grid.SetColumn(Can,2); Grid.SetZIndex(Can, 100); }
public FormBusProp(GlobalLine GLBus) { InitializeComponent(); this.GLine = GLBus; this.Bus = (GLBus.DLine as BusLine).Bus; this.Title = "Свойства шины " + Bus.Name; }
public GlobalLine(Signal signal, GlobalLine Parent, MainWindow wnd) { signal.GLines.Add(this); this.wnd = wnd; CreateCMSignal(); CreateItems(); TVIName.ContextMenu = CMSignal; TVIName.Header = signal.Name; TVIName.Style = (Style)wnd.FindResource(Signal.Modes.ToStr(signal.Mode)); Parent.TVIName.Items.Add(TVIName); DLine = new SignalLine(signal, TVILine, this, wnd); this.Parent = Parent; }
public SignalLine(Signal signal, TreeViewItem LBILine, GlobalLine GLine, MainWindow Wnd) { Type = DrawingLine.Types.Signal; wnd = Wnd; Parent = GLine; //------------------- Creating Canvas ------------------------------------ CanLine = new Canvas(); CanLine.Height = Settings.LineHeight -2; CanLine.VerticalAlignment = VerticalAlignment.Top; CanLine.HorizontalAlignment = HorizontalAlignment.Stretch; CanLine.Background = Brushes.Transparent; CanLine.Margin = new Thickness(-18, 0, 0, 0); LBILine.Header = CanLine; //------------------------------------------------------------------------- // Context Menu MenuItem MITemp = new MenuItem { Header = "0"}; MITemp.Click += MISetZero_Click; CMCanLine.Items.Add(MITemp); MITemp = new MenuItem { Header = "1" }; MITemp.Click += MISetOne_Click; CMCanLine.Items.Add(MITemp); MITemp = new MenuItem { Header = "#" }; MITemp.Click += MISetHash_Click; CMCanLine.Items.Add(MITemp); MITemp = new MenuItem { Header = "*" }; MITemp.Click += MISetStar_Click; CMCanLine.Items.Add(MITemp); MITemp = new MenuItem { Header = "Z" }; MITemp.Click += MISetZ_Click; CMCanLine.Items.Add(MITemp); MITemp = new MenuItem { Header = "X" }; MITemp.Click += MISetX_Click; CMCanLine.Items.Add(MITemp); MITemp = new MenuItem { Header = "Удалить" }; MITemp.Click += MIDelete_Click; CMCanLine.Items.Add(MITemp); CanLine.ContextMenu = CMCanLine; //Signal = signal; Source = signal; //------------------------------------------------------------------------- RenewContextMenuVisibility(); Gen = Project.Gens.Pot; //Redraw(); }
public FormSignalProp(GlobalLine GLine) { InitializeComponent(); this.GLine = GLine; this.Title = "Свойства сигнала " + (GLine.DLine as SignalLine).Signal.Name; }
public void Select(GlobalLine GLine) { if (GLine == null) return; List<GlobalLine> Selected = SelectedLines; if (Selected.Count == 0) { if (Keyboard.IsKeyDown(Key.LeftShift)) { if (GLine.Parent == null) // если сигнал вне шины/группы или он и есть шина/группа { foreach (GlobalLine TempGLine in GlobalLines) // выделяем все до него включительно { TempGLine.Select(); if (TempGLine == GLine) break; } } else { foreach (GlobalLine TempGLine in GLine.Parent.BusSubLines) // выделяем все внутри шины/группы до него включительно { TempGLine.Select(); if (TempGLine == GLine) break; } } } else GLine.Select(); } else { if (Keyboard.IsKeyDown(Key.LeftShift)) { if (Selected[Selected.Count - 1].Parent == GLine.Parent) { List<GlobalLine> GlobalsFrom; if (GLine.Parent == null) GlobalsFrom = GlobalLines; else GlobalsFrom = GLine.Parent.BusSubLines; int ibase = GlobalsFrom.IndexOf(GLine); int ilastsel = GlobalsFrom.IndexOf(Selected[Selected.Count - 1]); if (ibase < ilastsel) { int t = ilastsel; ilastsel = ibase; ibase = t; } for (int i = 0; i < Selected.Count; i++) Selected[0].Unselect(); for (int i = ilastsel; i <= ibase; i++) GlobalsFrom[i].Select(); } else { } } else { if ((Selected.Count == 1) && (Selected[0] == GLine)) { if (Keyboard.IsKeyDown(Key.LeftCtrl)) { GLine.Unselect(); } } else { if (Keyboard.IsKeyDown(Key.LeftCtrl)) { if (GLine.isSelected) { GLine.Unselect(); if (GLine.BusSubLines != null) foreach (GlobalLine TemoGLine in GLine.BusSubLines) TemoGLine.Unselect(); } else GLine.Select(); } else { while (Selected.Count > 0) Selected[0].Unselect(); GLine.Select(); } } } } }
public void Remove(GlobalLine GLine) { if (Contains(GLine)) GlobalLines.Remove(GLine); }
public void Insert(int index, GlobalLine item) { if (index >= GlobalLines.Count) GlobalLines.Add(item); GlobalLines.Insert(index, item); }
public int IndexOf(GlobalLine GLTemp) { return GlobalLines.IndexOf(GLTemp); }
public double GetHpos(GlobalLine GLine) { double h = 0; for (int i = 0; i < GlobalLines.Count; i++) { if (GlobalLines[i] == GLine) return h; if (GlobalLines[i] == GLine.Parent) { h += Settings.LineHeight + 4; for (int j = 0; j < GlobalLines[i].BusSubLines.Count; j++) { if (GlobalLines[i].BusSubLines[j] == GLine) return h; h += GlobalLines[i].BusSubLines[j].TVIName.Height; } } h += GlobalLines[i].TVIName.Height; } return h; }
public int GetGlobalIndex(GlobalLine GLine) { int index = 0; for (int i = 0; i < GlobalLines.Count; i++ ) { if (GlobalLines[i] == GLine) return index; index++; if (GlobalLines[i].Type == DrawingLine.Types.Bus) { for (int j = 0; j < GlobalLines[i].BusSubLines.Count; j++) { if (GlobalLines[i].BusSubLines[j] == GLine) return index; index++; } } } return index; }
public bool Contains(GlobalLine GLine) { return GlobalLines.Contains(GLine); }
public void Add(GlobalLine GLine) { GlobalLines.Add(GLine); }
void Can_MouseMove(object sender, System.Windows.Input.MouseEventArgs e) { wnd.LDiff.Content = e.GetPosition(Line.DLine.CanLine).X; if (Mouse.LeftButton == MouseButtonState.Pressed) { if (isDragged) { double newX = e.GetPosition(Line.DLine.CanLine).X; double newY = e.GetPosition(Line.DLine.CanLine).Y; double taktwidth = Line.DLine.CanLine.ActualWidth / (wnd.EndTakt - wnd.BeginTakt + 1); wnd.LDiff.Content = newX; int newBeg = wnd.BeginTakt + Convert.ToInt32(Math.Floor((newX - MouseDelta.X) / taktwidth)); TopSdv = newY - MouseDelta.Y; if (newBeg < 0) newBeg = 0; Source.Beg = newBeg; int index = wnd.Lines.GetGlobalIndex(Line) + Convert.ToInt32(TopSdv / Settings.LineHeight); GlobalLine GLine = wnd.Lines.FromGlobalIndex(index); if ((GLine != null) && (GLine != Line)) { if (GLine.DLine.Type == DrawingLine.Types.Signal) { (Line.DLine.Source as Signal).Periods.Remove(Source); (GLine.DLine.Source as Signal).Periods.Add(Source); Line.UnselectOver(); TopSdv -= Settings.LineHeight * (index - wnd.Lines.GetGlobalIndex(Line)); this.Line = GLine; Line.SelectOver(); } } Redraw(); } } else { if (isDragged) { isDragged = false; TopSdv = 0; Redraw(); } } }