मैं बिना किसी सीमा वाले विंडो का उपयोग कर रहा हूं और क्रोम को स्वयं खींच रहा हूं। मैं खिड़की का एक सामान्य तरीके से आकार बदलना चाहता हूं और केंद्र के साथ एक 3x3 ग्रिड परिभाषित किया गया है और संबंधित क्षेत्रों का गठन करने वाले बाहरी कोशिकाओं को अलग-अलग उपचार (टॉपलेफ्ट/टॉपमेडल/टॉपराइट ... आदि) जैसे कि कर्सर की आवश्यकता होती है। अधिकतम करें, छोटा करें, मूव इत्यादि सभी सीधे आगे हैं लेकिन कर्सर खत्म होने वाले सेल के आधार पर मैं विभिन्न दिशाओं में आकार बदलने के लिए कुछ पॉइंटर्स का उपयोग कर सकता हूं।डब्ल्यूपीएफ/एक्सएएमएल: मैं बिना किसी सीमा वाले खिड़की का आकार कैसे लगा सकता हूं?
10
A
उत्तर
6
यह बहुत तंग लगता है। न्यूनतम/अधिकतम चौड़ाई और ऊंचाई के साथ-साथ परिवर्तनीय सीमावर्ती भी हैं। एकमात्र मुद्दा जो मुझे पता है वह है जब कर्सर आंदोलन तेज़ होता है और आकार न्यूनतम 20 मिनट के भीतर होता है, यह ताज़ा दर के कारण कुछ हद तक चिपक जाता है। एक बड़ा सौदा नहीं है लेकिन मैं इसे हल करूंगा।
alt text http://cartesia.pbworks.com/f/1265489984/Resize.png
मैं ठीक से प्रदर्शित करने विंडो टैग प्राप्त ... (बस apostrophe बाहर ले जाना और यह ठीक होना चाहिए।) किसी को भी कोई विचार नहीं कर पा रहे?
XAML
<'Window x:Class="Article_1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Title="Article_1_Resizing"
Background="Transparent" AllowsTransparency="True"
WindowStyle="None" WindowStartupLocation="CenterScreen"
MinHeight="100" Height="400" MaxHeight="600"
MinWidth="100" Width="400" MaxWidth="800">
<Window.Resources>
<SolidColorBrush x:Key="Brush_ChromeBackground" Color="#FFC8D1E0"/>
<SolidColorBrush x:Key="Brush_ChromeBorder" Color="#FFA0A0A0"/>
<sys:Double x:Key="Chrome_BorderWidth">5</sys:Double>
</Window.Resources>
<Border x:Name="Border_Chrome"
BorderBrush="{StaticResource Brush_ChromeBorder}" BorderThickness="1,1,1,1"
CornerRadius="2,2,2,2"
Width="Auto">
<Grid x:Name="Grid" ShowGridLines="False">
<Grid.RowDefinitions>
<RowDefinition x:Name="row_Top" Height="Auto"/>
<RowDefinition x:Name="row_Middle" Height="*"/>
<RowDefinition x:Name="row_Bottom" Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="col_Left" Width="Auto"/>
<ColumnDefinition x:Name="col_Middle" Width="*"/>
<ColumnDefinition x:Name="col_Right" Width="Auto"/>
</Grid.ColumnDefinitions>
<!-- Top Row -->
<Rectangle x:Name="Rectangle_TopLeft"
Grid.Row="0" Grid.Column="0"
Width="{StaticResource Chrome_BorderWidth}" Height="{StaticResource Chrome_BorderWidth}"
Fill="{StaticResource Brush_ChromeBackground}"
Cursor="SizeNWSE"
MouseLeftButtonDown="Resize_Begin" MouseLeftButtonUp="Resize_End"
MouseMove="Resize"/>
<Rectangle x:Name="Rectangle_TopMiddle"
Grid.Row="0" Grid.Column="1"
Height="{StaticResource Chrome_BorderWidth}"
Fill="{StaticResource Brush_ChromeBackground}"
Cursor="SizeNS"
MouseLeftButtonDown="Resize_Begin" MouseLeftButtonUp="Resize_End"
MouseMove="Resize"/>
<Rectangle x:Name="Rectangle_TopRight"
Grid.Row="0" Grid.Column="2"
Width="{StaticResource Chrome_BorderWidth}" Height="{StaticResource Chrome_BorderWidth}"
Fill="{StaticResource Brush_ChromeBackground}"
Cursor="SizeNESW"
MouseLeftButtonDown="Resize_Begin" MouseLeftButtonUp="Resize_End"
MouseMove="Resize"/>
<!-- Middle Row -->
<Rectangle x:Name="Rectangle_MiddleLeft"
Grid.Row="1" Grid.Column="0"
Width="{StaticResource Chrome_BorderWidth}"
Fill="{StaticResource Brush_ChromeBackground}"
Cursor="SizeWE"
MouseLeftButtonDown="Resize_Begin" MouseLeftButtonUp="Resize_End"
MouseMove="Resize"/>
<!-- Content -->
<Label Content="Mouse Down to Move - Double Click to Close"
Grid.Row="1" Grid.Column="1"
Background="White" Foreground="Black"
HorizontalAlignment="Stretch" HorizontalContentAlignment="Center"
VerticalAlignment="Stretch" VerticalContentAlignment="Center"
MouseDoubleClick="_Close"
MouseLeftButtonDown="Move"/>
<Rectangle x:Name="Rectangle_MiddleRight"
Grid.Row="1" Grid.Column="2"
Width="{StaticResource Chrome_BorderWidth}"
Fill="{StaticResource Brush_ChromeBackground}"
Cursor="SizeWE"
MouseLeftButtonDown="Resize_Begin" MouseLeftButtonUp="Resize_End"
MouseMove="Resize"/>
<!-- Bottom Row -->
<Rectangle x:Name="Rectangle_BottomLeft"
Grid.Row="2" Grid.Column="0"
Width="{StaticResource Chrome_BorderWidth}" Height="{StaticResource Chrome_BorderWidth}"
Fill="{StaticResource Brush_ChromeBackground}"
Cursor="SizeNESW"
MouseLeftButtonDown="Resize_Begin" MouseLeftButtonUp="Resize_End"
MouseMove="Resize"/>
<Rectangle x:Name="Rectangle_BottomMiddle"
Grid.Row="2" Grid.Column="1"
Height="{StaticResource Chrome_BorderWidth}"
Fill="{StaticResource Brush_ChromeBackground}"
Cursor="SizeNS"
MouseLeftButtonDown="Resize_Begin" MouseLeftButtonUp="Resize_End"
MouseMove="Resize"/>
<Rectangle x:Name="Rectangle_BottomRight"
Grid.Row="2" Grid.Column="2"
Width="{StaticResource Chrome_BorderWidth}" Height="{StaticResource Chrome_BorderWidth}"
Fill="{StaticResource Brush_ChromeBackground}"
Cursor="SizeNWSE"
MouseLeftButtonDown="Resize_Begin" MouseLeftButtonUp="Resize_End"
MouseMove="Resize"/>
</Grid>
</Border>
</Window>
कोड के पीछे
Partial Public Class Article_1
Public Sub New()
InitializeComponent()
Initialize_Sizes
End Sub
Private isResizing as Boolean = False
Private Const CURSOR_OFFSET_SMALL As Double = 3
Private Const CURSOR_OFFSET_LARGE As Double = 5
Private _x As Double = 0
Private _Y As Double = 0
Private Sub Initialize_Sizes
Dim _MinWidth As Double = Rectangle_MiddleLeft.Width + _
Rectangle_BottomRight.Width + _
border_Chrome.BorderThickness.Left + _
border_Chrome.BorderThickness.Right + 1
If MinWidth < _MinWidth then _
MinWidth = _MinWidth
Dim _MinHeight As Double = Rectangle_TopMiddle.Height + _
Rectangle_BottomMiddle.Height + _
border_Chrome.BorderThickness.top + _
border_Chrome.BorderThickness.Bottom + 1
If MinHeight < _MinHeight then _
MinHeight = _MinHeight
End Sub
Private sub Resize_Begin(sender as object, _
e As MouseEventArgs)
isResizing = True
DirectCast(sender, Rectangle).CaptureMouse
End Sub
Private sub Resize_End(sender as object, _
e As MouseEventArgs)
isResizing = False
DirectCast(sender, Rectangle).ReleaseMouseCapture
End Sub
Private Sub Resize(sender As Object, _
e As MouseEventArgs)
If isResizing = False then Exit Sub
_x = e.GetPosition(me).x
_y = e.GetPosition(me).Y
Select Case DirectCast(sender, Rectangle).Name
Case "Rectangle_TopLeft" : Resize_Width_Left
Resize_Height_Top
Case "Rectangle_TopMiddle" : Resize_Height_Top
Case "Rectangle_TopRight" : Resize_Width_Right
Resize_Height_Top
Case "Rectangle_MiddleLeft" : Resize_Width_Left
Case "Rectangle_MiddleRight" : Resize_Width_Right
Case "Rectangle_BottomLeft" : Resize_Width_Left
Resize_Height_Bottom
Case "Rectangle_BottomMiddle" : Resize_Height_Bottom
Case "Rectangle_BottomRight" : Resize_Width_Right
Resize_Height_Bottom
Case else : MessageBox.Show("Error in Resize")
End Select
End Sub
Private Sub Resize_Width_Left
_x -= CURSOR_OFFSET_SMALL
If Width - _x >= MinWidth Then
If Width - _x <= MaxWidth then
Width -= _x
Left += _x
End If
End If
End Sub
Private Sub Resize_Width_Right
_x += CURSOR_OFFSET_LARGE
Select Case _x
Case Is < MinWidth : width = MinWidth
Case Is > MaxWidth : Width = MaxWidth
Case Else : Width = _x
End Select
End Sub
Private Sub Resize_Height_Top
_y -= CURSOR_OFFSET_SMALL
If Height - _y >= MinHeight Then
If Height - _y <= MaxHeight then
Height -= _y
Top += _y
End If
End If
End Sub
Private Sub Resize_Height_Bottom
_y += CURSOR_OFFSET_SMALL
Select Case _y
Case Is < MinHeight : Height = MinHeight
Case Is > MaxHeight : Height = MaxHeight
Case Else : Height = _y
End Select
End Sub
Private Sub Move(ByVal sender As Object, _
ByVal e As System.Windows.Input.MouseButtonEventArgs)
Dim curs As Cursor = Cursor
Cursor = Cursors.SizeAll
DragMove()
Cursor = Curs
End Sub
Private Sub _Close()
Close
End Sub
End Class
2
एक minimalist दृष्टिकोण के लिए,
- Brush_ChromeBackground रंग करने के लिए "पारदर्शी" सेट करें। यह ड्रैग आयताकार अदृश्य बनाता है।
- विंडो का ResizeMode "NoResize" पर सेट करें। यह खिड़की के चारों ओर ग्रे bevelled किनारे छुपाता है, केवल 1px Border_Chrome छोड़कर।
इसके अलावा, मैं सी # करने के लिए कोड-पीछे अनुवाद:
public partial class Article_1 : Window
{
private bool _isResizing = false;
private const double CURSOR_OFFSET_SMALL = 3;
private const double CURSOR_OFFSET_LARGE = 5;
public Article_1()
{
InitializeComponent();
MinWidth = Math.Max(MinWidth, Rectangle_MiddleLeft.Width + Rectangle_MiddleRight.Width + 10);
MinHeight = Math.Max(MinHeight, Rectangle_TopMiddle.Height + Rectangle_BottomMiddle.Height + 10);
}
private void Resize_Begin(object sender, MouseButtonEventArgs e)
{
if (sender is Rectangle)
{
_isResizing = true;
((Rectangle)sender).CaptureMouse();
}
}
private void Resize_End(object sender, MouseButtonEventArgs e)
{
if (sender is Rectangle)
{
_isResizing = false;
((Rectangle)sender).ReleaseMouseCapture();
}
}
private void Resize(object sender, MouseEventArgs e)
{
if (_isResizing && (sender is Rectangle))
{
double x = e.GetPosition(this).X;
double y = e.GetPosition(this).Y;
string mode = ((Rectangle)sender).Name.ToLower();
if (mode.Contains("left"))
{
x -= CURSOR_OFFSET_SMALL;
if ((Width - x >= MinWidth) && (Width - x <= MaxWidth))
{
Width -= x;
Left += x;
}
}
if (mode.Contains("right"))
{
Width = Math.Max(MinWidth, Math.Min(MaxWidth, x + CURSOR_OFFSET_LARGE));
}
if (mode.Contains("top"))
{
y -= CURSOR_OFFSET_SMALL;
if ((Height - y >= MinHeight) && (Height - y <= MaxHeight))
{
Height -= y;
Top += y;
}
}
if (mode.Contains("bottom"))
{
Height = Math.Max(MinHeight, Math.Min(MaxHeight, y + CURSOR_OFFSET_SMALL));
}
}
}
private void Move(object sender, MouseButtonEventArgs e)
{
Cursor old = Cursor;
Cursor = Cursors.SizeAll;
DragMove();
Cursor = old;
}
private void Close(object sender, MouseButtonEventArgs e)
{
Close();
}
}
संबंधित मुद्दे
- 1. मैं चेकसम एल्गोरिदम का अनुमान कैसे लगा सकता हूं?
- 2. मैं चेकसम एल्गोरिदम का अनुमान कैसे लगा सकता हूं?
- 3. मैं कैसे पता लगा सकता हूं कि मेरी खिड़की WxPython के साथ कम हो गई है?
- 4. मैं कैसे पता लगा सकता हूं कि बिना किसी देरी के जावा नेटवर्क कनेक्ट नहीं है?
- 5. मैं COM ऑब्जेक्ट लागू करने वाले सभी इंटरफेस का पता कैसे लगा सकता हूं?
- 6. आईफोन - मैं आईफोन संस्करण का पता कैसे लगा सकता हूं?
- 7. डब्ल्यूसीएफ: मैं संदेश निकायों का पता कैसे लगा सकता हूं?
- 8. मैं गैर-पश्चिमी पात्रों का पता कैसे लगा सकता हूं?
- 9. मैं टेक्स्ट फ़ॉन्ट की रूपरेखा कैसे लगा सकता हूं?
- 10. मैं jQuery के साथ विंडो आकार का पता कैसे लगा सकता हूं?
- 11. मैं सेवा विज्ञापन आयामों का पता कैसे लगा सकता हूं
- 12. मैं स्रोत के बिना किसी छवि के चारों ओर सीमा को कैसे हटा सकता हूं?
- 13. मैं ओरेकल इंडेक्स के आकार का अनुमान कैसे लगा सकता हूं?
- 14. मैं कैसे अनुमान लगा सकता हूं "क्या आपका मतलब था?" Google का उपयोग किए बिना?
- 15. मैं जावास्क्रिप्ट लाइब्रेरी के बिना एक संक्रमण अंत का पता कैसे लगा सकता हूं?
- 16. मैं स्कैला में डेटा संरचना के आकार का अनुमान कैसे लगा सकता हूं?
- 17. क्या मैं Emacs में डिस्प्ले आकार/रिज़ॉल्यूशन का पता लगा सकता हूं?
- 18. मैं जावास्क्रिप्ट में विंडो आकार बदलने वाले ईवेंट श्रोता को कैसे संलग्न कर सकता हूं?
- 19. मैं cocos2d में स्पर्श का पता कैसे लगा सकता हूं?
- 20. मैं सी में पैलिंड्रोम का पता कैसे लगा सकता हूं?
- 21. मैं फ़ाइल के एन्कोडिंग का पता कैसे लगा सकता हूं?
- 22. एनएसआईएस - मैं चुप इंस्टॉल का पता कैसे लगा सकता हूं?
- 23. मैं सी ++ स्ट्रिंग में "_" का पता कैसे लगा सकता हूं?
- 24. मैं rel = "noreferrer" समर्थन का पता कैसे लगा सकता हूं?
- 25. मैं किसी वेबसाइट पर माउस के अस्तित्व का पता कैसे लगा सकता हूं?
- 26. मैं खिड़की पर नियंत्रण कैसे ओवरले कर सकता हूं?
- 27. मैं कैसे पता लगा सकता हूं कि वीबी.Net DataRow
- 28. खिड़की के आकार का आकार बदलना
- 29. खिड़की का आकार बदलना Win32
- 30. मैं एक बटन का आकार कैसे सेट कर सकता हूं?
धन्यवाद ehartwell! – Brad