本文介绍了来自不同类别的访问控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经找到并出于某些原因不得不删除此消息
I have Found and some reason i have to deleted this messages
推荐答案
<window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="768" Width="1024" WindowState="Maximized"
xmlns:s="clr-namespace:KarmaTasarimv3"
xmlns:c="clr-namespace:KarmaTasarimv3.Controls"
xmlns:zoom="clr-namespace:ZoomAndPan;assembly=ZoomAndPan"
xmlns:my="clr-namespace:LogicNP.FolderViewControl;assembly=LogicNP.FolderView.WPF"
x:Class="KarmaTasarimv3.TasarimEkrani"
>
<window.resources>
<contextmenu x:key="DesignerCanvasContextMenu" xmlns:x="#unknown">
<menuitem header="Paste" command="{x:Static ApplicationCommands.Paste}">
<menuitem.icon>
<image source="Resources/Images/Paste.png" width="16" />
</menuitem.icon>
</menuitem>
<menuitem header="Select All" command="{x:Static s:DesignerCanvas.SelectAll}" />
</contextmenu>
</window.resources>
<grid x:name="grid_layoutGrid" xmlns:x="#unknown">
<grid.rowdefinitions>
<rowdefinition height="Auto" />
<rowdefinition />
</grid.rowdefinitions>
<contentcontrol content="{StaticResource MyToolbar}" />
<grid grid.row="1">
<grid.columndefinitions>
<columndefinition width="1*" />
<columndefinition width="5*" />
<columndefinition width="1*" minwidth="300" />
</grid.columndefinitions>
<!--sol Sütün-->
<stackpanel x:name="solSutun" grid.column="0" margin="0,0,5,0">
<s:mygezgin scrollviewer.verticalscrollbarvisibility="Auto" xmlns:s="#unknown"></s:mygezgin>
</stackpanel>
<gridsplitter focusable="False" width="4" removed="LightGray" grid.column="0" verticalalignment="Stretch" horizontalalignment="Right" />
<!--Orta Alan-->
<groupbox x:name="CalismaAlani" header="Çalışma Alanı" grid.column="1">
<grid>
<grid.rowdefinitions>
<rowdefinition height="1*" />
<rowdefinition height="40" />
</grid.rowdefinitions>
<grid grid.row="0">
<grid.rowdefinitions>
<rowdefinition />
<rowdefinition height="Auto" />
<rowdefinition />
</grid.rowdefinitions>
<grid.columndefinitions>
<columndefinition />
<columndefinition width="Auto" />
<columndefinition />
</grid.columndefinitions>
<scrollviewer x:name="scroller">
CanContentScroll="True"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto"
Grid.Row="1"
Grid.Column="1">
<zoom:zoomandpancontrol x:name="ZoomAndPanControl" xmlns:zoom="#unknown">
ContentScale="{Binding Source={x:Static s:DataModel.Instance}, Path=ContentScale, Mode=TwoWay}"
ContentOffsetX="{Binding Source={x:Static s:DataModel.Instance}, Path=ContentOffsetX, Mode=TwoWay}"
ContentOffsetY="{Binding Source={x:Static s:DataModel.Instance}, Path=ContentOffsetY, Mode=TwoWay}"
ContentViewportWidth="{Binding Source={x:Static s:DataModel.Instance}, Path=ContentViewportWidth, Mode=OneWayToSource}"
ContentViewportHeight="{Binding Source={x:Static s:DataModel.Instance}, Path=ContentViewportHeight, Mode=OneWayToSource}"
VerticalAlignment="Top"
Width="Auto"
Height="Auto"
MouseWheel="ZoomAndPanControl_MouseWheel"
>
<grid>
<grid.rowdefinitions>
<rowdefinition />
<rowdefinition />
</grid.rowdefinitions>
<border x:name="dragZoomBorder" visibility="Collapsed" borderbrush="Black" borderthickness="1" grid.row="0" removed="Silver" cornerradius="1" opacity="0"></border>
<listbox x:name="removed" grid.row="0" removed="White" visibility="Collapsed" itemssource="{Binding Source={x:Static s:DataModel.Instance}, Path=Rectangles}" style="{StaticResource noScrollViewerListBoxStyle}" itemcontainerstyle="{StaticResource listBoxItemStyle}" />
<s:designercanvas focusable="true" xmlns:s="#unknown">
x:Name="MyDesigner"
Background="#f5f5f5"
Margin="0"
FocusVisualStyle="{x:Null}"
MaxWidth="1075"
MaxHeight="661"
Width="537"
Height="330"
ContextMenu="{StaticResource DesignerCanvasContextMenu}">
</s:designercanvas>
</grid>
</zoom:zoomandpancontrol>
</scrollviewer>
</grid>
</grid>
</groupbox>
<gridsplitter focusable="False" width="4" removed="LightGray" grid.column="1" verticalalignment="Stretch" horizontalalignment="Right" />
<!--Sağ Sütun-->
<stackpanel x:name="sagSutun" margin="5,0,0,0" grid.column="2">
<expander header="Şablonlar" isexpanded="True">
<s:sablonlar mousedoubleclick="s_MouseDoubleClick" xmlns:s="#unknown"></s:sablonlar>
</expander>
<expander header="Katmanlar" isexpanded="True">
<listbox height="300" x:name="myList"></listbox>
</expander>
</stackpanel>
</grid>
</grid>
</window>
和我的画布代码
and My Canvas Code
public partial class DesignerCanvas : Canvas
{
private Point? rubberbandSelectionStartPoint = null;
private SelectionService selectionService;
internal SelectionService SelectionService
{
get
{
if (selectionService == null)
selectionService = new SelectionService(this);
return selectionService;
}
}
private Layers layerService;
internal Layers LayerService
{
get
{
if (layerService == null)
layerService = new Layers();
return layerService;
}
}
protected override void OnMouseDown(MouseButtonEventArgs e)
{
base.OnMouseDown(e);
if (e.Source == this)
{
// in case that this click is the start of a
// drag operation we cache the start point
this.rubberbandSelectionStartPoint = new Point?(e.GetPosition(this));
// if you click directly on the canvas all
// selected items are 'de-selected'
SelectionService.ClearSelection();
Focus();
e.Handled = true;
}
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
// if mouse button is not pressed we have no drag operation, ...
if (e.LeftButton != MouseButtonState.Pressed)
this.rubberbandSelectionStartPoint = null;
// ... but if mouse button is pressed and start
// point value is set we do have one
if (this.rubberbandSelectionStartPoint.HasValue)
{
// create rubberband adorner
AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this);
if (adornerLayer != null)
{
RubberbandAdorner adorner = new RubberbandAdorner(this, rubberbandSelectionStartPoint);
if (adorner != null)
{
adornerLayer.Add(adorner);
}
}
}
e.Handled = true;
}
protected override void OnDrop(DragEventArgs e)
{
base.OnDrop(e);
DragObject dragObject = e.Data.GetData(typeof(DragObject)) as DragObject;
if (dragObject != null && !String.IsNullOrEmpty(dragObject.Xaml))
{
DesignerItem newItem = null;
Object content = XamlReader.Load(XmlReader.Create(new StringReader(dragObject.Xaml)));
if (content != null)
{
newItem = new DesignerItem();
newItem.Content = content;
Point position = e.GetPosition(this);
if (dragObject.DesiredSize.HasValue)
{
Size desiredSize = dragObject.DesiredSize.Value;
newItem.Width = desiredSize.Width;
newItem.Height = desiredSize.Height;
DesignerCanvas.SetLeft(newItem, Math.Max(0, position.X - newItem.Width / 2));
DesignerCanvas.SetTop(newItem, Math.Max(0, position.Y - newItem.Height / 2));
}
else
{
DesignerCanvas.SetLeft(newItem, Math.Max(0, position.X));
DesignerCanvas.SetTop(newItem, Math.Max(0, position.Y));
}
newItem.Width = 60;
newItem.Height = 60;
Canvas.SetZIndex(newItem, this.Children.Count);
this.Children.Add(newItem);
//SetConnectorDecoratorTemplate(newItem);
//this.LayerService.KatmanEkle(newItem as DesignerItem);
this.LayerService.Items.Add("asdasd");
//update selection
//this.SelectionService.SelectItem(newItem);
//newItem.Focus();
}
e.Handled = true;
}
}
protected override void OnVisualChildrenChanged(DependencyObject visualAdded, DependencyObject visualRemoved)
{
base.OnVisualChildrenChanged(visualAdded, visualRemoved);
this.LayerService.KatmanEkle(visualAdded as DesignerItem);
}
protected override Size MeasureOverride(Size constraint)
{
Size size = new Size();
foreach (UIElement element in this.InternalChildren)
{
double left = Canvas.GetLeft(element);
double top = Canvas.GetTop(element);
left = double.IsNaN(left) ? 0 : left;
top = double.IsNaN(top) ? 0 : top;
//measure desired size for each child
element.Measure(constraint);
Size desiredSize = element.DesiredSize;
if (!double.IsNaN(desiredSize.Width) && !double.IsNaN(desiredSize.Height))
{
size.Width = Math.Max(size.Width, left + desiredSize.Width);
size.Height = Math.Max(size.Height, top + desiredSize.Height);
}
}
// add margin
size.Width += 10;
size.Height += 10;
return size;
}
我要下载所有项目,只是告诉我如何上传.
再次感谢...
i you want to download all project just tell me how can i upload.
thanks again...
Grid grid = (Grid)Application.Current.MainWindow.Content;
foreach (UIElement item in grid.Children)
{
if (item is Grid)
{
Grid MyGrid = item as Grid;
foreach (UIElement itm in MyGrid.Children)
{
if (itm is StackPanel)
{
StackPanel myStack = itm as StackPanel;
if (myStack.Name == "sagSutun")
{
foreach (UIElement i in myStack.Children)
{
if (i is Expander)
{
Expander exp = i as Expander;
if (exp.Name == "expKatman")
{
ListBox box = exp.Content as ListBox;
box.Items.Add("sadasd");
}
}
}
}
}
}
}
}
这篇关于来自不同类别的访问控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!